meshy-node 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,256 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-whvYFVNX.js","assets/index-CYzyOxWi.js","assets/index-B6ZKt9Yk.css","assets/file-BcHgn-IP.js","assets/PreviewTab-Dmb7EJl7.js","assets/DiffTab-C9xK4VcC.js"])))=>i.map(i=>d[i]);
2
+ import{c as G,r as i,j as r,R as go,a as oc,b as En,u as le,d as ac,e as U,f as ic,g as lc,h as cc,B as Ee,i as K,k as it,l as vo,m as dc,n as uc,t as pe,T as bo,P as fc,_ as Dr,o as mc,N as yo,p as wo,q as pc,s as hc,v as xc,w as gc,x as vc,y as bc,z as yc,A as wc,C as Nc,D as jc,E as kc,F as Cc,G as Sc,H as Ec,I as Ac,J as Tc,K as Rc,L as _c}from"./index-CYzyOxWi.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 Pc=[["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"}]],Dc=G("archive",Pc);/**
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 Mc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Oc=G("arrow-up",Mc);/**
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 Ic=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Mr=G("bot",Ic);/**
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 Lc=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],$c=G("brain",Lc);/**
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 Fc=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],He=G("check",Fc);/**
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 Bc=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Tt=G("chevron-down",Bc);/**
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 Uc=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Or=G("chevron-right",Uc);/**
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 Wc=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ir=G("chevron-up",Wc);/**
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 Vc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],zc=G("circle-question-mark",Vc);/**
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 Hc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Kc=G("circle-x",Hc);/**
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 qc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Gc=G("circle",qc);/**
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 Yc=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],An=G("copy",Yc);/**
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 Xc=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],No=G("external-link",Xc);/**
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 Jc=[["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"}]],Zc=G("flag",Jc);/**
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 Qc=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],ed=G("folder-tree",Qc);/**
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 td=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],nd=G("folder",td);/**
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 rd=[["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"}]],sd=G("funnel",rd);/**
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 od=[["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"}]],ad=G("globe",od);/**
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 id=[["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"}]],ld=G("history",id);/**
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 cd=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],fr=G("image-plus",cd);/**
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 dd=[["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"}]],ud=G("laptop",dd);/**
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 fd=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],md=G("list-checks",fd);/**
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 pd=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],je=G("loader-circle",pd);/**
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 hd=[["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"}]],jo=G("message-square-plus",hd);/**
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 xd=[["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"}]],ko=G("panel-left-close",xd);/**
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 gd=[["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"}]],vd=G("panel-left-open",gd);/**
133
+ * @license lucide-react v1.7.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */const bd=[["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"}]],Co=G("panel-right-close",bd);/**
138
+ * @license lucide-react v1.7.0 - ISC
139
+ *
140
+ * This source code is licensed under the ISC license.
141
+ * See the LICENSE file in the root directory of this source tree.
142
+ */const yd=[["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"}]],wd=G("panel-right-open",yd);/**
143
+ * @license lucide-react v1.7.0 - ISC
144
+ *
145
+ * This source code is licensed under the ISC license.
146
+ * See the LICENSE file in the root directory of this source tree.
147
+ */const Nd=[["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"}]],Lr=G("pencil",Nd);/**
148
+ * @license lucide-react v1.7.0 - ISC
149
+ *
150
+ * This source code is licensed under the ISC license.
151
+ * See the LICENSE file in the root directory of this source tree.
152
+ */const jd=[["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"}]],kd=G("rotate-ccw",jd);/**
153
+ * @license lucide-react v1.7.0 - ISC
154
+ *
155
+ * This source code is licensed under the ISC license.
156
+ * See the LICENSE file in the root directory of this source tree.
157
+ */const Cd=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ts=G("search",Cd);/**
158
+ * @license lucide-react v1.7.0 - ISC
159
+ *
160
+ * This source code is licensed under the ISC license.
161
+ * See the LICENSE file in the root directory of this source tree.
162
+ */const Sd=[["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"}]],So=G("send",Sd);/**
163
+ * @license lucide-react v1.7.0 - ISC
164
+ *
165
+ * This source code is licensed under the ISC license.
166
+ * See the LICENSE file in the root directory of this source tree.
167
+ */const Ed=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Ad=G("shield-alert",Ed);/**
168
+ * @license lucide-react v1.7.0 - ISC
169
+ *
170
+ * This source code is licensed under the ISC license.
171
+ * See the LICENSE file in the root directory of this source tree.
172
+ */const Td=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Rd=G("shield-check",Td);/**
173
+ * @license lucide-react v1.7.0 - ISC
174
+ *
175
+ * This source code is licensed under the ISC license.
176
+ * See the LICENSE file in the root directory of this source tree.
177
+ */const _d=[["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"}]],Pd=G("sliders-horizontal",_d);/**
178
+ * @license lucide-react v1.7.0 - ISC
179
+ *
180
+ * This source code is licensed under the ISC license.
181
+ * See the LICENSE file in the root directory of this source tree.
182
+ */const Dd=[["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"}]],Md=G("trash-2",Dd);/**
183
+ * @license lucide-react v1.7.0 - ISC
184
+ *
185
+ * This source code is licensed under the ISC license.
186
+ * See the LICENSE file in the root directory of this source tree.
187
+ */const Od=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Id=G("user",Od);/**
188
+ * @license lucide-react v1.7.0 - ISC
189
+ *
190
+ * This source code is licensed under the ISC license.
191
+ * See the LICENSE file in the root directory of this source tree.
192
+ */const Ld=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Eo=G("wrench",Ld);/**
193
+ * @license lucide-react v1.7.0 - ISC
194
+ *
195
+ * This source code is licensed under the ISC license.
196
+ * See the LICENSE file in the root directory of this source tree.
197
+ */const $d=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],kt=G("x",$d),Fd=new Set(["assigned","running"]);function Bd(e,t){return e.reduce((n,s)=>s.assignedTo===t&&Fd.has(s.status)?n+1:n,0)}function Rt(e){return(e==null?void 0:e.toLowerCase())==="devtunnel"}function Ud(e){return e?Rt(e)?"DevTunnel":e.charAt(0).toUpperCase()+e.slice(1):"Direct"}function $r(e,t){return Rt(t??e.transportType)||!!e.devtunnelEndpoint}function Ao(e,t){return!Rt(t??e.transportType)}function To(e,t){const n=t??e.transportType;return Rt(n)?"DevTunnel":e.devtunnelEndpoint?"Direct + DevTunnel":Ud(n)}function Rs(e,t){return!e&&!t}function Wd({routeTaskId:e,creatingTask:t,internalSelectedTaskId:n,sortedTaskIds:s}){return e||(t?null:n??s[0]??null)}function Vd(e,t){return[t,...e.filter(n=>n.id!==t.id)]}const zd=new Set(["completed","failed","cancelled","archived"]);function Hd(e,t){const n=new Set(t);return new Set(Array.from(e).filter(s=>n.has(s)))}function Kd(e,t){const n=new Set(t);if(n.size===0)return!1;const s=e.filter(o=>n.has(o.id));return s.length===n.size&&s.every(o=>zd.has(o.status))}function qd(e,t){var s;const n=new Set(t);return((s=e.find(o=>!n.has(o.id)))==null?void 0:s.id)??null}function un(e){return typeof e=="object"&&e!==null}function Gd(e){if(!un(e))return null;if(e.type==="text"&&typeof e.text=="string"){const t=e.text.trim();return t?{type:"text",text:t}:null}if(e.type==="image"&&typeof e.mediaType=="string"&&typeof e.data=="string"){const t=e.mediaType.trim(),n=e.data;return!t||!n?null:{type:"image",mediaType:t,data:n,...typeof e.filename=="string"&&e.filename.trim()?{filename:e.filename.trim()}:{}}}if(e.type==="tool_result"&&typeof e.toolUseId=="string"&&typeof e.content=="string"){const t=e.toolUseId.trim(),n=e.content.trim();return!t||!n?null:{type:"tool_result",toolUseId:t,content:n,...typeof e.isError=="boolean"?{isError:e.isError}:{}}}return null}function Yd(e){if(!un(e))return null;if(e.type==="text"&&typeof e.text=="string"){const s=e.text.trim();return s?{type:"text",text:s}:null}if(e.type!=="image"||!un(e.source)){if(e.type==="tool_result"&&typeof e.tool_use_id=="string"&&typeof e.content=="string"){const s=e.tool_use_id.trim(),o=e.content.trim();return!s||!o?null:{type:"tool_result",toolUseId:s,content:o,...typeof e.is_error=="boolean"?{isError:e.is_error}:{}}}return null}const t=typeof e.source.media_type=="string"?e.source.media_type.trim():"",n=typeof e.source.data=="string"?e.source.data:"";return!t||!n?null:{type:"image",mediaType:t,data:n}}function $t(e){if(typeof e=="string"){const t=e.trim();return t?[{type:"text",text:t}]:[]}return Array.isArray(e)?e.map(t=>Gd(t)??Yd(t)).filter(t=>t!==null):[]}function Ro(e,t){const n=e.trim();return[...n?[{type:"text",text:n}]:[],...t]}function Xd(e){return{role:"user",content:e.map(t=>t.type==="text"?{type:"text",text:t.text}:t.type==="tool_result"?{type:"tool_result",tool_use_id:t.toolUseId,content:t.content,...typeof t.isError=="boolean"?{is_error:t.isError}:{}}:{type:"image",source:{type:"base64",media_type:t.mediaType,data:t.data}})}}function Jn(e,t=new Date().toISOString()){return{type:"user",message:Xd(e),timestamp:t}}function Kt(e){if(e.type!=="user"||e.isSynthetic===!0)return null;if(typeof e.message=="string"){const t=$t(e.message);return t.length>0?t:null}if(un(e.message)&&Array.isArray(e.message.content)){const t=$t(e.message.content);return t.length>0?t:null}if(Array.isArray(e.content)){const t=$t(e.content);return t.length>0?t:null}return null}function Jd(e){return $t(e.payload.initialMessage)}function Bt(e){return e.map(t=>{if(t.type==="text")return`t:${t.text}`;if(t.type==="tool_result")return`r:${t.toolUseId}:${t.isError===!0?"1":"0"}:${t.content}`;const n=t.data.slice(0,32),s=t.data.slice(-32);return`i:${t.mediaType}:${t.data.length}:${n}:${s}`}).join("|")}function Zd(e){return e.map(t=>t.type==="text"?t.text:t.type==="tool_result"?t.content:"").filter(Boolean).join(`
198
+ `)}function Fr(e){return`data:${e.mediaType};base64,${e.data}`}function Qd(e){var o,a;if(!e)return[];const t=[],n=e.items;if(n)for(const l of Array.from(n)){if((l==null?void 0:l.kind)!=="file"||!((o=l.type)!=null&&o.startsWith("image/")))continue;const c=(a=l.getAsFile)==null?void 0:a.call(l);c&&c.type.startsWith("image/")&&t.push(c)}if(t.length>0)return t;const s=e.files;return s?Array.from(s).filter(l=>l.type.startsWith("image/")):[]}function eu(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{if(typeof s.result!="string"){n(new Error(`Failed to read ${e.name}`));return}t(s.result)},s.onerror=()=>n(s.error??new Error(`Failed to read ${e.name}`)),s.readAsDataURL(e)})}async function _s(e){return Promise.all(Array.from(e).map(async t=>{if(!t.type.startsWith("image/"))throw new Error(`${t.name} is not an image`);const n=await eu(t),s=n.indexOf(",");if(s===-1)throw new Error(`Failed to parse ${t.name}`);return{type:"image",mediaType:t.type||"image/png",data:n.slice(s+1),filename:t.name}}))}function qt(e){return typeof e=="object"&&e!==null}function tu(e){return qt(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function nu(e){return!qt(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function ru(e){if(!qt(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(nu).filter(n=>n!==null):[];return t.length===0?null:{header:typeof e.header=="string"&&e.header.trim()?e.header.trim():void 0,question:e.question.trim(),multiSelect:e.multiSelect===!0,options:t}}function mr(e){if(!qt(e)||!Array.isArray(e.questions))return null;const t=e.questions.map(ru).filter(n=>n!==null);return t.length===0?null:{questions:t}}function _t(e){return JSON.stringify({questions:e.questions})}function Tn(e){const t=mr(e);if(t)return t;if(tu(e)){const n=qt(e.input)?e.input:void 0,s=mr(n);return s?{...s,...typeof e.id=="string"&&e.id.trim()?{toolUseId:e.id.trim()}:{}}:null}return null}function su(e){var o;const t=e.trim();if(!t)return[];const n=[t],s=t.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi);for(const a of s){const l=(o=a[1])==null?void 0:o.trim();l&&n.push(l)}return n}function Rn(e){for(const t of su(e))try{const n=JSON.parse(t),s=mr(n);if(s)return s}catch{}return null}function ou(e){return e.questions.map(t=>t.options.length>0?[0]:[])}function au(e,t){return e.questions.every((n,s)=>(t[s]??[]).length>0)}function iu(e,t){const s=e.questions.map((o,a)=>{const l=[...new Set(t[a]??[])].sort((c,d)=>c-d).filter(c=>o.options[c]!==void 0);return{header:o.header??null,question:o.question,multiSelect:o.multiSelect,selectedOptions:l.map(c=>o.options[c]).filter(c=>c!==void 0)}}).map(o=>{const a=o.header??o.question,l=o.selectedOptions.map(c=>c.label).join(o.multiSelect?", ":"");return`${a}: ${l}`}).join(`
199
+ `);return e.toolUseId?[{type:"tool_result",toolUseId:e.toolUseId,content:s,isError:!1}]:[{type:"text",text:s}]}function Ut(e){return typeof e=="object"&&e!==null}function lu(e){if(!e)return;const t=["file_path","path","command"].map(n=>e[n]).find(n=>typeof n=="string"&&n.trim().length>0);return t==null?void 0:t.trim()}function cu(e){const t=e.toLowerCase();return t.includes(" permission to write ")?"Write":t.includes(" permission to edit ")?"Edit":t.includes(" permission to run ")||t.includes(" permission to execute ")?"Bash":"Action"}function pr(e){const t=e.trim();if(!t.startsWith("Awaiting your permission to "))return null;const n=t.match(/`([^`]+)`/);return{requests:[{toolName:cu(t),target:n==null?void 0:n[1],summary:t}]}}function du(e){if(!Array.isArray(e.permission_denials))return null;const t=[];for(const n of e.permission_denials){if(!Ut(n)||typeof n.tool_name!="string")continue;const s=Ut(n.tool_input)?n.tool_input:void 0,o=lu(s),a=typeof e.result=="string"&&e.result.trim().length>0?e.result.trim():`Awaiting your permission to use ${n.tool_name}${o?` on \`${o}\``:""}.`;t.push({toolName:n.tool_name,...typeof n.tool_use_id=="string"?{toolUseId:n.tool_use_id}:{},...o?{target:o}:{},summary:a})}return t.length>0?{requests:t}:null}function Ps(e){if(!Array.isArray(e))return null;for(const t of e){if(!Ut(t)||t.type!=="text"||typeof t.text!="string")continue;const n=pr(t.text);if(n)return n}return null}function Br(e){if(!Ut(e))return null;const t=du(e);if(t)return t;if(typeof e.result=="string"){const s=pr(e.result);if(s)return s}if(typeof e.message=="string"){const s=pr(e.message);if(s)return s}if(Ut(e.message)){const s=Br(e.message);if(s)return s;const o=Ps(e.message.content);if(o)return o}const n=Ps(e.content);return n||null}function uu(e){return JSON.stringify(e.requests.map(t=>({toolName:t.toolName,target:t.target??null,summary:t.summary})))}function fu(e,t){return e.requests.map(n=>{const s=n.target?` for \`${n.target}\``:"",o=t==="approve"?`Approved. Proceed with the requested ${n.toolName} action${s}.`:`Denied. Do not proceed with the requested ${n.toolName} action${s}. Ask for another approach if needed.`;return n.toolUseId?{type:"tool_result",toolUseId:n.toolUseId,content:o,isError:t==="deny"}:t==="approve"?{type:"text",text:o}:{type:"text",text:o}})}function _o(e){return Kt(e)!==null}function fn(e){if(e.type==="user"){const t=Kt(e),n=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${n}:${Bt(t)}`}return JSON.stringify(e)}function hr(e){const t=Tn(e);return t?`question:${_t(t)}`:null}function mu(e){const t=Br(e);return t?`permission:${uu(t)}`:null}function Ds(e){if(!Array.isArray(e))return null;const t=new Set;for(const n of e){const s=hr(n);if(s){t.add(s);continue}if(typeof n=="object"&&n!==null&&n.type==="text"&&typeof n.text=="string"){const o=Rn(n.text);o&&t.add(_t(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function pu(e){const t=hr(e);if(t)return t;if(typeof e.message=="string"){const n=Rn(e.message);return n?_t(n):null}if(typeof e.message=="object"&&e.message!==null){const n=hr(e.message);return n||Ds(e.message.content)}return Ds(e.content)}function hu(e){return mu(e)}function xu(e,t,n){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${n}`}function gu(e,t){const n=t.map(o=>({...o})),s=new Set(n.map(fn));for(const o of e){const a=fn(o);s.has(a)||(n.push(o),s.add(a))}return n}function vu(e,t){const n=fn(t);return e.some(s=>fn(s)===n)?e:[...e,{...t}]}function bu(e,t){const n=new Map;for(const s of t){const o=Kt(s);if(!o)continue;const a=Bt(o);n.set(a,(n.get(a)??0)+1)}return e.filter(s=>{const o=Bt(s.content),a=n.get(o)??0;return a<=0?!0:(n.set(o,a-1),!1)})}function yu(e,t){const n=Bt(t),s=e.findIndex(o=>Bt(o.content)===n);return s===-1?e:e.filter((o,a)=>a!==s)}function wu(e){return e.some(_o)}function Nu(e){const t=[];let n=null;for(const s of e){if(_o(s)){n=null,t.push(s);continue}const o=hu(s)??pu(s);o&&o===n||(t.push(s),o&&(n=o))}return t}function Z(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function ju(e,t){const n=i.createContext(t),s=a=>{const{children:l,...c}=a,d=i.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:d,children:l})};s.displayName=e+"Provider";function o(a){const l=i.useContext(n);if(l)return l;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[s,o]}function rt(e,t=[]){let n=[];function s(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const f=m=>{var b;const{scope:h,children:x,...g}=m,p=((b=h==null?void 0:h[e])==null?void 0:b[d])||c,v=i.useMemo(()=>g,Object.values(g));return r.jsx(p.Provider,{value:v,children:x})};f.displayName=a+"Provider";function u(m,h){var p;const x=((p=h==null?void 0:h[e])==null?void 0:p[d])||c,g=i.useContext(x);if(g)return g;if(l!==void 0)return l;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[f,u]}const o=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=(c==null?void 0:c[e])||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,ku(o,...t)]}function ku(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const l=s.reduce((c,{useScope:d,scopeName:f})=>{const m=d(a)[`__scope${f}`];return{...c,...m}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}var ye=globalThis!=null&&globalThis.document?i.useLayoutEffect:()=>{},Cu=go[" useId ".trim().toString()]||(()=>{}),Su=0;function Ze(e){const[t,n]=i.useState(Cu());return ye(()=>{n(s=>s??String(Su++))},[e]),e||(t?`radix-${t}`:"")}var Eu=go[" useInsertionEffect ".trim().toString()]||ye;function Ct({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,l]=Au({defaultProp:t,onChange:n}),c=e!==void 0,d=c?e:o;{const u=i.useRef(e!==void 0);i.useEffect(()=>{const m=u.current;m!==c&&console.warn(`${s} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=c},[c,s])}const f=i.useCallback(u=>{var m;if(c){const h=Tu(u)?u(e):u;h!==e&&((m=l.current)==null||m.call(l,h))}else a(u)},[c,e,a,l]);return[d,f]}function Au({defaultProp:e,onChange:t}){const[n,s]=i.useState(e),o=i.useRef(n),a=i.useRef(t);return Eu(()=>{a.current=t},[t]),i.useEffect(()=>{var l;o.current!==n&&((l=a.current)==null||l.call(a,n),o.current=n)},[n,o]),[n,s,a]}function Tu(e){return typeof e=="function"}function Wt(e){const t=Ru(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),d=c.find(Pu);if(d){const f=d.props.children,u=c.map(m=>m===d?i.Children.count(f)>1?i.Children.only(null):i.isValidElement(f)?f.props.children:null:m);return r.jsx(t,{...l,ref:o,children:i.isValidElement(f)?i.cloneElement(f,void 0,u):null})}return r.jsx(t,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Ru(e){const t=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=Mu(o),c=Du(a,o.props);return o.type!==i.Fragment&&(c.ref=s?oc(s,l):l),i.cloneElement(o,c)}return i.Children.count(o)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Po=Symbol("radix.slottable");function _u(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Po,t}function Pu(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Po}function Du(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Mu(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Ou=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Q=Ou.reduce((e,t)=>{const n=Wt(`Primitive.${t}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Iu(e,t){e&&En.flushSync(()=>e.dispatchEvent(t))}function et(e){const t=i.useRef(e);return i.useEffect(()=>{t.current=e}),i.useMemo(()=>(...n)=>{var s;return(s=t.current)==null?void 0:s.call(t,...n)},[])}function Lu(e,t=globalThis==null?void 0:globalThis.document){const n=et(e);i.useEffect(()=>{const s=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var $u="DismissableLayer",xr="dismissableLayer.update",Fu="dismissableLayer.pointerDownOutside",Bu="dismissableLayer.focusOutside",Ms,Do=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ur=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...d}=e,f=i.useContext(Do),[u,m]=i.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=i.useState({}),g=le(t,k=>m(k)),p=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=p.indexOf(v),y=u?p.indexOf(u):-1,w=f.layersWithOutsidePointerEventsDisabled.size>0,j=y>=b,C=Vu(k=>{const A=k.target,R=[...f.branches].some(D=>D.contains(A));!j||R||(o==null||o(k),l==null||l(k),k.defaultPrevented||c==null||c())},h),S=zu(k=>{const A=k.target;[...f.branches].some(D=>D.contains(A))||(a==null||a(k),l==null||l(k),k.defaultPrevented||c==null||c())},h);return Lu(k=>{y===f.layers.size-1&&(s==null||s(k),!k.defaultPrevented&&c&&(k.preventDefault(),c()))},h),i.useEffect(()=>{if(u)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Ms=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),Os(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ms)}},[u,h,n,f]),i.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),Os())},[u,f]),i.useEffect(()=>{const k=()=>x({});return document.addEventListener(xr,k),()=>document.removeEventListener(xr,k)},[]),r.jsx(Q.div,{...d,ref:g,style:{pointerEvents:w?j?"auto":"none":void 0,...e.style},onFocusCapture:Z(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Z(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Z(e.onPointerDownCapture,C.onPointerDownCapture)})});Ur.displayName=$u;var Uu="DismissableLayerBranch",Wu=i.forwardRef((e,t)=>{const n=i.useContext(Do),s=i.useRef(null),o=le(t,s);return i.useEffect(()=>{const a=s.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(Q.div,{...e,ref:o})});Wu.displayName=Uu;function Vu(e,t=globalThis==null?void 0:globalThis.document){const n=et(e),s=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let d=function(){Mo(Fu,n,f,{discrete:!0})};const f={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);s.current=!1},l=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(l),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function zu(e,t=globalThis==null?void 0:globalThis.document){const n=et(e),s=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!s.current&&Mo(Bu,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function Os(){const e=new CustomEvent(xr);document.dispatchEvent(e)}function Mo(e,t,n,{discrete:s}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),s?Iu(o,a):o.dispatchEvent(a)}var Zn="focusScope.autoFocusOnMount",Qn="focusScope.autoFocusOnUnmount",Is={bubbles:!1,cancelable:!0},Hu="FocusScope",Wr=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,d]=i.useState(null),f=et(o),u=et(a),m=i.useRef(null),h=le(t,p=>d(p)),x=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(s){let p=function(w){if(x.paused||!c)return;const j=w.target;c.contains(j)?m.current=j:Ye(m.current,{select:!0})},v=function(w){if(x.paused||!c)return;const j=w.relatedTarget;j!==null&&(c.contains(j)||Ye(m.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&Ye(c)};document.addEventListener("focusin",p),document.addEventListener("focusout",v);const y=new MutationObserver(b);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v),y.disconnect()}}},[s,c,x.paused]),i.useEffect(()=>{if(c){$s.add(x);const p=document.activeElement;if(!c.contains(p)){const b=new CustomEvent(Zn,Is);c.addEventListener(Zn,f),c.dispatchEvent(b),b.defaultPrevented||(Ku(Ju(Oo(c)),{select:!0}),document.activeElement===p&&Ye(c))}return()=>{c.removeEventListener(Zn,f),setTimeout(()=>{const b=new CustomEvent(Qn,Is);c.addEventListener(Qn,u),c.dispatchEvent(b),b.defaultPrevented||Ye(p??document.body,{select:!0}),c.removeEventListener(Qn,u),$s.remove(x)},0)}}},[c,f,u,x]);const g=i.useCallback(p=>{if(!n&&!s||x.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,b=document.activeElement;if(v&&b){const y=p.currentTarget,[w,j]=qu(y);w&&j?!p.shiftKey&&b===j?(p.preventDefault(),n&&Ye(w,{select:!0})):p.shiftKey&&b===w&&(p.preventDefault(),n&&Ye(j,{select:!0})):b===y&&p.preventDefault()}},[n,s,x.paused]);return r.jsx(Q.div,{tabIndex:-1,...l,ref:h,onKeyDown:g})});Wr.displayName=Hu;function Ku(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Ye(s,{select:t}),document.activeElement!==n)return}function qu(e){const t=Oo(e),n=Ls(t,e),s=Ls(t.reverse(),e);return[n,s]}function Oo(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ls(e,t){for(const n of e)if(!Gu(n,{upTo:t}))return n}function Gu(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Yu(e){return e instanceof HTMLInputElement&&"select"in e}function Ye(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yu(e)&&t&&e.select()}}var $s=Xu();function Xu(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Fs(e,t),e.unshift(t)},remove(t){var n;e=Fs(e,t),(n=e[0])==null||n.resume()}}}function Fs(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Ju(e){return e.filter(t=>t.tagName!=="A")}var Zu="Portal",Vr=i.forwardRef((e,t)=>{var c;const{container:n,...s}=e,[o,a]=i.useState(!1);ye(()=>a(!0),[]);const l=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?ac.createPortal(r.jsx(Q.div,{...s,ref:t}),l):null});Vr.displayName=Zu;function Qu(e,t){return i.useReducer((n,s)=>t[n][s]??n,e)}var Pt=e=>{const{present:t,children:n}=e,s=ef(t),o=typeof n=="function"?n({present:s.isPresent}):i.Children.only(n),a=le(s.ref,tf(o));return typeof n=="function"||s.isPresent?i.cloneElement(o,{ref:a}):null};Pt.displayName="Presence";function ef(e){const[t,n]=i.useState(),s=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),l=e?"mounted":"unmounted",[c,d]=Qu(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const f=en(s.current);a.current=c==="mounted"?f:"none"},[c]),ye(()=>{const f=s.current,u=o.current;if(u!==e){const h=a.current,x=en(f);e?d("MOUNT"):x==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(u&&h!==x?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),ye(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,m=x=>{const p=en(s.current).includes(CSS.escape(x.animationName));if(x.target===t&&p&&(d("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},h=x=>{x.target===t&&(a.current=en(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:i.useCallback(f=>{s.current=f?getComputedStyle(f):null,n(f)},[])}}function en(e){return(e==null?void 0:e.animationName)||"none"}function tf(e){var s,o;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var er=0;function Io(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Bs()),document.body.insertAdjacentElement("beforeend",e[1]??Bs()),er++,()=>{er===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),er--}},[])}function Bs(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Le=function(){return Le=Object.assign||function(t){for(var n,s=1,o=arguments.length;s<o;s++){n=arguments[s];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Le.apply(this,arguments)};function Lo(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n}function nf(e,t,n){if(n||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}var an="right-scroll-bar-position",ln="width-before-scroll-bar",rf="with-scroll-bars-hidden",sf="--removed-body-scroll-bar-size";function tr(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function of(e,t){var n=i.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var o=n.value;o!==s&&(n.value=s,n.callback(s,o))}}}})[0];return n.callback=t,n.facade}var af=typeof window<"u"?i.useLayoutEffect:i.useEffect,Us=new WeakMap;function lf(e,t){var n=of(null,function(s){return e.forEach(function(o){return tr(o,s)})});return af(function(){var s=Us.get(n);if(s){var o=new Set(s),a=new Set(e),l=n.current;o.forEach(function(c){a.has(c)||tr(c,null)}),a.forEach(function(c){o.has(c)||tr(c,l)})}Us.set(n,e)},[e]),n}function cf(e){return e}function df(e,t){t===void 0&&(t=cf);var n=[],s=!1,o={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var l=t(a,s);return n.push(l),function(){n=n.filter(function(c){return c!==l})}},assignSyncMedium:function(a){for(s=!0;n.length;){var l=n;n=[],l.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){s=!0;var l=[];if(n.length){var c=n;n=[],c.forEach(a),l=n}var d=function(){var u=l;l=[],u.forEach(a)},f=function(){return Promise.resolve().then(d)};f(),n={push:function(u){l.push(u),f()},filter:function(u){return l=l.filter(u),n}}}};return o}function uf(e){e===void 0&&(e={});var t=df(null);return t.options=Le({async:!0,ssr:!1},e),t}var $o=function(e){var t=e.sideCar,n=Lo(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return i.createElement(s,Le({},n))};$o.isSideCarExport=!0;function ff(e,t){return e.useMedium(t),$o}var Fo=uf(),nr=function(){},_n=i.forwardRef(function(e,t){var n=i.useRef(null),s=i.useState({onScrollCapture:nr,onWheelCapture:nr,onTouchMoveCapture:nr}),o=s[0],a=s[1],l=e.forwardProps,c=e.children,d=e.className,f=e.removeScrollBar,u=e.enabled,m=e.shards,h=e.sideCar,x=e.noRelative,g=e.noIsolation,p=e.inert,v=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,w=e.gapMode,j=Lo(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,S=lf([n,t]),k=Le(Le({},j),o);return i.createElement(i.Fragment,null,u&&i.createElement(C,{sideCar:Fo,removeScrollBar:f,shards:m,noRelative:x,noIsolation:g,inert:p,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:w}),l?i.cloneElement(i.Children.only(c),Le(Le({},k),{ref:S})):i.createElement(y,Le({},k,{className:d,ref:S}),c))});_n.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};_n.classNames={fullWidth:ln,zeroRight:an};var mf=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pf(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=mf();return t&&e.setAttribute("nonce",t),e}function hf(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function xf(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var gf=function(){var e=0,t=null;return{add:function(n){e==0&&(t=pf())&&(hf(t,n),xf(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},vf=function(){var e=gf();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bo=function(){var e=vf(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},bf={left:0,top:0,right:0,gap:0},rr=function(e){return parseInt(e||"",10)||0},yf=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[rr(n),rr(s),rr(o)]},wf=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return bf;var t=yf(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},Nf=Bo(),yt="data-scroll-locked",jf=function(e,t,n,s){var o=e.left,a=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
200
+ .`.concat(rf,` {
201
+ overflow: hidden `).concat(s,`;
202
+ padding-right: `).concat(c,"px ").concat(s,`;
203
+ }
204
+ body[`).concat(yt,`] {
205
+ overflow: hidden `).concat(s,`;
206
+ overscroll-behavior: contain;
207
+ `).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
208
+ padding-left: `.concat(o,`px;
209
+ padding-top: `).concat(a,`px;
210
+ padding-right: `).concat(l,`px;
211
+ margin-left:0;
212
+ margin-top:0;
213
+ margin-right: `).concat(c,"px ").concat(s,`;
214
+ `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(s,";")].filter(Boolean).join(""),`
215
+ }
216
+
217
+ .`).concat(an,` {
218
+ right: `).concat(c,"px ").concat(s,`;
219
+ }
220
+
221
+ .`).concat(ln,` {
222
+ margin-right: `).concat(c,"px ").concat(s,`;
223
+ }
224
+
225
+ .`).concat(an," .").concat(an,` {
226
+ right: 0 `).concat(s,`;
227
+ }
228
+
229
+ .`).concat(ln," .").concat(ln,` {
230
+ margin-right: 0 `).concat(s,`;
231
+ }
232
+
233
+ body[`).concat(yt,`] {
234
+ `).concat(sf,": ").concat(c,`px;
235
+ }
236
+ `)},Ws=function(){var e=parseInt(document.body.getAttribute(yt)||"0",10);return isFinite(e)?e:0},kf=function(){i.useEffect(function(){return document.body.setAttribute(yt,(Ws()+1).toString()),function(){var e=Ws()-1;e<=0?document.body.removeAttribute(yt):document.body.setAttribute(yt,e.toString())}},[])},Cf=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;kf();var a=i.useMemo(function(){return wf(o)},[o]);return i.createElement(Nf,{styles:jf(a,!t,o,n?"":"!important")})},gr=!1;if(typeof window<"u")try{var tn=Object.defineProperty({},"passive",{get:function(){return gr=!0,!0}});window.addEventListener("test",tn,tn),window.removeEventListener("test",tn,tn)}catch{gr=!1}var xt=gr?{passive:!1}:!1,Sf=function(e){return e.tagName==="TEXTAREA"},Uo=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Sf(e)&&n[t]==="visible")},Ef=function(e){return Uo(e,"overflowY")},Af=function(e){return Uo(e,"overflowX")},Vs=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=Wo(e,s);if(o){var a=Vo(e,s),l=a[1],c=a[2];if(l>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},Tf=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Rf=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Wo=function(e,t){return e==="v"?Ef(t):Af(t)},Vo=function(e,t){return e==="v"?Tf(t):Rf(t)},_f=function(e,t){return e==="h"&&t==="rtl"?-1:1},Pf=function(e,t,n,s,o){var a=_f(e,window.getComputedStyle(t).direction),l=a*s,c=n.target,d=t.contains(c),f=!1,u=l>0,m=0,h=0;do{if(!c)break;var x=Vo(e,c),g=x[0],p=x[1],v=x[2],b=p-v-a*g;(g||b)&&Wo(e,c)&&(m+=b,h+=g);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(u&&Math.abs(m)<1||!u&&Math.abs(h)<1)&&(f=!0),f},nn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},zs=function(e){return[e.deltaX,e.deltaY]},Hs=function(e){return e&&"current"in e?e.current:e},Df=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Mf=function(e){return`
237
+ .block-interactivity-`.concat(e,` {pointer-events: none;}
238
+ .allow-interactivity-`).concat(e,` {pointer-events: all;}
239
+ `)},Of=0,gt=[];function If(e){var t=i.useRef([]),n=i.useRef([0,0]),s=i.useRef(),o=i.useState(Of++)[0],a=i.useState(Bo)[0],l=i.useRef(e);i.useEffect(function(){l.current=e},[e]),i.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var p=nf([e.lockRef.current],(e.shards||[]).map(Hs),!0).filter(Boolean);return p.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=i.useCallback(function(p,v){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!l.current.allowPinchZoom;var b=nn(p),y=n.current,w="deltaX"in p?p.deltaX:y[0]-b[0],j="deltaY"in p?p.deltaY:y[1]-b[1],C,S=p.target,k=Math.abs(w)>Math.abs(j)?"h":"v";if("touches"in p&&k==="h"&&S.type==="range")return!1;var A=window.getSelection(),R=A&&A.anchorNode,D=R?R===S||R.contains(S):!1;if(D)return!1;var F=Vs(k,S);if(!F)return!0;if(F?C=k:(C=k==="v"?"h":"v",F=Vs(k,S)),!F)return!1;if(!s.current&&"changedTouches"in p&&(w||j)&&(s.current=C),!C)return!0;var _=s.current||C;return Pf(_,v,p,_==="h"?w:j)},[]),d=i.useCallback(function(p){var v=p;if(!(!gt.length||gt[gt.length-1]!==a)){var b="deltaY"in v?zs(v):nn(v),y=t.current.filter(function(C){return C.name===v.type&&(C.target===v.target||v.target===C.shadowParent)&&Df(C.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var w=(l.current.shards||[]).map(Hs).filter(Boolean).filter(function(C){return C.contains(v.target)}),j=w.length>0?c(v,w[0]):!l.current.noIsolation;j&&v.cancelable&&v.preventDefault()}}},[]),f=i.useCallback(function(p,v,b,y){var w={name:p,delta:v,target:b,should:y,shadowParent:Lf(b)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(j){return j!==w})},1)},[]),u=i.useCallback(function(p){n.current=nn(p),s.current=void 0},[]),m=i.useCallback(function(p){f(p.type,zs(p),p.target,c(p,e.lockRef.current))},[]),h=i.useCallback(function(p){f(p.type,nn(p),p.target,c(p,e.lockRef.current))},[]);i.useEffect(function(){return gt.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",d,xt),document.addEventListener("touchmove",d,xt),document.addEventListener("touchstart",u,xt),function(){gt=gt.filter(function(p){return p!==a}),document.removeEventListener("wheel",d,xt),document.removeEventListener("touchmove",d,xt),document.removeEventListener("touchstart",u,xt)}},[]);var x=e.removeScrollBar,g=e.inert;return i.createElement(i.Fragment,null,g?i.createElement(a,{styles:Mf(o)}):null,x?i.createElement(Cf,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Lf(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const $f=ff(Fo,If);var zr=i.forwardRef(function(e,t){return i.createElement(_n,Le({},e,{ref:t,sideCar:$f}))});zr.classNames=_n.classNames;var Ff=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},vt=new WeakMap,rn=new WeakMap,sn={},sr=0,zo=function(e){return e&&(e.host||zo(e.parentNode))},Bf=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=zo(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Uf=function(e,t,n,s){var o=Bf(t,Array.isArray(e)?e:[e]);sn[n]||(sn[n]=new WeakMap);var a=sn[n],l=[],c=new Set,d=new Set(o),f=function(m){!m||c.has(m)||(c.add(m),f(m.parentNode))};o.forEach(f);var u=function(m){!m||d.has(m)||Array.prototype.forEach.call(m.children,function(h){if(c.has(h))u(h);else try{var x=h.getAttribute(s),g=x!==null&&x!=="false",p=(vt.get(h)||0)+1,v=(a.get(h)||0)+1;vt.set(h,p),a.set(h,v),l.push(h),p===1&&g&&rn.set(h,!0),v===1&&h.setAttribute(n,"true"),g||h.setAttribute(s,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return u(t),c.clear(),sr++,function(){l.forEach(function(m){var h=vt.get(m)-1,x=a.get(m)-1;vt.set(m,h),a.set(m,x),h||(rn.has(m)||m.removeAttribute(s),rn.delete(m)),x||m.removeAttribute(n)}),sr--,sr||(vt=new WeakMap,vt=new WeakMap,rn=new WeakMap,sn={})}},Ho=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=Ff(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),Uf(s,o,n,"aria-hidden")):function(){return null}},Pn="Dialog",[Ko,qo]=rt(Pn),[Wf,Ie]=Ko(Pn),Go=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=i.useRef(null),d=i.useRef(null),[f,u]=Ct({prop:s,defaultProp:o??!1,onChange:a,caller:Pn});return r.jsx(Wf,{scope:t,triggerRef:c,contentRef:d,contentId:Ze(),titleId:Ze(),descriptionId:Ze(),open:f,onOpenChange:u,onOpenToggle:i.useCallback(()=>u(m=>!m),[u]),modal:l,children:n})};Go.displayName=Pn;var Yo="DialogTrigger",Xo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ie(Yo,n),a=le(t,o.triggerRef);return r.jsx(Q.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":qr(o.open),...s,ref:a,onClick:Z(e.onClick,o.onOpenToggle)})});Xo.displayName=Yo;var Hr="DialogPortal",[Vf,Jo]=Ko(Hr,{forceMount:void 0}),Zo=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=Ie(Hr,t);return r.jsx(Vf,{scope:t,forceMount:n,children:i.Children.map(s,l=>r.jsx(Pt,{present:n||a.open,children:r.jsx(Vr,{asChild:!0,container:o,children:l})}))})};Zo.displayName=Hr;var mn="DialogOverlay",Qo=i.forwardRef((e,t)=>{const n=Jo(mn,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Ie(mn,e.__scopeDialog);return a.modal?r.jsx(Pt,{present:s||a.open,children:r.jsx(Hf,{...o,ref:t})}):null});Qo.displayName=mn;var zf=Wt("DialogOverlay.RemoveScroll"),Hf=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ie(mn,n);return r.jsx(zr,{as:zf,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(Q.div,{"data-state":qr(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),ct="DialogContent",ea=i.forwardRef((e,t)=>{const n=Jo(ct,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Ie(ct,e.__scopeDialog);return r.jsx(Pt,{present:s||a.open,children:a.modal?r.jsx(Kf,{...o,ref:t}):r.jsx(qf,{...o,ref:t})})});ea.displayName=ct;var Kf=i.forwardRef((e,t)=>{const n=Ie(ct,e.__scopeDialog),s=i.useRef(null),o=le(t,n.contentRef,s);return i.useEffect(()=>{const a=s.current;if(a)return Ho(a)},[]),r.jsx(ta,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Z(e.onCloseAutoFocus,a=>{var l;a.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Z(e.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&a.preventDefault()}),onFocusOutside:Z(e.onFocusOutside,a=>a.preventDefault())})}),qf=i.forwardRef((e,t)=>{const n=Ie(ct,e.__scopeDialog),s=i.useRef(!1),o=i.useRef(!1);return r.jsx(ta,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var l,c;(l=e.onCloseAutoFocus)==null||l.call(e,a),a.defaultPrevented||(s.current||(c=n.triggerRef.current)==null||c.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=a.target;((f=n.triggerRef.current)==null?void 0:f.contains(l))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),ta=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=e,c=Ie(ct,n),d=i.useRef(null),f=le(t,d);return Io(),r.jsxs(r.Fragment,{children:[r.jsx(Wr,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(Ur,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":qr(c.open),...l,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(Yf,{titleId:c.titleId}),r.jsx(Jf,{contentRef:d,descriptionId:c.descriptionId})]})]})}),Kr="DialogTitle",na=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ie(Kr,n);return r.jsx(Q.h2,{id:o.titleId,...s,ref:t})});na.displayName=Kr;var ra="DialogDescription",sa=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ie(ra,n);return r.jsx(Q.p,{id:o.descriptionId,...s,ref:t})});sa.displayName=ra;var oa="DialogClose",aa=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Ie(oa,n);return r.jsx(Q.button,{type:"button",...s,ref:t,onClick:Z(e.onClick,()=>o.onOpenChange(!1))})});aa.displayName=oa;function qr(e){return e?"open":"closed"}var ia="DialogTitleWarning",[Gf,la]=ju(ia,{contentName:ct,titleName:Kr,docsSlug:"dialog"}),Yf=({titleId:e})=>{const t=la(ia),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
240
+
241
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
242
+
243
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Xf="DialogDescriptionWarning",Jf=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${la(Xf).contentName}}.`;return i.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},ca=Go,Zf=Xo,da=Zo,Gr=Qo,Yr=ea,Xr=na,Jr=sa,Dn=aa;const Qf=ca,em=da,Kx=Dn,ua=i.forwardRef(({className:e,...t},n)=>r.jsx(Gr,{ref:n,className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));ua.displayName=Gr.displayName;const fa=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(em,{children:[r.jsx(ua,{}),r.jsxs(Yr,{ref:s,className:U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,r.jsxs(Dn,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[r.jsx(kt,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fa.displayName=Yr.displayName;const ma=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});ma.displayName="DialogHeader";const pa=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});pa.displayName="DialogFooter";const ha=i.forwardRef(({className:e,...t},n)=>r.jsx(Xr,{ref:n,className:U("text-lg font-semibold leading-none tracking-tight",e),...t}));ha.displayName=Xr.displayName;const tm=i.forwardRef(({className:e,...t},n)=>r.jsx(Jr,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));tm.displayName=Jr.displayName;const St=i.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:U("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...n}));St.displayName="Input";var nm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],rm=nm.reduce((e,t)=>{const n=ic(`Primitive.${t}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),sm="Label",xa=i.forwardRef((e,t)=>r.jsx(rm.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));xa.displayName=sm;var ga=xa;const om=lc("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ue=i.forwardRef(({className:e,...t},n)=>r.jsx(ga,{ref:n,className:U(om(),e),...t}));Ue.displayName=ga.displayName;function am({onAdded:e}){const[t,n]=i.useState(""),[s,o]=i.useState(!1),[a,l]=i.useState(null),c=i.useCallback(async d=>{if(d.preventDefault(),!!t.trim()){o(!0),l(null);try{await cc({leaderEndpoint:t.trim(),transport:"devtunnel"}),e()}catch(f){l(f instanceof Error?f.message:"Failed to join node")}finally{o(!1)}}},[t,e]);return r.jsx(fa,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:r.jsxs("div",{className:"overflow-hidden rounded-[28px] border border-border/60 bg-background/95 p-0 shadow-[0_40px_120px_-60px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[r.jsx("div",{className:"border-b border-border/60 px-6 py-5",children:r.jsxs(ma,{className:"space-y-2 text-left",children:[r.jsx(ha,{className:"text-2xl tracking-tight",children:"Join node"}),r.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."})]})}),r.jsxs("form",{onSubmit:c,className:"space-y-4 px-6 py-5",children:[a&&r.jsx("div",{className:"rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:a}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(Ue,{htmlFor:"leader-endpoint",children:"Leader endpoint"}),r.jsx(Ee,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),r.jsx(St,{id:"leader-endpoint",type:"url",value:t,onChange:d=>n(d.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-11 rounded-2xl border-border/70 bg-background/70"})]}),r.jsx("div",{className:"rounded-[20px] border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),r.jsx(pa,{className:"border-t border-border/60 pt-4",children:r.jsx(K,{type:"submit",disabled:!t.trim()||s,className:"rounded-2xl",children:s?"Joining...":"Join node"})})]})]})})}function va(){const[e,t]=i.useState([]),[n,s]=i.useState(null),o=i.useRef(null),a=i.useCallback(()=>{var u;(u=o.current)==null||u.click()},[]),l=i.useCallback(async u=>{const m=Array.from(u.target.files??[]);if(m.length!==0)try{const h=await _s(m);t(x=>[...x,...h]),s(null)}catch(h){s(h instanceof Error?h.message:"Failed to attach image")}finally{u.target.value=""}},[]),c=i.useCallback(async u=>{const m=Qd(u.clipboardData);if(m.length!==0){u.preventDefault();try{const h=await _s(m);t(x=>[...x,...h]),s(null)}catch(h){s(h instanceof Error?h.message:"Failed to attach image")}}},[]),d=i.useCallback(u=>{t(m=>m.filter((h,x)=>x!==u))},[]),f=i.useCallback(()=>{t([]),s(null)},[]);return{images:e,error:n,fileInputRef:o,pickImages:a,handleFileChange:l,handlePaste:c,removeImage:d,clearImages:f}}function im({onSend:e,disabled:t,disabledReason:n="Chat is waiting on the agent.",placeholder:s="Send a follow-up message...",contextItems:o=[],running:a=!1,onStop:l}){const[c,d]=i.useState(""),f=i.useRef(null),{images:u,error:m,fileInputRef:h,pickImages:x,handleFileChange:g,handlePaste:p,removeImage:v,clearImages:b}=va(),y=i.useCallback(()=>{f.current&&(f.current.style.height="auto")},[]),w=i.useCallback(()=>{const R=Ro(c,u);R.length===0||t||(e(R),d(""),b(),y())},[c,u,t,e,b,y]),j=i.useCallback(R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),w())},[w]),C=i.useCallback(()=>{f.current&&(f.current.style.height="auto",f.current.style.height=`${Math.min(f.current.scrollHeight,220)}px`)},[]),S=!t&&!a&&(c.trim().length>0||u.length>0),k=a&&!!l,A=a?l?"Task is running — click to stop":"Task is running...":t?n:"Enter sends, Shift+Enter adds a line";return r.jsxs("div",{className:"border-t border-border/60 bg-background/55 px-2 py-1.5 backdrop-blur-xl sm:px-4 sm:py-2",children:[o.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-2 px-3 pb-2.5",children:o.map(R=>r.jsxs("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-border/60 bg-muted/40 px-3 py-1 text-xs",children:[r.jsx("span",{className:"shrink-0 text-[9px] font-medium uppercase tracking-[0.12em] text-muted-foreground/80",children:R.label}),r.jsx("span",{className:`truncate text-foreground/90 ${R.mono?"font-mono text-[11px]":""}`,children:R.value})]},`${R.label}:${R.value}`))}),r.jsxs("div",{className:"overflow-hidden rounded-3xl border border-border/65 bg-card/85 shadow-[0_28px_90px_-62px_rgba(0,0,0,var(--panel-shadow-alpha))] sm:rounded-[40px]",children:[r.jsx("input",{ref:h,type:"file",accept:"image/*",multiple:!0,onChange:g,className:"hidden"}),u.length>0&&r.jsx("div",{className:"px-3 pt-3 sm:px-6 sm:pt-6",children:r.jsx("div",{className:"flex flex-wrap gap-3",children:u.map((R,D)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:Fr(R),alt:R.filename??`attachment ${D+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>v(D),className:"absolute -top-2 -right-2 flex h-7 w-7 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${R.filename??`image ${D+1}`}`,children:r.jsx(kt,{className:"h-3.5 w-3.5"})})]},`${R.filename??"image"}-${D}`))})}),r.jsxs("div",{className:"flex items-end gap-2 px-3 pt-3 pb-3 sm:px-6 sm:pt-4 sm:pb-4",children:[r.jsx("textarea",{ref:f,value:c,onChange:R=>d(R.target.value),onKeyDown:j,onPaste:p,onInput:C,placeholder:s,disabled:t,rows:1,className:"min-h-[2.5rem] flex-1 resize-none bg-transparent px-0 py-1 text-sm leading-7 text-foreground placeholder:text-muted-foreground/70 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),r.jsxs(K,{type:"button",variant:"ghost",onClick:x,disabled:t,className:"mb-0.5 h-9 shrink-0 gap-1.5 rounded-full px-2 text-xs text-muted-foreground hover:text-foreground sm:px-3",title:"Attach images",children:[r.jsx(fr,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5"}),r.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),r.jsx("span",{title:A,children:r.jsx(K,{onClick:a?l:w,disabled:a?!k:!S,size:"icon","aria-label":a?"Stop running task":"Send message",className:"mb-0.5 h-9 w-9 shrink-0 rounded-full bg-primary/85 text-primary-foreground shadow-sm hover:bg-primary",children:a?r.jsx(je,{className:"h-4 w-4 animate-spin"}):r.jsx(So,{className:"h-4 w-4"})})})]}),m&&r.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-2 text-xs text-destructive sm:px-6 sm:py-3",children:m})]})]})}function Vt({payload:e,disabled:t=!1,bypassEnabled:n=!1,onBypassChange:s,onSubmit:o}){const[a,l]=i.useState(()=>n?ou(e):e.questions.map(()=>[])),[c,d]=i.useState(!1),[f,u]=i.useState(!1);i.useEffect(()=>{n&&l(g=>g.map((p,v)=>{var b;return p.length>0?p:(b=e.questions[v])!=null&&b.options.length?[0]:[]}))},[n,e]);const m=au(e,a)&&!t&&!c&&!f&&!!o,h=(g,p)=>{t||f||c||l(v=>v.map((b,y)=>{if(y!==g)return b;const w=e.questions[y];return w?w.multiSelect?b.includes(p)?b.filter(j=>j!==p):[...b,p].sort((j,C)=>j-C):[p]:b}))},x=async()=>{if(!m||!o)return;d(!0);const g=await o(iu(e,a));d(!1),g&&u(!0)};return r.jsxs("div",{className:"rounded-[24px] border border-primary/20 bg-primary/5 p-4 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:r.jsx(zc,{className:"h-4 w-4"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-primary/80",children:"Ask User Question"}),r.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Select the answer you want to send back to the agent."})]})]}),r.jsxs(K,{type:"button",variant:n?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!n),className:"rounded-full",children:[r.jsx(Rd,{className:"h-4 w-4"}),n?"Bypass on":"Bypass future questions"]})]}),r.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((g,p)=>{const v=a[p]??[];return r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/75 p-4",children:[r.jsxs("div",{children:[g.header&&r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:g.header}),r.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:g.question}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:g.multiSelect?"Select one or more options.":"Select one option."})]}),r.jsx("div",{className:"space-y-2",children:g.options.map((b,y)=>{const w=v.includes(y);return r.jsxs("button",{type:"button",onClick:()=>h(p,y),disabled:t||c||f,"aria-pressed":w,className:U("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[r.jsx("span",{className:U("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:r.jsx(He,{className:"h-3.5 w-3.5"})}),r.jsxs("span",{className:"min-w-0",children:[r.jsx("span",{className:"block text-sm font-medium leading-5",children:b.label}),b.description&&r.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:b.description})]})]},`${b.label}-${y}`)})})]},`${g.header??"question"}-${p}`)})}),r.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:n?"Bypass is enabled. New question cards will default to the first option.":"Enable bypass if you want future question cards to preselect the first option."}),r.jsx(K,{type:"button",onClick:()=>void x(),disabled:!m,className:"rounded-full px-5",children:f?"Sent":c?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function lm({payload:e,disabled:t=!1,onSubmit:n}){const[s,o]=i.useState(null),[a,l]=i.useState(!1),c=!t&&!a&&!!n,d=async f=>{if(!c||!n)return;o(f);const u=await n(fu(e,f));o(null),u&&l(!0)};return r.jsxs("div",{className:"rounded-[24px] border border-amber-500/25 bg-amber-500/5 p-4 shadow-[0_24px_80px_-60px_rgba(245,158,11,0.8)]",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-amber-500/25 bg-amber-500/10 text-amber-600 dark:text-amber-400",children:r.jsx(Ad,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-amber-700/80 dark:text-amber-300/80",children:"Permission Request"}),r.jsx("div",{className:"mt-1 space-y-3",children:e.requests.map((f,u)=>r.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/75 px-4 py-3",children:[r.jsx("div",{className:"text-sm font-medium leading-6 text-foreground",children:f.summary}),(f.toolName||f.target)&&r.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:[r.jsx("span",{children:f.toolName}),f.target&&r.jsx("span",{className:"font-mono normal-case tracking-normal",children:f.target})]})]},`${f.toolUseId??f.toolName}-${u}`))})]})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[r.jsxs(K,{type:"button",variant:"outline",onClick:()=>void d("deny"),disabled:!c||s!==null,className:"rounded-full",children:[r.jsx(kt,{className:"h-4 w-4"}),a?"Sent":s==="deny"?"Sending...":"Deny"]}),r.jsxs(K,{type:"button",onClick:()=>void d("approve"),disabled:!c||s!==null,className:"rounded-full",children:[r.jsx(He,{className:"h-4 w-4"}),a?"Sent":s==="approve"?"Sending...":"Approve"]})]})]})}function Ks({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const a=e.type,l=Br(e),c=Tn(e);if(l)return r.jsx(Ft,{children:r.jsx(lm,{payload:l,onSubmit:s,disabled:o})});if(c)return r.jsx(Ft,{children:r.jsx(Vt,{payload:c,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});if(a==="user"){const d=cm(e),f=d.filter(m=>m.type==="tool_result");if(f.length>0&&d.every(m=>m.type==="tool_result"))return r.jsx(Ft,{children:f.map((m,h)=>r.jsx(ya,{block:m,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},h))});const u=Kt(e);return u?r.jsx(mm,{content:u}):null}return a==="assistant"?r.jsx(pm,{event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function cm(e){const t=e.message,n=t==null?void 0:t.content;if(Array.isArray(n))return n.filter(o=>typeof o=="object"&&o!==null);const s=e.content;return Array.isArray(s)?s.filter(o=>typeof o=="object"&&o!==null):[]}function or(e){var n;const t=e.replace(/\r\n/g,`
244
+ `).split(`
245
+ `);for(;t.length>0&&((n=t[0])==null?void 0:n.trim())==="";)t.shift();return t.join(`
246
+ `)}function ba({text:e,className:t=""}){const[n,s]=i.useState(!1);if(!e)return null;const o=async a=>{a.stopPropagation();try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)}catch{}};return r.jsx("button",{type:"button",onClick:o,"aria-label":n?"Copied":"Copy message",className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-background/80 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:n?r.jsx(He,{className:"h-3 w-3 text-emerald-500"}):r.jsx(An,{className:"h-3 w-3"})})}async function dm(e){let n=await(await fetch(e)).blob();n.type!=="image/png"&&(n=await um(n)),await navigator.clipboard.write([new ClipboardItem({[n.type]:n})])}async function um(e){const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const s=n.getContext("2d");if(!s)throw new Error("canvas 2d context unavailable");return s.drawImage(t,0,0),await new Promise((o,a)=>{n.toBlob(l=>l?o(l):a(new Error("toBlob failed")),"image/png")})}function fm({dataUrl:e,className:t=""}){const[n,s]=i.useState(!1),o=async a=>{a.stopPropagation();try{await dm(e),s(!0),setTimeout(()=>s(!1),1500)}catch(l){console.error("copy image failed",l)}};return r.jsx("button",{type:"button",onClick:o,"aria-label":n?"Copied":"Copy image",className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-background/80 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:n?r.jsx(He,{className:"h-3 w-3 text-emerald-500"}):r.jsx(An,{className:"h-3 w-3"})})}function mm({content:e}){const t=Zd(e),n=e.filter(s=>s.type==="image");return r.jsx("div",{className:"animate-message-rise flex justify-end",children:r.jsxs("div",{className:"group relative flex max-w-[88%] items-start gap-3",children:[r.jsx(ba,{text:t,className:"absolute -left-8 top-2"}),r.jsxs("div",{className:"space-y-1 rounded-[26px] rounded-tr-md border border-primary/25 bg-primary px-4 py-3 text-[13px] leading-5 text-primary-foreground shadow-[0_20px_70px_-42px_hsl(var(--primary)/0.95)]",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-primary-foreground/75",children:"You"}),t&&r.jsx("div",{className:"whitespace-pre-wrap",children:t}),n.length>0&&r.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:n.map((s,o)=>{const a=Fr(s);return r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:a,alt:s.filename??`attachment ${o+1}`,className:"max-h-72 w-full rounded-2xl border border-primary-foreground/15 object-cover"}),r.jsx(fm,{dataUrl:a,className:"absolute right-2 top-2"})]},`${s.filename??"image"}-${o}`)})})]}),r.jsx("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:r.jsx(Id,{className:"h-4 w-4"})})]})})}function Ft({children:e}){return r.jsx("div",{className:"animate-message-rise flex justify-start",children:r.jsxs("div",{className:"flex max-w-[92%] items-start gap-3",children:[r.jsx("div",{className:"mt-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-border/70 bg-muted/70 text-muted-foreground",children:r.jsx(Mr,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0 space-y-3",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"Agent"}),e]})]})})}function pm({event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}){const a=e.message;if(!a)return null;const l=Tn(a);if(l)return r.jsx(Ft,{children:r.jsx(Vt,{payload:l,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});const c=a.content;if(!c||!Array.isArray(c))return null;const d=new Set,f=c.filter(g=>g.type==="text").map(g=>({...g,text:or(String(g.text??"")),questionPayload:Rn(or(String(g.text??"")))})).filter(g=>g.text.length>0||g.questionPayload),u=c.filter(g=>g.type==="thinking").map(g=>or(String(g.thinking??""))).filter(Boolean).join(`
247
+
248
+ `),m=c.filter(g=>g.type==="tool_use"),h=c.filter(g=>g.type==="tool_result");return f.length>0||u.length>0||m.length>0||h.length>0?r.jsxs(Ft,{children:[u.length>0&&r.jsx(vm,{text:u}),f.map((g,p)=>{if(g.questionPayload){const v=_t(g.questionPayload);return d.has(v)?null:(d.add(v),r.jsx(Vt,{payload:g.questionPayload,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o},p))}return r.jsxs("div",{className:"group relative rounded-[26px] rounded-tl-md border border-border/70 bg-card/80 px-4 py-3 text-[13px] leading-5 text-foreground shadow-[0_20px_70px_-58px_rgba(0,0,0,0.9)] backdrop-blur-sm",children:[r.jsx(ba,{text:g.text,className:"absolute right-2 top-2"}),r.jsx("div",{className:"whitespace-pre-wrap",children:g.text})]},p)}),m.map((g,p)=>r.jsx(bm,{block:g,renderedQuestionSignatures:d,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p)),h.map((g,p)=>r.jsx(ya,{block:g,renderedQuestionSignatures:d,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p))]}):null}function hm(e){return e.replace(/\s+/g," ").trim()}function wt(e,t=132){const n=hm(e);return n?n.length>t?`${n.slice(0,t-3)}...`:n:""}function vr(e,t=84){if(typeof e=="string")return wt(e,t);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const n=e.slice(0,3).map(s=>vr(s,28)).filter(Boolean).join(", ");return wt(n||JSON.stringify(e),t)}if(typeof e=="object"&&e!==null){const n=Object.entries(e).slice(0,3).map(([s,o])=>`${s}: ${vr(o,32)}`).join(" · ");return wt(n||JSON.stringify(e),t)}return""}function xm(e){if(!e)return"No input";const t=Object.entries(e).slice(0,4).map(([n,s])=>`${n}: ${vr(s,40)}`).filter(n=>n.trim().length>0).join(" · ");return wt(t||JSON.stringify(e),156)||"No input"}function gm({expanded:e}){return r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-border/60 bg-background/70 px-2 py-1 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[e?"Less":"More",e?r.jsx(Ir,{className:"h-3 w-3"}):r.jsx(Tt,{className:"h-3 w-3"})]})}function Zr({title:e,preview:t,icon:n,children:s,accentClassName:o,previewClassName:a="font-mono text-[11px] text-muted-foreground/90"}){const[l,c]=i.useState(!1);return r.jsxs("div",{className:`overflow-hidden rounded-[22px] border border-border/60 ${o}`,children:[r.jsxs("button",{type:"button",onClick:()=>c(d=>!d),className:"flex w-full items-start gap-3 px-4 py-3 text-left transition-colors hover:bg-background/30",children:[r.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/70 text-muted-foreground",children:n}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:e})}),r.jsx("div",{className:`mt-1 whitespace-pre-wrap break-words text-[12px] leading-5 ${a}`,children:t})]}),r.jsx(gm,{expanded:l})]}),l&&r.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:s})]})}function vm({text:e}){const t=wt(e,156);return r.jsx(Zr,{title:"Thinking",preview:t,icon:r.jsx($c,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/35",previewClassName:"text-[12px] leading-5 text-muted-foreground/90",children:r.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-5 text-muted-foreground/90",children:e})})}function bm({block:e,renderedQuestionSignatures:t,questionBypassEnabled:n,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:a}){const l=String(e.name??"tool"),c=e.input,d=Tn(e);if(d){const u=_t(d);return t!=null&&t.has(u)?null:(t==null||t.add(u),r.jsx(Vt,{payload:d,bypassEnabled:n,onBypassChange:s,onSubmit:o,disabled:a}))}const f=xm(c);if(l==="TodoWrite"){const u=ym(c==null?void 0:c.todos);if(u.length>0)return r.jsx(wm,{todos:u})}return r.jsx(Zr,{title:`Tool: ${l}`,preview:f,icon:r.jsx(Eo,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/25",children:r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(c??{},null,2)})})}function ya({block:e,renderedQuestionSignatures:t,questionBypassEnabled:n,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:a}){const l=e.content,c=typeof l=="string"?l:Array.isArray(l)?l.map(u=>String(u.text??"")).join(`
249
+ `):"";if(!c)return null;const d=Rn(c);if(d){const u=_t(d);return t!=null&&t.has(u)?null:(t==null||t.add(u),r.jsx(Vt,{payload:d,bypassEnabled:n,onBypassChange:s,onSubmit:o,disabled:a}))}const f=wt(c,156);return r.jsx(Zr,{title:"Result",preview:f,icon:r.jsx(Eo,{className:"h-3.5 w-3.5"}),accentClassName:"bg-background/65",children:r.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:c})})}function ym(e){return Array.isArray(e)?e.map(t=>{if(typeof t!="object"||t===null)return null;const n=t,s=typeof n.content=="string"?n.content:"";if(!s)return null;const o=typeof n.activeForm=="string"?n.activeForm:s,a=typeof n.status=="string"?n.status:"pending";return{content:s,activeForm:o,status:a==="completed"||a==="in_progress"?a:"pending"}}).filter(t=>t!==null):[]}function wm({todos:e}){const t=e.filter(o=>o.status==="completed").length,n=e.length,s=e.find(o=>o.status==="in_progress");return r.jsxs("div",{className:"overflow-hidden rounded-[22px] border border-border/60 bg-muted/20",children:[r.jsxs("div",{className:"flex items-center gap-3 border-b border-border/50 px-4 py-3",children:[r.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border/60 bg-background/70 text-muted-foreground",children:r.jsx(md,{className:"h-3.5 w-3.5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:"Todos"}),r.jsx("div",{className:"mt-0.5 truncate text-[12px] leading-5 text-muted-foreground/90",children:s?s.activeForm:n===0?"No items":t===n?"All complete":"Up next"})]}),r.jsxs("div",{className:"shrink-0 rounded-full border border-border/60 bg-background/70 px-2 py-0.5 font-mono text-[10px] tracking-wide text-muted-foreground",children:[t,"/",n]})]}),r.jsx("ul",{className:"divide-y divide-border/40",children:e.map((o,a)=>r.jsxs("li",{className:"flex items-start gap-3 px-4 py-2.5",children:[r.jsx(Nm,{status:o.status}),r.jsx("span",{className:o.status==="completed"?"text-[13px] leading-5 text-muted-foreground line-through decoration-muted-foreground/60":o.status==="in_progress"?"text-[13px] font-medium leading-5 text-foreground":"text-[13px] leading-5 text-foreground/85",children:o.status==="in_progress"?o.activeForm:o.content})]},`${a}-${o.content}`))})]})}function Nm({status:e}){return e==="completed"?r.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-500 dark:text-emerald-400",children:r.jsx(He,{className:"h-3 w-3"})}):e==="in_progress"?r.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-primary",children:r.jsx(je,{className:"h-3.5 w-3.5 animate-spin"})}):r.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground/60",children:r.jsx(Gc,{className:"h-3 w-3"})})}function wa(e){const t=e+"CollectionProvider",[n,s]=rt(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=p=>{const{scope:v,children:b}=p,y=it.useRef(null),w=it.useRef(new Map).current;return r.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:b})};l.displayName=t;const c=e+"CollectionSlot",d=Wt(c),f=it.forwardRef((p,v)=>{const{scope:b,children:y}=p,w=a(c,b),j=le(v,w.collectionRef);return r.jsx(d,{ref:j,children:y})});f.displayName=c;const u=e+"CollectionItemSlot",m="data-radix-collection-item",h=Wt(u),x=it.forwardRef((p,v)=>{const{scope:b,children:y,...w}=p,j=it.useRef(null),C=le(v,j),S=a(u,b);return it.useEffect(()=>(S.itemMap.set(j,{ref:j,...w}),()=>void S.itemMap.delete(j))),r.jsx(h,{[m]:"",ref:C,children:y})});x.displayName=u;function g(p){const v=a(e+"CollectionConsumer",p);return it.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((S,k)=>w.indexOf(S.ref.current)-w.indexOf(k.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:l,Slot:f,ItemSlot:x},g,s]}var jm=i.createContext(void 0);function Qr(e){const t=i.useContext(jm);return e||t||"ltr"}var ar="rovingFocusGroup.onEntryFocus",km={bubbles:!1,cancelable:!0},Gt="RovingFocusGroup",[br,Na,Cm]=wa(Gt),[Sm,ja]=rt(Gt,[Cm]),[Em,Am]=Sm(Gt),ka=i.forwardRef((e,t)=>r.jsx(br.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(br.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Tm,{...e,ref:t})})}));ka.displayName=Gt;var Tm=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:u=!1,...m}=e,h=i.useRef(null),x=le(t,h),g=Qr(a),[p,v]=Ct({prop:l,defaultProp:c??null,onChange:d,caller:Gt}),[b,y]=i.useState(!1),w=et(f),j=Na(n),C=i.useRef(!1),[S,k]=i.useState(0);return i.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ar,w),()=>A.removeEventListener(ar,w)},[w]),r.jsx(Em,{scope:n,orientation:s,dir:g,loop:o,currentTabStopId:p,onItemFocus:i.useCallback(A=>v(A),[v]),onItemShiftTab:i.useCallback(()=>y(!0),[]),onFocusableItemAdd:i.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:i.useCallback(()=>k(A=>A-1),[]),children:r.jsx(Q.div,{tabIndex:b||S===0?-1:0,"data-orientation":s,...m,ref:x,style:{outline:"none",...e.style},onMouseDown:Z(e.onMouseDown,()=>{C.current=!0}),onFocus:Z(e.onFocus,A=>{const R=!C.current;if(A.target===A.currentTarget&&R&&!b){const D=new CustomEvent(ar,km);if(A.currentTarget.dispatchEvent(D),!D.defaultPrevented){const F=j().filter(M=>M.focusable),_=F.find(M=>M.active),$=F.find(M=>M.id===p),z=[_,$,...F].filter(Boolean).map(M=>M.ref.current);Ea(z,u)}}C.current=!1}),onBlur:Z(e.onBlur,()=>y(!1))})})}),Ca="RovingFocusGroupItem",Sa=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:l,...c}=e,d=Ze(),f=a||d,u=Am(Ca,n),m=u.currentTabStopId===f,h=Na(n),{onFocusableItemAdd:x,onFocusableItemRemove:g,currentTabStopId:p}=u;return i.useEffect(()=>{if(s)return x(),()=>g()},[s,x,g]),r.jsx(br.ItemSlot,{scope:n,id:f,focusable:s,active:o,children:r.jsx(Q.span,{tabIndex:m?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:Z(e.onMouseDown,v=>{s?u.onItemFocus(f):v.preventDefault()}),onFocus:Z(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:Z(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){u.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=Pm(v,u.orientation,u.dir);if(b!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let w=h().filter(j=>j.focusable).map(j=>j.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const j=w.indexOf(v.currentTarget);w=u.loop?Dm(w,j+1):w.slice(j+1)}setTimeout(()=>Ea(w))}}),children:typeof l=="function"?l({isCurrentTabStop:m,hasTabStop:p!=null}):l})})});Sa.displayName=Ca;var Rm={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _m(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Pm(e,t,n){const s=_m(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Rm[s]}function Ea(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function Dm(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Mm=ka,Om=Sa,Mn="Tabs",[Im]=rt(Mn,[ja]),Aa=ja(),[Lm,es]=Im(Mn),Ta=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:l="horizontal",dir:c,activationMode:d="automatic",...f}=e,u=Qr(c),[m,h]=Ct({prop:s,onChange:o,defaultProp:a??"",caller:Mn});return r.jsx(Lm,{scope:n,baseId:Ze(),value:m,onValueChange:h,orientation:l,dir:u,activationMode:d,children:r.jsx(Q.div,{dir:u,"data-orientation":l,...f,ref:t})})});Ta.displayName=Mn;var Ra="TabsList",_a=i.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=es(Ra,n),l=Aa(n);return r.jsx(Mm,{asChild:!0,...l,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(Q.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});_a.displayName=Ra;var Pa="TabsTrigger",Da=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,l=es(Pa,n),c=Aa(n),d=Ia(l.baseId,s),f=La(l.baseId,s),u=s===l.value;return r.jsx(Om,{asChild:!0,...c,focusable:!o,active:u,children:r.jsx(Q.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":f,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...a,ref:t,onMouseDown:Z(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?l.onValueChange(s):m.preventDefault()}),onKeyDown:Z(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&l.onValueChange(s)}),onFocus:Z(e.onFocus,()=>{const m=l.activationMode!=="manual";!u&&!o&&m&&l.onValueChange(s)})})})});Da.displayName=Pa;var Ma="TabsContent",Oa=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...l}=e,c=es(Ma,n),d=Ia(c.baseId,s),f=La(c.baseId,s),u=s===c.value,m=i.useRef(u);return i.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),r.jsx(Pt,{present:o||u,children:({present:h})=>r.jsx(Q.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:f,tabIndex:0,...l,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:h&&a})})});Oa.displayName=Ma;function Ia(e,t){return`${e}-trigger-${t}`}function La(e,t){return`${e}-content-${t}`}var $m=Ta,$a=_a,Fa=Da,Ba=Oa;const Ua=$m,ts=i.forwardRef(({className:e,...t},n)=>r.jsx($a,{ref:n,className:U("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));ts.displayName=$a.displayName;const Xe=i.forwardRef(({className:e,...t},n)=>r.jsx(Fa,{ref:n,className:U("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Xe.displayName=Fa.displayName;const Je=i.forwardRef(({className:e,...t},n)=>r.jsx(Ba,{ref:n,className:U("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Je.displayName=Ba.displayName;var Wa="AlertDialog",[Fm]=rt(Wa,[qo]),Ke=qo(),Va=e=>{const{__scopeAlertDialog:t,...n}=e,s=Ke(t);return r.jsx(ca,{...s,...n,modal:!0})};Va.displayName=Wa;var Bm="AlertDialogTrigger",za=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ke(n);return r.jsx(Zf,{...o,...s,ref:t})});za.displayName=Bm;var Um="AlertDialogPortal",Ha=e=>{const{__scopeAlertDialog:t,...n}=e,s=Ke(t);return r.jsx(da,{...s,...n})};Ha.displayName=Um;var Wm="AlertDialogOverlay",Ka=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ke(n);return r.jsx(Gr,{...o,...s,ref:t})});Ka.displayName=Wm;var Nt="AlertDialogContent",[Vm,zm]=Fm(Nt),Hm=_u("AlertDialogContent"),qa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:s,...o}=e,a=Ke(n),l=i.useRef(null),c=le(t,l),d=i.useRef(null);return r.jsx(Gf,{contentName:Nt,titleName:Ga,docsSlug:"alert-dialog",children:r.jsx(Vm,{scope:n,cancelRef:d,children:r.jsxs(Yr,{role:"alertdialog",...a,...o,ref:c,onOpenAutoFocus:Z(o.onOpenAutoFocus,f=>{var u;f.preventDefault(),(u=d.current)==null||u.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[r.jsx(Hm,{children:s}),r.jsx(qm,{contentRef:l})]})})})});qa.displayName=Nt;var Ga="AlertDialogTitle",Ya=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ke(n);return r.jsx(Xr,{...o,...s,ref:t})});Ya.displayName=Ga;var Xa="AlertDialogDescription",Ja=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ke(n);return r.jsx(Jr,{...o,...s,ref:t})});Ja.displayName=Xa;var Km="AlertDialogAction",Za=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=Ke(n);return r.jsx(Dn,{...o,...s,ref:t})});Za.displayName=Km;var Qa="AlertDialogCancel",ei=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,{cancelRef:o}=zm(Qa,n),a=Ke(n),l=le(t,o);return r.jsx(Dn,{...a,...s,ref:l})});ei.displayName=Qa;var qm=({contentRef:e})=>{const t=`\`${Nt}\` requires a description for the component to be accessible for screen reader users.
250
+
251
+ You can add a description to the \`${Nt}\` by passing a \`${Xa}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
252
+
253
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Nt}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
254
+
255
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return i.useEffect(()=>{var s;document.getElementById((s=e.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Gm=Va,Ym=za,Xm=Ha,ti=Ka,ni=qa,ri=Za,si=ei,oi=Ya,ai=Ja;const yr=Gm,qs=Ym,Jm=Xm,ii=i.forwardRef(({className:e,...t},n)=>r.jsx(ti,{className:U("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));ii.displayName=ti.displayName;const pn=i.forwardRef(({className:e,...t},n)=>r.jsxs(Jm,{children:[r.jsx(ii,{}),r.jsx(ni,{ref:n,className:U("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));pn.displayName=ni.displayName;const hn=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col space-y-2 text-center sm:text-left",e),...t});hn.displayName="AlertDialogHeader";const xn=({className:e,...t})=>r.jsx("div",{className:U("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});xn.displayName="AlertDialogFooter";const gn=i.forwardRef(({className:e,...t},n)=>r.jsx(oi,{ref:n,className:U("text-lg font-semibold",e),...t}));gn.displayName=oi.displayName;const vn=i.forwardRef(({className:e,...t},n)=>r.jsx(ai,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));vn.displayName=ai.displayName;const bn=i.forwardRef(({className:e,...t},n)=>r.jsx(ri,{ref:n,className:U(vo(),e),...t}));bn.displayName=ri.displayName;const yn=i.forwardRef(({className:e,...t},n)=>r.jsx(si,{ref:n,className:U(vo({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));yn.displayName=si.displayName;function Gs(e,[t,n]){return Math.min(n,Math.max(t,e))}const Zm=["top","right","bottom","left"],tt=Math.min,Se=Math.max,wn=Math.round,on=Math.floor,Fe=e=>({x:e,y:e}),Qm={left:"right",right:"left",bottom:"top",top:"bottom"};function wr(e,t,n){return Se(e,tt(t,n))}function Ve(e,t){return typeof e=="function"?e(t):e}function ze(e){return e.split("-")[0]}function Dt(e){return e.split("-")[1]}function ns(e){return e==="x"?"y":"x"}function rs(e){return e==="y"?"height":"width"}function $e(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ss(e){return ns($e(e))}function ep(e,t,n){n===void 0&&(n=!1);const s=Dt(e),o=ss(e),a=rs(o);let l=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(l=Nn(l)),[l,Nn(l)]}function tp(e){const t=Nn(e);return[Nr(e),t,Nr(t)]}function Nr(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Ys=["left","right"],Xs=["right","left"],np=["top","bottom"],rp=["bottom","top"];function sp(e,t,n){switch(e){case"top":case"bottom":return n?t?Xs:Ys:t?Ys:Xs;case"left":case"right":return t?np:rp;default:return[]}}function op(e,t,n,s){const o=Dt(e);let a=sp(ze(e),n==="start",s);return o&&(a=a.map(l=>l+"-"+o),t&&(a=a.concat(a.map(Nr)))),a}function Nn(e){const t=ze(e);return Qm[t]+e.slice(t.length)}function ap(e){return{top:0,right:0,bottom:0,left:0,...e}}function li(e){return typeof e!="number"?ap(e):{top:e,right:e,bottom:e,left:e}}function jn(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function Js(e,t,n){let{reference:s,floating:o}=e;const a=$e(t),l=ss(t),c=rs(l),d=ze(t),f=a==="y",u=s.x+s.width/2-o.width/2,m=s.y+s.height/2-o.height/2,h=s[c]/2-o[c]/2;let x;switch(d){case"top":x={x:u,y:s.y-o.height};break;case"bottom":x={x:u,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y:m};break;case"left":x={x:s.x-o.width,y:m};break;default:x={x:s.x,y:s.y}}switch(Dt(t)){case"start":x[l]-=h*(n&&f?-1:1);break;case"end":x[l]+=h*(n&&f?-1:1);break}return x}async function ip(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:a,rects:l,elements:c,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:m="floating",altBoundary:h=!1,padding:x=0}=Ve(t,e),g=li(x),v=c[h?m==="floating"?"reference":"floating":m],b=jn(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:f,rootBoundary:u,strategy:d})),y=m==="floating"?{x:s,y:o,width:l.floating.width,height:l.floating.height}:l.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),j=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},C=jn(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:w,strategy:d}):y);return{top:(b.top-C.top+g.top)/j.y,bottom:(C.bottom-b.bottom+g.bottom)/j.y,left:(b.left-C.left+g.left)/j.x,right:(C.right-b.right+g.right)/j.x}}const lp=50,cp=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:ip},d=await(l.isRTL==null?void 0:l.isRTL(t));let f=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:m}=Js(f,s,d),h=s,x=0;const g={};for(let p=0;p<a.length;p++){const v=a[p];if(!v)continue;const{name:b,fn:y}=v,{x:w,y:j,data:C,reset:S}=await y({x:u,y:m,initialPlacement:s,placement:h,strategy:o,middlewareData:g,rects:f,platform:c,elements:{reference:e,floating:t}});u=w??u,m=j??m,g[b]={...g[b],...C},S&&x<lp&&(x++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(f=S.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:u,y:m}=Js(f,h,d)),p=-1)}return{x:u,y:m,placement:h,strategy:o,middlewareData:g}},dp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:a,platform:l,elements:c,middlewareData:d}=t,{element:f,padding:u=0}=Ve(e,t)||{};if(f==null)return{};const m=li(u),h={x:n,y:s},x=ss(o),g=rs(x),p=await l.getDimensions(f),v=x==="y",b=v?"top":"left",y=v?"bottom":"right",w=v?"clientHeight":"clientWidth",j=a.reference[g]+a.reference[x]-h[x]-a.floating[g],C=h[x]-a.reference[x],S=await(l.getOffsetParent==null?void 0:l.getOffsetParent(f));let k=S?S[w]:0;(!k||!await(l.isElement==null?void 0:l.isElement(S)))&&(k=c.floating[w]||a.floating[g]);const A=j/2-C/2,R=k/2-p[g]/2-1,D=tt(m[b],R),F=tt(m[y],R),_=D,$=k-p[g]-F,V=k/2-p[g]/2+A,z=wr(_,V,$),M=!d.arrow&&Dt(o)!=null&&V!==z&&a.reference[g]/2-(V<_?D:F)-p[g]/2<0,T=M?V<_?V-_:V-$:0;return{[x]:h[x]+T,data:{[x]:z,centerOffset:V-z-T,...M&&{alignmentOffset:T}},reset:M}}}),up=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:a,rects:l,initialPlacement:c,platform:d,elements:f}=t,{mainAxis:u=!0,crossAxis:m=!0,fallbackPlacements:h,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...v}=Ve(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=ze(o),y=$e(c),w=ze(c)===c,j=await(d.isRTL==null?void 0:d.isRTL(f.floating)),C=h||(w||!p?[Nn(c)]:tp(c)),S=g!=="none";!h&&S&&C.push(...op(c,p,g,j));const k=[c,...C],A=await d.detectOverflow(t,v),R=[];let D=((s=a.flip)==null?void 0:s.overflows)||[];if(u&&R.push(A[b]),m){const V=ep(o,l,j);R.push(A[V[0]],A[V[1]])}if(D=[...D,{placement:o,overflows:R}],!R.every(V=>V<=0)){var F,_;const V=(((F=a.flip)==null?void 0:F.index)||0)+1,z=k[V];if(z&&(!(m==="alignment"?y!==$e(z):!1)||D.every(I=>$e(I.placement)===y?I.overflows[0]>0:!0)))return{data:{index:V,overflows:D},reset:{placement:z}};let M=(_=D.filter(T=>T.overflows[0]<=0).sort((T,I)=>T.overflows[1]-I.overflows[1])[0])==null?void 0:_.placement;if(!M)switch(x){case"bestFit":{var $;const T=($=D.filter(I=>{if(S){const E=$e(I.placement);return E===y||E==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(E=>E>0).reduce((E,ne)=>E+ne,0)]).sort((I,E)=>I[1]-E[1])[0])==null?void 0:$[0];T&&(M=T);break}case"initialPlacement":M=c;break}if(o!==M)return{reset:{placement:M}}}return{}}}};function Zs(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Qs(e){return Zm.some(t=>e[t]>=0)}const fp=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:o="referenceHidden",...a}=Ve(e,t);switch(o){case"referenceHidden":{const l=await s.detectOverflow(t,{...a,elementContext:"reference"}),c=Zs(l,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Qs(c)}}}case"escaped":{const l=await s.detectOverflow(t,{...a,altBoundary:!0}),c=Zs(l,n.floating);return{data:{escapedOffsets:c,escaped:Qs(c)}}}default:return{}}}}},ci=new Set(["left","top"]);async function mp(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),l=ze(n),c=Dt(n),d=$e(n)==="y",f=ci.has(l)?-1:1,u=a&&d?-1:1,m=Ve(t,e);let{mainAxis:h,crossAxis:x,alignmentAxis:g}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof g=="number"&&(x=c==="end"?g*-1:g),d?{x:x*u,y:h*f}:{x:h*f,y:x*u}}const pp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:a,placement:l,middlewareData:c}=t,d=await mp(t,e);return l===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:o+d.x,y:a+d.y,data:{...d,placement:l}}}}},hp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o,platform:a}=t,{mainAxis:l=!0,crossAxis:c=!1,limiter:d={fn:b=>{let{x:y,y:w}=b;return{x:y,y:w}}},...f}=Ve(e,t),u={x:n,y:s},m=await a.detectOverflow(t,f),h=$e(ze(o)),x=ns(h);let g=u[x],p=u[h];if(l){const b=x==="y"?"top":"left",y=x==="y"?"bottom":"right",w=g+m[b],j=g-m[y];g=wr(w,g,j)}if(c){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=p+m[b],j=p-m[y];p=wr(w,p,j)}const v=d.fn({...t,[x]:g,[h]:p});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[x]:l,[h]:c}}}}}},xp=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:a,middlewareData:l}=t,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=Ve(e,t),u={x:n,y:s},m=$e(o),h=ns(m);let x=u[h],g=u[m];const p=Ve(c,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(d){const w=h==="y"?"height":"width",j=a.reference[h]-a.floating[w]+v.mainAxis,C=a.reference[h]+a.reference[w]-v.mainAxis;x<j?x=j:x>C&&(x=C)}if(f){var b,y;const w=h==="y"?"width":"height",j=ci.has(ze(o)),C=a.reference[m]-a.floating[w]+(j&&((b=l.offset)==null?void 0:b[m])||0)+(j?0:v.crossAxis),S=a.reference[m]+a.reference[w]+(j?0:((y=l.offset)==null?void 0:y[m])||0)-(j?v.crossAxis:0);g<C?g=C:g>S&&(g=S)}return{[h]:x,[m]:g}}}},gp=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:a,platform:l,elements:c}=t,{apply:d=()=>{},...f}=Ve(e,t),u=await l.detectOverflow(t,f),m=ze(o),h=Dt(o),x=$e(o)==="y",{width:g,height:p}=a.floating;let v,b;m==="top"||m==="bottom"?(v=m,b=h===(await(l.isRTL==null?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(b=m,v=h==="end"?"top":"bottom");const y=p-u.top-u.bottom,w=g-u.left-u.right,j=tt(p-u[v],y),C=tt(g-u[b],w),S=!t.middlewareData.shift;let k=j,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=w),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(k=y),S&&!h){const D=Se(u.left,0),F=Se(u.right,0),_=Se(u.top,0),$=Se(u.bottom,0);x?A=g-2*(D!==0||F!==0?D+F:Se(u.left,u.right)):k=p-2*(_!==0||$!==0?_+$:Se(u.top,u.bottom))}await d({...t,availableWidth:A,availableHeight:k});const R=await l.getDimensions(c.floating);return g!==R.width||p!==R.height?{reset:{rects:!0}}:{}}}};function On(){return typeof window<"u"}function Mt(e){return di(e)?(e.nodeName||"").toLowerCase():"#document"}function Ae(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Be(e){var t;return(t=(di(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function di(e){return On()?e instanceof Node||e instanceof Ae(e).Node:!1}function Me(e){return On()?e instanceof Element||e instanceof Ae(e).Element:!1}function qe(e){return On()?e instanceof HTMLElement||e instanceof Ae(e).HTMLElement:!1}function eo(e){return!On()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ae(e).ShadowRoot}function Yt(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Oe(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&o!=="inline"&&o!=="contents"}function vp(e){return/^(table|td|th)$/.test(Mt(e))}function In(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const bp=/transform|translate|scale|rotate|perspective|filter/,yp=/paint|layout|strict|content/,lt=e=>!!e&&e!=="none";let ir;function os(e){const t=Me(e)?Oe(e):e;return lt(t.transform)||lt(t.translate)||lt(t.scale)||lt(t.rotate)||lt(t.perspective)||!as()&&(lt(t.backdropFilter)||lt(t.filter))||bp.test(t.willChange||"")||yp.test(t.contain||"")}function wp(e){let t=nt(e);for(;qe(t)&&!Et(t);){if(os(t))return t;if(In(t))return null;t=nt(t)}return null}function as(){return ir==null&&(ir=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ir}function Et(e){return/^(html|body|#document)$/.test(Mt(e))}function Oe(e){return Ae(e).getComputedStyle(e)}function Ln(e){return Me(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nt(e){if(Mt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||eo(e)&&e.host||Be(e);return eo(t)?t.host:t}function ui(e){const t=nt(e);return Et(t)?e.ownerDocument?e.ownerDocument.body:e.body:qe(t)&&Yt(t)?t:ui(t)}function zt(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ui(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),l=Ae(o);if(a){const c=jr(l);return t.concat(l,l.visualViewport||[],Yt(o)?o:[],c&&n?zt(c):[])}else return t.concat(o,zt(o,[],n))}function jr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fi(e){const t=Oe(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=qe(e),a=o?e.offsetWidth:n,l=o?e.offsetHeight:s,c=wn(n)!==a||wn(s)!==l;return c&&(n=a,s=l),{width:n,height:s,$:c}}function is(e){return Me(e)?e:e.contextElement}function jt(e){const t=is(e);if(!qe(t))return Fe(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=fi(t);let l=(a?wn(n.width):n.width)/s,c=(a?wn(n.height):n.height)/o;return(!l||!Number.isFinite(l))&&(l=1),(!c||!Number.isFinite(c))&&(c=1),{x:l,y:c}}const Np=Fe(0);function mi(e){const t=Ae(e);return!as()||!t.visualViewport?Np:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jp(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ae(e)?!1:t}function dt(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=is(e);let l=Fe(1);t&&(s?Me(s)&&(l=jt(s)):l=jt(e));const c=jp(a,n,s)?mi(a):Fe(0);let d=(o.left+c.x)/l.x,f=(o.top+c.y)/l.y,u=o.width/l.x,m=o.height/l.y;if(a){const h=Ae(a),x=s&&Me(s)?Ae(s):s;let g=h,p=jr(g);for(;p&&s&&x!==g;){const v=jt(p),b=p.getBoundingClientRect(),y=Oe(p),w=b.left+(p.clientLeft+parseFloat(y.paddingLeft))*v.x,j=b.top+(p.clientTop+parseFloat(y.paddingTop))*v.y;d*=v.x,f*=v.y,u*=v.x,m*=v.y,d+=w,f+=j,g=Ae(p),p=jr(g)}}return jn({width:u,height:m,x:d,y:f})}function $n(e,t){const n=Ln(e).scrollLeft;return t?t.left+n:dt(Be(e)).left+n}function pi(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-$n(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function kp(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",l=Be(s),c=t?In(t.floating):!1;if(s===l||c&&a)return n;let d={scrollLeft:0,scrollTop:0},f=Fe(1);const u=Fe(0),m=qe(s);if((m||!m&&!a)&&((Mt(s)!=="body"||Yt(l))&&(d=Ln(s)),m)){const x=dt(s);f=jt(s),u.x=x.x+s.clientLeft,u.y=x.y+s.clientTop}const h=l&&!m&&!a?pi(l,d):Fe(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+u.x+h.x,y:n.y*f.y-d.scrollTop*f.y+u.y+h.y}}function Cp(e){return Array.from(e.getClientRects())}function Sp(e){const t=Be(e),n=Ln(e),s=e.ownerDocument.body,o=Se(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=Se(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let l=-n.scrollLeft+$n(e);const c=-n.scrollTop;return Oe(s).direction==="rtl"&&(l+=Se(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:l,y:c}}const to=25;function Ep(e,t){const n=Ae(e),s=Be(e),o=n.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,d=0;if(o){a=o.width,l=o.height;const u=as();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=$n(s);if(f<=0){const u=s.ownerDocument,m=u.body,h=getComputedStyle(m),x=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(s.clientWidth-m.clientWidth-x);g<=to&&(a-=g)}else f<=to&&(a+=f);return{width:a,height:l,x:c,y:d}}function Ap(e,t){const n=dt(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=qe(e)?jt(e):Fe(1),l=e.clientWidth*a.x,c=e.clientHeight*a.y,d=o*a.x,f=s*a.y;return{width:l,height:c,x:d,y:f}}function no(e,t,n){let s;if(t==="viewport")s=Ep(e,n);else if(t==="document")s=Sp(Be(e));else if(Me(t))s=Ap(t,n);else{const o=mi(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return jn(s)}function hi(e,t){const n=nt(e);return n===t||!Me(n)||Et(n)?!1:Oe(n).position==="fixed"||hi(n,t)}function Tp(e,t){const n=t.get(e);if(n)return n;let s=zt(e,[],!1).filter(c=>Me(c)&&Mt(c)!=="body"),o=null;const a=Oe(e).position==="fixed";let l=a?nt(e):e;for(;Me(l)&&!Et(l);){const c=Oe(l),d=os(l);!d&&c.position==="fixed"&&(o=null),(a?!d&&!o:!d&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Yt(l)&&!d&&hi(e,l))?s=s.filter(u=>u!==l):o=c,l=nt(l)}return t.set(e,s),s}function Rp(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const l=[...n==="clippingAncestors"?In(t)?[]:Tp(t,this._c):[].concat(n),s],c=no(t,l[0],o);let d=c.top,f=c.right,u=c.bottom,m=c.left;for(let h=1;h<l.length;h++){const x=no(t,l[h],o);d=Se(x.top,d),f=tt(x.right,f),u=tt(x.bottom,u),m=Se(x.left,m)}return{width:f-m,height:u-d,x:m,y:d}}function _p(e){const{width:t,height:n}=fi(e);return{width:t,height:n}}function Pp(e,t,n){const s=qe(t),o=Be(t),a=n==="fixed",l=dt(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const d=Fe(0);function f(){d.x=$n(o)}if(s||!s&&!a)if((Mt(t)!=="body"||Yt(o))&&(c=Ln(t)),s){const x=dt(t,!0,a,t);d.x=x.x+t.clientLeft,d.y=x.y+t.clientTop}else o&&f();a&&!s&&o&&f();const u=o&&!s&&!a?pi(o,c):Fe(0),m=l.left+c.scrollLeft-d.x-u.x,h=l.top+c.scrollTop-d.y-u.y;return{x:m,y:h,width:l.width,height:l.height}}function lr(e){return Oe(e).position==="static"}function ro(e,t){if(!qe(e)||Oe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Be(e)===n&&(n=n.ownerDocument.body),n}function xi(e,t){const n=Ae(e);if(In(e))return n;if(!qe(e)){let o=nt(e);for(;o&&!Et(o);){if(Me(o)&&!lr(o))return o;o=nt(o)}return n}let s=ro(e,t);for(;s&&vp(s)&&lr(s);)s=ro(s,t);return s&&Et(s)&&lr(s)&&!os(s)?n:s||wp(e)||n}const Dp=async function(e){const t=this.getOffsetParent||xi,n=this.getDimensions,s=await n(e.floating);return{reference:Pp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Mp(e){return Oe(e).direction==="rtl"}const Op={convertOffsetParentRelativeRectToViewportRelativeRect:kp,getDocumentElement:Be,getClippingRect:Rp,getOffsetParent:xi,getElementRects:Dp,getClientRects:Cp,getDimensions:_p,getScale:jt,isElement:Me,isRTL:Mp};function gi(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ip(e,t){let n=null,s;const o=Be(e);function a(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function l(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),a();const f=e.getBoundingClientRect(),{left:u,top:m,width:h,height:x}=f;if(c||t(),!h||!x)return;const g=on(m),p=on(o.clientWidth-(u+h)),v=on(o.clientHeight-(m+x)),b=on(u),w={rootMargin:-g+"px "+-p+"px "+-v+"px "+-b+"px",threshold:Se(0,tt(1,d))||1};let j=!0;function C(S){const k=S[0].intersectionRatio;if(k!==d){if(!j)return l();k?l(!1,k):s=setTimeout(()=>{l(!1,1e-7)},1e3)}k===1&&!gi(f,e.getBoundingClientRect())&&l(),j=!1}try{n=new IntersectionObserver(C,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return l(!0),a}function Lp(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:l=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=s,f=is(e),u=o||a?[...f?zt(f):[],...t?zt(t):[]]:[];u.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const m=f&&c?Ip(f,n):null;let h=-1,x=null;l&&(x=new ResizeObserver(b=>{let[y]=b;y&&y.target===f&&x&&t&&(x.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=x)==null||w.observe(t)})),n()}),f&&!d&&x.observe(f),t&&x.observe(t));let g,p=d?dt(e):null;d&&v();function v(){const b=dt(e);p&&!gi(p,b)&&n(),p=b,g=requestAnimationFrame(v)}return n(),()=>{var b;u.forEach(y=>{o&&y.removeEventListener("scroll",n),a&&y.removeEventListener("resize",n)}),m==null||m(),(b=x)==null||b.disconnect(),x=null,d&&cancelAnimationFrame(g)}}const $p=pp,Fp=hp,Bp=up,Up=gp,Wp=fp,so=dp,Vp=xp,zp=(e,t,n)=>{const s=new Map,o={platform:Op,...n},a={...o.platform,_c:s};return cp(e,t,{...o,platform:a})};var Hp=typeof document<"u",Kp=function(){},cn=Hp?i.useLayoutEffect:Kp;function kn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!kn(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const a=o[s];if(!(a==="_owner"&&e.$$typeof)&&!kn(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function vi(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oo(e,t){const n=vi(e);return Math.round(t*n)/n}function cr(e){const t=i.useRef(e);return cn(()=>{t.current=e}),t}function qp(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:a,floating:l}={},transform:c=!0,whileElementsMounted:d,open:f}=e,[u,m]=i.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,x]=i.useState(s);kn(h,s)||x(s);const[g,p]=i.useState(null),[v,b]=i.useState(null),y=i.useCallback(I=>{I!==S.current&&(S.current=I,p(I))},[]),w=i.useCallback(I=>{I!==k.current&&(k.current=I,b(I))},[]),j=a||g,C=l||v,S=i.useRef(null),k=i.useRef(null),A=i.useRef(u),R=d!=null,D=cr(d),F=cr(o),_=cr(f),$=i.useCallback(()=>{if(!S.current||!k.current)return;const I={placement:t,strategy:n,middleware:h};F.current&&(I.platform=F.current),zp(S.current,k.current,I).then(E=>{const ne={...E,isPositioned:_.current!==!1};V.current&&!kn(A.current,ne)&&(A.current=ne,En.flushSync(()=>{m(ne)}))})},[h,t,n,F,_]);cn(()=>{f===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,m(I=>({...I,isPositioned:!1})))},[f]);const V=i.useRef(!1);cn(()=>(V.current=!0,()=>{V.current=!1}),[]),cn(()=>{if(j&&(S.current=j),C&&(k.current=C),j&&C){if(D.current)return D.current(j,C,$);$()}},[j,C,$,D,R]);const z=i.useMemo(()=>({reference:S,floating:k,setReference:y,setFloating:w}),[y,w]),M=i.useMemo(()=>({reference:j,floating:C}),[j,C]),T=i.useMemo(()=>{const I={position:n,left:0,top:0};if(!M.floating)return I;const E=oo(M.floating,u.x),ne=oo(M.floating,u.y);return c?{...I,transform:"translate("+E+"px, "+ne+"px)",...vi(M.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:ne}},[n,c,M.floating,u.x,u.y]);return i.useMemo(()=>({...u,update:$,refs:z,elements:M,floatingStyles:T}),[u,$,z,M,T])}const Gp=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?so({element:s.current,padding:o}).fn(n):{}:s?so({element:s,padding:o}).fn(n):{}}}},Yp=(e,t)=>{const n=$p(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xp=(e,t)=>{const n=Fp(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jp=(e,t)=>({fn:Vp(e).fn,options:[e,t]}),Zp=(e,t)=>{const n=Bp(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qp=(e,t)=>{const n=Up(e);return{name:n.name,fn:n.fn,options:[e,t]}},eh=(e,t)=>{const n=Wp(e);return{name:n.name,fn:n.fn,options:[e,t]}},th=(e,t)=>{const n=Gp(e);return{name:n.name,fn:n.fn,options:[e,t]}};var nh="Arrow",bi=i.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...a}=e;return r.jsx(Q.svg,{...a,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});bi.displayName=nh;var rh=bi;function yi(e){const[t,n]=i.useState(void 0);return ye(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let l,c;if("borderBoxSize"in a){const d=a.borderBoxSize,f=Array.isArray(d)?d[0]:d;l=f.inlineSize,c=f.blockSize}else l=e.offsetWidth,c=e.offsetHeight;n({width:l,height:c})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var ls="Popper",[wi,Ni]=rt(ls),[sh,ji]=wi(ls),ki=e=>{const{__scopePopper:t,children:n}=e,[s,o]=i.useState(null);return r.jsx(sh,{scope:t,anchor:s,onAnchorChange:o,children:n})};ki.displayName=ls;var Ci="PopperAnchor",Si=i.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=ji(Ci,n),l=i.useRef(null),c=le(t,l),d=i.useRef(null);return i.useEffect(()=>{const f=d.current;d.current=(s==null?void 0:s.current)||l.current,f!==d.current&&a.onAnchorChange(d.current)}),s?null:r.jsx(Q.div,{...o,ref:c})});Si.displayName=Ci;var cs="PopperContent",[oh,ah]=wi(cs),Ei=i.forwardRef((e,t)=>{var O,B,Y,X,J,q;const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:u=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:x="optimized",onPlaced:g,...p}=e,v=ji(cs,n),[b,y]=i.useState(null),w=le(t,ie=>y(ie)),[j,C]=i.useState(null),S=yi(j),k=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,R=s+(a!=="center"?"-"+a:""),D=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},F=Array.isArray(f)?f:[f],_=F.length>0,$={padding:D,boundary:F.filter(lh),altBoundary:_},{refs:V,floatingStyles:z,placement:M,isPositioned:T,middlewareData:I}=qp({strategy:"fixed",placement:R,whileElementsMounted:(...ie)=>Lp(...ie,{animationFrame:x==="always"}),elements:{reference:v.anchor},middleware:[Yp({mainAxis:o+A,alignmentAxis:l}),d&&Xp({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Jp():void 0,...$}),d&&Zp({...$}),Qp({...$,apply:({elements:ie,rects:fe,availableWidth:Ne,availableHeight:we})=>{const{width:H,height:oe}=fe.reference,ge=ie.floating.style;ge.setProperty("--radix-popper-available-width",`${Ne}px`),ge.setProperty("--radix-popper-available-height",`${we}px`),ge.setProperty("--radix-popper-anchor-width",`${H}px`),ge.setProperty("--radix-popper-anchor-height",`${oe}px`)}}),j&&th({element:j,padding:c}),ch({arrowWidth:k,arrowHeight:A}),h&&eh({strategy:"referenceHidden",...$})]}),[E,ne]=Ri(M),re=et(g);ye(()=>{T&&(re==null||re())},[T,re]);const de=(O=I.arrow)==null?void 0:O.x,ee=(B=I.arrow)==null?void 0:B.y,ue=((Y=I.arrow)==null?void 0:Y.centerOffset)!==0,[he,L]=i.useState();return ye(()=>{b&&L(window.getComputedStyle(b).zIndex)},[b]),r.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:T?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:he,"--radix-popper-transform-origin":[(X=I.transformOrigin)==null?void 0:X.x,(J=I.transformOrigin)==null?void 0:J.y].join(" "),...((q=I.hide)==null?void 0:q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(oh,{scope:n,placedSide:E,onArrowChange:C,arrowX:de,arrowY:ee,shouldHideArrow:ue,children:r.jsx(Q.div,{"data-side":E,"data-align":ne,...p,ref:w,style:{...p.style,animation:T?void 0:"none"}})})})});Ei.displayName=cs;var Ai="PopperArrow",ih={top:"bottom",right:"left",bottom:"top",left:"right"},Ti=i.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=ah(Ai,s),l=ih[a.placedSide];return r.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[l]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:r.jsx(rh,{...o,ref:n,style:{...o.style,display:"block"}})})});Ti.displayName=Ai;function lh(e){return e!==null}var ch=e=>({name:"transformOrigin",options:e,fn(t){var v,b,y;const{placement:n,rects:s,middlewareData:o}=t,l=((v=o.arrow)==null?void 0:v.centerOffset)!==0,c=l?0:e.arrowWidth,d=l?0:e.arrowHeight,[f,u]=Ri(n),m={start:"0%",center:"50%",end:"100%"}[u],h=(((b=o.arrow)==null?void 0:b.x)??0)+c/2,x=(((y=o.arrow)==null?void 0:y.y)??0)+d/2;let g="",p="";return f==="bottom"?(g=l?m:`${h}px`,p=`${-d}px`):f==="top"?(g=l?m:`${h}px`,p=`${s.floating.height+d}px`):f==="right"?(g=`${-d}px`,p=l?m:`${x}px`):f==="left"&&(g=`${s.floating.width+d}px`,p=l?m:`${x}px`),{data:{x:g,y:p}}}});function Ri(e){const[t,n="center"]=e.split("-");return[t,n]}var dh=ki,uh=Si,fh=Ei,mh=Ti;function _i(e){const t=i.useRef({value:e,previous:e});return i.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Pi=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ph="VisuallyHidden",hh=i.forwardRef((e,t)=>r.jsx(Q.span,{...e,ref:t,style:{...Pi,...e.style}}));hh.displayName=ph;var xh=[" ","Enter","ArrowUp","ArrowDown"],gh=[" ","Enter"],ut="Select",[Fn,Bn,vh]=wa(ut),[Ot]=rt(ut,[vh,Ni]),Un=Ni(),[bh,st]=Ot(ut),[yh,wh]=Ot(ut),Di=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:a,value:l,defaultValue:c,onValueChange:d,dir:f,name:u,autoComplete:m,disabled:h,required:x,form:g}=e,p=Un(t),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,C]=i.useState(!1),S=Qr(f),[k,A]=Ct({prop:s,defaultProp:o??!1,onChange:a,caller:ut}),[R,D]=Ct({prop:l,defaultProp:c,onChange:d,caller:ut}),F=i.useRef(null),_=v?g||!!v.closest("form"):!0,[$,V]=i.useState(new Set),z=Array.from($).map(M=>M.props.value).join(";");return r.jsx(dh,{...p,children:r.jsxs(bh,{required:x,scope:t,trigger:v,onTriggerChange:b,valueNode:y,onValueNodeChange:w,valueNodeHasChildren:j,onValueNodeHasChildrenChange:C,contentId:Ze(),value:R,onValueChange:D,open:k,onOpenChange:A,dir:S,triggerPointerDownPosRef:F,disabled:h,children:[r.jsx(Fn.Provider,{scope:t,children:r.jsx(yh,{scope:e.__scopeSelect,onNativeOptionAdd:i.useCallback(M=>{V(T=>new Set(T).add(M))},[]),onNativeOptionRemove:i.useCallback(M=>{V(T=>{const I=new Set(T);return I.delete(M),I})},[]),children:n})}),_?r.jsxs(rl,{"aria-hidden":!0,required:x,tabIndex:-1,name:u,autoComplete:m,value:R,onChange:M=>D(M.target.value),disabled:h,form:g,children:[R===void 0?r.jsx("option",{value:""}):null,Array.from($)]},z):null]})})};Di.displayName=ut;var Mi="SelectTrigger",Oi=i.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=Un(n),l=st(Mi,n),c=l.disabled||s,d=le(t,l.onTriggerChange),f=Bn(n),u=i.useRef("touch"),[m,h,x]=ol(p=>{const v=f().filter(w=>!w.disabled),b=v.find(w=>w.value===l.value),y=al(v,p,b);y!==void 0&&l.onValueChange(y.value)}),g=p=>{c||(l.onOpenChange(!0),x()),p&&(l.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(uh,{asChild:!0,...a,children:r.jsx(Q.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":sl(l.value)?"":void 0,...o,ref:d,onClick:Z(o.onClick,p=>{p.currentTarget.focus(),u.current!=="mouse"&&g(p)}),onPointerDown:Z(o.onPointerDown,p=>{u.current=p.pointerType;const v=p.target;v.hasPointerCapture(p.pointerId)&&v.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(g(p),p.preventDefault())}),onKeyDown:Z(o.onKeyDown,p=>{const v=m.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&h(p.key),!(v&&p.key===" ")&&xh.includes(p.key)&&(g(),p.preventDefault())})})})});Oi.displayName=Mi;var Ii="SelectValue",Li=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:l="",...c}=e,d=st(Ii,n),{onValueNodeHasChildrenChange:f}=d,u=a!==void 0,m=le(t,d.onValueNodeChange);return ye(()=>{f(u)},[f,u]),r.jsx(Q.span,{...c,ref:m,style:{pointerEvents:"none"},children:sl(d.value)?r.jsx(r.Fragment,{children:l}):a})});Li.displayName=Ii;var Nh="SelectIcon",$i=i.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(Q.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});$i.displayName=Nh;var jh="SelectPortal",Fi=e=>r.jsx(Vr,{asChild:!0,...e});Fi.displayName=jh;var ft="SelectContent",Bi=i.forwardRef((e,t)=>{const n=st(ft,e.__scopeSelect),[s,o]=i.useState();if(ye(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?En.createPortal(r.jsx(Ui,{scope:e.__scopeSelect,children:r.jsx(Fn.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(Wi,{...e,ref:t})});Bi.displayName=ft;var Pe=10,[Ui,ot]=Ot(ft),kh="SelectContentImpl",Ch=Wt("SelectContent.RemoveScroll"),Wi=i.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:l,side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:m,collisionBoundary:h,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v,...b}=e,y=st(ft,n),[w,j]=i.useState(null),[C,S]=i.useState(null),k=le(t,O=>j(O)),[A,R]=i.useState(null),[D,F]=i.useState(null),_=Bn(n),[$,V]=i.useState(!1),z=i.useRef(!1);i.useEffect(()=>{if(w)return Ho(w)},[w]),Io();const M=i.useCallback(O=>{const[B,...Y]=_().map(q=>q.ref.current),[X]=Y.slice(-1),J=document.activeElement;for(const q of O)if(q===J||(q==null||q.scrollIntoView({block:"nearest"}),q===B&&C&&(C.scrollTop=0),q===X&&C&&(C.scrollTop=C.scrollHeight),q==null||q.focus(),document.activeElement!==J))return},[_,C]),T=i.useCallback(()=>M([A,w]),[M,A,w]);i.useEffect(()=>{$&&T()},[$,T]);const{onOpenChange:I,triggerPointerDownPosRef:E}=y;i.useEffect(()=>{if(w){let O={x:0,y:0};const B=X=>{var J,q;O={x:Math.abs(Math.round(X.pageX)-(((J=E.current)==null?void 0:J.x)??0)),y:Math.abs(Math.round(X.pageY)-(((q=E.current)==null?void 0:q.y)??0))}},Y=X=>{O.x<=10&&O.y<=10?X.preventDefault():w.contains(X.target)||I(!1),document.removeEventListener("pointermove",B),E.current=null};return E.current!==null&&(document.addEventListener("pointermove",B),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",B),document.removeEventListener("pointerup",Y,{capture:!0})}}},[w,I,E]),i.useEffect(()=>{const O=()=>I(!1);return window.addEventListener("blur",O),window.addEventListener("resize",O),()=>{window.removeEventListener("blur",O),window.removeEventListener("resize",O)}},[I]);const[ne,re]=ol(O=>{const B=_().filter(J=>!J.disabled),Y=B.find(J=>J.ref.current===document.activeElement),X=al(B,O,Y);X&&setTimeout(()=>X.ref.current.focus())}),de=i.useCallback((O,B,Y)=>{const X=!z.current&&!Y;(y.value!==void 0&&y.value===B||X)&&(R(O),X&&(z.current=!0))},[y.value]),ee=i.useCallback(()=>w==null?void 0:w.focus(),[w]),ue=i.useCallback((O,B,Y)=>{const X=!z.current&&!Y;(y.value!==void 0&&y.value===B||X)&&F(O)},[y.value]),he=s==="popper"?kr:Vi,L=he===kr?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:m,collisionBoundary:h,collisionPadding:x,sticky:g,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(Ui,{scope:n,content:w,viewport:C,onViewportChange:S,itemRefCallback:de,selectedItem:A,onItemLeave:ee,itemTextRefCallback:ue,focusSelectedItem:T,selectedItemText:D,position:s,isPositioned:$,searchRef:ne,children:r.jsx(zr,{as:Ch,allowPinchZoom:!0,children:r.jsx(Wr,{asChild:!0,trapped:y.open,onMountAutoFocus:O=>{O.preventDefault()},onUnmountAutoFocus:Z(o,O=>{var B;(B=y.trigger)==null||B.focus({preventScroll:!0}),O.preventDefault()}),children:r.jsx(Ur,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:O=>O.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:r.jsx(he,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:O=>O.preventDefault(),...b,...L,onPlaced:()=>V(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Z(b.onKeyDown,O=>{const B=O.ctrlKey||O.altKey||O.metaKey;if(O.key==="Tab"&&O.preventDefault(),!B&&O.key.length===1&&re(O.key),["ArrowUp","ArrowDown","Home","End"].includes(O.key)){let X=_().filter(J=>!J.disabled).map(J=>J.ref.current);if(["ArrowUp","End"].includes(O.key)&&(X=X.slice().reverse()),["ArrowUp","ArrowDown"].includes(O.key)){const J=O.target,q=X.indexOf(J);X=X.slice(q+1)}setTimeout(()=>M(X)),O.preventDefault()}})})})})})})});Wi.displayName=kh;var Sh="SelectItemAlignedPosition",Vi=i.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=st(ft,n),l=ot(ft,n),[c,d]=i.useState(null),[f,u]=i.useState(null),m=le(t,k=>u(k)),h=Bn(n),x=i.useRef(!1),g=i.useRef(!0),{viewport:p,selectedItem:v,selectedItemText:b,focusSelectedItem:y}=l,w=i.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&f&&p&&v&&b){const k=a.trigger.getBoundingClientRect(),A=f.getBoundingClientRect(),R=a.valueNode.getBoundingClientRect(),D=b.getBoundingClientRect();if(a.dir!=="rtl"){const J=D.left-A.left,q=R.left-J,ie=k.left-q,fe=k.width+ie,Ne=Math.max(fe,A.width),we=window.innerWidth-Pe,H=Gs(q,[Pe,Math.max(Pe,we-Ne)]);c.style.minWidth=fe+"px",c.style.left=H+"px"}else{const J=A.right-D.right,q=window.innerWidth-R.right-J,ie=window.innerWidth-k.right-q,fe=k.width+ie,Ne=Math.max(fe,A.width),we=window.innerWidth-Pe,H=Gs(q,[Pe,Math.max(Pe,we-Ne)]);c.style.minWidth=fe+"px",c.style.right=H+"px"}const F=h(),_=window.innerHeight-Pe*2,$=p.scrollHeight,V=window.getComputedStyle(f),z=parseInt(V.borderTopWidth,10),M=parseInt(V.paddingTop,10),T=parseInt(V.borderBottomWidth,10),I=parseInt(V.paddingBottom,10),E=z+M+$+I+T,ne=Math.min(v.offsetHeight*5,E),re=window.getComputedStyle(p),de=parseInt(re.paddingTop,10),ee=parseInt(re.paddingBottom,10),ue=k.top+k.height/2-Pe,he=_-ue,L=v.offsetHeight/2,O=v.offsetTop+L,B=z+M+O,Y=E-B;if(B<=ue){const J=F.length>0&&v===F[F.length-1].ref.current;c.style.bottom="0px";const q=f.clientHeight-p.offsetTop-p.offsetHeight,ie=Math.max(he,L+(J?ee:0)+q+T),fe=B+ie;c.style.height=fe+"px"}else{const J=F.length>0&&v===F[0].ref.current;c.style.top="0px";const ie=Math.max(ue,z+p.offsetTop+(J?de:0)+L)+Y;c.style.height=ie+"px",p.scrollTop=B-ue+p.offsetTop}c.style.margin=`${Pe}px 0`,c.style.minHeight=ne+"px",c.style.maxHeight=_+"px",s==null||s(),requestAnimationFrame(()=>x.current=!0)}},[h,a.trigger,a.valueNode,c,f,p,v,b,a.dir,s]);ye(()=>w(),[w]);const[j,C]=i.useState();ye(()=>{f&&C(window.getComputedStyle(f).zIndex)},[f]);const S=i.useCallback(k=>{k&&g.current===!0&&(w(),y==null||y(),g.current=!1)},[w,y]);return r.jsx(Ah,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:x,onScrollButtonChange:S,children:r.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(Q.div,{...o,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Vi.displayName=Sh;var Eh="SelectPopperPosition",kr=i.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Pe,...a}=e,l=Un(n);return r.jsx(fh,{...l,...a,ref:t,align:s,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});kr.displayName=Eh;var[Ah,ds]=Ot(ft,{}),Cr="SelectViewport",zi=i.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=ot(Cr,n),l=ds(Cr,n),c=le(t,a.onViewportChange),d=i.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx(Fn.Slot,{scope:n,children:r.jsx(Q.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Z(o.onScroll,f=>{const u=f.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:h}=l;if(h!=null&&h.current&&m){const x=Math.abs(d.current-u.scrollTop);if(x>0){const g=window.innerHeight-Pe*2,p=parseFloat(m.style.minHeight),v=parseFloat(m.style.height),b=Math.max(p,v);if(b<g){const y=b+x,w=Math.min(g,y),j=y-w;m.style.height=w+"px",m.style.bottom==="0px"&&(u.scrollTop=j>0?j:0,m.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});zi.displayName=Cr;var Hi="SelectGroup",[Th,Rh]=Ot(Hi),_h=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Ze();return r.jsx(Th,{scope:n,id:o,children:r.jsx(Q.div,{role:"group","aria-labelledby":o,...s,ref:t})})});_h.displayName=Hi;var Ki="SelectLabel",qi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Rh(Ki,n);return r.jsx(Q.div,{id:o.id,...s,ref:t})});qi.displayName=Ki;var Cn="SelectItem",[Ph,Gi]=Ot(Cn),Yi=i.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...l}=e,c=st(Cn,n),d=ot(Cn,n),f=c.value===s,[u,m]=i.useState(a??""),[h,x]=i.useState(!1),g=le(t,y=>{var w;return(w=d.itemRefCallback)==null?void 0:w.call(d,y,s,o)}),p=Ze(),v=i.useRef("touch"),b=()=>{o||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(Ph,{scope:n,value:s,disabled:o,textId:p,isSelected:f,onItemTextChange:i.useCallback(y=>{m(w=>w||((y==null?void 0:y.textContent)??"").trim())},[]),children:r.jsx(Fn.ItemSlot,{scope:n,value:s,disabled:o,textValue:u,children:r.jsx(Q.div,{role:"option","aria-labelledby":p,"data-highlighted":h?"":void 0,"aria-selected":f&&h,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:g,onFocus:Z(l.onFocus,()=>x(!0)),onBlur:Z(l.onBlur,()=>x(!1)),onClick:Z(l.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:Z(l.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:Z(l.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:Z(l.onPointerMove,y=>{var w;v.current=y.pointerType,o?(w=d.onItemLeave)==null||w.call(d):v.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Z(l.onPointerLeave,y=>{var w;y.currentTarget===document.activeElement&&((w=d.onItemLeave)==null||w.call(d))}),onKeyDown:Z(l.onKeyDown,y=>{var j;((j=d.searchRef)==null?void 0:j.current)!==""&&y.key===" "||(gh.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});Yi.displayName=Cn;var Lt="SelectItemText",Xi=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,l=st(Lt,n),c=ot(Lt,n),d=Gi(Lt,n),f=wh(Lt,n),[u,m]=i.useState(null),h=le(t,b=>m(b),d.onItemTextChange,b=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,b,d.value,d.disabled)}),x=u==null?void 0:u.textContent,g=i.useMemo(()=>r.jsx("option",{value:d.value,disabled:d.disabled,children:x},d.value),[d.disabled,d.value,x]),{onNativeOptionAdd:p,onNativeOptionRemove:v}=f;return ye(()=>(p(g),()=>v(g)),[p,v,g]),r.jsxs(r.Fragment,{children:[r.jsx(Q.span,{id:d.textId,...a,ref:h}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?En.createPortal(a.children,l.valueNode):null]})});Xi.displayName=Lt;var Ji="SelectItemIndicator",Zi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return Gi(Ji,n).isSelected?r.jsx(Q.span,{"aria-hidden":!0,...s,ref:t}):null});Zi.displayName=Ji;var Sr="SelectScrollUpButton",Qi=i.forwardRef((e,t)=>{const n=ot(Sr,e.__scopeSelect),s=ds(Sr,e.__scopeSelect),[o,a]=i.useState(!1),l=le(t,s.onScrollButtonChange);return ye(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;a(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(tl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Qi.displayName=Sr;var Er="SelectScrollDownButton",el=i.forwardRef((e,t)=>{const n=ot(Er,e.__scopeSelect),s=ds(Er,e.__scopeSelect),[o,a]=i.useState(!1),l=le(t,s.onScrollButtonChange);return ye(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<f;a(u)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(tl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});el.displayName=Er;var tl=i.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=ot("SelectScrollButton",n),l=i.useRef(null),c=Bn(n),d=i.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return i.useEffect(()=>()=>d(),[d]),ye(()=>{var u;const f=c().find(m=>m.ref.current===document.activeElement);(u=f==null?void 0:f.ref.current)==null||u.scrollIntoView({block:"nearest"})},[c]),r.jsx(Q.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Z(o.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:Z(o.onPointerMove,()=>{var f;(f=a.onItemLeave)==null||f.call(a),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:Z(o.onPointerLeave,()=>{d()})})}),Dh="SelectSeparator",nl=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(Q.div,{"aria-hidden":!0,...s,ref:t})});nl.displayName=Dh;var Ar="SelectArrow",Mh=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Un(n),a=st(Ar,n),l=ot(Ar,n);return a.open&&l.position==="popper"?r.jsx(mh,{...o,...s,ref:t}):null});Mh.displayName=Ar;var Oh="SelectBubbleInput",rl=i.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=i.useRef(null),a=le(s,o),l=_i(t);return i.useEffect(()=>{const c=o.current;if(!c)return;const d=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&u){const m=new Event("change",{bubbles:!0});u.call(c,t),c.dispatchEvent(m)}},[l,t]),r.jsx(Q.select,{...n,style:{...Pi,...n.style},ref:a,defaultValue:t})});rl.displayName=Oh;function sl(e){return e===""||e===void 0}function ol(e){const t=et(e),n=i.useRef(""),s=i.useRef(0),o=i.useCallback(l=>{const c=n.current+l;t(c),(function d(f){n.current=f,window.clearTimeout(s.current),f!==""&&(s.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),a=i.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return i.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,a]}function al(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let l=Ih(e,Math.max(a,0));o.length===1&&(l=l.filter(f=>f!==n));const d=l.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function Ih(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Lh=Di,il=Oi,$h=Li,Fh=$i,Bh=Fi,ll=Bi,Uh=zi,cl=qi,dl=Yi,Wh=Xi,Vh=Zi,ul=Qi,fl=el,ml=nl;const Re=Lh,We=$h,ke=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(il,{ref:s,className:U("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,r.jsx(Fh,{asChild:!0,children:r.jsx(Tt,{className:"h-4 w-4 opacity-50"})})]}));ke.displayName=il.displayName;const pl=i.forwardRef(({className:e,...t},n)=>r.jsx(ul,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Ir,{className:"h-4 w-4"})}));pl.displayName=ul.displayName;const hl=i.forwardRef(({className:e,...t},n)=>r.jsx(fl,{ref:n,className:U("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Tt,{className:"h-4 w-4"})}));hl.displayName=fl.displayName;const Ce=i.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(Bh,{children:r.jsxs(ll,{ref:o,className:U("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[r.jsx(pl,{}),r.jsx(Uh,{className:U("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(hl,{})]})}));Ce.displayName=ll.displayName;const zh=i.forwardRef(({className:e,...t},n)=>r.jsx(cl,{ref:n,className:U("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));zh.displayName=cl.displayName;const be=i.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(dl,{ref:s,className:U("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Vh,{children:r.jsx(He,{className:"h-4 w-4"})})}),r.jsx(Wh,{children:t})]}));be.displayName=dl.displayName;const Hh=i.forwardRef(({className:e,...t},n)=>r.jsx(ml,{ref:n,className:U("-mx-1 my-1 h-px bg-muted",e),...t}));Hh.displayName=ml.displayName;const Tr="bypass",us=[{value:"claudecode",label:"claudecode",supportsFollowUp:!0},{value:"codex",label:"codex",supportsFollowUp:!0},{value:"mars",label:"mars",disabled:!0,description:"coming soon"},{value:"eureka",label:"eureka",disabled:!0,description:"coming soon"}],xl=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],Kh=new Set(us.filter(e=>e.supportsFollowUp).map(e=>e.value)),qh=20,Gh=3,ao="meshy-working-dir-recents-by-node";function Yh(e){return e.startsWith("/")||e.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(e)}function Xh(e){const t=e.trim();return t||"."}function Rr(e){const t=[],n=new Set;for(const s of e){const o=s.trim();if(!(!o||n.has(o))&&(n.add(o),t.push(o),t.length===Gh))break}return t}function Jh(e,t){const n=t.trim();return Rr(n?[n,...e]:e)}function Zh(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e)){if(!n||!Array.isArray(s))continue;const o=s.filter(l=>typeof l=="string"),a=Rr(o);a.length>0&&(t[n]=a)}return t}function Qh(e,t,n){if(!t)return e;const s=e[t]??[],o=Jh(s,n);if(o.length===0){if(!(t in e))return e;const{[t]:a,...l}=e;return l}return{...e,[t]:o}}function ex(e,t,n){return e!=="auto"?t.find(s=>s.id===e)??null:n.length===1?n[0]??null:null}function tx(e,t){const n=t.trim();return n?Yh(n)||!e?n:`${e.replace(/[/\\]+$/,"")}/${n}`:""}function nx(e,t){return e?e.isAbsolute?e.currentPath:e.currentPath==="."||e.currentPath===""?e.rootPath||(t==null?void 0:t.workDir)||"Node root":e.currentPath:(t==null?void 0:t.workDir)??"Node root"}function io({value:e,onChange:t,assignTo:n,nodes:s,assignableNodes:o,layout:a="default",chipClassName:l,chipActiveClassName:c,chipInactiveClassName:d,labelClassName:f,triggerClassName:u}){const[m,h]=i.useState(!1),[x,g]=i.useState(null),[p,v]=i.useState(!1),[b,y]=i.useState(!1),[w,j]=i.useState(null),[C,S]=i.useState(""),[k,A]=i.useState(!1),[R,D]=i.useState({}),F=i.useRef(null),_=i.useMemo(()=>ex(n,s,o),[n,s,o]),$=_==null?void 0:_.id,V=i.useMemo(()=>$?R[$]??[]:[],[R,$]),z=i.useMemo(()=>e.trim()?tx(_==null?void 0:_.workDir,e):"Use node default",[e,_==null?void 0:_.workDir]);i.useEffect(()=>{if(!(typeof window>"u"))try{const L=window.localStorage.getItem(ao);if(!L)return;const O=JSON.parse(L);D(Zh(O))}catch{}},[]);const M=i.useCallback(L=>{$&&D(O=>{const B=Qh(O,$,L);if(B===O)return O;if(typeof window<"u")try{window.localStorage.setItem(ao,JSON.stringify(B))}catch{}return B})},[$]),T=i.useCallback((L,O=!0)=>{const B=L.trim();t(B),O&&B&&M(B),h(!1)},[t,M]),I=i.useCallback(async(L,O=0,B=!1)=>{if($){j(null),B?y(!0):v(!0);try{const Y=await dc($,{path:L,limit:qh,offset:O,directoriesOnly:!0,allowAbsolute:!0});g(X=>B&&X?{...Y,entries:[...X.entries,...Y.entries]}:Y)}catch(Y){j(Y instanceof Error?Y.message:"Failed to browse directories"),B||g(null)}finally{v(!1),y(!1)}}},[$]),E=i.useRef(e);E.current=e;const ne=i.useRef(I);ne.current=I,i.useEffect(()=>{if(!m)return;const L=E.current;S(L),A(!1),g(null),j(null),$&&ne.current(Xh(L))},[m,$]),i.useEffect(()=>{if(!m)return;const L=B=>{F.current&&(F.current.contains(B.target)||h(!1))},O=B=>{B.key==="Escape"&&h(!1)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",O)}},[m]);const re=i.useCallback(L=>{I(L)},[I]),de=i.useCallback(()=>{x&&I(x.currentPath,x.entries.length,!0)},[x,I]),ee=a==="composer"?r.jsxs(K,{type:"button",variant:"ghost",onClick:()=>h(L=>!L),title:z,"aria-label":`Working directory: ${z}`,className:U(l,u,"min-w-0 max-w-full",e.trim()?c:d),children:[r.jsx(ed,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:U("min-w-0 truncate",f),children:z})]}):r.jsxs(K,{type:"button",variant:"outline",onClick:()=>h(L=>!L),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:z,children:[r.jsx("span",{className:U("truncate",e.trim()?"font-mono text-foreground":"text-muted-foreground"),children:z}),r.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:_?_.name:"Manual"})]}),ue=nx(x,_),he=!!(x!=null&&x.parentPath);return r.jsxs("div",{className:U("relative inline-block",a==="composer"?"min-w-0 flex-1":"w-full"),ref:F,children:[a==="default"?r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Working directory"}),ee]}):ee,m&&r.jsxs("div",{className:U("absolute z-50 mt-2 w-[360px] overflow-hidden rounded-2xl border border-border/60 bg-background/95 shadow-lg backdrop-blur",a==="composer"?"left-0":"left-0 right-0 w-auto min-w-[320px]"),children:[V.length>0&&r.jsxs("div",{className:"border-b border-border/60 px-3 py-2.5",children:[r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[r.jsx(ld,{className:"h-3 w-3"}),"Recent"]}),r.jsx("div",{className:"flex flex-col gap-1",children:V.map(L=>r.jsx("button",{type:"button",onClick:()=>T(L,!1),className:"truncate rounded-md px-2 py-1 text-left font-mono text-xs text-foreground hover:bg-background/60",title:L,children:L},L))})]}),r.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[r.jsx("button",{type:"button",onClick:()=>(x==null?void 0:x.parentPath)&&re(x.parentPath),disabled:!he||p,className:"flex h-7 w-7 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:r.jsx(Oc,{className:"h-3.5 w-3.5"})}),r.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:ue,children:ue}),x&&r.jsx("button",{type:"button",onClick:()=>T(x.isAbsolute?x.currentPath:x.currentPath==="."?"":x.currentPath),className:"shrink-0 rounded-md px-2 py-1 text-[11px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),r.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[_?p?r.jsxs("div",{className:"flex items-center justify-center px-3 py-6 text-xs text-muted-foreground",children:[r.jsx(je,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Loading..."]}):x&&x.entries.length>0?r.jsxs(r.Fragment,{children:[x.entries.map(L=>r.jsxs("div",{className:"group flex items-stretch border-b border-border/40 last:border-b-0",children:[r.jsxs("button",{type:"button",onClick:()=>T(L.path),className:"flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left hover:bg-background/55",title:`Use ${L.path}`,children:[r.jsx(nd,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate text-sm text-foreground",children:L.name})]}),r.jsx("button",{type:"button",onClick:()=>re(L.path),className:"flex w-16 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 ${L.name}`,children:r.jsx(Or,{className:"h-4 w-4"})})]},L.path)),x.hasMore&&r.jsx("div",{className:"border-t border-border/60 p-2",children:r.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:de,disabled:b,className:"h-8 w-full rounded-md text-xs",children:[b?r.jsx(je,{className:"mr-1.5 h-3 w-3 animate-spin"}):null,"Load more"]})})]}):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:w??"No subfolders."}):r.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Select a specific node to browse folders."}),w&&x&&x.entries.length>0&&r.jsx("div",{className:"border-t border-border/60 px-3 py-2 text-xs text-destructive",children:w})]}),r.jsx("div",{className:"flex items-center gap-1.5 border-t border-border/60 bg-background/40 px-3 py-2",children:k?r.jsxs(r.Fragment,{children:[r.jsx(St,{value:C,onChange:L=>S(L.target.value),onKeyDown:L=>{L.key==="Enter"&&C.trim()?(L.preventDefault(),T(C)):L.key==="Escape"&&(L.preventDefault(),A(!1),S(e))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-8 flex-1 rounded-md border-border/60 bg-background/70 font-mono text-xs"}),r.jsx("button",{type:"button",onClick:()=>T(C),disabled:!C.trim(),className:"flex h-8 w-8 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:r.jsx(He,{className:"h-4 w-4"})}),r.jsx("button",{type:"button",onClick:()=>{A(!1),S(e)},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","aria-label":"Cancel manual path",children:r.jsx(kt,{className:"h-4 w-4"})})]}):r.jsxs("button",{type:"button",onClick:()=>{S(e),A(!0)},className:"flex h-8 flex-1 items-center justify-between rounded-md px-2 text-xs text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[r.jsx("span",{children:"Manual input"}),r.jsx(Lr,{className:"h-3.5 w-3.5"})]})})]})]})}function rx(e,t={}){const n=e.filter(s=>s.status==="online");return t.currentNodeRole!=="follower"||!t.leaderNodeId?n:n.filter(s=>s.id!==t.leaderNodeId)}function lo(){return us.map(e=>r.jsx(be,{value:e.value,disabled:e.disabled,children:r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{children:e.label}),e.description&&r.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:e.description})]})},e.value))}function co(){return xl.map(e=>r.jsx(be,{value:e.value,children:r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{children:e.label}),e.description&&r.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:e.description})]})},e.value))}function gl({isCurrent:e}){return e?r.jsx(ud,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):r.jsx(ad,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function uo(e,t){return e.map(n=>{const s=!!t&&n.id===t;return r.jsx(be,{value:n.id,children:r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(gl,{isCurrent:s}),r.jsx("span",{className:"truncate",children:n.name}),r.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:s?"current":"remote"})]})},n.id)})}function sx(e){var t;return((t=us.find(n=>n.value===e))==null?void 0:t.label)??e}function ox(e){var t;return((t=xl.find(n=>n.value===e))==null?void 0:t.label)??e}function vl(e,t,n=!1){const s=e.trim();if(s)return s;const o=t.trim().split(`
256
+ `).map(a=>a.trim()).find(Boolean);return o?o.length>72?`${o.slice(0,69).trimEnd()}...`:o:n?"Image task":""}function ax(e){const t=vl(e.title,e.description,e.images.length>0),n=e.description.trim()||t,s=e.mode??Tr,o=Ro(e.description,e.images);return!t||!n||!e.agent?null:{title:t,description:n,agent:e.agent,project:e.project.trim()||null,payload:{initialMessage:o,mode:s},priority:e.priority,assignTo:e.assignTo==="auto"?void 0:e.assignTo}}function ix({nodes:e,currentNodeRole:t,currentNodeId:n,leaderNodeId:s,onCreated:o,onCancel:a,className:l,footerClassName:c,submitLabel:d="Create chat",cancelLabel:f="Cancel",autoFocus:u=!1,layout:m="default"}){const[h,x]=i.useState(""),[g,p]=i.useState(""),[v,b]=i.useState("claudecode"),[y,w]=i.useState(Tr),[j,C]=i.useState(""),[S,k]=i.useState("normal"),A=i.useMemo(()=>rx(e,{currentNodeRole:t,leaderNodeId:s}),[e,t,s]),R=i.useMemo(()=>{var H;return n&&A.some(oe=>oe.id===n)?n:((H=A[0])==null?void 0:H.id)??""},[A,n]),[D,F]=i.useState(R),[_,$]=i.useState(!1),[V,z]=i.useState(!1),{images:M,error:T,fileInputRef:I,pickImages:E,handleFileChange:ne,handlePaste:re,removeImage:de}=va(),ee=i.useMemo(()=>A.find(H=>H.id===D)??null,[D,A]),ue=!!(n&&(ee==null?void 0:ee.id)===n),he=sx(v),L=ox(y);i.useEffect(()=>{D&&A.some(H=>H.id===D)||F(R)},[D,A,R]),i.useEffect(()=>{C("")},[D]);const O=i.useCallback(async H=>{H.preventDefault();const oe=ax({title:h,description:g,agent:v,project:j,priority:S,assignTo:D,mode:y,images:M});if(oe){$(!0);try{const ge=await uc(oe);o(ge)}catch(ge){pe.error(ge instanceof Error?ge.message:"Failed to create task")}finally{$(!1)}}},[h,g,v,j,S,D,y,M,o]),B=vl(h,g,M.length>0),Y=!!(B&&v&&D&&(g.trim()||M.length>0)),X=i.useCallback(H=>{var oe;H.nativeEvent.isComposing||H.key==="Enter"&&(H.ctrlKey||H.metaKey)&&Y&&!_&&(H.preventDefault(),(oe=H.currentTarget.form)==null||oe.requestSubmit())},[Y,_]),J=M.length>0&&r.jsx("div",{className:"flex flex-wrap gap-3",children:M.map((H,oe)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:Fr(H),alt:H.filename??`attachment ${oe+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>de(oe),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-full border border-border/70 bg-background text-muted-foreground transition-colors hover:text-foreground","aria-label":`Remove ${H.filename??`image ${oe+1}`}`,children:r.jsx(kt,{className:"h-3.5 w-3.5"})})]},`${H.filename??"image"}-${oe}`))}),q=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Assign to"}),r.jsxs(Re,{value:D,onValueChange:F,children:[r.jsx(ke,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(We,{placeholder:"Select node"})}),r.jsx(Ce,{children:uo(A,n)})]})]}),ie=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Agent"}),r.jsxs(Re,{value:v,onValueChange:b,children:[r.jsx(ke,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(We,{placeholder:"Select agent"})}),r.jsx(Ce,{children:lo()})]})]}),fe=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Mode"}),r.jsxs(Re,{value:y,onValueChange:H=>w(H),children:[r.jsx(ke,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(We,{placeholder:"Select mode"})}),r.jsx(Ce,{children:co()})]})]}),Ne=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Priority"}),r.jsxs(Re,{value:S,onValueChange:k,children:[r.jsx(ke,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(We,{placeholder:"Select priority"})}),r.jsxs(Ce,{children:[r.jsx(be,{value:"low",children:"Low"}),r.jsx(be,{value:"normal",children:"Normal"}),r.jsx(be,{value:"high",children:"High"}),r.jsx(be,{value:"critical",children:"Critical"})]})]})]}),we=r.jsx(io,{value:j,onChange:C,assignTo:D,nodes:e,assignableNodes:A});return m==="composer"?r.jsxs("form",{onSubmit:O,className:U("space-y-4",l),children:[r.jsx("input",{ref:I,type:"file",accept:"image/*",multiple:!0,onChange:ne,className:"hidden"}),(()=>{const H="chat-composer__chip h-9 w-auto gap-1.5 rounded-full px-3.5 text-xs shadow-none transition-colors",oe="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",ge="border-border/70 bg-background/55 text-foreground",mt=v==="claudecode",Vn=y===Tr;return r.jsxs("div",{className:"chat-composer relative rounded-[24px] border border-border/60 bg-background/45 shadow-[0_20px_80px_-40px_rgba(0,0,0,0.6)]",children:[r.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[r.jsxs(Re,{value:D,onValueChange:F,children:[r.jsx(ke,{className:U(H,ge,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${(ee==null?void 0:ee.name)??"unassigned"}`,"aria-label":`Assigned node: ${(ee==null?void 0:ee.name)??"unassigned"}`,children:ee?r.jsxs(r.Fragment,{children:[r.jsx(gl,{isCurrent:ue}),r.jsx("span",{className:"min-w-0 truncate",children:ee.name}),r.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:ue?"current":"remote"})]}):r.jsx(We,{placeholder:"Select node"})}),r.jsx(Ce,{children:uo(A,n)})]}),V?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(St,{id:"task-title-composer",type:"text",value:h,onChange:ve=>x(ve.target.value),onKeyDown:ve=>{(ve.key==="Enter"||ve.key==="Escape")&&(ve.preventDefault(),z(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-full border-border/70 bg-background/55 px-3 text-xs shadow-none"}),r.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>z(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:r.jsx(He,{className:"h-3.5 w-3.5"})})]}):r.jsxs("button",{type:"button",onClick:()=>z(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-full px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:B||"Title","aria-label":B?`Edit title: ${B}`:"Edit title",children:[r.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:B||"Title"}),r.jsx(Lr,{className:"h-3 w-3 shrink-0"})]})]}),r.jsx("textarea",{id:"task-description",value:g,onChange:ve=>p(ve.target.value),onKeyDown:X,onPaste:re,placeholder:"Ask anything...",rows:4,autoFocus:u,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-2 pb-16 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),r.jsxs("div",{className:"chat-composer__rail absolute bottom-3 left-3 right-3 flex flex-nowrap items-center gap-2",children:[r.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:E,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-full text-muted-foreground hover:text-foreground",children:r.jsx(fr,{className:"h-4 w-4"})}),r.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),r.jsx(io,{value:j,onChange:C,assignTo:D,nodes:e,assignableNodes:A,layout:"composer",chipClassName:H,chipActiveClassName:ge,chipInactiveClassName:oe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__footer-label"}),r.jsxs(Re,{value:v,onValueChange:b,children:[r.jsxs(ke,{className:U(H,"chat-composer__icon-trigger",mt?oe:ge),title:`Agent: ${he}`,"aria-label":`Agent: ${he}`,children:[r.jsx(Mr,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"chat-composer__footer-label truncate",children:he})]}),r.jsx(Ce,{children:lo()})]}),r.jsxs(Re,{value:y,onValueChange:ve=>w(ve),children:[r.jsxs(ke,{className:U(H,"chat-composer__icon-trigger",Vn?oe:ge),title:`Mode: ${L}`,"aria-label":`Mode: ${L}`,children:[r.jsx(Pd,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"chat-composer__footer-label truncate",children:L})]}),r.jsx(Ce,{children:co()})]}),r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[r.jsxs(Re,{value:S,onValueChange:k,children:[r.jsx(ke,{"aria-label":`Priority: ${S}`,title:`Priority: ${S}`,className:U("h-9 w-9 justify-center gap-0 rounded-full p-0 text-xs shadow-none [&>svg:last-child]:hidden",S==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",S==="critical"&&"text-destructive",S==="high"&&"text-amber-600 dark:text-amber-400",S==="low"&&"text-muted-foreground"),children:r.jsx(Zc,{className:U("h-4 w-4",S==="critical"&&"fill-destructive/20")})}),r.jsxs(Ce,{children:[r.jsx(be,{value:"low",children:"Low"}),r.jsx(be,{value:"normal",children:"Normal"}),r.jsx(be,{value:"high",children:"High"}),r.jsx(be,{value:"critical",children:"Critical"})]})]}),a&&r.jsxs(K,{type:"button",variant:"ghost",size:"sm",onClick:a,"aria-label":f,className:"chat-composer__cancel h-9 rounded-full px-4 text-xs text-muted-foreground",children:[r.jsx(kt,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),r.jsx("span",{className:"chat-composer__footer-label",children:f})]}),r.jsxs(K,{type:"submit",size:"icon",disabled:!Y||_,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[_?r.jsx(je,{className:"h-4 w-4 animate-spin"}):r.jsx(So,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:_?"Creating chat":d})]})]})]})]})})(),(J||T)&&r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[J,T&&r.jsx("div",{className:"text-xs text-destructive",children:T}),!T&&r.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."})]})]}):r.jsxs("form",{onSubmit:O,className:U("space-y-5",l),children:[r.jsx("input",{ref:I,type:"file",accept:"image/*",multiple:!0,onChange:ne,className:"hidden"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{htmlFor:"task-description",className:"text-sm font-medium",children:"Opening prompt"}),r.jsx("textarea",{id:"task-description",value:g,onChange:H=>p(H.target.value),onKeyDown:X,onPaste:re,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:u,className:"flex min-h-[144px] w-full resize-none rounded-[22px] border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs(K,{type:"button",variant:"outline",onClick:E,className:"rounded-2xl",children:[r.jsx(fr,{className:"h-4 w-4"}),"Add images"]}),r.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."})]}),J,T&&r.jsx("p",{className:"text-xs text-destructive",children:T})]}),r.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_220px_220px]",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{htmlFor:"task-title",className:"text-sm font-medium",children:"Chat title"}),r.jsx(St,{id:"task-title",type:"text",value:h,onChange:H=>x(H.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-11 rounded-2xl border-border/70 bg-background/70"}),r.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."})]}),ie,fe]}),we,r.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[Ne,q]}),r.jsxs("div",{className:U("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[a&&r.jsx(K,{type:"button",variant:"ghost",onClick:a,className:"rounded-2xl",children:f}),r.jsx(K,{type:"submit",disabled:!Y||_,className:"rounded-2xl px-5",children:_?"Creating...":d})]})]})}const lx=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"archived",label:"Archived"}],Sn=new Set(["pending","assigned"]),bl=new Set(["running"]),cx=new Set(["completed","failed","cancelled"]);function dx(e,t){switch(t){case"running":return bl.has(e.status);case"waiting":return Sn.has(e.status);case"closed":return cx.has(e.status);case"archived":return e.status==="archived";case"active":default:return e.status!=="archived"}}function ux(e,t){const n=t.trim().toLowerCase();return n?[e.title,e.description,e.id,e.agent,e.assignedTo??"",e.assignedNodeName??"",e.project??"",e.effectiveProjectPath??""].some(s=>s.toLowerCase().includes(n)):!0}function fs(e,t,n){if(!e)return"unassigned";const s=t==null?void 0:t.find(o=>o.id===e);return(s==null?void 0:s.name)??n??e.slice(0,8)}function fx(e,t,n){return fs(e,t,n).toLowerCase()}function mx(e,t){return[...e].sort((n,s)=>n.id===t?-1:s.id===t?1:n.name.localeCompare(s.name))}function px(e){if(!e||typeof e!="object")return null;const t=e;return{draftNewTask:t.draftNewTask===!0,returnRoute:typeof t.returnRoute=="string"?t.returnRoute:void 0,returnTaskId:typeof t.returnTaskId=="string"||t.returnTaskId===null?t.returnTaskId:void 0}}function hx(e){switch(e){case"running":return"bg-amber-500";case"completed":return"bg-emerald-500";case"failed":return"bg-destructive";case"cancelled":case"archived":return"bg-slate-400";case"assigned":return"bg-teal-500";case"pending":default:return"bg-muted-foreground"}}function xx(e){return e==="default workspace"?e:e.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??e}function gx(e){if(e==="default workspace")return"Uses the node default workspace";const t=e.replace(/\\/g,"/"),n=t.split("/").filter(Boolean);return n.length<=3?t:`.../${n.slice(-3).join("/")}`}function vx(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m`:t<864e5?`${Math.floor(t/36e5)}h`:`${Math.floor(t/864e5)}d`}function bx(e){return new Date(e).toLocaleString()}function yx(e){const t=Math.floor(e/1e3),n=Math.floor(t/3600),s=Math.floor(t%3600/60),o=t%60;return`${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(o).padStart(2,"0")}`}async function At(e,t="Copied to clipboard"){var n,s,o;try{if((s=(n=globalThis.navigator)==null?void 0:n.clipboard)!=null&&s.writeText)return await globalThis.navigator.clipboard.writeText(e),pe.success(t),!0;const a=globalThis.document,l=(o=a==null?void 0:a.execCommand)==null?void 0:o.bind(a);if(!(a!=null&&a.body)||typeof a.createElement!="function"||typeof l!="function")throw new Error("Clipboard access is unavailable");const c=a.createElement("textarea"),d=a.activeElement,f=d&&typeof d.focus=="function"?d:null;c.value=e,c.setAttribute("readonly","true"),c.style.position="fixed",c.style.opacity="0",c.style.pointerEvents="none",a.body.appendChild(c),c.select(),c.setSelectionRange(0,c.value.length);const u=l("copy");if(a.body.removeChild(c),f==null||f.focus(),!u)throw new Error("Clipboard access is unavailable");return pe.success(t),!0}catch(a){return pe.error(a instanceof Error?a.message:"Failed to copy"),!1}}function bt({label:e,value:t}){return r.jsxs("div",{className:"min-w-[7.25rem] flex-1 rounded-[20px] border border-border/60 bg-background/45 px-3 py-3",children:[r.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),r.jsx("div",{className:"mt-1 text-lg font-semibold tracking-tight text-foreground",children:t})]})}function dr({label:e}){return r.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function De({label:e,value:t,mono:n,action:s}){return r.jsxs("div",{className:"grid grid-cols-[5.25rem,minmax(0,1fr)] items-start gap-3",children:[r.jsx("span",{className:"pt-0.5 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),r.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[r.jsx("span",{className:U("min-w-0 flex-1 break-all text-sm text-foreground",n&&"font-mono text-[11px] leading-5"),children:t}),s]})]})}function _r({label:e,value:t,mono:n}){return r.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/60 px-3 py-3",children:[r.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),r.jsx("div",{className:U("mt-1 text-sm font-medium text-foreground",n&&"font-mono text-[11px]"),children:t})]})}function yl({capabilities:e,action:t}){return r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Capabilities"}),r.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:e.length>0?e.map(n=>r.jsx(Ee,{variant:"secondary",className:"rounded-full",children:n},n)):r.jsx("span",{className:"text-sm text-muted-foreground",children:"None declared"})})]}),t&&r.jsx("div",{className:"shrink-0 self-start",children:t})]})}const wx=i.lazy(async()=>({default:(await Dr(()=>import("./FilesTab-whvYFVNX.js"),__vite__mapDeps([0,1,2,3]))).FilesTab})),Nx=i.lazy(async()=>({default:(await Dr(()=>import("./PreviewTab-Dmb7EJl7.js"),__vite__mapDeps([4,1,2]))).PreviewTab})),jx=i.lazy(async()=>({default:(await Dr(()=>import("./DiffTab-C9xK4VcC.js"),__vite__mapDeps([5,1,2,3]))).DiffTab}));function kx({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,activeTab:c,setActiveTab:d,creatingTask:f,activeTask:u,assignedNode:m,taskLoading:h,taskError:x,displayEvents:g,hasUserMessageInLogs:p,initialPrompt:v,supportsFollowUp:b,taskUnavailable:y,chatDisabled:w,chatDisabledReason:j,questionBypassEnabled:C,isRunning:S,hasPendingFollowUp:k,canCancel:A,canRetry:R,onRetry:D,onCancel:F,onStartCreateTask:_,onCancelCreateTask:$,onCreateTask:V,onSendMessage:z,onQuestionBypassChange:M,onSubmitQuestionResponse:T,messagesEndRef:I}){const[E,ne]=i.useState(!1),[re,de]=i.useState(!1),[ee,ue]=i.useState(!1),he=i.useRef(0),L=i.useRef(!1),O=i.useCallback(q=>{const ie=q.currentTarget,fe=he.current;if(he.current=ie.scrollTop,L.current)return;if(ie.scrollHeight-ie.scrollTop-ie.clientHeight<30){de(!1),L.current=!0,setTimeout(()=>{L.current=!1},300);return}ie.scrollTop<fe&&fe-ie.scrollTop>10&&de(!0),ie.scrollTop<=0&&de(!0)},[]),B=(u==null?void 0:u.effectiveProjectPath)??(u==null?void 0:u.project)??"default workspace",Y=u?(m==null?void 0:m.name)??fs(u.assignedTo,a==null?void 0:a.nodes,u.assignedNodeName):"unassigned",X=u?[{label:"Working dir",value:B,mono:!0},{label:"Agent",value:u.agent,mono:!0},{label:"Node",value:Y}]:[],J=u!=null&&u.description&&u.description!==u.title?u.description:null;return f?r.jsx(Cx,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,onCancel:$,onCreated:V}):!u&&h?r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:r.jsx(dn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),r.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:r.jsxs("div",{className:"space-y-4 text-center",children:[r.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:r.jsx(je,{className:"h-7 w-7 animate-spin"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Loading conversation"}),r.jsxs("div",{className:"flex items-center justify-center gap-3 text-sm text-muted-foreground",children:[r.jsx(je,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?r.jsxs(Ua,{value:c,onValueChange:d,className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-2.5 sm:px-5",children:[r.jsx("div",{className:"flex items-center gap-3",children:r.jsx(dn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[r.jsx("h2",{className:"min-w-0 truncate text-base font-semibold tracking-tight text-foreground sm:text-lg",title:u.title,children:u.title}),r.jsx(bo,{status:u.status}),r.jsx(fc,{priority:u.priority}),r.jsx(K,{variant:"ghost",size:"icon",className:"ml-auto h-6 w-6 shrink-0 rounded-full text-muted-foreground",onClick:()=>ne(q=>!q),children:E?r.jsx(Ir,{className:"h-3.5 w-3.5"}):r.jsx(Tt,{className:"h-3.5 w-3.5"})})]}),E&&r.jsxs("div",{className:"mt-2 space-y-2",children:[J&&r.jsx("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:J}),x&&r.jsx("div",{className:"w-fit rounded-full border border-destructive/25 bg-destructive/10 px-3 py-1 text-xs text-destructive",children:x}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[r.jsxs("span",{children:["updated ",bx(u.updatedAt)]}),r.jsx("span",{className:"font-mono",children:u.id.slice(0,8)})]}),r.jsx("div",{className:"flex items-center gap-2",children:R&&r.jsxs(K,{variant:"outline",size:"sm",onClick:D,className:"shrink-0 rounded-full",children:[r.jsx(kd,{className:"h-3.5 w-3.5"}),"Retry"]})})]})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[r.jsxs(ts,{className:"h-auto max-w-full overflow-x-auto rounded-full bg-muted/70 p-1",children:[r.jsx(Xe,{value:"transcript",className:"rounded-full px-2.5 sm:px-4",children:"Transcript"}),r.jsx(Xe,{value:"files",className:"rounded-full px-2.5 sm:px-4",children:"Files"}),r.jsx(Xe,{value:"preview",className:"rounded-full px-2.5 sm:px-4",children:"Preview"}),r.jsx(Xe,{value:"diff",className:"rounded-full px-2.5 sm:px-4",children:"Diff"})]}),S&&r.jsx(Ee,{variant:"outline",className:"hidden rounded-full border-amber-500/30 bg-amber-500/10 text-amber-700 sm:inline-flex dark:text-amber-300",children:"Working"}),k&&r.jsx(Ee,{variant:"outline",className:"hidden rounded-full border-primary/30 bg-primary/10 text-primary sm:inline-flex",children:"Queued"}),y&&r.jsx(Ee,{variant:"outline",className:"hidden rounded-full border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"})]})]}),r.jsx(Je,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:r.jsxs("div",{className:"relative flex h-full min-h-0 flex-col",children:[r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-5",onScroll:O,children:r.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[v&&!p&&r.jsx(Ks,{event:v,questionBypassEnabled:C,onQuestionBypassChange:M,onSubmitQuestionResponse:T,questionResponseDisabled:!b||w}),g.map((q,ie)=>r.jsx(Ks,{event:q,questionBypassEnabled:C,onQuestionBypassChange:M,onSubmitQuestionResponse:T,questionResponseDisabled:!b||w},xu("transcript",q,ie))),g.length===0&&r.jsxs("div",{className:"rounded-[28px] border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:"Transcript is warming up"}),r.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:h?"Fetching task output...":"The opening prompt has been stored, but the agent has not emitted conversation output yet."})]}),(!b&&u.result||u.error)&&r.jsxs("div",{className:"space-y-3",children:[!b&&u.result&&r.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card/80 px-4 py-4",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),r.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(u.result,null,2)})]}),u.error&&r.jsxs("div",{className:"rounded-[26px] border border-destructive/20 bg-destructive/10 px-4 py-4 text-destructive",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),r.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-xs leading-5",children:u.error})]})]}),(S||k)&&g.length>0&&r.jsxs("div",{className:"flex items-center gap-3 rounded-[24px] border border-border/60 bg-background/45 px-4 py-3 text-sm text-muted-foreground",children:[r.jsx(je,{className:"h-4 w-4 animate-spin"}),"The agent is still working on this conversation."]}),r.jsx("div",{ref:I})]})}),b?re?r.jsx(K,{size:"icon",onClick:()=>de(!1),className:"absolute bottom-4 right-4 z-10 h-12 w-12 rounded-full shadow-lg",children:r.jsx(Lr,{className:"h-5 w-5"})}):r.jsx("div",{className:"shrink-0",children:r.jsx("div",{className:"mx-auto w-full max-w-[72rem]",children:r.jsx(im,{onSend:z,disabled:w,disabledReason:j,contextItems:X,placeholder:w?j:"Continue the conversation...",running:S||k,onStop:A?()=>ue(!0):void 0})})}):r.jsx("div",{className:"shrink-0 border-t border-border/60 px-4 py-4 text-sm text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),r.jsx(Je,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(dr,{label:"Loading files..."}),children:r.jsx(wx,{taskId:u.id})})}),r.jsx(Je,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(dr,{label:"Loading preview..."}),children:r.jsx(Nx,{taskId:u.id})})}),r.jsx(Je,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(dr,{label:"Loading diff..."}),children:r.jsx(jx,{taskId:u.id})})}),r.jsx(yr,{open:ee,onOpenChange:ue,children:r.jsxs(pn,{children:[r.jsxs(hn,{children:[r.jsx(gn,{children:"Stop this task?"}),r.jsx(vn,{children:"The task will stop and move to a cancelled state."})]}),r.jsxs(xn,{children:[r.jsx(yn,{children:"Keep running"}),r.jsx(bn,{onClick:F,children:"Stop task"})]})]})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:r.jsx(dn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),r.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-6 py-10 sm:px-8",children:r.jsxs("div",{className:"w-full max-w-2xl text-center",children:[r.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full border border-primary/20 bg-primary/10 text-primary",children:r.jsx(Mr,{className:"h-7 w-7"})}),r.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground sm:text-3xl",children:"No chat selected"}),r.jsx("p",{className:"mx-auto mt-3 max-w-xl text-sm leading-6 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task to create a fresh chat thread."}),r.jsxs(K,{onClick:_,className:"mt-6 rounded-full px-5",children:[r.jsx(jo,{className:"h-4 w-4"}),"Start new chat"]}),x&&r.jsx("div",{className:"mx-auto mt-4 max-w-lg rounded-[20px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:x})]})})]})}function Cx({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,onCancel:c,onCreated:d}){var f,u,m;return r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-2xl sm:rounded-[32px] border border-border/60 bg-background/78 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsx("div",{className:"shrink-0 border-b border-border/60 px-4 py-4 sm:px-5",children:r.jsx(dn,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l})}),r.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:r.jsx("div",{className:"w-full max-w-2xl",children:r.jsx(ix,{nodes:(a==null?void 0:a.nodes)??[],currentNodeRole:(f=a==null?void 0:a.self)==null?void 0:f.role,currentNodeId:((u=a==null?void 0:a.self)==null?void 0:u.id)??null,leaderNodeId:((m=a==null?void 0:a.leader)==null?void 0:m.id)??null,onCreated:d,onCancel:c,submitLabel:"Start chat",autoFocus:!0,layout:"composer"})})})]})}function dn({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l}){var c;return r.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[r.jsx(Sx,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:e}),r.jsx(Ee,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:l?"Live":"Retrying"}),((c=a==null?void 0:a.leader)==null?void 0:c.name)&&r.jsxs(Ee,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:["leader ",a.leader.name]})]}),r.jsxs(K,{variant:"outline",onClick:o,className:"shrink-0 rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(Co,{className:"h-4 w-4"}):r.jsx(wd,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide cluster":"Show cluster"})]})]})}function Sx({desktopTasksOpen:e,mobileTasksPanelOpen:t,onToggleTasks:n}){var o,a;const s=(a=(o=globalThis.window)==null?void 0:o.matchMedia("(min-width: 1024px)"))!=null&&a.matches?e:t;return r.jsxs(K,{variant:"outline",onClick:n,className:"rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(ko,{className:"h-4 w-4"}):r.jsx(vd,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide tasks":"Show tasks"})]})}const Ex={node:"border-teal-500/30 bg-teal-500/10 text-teal-700 dark:text-teal-300",task:"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300",election:"border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",cluster:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"};function Ax(e){return e.split(".")[0]??"unknown"}function Tx(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}function ur(e,t){return(t==null?void 0:t.get(e))??e}function Rx(e,t){const n=e.data;switch(e.type){case"node.joined":return`${n.name} joined the cluster`;case"node.left":return`${ur(n.nodeId,t)} left (${n.reason})`;case"node.status":return`${ur(n.nodeId,t)} is now ${n.status}`;case"task.created":return`"${n.title}" created`;case"task.assigned":return`task assigned to ${ur(n.nodeId,t)}`;case"task.status":return`task ${n.taskId.slice(0,8)} -> ${n.status}`;case"election.started":return`candidate ${n.candidateId.slice(0,8)} term ${n.term}`;case"election.complete":return`leader elected, term ${n.term}`;case"cluster.state":return`${n.nodeCount} nodes, term ${n.term}`;default:return JSON.stringify(n)}}function _x(e){return JSON.stringify(e,null,2)}function Px({events:e,maxHeight:t="400px",emptyTitle:n="No live events yet",emptyDescription:s="Cluster activity appears here as it happens.",nodeNameById:o}){return e.length===0?r.jsx("div",{className:"flex h-28 items-center justify-center rounded-[20px] border border-dashed border-border/70 bg-background/40 text-center",children:r.jsxs("div",{children:[r.jsx("div",{className:"text-sm text-muted-foreground",children:n}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground/70",children:s})]})}):r.jsx("div",{className:"overflow-y-auto pr-1",style:{maxHeight:t},children:r.jsx("div",{className:"space-y-2",children:e.map(a=>{const l=Ax(a.type);return r.jsx("div",{className:"rounded-[20px] border border-border/60 bg-background/45 px-4 py-3 transition-colors hover:border-border hover:bg-background/65",children:r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:Tx(a.timestamp)}),r.jsx(Ee,{variant:"outline",className:U("w-fit text-[10px] font-medium uppercase tracking-[0.16em]",Ex[l]),children:a.type})]}),r.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void At(_x(a),"Event copied"),"aria-label":`Copy ${a.type} event`,title:"Copy event",children:r.jsx(An,{className:"h-3.5 w-3.5"})})]}),r.jsx("div",{className:"text-sm leading-6 text-foreground/85",children:Rx(a,o)})]})},a.id)})})})}function fo({cluster:e,systemInfo:t,nodeNameById:n,nodeBlockingTaskCounts:s,eventTypeFilter:o,onEventTypeFilterChange:a,eventTypeOptions:l,filteredEvents:c,sseConnected:d,clusterLoading:f,clusterError:u,electionPending:m,onTriggerElection:h,promotePending:x,onPromote:g,onAddNode:p,leavePending:v,onLeaveCluster:b,onToggleNodeDevTunnel:y,devTunnelNodeId:w,onClose:j}){var _,$,V,z,M;const C=((_=e==null?void 0:e.self)==null?void 0:_.role)==="leader",S=(($=e==null?void 0:e.self)==null?void 0:$.role)==="follower"&&!(e!=null&&e.leader),k=(e==null?void 0:e.self)??null,R=mx((e==null?void 0:e.nodes)??[],k==null?void 0:k.id).filter(T=>T.id!==(k==null?void 0:k.id)),D=(k==null?void 0:k.role)==="leader"&&R.length===0,F=(k==null?void 0:k.role)==="follower"&&!!(e!=null&&e.leader);return r.jsx("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/84 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:r.jsxs(Ua,{defaultValue:"overview",className:"flex h-full min-h-0 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-lg font-semibold tracking-tight",children:"Operations"}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Node, cluster, and live events."})]}),r.jsx(K,{variant:"ghost",size:"icon",onClick:j,className:"rounded-full",children:r.jsx(Co,{className:"h-4 w-4"})})]}),r.jsxs(ts,{className:"mt-4 grid h-auto w-full grid-cols-3 rounded-full bg-muted/70 p-1",children:[r.jsx(Xe,{value:"overview",className:"rounded-full px-3 text-xs",children:"Overview"}),r.jsx(Xe,{value:"nodes",className:"rounded-full px-3 text-xs",children:"Nodes"}),r.jsx(Xe,{value:"events",className:"rounded-full px-3 text-xs",children:"Live events"})]})]}),r.jsx(Je,{value:"overview",className:"mt-0 min-h-0 flex-1",children:r.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-4 py-5",children:r.jsxs("div",{className:"space-y-7",children:[k&&r.jsx(mo,{node:k,systemInfo:t,blockingTaskCount:s.get(k.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y,showActions:!1,defaultExpanded:!1}),r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:"Cluster snapshot"}),r.jsx(Ee,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:d?"Connected":"Reconnecting"})]}),f&&!e?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(je,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):u&&!e?r.jsx("div",{className:"rounded-[22px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:u}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(bt,{label:"Term",value:String((e==null?void 0:e.term)??0)}),r.jsx(bt,{label:"Nodes",value:String((e==null?void 0:e.nodes.length)??0)}),r.jsx(bt,{label:"Pending",value:String((e==null?void 0:e.taskSummary.pending)??0)}),r.jsx(bt,{label:"Running",value:String((e==null?void 0:e.taskSummary.running)??0)}),r.jsx(bt,{label:"Completed",value:String((e==null?void 0:e.taskSummary.completed)??0)}),r.jsx(bt,{label:"Failed",value:String((e==null?void 0:e.taskSummary.failed)??0)})]}),r.jsxs("div",{className:"space-y-3 rounded-[24px] border border-border/60 bg-background/45 px-4 py-4",children:[r.jsx(De,{label:"Leader",value:((V=e==null?void 0:e.leader)==null?void 0:V.name)??"None"}),r.jsx(De,{label:"Leader URL",value:((z=e==null?void 0:e.leader)==null?void 0:z.endpoint)??"Unavailable",mono:!0,action:(M=e==null?void 0:e.leader)!=null&&M.endpoint?r.jsx(Ht,{label:"Copy leader URL",onClick:()=>{var T;return void At(((T=e.leader)==null?void 0:T.endpoint)??"","Leader URL copied")}}):void 0}),r.jsx(De,{label:"Feed",value:d?"Receiving live updates":"Reconnecting to event stream"})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[C&&r.jsxs(K,{variant:"outline",size:"sm",onClick:h,disabled:m,className:"rounded-full",children:[m&&r.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}),"Trigger election"]}),S&&r.jsxs(K,{variant:"outline",size:"sm",onClick:g,disabled:x,className:"rounded-full",children:[x&&r.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})]})]})]})]})})}),r.jsx(Je,{value:"nodes",className:"mt-0 min-h-0 flex-1",children:r.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-y-auto px-4 py-5",children:r.jsxs("div",{className:"space-y-7",children:[r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:"This node"}),D?r.jsx(K,{variant:"outline",size:"sm",onClick:p,className:"rounded-full",children:"Join node"}):F?r.jsxs(K,{variant:"outline",size:"sm",onClick:b,disabled:v,className:"rounded-full",children:[v&&r.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),k&&r.jsx(mo,{node:k,systemInfo:t,blockingTaskCount:s.get(k.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y,showActions:!0,defaultExpanded:!0})]}),r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{className:"text-sm font-medium text-foreground",children:["Peer nodes (",R.length,")"]}),R.length>0?r.jsx("div",{className:"space-y-3",children:R.map(T=>r.jsx(Dx,{node:T,isLeader:!!C,blockingTaskCount:s.get(T.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y},T.id))}):r.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-4 py-5 text-sm text-muted-foreground",children:"No peer nodes are connected yet."})]})]})})}),r.jsx(Je,{value:"events",className:"mt-0 min-h-0 flex-1",children:r.jsxs("div",{className:"flex h-full min-h-0 flex-col px-4 py-5",children:[r.jsxs("div",{className:"mb-4 space-y-3",children:[r.jsx("div",{children:r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[r.jsx(mc,{className:U("h-4 w-4",d?"text-emerald-500":"text-destructive")}),"Live events"]})}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(Re,{value:o,onValueChange:a,children:[r.jsx(ke,{className:"h-9 min-w-[11rem] flex-1 rounded-full border-border/70 bg-background/55 text-[12px] sm:max-w-[15rem]",children:r.jsx(We,{placeholder:"Event type"})}),r.jsx(Ce,{children:l.map(T=>r.jsx(be,{value:T,className:"text-[12px]",children:T==="all"?"All event types":T},T))})]}),r.jsx(Ee,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:d?"Connected":"Reconnecting"})]})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Px,{events:c,maxHeight:"100%",emptyTitle:o==="all"?"No live events yet":"No matching events",emptyDescription:o==="all"?"Cluster activity appears here as it happens.":`No "${o}" events are in the current stream.`,nodeNameById:n})})]})})]})})}function mo({node:e,systemInfo:t,blockingTaskCount:n,devTunnelNodeId:s,onToggleNodeDevTunnel:o,showActions:a=!0,defaultExpanded:l=!1}){const[c,d]=i.useState(l),f=(t==null?void 0:t.dashboardOrigin)??e.dashboardOrigin,u=e.devtunnelEndpoint??e.endpoint,m=f??e.endpoint,h=(t==null?void 0:t.workDir)??e.workDir,x=To(e,t==null?void 0:t.transportType),g=$r(e,t==null?void 0:t.transportType),p=g&&Rt((t==null?void 0:t.transportType)??e.transportType)?!0:Ao(e,t==null?void 0:t.transportType),v=n>0;return r.jsxs("section",{className:"rounded-[28px] border border-primary/20 bg-primary/8 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[r.jsxs("button",{type:"button",onClick:()=>d(b=>!b),className:"w-full px-4 py-3.5 text-left",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[c?r.jsx(Tt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Or,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(yo,{status:e.status}),r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current node"}),r.jsx("a",{href:m,target:"_blank",rel:"noreferrer",onClick:b=>b.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:r.jsx(No,{className:"h-3.5 w-3.5"})})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 pl-6",children:[r.jsx("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:e.name}),r.jsx(wo,{role:e.role}),r.jsx(Ee,{variant:"outline",className:"rounded-full border-primary/30 bg-background/60 text-[10px] capitalize",children:e.status})]})]}),c&&r.jsxs("div",{className:"space-y-4 border-t border-primary/15 px-4 pb-4 pt-3",children:[r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-primary/20 bg-background/72 px-3.5 py-3.5",children:[r.jsx(De,{label:"Node ID",value:e.id,mono:!0}),f&&r.jsx(De,{label:"Dashboard",value:f,mono:!0,action:r.jsx(Ht,{label:"Copy dashboard URL",onClick:()=>void At(f,"Dashboard URL copied")})}),r.jsx(De,{label:"Node URL",value:u,mono:!0,action:r.jsx(Ht,{label:"Copy node URL",onClick:()=>void At(u,"Node URL copied")})}),h&&r.jsx(De,{label:"Workspace",value:h,mono:!0})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(_r,{label:"Transport",value:x}),t&&r.jsx(_r,{label:"Uptime",value:yx(t.uptime),mono:!0})]}),r.jsx(yl,{capabilities:e.capabilities,action:a&&p?r.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(e),disabled:s===e.id||v,className:"rounded-full",title:v?"Finish assigned or running tasks before changing remote access":void 0,children:[s===e.id&&r.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}),g?"Disable Remote Access":"Enable Remote Access"]}):void 0}),a&&p&&v&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Dx({node:e,isLeader:t,blockingTaskCount:n,devTunnelNodeId:s,onToggleNodeDevTunnel:o}){const[a,l]=i.useState(!1),c=e.dashboardOrigin,d=e.devtunnelEndpoint??e.endpoint,f=c??e.endpoint,u=To(e),m=$r(e),h=Ao(e),x=n>0;return r.jsxs("div",{className:"rounded-[24px] border border-border/60 bg-background/45",children:[r.jsxs("button",{type:"button",onClick:()=>l(g=>!g),className:"w-full px-4 py-3 text-left",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[a?r.jsx(Tt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):r.jsx(Or,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx(yo,{status:e.status}),r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Peer node"}),r.jsx("a",{href:f,target:"_blank",rel:"noreferrer",onClick:g=>g.stopPropagation(),className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-primary",title:"Open Dashboard",children:r.jsx(No,{className:"h-3.5 w-3.5"})})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-2 pl-6",children:[r.jsx("span",{className:"text-sm font-semibold text-foreground",children:e.name}),r.jsx(wo,{role:e.role}),r.jsx(Ee,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] capitalize",children:e.status})]})]}),a&&r.jsxs("div",{className:"space-y-4 border-t border-border/50 px-4 pb-4 pt-3",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx(De,{label:"Node ID",value:e.id,mono:!0}),c&&r.jsx(De,{label:"Dashboard",value:c,mono:!0,action:r.jsx(Ht,{label:"Copy dashboard URL",onClick:()=>void At(c,"Dashboard URL copied")})}),r.jsx(De,{label:"Node URL",value:d,mono:!0,action:r.jsx(Ht,{label:"Copy node URL",onClick:()=>void At(d,"Node URL copied")})}),e.workDir&&r.jsx(De,{label:"Workspace",value:e.workDir,mono:!0}),r.jsx(_r,{label:"Transport",value:u})]}),r.jsx(yl,{capabilities:e.capabilities,action:t&&h?r.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(e),disabled:s===e.id||x,className:"rounded-full",title:x?"Finish assigned or running tasks before changing remote access":void 0,children:[s===e.id&&r.jsx(je,{className:"h-3.5 w-3.5 animate-spin"}),m?"Disable Remote Access":"Enable Remote Access"]}):void 0}),t&&h&&x&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Ht({label:e,onClick:t}){return r.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:t,"aria-label":e,title:e,children:r.jsx(An,{className:"h-3.5 w-3.5"})})}function Mx(e,t,n,s){var l;if(!e)return{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Select a task to continue the conversation."};const o=((l=t==null?void 0:t.self)==null?void 0:l.role)==="follower";return e.assignedTo!==null&&e.assignedNodeAvailable===!1?{taskUnavailable:!0,chatDisabled:!0,chatDisabledReason:`${e.assignedNodeName??"Assigned node"} is unavailable. Leave the cluster on that node or re-run the task elsewhere.`}:o?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Follower nodes are read-only. Use the leader dashboard to manage chat, or leave the cluster first."}:n||s?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:"Waiting for the current turn to finish..."}:Sn.has(e.status)||e.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:Sn.has(e.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var Wn="Checkbox",[Ox]=rt(Wn),[Ix,ms]=Ox(Wn);function Lx(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:o,disabled:a,form:l,name:c,onCheckedChange:d,required:f,value:u="on",internal_do_not_use_render:m}=e,[h,x]=Ct({prop:n,defaultProp:o??!1,onChange:d,caller:Wn}),[g,p]=i.useState(null),[v,b]=i.useState(null),y=i.useRef(!1),w=g?!!l||!!g.closest("form"):!0,j={checked:h,disabled:a,setChecked:x,control:g,setControl:p,name:c,form:l,value:u,hasConsumerStoppedPropagationRef:y,required:f,defaultChecked:Qe(o)?!1:o,isFormControl:w,bubbleInput:v,setBubbleInput:b};return r.jsx(Ix,{scope:t,...j,children:$x(m)?m(j):s})}var wl="CheckboxTrigger",Nl=i.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},o)=>{const{control:a,value:l,disabled:c,checked:d,required:f,setControl:u,setChecked:m,hasConsumerStoppedPropagationRef:h,isFormControl:x,bubbleInput:g}=ms(wl,e),p=le(o,u),v=i.useRef(d);return i.useEffect(()=>{const b=a==null?void 0:a.form;if(b){const y=()=>m(v.current);return b.addEventListener("reset",y),()=>b.removeEventListener("reset",y)}},[a,m]),r.jsx(Q.button,{type:"button",role:"checkbox","aria-checked":Qe(d)?"mixed":d,"aria-required":f,"data-state":El(d),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:p,onKeyDown:Z(t,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:Z(n,b=>{m(y=>Qe(y)?!0:!y),g&&x&&(h.current=b.isPropagationStopped(),h.current||b.stopPropagation())})})});Nl.displayName=wl;var ps=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:o,defaultChecked:a,required:l,disabled:c,value:d,onCheckedChange:f,form:u,...m}=e;return r.jsx(Lx,{__scopeCheckbox:n,checked:o,defaultChecked:a,disabled:c,required:l,onCheckedChange:f,name:s,form:u,value:d,internal_do_not_use_render:({isFormControl:h})=>r.jsxs(r.Fragment,{children:[r.jsx(Nl,{...m,ref:t,__scopeCheckbox:n}),h&&r.jsx(Sl,{__scopeCheckbox:n})]})})});ps.displayName=Wn;var jl="CheckboxIndicator",kl=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...o}=e,a=ms(jl,n);return r.jsx(Pt,{present:s||Qe(a.checked)||a.checked===!0,children:r.jsx(Q.span,{"data-state":El(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});kl.displayName=jl;var Cl="CheckboxBubbleInput",Sl=i.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:o,checked:a,defaultChecked:l,required:c,disabled:d,name:f,value:u,form:m,bubbleInput:h,setBubbleInput:x}=ms(Cl,e),g=le(n,x),p=_i(a),v=yi(s);i.useEffect(()=>{const y=h;if(!y)return;const w=window.HTMLInputElement.prototype,C=Object.getOwnPropertyDescriptor(w,"checked").set,S=!o.current;if(p!==a&&C){const k=new Event("click",{bubbles:S});y.indeterminate=Qe(a),C.call(y,Qe(a)?!1:a),y.dispatchEvent(k)}},[h,p,a,o]);const b=i.useRef(Qe(a)?!1:a);return r.jsx(Q.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??b.current,required:c,disabled:d,name:f,value:u,form:m,...t,tabIndex:-1,ref:g,style:{...t.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Sl.displayName=Cl;function $x(e){return typeof e=="function"}function Qe(e){return e==="indeterminate"}function El(e){return Qe(e)?"indeterminate":e?"checked":"unchecked"}const Pr=i.forwardRef(({className:e,...t},n)=>r.jsx(ps,{ref:n,className:U("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:r.jsx(kl,{className:U("flex items-center justify-center text-current"),children:r.jsx(He,{className:"h-3.5 w-3.5"})})}));Pr.displayName=ps.displayName;function po({toolbarTasks:e,activeTaskId:t,tasksLoading:n,tasksError:s,isLeader:o,scope:a,agentFilter:l,nodeFilter:c,agentOptions:d,nodeOptions:f,nodeNameById:u,searchQuery:m,selectedTaskIds:h,allVisibleTasksSelected:x,someVisibleTasksSelected:g,canBatchArchive:p,onSearchChange:v,onScopeChange:b,onAgentFilterChange:y,onNodeFilterChange:w,onToggleTaskSelected:j,onToggleAllVisibleTasks:C,onBatchArchive:S,onBatchDelete:k,onCreateTask:A,onSelectTask:R,onClose:D}){const[F,_]=i.useState(!!m),[$,V]=i.useState(!1),z=i.useRef(null),M=i.useRef(null),T=h.size,I=a!=="active"||c!=="all"||l!=="all";return i.useEffect(()=>{m&&_(!0)},[m]),i.useEffect(()=>{var E;F&&((E=z.current)==null||E.focus())},[F]),i.useEffect(()=>{if(!F)return;const E=re=>{var ee;const de=re.target;de instanceof Node&&((ee=M.current)!=null&&ee.contains(de)||_(!1))},ne=re=>{re.key==="Escape"&&_(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",ne),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",ne)}},[F]),r.jsxs("aside",{className:"flex h-full min-h-0 flex-col overflow-hidden rounded-[32px] border border-border/60 bg-background/80 shadow-[0_30px_120px_-60px_rgba(0,0,0,var(--panel-shadow-alpha))] backdrop-blur-xl",children:[r.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("div",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Tasks"}),r.jsx(K,{variant:"ghost",size:"icon",onClick:D,className:"rounded-full",children:r.jsx(ko,{className:"h-4 w-4"})})]}),r.jsxs("div",{ref:M,className:"mt-4 flex items-center gap-2",children:[r.jsxs(K,{onClick:A,className:U("justify-start rounded-[22px] px-4 py-6 text-left shadow-[0_24px_60px_-32px_hsl(var(--primary)/0.95)] transition-[flex] duration-200",F?"flex-[2]":"flex-1"),children:[r.jsx(jo,{className:"h-4 w-4"}),"New chat"]}),F?r.jsxs("div",{className:"flex min-w-0 flex-[3] items-center gap-2",children:[r.jsxs("div",{className:"relative min-w-0 flex-1",children:[r.jsx(Ts,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx(St,{ref:z,value:m,onChange:E=>v(E.target.value),placeholder:"Search tasks",className:"h-11 rounded-full border-border/70 bg-background/60 pl-11 text-sm"})]}),r.jsx(K,{variant:"outline",size:"icon",onClick:()=>_(!1),className:"rounded-full border-border/70 bg-background/60",children:r.jsx(Kc,{className:"h-4 w-4"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs(K,{variant:"outline",onClick:()=>_(!0),className:U("rounded-full border-border/70 bg-background/60 px-4 text-sm",m&&"border-primary/40 bg-primary/8 text-primary"),children:[r.jsx(Ts,{className:"h-4 w-4"}),"Search"]}),r.jsx(K,{variant:$||I?"secondary":"outline",size:"icon",onClick:()=>V(E=>!E),className:U("shrink-0 rounded-full border-border/70 bg-background/60",I&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:r.jsx(sd,{className:"h-4 w-4"})})]})]}),($||I)&&r.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[r.jsxs(Re,{value:a,onValueChange:E=>b(E),children:[r.jsx(ke,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(We,{})}),r.jsx(Ce,{children:lx.map(E=>r.jsx(be,{value:E.value,className:"text-[12px]",children:E.label},E.value))})]}),r.jsxs(Re,{value:c,onValueChange:w,children:[r.jsx(ke,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(We,{placeholder:"Node"})}),r.jsx(Ce,{children:f.map(E=>r.jsx(be,{value:E.value,className:"text-[12px]",children:E.label},E.value))})]}),r.jsxs(Re,{value:l,onValueChange:y,children:[r.jsx(ke,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(We,{placeholder:"Agent"})}),r.jsx(Ce,{children:d.map(E=>r.jsx(be,{value:E,className:"text-[12px]",children:E==="all"?"All agents":E},E))})]})]})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:e.length>0?r.jsxs("div",{className:"space-y-2",children:[o&&r.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 py-1",children:[r.jsxs("label",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:[r.jsx(Pr,{checked:g&&!x?"indeterminate":x,onCheckedChange:E=>C(E===!0),"aria-label":"Select all visible tasks"}),r.jsx("span",{children:"Select all"})]}),T>0&&r.jsx(K,{variant:"ghost",size:"sm",onClick:()=>C(!1),className:"h-7 rounded-full px-3 text-xs",children:"Clear"})]}),e.map(E=>r.jsxs("div",{className:U("flex items-start gap-3 rounded-[24px] border px-3 py-3 transition-all",E.id===t?"border-primary/45 bg-primary/9 shadow-[0_24px_80px_-54px_hsl(var(--primary)/0.95)]":"border-border/60 bg-background/40 hover:border-border hover:bg-background/60"),children:[o&&r.jsx("div",{className:"flex shrink-0 pt-1",onClick:ne=>ne.stopPropagation(),children:r.jsx(Pr,{checked:h.has(E.id),onCheckedChange:ne=>j(E.id,ne===!0),"aria-label":`Select ${E.title}`})}),r.jsx("button",{type:"button",onClick:()=>R(E.id),className:"min-w-0 flex-1 text-left",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:U("mt-1 h-2.5 w-2.5 shrink-0 rounded-full",hx(E.status))}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:E.title}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx("span",{className:"font-mono",children:E.agent}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),r.jsx("span",{children:E.assignedTo?u.get(E.assignedTo)??E.assignedTo.slice(0,8):"unassigned"}),r.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),r.jsx("span",{children:vx(E.updatedAt)})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx(bo,{status:E.status}),E.assignedNodeAvailable===!1&&r.jsx(Ee,{variant:"outline",className:"border-destructive/25 bg-destructive/10 text-[10px] text-destructive",children:"unavailable"}),r.jsx("span",{className:"truncate font-medium text-foreground/85",children:xx(E.effectiveProjectPath??E.project??"default workspace")})]}),r.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground/85",children:gx(E.effectiveProjectPath??E.project??"default workspace")})]})]})})]},E.id))]}):r.jsx("div",{className:"rounded-[24px] border border-dashed border-border/70 bg-background/35 px-4 py-5 text-sm text-muted-foreground",children:n?"Loading tasks...":s||"No tasks match this view."})}),o&&T>0?r.jsxs("div",{className:"shrink-0 border-t border-border/60 px-4 py-4",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Batch actions"}),r.jsxs("div",{className:"mt-2 text-sm font-semibold text-foreground",children:[T," task",T!==1?"s":""," selected"]}),!p&&r.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Only completed, failed, cancelled, or archived tasks can be archived."}),r.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[r.jsxs(yr,{children:[r.jsx(qs,{asChild:!0,children:r.jsxs(K,{variant:"outline",size:"sm",disabled:!p,className:"rounded-full",children:[r.jsx(Dc,{className:"h-3.5 w-3.5"}),"Archive"]})}),r.jsxs(pn,{children:[r.jsxs(hn,{children:[r.jsxs(gn,{children:["Archive ",T," task",T!==1?"s":"","?"]}),r.jsx(vn,{children:"Archived tasks stay hidden from the default task view and can be reopened from the archived scope."})]}),r.jsxs(xn,{children:[r.jsx(yn,{children:"Cancel"}),r.jsx(bn,{onClick:S,disabled:!p,children:"Archive"})]})]})]}),r.jsxs(yr,{children:[r.jsx(qs,{asChild:!0,children:r.jsxs(K,{variant:"destructive",size:"sm",className:"rounded-full",children:[r.jsx(Md,{className:"h-3.5 w-3.5"}),"Delete"]})}),r.jsxs(pn,{children:[r.jsxs(hn,{children:[r.jsxs(gn,{children:["Delete ",T," task",T!==1?"s":"","?"]}),r.jsx(vn,{children:"This removes the selected tasks and their saved logs."})]}),r.jsxs(xn,{children:[r.jsx(yn,{children:"Cancel"}),r.jsx(bn,{onClick:k,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}function ho(e,t,n){const s=i.useRef(t);s.current=t,i.useEffect(()=>{let l=0,c=0;const d=m=>{const h=m.touches[0];h&&(l=h.clientX,c=h.clientY)},f=m=>{var p,v,b,y;const h=m.changedTouches[0];if(!h)return;const x=h.clientX-l;Math.abs(h.clientY-c)>100||Math.abs(x)<50||(x>0?(v=(p=s.current).onSwipeRight)==null||v.call(p):(y=(b=s.current).onSwipeLeft)==null||y.call(b))},u=(e==null?void 0:e.current)??document;return u.addEventListener("touchstart",d,{passive:!0}),u.addEventListener("touchend",f,{passive:!0}),()=>{u.removeEventListener("touchstart",d),u.removeEventListener("touchend",f)}},[e,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}const Fx="(min-width: 1024px)",Bx="(min-width: 1280px)";function xo(e){var t,n,s;return((s=(n=(t=globalThis.window)==null?void 0:t.matchMedia)==null?void 0:n.call(t,e))==null?void 0:s.matches)??!1}function Ux(){const[e,t]=i.useState(!0),[n,s]=i.useState(!1),[o,a]=i.useState(()=>xo(Bx)),l=i.useRef(null),c=i.useRef(null);ho(l,{onSwipeLeft:()=>s(!1)}),ho(c,{onSwipeRight:()=>a(!1)});const d=i.useCallback(()=>{if(xo(Fx)){t(f=>!f);return}s(f=>!f)},[]);return{desktopTasksOpen:e,mobileTasksPanelOpen:n,mobileTasksPanelRef:l,operationsOpen:o,operationsPanelRef:c,setMobileTasksPanelOpen:s,setOperationsOpen:a,toggleTasksPanel:d}}function Wx(e,t){return t.data.nodeId===e.self.id||t.data.name===e.self.name||t.data.endpoint===e.self.endpoint}function Vx({cluster:e,subscribe:t}){i.useEffect(()=>{var n;if(((n=e==null?void 0:e.self)==null?void 0:n.role)==="leader")return t("node",s=>{const o=String(s.data.name??s.data.nodeId??"node"),a=Wx(e,s);s.type==="node.joined"&&!a&&pe.success(`${o} joined the cluster`),s.type==="node.left"&&!a&&pe.message(`${o} left the cluster`)})},[e,t])}function zx(){var ks,Cs,Ss;const{id:e}=pc(),t=hc(),n=xc(),{cluster:s,systemInfo:o,events:a,sseConnected:l,subscribe:c,refresh:d,loading:f,error:u}=gc(),m=i.useMemo(()=>px(t.state),[t.state]),[h,x]=i.useState([]),[g,p]=i.useState(!0),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,C]=i.useState("active"),[S,k]=i.useState("all"),[A,R]=i.useState("all"),[D,F]=i.useState(""),_=i.useDeferredValue(D),{desktopTasksOpen:$,mobileTasksPanelOpen:V,mobileTasksPanelRef:z,operationsOpen:M,operationsPanelRef:T,setMobileTasksPanelOpen:I,setOperationsOpen:E,toggleTasksPanel:ne}=Ux(),[re,de]=i.useState(()=>!!(m!=null&&m.draftNewTask)),[ee,ue]=i.useState(()=>m!=null&&m.draftNewTask?{route:m.returnRoute??"/",taskId:m.returnTaskId??null}:null),[he,L]=i.useState(!1),[O,B]=i.useState("transcript"),[Y,X]=i.useState("all"),[J,q]=i.useState(!1),[ie,fe]=i.useState(null),[Ne,we]=i.useState([]),[H,oe]=i.useState([]),[ge,mt]=i.useState(!1),[Vn,ve]=i.useState(null),[Ge,at]=i.useState(new Set),[Al,hs]=i.useState(!1),[Tl,xs]=i.useState(!1),[Rl,gs]=i.useState(!1),[_l,vs]=i.useState(null),bs=i.useRef(null),It=i.useRef(null),pt=((ks=s==null?void 0:s.self)==null?void 0:ks.role)==="leader",zn=(Cs=s==null?void 0:s.self)==null?void 0:Cs.id;Vx({cluster:s,subscribe:c});const xe=i.useCallback(async()=>{try{const N=await vc({assignedTo:!pt&&zn?zn:void 0,limit:100});x(N),b(null)}catch(N){b(N instanceof Error?N.message:"Failed to load tasks")}finally{p(!1)}},[pt,zn]);bc(xe,1e4),i.useEffect(()=>{xe()},[xe]),i.useEffect(()=>c("task",xe),[c,xe]);const me=i.useMemo(()=>[...h].sort((N,P)=>P.updatedAt-N.updatedAt),[h]),Pl=i.useMemo(()=>{const N=new Map;for(const P of(s==null?void 0:s.nodes)??[]){const W=Bd(me,P.id);W>0&&N.set(P.id,W)}return N},[s==null?void 0:s.nodes,me]),_e=i.useMemo(()=>me.filter(N=>!dx(N,j)||S!=="all"&&N.agent!==S||A==="unassigned"&&N.assignedTo||A!=="all"&&A!=="unassigned"&&fx(N.assignedTo,s==null?void 0:s.nodes,N.assignedNodeName)!==A?!1:_.trim()?ux(N,_):!0),[me,j,S,A,_]);i.useEffect(()=>{at(N=>{const P=Hd(N,_e.map(W=>W.id));return P.size===N.size?N:P})},[_e]),i.useEffect(()=>{pt||at(new Set)},[pt]);const Dl=i.useMemo(()=>["all",...Array.from(new Set(me.map(N=>N.agent))).sort()],[me]),Ml=i.useMemo(()=>{const P=Array.from(new Set(me.map(W=>W.assignedTo).filter(W=>!!W))).map(W=>{const ce=me.find(te=>te.assignedTo===W);return(s==null?void 0:s.nodes.find(te=>te.id===W))??{id:W,name:fs(W,s==null?void 0:s.nodes,ce==null?void 0:ce.assignedNodeName)}}).sort((W,ce)=>W.name.localeCompare(ce.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...P.map(W=>({value:W.name.toLowerCase(),label:W.name}))]},[me,s==null?void 0:s.nodes]),ys=i.useMemo(()=>{const N=new Map;for(const P of(s==null?void 0:s.nodes)??[])N.set(P.id,P.name);for(const P of me)P.assignedTo&&P.assignedNodeName&&!N.has(P.assignedTo)&&N.set(P.assignedTo,P.assignedNodeName);return N},[s==null?void 0:s.nodes,me]),Hn=i.useMemo(()=>["all",...Array.from(new Set(a.map(N=>N.type))).sort()],[a]),Ol=i.useMemo(()=>Y==="all"?a:a.filter(N=>N.type===Y),[a,Y]),Il=_e.length>0&&_e.every(N=>Ge.has(N.id)),Ll=_e.some(N=>Ge.has(N.id)),$l=Kd(_e,Ge);i.useEffect(()=>{m!=null&&m.draftNewTask&&(de(!0),ue({route:m.returnRoute??"/",taskId:m.returnTaskId??null}))},[m]),i.useEffect(()=>{Y!=="all"&&!Hn.includes(Y)&&X("all")},[Y,Hn]),i.useEffect(()=>{Rs(e,re)&&!y&&me[0]&&w(me[0].id)},[e,re,y,me]),i.useEffect(()=>{var N;Rs(e,re)&&(y&&h.some(P=>P.id===y)||w(((N=me[0])==null?void 0:N.id)??null))},[e,re,y,me,h]);const ae=Wd({routeTaskId:e,creatingTask:re,internalSelectedTaskId:y,sortedTaskIds:me.map(N=>N.id)}),ht=i.useMemo(()=>h.find(N=>N.id===ae)??null,[h,ae]);i.useEffect(()=>{It.current=ae??null},[ae]);const Xt=i.useCallback(()=>{fe(null),we([]),oe([]),ve(null)},[]),Te=i.useCallback(async()=>{const N=ae;if(N)try{const P=await yc(N);if(It.current!==N)return;fe(P),ve(null)}catch(P){if(It.current!==N)return;fe(null),we([]),oe([]),ve(P instanceof Error?P.message:"Failed to load task")}finally{It.current===N&&mt(!1)}},[ae]),Jt=i.useCallback(async()=>{const N=ae;if(N)try{const P=await wc(N);if(It.current!==N)return;we(W=>gu(W,P.logs)),oe(W=>bu(W,P.logs))}catch{}},[ae]);i.useEffect(()=>{if(!ae){fe(null),we([]),oe([]),ve(null),mt(!1);return}B("transcript"),fe(ht),we([]),oe([]),ve(null),mt(!0),Te(),Jt()},[ae,Jt,Te]),i.useEffect(()=>{var P;if(!ae||re||g||h.some(W=>W.id===ae))return;const N=((P=me[0])==null?void 0:P.id)??null;w(N),Xt(),i.startTransition(()=>{n(N?`/tasks/${N}`:"/",{state:null})})},[ae,Xt,re,n,me,h,g]),i.useEffect(()=>{ht&&fe(N=>!N||N.id!==ht.id?N:{...N,...ht})},[ht]),i.useEffect(()=>{if(ae)return c("task",N=>{const P=N.data.taskId;if(!(typeof P!="string"||P!==ae)){if(N.type==="task.output"){const W=N.data.event;if(W){we(te=>vu(te,W));const ce=Kt(W);ce&&oe(te=>yu(te,ce))}}N.type==="task.status"&&(Te(),Jt())}})},[c,ae,Te,Jt]),i.useEffect(()=>{var N;O==="transcript"&&((N=bs.current)==null||N.scrollIntoView({behavior:"smooth"}))},[Ne,H,O]);const se=ie??ht,Fl=se!=null&&se.assignedTo?(s==null?void 0:s.nodes.find(N=>N.id===se.assignedTo))??null:null,Kn=H.length>0,Bl=se?Kh.has(se.agent):!1,qn=(se==null?void 0:se.status)==="running",Ul=se?Sn.has(se.status)||bl.has(se.status):!1,Wl=!!(se&&pt&&se.status==="failed"),Gn=i.useMemo(()=>Mx(se,s,Kn,!!qn),[se,s,Kn,qn]),Vl=i.useMemo(()=>wu(Ne),[Ne]),Yn=i.useMemo(()=>Nu([...Ne,...H.map(N=>Jn(N.content,N.timestamp))]),[Ne,H]),zl=i.useMemo(()=>{if(!se)return null;const N=Jd(se);if(N.length>0)return Jn(N,new Date(se.createdAt).toISOString());if(Yn.length>0)return null;const P=$t(se.description||se.title);return P.length>0?Jn(P,new Date(se.createdAt).toISOString()):null},[se,Yn]),Xn=i.useCallback(()=>{const N={route:e?`/tasks/${e}`:"/",taskId:ae};ue(N),de(!0),i.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:N.route,returnTaskId:N.taskId}})})},[e,ae,n]),Hl=i.useCallback(()=>{var P;const N=(ee==null?void 0:ee.taskId)??((P=me[0])==null?void 0:P.id)??null;de(!1),ue(null),w(N),i.startTransition(()=>{n((ee==null?void 0:ee.route)??"/",{state:null})})},[ee,me,n]),ws=i.useCallback(N=>{de(!1),ue(null),w(N),i.startTransition(()=>{n(`/tasks/${N}`,{state:null})})},[n]),Kl=i.useCallback(N=>{de(!1),ue(null),x(P=>Vd(P,N)),fe(N),we([]),oe([]),ve(null),mt(!1),B("transcript"),w(N.id),xe(),i.startTransition(()=>{n(`/tasks/${N.id}`,{state:null})})},[xe,n]),Zt=i.useCallback(async N=>{if(!ae)return!1;const P=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;oe(W=>[...W,{id:P,content:N,timestamp:new Date().toISOString()}]);try{return await Nc(ae,N),Te(),!0}catch(W){return oe(ce=>ce.filter(te=>te.id!==P)),pe.error(W instanceof Error?W.message:"Failed to send message"),!1}},[ae,Te]),ql=i.useCallback(N=>{Zt(N)},[Zt]),Gl=i.useCallback(N=>Zt(N),[Zt]),Yl=i.useCallback(async()=>{if(se)try{await jc(se.id),Te(),xe()}catch(N){pe.error(N instanceof Error?N.message:"Failed to cancel task")}},[se,Te,xe]),Xl=i.useCallback(async()=>{if(se)try{await kc(se.id),Te(),xe()}catch(N){pe.error(N instanceof Error?N.message:"Failed to retry task")}},[se,Te,xe]),Qt=i.useCallback((N,P=!1)=>{const W=qd(_e,N);return w(W),(P||!W)&&Xt(),i.startTransition(()=>{n(W?`/tasks/${W}`:"/",{state:null})}),W},[Xt,_e,n]),Jl=i.useCallback((N,P)=>{at(W=>{const ce=new Set(W);return P?ce.add(N):ce.delete(N),ce})},[]),Zl=i.useCallback(N=>{if(!N){at(new Set);return}at(new Set(_e.map(P=>P.id)))},[_e]),Ql=i.useCallback(async()=>{const N=Array.from(Ge);if(N.length!==0)try{const{results:P}=await Cc(N),W=P.filter(te=>!te.ok),ce=P.filter(te=>te.ok).map(te=>te.id);ae&&ce.includes(ae)&&Qt(ce),W.length>0?pe.error(`Failed to archive ${W.length} task(s): ${W.map(te=>te.error??te.id).join(", ")}`):pe.success(`Archived ${ce.length} task(s)`),at(new Set(W.map(te=>te.id))),xe()}catch(P){pe.error(P instanceof Error?P.message:"Failed to archive tasks")}},[ae,xe,Qt,Ge]),ec=i.useCallback(async()=>{const N=Array.from(Ge);if(N.length!==0)try{const{results:P}=await Sc(N),W=P.filter(te=>!te.ok),ce=P.filter(te=>te.ok).map(te=>te.id);ae&&ce.includes(ae)&&Qt(ce,!0),W.length>0?pe.error(`Failed to delete ${W.length} task(s): ${W.map(te=>te.error??te.id).join(", ")}`):pe.success(`Deleted ${ce.length} task(s)`),at(new Set(W.map(te=>te.id))),xe()}catch(P){pe.error(P instanceof Error?P.message:"Failed to delete tasks")}},[ae,xe,Qt,Ge]),tc=i.useCallback(async()=>{hs(!0);try{await Ec(),d()}catch(N){pe.error(N instanceof Error?N.message:"Failed to trigger election")}finally{hs(!1)}},[d]),nc=i.useCallback(async()=>{xs(!0);try{await Ac(),d()}catch(N){pe.error(N instanceof Error?N.message:"Failed to promote node")}finally{xs(!1)}},[d]),rc=i.useCallback(async()=>{gs(!0);try{await Tc(),pe.success("This node left the remote cluster and is leading itself again."),xe(),Te(),d()}catch(N){pe.error(N instanceof Error?N.message:"Failed to leave cluster")}finally{gs(!1)}},[Te,xe,d]),sc=i.useCallback(async N=>{var Es;const P=!$r(N),W=N.id===((Es=s==null?void 0:s.self)==null?void 0:Es.id),ce=W?(o==null?void 0:o.transportType)??N.transportType:N.transportType,te=W&&!P&&Rt(ce);vs(N.id);try{te?await Rc("direct"):await _c(N.id,P),pe.success(P?`Enabled remote access on ${N.name}`:`Disabled remote access on ${N.name}`),d()}catch(As){pe.error(As instanceof Error?As.message:"Failed to update remote access")}finally{vs(null)}},[(Ss=s==null?void 0:s.self)==null?void 0:Ss.id,d,o==null?void 0:o.transportType]),Ns={toolbarTasks:_e,activeTaskId:ae,tasksLoading:g,tasksError:v,isLeader:pt,scope:j,agentFilter:S,nodeFilter:A,agentOptions:Dl,nodeOptions:Ml,nodeNameById:ys,searchQuery:D,selectedTaskIds:Ge,allVisibleTasksSelected:Il,someVisibleTasksSelected:Ll,canBatchArchive:$l,onSearchChange:F,onScopeChange:C,onAgentFilterChange:k,onNodeFilterChange:R,onToggleTaskSelected:Jl,onToggleAllVisibleTasks:Zl,onBatchArchive:Ql,onBatchDelete:ec,onCreateTask:Xn,onSelectTask:ws,onClose:ne},js={cluster:s,systemInfo:o,nodeNameById:ys,nodeBlockingTaskCounts:Pl,eventTypeFilter:Y,onEventTypeFilterChange:X,eventTypeOptions:Hn,filteredEvents:Ol,sseConnected:l,clusterLoading:f,clusterError:u,electionPending:Al,onTriggerElection:tc,promotePending:Tl,onPromote:nc,onAddNode:()=>L(!0),leavePending:Rl,onLeaveCluster:rc,onToggleNodeDevTunnel:sc,devTunnelNodeId:_l,onClose:()=>E(!1)};return r.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden pb-2",children:[r.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[r.jsx("div",{className:U("hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",$?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:$&&r.jsx(po,{...Ns})}),r.jsx("section",{className:"min-h-0 min-w-0 flex-1",children:r.jsx(kx,{onToggleTasks:ne,desktopTasksOpen:$,mobileTasksPanelOpen:V,operationsOpen:M,onToggleOperations:()=>E(N=>!N),cluster:s,sseConnected:l,activeTab:O,setActiveTab:B,creatingTask:re,activeTask:se,assignedNode:Fl,taskLoading:ge,taskError:Vn,displayEvents:Yn,hasUserMessageInLogs:Vl,initialPrompt:zl,supportsFollowUp:Bl,taskUnavailable:Gn.taskUnavailable,chatDisabled:Gn.chatDisabled,chatDisabledReason:Gn.chatDisabledReason,questionBypassEnabled:J,isRunning:!!qn,hasPendingFollowUp:Kn,canCancel:!!Ul,canRetry:!!Wl,onRetry:Xl,onCancel:Yl,onStartCreateTask:Xn,onCancelCreateTask:Hl,onCreateTask:Kl,onSendMessage:ql,onQuestionBypassChange:q,onSubmitQuestionResponse:Gl,messagesEndRef:bs})}),r.jsx("div",{className:U("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",M?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:M&&r.jsx(fo,{...js})})]}),M&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>E(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),r.jsx("div",{ref:T,className:"fixed inset-y-0 right-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:r.jsx(fo,{...js})})]}),V&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>I(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),r.jsx("div",{ref:z,className:"fixed inset-y-0 left-0 z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:r.jsx(po,{...Ns,onCreateTask:()=>{I(!1),Xn()},onSelectTask:N=>{I(!1),ws(N)},onClose:()=>I(!1)})})]}),r.jsx(Qf,{open:he,onOpenChange:L,children:r.jsx(am,{onAdded:()=>{L(!1),d()}})})]})}const qx=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:zx},Symbol.toStringTag,{value:"Module"}));export{Or as C,Qf as D,No as E,nd as F,fa as a,ha as b,Kx as c,Tt as d,qx as e};