meshy-node 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,251 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-Bhu_DR2i.js","assets/index-srY9WA9N.js","assets/index-CnADF-Qd.css","assets/file-Oxijj5Ue.js","assets/PreviewTab-HFeFMit9.js","assets/DiffTab-CPP_KlNw.js"])))=>i.map(i=>d[i]);
2
- import{c as G,r as i,j as r,R as xo,a as ac,b as En,u as le,d as ic,e as U,f as lc,g as cc,h as dc,B as ke,i as H,k as at,l as go,m as uc,n as fc,t as he,T as vo,P as mc,_ as Mr,o as pc,N as bo,p as yo,q as hc,s as xc,v as gc,w as vc,x as bc,y as yc,z as wc,A as Nc,C as jc,D as Sc,E as kc,F as Cc,G as Ec,H as Tc,I as Ac,J as Rc,K as _c,L as Pc}from"./index-srY9WA9N.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 Dc=[["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"}]],Mc=G("archive",Dc);/**
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 Oc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ic=G("arrow-up",Oc);/**
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 Lc=[["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"}]],wo=G("bot",Lc);/**
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 $c=[["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"}]],Fc=G("brain",$c);/**
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 Bc=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ze=G("check",Bc);/**
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 Uc=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Et=G("chevron-down",Uc);/**
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 Vc=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Or=G("chevron-right",Vc);/**
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 zc=[["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"}]],Hc=G("circle-question-mark",zc);/**
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 Kc=[["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"}]],qc=G("circle-x",Kc);/**
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 Gc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Yc=G("circle",Gc);/**
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 Xc=[["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"}]],Tn=G("copy",Xc);/**
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 Jc=[["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",Jc);/**
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 Zc=[["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"}]],Qc=G("flag",Zc);/**
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 ed=[["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"}]],td=G("folder-tree",ed);/**
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 nd=[["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"}]],rd=G("folder",nd);/**
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 sd=[["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"}]],od=G("funnel",sd);/**
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 ad=[["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"}]],id=G("globe",ad);/**
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 ld=[["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"}]],cd=G("history",ld);/**
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 dd=[["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"}]],mr=G("image-plus",dd);/**
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 ud=[["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"}]],fd=G("laptop",ud);/**
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 md=[["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"}]],pd=G("list-checks",md);/**
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 hd=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ye=G("loader-circle",hd);/**
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 xd=[["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",xd);/**
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 gd=[["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"}]],So=G("panel-left-close",gd);/**
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 vd=[["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"}]],bd=G("panel-left-open",vd);/**
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 yd=[["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"}]],ko=G("panel-right-close",yd);/**
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 wd=[["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"}]],Nd=G("panel-right-open",wd);/**
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 jd=[["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",jd);/**
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 Sd=[["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",Sd);/**
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 Ed=[["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"}]],Co=G("send",Ed);/**
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 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:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Ad=G("shield-alert",Td);/**
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 Rd=[["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"}]],_d=G("shield-check",Rd);/**
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 Pd=[["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"}]],Dd=G("trash-2",Pd);/**
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 Md=[["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"}]],Od=G("user",Md);/**
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 Id=[["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",Id);/**
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:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zt=G("x",Ld),$d=new Set(["assigned","running"]);function Fd(e,t){return e.reduce((n,s)=>s.assignedTo===t&&$d.has(s.status)?n+1:n,0)}function Tt(e){return(e==null?void 0:e.toLowerCase())==="devtunnel"}function Bd(e){return e?Tt(e)?"DevTunnel":e.charAt(0).toUpperCase()+e.slice(1):"Direct"}function $r(e,t){return Tt(t??e.transportType)||!!e.devtunnelEndpoint}function To(e,t){return!Tt(t??e.transportType)}function Ao(e,t){const n=t??e.transportType;return Tt(n)?"DevTunnel":e.devtunnelEndpoint?"Direct + DevTunnel":Bd(n)}function As(e,t){return!e&&!t}function Ud({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 Wd=new Set(["completed","failed","cancelled","archived"]);function zd(e,t){const n=new Set(t);return new Set(Array.from(e).filter(s=>n.has(s)))}function Hd(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=>Wd.has(o.status))}function Kd(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 qd(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 Gd(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 It(e){if(typeof e=="string"){const t=e.trim();return t?[{type:"text",text:t}]:[]}return Array.isArray(e)?e.map(t=>qd(t)??Gd(t)).filter(t=>t!==null):[]}function Ro(e,t){const n=e.trim();return[...n?[{type:"text",text:n}]:[],...t]}function Yd(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 Xn(e,t=new Date().toISOString()){return{type:"user",message:Yd(e),timestamp:t}}function Ht(e){if(e.type!=="user"||e.isSynthetic===!0)return null;if(typeof e.message=="string"){const t=It(e.message);return t.length>0?t:null}if(un(e.message)&&Array.isArray(e.message.content)){const t=It(e.message.content);return t.length>0?t:null}if(Array.isArray(e.content)){const t=It(e.content);return t.length>0?t:null}return null}function Xd(e){return It(e.payload.initialMessage)}function $t(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 Jd(e){return e.map(t=>t.type==="text"?t.text:t.type==="tool_result"?t.content:"").filter(Boolean).join(`
193
- `)}function Fr(e){return`data:${e.mediaType};base64,${e.data}`}function Zd(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 Qd(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 Rs(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 Qd(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 Kt(e){return typeof e=="object"&&e!==null}function eu(e){return Kt(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function tu(e){return!Kt(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function nu(e){if(!Kt(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(tu).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 pr(e){if(!Kt(e)||!Array.isArray(e.questions))return null;const t=e.questions.map(nu).filter(n=>n!==null);return t.length===0?null:{questions:t}}function At(e){return JSON.stringify({questions:e.questions})}function An(e){const t=pr(e);if(t)return t;if(eu(e)){const n=Kt(e.input)?e.input:void 0,s=pr(n);return s?{...s,...typeof e.id=="string"&&e.id.trim()?{toolUseId:e.id.trim()}:{}}:null}return null}function ru(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 ru(e))try{const n=JSON.parse(t),s=pr(n);if(s)return s}catch{}return null}function su(e){return e.questions.map(t=>t.options.length>0?[0]:[])}function ou(e,t){return e.questions.every((n,s)=>(t[s]??[]).length>0)}function au(e,t){const s=e.questions.map((o,a)=>{const l=[...new Set(t[a]??[])].sort((c,u)=>c-u).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(`
194
- `);return e.toolUseId?[{type:"tool_result",toolUseId:e.toolUseId,content:s,isError:!1}]:[{type:"text",text:s}]}function Ft(e){return typeof e=="object"&&e!==null}function iu(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 lu(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 hr(e){const t=e.trim();if(!t.startsWith("Awaiting your permission to "))return null;const n=t.match(/`([^`]+)`/);return{requests:[{toolName:lu(t),target:n==null?void 0:n[1],summary:t}]}}function cu(e){if(!Array.isArray(e.permission_denials))return null;const t=[];for(const n of e.permission_denials){if(!Ft(n)||typeof n.tool_name!="string")continue;const s=Ft(n.tool_input)?n.tool_input:void 0,o=iu(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 _s(e){if(!Array.isArray(e))return null;for(const t of e){if(!Ft(t)||t.type!=="text"||typeof t.text!="string")continue;const n=hr(t.text);if(n)return n}return null}function Br(e){if(!Ft(e))return null;const t=cu(e);if(t)return t;if(typeof e.result=="string"){const s=hr(e.result);if(s)return s}if(typeof e.message=="string"){const s=hr(e.message);if(s)return s}if(Ft(e.message)){const s=Br(e.message);if(s)return s;const o=_s(e.message.content);if(o)return o}const n=_s(e.content);return n||null}function du(e){return JSON.stringify(e.requests.map(t=>({toolName:t.toolName,target:t.target??null,summary:t.summary})))}function uu(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 Ht(e)!==null}function fn(e){if(e.type==="user"){const t=Ht(e),n=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${n}:${$t(t)}`}return JSON.stringify(e)}function xr(e){const t=An(e);return t?`question:${At(t)}`:null}function fu(e){const t=Br(e);return t?`permission:${du(t)}`:null}function Ps(e){if(!Array.isArray(e))return null;const t=new Set;for(const n of e){const s=xr(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(At(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function mu(e){const t=xr(e);if(t)return t;if(typeof e.message=="string"){const n=Rn(e.message);return n?At(n):null}if(typeof e.message=="object"&&e.message!==null){const n=xr(e.message);return n||Ps(e.message.content)}return Ps(e.content)}function pu(e){return fu(e)}function hu(e,t,n){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${n}`}function xu(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 gu(e,t){const n=fn(t);return e.some(s=>fn(s)===n)?e:[...e,{...t}]}function vu(e,t){const n=new Map;for(const s of t){const o=Ht(s);if(!o)continue;const a=$t(o);n.set(a,(n.get(a)??0)+1)}return e.filter(s=>{const o=$t(s.content),a=n.get(o)??0;return a<=0?!0:(n.set(o,a-1),!1)})}function bu(e,t){const n=$t(t),s=e.findIndex(o=>$t(o.content)===n);return s===-1?e:e.filter((o,a)=>a!==s)}function yu(e){return e.some(_o)}function wu(e){const t=[];let n=null;for(const s of e){if(_o(s)){n=null,t.push(s);continue}const o=pu(s)??mu(s);o&&o===n||(t.push(s),o&&(n=o))}return t}function Y(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 Nu(e,t){const n=i.createContext(t),s=a=>{const{children:l,...c}=a,u=i.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:u,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 nt(e,t=[]){let n=[];function s(a,l){const c=i.createContext(l),u=n.length;n=[...n,l];const f=m=>{var b;const{scope:h,children:g,...x}=m,p=((b=h==null?void 0:h[e])==null?void 0:b[u])||c,v=i.useMemo(()=>x,Object.values(x));return r.jsx(p.Provider,{value:v,children:g})};f.displayName=a+"Provider";function d(m,h){var p;const g=((p=h==null?void 0:h[e])==null?void 0:p[u])||c,x=i.useContext(g);if(x)return x;if(l!==void 0)return l;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[f,d]}const o=()=>{const a=n.map(l=>i.createContext(l));return function(c){const u=(c==null?void 0:c[e])||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:u}}),[c,u])}};return o.scopeName=e,[s,ju(o,...t)]}function ju(...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:u,scopeName:f})=>{const m=u(a)[`__scope${f}`];return{...c,...m}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}var ve=globalThis!=null&&globalThis.document?i.useLayoutEffect:()=>{},Su=xo[" useId ".trim().toString()]||(()=>{}),ku=0;function Je(e){const[t,n]=i.useState(Su());return ve(()=>{n(s=>s??String(ku++))},[e]),e||(t?`radix-${t}`:"")}var Cu=xo[" useInsertionEffect ".trim().toString()]||ve;function jt({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,l]=Eu({defaultProp:t,onChange:n}),c=e!==void 0,u=c?e:o;{const d=i.useRef(e!==void 0);i.useEffect(()=>{const m=d.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.`),d.current=c},[c,s])}const f=i.useCallback(d=>{var m;if(c){const h=Tu(d)?d(e):d;h!==e&&((m=l.current)==null||m.call(l,h))}else a(d)},[c,e,a,l]);return[u,f]}function Eu({defaultProp:e,onChange:t}){const[n,s]=i.useState(e),o=i.useRef(n),a=i.useRef(t);return Cu(()=>{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 Bt(e){const t=Au(e),n=i.forwardRef((s,o)=>{const{children:a,...l}=s,c=i.Children.toArray(a),u=c.find(_u);if(u){const f=u.props.children,d=c.map(m=>m===u?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,d):null})}return r.jsx(t,{...l,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Au(e){const t=i.forwardRef((n,s)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const l=Du(o),c=Pu(a,o.props);return o.type!==i.Fragment&&(c.ref=s?ac(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 Ru(e){const t=({children:n})=>r.jsx(r.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=Po,t}function _u(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Po}function Pu(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 u=a(...c);return o(...c),u}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Du(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 Mu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Z=Mu.reduce((e,t)=>{const n=Bt(`Primitive.${t}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,u=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Ou(e,t){e&&En.flushSync(()=>e.dispatchEvent(t))}function Qe(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 Iu(e,t=globalThis==null?void 0:globalThis.document){const n=Qe(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 Lu="DismissableLayer",gr="dismissableLayer.update",$u="dismissableLayer.pointerDownOutside",Fu="dismissableLayer.focusOutside",Ds,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,...u}=e,f=i.useContext(Do),[d,m]=i.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=i.useState({}),x=le(t,S=>m(S)),p=Array.from(f.layers),[v]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=p.indexOf(v),y=d?p.indexOf(d):-1,w=f.layersWithOutsidePointerEventsDisabled.size>0,j=y>=b,k=Vu(S=>{const T=S.target,R=[...f.branches].some(A=>A.contains(T));!j||R||(o==null||o(S),l==null||l(S),S.defaultPrevented||c==null||c())},h),C=Wu(S=>{const T=S.target;[...f.branches].some(A=>A.contains(T))||(a==null||a(S),l==null||l(S),S.defaultPrevented||c==null||c())},h);return Iu(S=>{y===f.layers.size-1&&(s==null||s(S),!S.defaultPrevented&&c&&(S.preventDefault(),c()))},h),i.useEffect(()=>{if(d)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(Ds=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(d)),f.layers.add(d),Ms(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ds)}},[d,h,n,f]),i.useEffect(()=>()=>{d&&(f.layers.delete(d),f.layersWithOutsidePointerEventsDisabled.delete(d),Ms())},[d,f]),i.useEffect(()=>{const S=()=>g({});return document.addEventListener(gr,S),()=>document.removeEventListener(gr,S)},[]),r.jsx(Z.div,{...u,ref:x,style:{pointerEvents:w?j?"auto":"none":void 0,...e.style},onFocusCapture:Y(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Y(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Y(e.onPointerDownCapture,k.onPointerDownCapture)})});Ur.displayName=Lu;var Bu="DismissableLayerBranch",Uu=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(Z.div,{...e,ref:o})});Uu.displayName=Bu;function Vu(e,t=globalThis==null?void 0:globalThis.document){const n=Qe(e),s=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let u=function(){Mo($u,n,f,{discrete:!0})};const f={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}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 Wu(e,t=globalThis==null?void 0:globalThis.document){const n=Qe(e),s=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!s.current&&Mo(Fu,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 Ms(){const e=new CustomEvent(gr);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?Ou(o,a):o.dispatchEvent(a)}var Jn="focusScope.autoFocusOnMount",Zn="focusScope.autoFocusOnUnmount",Os={bubbles:!1,cancelable:!0},zu="FocusScope",Vr=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,u]=i.useState(null),f=Qe(o),d=Qe(a),m=i.useRef(null),h=le(t,p=>u(p)),g=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(s){let p=function(w){if(g.paused||!c)return;const j=w.target;c.contains(j)?m.current=j:Ge(m.current,{select:!0})},v=function(w){if(g.paused||!c)return;const j=w.relatedTarget;j!==null&&(c.contains(j)||Ge(m.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&Ge(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,g.paused]),i.useEffect(()=>{if(c){Ls.add(g);const p=document.activeElement;if(!c.contains(p)){const b=new CustomEvent(Jn,Os);c.addEventListener(Jn,f),c.dispatchEvent(b),b.defaultPrevented||(Hu(Xu(Oo(c)),{select:!0}),document.activeElement===p&&Ge(c))}return()=>{c.removeEventListener(Jn,f),setTimeout(()=>{const b=new CustomEvent(Zn,Os);c.addEventListener(Zn,d),c.dispatchEvent(b),b.defaultPrevented||Ge(p??document.body,{select:!0}),c.removeEventListener(Zn,d),Ls.remove(g)},0)}}},[c,f,d,g]);const x=i.useCallback(p=>{if(!n&&!s||g.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]=Ku(y);w&&j?!p.shiftKey&&b===j?(p.preventDefault(),n&&Ge(w,{select:!0})):p.shiftKey&&b===w&&(p.preventDefault(),n&&Ge(j,{select:!0})):b===y&&p.preventDefault()}},[n,s,g.paused]);return r.jsx(Z.div,{tabIndex:-1,...l,ref:h,onKeyDown:x})});Vr.displayName=zu;function Hu(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Ge(s,{select:t}),document.activeElement!==n)return}function Ku(e){const t=Oo(e),n=Is(t,e),s=Is(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 Is(e,t){for(const n of e)if(!qu(n,{upTo:t}))return n}function qu(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 Gu(e){return e instanceof HTMLInputElement&&"select"in e}function Ge(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Gu(e)&&t&&e.select()}}var Ls=Yu();function Yu(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=$s(e,t),e.unshift(t)},remove(t){var n;e=$s(e,t),(n=e[0])==null||n.resume()}}}function $s(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Xu(e){return e.filter(t=>t.tagName!=="A")}var Ju="Portal",Wr=i.forwardRef((e,t)=>{var c;const{container:n,...s}=e,[o,a]=i.useState(!1);ve(()=>a(!0),[]);const l=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?ic.createPortal(r.jsx(Z.div,{...s,ref:t}),l):null});Wr.displayName=Ju;function Zu(e,t){return i.useReducer((n,s)=>t[n][s]??n,e)}var Rt=e=>{const{present:t,children:n}=e,s=Qu(t),o=typeof n=="function"?n({present:s.isPresent}):i.Children.only(n),a=le(s.ref,ef(o));return typeof n=="function"||s.isPresent?i.cloneElement(o,{ref:a}):null};Rt.displayName="Presence";function Qu(e){const[t,n]=i.useState(),s=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),l=e?"mounted":"unmounted",[c,u]=Zu(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]),ve(()=>{const f=s.current,d=o.current;if(d!==e){const h=a.current,g=en(f);e?u("MOUNT"):g==="none"||(f==null?void 0:f.display)==="none"?u("UNMOUNT"):u(d&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),ve(()=>{if(t){let f;const d=t.ownerDocument.defaultView??window,m=g=>{const p=en(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&p&&(u("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",f=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},h=g=>{g.target===t&&(a.current=en(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{d.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[t,u]),{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 ef(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 Qn=0;function Io(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Fs()),document.body.insertAdjacentElement("beforeend",e[1]??Fs()),Qn++,()=>{Qn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Qn--}},[])}function Fs(){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 Ie=function(){return Ie=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},Ie.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 tf(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",nf="with-scroll-bars-hidden",rf="--removed-body-scroll-bar-size";function er(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function sf(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 of=typeof window<"u"?i.useLayoutEffect:i.useEffect,Bs=new WeakMap;function af(e,t){var n=sf(null,function(s){return e.forEach(function(o){return er(o,s)})});return of(function(){var s=Bs.get(n);if(s){var o=new Set(s),a=new Set(e),l=n.current;o.forEach(function(c){a.has(c)||er(c,null)}),a.forEach(function(c){o.has(c)||er(c,l)})}Bs.set(n,e)},[e]),n}function lf(e){return e}function cf(e,t){t===void 0&&(t=lf);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 u=function(){var d=l;l=[],d.forEach(a)},f=function(){return Promise.resolve().then(u)};f(),n={push:function(d){l.push(d),f()},filter:function(d){return l=l.filter(d),n}}}};return o}function df(e){e===void 0&&(e={});var t=cf(null);return t.options=Ie({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,Ie({},n))};$o.isSideCarExport=!0;function uf(e,t){return e.useMedium(t),$o}var Fo=df(),tr=function(){},_n=i.forwardRef(function(e,t){var n=i.useRef(null),s=i.useState({onScrollCapture:tr,onWheelCapture:tr,onTouchMoveCapture:tr}),o=s[0],a=s[1],l=e.forwardProps,c=e.children,u=e.className,f=e.removeScrollBar,d=e.enabled,m=e.shards,h=e.sideCar,g=e.noRelative,x=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"]),k=h,C=af([n,t]),S=Ie(Ie({},j),o);return i.createElement(i.Fragment,null,d&&i.createElement(k,{sideCar:Fo,removeScrollBar:f,shards:m,noRelative:g,noIsolation:x,inert:p,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:w}),l?i.cloneElement(i.Children.only(c),Ie(Ie({},S),{ref:C})):i.createElement(y,Ie({},S,{className:u,ref:C}),c))});_n.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};_n.classNames={fullWidth:ln,zeroRight:an};var ff=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function mf(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ff();return t&&e.setAttribute("nonce",t),e}function pf(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function hf(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var xf=function(){var e=0,t=null;return{add:function(n){e==0&&(t=mf())&&(pf(t,n),hf(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},gf=function(){var e=xf();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bo=function(){var e=gf(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},vf={left:0,top:0,right:0,gap:0},nr=function(e){return parseInt(e||"",10)||0},bf=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[nr(n),nr(s),nr(o)]},yf=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vf;var t=bf(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])}},wf=Bo(),bt="data-scroll-locked",Nf=function(e,t,n,s){var o=e.left,a=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
195
- .`.concat(nf,` {
196
- overflow: hidden `).concat(s,`;
197
- padding-right: `).concat(c,"px ").concat(s,`;
198
- }
199
- body[`).concat(bt,`] {
200
- overflow: hidden `).concat(s,`;
201
- overscroll-behavior: contain;
202
- `).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
203
- padding-left: `.concat(o,`px;
204
- padding-top: `).concat(a,`px;
205
- padding-right: `).concat(l,`px;
206
- margin-left:0;
207
- margin-top:0;
208
- margin-right: `).concat(c,"px ").concat(s,`;
209
- `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(s,";")].filter(Boolean).join(""),`
210
- }
211
-
212
- .`).concat(an,` {
213
- right: `).concat(c,"px ").concat(s,`;
214
- }
215
-
216
- .`).concat(ln,` {
217
- margin-right: `).concat(c,"px ").concat(s,`;
218
- }
219
-
220
- .`).concat(an," .").concat(an,` {
221
- right: 0 `).concat(s,`;
222
- }
223
-
224
- .`).concat(ln," .").concat(ln,` {
225
- margin-right: 0 `).concat(s,`;
226
- }
227
-
228
- body[`).concat(bt,`] {
229
- `).concat(rf,": ").concat(c,`px;
230
- }
231
- `)},Us=function(){var e=parseInt(document.body.getAttribute(bt)||"0",10);return isFinite(e)?e:0},jf=function(){i.useEffect(function(){return document.body.setAttribute(bt,(Us()+1).toString()),function(){var e=Us()-1;e<=0?document.body.removeAttribute(bt):document.body.setAttribute(bt,e.toString())}},[])},Sf=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;jf();var a=i.useMemo(function(){return yf(o)},[o]);return i.createElement(wf,{styles:Nf(a,!t,o,n?"":"!important")})},vr=!1;if(typeof window<"u")try{var tn=Object.defineProperty({},"passive",{get:function(){return vr=!0,!0}});window.addEventListener("test",tn,tn),window.removeEventListener("test",tn,tn)}catch{vr=!1}var ht=vr?{passive:!1}:!1,kf=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&&!kf(e)&&n[t]==="visible")},Cf=function(e){return Uo(e,"overflowY")},Ef=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=Vo(e,s);if(o){var a=Wo(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]},Af=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Vo=function(e,t){return e==="v"?Cf(t):Ef(t)},Wo=function(e,t){return e==="v"?Tf(t):Af(t)},Rf=function(e,t){return e==="h"&&t==="rtl"?-1:1},_f=function(e,t,n,s,o){var a=Rf(e,window.getComputedStyle(t).direction),l=a*s,c=n.target,u=t.contains(c),f=!1,d=l>0,m=0,h=0;do{if(!c)break;var g=Wo(e,c),x=g[0],p=g[1],v=g[2],b=p-v-a*x;(x||b)&&Vo(e,c)&&(m+=b,h+=x);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(d&&Math.abs(m)<1||!d&&Math.abs(h)<1)&&(f=!0),f},nn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ws=function(e){return[e.deltaX,e.deltaY]},zs=function(e){return e&&"current"in e?e.current:e},Pf=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Df=function(e){return`
232
- .block-interactivity-`.concat(e,` {pointer-events: none;}
233
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
234
- `)},Mf=0,xt=[];function Of(e){var t=i.useRef([]),n=i.useRef([0,0]),s=i.useRef(),o=i.useState(Mf++)[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=tf([e.lockRef.current],(e.shards||[]).map(zs),!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],k,C=p.target,S=Math.abs(w)>Math.abs(j)?"h":"v";if("touches"in p&&S==="h"&&C.type==="range")return!1;var T=window.getSelection(),R=T&&T.anchorNode,A=R?R===C||R.contains(C):!1;if(A)return!1;var O=Vs(S,C);if(!O)return!0;if(O?k=S:(k=S==="v"?"h":"v",O=Vs(S,C)),!O)return!1;if(!s.current&&"changedTouches"in p&&(w||j)&&(s.current=k),!k)return!0;var $=s.current||k;return _f($,v,p,$==="h"?w:j)},[]),u=i.useCallback(function(p){var v=p;if(!(!xt.length||xt[xt.length-1]!==a)){var b="deltaY"in v?Ws(v):nn(v),y=t.current.filter(function(k){return k.name===v.type&&(k.target===v.target||v.target===k.shadowParent)&&Pf(k.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var w=(l.current.shards||[]).map(zs).filter(Boolean).filter(function(k){return k.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:If(b)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(j){return j!==w})},1)},[]),d=i.useCallback(function(p){n.current=nn(p),s.current=void 0},[]),m=i.useCallback(function(p){f(p.type,Ws(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 xt.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:h}),document.addEventListener("wheel",u,ht),document.addEventListener("touchmove",u,ht),document.addEventListener("touchstart",d,ht),function(){xt=xt.filter(function(p){return p!==a}),document.removeEventListener("wheel",u,ht),document.removeEventListener("touchmove",u,ht),document.removeEventListener("touchstart",d,ht)}},[]);var g=e.removeScrollBar,x=e.inert;return i.createElement(i.Fragment,null,x?i.createElement(a,{styles:Df(o)}):null,g?i.createElement(Sf,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function If(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lf=uf(Fo,Of);var zr=i.forwardRef(function(e,t){return i.createElement(_n,Ie({},e,{ref:t,sideCar:Lf}))});zr.classNames=_n.classNames;var $f=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gt=new WeakMap,rn=new WeakMap,sn={},rr=0,zo=function(e){return e&&(e.host||zo(e.parentNode))},Ff=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})},Bf=function(e,t,n,s){var o=Ff(t,Array.isArray(e)?e:[e]);sn[n]||(sn[n]=new WeakMap);var a=sn[n],l=[],c=new Set,u=new Set(o),f=function(m){!m||c.has(m)||(c.add(m),f(m.parentNode))};o.forEach(f);var d=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(h){if(c.has(h))d(h);else try{var g=h.getAttribute(s),x=g!==null&&g!=="false",p=(gt.get(h)||0)+1,v=(a.get(h)||0)+1;gt.set(h,p),a.set(h,v),l.push(h),p===1&&x&&rn.set(h,!0),v===1&&h.setAttribute(n,"true"),x||h.setAttribute(s,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return d(t),c.clear(),rr++,function(){l.forEach(function(m){var h=gt.get(m)-1,g=a.get(m)-1;gt.set(m,h),a.set(m,g),h||(rn.has(m)||m.removeAttribute(s),rn.delete(m)),g||m.removeAttribute(n)}),rr--,rr||(gt=new WeakMap,gt=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=$f(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),Bf(s,o,n,"aria-hidden")):function(){return null}},Pn="Dialog",[Ko,qo]=nt(Pn),[Uf,Oe]=Ko(Pn),Go=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=i.useRef(null),u=i.useRef(null),[f,d]=jt({prop:s,defaultProp:o??!1,onChange:a,caller:Pn});return r.jsx(Uf,{scope:t,triggerRef:c,contentRef:u,contentId:Je(),titleId:Je(),descriptionId:Je(),open:f,onOpenChange:d,onOpenToggle:i.useCallback(()=>d(m=>!m),[d]),modal:l,children:n})};Go.displayName=Pn;var Yo="DialogTrigger",Xo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(Yo,n),a=le(t,o.triggerRef);return r.jsx(Z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":qr(o.open),...s,ref:a,onClick:Y(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=Oe(Hr,t);return r.jsx(Vf,{scope:t,forceMount:n,children:i.Children.map(s,l=>r.jsx(Rt,{present:n||a.open,children:r.jsx(Wr,{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=Oe(mn,e.__scopeDialog);return a.modal?r.jsx(Rt,{present:s||a.open,children:r.jsx(zf,{...o,ref:t})}):null});Qo.displayName=mn;var Wf=Bt("DialogOverlay.RemoveScroll"),zf=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(mn,n);return r.jsx(zr,{as:Wf,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(Z.div,{"data-state":qr(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),lt="DialogContent",ea=i.forwardRef((e,t)=>{const n=Jo(lt,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Oe(lt,e.__scopeDialog);return r.jsx(Rt,{present:s||a.open,children:a.modal?r.jsx(Hf,{...o,ref:t}):r.jsx(Kf,{...o,ref:t})})});ea.displayName=lt;var Hf=i.forwardRef((e,t)=>{const n=Oe(lt,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:Y(e.onCloseAutoFocus,a=>{var l;a.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Y(e.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&a.preventDefault()}),onFocusOutside:Y(e.onFocusOutside,a=>a.preventDefault())})}),Kf=i.forwardRef((e,t)=>{const n=Oe(lt,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 u,f;(u=e.onInteractOutside)==null||u.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=Oe(lt,n),u=i.useRef(null),f=le(t,u);return Io(),r.jsxs(r.Fragment,{children:[r.jsx(Vr,{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(Gf,{titleId:c.titleId}),r.jsx(Xf,{contentRef:u,descriptionId:c.descriptionId})]})]})}),Kr="DialogTitle",na=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(Kr,n);return r.jsx(Z.h2,{id:o.titleId,...s,ref:t})});na.displayName=Kr;var ra="DialogDescription",sa=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(ra,n);return r.jsx(Z.p,{id:o.descriptionId,...s,ref:t})});sa.displayName=ra;var oa="DialogClose",aa=i.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Oe(oa,n);return r.jsx(Z.button,{type:"button",...s,ref:t,onClick:Y(e.onClick,()=>o.onOpenChange(!1))})});aa.displayName=oa;function qr(e){return e?"open":"closed"}var ia="DialogTitleWarning",[qf,la]=Nu(ia,{contentName:lt,titleName:Kr,docsSlug:"dialog"}),Gf=({titleId:e})=>{const t=la(ia),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
235
-
236
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
237
-
238
- 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},Yf="DialogDescriptionWarning",Xf=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${la(Yf).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,Jf=Xo,da=Zo,Gr=Qo,Yr=ea,Xr=na,Jr=sa,Dn=aa;const Zf=ca,Qf=da,zx=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(Qf,{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(zt,{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 em=i.forwardRef(({className:e,...t},n)=>r.jsx(Jr,{ref:n,className:U("text-sm text-muted-foreground",e),...t}));em.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 tm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],nm=tm.reduce((e,t)=>{const n=lc(`Primitive.${t}`),s=i.forwardRef((o,a)=>{const{asChild:l,...c}=o,u=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),rm="Label",xa=i.forwardRef((e,t)=>r.jsx(nm.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=rm;var ga=xa;const sm=cc("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(sm(),e),...t}));Ue.displayName=ga.displayName;function om({onAdded:e}){const[t,n]=i.useState(""),[s,o]=i.useState(!1),[a,l]=i.useState(null),c=i.useCallback(async u=>{if(u.preventDefault(),!!t.trim()){o(!0),l(null);try{await dc({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(ke,{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:u=>n(u.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(H,{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 d;(d=o.current)==null||d.click()},[]),l=i.useCallback(async d=>{const m=Array.from(d.target.files??[]);if(m.length!==0)try{const h=await Rs(m);t(g=>[...g,...h]),s(null)}catch(h){s(h instanceof Error?h.message:"Failed to attach image")}finally{d.target.value=""}},[]),c=i.useCallback(async d=>{const m=Zd(d.clipboardData);if(m.length!==0){d.preventDefault();try{const h=await Rs(m);t(g=>[...g,...h]),s(null)}catch(h){s(h instanceof Error?h.message:"Failed to attach image")}}},[]),u=i.useCallback(d=>{t(m=>m.filter((h,g)=>g!==d))},[]),f=i.useCallback(()=>{t([]),s(null)},[]);return{images:e,error:n,fileInputRef:o,pickImages:a,handleFileChange:l,handlePaste:c,removeImage:u,clearImages:f}}function am({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,u]=i.useState(""),f=i.useRef(null),{images:d,error:m,fileInputRef:h,pickImages:g,handleFileChange:x,handlePaste:p,removeImage:v,clearImages:b}=va(),y=i.useCallback(()=>{f.current&&(f.current.style.height="auto")},[]),w=i.useCallback(()=>{const R=Ro(c,d);R.length===0||t||(e(R),u(""),b(),y())},[c,d,t,e,b,y]),j=i.useCallback(R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),w())},[w]),k=i.useCallback(()=>{f.current&&(f.current.style.height="auto",f.current.style.height=`${Math.min(f.current.scrollHeight,220)}px`)},[]),C=!t&&!a&&(c.trim().length>0||d.length>0),S=a&&!!l,T=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:x,className:"hidden"}),d.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:d.map((R,A)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:Fr(R),alt:R.filename??`attachment ${A+1}`,className:"h-24 w-24 rounded-[22px] border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>v(A),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 ${A+1}`}`,children:r.jsx(zt,{className:"h-3.5 w-3.5"})})]},`${R.filename??"image"}-${A}`))})}),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=>u(R.target.value),onKeyDown:j,onPaste:p,onInput:k,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(H,{type:"button",variant:"ghost",onClick:g,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(mr,{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:T,children:r.jsx(H,{onClick:a?l:w,disabled:a?!S:!C,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(ye,{className:"h-4 w-4 animate-spin"}):r.jsx(Co,{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 Ut({payload:e,disabled:t=!1,bypassEnabled:n=!1,onBypassChange:s,onSubmit:o}){const[a,l]=i.useState(()=>n?su(e):e.questions.map(()=>[])),[c,u]=i.useState(!1),[f,d]=i.useState(!1);i.useEffect(()=>{n&&l(x=>x.map((p,v)=>{var b;return p.length>0?p:(b=e.questions[v])!=null&&b.options.length?[0]:[]}))},[n,e]);const m=ou(e,a)&&!t&&!c&&!f&&!!o,h=(x,p)=>{t||f||c||l(v=>v.map((b,y)=>{if(y!==x)return b;const w=e.questions[y];return w?w.multiSelect?b.includes(p)?b.filter(j=>j!==p):[...b,p].sort((j,k)=>j-k):[p]:b}))},g=async()=>{if(!m||!o)return;u(!0);const x=await o(au(e,a));u(!1),x&&d(!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(Hc,{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(H,{type:"button",variant:n?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!n),className:"rounded-full",children:[r.jsx(_d,{className:"h-4 w-4"}),n?"Bypass on":"Bypass future questions"]})]}),r.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((x,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:[x.header&&r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:x.header}),r.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:x.question}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:x.multiSelect?"Select one or more options.":"Select one option."})]}),r.jsx("div",{className:"space-y-2",children:x.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(ze,{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}`)})})]},`${x.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(H,{type:"button",onClick:()=>void g(),disabled:!m,className:"rounded-full px-5",children:f?"Sent":c?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function im({payload:e,disabled:t=!1,onSubmit:n}){const[s,o]=i.useState(null),[a,l]=i.useState(!1),c=!t&&!a&&!!n,u=async f=>{if(!c||!n)return;o(f);const d=await n(uu(e,f));o(null),d&&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,d)=>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}-${d}`))})]})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[r.jsxs(H,{type:"button",variant:"outline",onClick:()=>void u("deny"),disabled:!c||s!==null,className:"rounded-full",children:[r.jsx(zt,{className:"h-4 w-4"}),a?"Sent":s==="deny"?"Sending...":"Deny"]}),r.jsxs(H,{type:"button",onClick:()=>void u("approve"),disabled:!c||s!==null,className:"rounded-full",children:[r.jsx(ze,{className:"h-4 w-4"}),a?"Sent":s==="approve"?"Sending...":"Approve"]})]})]})}function Hs({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const a=e.type,l=Br(e),c=An(e);if(l)return r.jsx(Lt,{children:r.jsx(im,{payload:l,onSubmit:s,disabled:o})});if(c)return r.jsx(Lt,{children:r.jsx(Ut,{payload:c,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});if(a==="user"){const u=lm(e),f=u.filter(m=>m.type==="tool_result");if(f.length>0&&u.every(m=>m.type==="tool_result"))return r.jsx(Lt,{children:f.map((m,h)=>r.jsx(ya,{block:m,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},h))});const d=Ht(e);return d?r.jsx(fm,{content:d}):null}return a==="assistant"?r.jsx(mm,{event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function lm(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 sr(e){var n;const t=e.replace(/\r\n/g,`
239
- `).split(`
240
- `);for(;t.length>0&&((n=t[0])==null?void 0:n.trim())==="";)t.shift();return t.join(`
241
- `)}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(ze,{className:"h-3 w-3 text-emerald-500"}):r.jsx(Tn,{className:"h-3 w-3"})})}async function cm(e){let n=await(await fetch(e)).blob();n.type!=="image/png"&&(n=await dm(n)),await navigator.clipboard.write([new ClipboardItem({[n.type]:n})])}async function dm(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 um({dataUrl:e,className:t=""}){const[n,s]=i.useState(!1),o=async a=>{a.stopPropagation();try{await cm(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(ze,{className:"h-3 w-3 text-emerald-500"}):r.jsx(Tn,{className:"h-3 w-3"})})}function fm({content:e}){const t=Jd(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(um,{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(Od,{className:"h-4 w-4"})})]})})}function Lt({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(wo,{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 mm({event:e,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o}){const a=e.message;if(!a)return null;const l=An(a);if(l)return r.jsx(Lt,{children:r.jsx(Ut,{payload:l,bypassEnabled:t,onBypassChange:n,onSubmit:s,disabled:o})});const c=a.content;if(!c||!Array.isArray(c))return null;const u=new Set,f=c.filter(x=>x.type==="text").map(x=>({...x,text:sr(String(x.text??"")),questionPayload:Rn(sr(String(x.text??"")))})).filter(x=>x.text.length>0||x.questionPayload),d=c.filter(x=>x.type==="thinking").map(x=>sr(String(x.thinking??""))).filter(Boolean).join(`
242
-
243
- `),m=c.filter(x=>x.type==="tool_use"),h=c.filter(x=>x.type==="tool_result");return f.length>0||d.length>0||m.length>0||h.length>0?r.jsxs(Lt,{children:[d.length>0&&r.jsx(gm,{text:d}),f.map((x,p)=>{if(x.questionPayload){const v=At(x.questionPayload);return u.has(v)?null:(u.add(v),r.jsx(Ut,{payload:x.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:x.text,className:"absolute right-2 top-2"}),r.jsx("div",{className:"whitespace-pre-wrap",children:x.text})]},p)}),m.map((x,p)=>r.jsx(vm,{block:x,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p)),h.map((x,p)=>r.jsx(ya,{block:x,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:n,onSubmitQuestionResponse:s,questionResponseDisabled:o},p))]}):null}function pm(e){return e.replace(/\s+/g," ").trim()}function yt(e,t=132){const n=pm(e);return n?n.length>t?`${n.slice(0,t-3)}...`:n:""}function br(e,t=84){if(typeof e=="string")return yt(e,t);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const n=e.slice(0,3).map(s=>br(s,28)).filter(Boolean).join(", ");return yt(n||JSON.stringify(e),t)}if(typeof e=="object"&&e!==null){const n=Object.entries(e).slice(0,3).map(([s,o])=>`${s}: ${br(o,32)}`).join(" · ");return yt(n||JSON.stringify(e),t)}return""}function hm(e){if(!e)return"No input";const t=Object.entries(e).slice(0,4).map(([n,s])=>`${n}: ${br(s,40)}`).filter(n=>n.trim().length>0).join(" · ");return yt(t||JSON.stringify(e),156)||"No input"}function xm({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(Et,{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(u=>!u),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(xm,{expanded:l})]}),l&&r.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:s})]})}function gm({text:e}){const t=yt(e,156);return r.jsx(Zr,{title:"Thinking",preview:t,icon:r.jsx(Fc,{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 vm({block:e,renderedQuestionSignatures:t,questionBypassEnabled:n,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:a}){const l=String(e.name??"tool"),c=e.input,u=An(e);if(u){const d=At(u);return t!=null&&t.has(d)?null:(t==null||t.add(d),r.jsx(Ut,{payload:u,bypassEnabled:n,onBypassChange:s,onSubmit:o,disabled:a}))}const f=hm(c);if(l==="TodoWrite"){const d=bm(c==null?void 0:c.todos);if(d.length>0)return r.jsx(ym,{todos:d})}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(d=>String(d.text??"")).join(`
244
- `):"";if(!c)return null;const u=Rn(c);if(u){const d=At(u);return t!=null&&t.has(d)?null:(t==null||t.add(d),r.jsx(Ut,{payload:u,bypassEnabled:n,onBypassChange:s,onSubmit:o,disabled:a}))}const f=yt(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 bm(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 ym({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(pd,{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(wm,{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 wm({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(ze,{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(ye,{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(Yc,{className:"h-3 w-3"})})}function wa(e){const t=e+"CollectionProvider",[n,s]=nt(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=p=>{const{scope:v,children:b}=p,y=at.useRef(null),w=at.useRef(new Map).current;return r.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:b})};l.displayName=t;const c=e+"CollectionSlot",u=Bt(c),f=at.forwardRef((p,v)=>{const{scope:b,children:y}=p,w=a(c,b),j=le(v,w.collectionRef);return r.jsx(u,{ref:j,children:y})});f.displayName=c;const d=e+"CollectionItemSlot",m="data-radix-collection-item",h=Bt(d),g=at.forwardRef((p,v)=>{const{scope:b,children:y,...w}=p,j=at.useRef(null),k=le(v,j),C=a(d,b);return at.useEffect(()=>(C.itemMap.set(j,{ref:j,...w}),()=>void C.itemMap.delete(j))),r.jsx(h,{[m]:"",ref:k,children:y})});g.displayName=d;function x(p){const v=a(e+"CollectionConsumer",p);return at.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${m}]`));return Array.from(v.itemMap.values()).sort((C,S)=>w.indexOf(C.ref.current)-w.indexOf(S.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:l,Slot:f,ItemSlot:g},x,s]}var Nm=i.createContext(void 0);function Qr(e){const t=i.useContext(Nm);return e||t||"ltr"}var or="rovingFocusGroup.onEntryFocus",jm={bubbles:!1,cancelable:!0},qt="RovingFocusGroup",[yr,Na,Sm]=wa(qt),[km,ja]=nt(qt,[Sm]),[Cm,Em]=km(qt),Sa=i.forwardRef((e,t)=>r.jsx(yr.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(yr.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Tm,{...e,ref:t})})}));Sa.displayName=qt;var Tm=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:d=!1,...m}=e,h=i.useRef(null),g=le(t,h),x=Qr(a),[p,v]=jt({prop:l,defaultProp:c??null,onChange:u,caller:qt}),[b,y]=i.useState(!1),w=Qe(f),j=Na(n),k=i.useRef(!1),[C,S]=i.useState(0);return i.useEffect(()=>{const T=h.current;if(T)return T.addEventListener(or,w),()=>T.removeEventListener(or,w)},[w]),r.jsx(Cm,{scope:n,orientation:s,dir:x,loop:o,currentTabStopId:p,onItemFocus:i.useCallback(T=>v(T),[v]),onItemShiftTab:i.useCallback(()=>y(!0),[]),onFocusableItemAdd:i.useCallback(()=>S(T=>T+1),[]),onFocusableItemRemove:i.useCallback(()=>S(T=>T-1),[]),children:r.jsx(Z.div,{tabIndex:b||C===0?-1:0,"data-orientation":s,...m,ref:g,style:{outline:"none",...e.style},onMouseDown:Y(e.onMouseDown,()=>{k.current=!0}),onFocus:Y(e.onFocus,T=>{const R=!k.current;if(T.target===T.currentTarget&&R&&!b){const A=new CustomEvent(or,jm);if(T.currentTarget.dispatchEvent(A),!A.defaultPrevented){const O=j().filter(P=>P.focusable),$=O.find(P=>P.active),V=O.find(P=>P.id===p),z=[$,V,...O].filter(Boolean).map(P=>P.ref.current);Ea(z,d)}}k.current=!1}),onBlur:Y(e.onBlur,()=>y(!1))})})}),ka="RovingFocusGroupItem",Ca=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:l,...c}=e,u=Je(),f=a||u,d=Em(ka,n),m=d.currentTabStopId===f,h=Na(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:p}=d;return i.useEffect(()=>{if(s)return g(),()=>x()},[s,g,x]),r.jsx(yr.ItemSlot,{scope:n,id:f,focusable:s,active:o,children:r.jsx(Z.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...c,ref:t,onMouseDown:Y(e.onMouseDown,v=>{s?d.onItemFocus(f):v.preventDefault()}),onFocus:Y(e.onFocus,()=>d.onItemFocus(f)),onKeyDown:Y(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=_m(v,d.orientation,d.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=d.loop?Pm(w,j+1):w.slice(j+1)}setTimeout(()=>Ea(w))}}),children:typeof l=="function"?l({isCurrentTabStop:m,hasTabStop:p!=null}):l})})});Ca.displayName=ka;var Am={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Rm(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function _m(e,t,n){const s=Rm(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Am[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 Pm(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Dm=Sa,Mm=Ca,Mn="Tabs",[Om]=nt(Mn,[ja]),Ta=ja(),[Im,es]=Om(Mn),Aa=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:l="horizontal",dir:c,activationMode:u="automatic",...f}=e,d=Qr(c),[m,h]=jt({prop:s,onChange:o,defaultProp:a??"",caller:Mn});return r.jsx(Im,{scope:n,baseId:Je(),value:m,onValueChange:h,orientation:l,dir:d,activationMode:u,children:r.jsx(Z.div,{dir:d,"data-orientation":l,...f,ref:t})})});Aa.displayName=Mn;var Ra="TabsList",_a=i.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=es(Ra,n),l=Ta(n);return r.jsx(Dm,{asChild:!0,...l,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(Z.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=Ta(n),u=Ia(l.baseId,s),f=La(l.baseId,s),d=s===l.value;return r.jsx(Mm,{asChild:!0,...c,focusable:!o,active:d,children:r.jsx(Z.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":f,"data-state":d?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...a,ref:t,onMouseDown:Y(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?l.onValueChange(s):m.preventDefault()}),onKeyDown:Y(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&l.onValueChange(s)}),onFocus:Y(e.onFocus,()=>{const m=l.activationMode!=="manual";!d&&!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),u=Ia(c.baseId,s),f=La(c.baseId,s),d=s===c.value,m=i.useRef(d);return i.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),r.jsx(Rt,{present:o||d,children:({present:h})=>r.jsx(Z.div,{"data-state":d?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,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 Lm=Aa,$a=_a,Fa=Da,Ba=Oa;const Ua=Lm,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 Ye=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}));Ye.displayName=Fa.displayName;const Xe=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}));Xe.displayName=Ba.displayName;var Va="AlertDialog",[$m]=nt(Va,[qo]),He=qo(),Wa=e=>{const{__scopeAlertDialog:t,...n}=e,s=He(t);return r.jsx(ca,{...s,...n,modal:!0})};Wa.displayName=Va;var Fm="AlertDialogTrigger",za=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=He(n);return r.jsx(Jf,{...o,...s,ref:t})});za.displayName=Fm;var Bm="AlertDialogPortal",Ha=e=>{const{__scopeAlertDialog:t,...n}=e,s=He(t);return r.jsx(da,{...s,...n})};Ha.displayName=Bm;var Um="AlertDialogOverlay",Ka=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=He(n);return r.jsx(Gr,{...o,...s,ref:t})});Ka.displayName=Um;var wt="AlertDialogContent",[Vm,Wm]=$m(wt),zm=Ru("AlertDialogContent"),qa=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:s,...o}=e,a=He(n),l=i.useRef(null),c=le(t,l),u=i.useRef(null);return r.jsx(qf,{contentName:wt,titleName:Ga,docsSlug:"alert-dialog",children:r.jsx(Vm,{scope:n,cancelRef:u,children:r.jsxs(Yr,{role:"alertdialog",...a,...o,ref:c,onOpenAutoFocus:Y(o.onOpenAutoFocus,f=>{var d;f.preventDefault(),(d=u.current)==null||d.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[r.jsx(zm,{children:s}),r.jsx(Km,{contentRef:l})]})})})});qa.displayName=wt;var Ga="AlertDialogTitle",Ya=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=He(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=He(n);return r.jsx(Jr,{...o,...s,ref:t})});Ja.displayName=Xa;var Hm="AlertDialogAction",Za=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,o=He(n);return r.jsx(Dn,{...o,...s,ref:t})});Za.displayName=Hm;var Qa="AlertDialogCancel",ei=i.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...s}=e,{cancelRef:o}=Wm(Qa,n),a=He(n),l=le(t,o);return r.jsx(Dn,{...a,...s,ref:l})});ei.displayName=Qa;var Km=({contentRef:e})=>{const t=`\`${wt}\` requires a description for the component to be accessible for screen reader users.
245
-
246
- You can add a description to the \`${wt}\` by passing a \`${Xa}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
247
-
248
- 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 \`${wt}\`. 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.
249
-
250
- 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},qm=Wa,Gm=za,Ym=Ha,ti=Ka,ni=qa,ri=Za,si=ei,oi=Ya,ai=Ja;const wr=qm,Ks=Gm,Xm=Ym,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(Xm,{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(go(),e),...t}));bn.displayName=ri.displayName;const yn=i.forwardRef(({className:e,...t},n)=>r.jsx(si,{ref:n,className:U(go({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));yn.displayName=si.displayName;function qs(e,[t,n]){return Math.min(n,Math.max(t,e))}const Jm=["top","right","bottom","left"],et=Math.min,Se=Math.max,wn=Math.round,on=Math.floor,$e=e=>({x:e,y:e}),Zm={left:"right",right:"left",bottom:"top",top:"bottom"};function Nr(e,t,n){return Se(e,et(t,n))}function Ve(e,t){return typeof e=="function"?e(t):e}function We(e){return e.split("-")[0]}function _t(e){return e.split("-")[1]}function ns(e){return e==="x"?"y":"x"}function rs(e){return e==="y"?"height":"width"}function Le(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ss(e){return ns(Le(e))}function Qm(e,t,n){n===void 0&&(n=!1);const s=_t(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 ep(e){const t=Nn(e);return[jr(e),t,jr(t)]}function jr(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Gs=["left","right"],Ys=["right","left"],tp=["top","bottom"],np=["bottom","top"];function rp(e,t,n){switch(e){case"top":case"bottom":return n?t?Ys:Gs:t?Gs:Ys;case"left":case"right":return t?tp:np;default:return[]}}function sp(e,t,n,s){const o=_t(e);let a=rp(We(e),n==="start",s);return o&&(a=a.map(l=>l+"-"+o),t&&(a=a.concat(a.map(jr)))),a}function Nn(e){const t=We(e);return Zm[t]+e.slice(t.length)}function op(e){return{top:0,right:0,bottom:0,left:0,...e}}function li(e){return typeof e!="number"?op(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 Xs(e,t,n){let{reference:s,floating:o}=e;const a=Le(t),l=ss(t),c=rs(l),u=We(t),f=a==="y",d=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 g;switch(u){case"top":g={x:d,y:s.y-o.height};break;case"bottom":g={x:d,y:s.y+s.height};break;case"right":g={x:s.x+s.width,y:m};break;case"left":g={x:s.x-o.width,y:m};break;default:g={x:s.x,y:s.y}}switch(_t(t)){case"start":g[l]-=h*(n&&f?-1:1);break;case"end":g[l]+=h*(n&&f?-1:1);break}return g}async function ap(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:a,rects:l,elements:c,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:d="viewport",elementContext:m="floating",altBoundary:h=!1,padding:g=0}=Ve(t,e),x=li(g),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:d,strategy:u})),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},k=jn(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:w,strategy:u}):y);return{top:(b.top-k.top+x.top)/j.y,bottom:(k.bottom-b.bottom+x.bottom)/j.y,left:(b.left-k.left+x.left)/j.x,right:(k.right-b.right+x.right)/j.x}}const ip=50,lp=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:ap},u=await(l.isRTL==null?void 0:l.isRTL(t));let f=await l.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:m}=Xs(f,s,u),h=s,g=0;const x={};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:k,reset:C}=await y({x:d,y:m,initialPlacement:s,placement:h,strategy:o,middlewareData:x,rects:f,platform:c,elements:{reference:e,floating:t}});d=w??d,m=j??m,x[b]={...x[b],...k},C&&g<ip&&(g++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(f=C.rects===!0?await l.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:m}=Xs(f,h,u)),p=-1)}return{x:d,y:m,placement:h,strategy:o,middlewareData:x}},cp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:a,platform:l,elements:c,middlewareData:u}=t,{element:f,padding:d=0}=Ve(e,t)||{};if(f==null)return{};const m=li(d),h={x:n,y:s},g=ss(o),x=rs(g),p=await l.getDimensions(f),v=g==="y",b=v?"top":"left",y=v?"bottom":"right",w=v?"clientHeight":"clientWidth",j=a.reference[x]+a.reference[g]-h[g]-a.floating[x],k=h[g]-a.reference[g],C=await(l.getOffsetParent==null?void 0:l.getOffsetParent(f));let S=C?C[w]:0;(!S||!await(l.isElement==null?void 0:l.isElement(C)))&&(S=c.floating[w]||a.floating[x]);const T=j/2-k/2,R=S/2-p[x]/2-1,A=et(m[b],R),O=et(m[y],R),$=A,V=S-p[x]-O,W=S/2-p[x]/2+T,z=Nr($,W,V),P=!u.arrow&&_t(o)!=null&&W!==z&&a.reference[x]/2-(W<$?A:O)-p[x]/2<0,_=P?W<$?W-$:W-V:0;return{[g]:h[g]+_,data:{[g]:z,centerOffset:W-z-_,...P&&{alignmentOffset:_}},reset:P}}}),dp=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:u,elements:f}=t,{mainAxis:d=!0,crossAxis:m=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:p=!0,...v}=Ve(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=We(o),y=Le(c),w=We(c)===c,j=await(u.isRTL==null?void 0:u.isRTL(f.floating)),k=h||(w||!p?[Nn(c)]:ep(c)),C=x!=="none";!h&&C&&k.push(...sp(c,p,x,j));const S=[c,...k],T=await u.detectOverflow(t,v),R=[];let A=((s=a.flip)==null?void 0:s.overflows)||[];if(d&&R.push(T[b]),m){const W=Qm(o,l,j);R.push(T[W[0]],T[W[1]])}if(A=[...A,{placement:o,overflows:R}],!R.every(W=>W<=0)){var O,$;const W=(((O=a.flip)==null?void 0:O.index)||0)+1,z=S[W];if(z&&(!(m==="alignment"?y!==Le(z):!1)||A.every(L=>Le(L.placement)===y?L.overflows[0]>0:!0)))return{data:{index:W,overflows:A},reset:{placement:z}};let P=($=A.filter(_=>_.overflows[0]<=0).sort((_,L)=>_.overflows[1]-L.overflows[1])[0])==null?void 0:$.placement;if(!P)switch(g){case"bestFit":{var V;const _=(V=A.filter(L=>{if(C){const E=Le(L.placement);return E===y||E==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(E=>E>0).reduce((E,te)=>E+te,0)]).sort((L,E)=>L[1]-E[1])[0])==null?void 0:V[0];_&&(P=_);break}case"initialPlacement":P=c;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function Js(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Zs(e){return Jm.some(t=>e[t]>=0)}const up=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=Js(l,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:Zs(c)}}}case"escaped":{const l=await s.detectOverflow(t,{...a,altBoundary:!0}),c=Js(l,n.floating);return{data:{escapedOffsets:c,escaped:Zs(c)}}}default:return{}}}}},ci=new Set(["left","top"]);async function fp(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),l=We(n),c=_t(n),u=Le(n)==="y",f=ci.has(l)?-1:1,d=a&&u?-1:1,m=Ve(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:x}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof x=="number"&&(g=c==="end"?x*-1:x),u?{x:g*d,y:h*f}:{x:h*f,y:g*d}}const mp=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,u=await fp(t,e);return l===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:o+u.x,y:a+u.y,data:{...u,placement:l}}}}},pp=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:u={fn:b=>{let{x:y,y:w}=b;return{x:y,y:w}}},...f}=Ve(e,t),d={x:n,y:s},m=await a.detectOverflow(t,f),h=Le(We(o)),g=ns(h);let x=d[g],p=d[h];if(l){const b=g==="y"?"top":"left",y=g==="y"?"bottom":"right",w=x+m[b],j=x-m[y];x=Nr(w,x,j)}if(c){const b=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=p+m[b],j=p-m[y];p=Nr(w,p,j)}const v=u.fn({...t,[g]:x,[h]:p});return{...v,data:{x:v.x-n,y:v.y-s,enabled:{[g]:l,[h]:c}}}}}},hp=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:u=!0,crossAxis:f=!0}=Ve(e,t),d={x:n,y:s},m=Le(o),h=ns(m);let g=d[h],x=d[m];const p=Ve(c,t),v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(u){const w=h==="y"?"height":"width",j=a.reference[h]-a.floating[w]+v.mainAxis,k=a.reference[h]+a.reference[w]-v.mainAxis;g<j?g=j:g>k&&(g=k)}if(f){var b,y;const w=h==="y"?"width":"height",j=ci.has(We(o)),k=a.reference[m]-a.floating[w]+(j&&((b=l.offset)==null?void 0:b[m])||0)+(j?0:v.crossAxis),C=a.reference[m]+a.reference[w]+(j?0:((y=l.offset)==null?void 0:y[m])||0)-(j?v.crossAxis:0);x<k?x=k:x>C&&(x=C)}return{[h]:g,[m]:x}}}},xp=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:u=()=>{},...f}=Ve(e,t),d=await l.detectOverflow(t,f),m=We(o),h=_t(o),g=Le(o)==="y",{width:x,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-d.top-d.bottom,w=x-d.left-d.right,j=et(p-d[v],y),k=et(x-d[b],w),C=!t.middlewareData.shift;let S=j,T=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=w),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(S=y),C&&!h){const A=Se(d.left,0),O=Se(d.right,0),$=Se(d.top,0),V=Se(d.bottom,0);g?T=x-2*(A!==0||O!==0?A+O:Se(d.left,d.right)):S=p-2*($!==0||V!==0?$+V:Se(d.top,d.bottom))}await u({...t,availableWidth:T,availableHeight:S});const R=await l.getDimensions(c.floating);return x!==R.width||p!==R.height?{reset:{rects:!0}}:{}}}};function On(){return typeof window<"u"}function Pt(e){return di(e)?(e.nodeName||"").toLowerCase():"#document"}function Ce(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Fe(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 Ce(e).Node:!1}function De(e){return On()?e instanceof Element||e instanceof Ce(e).Element:!1}function Ke(e){return On()?e instanceof HTMLElement||e instanceof Ce(e).HTMLElement:!1}function Qs(e){return!On()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ce(e).ShadowRoot}function Gt(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Me(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&o!=="inline"&&o!=="contents"}function gp(e){return/^(table|td|th)$/.test(Pt(e))}function In(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const vp=/transform|translate|scale|rotate|perspective|filter/,bp=/paint|layout|strict|content/,it=e=>!!e&&e!=="none";let ar;function os(e){const t=De(e)?Me(e):e;return it(t.transform)||it(t.translate)||it(t.scale)||it(t.rotate)||it(t.perspective)||!as()&&(it(t.backdropFilter)||it(t.filter))||vp.test(t.willChange||"")||bp.test(t.contain||"")}function yp(e){let t=tt(e);for(;Ke(t)&&!kt(t);){if(os(t))return t;if(In(t))return null;t=tt(t)}return null}function as(){return ar==null&&(ar=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ar}function kt(e){return/^(html|body|#document)$/.test(Pt(e))}function Me(e){return Ce(e).getComputedStyle(e)}function Ln(e){return De(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tt(e){if(Pt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Qs(e)&&e.host||Fe(e);return Qs(t)?t.host:t}function ui(e){const t=tt(e);return kt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ke(t)&&Gt(t)?t:ui(t)}function Vt(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=Ce(o);if(a){const c=Sr(l);return t.concat(l,l.visualViewport||[],Gt(o)?o:[],c&&n?Vt(c):[])}else return t.concat(o,Vt(o,[],n))}function Sr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fi(e){const t=Me(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Ke(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 De(e)?e:e.contextElement}function Nt(e){const t=is(e);if(!Ke(t))return $e(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 wp=$e(0);function mi(e){const t=Ce(e);return!as()||!t.visualViewport?wp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Np(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ce(e)?!1:t}function ct(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=is(e);let l=$e(1);t&&(s?De(s)&&(l=Nt(s)):l=Nt(e));const c=Np(a,n,s)?mi(a):$e(0);let u=(o.left+c.x)/l.x,f=(o.top+c.y)/l.y,d=o.width/l.x,m=o.height/l.y;if(a){const h=Ce(a),g=s&&De(s)?Ce(s):s;let x=h,p=Sr(x);for(;p&&s&&g!==x;){const v=Nt(p),b=p.getBoundingClientRect(),y=Me(p),w=b.left+(p.clientLeft+parseFloat(y.paddingLeft))*v.x,j=b.top+(p.clientTop+parseFloat(y.paddingTop))*v.y;u*=v.x,f*=v.y,d*=v.x,m*=v.y,u+=w,f+=j,x=Ce(p),p=Sr(x)}}return jn({width:d,height:m,x:u,y:f})}function $n(e,t){const n=Ln(e).scrollLeft;return t?t.left+n:ct(Fe(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 jp(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",l=Fe(s),c=t?In(t.floating):!1;if(s===l||c&&a)return n;let u={scrollLeft:0,scrollTop:0},f=$e(1);const d=$e(0),m=Ke(s);if((m||!m&&!a)&&((Pt(s)!=="body"||Gt(l))&&(u=Ln(s)),m)){const g=ct(s);f=Nt(s),d.x=g.x+s.clientLeft,d.y=g.y+s.clientTop}const h=l&&!m&&!a?pi(l,u):$e(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+d.x+h.x,y:n.y*f.y-u.scrollTop*f.y+d.y+h.y}}function Sp(e){return Array.from(e.getClientRects())}function kp(e){const t=Fe(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 Me(s).direction==="rtl"&&(l+=Se(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:l,y:c}}const eo=25;function Cp(e,t){const n=Ce(e),s=Fe(e),o=n.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,u=0;if(o){a=o.width,l=o.height;const d=as();(!d||d&&t==="fixed")&&(c=o.offsetLeft,u=o.offsetTop)}const f=$n(s);if(f<=0){const d=s.ownerDocument,m=d.body,h=getComputedStyle(m),g=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,x=Math.abs(s.clientWidth-m.clientWidth-g);x<=eo&&(a-=x)}else f<=eo&&(a+=f);return{width:a,height:l,x:c,y:u}}function Ep(e,t){const n=ct(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=Ke(e)?Nt(e):$e(1),l=e.clientWidth*a.x,c=e.clientHeight*a.y,u=o*a.x,f=s*a.y;return{width:l,height:c,x:u,y:f}}function to(e,t,n){let s;if(t==="viewport")s=Cp(e,n);else if(t==="document")s=kp(Fe(e));else if(De(t))s=Ep(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=tt(e);return n===t||!De(n)||kt(n)?!1:Me(n).position==="fixed"||hi(n,t)}function Tp(e,t){const n=t.get(e);if(n)return n;let s=Vt(e,[],!1).filter(c=>De(c)&&Pt(c)!=="body"),o=null;const a=Me(e).position==="fixed";let l=a?tt(e):e;for(;De(l)&&!kt(l);){const c=Me(l),u=os(l);!u&&c.position==="fixed"&&(o=null),(a?!u&&!o:!u&&c.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Gt(l)&&!u&&hi(e,l))?s=s.filter(d=>d!==l):o=c,l=tt(l)}return t.set(e,s),s}function Ap(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=to(t,l[0],o);let u=c.top,f=c.right,d=c.bottom,m=c.left;for(let h=1;h<l.length;h++){const g=to(t,l[h],o);u=Se(g.top,u),f=et(g.right,f),d=et(g.bottom,d),m=Se(g.left,m)}return{width:f-m,height:d-u,x:m,y:u}}function Rp(e){const{width:t,height:n}=fi(e);return{width:t,height:n}}function _p(e,t,n){const s=Ke(t),o=Fe(t),a=n==="fixed",l=ct(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=$e(0);function f(){u.x=$n(o)}if(s||!s&&!a)if((Pt(t)!=="body"||Gt(o))&&(c=Ln(t)),s){const g=ct(t,!0,a,t);u.x=g.x+t.clientLeft,u.y=g.y+t.clientTop}else o&&f();a&&!s&&o&&f();const d=o&&!s&&!a?pi(o,c):$e(0),m=l.left+c.scrollLeft-u.x-d.x,h=l.top+c.scrollTop-u.y-d.y;return{x:m,y:h,width:l.width,height:l.height}}function ir(e){return Me(e).position==="static"}function no(e,t){if(!Ke(e)||Me(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Fe(e)===n&&(n=n.ownerDocument.body),n}function xi(e,t){const n=Ce(e);if(In(e))return n;if(!Ke(e)){let o=tt(e);for(;o&&!kt(o);){if(De(o)&&!ir(o))return o;o=tt(o)}return n}let s=no(e,t);for(;s&&gp(s)&&ir(s);)s=no(s,t);return s&&kt(s)&&ir(s)&&!os(s)?n:s||yp(e)||n}const Pp=async function(e){const t=this.getOffsetParent||xi,n=this.getDimensions,s=await n(e.floating);return{reference:_p(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Dp(e){return Me(e).direction==="rtl"}const Mp={convertOffsetParentRelativeRectToViewportRelativeRect:jp,getDocumentElement:Fe,getClippingRect:Ap,getOffsetParent:xi,getElementRects:Pp,getClientRects:Sp,getDimensions:Rp,getScale:Nt,isElement:De,isRTL:Dp};function gi(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Op(e,t){let n=null,s;const o=Fe(e);function a(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function l(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const f=e.getBoundingClientRect(),{left:d,top:m,width:h,height:g}=f;if(c||t(),!h||!g)return;const x=on(m),p=on(o.clientWidth-(d+h)),v=on(o.clientHeight-(m+g)),b=on(d),w={rootMargin:-x+"px "+-p+"px "+-v+"px "+-b+"px",threshold:Se(0,et(1,u))||1};let j=!0;function k(C){const S=C[0].intersectionRatio;if(S!==u){if(!j)return l();S?l(!1,S):s=setTimeout(()=>{l(!1,1e-7)},1e3)}S===1&&!gi(f,e.getBoundingClientRect())&&l(),j=!1}try{n=new IntersectionObserver(k,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,w)}n.observe(e)}return l(!0),a}function Ip(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:u=!1}=s,f=is(e),d=o||a?[...f?Vt(f):[],...t?Vt(t):[]]:[];d.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const m=f&&c?Op(f,n):null;let h=-1,g=null;l&&(g=new ResizeObserver(b=>{let[y]=b;y&&y.target===f&&g&&t&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),f&&!u&&g.observe(f),t&&g.observe(t));let x,p=u?ct(e):null;u&&v();function v(){const b=ct(e);p&&!gi(p,b)&&n(),p=b,x=requestAnimationFrame(v)}return n(),()=>{var b;d.forEach(y=>{o&&y.removeEventListener("scroll",n),a&&y.removeEventListener("resize",n)}),m==null||m(),(b=g)==null||b.disconnect(),g=null,u&&cancelAnimationFrame(x)}}const Lp=mp,$p=pp,Fp=dp,Bp=xp,Up=up,ro=cp,Vp=hp,Wp=(e,t,n)=>{const s=new Map,o={platform:Mp,...n},a={...o.platform,_c:s};return lp(e,t,{...o,platform:a})};var zp=typeof document<"u",Hp=function(){},cn=zp?i.useLayoutEffect:Hp;function Sn(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(!Sn(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)&&!Sn(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 so(e,t){const n=vi(e);return Math.round(t*n)/n}function lr(e){const t=i.useRef(e);return cn(()=>{t.current=e}),t}function Kp(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:u,open:f}=e,[d,m]=i.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=i.useState(s);Sn(h,s)||g(s);const[x,p]=i.useState(null),[v,b]=i.useState(null),y=i.useCallback(L=>{L!==C.current&&(C.current=L,p(L))},[]),w=i.useCallback(L=>{L!==S.current&&(S.current=L,b(L))},[]),j=a||x,k=l||v,C=i.useRef(null),S=i.useRef(null),T=i.useRef(d),R=u!=null,A=lr(u),O=lr(o),$=lr(f),V=i.useCallback(()=>{if(!C.current||!S.current)return;const L={placement:t,strategy:n,middleware:h};O.current&&(L.platform=O.current),Wp(C.current,S.current,L).then(E=>{const te={...E,isPositioned:$.current!==!1};W.current&&!Sn(T.current,te)&&(T.current=te,En.flushSync(()=>{m(te)}))})},[h,t,n,O,$]);cn(()=>{f===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,m(L=>({...L,isPositioned:!1})))},[f]);const W=i.useRef(!1);cn(()=>(W.current=!0,()=>{W.current=!1}),[]),cn(()=>{if(j&&(C.current=j),k&&(S.current=k),j&&k){if(A.current)return A.current(j,k,V);V()}},[j,k,V,A,R]);const z=i.useMemo(()=>({reference:C,floating:S,setReference:y,setFloating:w}),[y,w]),P=i.useMemo(()=>({reference:j,floating:k}),[j,k]),_=i.useMemo(()=>{const L={position:n,left:0,top:0};if(!P.floating)return L;const E=so(P.floating,d.x),te=so(P.floating,d.y);return c?{...L,transform:"translate("+E+"px, "+te+"px)",...vi(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:te}},[n,c,P.floating,d.x,d.y]);return i.useMemo(()=>({...d,update:V,refs:z,elements:P,floatingStyles:_}),[d,V,z,P,_])}const qp=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?ro({element:s.current,padding:o}).fn(n):{}:s?ro({element:s,padding:o}).fn(n):{}}}},Gp=(e,t)=>{const n=Lp(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yp=(e,t)=>{const n=$p(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xp=(e,t)=>({fn:Vp(e).fn,options:[e,t]}),Jp=(e,t)=>{const n=Fp(e);return{name:n.name,fn:n.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=qp(e);return{name:n.name,fn:n.fn,options:[e,t]}};var th="Arrow",bi=i.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...a}=e;return r.jsx(Z.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=th;var nh=bi;function yi(e){const[t,n]=i.useState(void 0);return ve(()=>{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 u=a.borderBoxSize,f=Array.isArray(u)?u[0]:u;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]=nt(ls),[rh,ji]=wi(ls),Si=e=>{const{__scopePopper:t,children:n}=e,[s,o]=i.useState(null);return r.jsx(rh,{scope:t,anchor:s,onAnchorChange:o,children:n})};Si.displayName=ls;var ki="PopperAnchor",Ci=i.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=ji(ki,n),l=i.useRef(null),c=le(t,l),u=i.useRef(null);return i.useEffect(()=>{const f=u.current;u.current=(s==null?void 0:s.current)||l.current,f!==u.current&&a.onAnchorChange(u.current)}),s?null:r.jsx(Z.div,{...o,ref:c})});Ci.displayName=ki;var cs="PopperContent",[sh,oh]=wi(cs),Ei=i.forwardRef((e,t)=>{var I,X,de,q,J,K;const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:d=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:x,...p}=e,v=ji(cs,n),[b,y]=i.useState(null),w=le(t,F=>y(F)),[j,k]=i.useState(null),C=yi(j),S=(C==null?void 0:C.width)??0,T=(C==null?void 0:C.height)??0,R=s+(a!=="center"?"-"+a:""),A=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},O=Array.isArray(f)?f:[f],$=O.length>0,V={padding:A,boundary:O.filter(ih),altBoundary:$},{refs:W,floatingStyles:z,placement:P,isPositioned:_,middlewareData:L}=Kp({strategy:"fixed",placement:R,whileElementsMounted:(...F)=>Ip(...F,{animationFrame:g==="always"}),elements:{reference:v.anchor},middleware:[Gp({mainAxis:o+T,alignmentAxis:l}),u&&Yp({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?Xp():void 0,...V}),u&&Jp({...V}),Zp({...V,apply:({elements:F,rects:re,availableWidth:ue,availableHeight:we})=>{const{width:be,height:Be}=re.reference,ie=F.floating.style;ie.setProperty("--radix-popper-available-width",`${ue}px`),ie.setProperty("--radix-popper-available-height",`${we}px`),ie.setProperty("--radix-popper-anchor-width",`${be}px`),ie.setProperty("--radix-popper-anchor-height",`${Be}px`)}}),j&&eh({element:j,padding:c}),lh({arrowWidth:S,arrowHeight:T}),h&&Qp({strategy:"referenceHidden",...V})]}),[E,te]=Ri(P),ce=Qe(x);ve(()=>{_&&(ce==null||ce())},[_,ce]);const ae=(I=L.arrow)==null?void 0:I.x,me=(X=L.arrow)==null?void 0:X.y,M=((de=L.arrow)==null?void 0:de.centerOffset)!==0,[Q,ne]=i.useState();return ve(()=>{b&&ne(window.getComputedStyle(b).zIndex)},[b]),r.jsx("div",{ref:W.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:_?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[(q=L.transformOrigin)==null?void 0:q.x,(J=L.transformOrigin)==null?void 0:J.y].join(" "),...((K=L.hide)==null?void 0:K.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(sh,{scope:n,placedSide:E,onArrowChange:k,arrowX:ae,arrowY:me,shouldHideArrow:M,children:r.jsx(Z.div,{"data-side":E,"data-align":te,...p,ref:w,style:{...p.style,animation:_?void 0:"none"}})})})});Ei.displayName=cs;var Ti="PopperArrow",ah={top:"bottom",right:"left",bottom:"top",left:"right"},Ai=i.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=oh(Ti,s),l=ah[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(nh,{...o,ref:n,style:{...o.style,display:"block"}})})});Ai.displayName=Ti;function ih(e){return e!==null}var lh=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,u=l?0:e.arrowHeight,[f,d]=Ri(n),m={start:"0%",center:"50%",end:"100%"}[d],h=(((b=o.arrow)==null?void 0:b.x)??0)+c/2,g=(((y=o.arrow)==null?void 0:y.y)??0)+u/2;let x="",p="";return f==="bottom"?(x=l?m:`${h}px`,p=`${-u}px`):f==="top"?(x=l?m:`${h}px`,p=`${s.floating.height+u}px`):f==="right"?(x=`${-u}px`,p=l?m:`${g}px`):f==="left"&&(x=`${s.floating.width+u}px`,p=l?m:`${g}px`),{data:{x,y:p}}}});function Ri(e){const[t,n="center"]=e.split("-");return[t,n]}var ch=Si,dh=Ci,uh=Ei,fh=Ai;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"}),mh="VisuallyHidden",ph=i.forwardRef((e,t)=>r.jsx(Z.span,{...e,ref:t,style:{...Pi,...e.style}}));ph.displayName=mh;var hh=[" ","Enter","ArrowUp","ArrowDown"],xh=[" ","Enter"],dt="Select",[Fn,Bn,gh]=wa(dt),[Dt]=nt(dt,[gh,Ni]),Un=Ni(),[vh,rt]=Dt(dt),[bh,yh]=Dt(dt),Di=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:a,value:l,defaultValue:c,onValueChange:u,dir:f,name:d,autoComplete:m,disabled:h,required:g,form:x}=e,p=Un(t),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,k]=i.useState(!1),C=Qr(f),[S,T]=jt({prop:s,defaultProp:o??!1,onChange:a,caller:dt}),[R,A]=jt({prop:l,defaultProp:c,onChange:u,caller:dt}),O=i.useRef(null),$=v?x||!!v.closest("form"):!0,[V,W]=i.useState(new Set),z=Array.from(V).map(P=>P.props.value).join(";");return r.jsx(ch,{...p,children:r.jsxs(vh,{required:g,scope:t,trigger:v,onTriggerChange:b,valueNode:y,onValueNodeChange:w,valueNodeHasChildren:j,onValueNodeHasChildrenChange:k,contentId:Je(),value:R,onValueChange:A,open:S,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:h,children:[r.jsx(Fn.Provider,{scope:t,children:r.jsx(bh,{scope:e.__scopeSelect,onNativeOptionAdd:i.useCallback(P=>{W(_=>new Set(_).add(P))},[]),onNativeOptionRemove:i.useCallback(P=>{W(_=>{const L=new Set(_);return L.delete(P),L})},[]),children:n})}),$?r.jsxs(rl,{"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:m,value:R,onChange:P=>A(P.target.value),disabled:h,form:x,children:[R===void 0?r.jsx("option",{value:""}):null,Array.from(V)]},z):null]})})};Di.displayName=dt;var Mi="SelectTrigger",Oi=i.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=Un(n),l=rt(Mi,n),c=l.disabled||s,u=le(t,l.onTriggerChange),f=Bn(n),d=i.useRef("touch"),[m,h,g]=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)}),x=p=>{c||(l.onOpenChange(!0),g()),p&&(l.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return r.jsx(dh,{asChild:!0,...a,children:r.jsx(Z.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:u,onClick:Y(o.onClick,p=>{p.currentTarget.focus(),d.current!=="mouse"&&x(p)}),onPointerDown:Y(o.onPointerDown,p=>{d.current=p.pointerType;const v=p.target;v.hasPointerCapture(p.pointerId)&&v.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(x(p),p.preventDefault())}),onKeyDown:Y(o.onKeyDown,p=>{const v=m.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&h(p.key),!(v&&p.key===" ")&&hh.includes(p.key)&&(x(),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,u=rt(Ii,n),{onValueNodeHasChildrenChange:f}=u,d=a!==void 0,m=le(t,u.onValueNodeChange);return ve(()=>{f(d)},[f,d]),r.jsx(Z.span,{...c,ref:m,style:{pointerEvents:"none"},children:sl(u.value)?r.jsx(r.Fragment,{children:l}):a})});Li.displayName=Ii;var wh="SelectIcon",$i=i.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(Z.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});$i.displayName=wh;var Nh="SelectPortal",Fi=e=>r.jsx(Wr,{asChild:!0,...e});Fi.displayName=Nh;var ut="SelectContent",Bi=i.forwardRef((e,t)=>{const n=rt(ut,e.__scopeSelect),[s,o]=i.useState();if(ve(()=>{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(Vi,{...e,ref:t})});Bi.displayName=ut;var Re=10,[Ui,st]=Dt(ut),jh="SelectContentImpl",Sh=Bt("SelectContent.RemoveScroll"),Vi=i.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:l,side:c,sideOffset:u,align:f,alignOffset:d,arrowPadding:m,collisionBoundary:h,collisionPadding:g,sticky:x,hideWhenDetached:p,avoidCollisions:v,...b}=e,y=rt(ut,n),[w,j]=i.useState(null),[k,C]=i.useState(null),S=le(t,I=>j(I)),[T,R]=i.useState(null),[A,O]=i.useState(null),$=Bn(n),[V,W]=i.useState(!1),z=i.useRef(!1);i.useEffect(()=>{if(w)return Ho(w)},[w]),Io();const P=i.useCallback(I=>{const[X,...de]=$().map(K=>K.ref.current),[q]=de.slice(-1),J=document.activeElement;for(const K of I)if(K===J||(K==null||K.scrollIntoView({block:"nearest"}),K===X&&k&&(k.scrollTop=0),K===q&&k&&(k.scrollTop=k.scrollHeight),K==null||K.focus(),document.activeElement!==J))return},[$,k]),_=i.useCallback(()=>P([T,w]),[P,T,w]);i.useEffect(()=>{V&&_()},[V,_]);const{onOpenChange:L,triggerPointerDownPosRef:E}=y;i.useEffect(()=>{if(w){let I={x:0,y:0};const X=q=>{var J,K;I={x:Math.abs(Math.round(q.pageX)-(((J=E.current)==null?void 0:J.x)??0)),y:Math.abs(Math.round(q.pageY)-(((K=E.current)==null?void 0:K.y)??0))}},de=q=>{I.x<=10&&I.y<=10?q.preventDefault():w.contains(q.target)||L(!1),document.removeEventListener("pointermove",X),E.current=null};return E.current!==null&&(document.addEventListener("pointermove",X),document.addEventListener("pointerup",de,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",X),document.removeEventListener("pointerup",de,{capture:!0})}}},[w,L,E]),i.useEffect(()=>{const I=()=>L(!1);return window.addEventListener("blur",I),window.addEventListener("resize",I),()=>{window.removeEventListener("blur",I),window.removeEventListener("resize",I)}},[L]);const[te,ce]=ol(I=>{const X=$().filter(J=>!J.disabled),de=X.find(J=>J.ref.current===document.activeElement),q=al(X,I,de);q&&setTimeout(()=>q.ref.current.focus())}),ae=i.useCallback((I,X,de)=>{const q=!z.current&&!de;(y.value!==void 0&&y.value===X||q)&&(R(I),q&&(z.current=!0))},[y.value]),me=i.useCallback(()=>w==null?void 0:w.focus(),[w]),M=i.useCallback((I,X,de)=>{const q=!z.current&&!de;(y.value!==void 0&&y.value===X||q)&&O(I)},[y.value]),Q=s==="popper"?kr:Wi,ne=Q===kr?{side:c,sideOffset:u,align:f,alignOffset:d,arrowPadding:m,collisionBoundary:h,collisionPadding:g,sticky:x,hideWhenDetached:p,avoidCollisions:v}:{};return r.jsx(Ui,{scope:n,content:w,viewport:k,onViewportChange:C,itemRefCallback:ae,selectedItem:T,onItemLeave:me,itemTextRefCallback:M,focusSelectedItem:_,selectedItemText:A,position:s,isPositioned:V,searchRef:te,children:r.jsx(zr,{as:Sh,allowPinchZoom:!0,children:r.jsx(Vr,{asChild:!0,trapped:y.open,onMountAutoFocus:I=>{I.preventDefault()},onUnmountAutoFocus:Y(o,I=>{var X;(X=y.trigger)==null||X.focus({preventScroll:!0}),I.preventDefault()}),children:r.jsx(Ur,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:I=>I.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:r.jsx(Q,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:I=>I.preventDefault(),...b,...ne,onPlaced:()=>W(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Y(b.onKeyDown,I=>{const X=I.ctrlKey||I.altKey||I.metaKey;if(I.key==="Tab"&&I.preventDefault(),!X&&I.key.length===1&&ce(I.key),["ArrowUp","ArrowDown","Home","End"].includes(I.key)){let q=$().filter(J=>!J.disabled).map(J=>J.ref.current);if(["ArrowUp","End"].includes(I.key)&&(q=q.slice().reverse()),["ArrowUp","ArrowDown"].includes(I.key)){const J=I.target,K=q.indexOf(J);q=q.slice(K+1)}setTimeout(()=>P(q)),I.preventDefault()}})})})})})})});Vi.displayName=jh;var kh="SelectItemAlignedPosition",Wi=i.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=rt(ut,n),l=st(ut,n),[c,u]=i.useState(null),[f,d]=i.useState(null),m=le(t,S=>d(S)),h=Bn(n),g=i.useRef(!1),x=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 S=a.trigger.getBoundingClientRect(),T=f.getBoundingClientRect(),R=a.valueNode.getBoundingClientRect(),A=b.getBoundingClientRect();if(a.dir!=="rtl"){const J=A.left-T.left,K=R.left-J,F=S.left-K,re=S.width+F,ue=Math.max(re,T.width),we=window.innerWidth-Re,be=qs(K,[Re,Math.max(Re,we-ue)]);c.style.minWidth=re+"px",c.style.left=be+"px"}else{const J=T.right-A.right,K=window.innerWidth-R.right-J,F=window.innerWidth-S.right-K,re=S.width+F,ue=Math.max(re,T.width),we=window.innerWidth-Re,be=qs(K,[Re,Math.max(Re,we-ue)]);c.style.minWidth=re+"px",c.style.right=be+"px"}const O=h(),$=window.innerHeight-Re*2,V=p.scrollHeight,W=window.getComputedStyle(f),z=parseInt(W.borderTopWidth,10),P=parseInt(W.paddingTop,10),_=parseInt(W.borderBottomWidth,10),L=parseInt(W.paddingBottom,10),E=z+P+V+L+_,te=Math.min(v.offsetHeight*5,E),ce=window.getComputedStyle(p),ae=parseInt(ce.paddingTop,10),me=parseInt(ce.paddingBottom,10),M=S.top+S.height/2-Re,Q=$-M,ne=v.offsetHeight/2,I=v.offsetTop+ne,X=z+P+I,de=E-X;if(X<=M){const J=O.length>0&&v===O[O.length-1].ref.current;c.style.bottom="0px";const K=f.clientHeight-p.offsetTop-p.offsetHeight,F=Math.max(Q,ne+(J?me:0)+K+_),re=X+F;c.style.height=re+"px"}else{const J=O.length>0&&v===O[0].ref.current;c.style.top="0px";const F=Math.max(M,z+p.offsetTop+(J?ae:0)+ne)+de;c.style.height=F+"px",p.scrollTop=X-M+p.offsetTop}c.style.margin=`${Re}px 0`,c.style.minHeight=te+"px",c.style.maxHeight=$+"px",s==null||s(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,c,f,p,v,b,a.dir,s]);ve(()=>w(),[w]);const[j,k]=i.useState();ve(()=>{f&&k(window.getComputedStyle(f).zIndex)},[f]);const C=i.useCallback(S=>{S&&x.current===!0&&(w(),y==null||y(),x.current=!1)},[w,y]);return r.jsx(Eh,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:C,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:j},children:r.jsx(Z.div,{...o,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Wi.displayName=kh;var Ch="SelectPopperPosition",kr=i.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Re,...a}=e,l=Un(n);return r.jsx(uh,{...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=Ch;var[Eh,ds]=Dt(ut,{}),Cr="SelectViewport",zi=i.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=st(Cr,n),l=ds(Cr,n),c=le(t,a.onViewportChange),u=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(Z.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Y(o.onScroll,f=>{const d=f.currentTarget,{contentWrapper:m,shouldExpandOnScrollRef:h}=l;if(h!=null&&h.current&&m){const g=Math.abs(u.current-d.scrollTop);if(g>0){const x=window.innerHeight-Re*2,p=parseFloat(m.style.minHeight),v=parseFloat(m.style.height),b=Math.max(p,v);if(b<x){const y=b+g,w=Math.min(x,y),j=y-w;m.style.height=w+"px",m.style.bottom==="0px"&&(d.scrollTop=j>0?j:0,m.style.justifyContent="flex-end")}}}u.current=d.scrollTop})})})]})});zi.displayName=Cr;var Hi="SelectGroup",[Th,Ah]=Dt(Hi),Rh=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Je();return r.jsx(Th,{scope:n,id:o,children:r.jsx(Z.div,{role:"group","aria-labelledby":o,...s,ref:t})})});Rh.displayName=Hi;var Ki="SelectLabel",qi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Ah(Ki,n);return r.jsx(Z.div,{id:o.id,...s,ref:t})});qi.displayName=Ki;var kn="SelectItem",[_h,Gi]=Dt(kn),Yi=i.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...l}=e,c=rt(kn,n),u=st(kn,n),f=c.value===s,[d,m]=i.useState(a??""),[h,g]=i.useState(!1),x=le(t,y=>{var w;return(w=u.itemRefCallback)==null?void 0:w.call(u,y,s,o)}),p=Je(),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(_h,{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:d,children:r.jsx(Z.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:x,onFocus:Y(l.onFocus,()=>g(!0)),onBlur:Y(l.onBlur,()=>g(!1)),onClick:Y(l.onClick,()=>{v.current!=="mouse"&&b()}),onPointerUp:Y(l.onPointerUp,()=>{v.current==="mouse"&&b()}),onPointerDown:Y(l.onPointerDown,y=>{v.current=y.pointerType}),onPointerMove:Y(l.onPointerMove,y=>{var w;v.current=y.pointerType,o?(w=u.onItemLeave)==null||w.call(u):v.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Y(l.onPointerLeave,y=>{var w;y.currentTarget===document.activeElement&&((w=u.onItemLeave)==null||w.call(u))}),onKeyDown:Y(l.onKeyDown,y=>{var j;((j=u.searchRef)==null?void 0:j.current)!==""&&y.key===" "||(xh.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});Yi.displayName=kn;var Ot="SelectItemText",Xi=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,l=rt(Ot,n),c=st(Ot,n),u=Gi(Ot,n),f=yh(Ot,n),[d,m]=i.useState(null),h=le(t,b=>m(b),u.onItemTextChange,b=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,b,u.value,u.disabled)}),g=d==null?void 0:d.textContent,x=i.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:p,onNativeOptionRemove:v}=f;return ve(()=>(p(x),()=>v(x)),[p,v,x]),r.jsxs(r.Fragment,{children:[r.jsx(Z.span,{id:u.textId,...a,ref:h}),u.isSelected&&l.valueNode&&!l.valueNodeHasChildren?En.createPortal(a.children,l.valueNode):null]})});Xi.displayName=Ot;var Ji="SelectItemIndicator",Zi=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return Gi(Ji,n).isSelected?r.jsx(Z.span,{"aria-hidden":!0,...s,ref:t}):null});Zi.displayName=Ji;var Er="SelectScrollUpButton",Qi=i.forwardRef((e,t)=>{const n=st(Er,e.__scopeSelect),s=ds(Er,e.__scopeSelect),[o,a]=i.useState(!1),l=le(t,s.onScrollButtonChange);return ve(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=u.scrollTop>0;a(f)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(tl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});Qi.displayName=Er;var Tr="SelectScrollDownButton",el=i.forwardRef((e,t)=>{const n=st(Tr,e.__scopeSelect),s=ds(Tr,e.__scopeSelect),[o,a]=i.useState(!1),l=le(t,s.onScrollButtonChange);return ve(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=u.scrollHeight-u.clientHeight,d=Math.ceil(u.scrollTop)<f;a(d)};const u=n.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(tl,{...e,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});el.displayName=Tr;var tl=i.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=st("SelectScrollButton",n),l=i.useRef(null),c=Bn(n),u=i.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return i.useEffect(()=>()=>u(),[u]),ve(()=>{var d;const f=c().find(m=>m.ref.current===document.activeElement);(d=f==null?void 0:f.ref.current)==null||d.scrollIntoView({block:"nearest"})},[c]),r.jsx(Z.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:Y(o.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:Y(o.onPointerMove,()=>{var f;(f=a.onItemLeave)==null||f.call(a),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:Y(o.onPointerLeave,()=>{u()})})}),Ph="SelectSeparator",nl=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(Z.div,{"aria-hidden":!0,...s,ref:t})});nl.displayName=Ph;var Ar="SelectArrow",Dh=i.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Un(n),a=rt(Ar,n),l=st(Ar,n);return a.open&&l.position==="popper"?r.jsx(fh,{...o,...s,ref:t}):null});Dh.displayName=Ar;var Mh="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 u=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(u,"value").set;if(l!==t&&d){const m=new Event("change",{bubbles:!0});d.call(c,t),c.dispatchEvent(m)}},[l,t]),r.jsx(Z.select,{...n,style:{...Pi,...n.style},ref:a,defaultValue:t})});rl.displayName=Mh;function sl(e){return e===""||e===void 0}function ol(e){const t=Qe(e),n=i.useRef(""),s=i.useRef(0),o=i.useCallback(l=>{const c=n.current+l;t(c),(function u(f){n.current=f,window.clearTimeout(s.current),f!==""&&(s.current=window.setTimeout(()=>u(""),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=Oh(e,Math.max(a,0));o.length===1&&(l=l.filter(f=>f!==n));const u=l.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function Oh(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Ih=Di,il=Oi,Lh=Li,$h=$i,Fh=Fi,ll=Bi,Bh=zi,cl=qi,dl=Yi,Uh=Xi,Vh=Zi,ul=Qi,fl=el,ml=nl;const Te=Ih,_e=Lh,Ne=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($h,{asChild:!0,children:r.jsx(Et,{className:"h-4 w-4 opacity-50"})})]}));Ne.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(Et,{className:"h-4 w-4"})}));hl.displayName=fl.displayName;const je=i.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(Fh,{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(Bh,{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,{})]})}));je.displayName=ll.displayName;const Wh=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}));Wh.displayName=cl.displayName;const ge=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(ze,{className:"h-4 w-4"})})}),r.jsx(Uh,{children:t})]}));ge.displayName=dl.displayName;const zh=i.forwardRef(({className:e,...t},n)=>r.jsx(ml,{ref:n,className:U("-mx-1 my-1 h-px bg-muted",e),...t}));zh.displayName=ml.displayName;const Rr="bypass",xl=[{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"}],Hh=[{value:"bypass",label:"Bypass"},{value:"plan",label:"Plan"},{value:"edit",label:"Edit"},{value:"dangerous",label:"Dangerous"}],Kh=new Set(xl.filter(e=>e.supportsFollowUp).map(e=>e.value)),qh=20,Gh=3,oo="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 _r(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 _r(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=_r(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 ao({value:e,onChange:t,assignTo:n,nodes:s,assignableNodes:o,layout:a="default",chipClassName:l,chipActiveClassName:c,chipInactiveClassName:u}){const[f,d]=i.useState(!1),[m,h]=i.useState(null),[g,x]=i.useState(!1),[p,v]=i.useState(!1),[b,y]=i.useState(null),[w,j]=i.useState(""),[k,C]=i.useState(!1),[S,T]=i.useState({}),R=i.useRef(null),A=i.useMemo(()=>ex(n,s,o),[n,s,o]),O=A==null?void 0:A.id,$=i.useMemo(()=>O?S[O]??[]:[],[S,O]),V=i.useMemo(()=>e.trim()?tx(A==null?void 0:A.workDir,e):"Use node default",[e,A==null?void 0:A.workDir]);i.useEffect(()=>{if(!(typeof window>"u"))try{const M=window.localStorage.getItem(oo);if(!M)return;const Q=JSON.parse(M);T(Zh(Q))}catch{}},[]);const W=i.useCallback(M=>{O&&T(Q=>{const ne=Qh(Q,O,M);if(ne===Q)return Q;if(typeof window<"u")try{window.localStorage.setItem(oo,JSON.stringify(ne))}catch{}return ne})},[O]),z=i.useCallback((M,Q=!0)=>{const ne=M.trim();t(ne),Q&&ne&&W(ne),d(!1)},[t,W]),P=i.useCallback(async(M,Q=0,ne=!1)=>{if(O){y(null),ne?v(!0):x(!0);try{const I=await uc(O,{path:M,limit:qh,offset:Q,directoriesOnly:!0,allowAbsolute:!0});h(X=>ne&&X?{...I,entries:[...X.entries,...I.entries]}:I)}catch(I){y(I instanceof Error?I.message:"Failed to browse directories"),ne||h(null)}finally{x(!1),v(!1)}}},[O]),_=i.useRef(e);_.current=e;const L=i.useRef(P);L.current=P,i.useEffect(()=>{if(!f)return;const M=_.current;j(M),C(!1),h(null),y(null),O&&L.current(Xh(M))},[f,O]),i.useEffect(()=>{if(!f)return;const M=ne=>{R.current&&(R.current.contains(ne.target)||d(!1))},Q=ne=>{ne.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",M),document.addEventListener("keydown",Q),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",Q)}},[f]);const E=i.useCallback(M=>{P(M)},[P]),te=i.useCallback(()=>{m&&P(m.currentPath,m.entries.length,!0)},[m,P]),ce=a==="composer"?r.jsxs(H,{type:"button",variant:"ghost",onClick:()=>d(M=>!M),title:V,className:U(l,"min-w-0 max-w-full",e.trim()?c:u),children:[r.jsx(td,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"min-w-0 truncate",children:V})]}):r.jsxs(H,{type:"button",variant:"outline",onClick:()=>d(M=>!M),className:"h-11 w-full justify-between rounded-2xl border-border/70 bg-background/70 px-4",title:V,children:[r.jsx("span",{className:U("truncate",e.trim()?"font-mono text-foreground":"text-muted-foreground"),children:V}),r.jsx("span",{className:"ml-3 shrink-0 text-xs text-muted-foreground",children:A?A.name:"Manual"})]}),ae=nx(m,A),me=!!(m!=null&&m.parentPath);return r.jsxs("div",{className:U("relative inline-block",a==="composer"?"min-w-0 flex-1":"w-full"),ref:R,children:[a==="default"?r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Working directory"}),ce]}):ce,f&&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:[$.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(cd,{className:"h-3 w-3"}),"Recent"]}),r.jsx("div",{className:"flex flex-col gap-1",children:$.map(M=>r.jsx("button",{type:"button",onClick:()=>z(M,!1),className:"truncate rounded-md px-2 py-1 text-left font-mono text-xs text-foreground hover:bg-background/60",title:M,children:M},M))})]}),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:()=>(m==null?void 0:m.parentPath)&&E(m.parentPath),disabled:!me||g,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(Ic,{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:ae,children:ae}),m&&r.jsx("button",{type:"button",onClick:()=>z(m.isAbsolute?m.currentPath:m.currentPath==="."?"":m.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:[A?g?r.jsxs("div",{className:"flex items-center justify-center px-3 py-6 text-xs text-muted-foreground",children:[r.jsx(ye,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Loading..."]}):m&&m.entries.length>0?r.jsxs(r.Fragment,{children:[m.entries.map(M=>r.jsxs("div",{className:"group flex items-stretch border-b border-border/40 last:border-b-0",children:[r.jsxs("button",{type:"button",onClick:()=>z(M.path),className:"flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left hover:bg-background/55",title:`Use ${M.path}`,children:[r.jsx(rd,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate text-sm text-foreground",children:M.name})]}),r.jsx("button",{type:"button",onClick:()=>E(M.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 ${M.name}`,children:r.jsx(Or,{className:"h-4 w-4"})})]},M.path)),m.hasMore&&r.jsx("div",{className:"border-t border-border/60 p-2",children:r.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:te,disabled:p,className:"h-8 w-full rounded-md text-xs",children:[p?r.jsx(ye,{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:b??"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."}),b&&m&&m.entries.length>0&&r.jsx("div",{className:"border-t border-border/60 px-3 py-2 text-xs text-destructive",children:b})]}),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:w,onChange:M=>j(M.target.value),onKeyDown:M=>{M.key==="Enter"&&w.trim()?(M.preventDefault(),z(w)):M.key==="Escape"&&(M.preventDefault(),C(!1),j(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:()=>z(w),disabled:!w.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(ze,{className:"h-4 w-4"})}),r.jsx("button",{type:"button",onClick:()=>{C(!1),j(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(zt,{className:"h-4 w-4"})})]}):r.jsxs("button",{type:"button",onClick:()=>{j(e),C(!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 io(){return xl.map(e=>r.jsx(ge,{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 lo(){return Hh.map(e=>r.jsx(ge,{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 sx({isCurrent:e}){return e?r.jsx(fd,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):r.jsx(id,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function co(e,t){return e.map(n=>{const s=!!t&&n.id===t;return r.jsx(ge,{value:n.id,children:r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(sx,{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 gl(e,t,n=!1){const s=e.trim();if(s)return s;const o=t.trim().split(`
251
- `).map(a=>a.trim()).find(Boolean);return o?o.length>72?`${o.slice(0,69).trimEnd()}...`:o:n?"Image task":""}function ox(e){const t=gl(e.title,e.description,e.images.length>0),n=e.description.trim()||t,s=e.mode??Rr,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 ax({nodes:e,currentNodeRole:t,currentNodeId:n,leaderNodeId:s,onCreated:o,onCancel:a,className:l,footerClassName:c,submitLabel:u="Create chat",cancelLabel:f="Cancel",autoFocus:d=!1,layout:m="default"}){const[h,g]=i.useState(""),[x,p]=i.useState(""),[v,b]=i.useState("claudecode"),[y,w]=i.useState(Rr),[j,k]=i.useState(""),[C,S]=i.useState("normal"),T=i.useMemo(()=>rx(e,{currentNodeRole:t,leaderNodeId:s}),[e,t,s]),R=i.useMemo(()=>{var F;return n&&T.some(re=>re.id===n)?n:((F=T[0])==null?void 0:F.id)??""},[T,n]),[A,O]=i.useState(R),[$,V]=i.useState(!1),[W,z]=i.useState(!1),{images:P,error:_,fileInputRef:L,pickImages:E,handleFileChange:te,handlePaste:ce,removeImage:ae}=va();i.useEffect(()=>{A&&T.some(F=>F.id===A)||O(R)},[A,T,R]),i.useEffect(()=>{k("")},[A]);const me=i.useCallback(async F=>{F.preventDefault();const re=ox({title:h,description:x,agent:v,project:j,priority:C,assignTo:A,mode:y,images:P});if(re){V(!0);try{const ue=await fc(re);o(ue)}catch(ue){he.error(ue instanceof Error?ue.message:"Failed to create task")}finally{V(!1)}}},[h,x,v,j,C,A,y,P,o]),M=gl(h,x,P.length>0),Q=!!(M&&v&&A&&(x.trim()||P.length>0)),ne=i.useCallback(F=>{var re;F.nativeEvent.isComposing||F.key==="Enter"&&(F.ctrlKey||F.metaKey)&&Q&&!$&&(F.preventDefault(),(re=F.currentTarget.form)==null||re.requestSubmit())},[Q,$]),I=P.length>0&&r.jsx("div",{className:"flex flex-wrap gap-3",children:P.map((F,re)=>r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:Fr(F),alt:F.filename??`attachment ${re+1}`,className:"h-24 w-24 rounded-2xl border border-border/70 object-cover"}),r.jsx("button",{type:"button",onClick:()=>ae(re),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 ${F.filename??`image ${re+1}`}`,children:r.jsx(zt,{className:"h-3.5 w-3.5"})})]},`${F.filename??"image"}-${re}`))}),X=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Assign to"}),r.jsxs(Te,{value:A,onValueChange:O,children:[r.jsx(Ne,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(_e,{placeholder:"Select node"})}),r.jsx(je,{children:co(T,n)})]})]}),de=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Agent"}),r.jsxs(Te,{value:v,onValueChange:b,children:[r.jsx(Ne,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(_e,{placeholder:"Select agent"})}),r.jsx(je,{children:io()})]})]}),q=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Mode"}),r.jsxs(Te,{value:y,onValueChange:F=>w(F),children:[r.jsx(Ne,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(_e,{placeholder:"Select mode"})}),r.jsx(je,{children:lo()})]})]}),J=r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ue,{className:"text-sm font-medium",children:"Priority"}),r.jsxs(Te,{value:C,onValueChange:S,children:[r.jsx(Ne,{className:"h-11 rounded-2xl border-border/70 bg-background/70",children:r.jsx(_e,{placeholder:"Select priority"})}),r.jsxs(je,{children:[r.jsx(ge,{value:"low",children:"Low"}),r.jsx(ge,{value:"normal",children:"Normal"}),r.jsx(ge,{value:"high",children:"High"}),r.jsx(ge,{value:"critical",children:"Critical"})]})]})]}),K=r.jsx(ao,{value:j,onChange:k,assignTo:A,nodes:e,assignableNodes:T});return m==="composer"?r.jsxs("form",{onSubmit:me,className:U("space-y-4",l),children:[r.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,onChange:te,className:"hidden"}),(()=>{var Be;const F="h-9 w-auto gap-1.5 rounded-full px-3.5 text-xs shadow-none transition-colors",re="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",ue="border-border/70 bg-background/55 text-foreground",we=v==="claudecode",be=y===Rr;return r.jsxs("div",{className:"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:"flex items-center justify-between gap-3 px-4 pt-3",children:[r.jsxs(Te,{value:A,onValueChange:O,children:[r.jsx(Ne,{className:U(F,ue,"border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${((Be=T.find(ie=>ie.id===A))==null?void 0:Be.name)??"unassigned"}`,children:r.jsx(_e,{placeholder:"Select node"})}),r.jsx(je,{children:co(T,n)})]}),W?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(St,{id:"task-title-composer",type:"text",value:h,onChange:ie=>g(ie.target.value),onKeyDown:ie=>{(ie.key==="Enter"||ie.key==="Escape")&&(ie.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(H,{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(ze,{className:"h-3.5 w-3.5"})})]}):r.jsxs("button",{type:"button",onClick:()=>z(!0),className:"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:M||"Title",children:[r.jsx("span",{className:"max-w-[220px] truncate",children:M||"Title"}),r.jsx(Lr,{className:"h-3 w-3 shrink-0"})]})]}),r.jsx("textarea",{id:"task-description",value:x,onChange:ie=>p(ie.target.value),onKeyDown:ne,onPaste:ce,placeholder:"Ask anything...",rows:4,autoFocus:d,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none rounded-[24px] bg-transparent px-5 pt-2 pb-16 text-[15px] leading-7 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),r.jsxs("div",{className:"absolute bottom-3 left-3 right-3 flex flex-nowrap items-center gap-2",children:[r.jsx(H,{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(mr,{className:"h-4 w-4"})}),r.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),r.jsx(ao,{value:j,onChange:k,assignTo:A,nodes:e,assignableNodes:T,layout:"composer",chipClassName:F,chipActiveClassName:ue,chipInactiveClassName:re}),r.jsxs(Te,{value:v,onValueChange:b,children:[r.jsx(Ne,{className:U(F,we?re:ue),children:r.jsx(_e,{placeholder:"Agent"})}),r.jsx(je,{children:io()})]}),r.jsxs(Te,{value:y,onValueChange:ie=>w(ie),children:[r.jsx(Ne,{className:U(F,be?re:ue),children:r.jsx(_e,{placeholder:"Mode"})}),r.jsx(je,{children:lo()})]}),r.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[r.jsxs(Te,{value:C,onValueChange:S,children:[r.jsx(Ne,{"aria-label":`Priority: ${C}`,title:`Priority: ${C}`,className:U("h-9 w-9 justify-center gap-0 rounded-full p-0 text-xs shadow-none [&>svg:last-child]:hidden",C==="normal"?"border-transparent bg-transparent text-muted-foreground hover:bg-background/40":"border-border/70 bg-background/55",C==="critical"&&"text-destructive",C==="high"&&"text-amber-600 dark:text-amber-400",C==="low"&&"text-muted-foreground"),children:r.jsx(Qc,{className:U("h-4 w-4",C==="critical"&&"fill-destructive/20")})}),r.jsxs(je,{children:[r.jsx(ge,{value:"low",children:"Low"}),r.jsx(ge,{value:"normal",children:"Normal"}),r.jsx(ge,{value:"high",children:"High"}),r.jsx(ge,{value:"critical",children:"Critical"})]})]}),a&&r.jsx(H,{type:"button",variant:"ghost",size:"sm",onClick:a,className:"h-9 rounded-full px-4 text-xs text-muted-foreground",children:f}),r.jsxs(H,{type:"submit",size:"icon",disabled:!Q||$,className:"h-10 w-10 rounded-full shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[$?r.jsx(ye,{className:"h-4 w-4 animate-spin"}):r.jsx(Co,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:$?"Creating chat":u})]})]})]})]})})(),(I||_)&&r.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/45 p-4",children:[I,_&&r.jsx("div",{className:"text-xs text-destructive",children:_}),!_&&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:me,className:U("space-y-5",l),children:[r.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,onChange:te,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:x,onChange:F=>p(F.target.value),onKeyDown:ne,onPaste:ce,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:d,className:"flex min-h-[144px] w-full resize-none rounded-[22px] border border-border/70 bg-background/70 px-4 py-3 text-sm leading-6 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs(H,{type:"button",variant:"outline",onClick:E,className:"rounded-2xl",children:[r.jsx(mr,{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."})]}),I,_&&r.jsx("p",{className:"text-xs text-destructive",children:_})]}),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:F=>g(F.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:M?`Will appear as: ${M}`:"A title will be generated from the first line of the prompt."})]}),de,q]}),K,r.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[J,X]}),r.jsxs("div",{className:U("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[a&&r.jsx(H,{type:"button",variant:"ghost",onClick:a,className:"rounded-2xl",children:f}),r.jsx(H,{type:"submit",disabled:!Q||$,className:"rounded-2xl px-5",children:$?"Creating...":u})]})]})}const ix=[{value:"active",label:"Active"},{value:"running",label:"Running"},{value:"waiting",label:"Waiting"},{value:"closed",label:"Closed"},{value:"archived",label:"Archived"}],Cn=new Set(["pending","assigned"]),vl=new Set(["running"]),lx=new Set(["completed","failed","cancelled"]);function cx(e,t){switch(t){case"running":return vl.has(e.status);case"waiting":return Cn.has(e.status);case"closed":return lx.has(e.status);case"archived":return e.status==="archived";case"active":default:return e.status!=="archived"}}function dx(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 us(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 ux(e,t,n){return us(e,t,n).toLowerCase()}function fx(e,t){return[...e].sort((n,s)=>n.id===t?-1:s.id===t?1:n.name.localeCompare(s.name))}function mx(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 px(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 hx(e){return e==="default workspace"?e:e.replace(/\\/g,"/").split("/").filter(Boolean).at(-1)??e}function xx(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 gx(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 vx(e){return new Date(e).toLocaleString()}function bx(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 Ct(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),he.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"),u=a.activeElement,f=u&&typeof u.focus=="function"?u: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 d=l("copy");if(a.body.removeChild(c),f==null||f.focus(),!d)throw new Error("Clipboard access is unavailable");return he.success(t),!0}catch(a){return he.error(a instanceof Error?a.message:"Failed to copy"),!1}}function vt({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 cr({label:e}){return r.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function Pe({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 Pr({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 bl({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(ke,{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 yx=i.lazy(async()=>({default:(await Mr(()=>import("./FilesTab-Bhu_DR2i.js"),__vite__mapDeps([0,1,2,3]))).FilesTab})),wx=i.lazy(async()=>({default:(await Mr(()=>import("./PreviewTab-HFeFMit9.js"),__vite__mapDeps([4,1,2]))).PreviewTab})),Nx=i.lazy(async()=>({default:(await Mr(()=>import("./DiffTab-CPP_KlNw.js"),__vite__mapDeps([5,1,2,3]))).DiffTab}));function jx({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,activeTab:c,setActiveTab:u,creatingTask:f,activeTask:d,assignedNode:m,taskLoading:h,taskError:g,displayEvents:x,hasUserMessageInLogs:p,initialPrompt:v,supportsFollowUp:b,taskUnavailable:y,chatDisabled:w,chatDisabledReason:j,questionBypassEnabled:k,isRunning:C,hasPendingFollowUp:S,canCancel:T,canRetry:R,onRetry:A,onCancel:O,onStartCreateTask:$,onCancelCreateTask:V,onCreateTask:W,onSendMessage:z,onQuestionBypassChange:P,onSubmitQuestionResponse:_,messagesEndRef:L}){const[E,te]=i.useState(!1),[ce,ae]=i.useState(!1),[me,M]=i.useState(!1),Q=i.useRef(0),ne=i.useRef(!1),I=i.useCallback(K=>{const F=K.currentTarget,re=Q.current;if(Q.current=F.scrollTop,ne.current)return;if(F.scrollHeight-F.scrollTop-F.clientHeight<30){ae(!1),ne.current=!0,setTimeout(()=>{ne.current=!1},300);return}F.scrollTop<re&&re-F.scrollTop>10&&ae(!0),F.scrollTop<=0&&ae(!0)},[]),X=(d==null?void 0:d.effectiveProjectPath)??(d==null?void 0:d.project)??"default workspace",de=d?(m==null?void 0:m.name)??us(d.assignedTo,a==null?void 0:a.nodes,d.assignedNodeName):"unassigned",q=d?[{label:"Working dir",value:X,mono:!0},{label:"Agent",value:d.agent,mono:!0},{label:"Node",value:de}]:[],J=d!=null&&d.description&&d.description!==d.title?d.description:null;return f?r.jsx(Sx,{onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,onCancel:V,onCreated:W}):!d&&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(ye,{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(ye,{className:"h-4 w-4 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):d?r.jsxs(Ua,{value:c,onValueChange:u,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:d.title,children:d.title}),r.jsx(vo,{status:d.status}),r.jsx(mc,{priority:d.priority}),r.jsx(H,{variant:"ghost",size:"icon",className:"ml-auto h-6 w-6 shrink-0 rounded-full text-muted-foreground",onClick:()=>te(K=>!K),children:E?r.jsx(Ir,{className:"h-3.5 w-3.5"}):r.jsx(Et,{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}),g&&r.jsx("div",{className:"w-fit rounded-full border border-destructive/25 bg-destructive/10 px-3 py-1 text-xs text-destructive",children:g}),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 ",vx(d.updatedAt)]}),r.jsx("span",{className:"font-mono",children:d.id.slice(0,8)})]}),r.jsx("div",{className:"flex items-center gap-2",children:R&&r.jsxs(H,{variant:"outline",size:"sm",onClick:A,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(Ye,{value:"transcript",className:"rounded-full px-2.5 sm:px-4",children:"Transcript"}),r.jsx(Ye,{value:"files",className:"rounded-full px-2.5 sm:px-4",children:"Files"}),r.jsx(Ye,{value:"preview",className:"rounded-full px-2.5 sm:px-4",children:"Preview"}),r.jsx(Ye,{value:"diff",className:"rounded-full px-2.5 sm:px-4",children:"Diff"})]}),C&&r.jsx(ke,{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"}),S&&r.jsx(ke,{variant:"outline",className:"hidden rounded-full border-primary/30 bg-primary/10 text-primary sm:inline-flex",children:"Queued"}),y&&r.jsx(ke,{variant:"outline",className:"hidden rounded-full border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"})]})]}),r.jsx(Xe,{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:I,children:r.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5",children:[v&&!p&&r.jsx(Hs,{event:v,questionBypassEnabled:k,onQuestionBypassChange:P,onSubmitQuestionResponse:_,questionResponseDisabled:!b||w}),x.map((K,F)=>r.jsx(Hs,{event:K,questionBypassEnabled:k,onQuestionBypassChange:P,onSubmitQuestionResponse:_,questionResponseDisabled:!b||w},hu("transcript",K,F))),x.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&&d.result||d.error)&&r.jsxs("div",{className:"space-y-3",children:[!b&&d.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(d.result,null,2)})]}),d.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:d.error})]})]}),(C||S)&&x.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(ye,{className:"h-4 w-4 animate-spin"}),"The agent is still working on this conversation."]}),r.jsx("div",{ref:L})]})}),b?ce?r.jsx(H,{size:"icon",onClick:()=>ae(!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(am,{onSend:z,disabled:w,disabledReason:j,contextItems:q,placeholder:w?j:"Continue the conversation...",running:C||S,onStop:T?()=>M(!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(Xe,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(cr,{label:"Loading files..."}),children:r.jsx(yx,{taskId:d.id})})}),r.jsx(Xe,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(cr,{label:"Loading preview..."}),children:r.jsx(wx,{taskId:d.id})})}),r.jsx(Xe,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx(cr,{label:"Loading diff..."}),children:r.jsx(Nx,{taskId:d.id})})}),r.jsx(wr,{open:me,onOpenChange:M,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:O,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(wo,{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(H,{onClick:$,className:"mt-6 rounded-full px-5",children:[r.jsx(jo,{className:"h-4 w-4"}),"Start new chat"]}),g&&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:g})]})})]})}function Sx({onToggleTasks:e,desktopTasksOpen:t,mobileTasksPanelOpen:n,operationsOpen:s,onToggleOperations:o,cluster:a,sseConnected:l,onCancel:c,onCreated:u}){var f,d,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(ax,{nodes:(a==null?void 0:a.nodes)??[],currentNodeRole:(f=a==null?void 0:a.self)==null?void 0:f.role,currentNodeId:((d=a==null?void 0:a.self)==null?void 0:d.id)??null,leaderNodeId:((m=a==null?void 0:a.leader)==null?void 0:m.id)??null,onCreated:u,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(kx,{desktopTasksOpen:t,mobileTasksPanelOpen:n,onToggleTasks:e}),r.jsx(ke,{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(ke,{variant:"outline",className:"hidden rounded-full border-border/70 bg-background/60 sm:inline-flex",children:["leader ",a.leader.name]})]}),r.jsxs(H,{variant:"outline",onClick:o,className:"shrink-0 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(Nd,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide cluster":"Show cluster"})]})]})}function kx({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(H,{variant:"outline",onClick:n,className:"rounded-full border-border/70 bg-background/60 px-3 sm:px-4",children:[s?r.jsx(So,{className:"h-4 w-4"}):r.jsx(bd,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:s?"Hide tasks":"Show tasks"})]})}const Cx={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 Ex(e){return e.split(".")[0]??"unknown"}function Tx(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}function dr(e,t){return(t==null?void 0:t.get(e))??e}function Ax(e,t){const n=e.data;switch(e.type){case"node.joined":return`${n.name} joined the cluster`;case"node.left":return`${dr(n.nodeId,t)} left (${n.reason})`;case"node.status":return`${dr(n.nodeId,t)} is now ${n.status}`;case"task.created":return`"${n.title}" created`;case"task.assigned":return`task assigned to ${dr(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 Rx(e){return JSON.stringify(e,null,2)}function _x({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=Ex(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(ke,{variant:"outline",className:U("w-fit text-[10px] font-medium uppercase tracking-[0.16em]",Cx[l]),children:a.type})]}),r.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-full text-muted-foreground",onClick:()=>void Ct(Rx(a),"Event copied"),"aria-label":`Copy ${a.type} event`,title:"Copy event",children:r.jsx(Tn,{className:"h-3.5 w-3.5"})})]}),r.jsx("div",{className:"text-sm leading-6 text-foreground/85",children:Ax(a,o)})]})},a.id)})})})}function uo({cluster:e,systemInfo:t,nodeNameById:n,nodeBlockingTaskCounts:s,eventTypeFilter:o,onEventTypeFilterChange:a,eventTypeOptions:l,filteredEvents:c,sseConnected:u,clusterLoading:f,clusterError:d,electionPending:m,onTriggerElection:h,promotePending:g,onPromote:x,onAddNode:p,leavePending:v,onLeaveCluster:b,onToggleNodeDevTunnel:y,devTunnelNodeId:w,onClose:j}){var $,V,W,z,P;const k=(($=e==null?void 0:e.self)==null?void 0:$.role)==="leader",C=((V=e==null?void 0:e.self)==null?void 0:V.role)==="follower"&&!(e!=null&&e.leader),S=(e==null?void 0:e.self)??null,R=fx((e==null?void 0:e.nodes)??[],S==null?void 0:S.id).filter(_=>_.id!==(S==null?void 0:S.id)),A=(S==null?void 0:S.role)==="leader"&&R.length===0,O=(S==null?void 0:S.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(H,{variant:"ghost",size:"icon",onClick:j,className:"rounded-full",children:r.jsx(ko,{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(Ye,{value:"overview",className:"rounded-full px-3 text-xs",children:"Overview"}),r.jsx(Ye,{value:"nodes",className:"rounded-full px-3 text-xs",children:"Nodes"}),r.jsx(Ye,{value:"events",className:"rounded-full px-3 text-xs",children:"Live events"})]})]}),r.jsx(Xe,{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:[S&&r.jsx(fo,{node:S,systemInfo:t,blockingTaskCount:s.get(S.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(ke,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:u?"Connected":"Reconnecting"})]}),f&&!e?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(ye,{className:"h-4 w-4 animate-spin"}),"Loading cluster state..."]}):d&&!e?r.jsx("div",{className:"rounded-[22px] border border-destructive/20 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:d}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(vt,{label:"Term",value:String((e==null?void 0:e.term)??0)}),r.jsx(vt,{label:"Nodes",value:String((e==null?void 0:e.nodes.length)??0)}),r.jsx(vt,{label:"Pending",value:String((e==null?void 0:e.taskSummary.pending)??0)}),r.jsx(vt,{label:"Running",value:String((e==null?void 0:e.taskSummary.running)??0)}),r.jsx(vt,{label:"Completed",value:String((e==null?void 0:e.taskSummary.completed)??0)}),r.jsx(vt,{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(Pe,{label:"Leader",value:((W=e==null?void 0:e.leader)==null?void 0:W.name)??"None"}),r.jsx(Pe,{label:"Leader URL",value:((z=e==null?void 0:e.leader)==null?void 0:z.endpoint)??"Unavailable",mono:!0,action:(P=e==null?void 0:e.leader)!=null&&P.endpoint?r.jsx(Wt,{label:"Copy leader URL",onClick:()=>{var _;return void Ct(((_=e.leader)==null?void 0:_.endpoint)??"","Leader URL copied")}}):void 0}),r.jsx(Pe,{label:"Feed",value:u?"Receiving live updates":"Reconnecting to event stream"})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[k&&r.jsxs(H,{variant:"outline",size:"sm",onClick:h,disabled:m,className:"rounded-full",children:[m&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),"Trigger election"]}),C&&r.jsxs(H,{variant:"outline",size:"sm",onClick:x,disabled:g,className:"rounded-full",children:[g&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),"Promote self"]})]})]})]})]})})}),r.jsx(Xe,{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"}),A?r.jsx(H,{variant:"outline",size:"sm",onClick:p,className:"rounded-full",children:"Join node"}):O?r.jsxs(H,{variant:"outline",size:"sm",onClick:b,disabled:v,className:"rounded-full",children:[v&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),"Leave cluster"]}):null]}),S&&r.jsx(fo,{node:S,systemInfo:t,blockingTaskCount:s.get(S.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(_=>r.jsx(Px,{node:_,isLeader:!!k,blockingTaskCount:s.get(_.id)??0,devTunnelNodeId:w,onToggleNodeDevTunnel:y},_.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(Xe,{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(pc,{className:U("h-4 w-4",u?"text-emerald-500":"text-destructive")}),"Live events"]})}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(Te,{value:o,onValueChange:a,children:[r.jsx(Ne,{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(_e,{placeholder:"Event type"})}),r.jsx(je,{children:l.map(_=>r.jsx(ge,{value:_,className:"text-[12px]",children:_==="all"?"All event types":_},_))})]}),r.jsx(ke,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:u?"Connected":"Reconnecting"})]})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(_x,{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 fo({node:e,systemInfo:t,blockingTaskCount:n,devTunnelNodeId:s,onToggleNodeDevTunnel:o,showActions:a=!0,defaultExpanded:l=!1}){const[c,u]=i.useState(l),f=(t==null?void 0:t.dashboardOrigin)??e.dashboardOrigin,d=e.devtunnelEndpoint??e.endpoint,m=f??e.endpoint,h=(t==null?void 0:t.workDir)??e.workDir,g=Ao(e,t==null?void 0:t.transportType),x=$r(e,t==null?void 0:t.transportType),p=x&&Tt((t==null?void 0:t.transportType)??e.transportType)?!0:To(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:()=>u(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(Et,{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(bo,{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(yo,{role:e.role}),r.jsx(ke,{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(Pe,{label:"Node ID",value:e.id,mono:!0}),f&&r.jsx(Pe,{label:"Dashboard",value:f,mono:!0,action:r.jsx(Wt,{label:"Copy dashboard URL",onClick:()=>void Ct(f,"Dashboard URL copied")})}),r.jsx(Pe,{label:"Node URL",value:d,mono:!0,action:r.jsx(Wt,{label:"Copy node URL",onClick:()=>void Ct(d,"Node URL copied")})}),h&&r.jsx(Pe,{label:"Workspace",value:h,mono:!0})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(Pr,{label:"Transport",value:g}),t&&r.jsx(Pr,{label:"Uptime",value:bx(t.uptime),mono:!0})]}),r.jsx(bl,{capabilities:e.capabilities,action:a&&p?r.jsxs(H,{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(ye,{className:"h-3.5 w-3.5 animate-spin"}),x?"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 Px({node:e,isLeader:t,blockingTaskCount:n,devTunnelNodeId:s,onToggleNodeDevTunnel:o}){const[a,l]=i.useState(!1),c=e.dashboardOrigin,u=e.devtunnelEndpoint??e.endpoint,f=c??e.endpoint,d=Ao(e),m=$r(e),h=To(e),g=n>0;return r.jsxs("div",{className:"rounded-[24px] border border-border/60 bg-background/45",children:[r.jsxs("button",{type:"button",onClick:()=>l(x=>!x),className:"w-full px-4 py-3 text-left",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[a?r.jsx(Et,{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(bo,{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:x=>x.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(yo,{role:e.role}),r.jsx(ke,{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(Pe,{label:"Node ID",value:e.id,mono:!0}),c&&r.jsx(Pe,{label:"Dashboard",value:c,mono:!0,action:r.jsx(Wt,{label:"Copy dashboard URL",onClick:()=>void Ct(c,"Dashboard URL copied")})}),r.jsx(Pe,{label:"Node URL",value:u,mono:!0,action:r.jsx(Wt,{label:"Copy node URL",onClick:()=>void Ct(u,"Node URL copied")})}),e.workDir&&r.jsx(Pe,{label:"Workspace",value:e.workDir,mono:!0}),r.jsx(Pr,{label:"Transport",value:d})]}),r.jsx(bl,{capabilities:e.capabilities,action:t&&h?r.jsxs(H,{variant:"outline",size:"sm",onClick:()=>o(e),disabled:s===e.id||g,className:"rounded-full",title:g?"Finish assigned or running tasks before changing remote access":void 0,children:[s===e.id&&r.jsx(ye,{className:"h-3.5 w-3.5 animate-spin"}),m?"Disable Remote Access":"Enable Remote Access"]}):void 0}),t&&h&&g&&r.jsxs("div",{className:"text-xs text-muted-foreground",children:[n," active task",n===1?"":"s"," on this node."]})]})]})}function Wt({label:e,onClick:t}){return r.jsx(H,{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(Tn,{className:"h-3.5 w-3.5"})})}function Dx(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..."}:Cn.has(e.status)||e.status==="archived"?{taskUnavailable:!1,chatDisabled:!0,chatDisabledReason:Cn.has(e.status)?"Task has not started yet...":"Archived tasks are read-only."}:{taskUnavailable:!1,chatDisabled:!1,chatDisabledReason:"Continue the conversation..."}}var Vn="Checkbox",[Mx]=nt(Vn),[Ox,fs]=Mx(Vn);function Ix(e){const{__scopeCheckbox:t,checked:n,children:s,defaultChecked:o,disabled:a,form:l,name:c,onCheckedChange:u,required:f,value:d="on",internal_do_not_use_render:m}=e,[h,g]=jt({prop:n,defaultProp:o??!1,onChange:u,caller:Vn}),[x,p]=i.useState(null),[v,b]=i.useState(null),y=i.useRef(!1),w=x?!!l||!!x.closest("form"):!0,j={checked:h,disabled:a,setChecked:g,control:x,setControl:p,name:c,form:l,value:d,hasConsumerStoppedPropagationRef:y,required:f,defaultChecked:Ze(o)?!1:o,isFormControl:w,bubbleInput:v,setBubbleInput:b};return r.jsx(Ox,{scope:t,...j,children:Lx(m)?m(j):s})}var yl="CheckboxTrigger",wl=i.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...s},o)=>{const{control:a,value:l,disabled:c,checked:u,required:f,setControl:d,setChecked:m,hasConsumerStoppedPropagationRef:h,isFormControl:g,bubbleInput:x}=fs(yl,e),p=le(o,d),v=i.useRef(u);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(Z.button,{type:"button",role:"checkbox","aria-checked":Ze(u)?"mixed":u,"aria-required":f,"data-state":Cl(u),"data-disabled":c?"":void 0,disabled:c,value:l,...s,ref:p,onKeyDown:Y(t,b=>{b.key==="Enter"&&b.preventDefault()}),onClick:Y(n,b=>{m(y=>Ze(y)?!0:!y),x&&g&&(h.current=b.isPropagationStopped(),h.current||b.stopPropagation())})})});wl.displayName=yl;var ms=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:s,checked:o,defaultChecked:a,required:l,disabled:c,value:u,onCheckedChange:f,form:d,...m}=e;return r.jsx(Ix,{__scopeCheckbox:n,checked:o,defaultChecked:a,disabled:c,required:l,onCheckedChange:f,name:s,form:d,value:u,internal_do_not_use_render:({isFormControl:h})=>r.jsxs(r.Fragment,{children:[r.jsx(wl,{...m,ref:t,__scopeCheckbox:n}),h&&r.jsx(kl,{__scopeCheckbox:n})]})})});ms.displayName=Vn;var Nl="CheckboxIndicator",jl=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:s,...o}=e,a=fs(Nl,n);return r.jsx(Rt,{present:s||Ze(a.checked)||a.checked===!0,children:r.jsx(Z.span,{"data-state":Cl(a.checked),"data-disabled":a.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});jl.displayName=Nl;var Sl="CheckboxBubbleInput",kl=i.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:s,hasConsumerStoppedPropagationRef:o,checked:a,defaultChecked:l,required:c,disabled:u,name:f,value:d,form:m,bubbleInput:h,setBubbleInput:g}=fs(Sl,e),x=le(n,g),p=_i(a),v=yi(s);i.useEffect(()=>{const y=h;if(!y)return;const w=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(w,"checked").set,C=!o.current;if(p!==a&&k){const S=new Event("click",{bubbles:C});y.indeterminate=Ze(a),k.call(y,Ze(a)?!1:a),y.dispatchEvent(S)}},[h,p,a,o]);const b=i.useRef(Ze(a)?!1:a);return r.jsx(Z.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??b.current,required:c,disabled:u,name:f,value:d,form:m,...t,tabIndex:-1,ref:x,style:{...t.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});kl.displayName=Sl;function Lx(e){return typeof e=="function"}function Ze(e){return e==="indeterminate"}function Cl(e){return Ze(e)?"indeterminate":e?"checked":"unchecked"}const Dr=i.forwardRef(({className:e,...t},n)=>r.jsx(ms,{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(jl,{className:U("flex items-center justify-center text-current"),children:r.jsx(ze,{className:"h-3.5 w-3.5"})})}));Dr.displayName=ms.displayName;function mo({toolbarTasks:e,activeTaskId:t,tasksLoading:n,tasksError:s,isLeader:o,scope:a,agentFilter:l,nodeFilter:c,agentOptions:u,nodeOptions:f,nodeNameById:d,searchQuery:m,selectedTaskIds:h,allVisibleTasksSelected:g,someVisibleTasksSelected:x,canBatchArchive:p,onSearchChange:v,onScopeChange:b,onAgentFilterChange:y,onNodeFilterChange:w,onToggleTaskSelected:j,onToggleAllVisibleTasks:k,onBatchArchive:C,onBatchDelete:S,onCreateTask:T,onSelectTask:R,onClose:A}){const[O,$]=i.useState(!!m),[V,W]=i.useState(!1),z=i.useRef(null),P=i.useRef(null),_=h.size,L=a!=="active"||c!=="all"||l!=="all";return i.useEffect(()=>{m&&$(!0)},[m]),i.useEffect(()=>{var E;O&&((E=z.current)==null||E.focus())},[O]),i.useEffect(()=>{if(!O)return;const E=ce=>{var me;const ae=ce.target;ae instanceof Node&&((me=P.current)!=null&&me.contains(ae)||$(!1))},te=ce=>{ce.key==="Escape"&&$(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",te),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",te)}},[O]),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(H,{variant:"ghost",size:"icon",onClick:A,className:"rounded-full",children:r.jsx(So,{className:"h-4 w-4"})})]}),r.jsxs("div",{ref:P,className:"mt-4 flex items-center gap-2",children:[r.jsxs(H,{onClick:T,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",O?"flex-[2]":"flex-1"),children:[r.jsx(jo,{className:"h-4 w-4"}),"New chat"]}),O?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(H,{variant:"outline",size:"icon",onClick:()=>$(!1),className:"rounded-full border-border/70 bg-background/60",children:r.jsx(qc,{className:"h-4 w-4"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs(H,{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(H,{variant:V||L?"secondary":"outline",size:"icon",onClick:()=>W(E=>!E),className:U("shrink-0 rounded-full border-border/70 bg-background/60",L&&"border-primary/40 bg-primary/8 text-primary"),title:"Filters",children:r.jsx(od,{className:"h-4 w-4"})})]})]}),(V||L)&&r.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-3",children:[r.jsxs(Te,{value:a,onValueChange:E=>b(E),children:[r.jsx(Ne,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(_e,{})}),r.jsx(je,{children:ix.map(E=>r.jsx(ge,{value:E.value,className:"text-[12px]",children:E.label},E.value))})]}),r.jsxs(Te,{value:c,onValueChange:w,children:[r.jsx(Ne,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(_e,{placeholder:"Node"})}),r.jsx(je,{children:f.map(E=>r.jsx(ge,{value:E.value,className:"text-[12px]",children:E.label},E.value))})]}),r.jsxs(Te,{value:l,onValueChange:y,children:[r.jsx(Ne,{className:"h-9 rounded-full border-border/70 bg-background/55 text-[12px]",children:r.jsx(_e,{placeholder:"Agent"})}),r.jsx(je,{children:u.map(E=>r.jsx(ge,{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(Dr,{checked:x&&!g?"indeterminate":g,onCheckedChange:E=>k(E===!0),"aria-label":"Select all visible tasks"}),r.jsx("span",{children:"Select all"})]}),_>0&&r.jsx(H,{variant:"ghost",size:"sm",onClick:()=>k(!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:te=>te.stopPropagation(),children:r.jsx(Dr,{checked:h.has(E.id),onCheckedChange:te=>j(E.id,te===!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",px(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?d.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:gx(E.updatedAt)})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[r.jsx(vo,{status:E.status}),E.assignedNodeAvailable===!1&&r.jsx(ke,{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:hx(E.effectiveProjectPath??E.project??"default workspace")})]}),r.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground/85",children:xx(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&&_>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:[_," task",_!==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(wr,{children:[r.jsx(Ks,{asChild:!0,children:r.jsxs(H,{variant:"outline",size:"sm",disabled:!p,className:"rounded-full",children:[r.jsx(Mc,{className:"h-3.5 w-3.5"}),"Archive"]})}),r.jsxs(pn,{children:[r.jsxs(hn,{children:[r.jsxs(gn,{children:["Archive ",_," task",_!==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:C,disabled:!p,children:"Archive"})]})]})]}),r.jsxs(wr,{children:[r.jsx(Ks,{asChild:!0,children:r.jsxs(H,{variant:"destructive",size:"sm",className:"rounded-full",children:[r.jsx(Dd,{className:"h-3.5 w-3.5"}),"Delete"]})}),r.jsxs(pn,{children:[r.jsxs(hn,{children:[r.jsxs(gn,{children:["Delete ",_," task",_!==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:S,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}):null]})}function ur(e,t,n){const s=i.useRef(t);s.current=t,i.useEffect(()=>{let l=0,c=0;const u=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 g=h.clientX-l;Math.abs(h.clientY-c)>100||Math.abs(g)<50||(g>0?(v=(p=s.current).onSwipeRight)==null||v.call(p):(y=(b=s.current).onSwipeLeft)==null||y.call(b))},d=(e==null?void 0:e.current)??document;return d.addEventListener("touchstart",u,{passive:!0}),d.addEventListener("touchend",f,{passive:!0}),()=>{d.removeEventListener("touchstart",u),d.removeEventListener("touchend",f)}},[e,n==null?void 0:n.threshold,n==null?void 0:n.maxVertical])}function po(e,t,n=30){const s=i.useRef(t);s.current=t,i.useEffect(()=>{let l=0,c=0,u=!1;const f=m=>{const h=m.touches[0];h&&(l=h.clientX,c=h.clientY,e==="left"?u=h.clientX<=n:u=h.clientX>=window.innerWidth-n)},d=m=>{if(!u)return;const h=m.changedTouches[0];if(!h)return;const g=h.clientX-l;Math.abs(h.clientY-c)>100||Math.abs(g)<50||(e==="left"&&g>0||e==="right"&&g<0)&&s.current()};return document.addEventListener("touchstart",f,{passive:!0}),document.addEventListener("touchend",d,{passive:!0}),()=>{document.removeEventListener("touchstart",f),document.removeEventListener("touchend",d)}},[e,n])}const ho="(min-width: 1024px)",$x="(min-width: 1280px)";function fr(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 Fx(){const[e,t]=i.useState(!0),[n,s]=i.useState(!1),[o,a]=i.useState(()=>fr($x)),l=i.useRef(null),c=i.useRef(null),u=i.useRef(null),f=i.useCallback(()=>!fr(ho),[]);po("left",()=>{f()&&s(!0)}),po("right",()=>{f()&&a(!0)}),ur(l,{onSwipeLeft:()=>s(!1)}),ur(c,{onSwipeRight:()=>a(!1)}),ur(u,{onSwipeRight:()=>{f()&&!n&&s(!0)},onSwipeLeft:()=>{o||a(!0)}});const d=i.useCallback(()=>{if(fr(ho)){t(m=>!m);return}s(m=>!m)},[]);return{conversationRef:u,desktopTasksOpen:e,mobileTasksPanelOpen:n,mobileTasksPanelRef:l,operationsOpen:o,operationsPanelRef:c,setMobileTasksPanelOpen:s,setOperationsOpen:a,toggleTasksPanel:d}}function Bx(e,t){return t.data.nodeId===e.self.id||t.data.name===e.self.name||t.data.endpoint===e.self.endpoint}function Ux({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=Bx(e,s);s.type==="node.joined"&&!a&&he.success(`${o} joined the cluster`),s.type==="node.left"&&!a&&he.message(`${o} left the cluster`)})},[e,t])}function Vx(){var js,Ss,ks;const{id:e}=hc(),t=xc(),n=gc(),{cluster:s,systemInfo:o,events:a,sseConnected:l,subscribe:c,refresh:u,loading:f,error:d}=vc(),m=i.useMemo(()=>mx(t.state),[t.state]),[h,g]=i.useState([]),[x,p]=i.useState(!0),[v,b]=i.useState(null),[y,w]=i.useState(null),[j,k]=i.useState("active"),[C,S]=i.useState("all"),[T,R]=i.useState("all"),[A,O]=i.useState(""),$=i.useDeferredValue(A),{conversationRef:V,desktopTasksOpen:W,mobileTasksPanelOpen:z,mobileTasksPanelRef:P,operationsOpen:_,operationsPanelRef:L,setMobileTasksPanelOpen:E,setOperationsOpen:te,toggleTasksPanel:ce}=Fx(),[ae,me]=i.useState(()=>!!(m!=null&&m.draftNewTask)),[M,Q]=i.useState(()=>m!=null&&m.draftNewTask?{route:m.returnRoute??"/",taskId:m.returnTaskId??null}:null),[ne,I]=i.useState(!1),[X,de]=i.useState("transcript"),[q,J]=i.useState("all"),[K,F]=i.useState(!1),[re,ue]=i.useState(null),[we,be]=i.useState([]),[Be,ie]=i.useState([]),[El,Yt]=i.useState(!1),[Tl,ft]=i.useState(null),[qe,ot]=i.useState(new Set),[Al,ps]=i.useState(!1),[Rl,hs]=i.useState(!1),[_l,xs]=i.useState(!1),[Pl,gs]=i.useState(null),vs=i.useRef(null),Mt=i.useRef(null),mt=((js=s==null?void 0:s.self)==null?void 0:js.role)==="leader",Wn=(Ss=s==null?void 0:s.self)==null?void 0:Ss.id;Ux({cluster:s,subscribe:c});const xe=i.useCallback(async()=>{try{const N=await bc({assignedTo:!mt&&Wn?Wn:void 0,limit:100});g(N),b(null)}catch(N){b(N instanceof Error?N.message:"Failed to load tasks")}finally{p(!1)}},[mt,Wn]);yc(xe,1e4),i.useEffect(()=>{xe()},[xe]),i.useEffect(()=>c("task",xe),[c,xe]);const pe=i.useMemo(()=>[...h].sort((N,D)=>D.updatedAt-N.updatedAt),[h]),Dl=i.useMemo(()=>{const N=new Map;for(const D of(s==null?void 0:s.nodes)??[]){const B=Fd(pe,D.id);B>0&&N.set(D.id,B)}return N},[s==null?void 0:s.nodes,pe]),Ae=i.useMemo(()=>pe.filter(N=>!cx(N,j)||C!=="all"&&N.agent!==C||T==="unassigned"&&N.assignedTo||T!=="all"&&T!=="unassigned"&&ux(N.assignedTo,s==null?void 0:s.nodes,N.assignedNodeName)!==T?!1:$.trim()?dx(N,$):!0),[pe,j,C,T,$]);i.useEffect(()=>{ot(N=>{const D=zd(N,Ae.map(B=>B.id));return D.size===N.size?N:D})},[Ae]),i.useEffect(()=>{mt||ot(new Set)},[mt]);const Ml=i.useMemo(()=>["all",...Array.from(new Set(pe.map(N=>N.agent))).sort()],[pe]),Ol=i.useMemo(()=>{const D=Array.from(new Set(pe.map(B=>B.assignedTo).filter(B=>!!B))).map(B=>{const fe=pe.find(ee=>ee.assignedTo===B);return(s==null?void 0:s.nodes.find(ee=>ee.id===B))??{id:B,name:us(B,s==null?void 0:s.nodes,fe==null?void 0:fe.assignedNodeName)}}).sort((B,fe)=>B.name.localeCompare(fe.name));return[{value:"all",label:"All nodes"},{value:"unassigned",label:"Unassigned"},...D.map(B=>({value:B.name.toLowerCase(),label:B.name}))]},[pe,s==null?void 0:s.nodes]),bs=i.useMemo(()=>{const N=new Map;for(const D of(s==null?void 0:s.nodes)??[])N.set(D.id,D.name);for(const D of pe)D.assignedTo&&D.assignedNodeName&&!N.has(D.assignedTo)&&N.set(D.assignedTo,D.assignedNodeName);return N},[s==null?void 0:s.nodes,pe]),zn=i.useMemo(()=>["all",...Array.from(new Set(a.map(N=>N.type))).sort()],[a]),Il=i.useMemo(()=>q==="all"?a:a.filter(N=>N.type===q),[a,q]),Ll=Ae.length>0&&Ae.every(N=>qe.has(N.id)),$l=Ae.some(N=>qe.has(N.id)),Fl=Hd(Ae,qe);i.useEffect(()=>{m!=null&&m.draftNewTask&&(me(!0),Q({route:m.returnRoute??"/",taskId:m.returnTaskId??null}))},[m]),i.useEffect(()=>{q!=="all"&&!zn.includes(q)&&J("all")},[q,zn]),i.useEffect(()=>{As(e,ae)&&!y&&pe[0]&&w(pe[0].id)},[e,ae,y,pe]),i.useEffect(()=>{var N;As(e,ae)&&(y&&h.some(D=>D.id===y)||w(((N=pe[0])==null?void 0:N.id)??null))},[e,ae,y,pe,h]);const oe=Ud({routeTaskId:e,creatingTask:ae,internalSelectedTaskId:y,sortedTaskIds:pe.map(N=>N.id)}),pt=i.useMemo(()=>h.find(N=>N.id===oe)??null,[h,oe]);i.useEffect(()=>{Mt.current=oe??null},[oe]);const Xt=i.useCallback(()=>{ue(null),be([]),ie([]),ft(null)},[]),Ee=i.useCallback(async()=>{const N=oe;if(N)try{const D=await wc(N);if(Mt.current!==N)return;ue(D),ft(null)}catch(D){if(Mt.current!==N)return;ue(null),be([]),ie([]),ft(D instanceof Error?D.message:"Failed to load task")}finally{Mt.current===N&&Yt(!1)}},[oe]),Jt=i.useCallback(async()=>{const N=oe;if(N)try{const D=await Nc(N);if(Mt.current!==N)return;be(B=>xu(B,D.logs)),ie(B=>vu(B,D.logs))}catch{}},[oe]);i.useEffect(()=>{if(!oe){ue(null),be([]),ie([]),ft(null),Yt(!1);return}de("transcript"),ue(pt),be([]),ie([]),ft(null),Yt(!0),Ee(),Jt()},[oe,Jt,Ee]),i.useEffect(()=>{var D;if(!oe||ae||x||h.some(B=>B.id===oe))return;const N=((D=pe[0])==null?void 0:D.id)??null;w(N),Xt(),i.startTransition(()=>{n(N?`/tasks/${N}`:"/",{state:null})})},[oe,Xt,ae,n,pe,h,x]),i.useEffect(()=>{pt&&ue(N=>!N||N.id!==pt.id?N:{...N,...pt})},[pt]),i.useEffect(()=>{if(oe)return c("task",N=>{const D=N.data.taskId;if(!(typeof D!="string"||D!==oe)){if(N.type==="task.output"){const B=N.data.event;if(B){be(ee=>gu(ee,B));const fe=Ht(B);fe&&ie(ee=>bu(ee,fe))}}N.type==="task.status"&&(Ee(),Jt())}})},[c,oe,Ee,Jt]),i.useEffect(()=>{var N;X==="transcript"&&((N=vs.current)==null||N.scrollIntoView({behavior:"smooth"}))},[we,Be,X]);const se=re??pt,Bl=se!=null&&se.assignedTo?(s==null?void 0:s.nodes.find(N=>N.id===se.assignedTo))??null:null,Hn=Be.length>0,Ul=se?Kh.has(se.agent):!1,Kn=(se==null?void 0:se.status)==="running",Vl=se?Cn.has(se.status)||vl.has(se.status):!1,Wl=!!(se&&mt&&se.status==="failed"),qn=i.useMemo(()=>Dx(se,s,Hn,!!Kn),[se,s,Hn,Kn]),zl=i.useMemo(()=>yu(we),[we]),Gn=i.useMemo(()=>wu([...we,...Be.map(N=>Xn(N.content,N.timestamp))]),[we,Be]),Hl=i.useMemo(()=>{if(!se)return null;const N=Xd(se);if(N.length>0)return Xn(N,new Date(se.createdAt).toISOString());if(Gn.length>0)return null;const D=It(se.description||se.title);return D.length>0?Xn(D,new Date(se.createdAt).toISOString()):null},[se,Gn]),Yn=i.useCallback(()=>{const N={route:e?`/tasks/${e}`:"/",taskId:oe};Q(N),me(!0),i.startTransition(()=>{n("/",{state:{draftNewTask:!0,returnRoute:N.route,returnTaskId:N.taskId}})})},[e,oe,n]),Kl=i.useCallback(()=>{var D;const N=(M==null?void 0:M.taskId)??((D=pe[0])==null?void 0:D.id)??null;me(!1),Q(null),w(N),i.startTransition(()=>{n((M==null?void 0:M.route)??"/",{state:null})})},[M,pe,n]),ys=i.useCallback(N=>{me(!1),Q(null),w(N),i.startTransition(()=>{n(`/tasks/${N}`,{state:null})})},[n]),ql=i.useCallback(N=>{me(!1),Q(null),g(D=>Vd(D,N)),ue(N),be([]),ie([]),ft(null),Yt(!1),de("transcript"),w(N.id),xe(),i.startTransition(()=>{n(`/tasks/${N.id}`,{state:null})})},[xe,n]),Zt=i.useCallback(async N=>{if(!oe)return!1;const D=`local-${Date.now()}-${Math.random().toString(16).slice(2)}`;ie(B=>[...B,{id:D,content:N,timestamp:new Date().toISOString()}]);try{return await jc(oe,N),Ee(),!0}catch(B){return ie(fe=>fe.filter(ee=>ee.id!==D)),he.error(B instanceof Error?B.message:"Failed to send message"),!1}},[oe,Ee]),Gl=i.useCallback(N=>{Zt(N)},[Zt]),Yl=i.useCallback(N=>Zt(N),[Zt]),Xl=i.useCallback(async()=>{if(se)try{await Sc(se.id),Ee(),xe()}catch(N){he.error(N instanceof Error?N.message:"Failed to cancel task")}},[se,Ee,xe]),Jl=i.useCallback(async()=>{if(se)try{await kc(se.id),Ee(),xe()}catch(N){he.error(N instanceof Error?N.message:"Failed to retry task")}},[se,Ee,xe]),Qt=i.useCallback((N,D=!1)=>{const B=Kd(Ae,N);return w(B),(D||!B)&&Xt(),i.startTransition(()=>{n(B?`/tasks/${B}`:"/",{state:null})}),B},[Xt,Ae,n]),Zl=i.useCallback((N,D)=>{ot(B=>{const fe=new Set(B);return D?fe.add(N):fe.delete(N),fe})},[]),Ql=i.useCallback(N=>{if(!N){ot(new Set);return}ot(new Set(Ae.map(D=>D.id)))},[Ae]),ec=i.useCallback(async()=>{const N=Array.from(qe);if(N.length!==0)try{const{results:D}=await Cc(N),B=D.filter(ee=>!ee.ok),fe=D.filter(ee=>ee.ok).map(ee=>ee.id);oe&&fe.includes(oe)&&Qt(fe),B.length>0?he.error(`Failed to archive ${B.length} task(s): ${B.map(ee=>ee.error??ee.id).join(", ")}`):he.success(`Archived ${fe.length} task(s)`),ot(new Set(B.map(ee=>ee.id))),xe()}catch(D){he.error(D instanceof Error?D.message:"Failed to archive tasks")}},[oe,xe,Qt,qe]),tc=i.useCallback(async()=>{const N=Array.from(qe);if(N.length!==0)try{const{results:D}=await Ec(N),B=D.filter(ee=>!ee.ok),fe=D.filter(ee=>ee.ok).map(ee=>ee.id);oe&&fe.includes(oe)&&Qt(fe,!0),B.length>0?he.error(`Failed to delete ${B.length} task(s): ${B.map(ee=>ee.error??ee.id).join(", ")}`):he.success(`Deleted ${fe.length} task(s)`),ot(new Set(B.map(ee=>ee.id))),xe()}catch(D){he.error(D instanceof Error?D.message:"Failed to delete tasks")}},[oe,xe,Qt,qe]),nc=i.useCallback(async()=>{ps(!0);try{await Tc(),u()}catch(N){he.error(N instanceof Error?N.message:"Failed to trigger election")}finally{ps(!1)}},[u]),rc=i.useCallback(async()=>{hs(!0);try{await Ac(),u()}catch(N){he.error(N instanceof Error?N.message:"Failed to promote node")}finally{hs(!1)}},[u]),sc=i.useCallback(async()=>{xs(!0);try{await Rc(),he.success("This node left the remote cluster and is leading itself again."),xe(),Ee(),u()}catch(N){he.error(N instanceof Error?N.message:"Failed to leave cluster")}finally{xs(!1)}},[Ee,xe,u]),oc=i.useCallback(async N=>{var Cs;const D=!$r(N),B=N.id===((Cs=s==null?void 0:s.self)==null?void 0:Cs.id),fe=B?(o==null?void 0:o.transportType)??N.transportType:N.transportType,ee=B&&!D&&Tt(fe);gs(N.id);try{ee?await _c("direct"):await Pc(N.id,D),he.success(D?`Enabled remote access on ${N.name}`:`Disabled remote access on ${N.name}`),u()}catch(Es){he.error(Es instanceof Error?Es.message:"Failed to update remote access")}finally{gs(null)}},[(ks=s==null?void 0:s.self)==null?void 0:ks.id,u,o==null?void 0:o.transportType]),ws={toolbarTasks:Ae,activeTaskId:oe,tasksLoading:x,tasksError:v,isLeader:mt,scope:j,agentFilter:C,nodeFilter:T,agentOptions:Ml,nodeOptions:Ol,nodeNameById:bs,searchQuery:A,selectedTaskIds:qe,allVisibleTasksSelected:Ll,someVisibleTasksSelected:$l,canBatchArchive:Fl,onSearchChange:O,onScopeChange:k,onAgentFilterChange:S,onNodeFilterChange:R,onToggleTaskSelected:Zl,onToggleAllVisibleTasks:Ql,onBatchArchive:ec,onBatchDelete:tc,onCreateTask:Yn,onSelectTask:ys,onClose:ce},Ns={cluster:s,systemInfo:o,nodeNameById:bs,nodeBlockingTaskCounts:Dl,eventTypeFilter:q,onEventTypeFilterChange:J,eventTypeOptions:zn,filteredEvents:Il,sseConnected:l,clusterLoading:f,clusterError:d,electionPending:Al,onTriggerElection:nc,promotePending:Rl,onPromote:rc,onAddNode:()=>I(!0),leavePending:_l,onLeaveCluster:sc,onToggleNodeDevTunnel:oc,devTunnelNodeId:Pl,onClose:()=>te(!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",W?"lg:mr-3 lg:w-[24rem]":"lg:w-0 lg:overflow-hidden"),children:W&&r.jsx(mo,{...ws})}),r.jsx("section",{ref:V,className:"min-h-0 min-w-0 flex-1",children:r.jsx(jx,{onToggleTasks:ce,desktopTasksOpen:W,mobileTasksPanelOpen:z,operationsOpen:_,onToggleOperations:()=>te(N=>!N),cluster:s,sseConnected:l,activeTab:X,setActiveTab:de,creatingTask:ae,activeTask:se,assignedNode:Bl,taskLoading:El,taskError:Tl,displayEvents:Gn,hasUserMessageInLogs:zl,initialPrompt:Hl,supportsFollowUp:Ul,taskUnavailable:qn.taskUnavailable,chatDisabled:qn.chatDisabled,chatDisabledReason:qn.chatDisabledReason,questionBypassEnabled:K,isRunning:!!Kn,hasPendingFollowUp:Hn,canCancel:!!Vl,canRetry:!!Wl,onRetry:Jl,onCancel:Xl,onStartCreateTask:Yn,onCancelCreateTask:Kl,onCreateTask:ql,onSendMessage:Gl,onQuestionBypassChange:F,onSubmitQuestionResponse:Yl,messagesEndRef:vs})}),r.jsx("div",{className:U("hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",_?"xl:ml-3 xl:w-[26rem]":"xl:w-0 xl:overflow-hidden"),children:_&&r.jsx(uo,{...Ns})})]}),_&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:()=>te(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),r.jsx("div",{ref:L,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(uo,{...Ns})})]}),z&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Close task list",onClick:()=>E(!1),className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),r.jsx("div",{ref:P,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(mo,{...ws,onCreateTask:()=>{E(!1),Yn()},onSelectTask:N=>{E(!1),ys(N)},onClose:()=>E(!1)})})]}),r.jsx(Zf,{open:ne,onOpenChange:I,children:r.jsx(om,{onAdded:()=>{I(!1),u()}})})]})}const Hx=Object.freeze(Object.defineProperty({__proto__:null,DashboardPage:Vx},Symbol.toStringTag,{value:"Module"}));export{Or as C,Zf as D,No as E,rd as F,fa as a,ha as b,zx as c,Et as d,Hx as e};