@polderlabs/bizar 4.4.3 → 4.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bizar-dash/dist/assets/main-C4Dq4wTz.js +347 -0
- package/bizar-dash/dist/assets/main-C4Dq4wTz.js.map +1 -0
- package/bizar-dash/dist/assets/main-Nq8Dq3VR.css +1 -0
- package/bizar-dash/dist/assets/{mobile-DbxIw8BG.js → mobile-CQTXbuHq.js} +2 -2
- package/bizar-dash/dist/assets/{mobile-DbxIw8BG.js.map → mobile-CQTXbuHq.js.map} +1 -1
- package/bizar-dash/dist/assets/mobile-CaZ0gEeJ.js +354 -0
- package/bizar-dash/dist/assets/mobile-CaZ0gEeJ.js.map +1 -0
- package/bizar-dash/dist/index.html +3 -3
- package/bizar-dash/dist/mobile.html +2 -2
- package/package.json +4 -2
- package/bizar-dash/dist/assets/main-B3RgW6FS.js +0 -331
- package/bizar-dash/dist/assets/main-B3RgW6FS.js.map +0 -1
- package/bizar-dash/dist/assets/main-DlJ8wgLR.css +0 -1
- package/bizar-dash/dist/assets/mobile-Dvq2d53Y.js +0 -354
- package/bizar-dash/dist/assets/mobile-Dvq2d53Y.js.map +0 -1
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
var Qt=Object.defineProperty;var Zt=(s,t,a)=>t in s?Qt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a;var tt=(s,t,a)=>Zt(s,typeof t!="symbol"?t+"":t,a);import{c as Z,r,a as M,j as e,R as de,C as qs,F as Ue,b as Ae,d as He,M as Ve,B as Ee,S as Oe,A as ze,e as Me,f as Xe,H as ns,g as ft,h as Be,i as ne,u as ke,P as pe,k as C,l as oe,X as $e,m as ea,T as De,n as ks,I as Ns,o as ve,p as ge,q as Qe,s as vt,t as ye,v as Vs,w as sa,E as ta,x as Ws,y as aa,z as Fe,D as is,G as na,J as ia,K as la,L as ra,N as Ze,O as yt,Q as Ks,U as ds,V as bt,W as ca,Y as kt,Z as Nt,_ as gs,$ as oa,a0 as da,a1 as ma,a2 as ha,a3 as ws,a4 as ua,a5 as at,a6 as pa,a7 as Je,a8 as nt,a9 as xa,aa as ja,ab as ga,ac as Ss,ad as ts,ae as Gs,af as fa,ag as va,ah as ya,ai as ba,aj as ka,ak as Na,al as wa,am as Sa,an as Ca,ao as za}from"./mobile-CaZ0gEeJ.js";/**
|
|
2
|
+
* @license lucide-react v0.460.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const fs=Z("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
|
|
7
|
+
* @license lucide-react v0.460.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Ma=Z("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
|
|
12
|
+
* @license lucide-react v0.460.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const wt=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
17
|
+
* @license lucide-react v0.460.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const St=Z("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
|
|
22
|
+
* @license lucide-react v0.460.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Ta=Z("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/**
|
|
27
|
+
* @license lucide-react v0.460.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Aa=Z("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
|
|
32
|
+
* @license lucide-react v0.460.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Ct=Z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
|
|
37
|
+
* @license lucide-react v0.460.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const Ls=Z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
42
|
+
* @license lucide-react v0.460.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const $a=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
47
|
+
* @license lucide-react v0.460.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const Ia=Z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
|
|
52
|
+
* @license lucide-react v0.460.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const it=Z("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
|
|
57
|
+
* @license lucide-react v0.460.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const Ps=Z("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
|
|
62
|
+
* @license lucide-react v0.460.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const zt=Z("CircleX",[["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"}]]);/**
|
|
67
|
+
* @license lucide-react v0.460.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const Ra=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
72
|
+
* @license lucide-react v0.460.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const zs=Z("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
|
|
77
|
+
* @license lucide-react v0.460.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const Ys=Z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
|
|
82
|
+
* @license lucide-react v0.460.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const Da=Z("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/**
|
|
87
|
+
* @license lucide-react v0.460.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const Le=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
92
|
+
* @license lucide-react v0.460.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const La=Z("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
|
|
97
|
+
* @license lucide-react v0.460.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const lt=Z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
102
|
+
* @license lucide-react v0.460.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const ls=Z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
107
|
+
* @license lucide-react v0.460.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const Js=Z("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
|
|
112
|
+
* @license lucide-react v0.460.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const Pa=Z("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/**
|
|
117
|
+
* @license lucide-react v0.460.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/const Ea=Z("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
|
122
|
+
* @license lucide-react v0.460.0 - ISC
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the ISC license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/const Oa=Z("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
|
|
127
|
+
* @license lucide-react v0.460.0 - ISC
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the ISC license.
|
|
130
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
+
*/const Ba=Z("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/**
|
|
132
|
+
* @license lucide-react v0.460.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const Fa=Z("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
|
|
137
|
+
* @license lucide-react v0.460.0 - ISC
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the ISC license.
|
|
140
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/const Ua=Z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]]);/**
|
|
142
|
+
* @license lucide-react v0.460.0 - ISC
|
|
143
|
+
*
|
|
144
|
+
* This source code is licensed under the ISC license.
|
|
145
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
+
*/const Ha=Z("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/**
|
|
147
|
+
* @license lucide-react v0.460.0 - ISC
|
|
148
|
+
*
|
|
149
|
+
* This source code is licensed under the ISC license.
|
|
150
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
+
*/const _a=Z("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
|
|
152
|
+
* @license lucide-react v0.460.0 - ISC
|
|
153
|
+
*
|
|
154
|
+
* This source code is licensed under the ISC license.
|
|
155
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
+
*/const rs=Z("Globe",[["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"}]]);/**
|
|
157
|
+
* @license lucide-react v0.460.0 - ISC
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the ISC license.
|
|
160
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
+
*/const qa=Z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/**
|
|
162
|
+
* @license lucide-react v0.460.0 - ISC
|
|
163
|
+
*
|
|
164
|
+
* This source code is licensed under the ISC license.
|
|
165
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
+
*/const vs=Z("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
|
|
167
|
+
* @license lucide-react v0.460.0 - ISC
|
|
168
|
+
*
|
|
169
|
+
* This source code is licensed under the ISC license.
|
|
170
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
+
*/const Va=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
|
|
172
|
+
* @license lucide-react v0.460.0 - ISC
|
|
173
|
+
*
|
|
174
|
+
* This source code is licensed under the ISC license.
|
|
175
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
+
*/const Mt=Z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
|
|
177
|
+
* @license lucide-react v0.460.0 - ISC
|
|
178
|
+
*
|
|
179
|
+
* This source code is licensed under the ISC license.
|
|
180
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
+
*/const Wa=Z("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
|
|
182
|
+
* @license lucide-react v0.460.0 - ISC
|
|
183
|
+
*
|
|
184
|
+
* This source code is licensed under the ISC license.
|
|
185
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
+
*/const Es=Z("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
|
|
187
|
+
* @license lucide-react v0.460.0 - ISC
|
|
188
|
+
*
|
|
189
|
+
* This source code is licensed under the ISC license.
|
|
190
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
+
*/const Tt=Z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
|
192
|
+
* @license lucide-react v0.460.0 - ISC
|
|
193
|
+
*
|
|
194
|
+
* This source code is licensed under the ISC license.
|
|
195
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
+
*/const Ka=Z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
197
|
+
* @license lucide-react v0.460.0 - ISC
|
|
198
|
+
*
|
|
199
|
+
* This source code is licensed under the ISC license.
|
|
200
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
+
*/const rt=Z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
|
|
202
|
+
* @license lucide-react v0.460.0 - ISC
|
|
203
|
+
*
|
|
204
|
+
* This source code is licensed under the ISC license.
|
|
205
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
+
*/const cs=Z("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/**
|
|
207
|
+
* @license lucide-react v0.460.0 - ISC
|
|
208
|
+
*
|
|
209
|
+
* This source code is licensed under the ISC license.
|
|
210
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
+
*/const Ga=Z("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
212
|
+
* @license lucide-react v0.460.0 - ISC
|
|
213
|
+
*
|
|
214
|
+
* This source code is licensed under the ISC license.
|
|
215
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
+
*/const Ya=Z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
217
|
+
* @license lucide-react v0.460.0 - ISC
|
|
218
|
+
*
|
|
219
|
+
* This source code is licensed under the ISC license.
|
|
220
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
221
|
+
*/const Ja=Z("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/**
|
|
222
|
+
* @license lucide-react v0.460.0 - ISC
|
|
223
|
+
*
|
|
224
|
+
* This source code is licensed under the ISC license.
|
|
225
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
226
|
+
*/const At=Z("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
|
|
227
|
+
* @license lucide-react v0.460.0 - ISC
|
|
228
|
+
*
|
|
229
|
+
* This source code is licensed under the ISC license.
|
|
230
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
231
|
+
*/const Xa=Z("PanelLeftClose",[["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"}]]);/**
|
|
232
|
+
* @license lucide-react v0.460.0 - ISC
|
|
233
|
+
*
|
|
234
|
+
* This source code is licensed under the ISC license.
|
|
235
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
236
|
+
*/const Qa=Z("PanelLeftOpen",[["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"}]]);/**
|
|
237
|
+
* @license lucide-react v0.460.0 - ISC
|
|
238
|
+
*
|
|
239
|
+
* This source code is licensed under the ISC license.
|
|
240
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
241
|
+
*/const Za=Z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/**
|
|
242
|
+
* @license lucide-react v0.460.0 - ISC
|
|
243
|
+
*
|
|
244
|
+
* This source code is licensed under the ISC license.
|
|
245
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
246
|
+
*/const os=Z("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
|
|
247
|
+
* @license lucide-react v0.460.0 - ISC
|
|
248
|
+
*
|
|
249
|
+
* This source code is licensed under the ISC license.
|
|
250
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
251
|
+
*/const en=Z("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
252
|
+
* @license lucide-react v0.460.0 - ISC
|
|
253
|
+
*
|
|
254
|
+
* This source code is licensed under the ISC license.
|
|
255
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
256
|
+
*/const ys=Z("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/**
|
|
257
|
+
* @license lucide-react v0.460.0 - ISC
|
|
258
|
+
*
|
|
259
|
+
* This source code is licensed under the ISC license.
|
|
260
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
261
|
+
*/const sn=Z("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/**
|
|
262
|
+
* @license lucide-react v0.460.0 - ISC
|
|
263
|
+
*
|
|
264
|
+
* This source code is licensed under the ISC license.
|
|
265
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
266
|
+
*/const tn=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
|
|
267
|
+
* @license lucide-react v0.460.0 - ISC
|
|
268
|
+
*
|
|
269
|
+
* This source code is licensed under the ISC license.
|
|
270
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
271
|
+
*/const $t=Z("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
|
|
272
|
+
* @license lucide-react v0.460.0 - ISC
|
|
273
|
+
*
|
|
274
|
+
* This source code is licensed under the ISC license.
|
|
275
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
276
|
+
*/const an=Z("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/**
|
|
277
|
+
* @license lucide-react v0.460.0 - ISC
|
|
278
|
+
*
|
|
279
|
+
* This source code is licensed under the ISC license.
|
|
280
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
281
|
+
*/const es=Z("ShieldCheck",[["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"}]]);/**
|
|
282
|
+
* @license lucide-react v0.460.0 - ISC
|
|
283
|
+
*
|
|
284
|
+
* This source code is licensed under the ISC license.
|
|
285
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
286
|
+
*/const nn=Z("Shield",[["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"}]]);/**
|
|
287
|
+
* @license lucide-react v0.460.0 - ISC
|
|
288
|
+
*
|
|
289
|
+
* This source code is licensed under the ISC license.
|
|
290
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
291
|
+
*/const ln=Z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
|
|
292
|
+
* @license lucide-react v0.460.0 - ISC
|
|
293
|
+
*
|
|
294
|
+
* This source code is licensed under the ISC license.
|
|
295
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
296
|
+
*/const It=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
297
|
+
* @license lucide-react v0.460.0 - ISC
|
|
298
|
+
*
|
|
299
|
+
* This source code is licensed under the ISC license.
|
|
300
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
301
|
+
*/const Rt=Z("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/**
|
|
302
|
+
* @license lucide-react v0.460.0 - ISC
|
|
303
|
+
*
|
|
304
|
+
* This source code is licensed under the ISC license.
|
|
305
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
306
|
+
*/const Os=Z("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
|
|
307
|
+
* @license lucide-react v0.460.0 - ISC
|
|
308
|
+
*
|
|
309
|
+
* This source code is licensed under the ISC license.
|
|
310
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
311
|
+
*/const rn=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
312
|
+
* @license lucide-react v0.460.0 - ISC
|
|
313
|
+
*
|
|
314
|
+
* This source code is licensed under the ISC license.
|
|
315
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
316
|
+
*/const cn=Z("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
|
|
317
|
+
* @license lucide-react v0.460.0 - ISC
|
|
318
|
+
*
|
|
319
|
+
* This source code is licensed under the ISC license.
|
|
320
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
321
|
+
*/const on=Z("User",[["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"}]]);/**
|
|
322
|
+
* @license lucide-react v0.460.0 - ISC
|
|
323
|
+
*
|
|
324
|
+
* This source code is licensed under the ISC license.
|
|
325
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
326
|
+
*/const dn=Z("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
|
|
327
|
+
* @license lucide-react v0.460.0 - ISC
|
|
328
|
+
*
|
|
329
|
+
* This source code is licensed under the ISC license.
|
|
330
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
331
|
+
*/const mn=Z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),hn=200,un=5*60*1e3,qe=new Map;function pn(s){const t=qe.get(s);return t?Date.now()-t.ts>un?(qe.delete(s),null):t.data:null}function Ms(s,t){qe.size>=hn&&[...qe.entries()].sort((i,n)=>i[1].ts-n[1].ts).slice(0,50).map(([i])=>i).forEach(i=>qe.delete(i)),qe.set(s,{data:t,ts:Date.now()})}function xn(s){if(!s||s==="/")return[{label:"/",path:"/"}];const t=s.split("/").filter(Boolean),a=[];let i="";for(let n=0;n<t.length;n++)i+="/"+t[n],a.push({label:t[n],path:i});return a}function jn(s){return[...s].sort((t,a)=>t.isDir!==a.isDir?t.isDir?-1:1:t.name.localeCompare(a.name,void 0,{sensitivity:"base"}))}function gn(s){const t=s.trim();return t?t!==s?{ok:!1,reason:"Name cannot have leading or trailing whitespace."}:t==="."?{ok:!1,reason:"Name cannot be '.'."}:t===".."?{ok:!1,reason:"Name cannot be '..'."}:t.startsWith("-")?{ok:!1,reason:"Name cannot start with '-'."}:t.length>255?{ok:!1,reason:"Name cannot be longer than 255 characters."}:/[/\0:*?"<>|]/.test(t)?{ok:!1,reason:'Name cannot contain / \\ : * ? " < > |'}:{ok:!0}:{ok:!1,reason:"Name cannot be empty."}}function Dt({value:s,onChange:t,initialPath:a,projectsDirectory:i,rootLabel:n="Home",height:o=360}){const[d,l]=r.useState(a??i??""),[p,h]=r.useState(new Set),[g,m]=r.useState(-1),[c,u]=r.useState(null),[k,f]=r.useState({}),[S,b]=r.useState(!1),[v,y]=r.useState(null),[T,x]=r.useState(!1),[E,q]=r.useState(""),[I,J]=r.useState(null),[R,L]=r.useState(!1),W=r.useRef(null),G=r.useCallback(async B=>{try{const ce=pn(B);if(ce)return ce;const le=await M.get("/fs?path="+encodeURIComponent(B));return Ms(B,le),le}catch{return null}},[]),w=r.useCallback(async B=>{var ce;b(!0),y(null);try{const le=await M.get("/fs?path="+encodeURIComponent(B));Ms(B,le),u(le),m(-1)}catch(le){const fe=((ce=le.data)==null?void 0:ce.message)??le.message??"Failed to load directory";y(fe)}finally{b(!1)}},[]);r.useEffect(()=>{d?w(d):M.get("/fs").then(B=>{Ms("",B),u(B),l(B.path),B.path!==s&&t(B.path)}).catch(()=>{y("Could not determine home directory."),b(!1)})},[d]),r.useEffect(()=>{s&&s!==d&&l(s)},[s]);const $=c?jn(c.entries):[],V=$.filter(B=>B.isDir),K=$,X=B=>{B.isDir&&(l(B.path),t(B.path))},ae=()=>{c!=null&&c.parent&&(l(c.parent),t(c.parent))},se=B=>{B!==d&&(l(B),t(B))},H=async()=>{const B=await G("");B&&(l(B.path),t(B.path))},F=async()=>{if(!i)return;const B=await G(i);B&&(l(B.path),t(B.path))},P=()=>{x(!0),q(""),J(null),setTimeout(()=>{var B;return(B=W.current)==null?void 0:B.focus()},0)},A=()=>{x(!1),q(""),J(null)},D=async()=>{var ce;const B=gn(E);if(!B.ok){J(B.reason);return}L(!0),J(null);try{const le=await M.post("/fs/mkdir",{parent:d,name:E.trim()});qe.delete(d),await w(d),t(le.path),x(!1),q("")}catch(le){const fe=le;fe.status===409?J(`A folder named "${E.trim()}" already exists.`):J(((ce=fe.data)==null?void 0:ce.message)??le.message??"Failed to create folder.")}finally{L(!1)}},Q=B=>{B.key==="Enter"?(B.preventDefault(),D()):B.key==="Escape"&&(B.preventDefault(),A())},z=B=>{h(ce=>{const le=new Set(ce);return le.has(B)?le.delete(B):le.add(B),le}),k[B]||G(B).then(ce=>{ce&&f(le=>({...le,[B]:ce.entries.filter(fe=>fe.isDir)}))})},_=B=>{if(!c)return;const ce=K.filter(me=>me.isDir),le=K.filter(me=>!me.isDir),fe=[...ce,...le];if(B.key==="ArrowDown")B.preventDefault(),m(me=>Math.min(me+1,fe.length-1));else if(B.key==="ArrowUp")B.preventDefault(),m(me=>Math.max(me-1,0));else if(B.key==="Enter"||B.key===" "){B.preventDefault();const me=fe[g];me&&(B.key==="Enter"&&me.isDir?X(me):me.isDir&&t(me.path))}else B.key==="Backspace"&&(B.preventDefault(),ae())},O=xn((c==null?void 0:c.path)??d??"/"),j=c==null?void 0:c.parent,U=j!=null,ee=d.split("/").filter(Boolean).at(-1)??"/";return e.jsxs("div",{className:"file-browser",onKeyDown:_,tabIndex:-1,children:[e.jsx("div",{className:"file-browser-breadcrumb",role:"navigation","aria-label":"Path breadcrumb",children:O.map((B,ce)=>e.jsxs("span",{className:"file-browser-breadcrumb-item",children:[ce>0&&e.jsx("span",{className:"file-browser-breadcrumb-sep","aria-hidden":!0,children:"/"}),e.jsx("button",{type:"button",className:"file-browser-breadcrumb-btn",onClick:()=>se(B.path),title:B.path,children:ce===0?B.path==="/"?"/":n:B.label})]},B.path))}),e.jsxs("div",{className:"file-browser-toolbar",children:[e.jsxs("div",{className:"file-browser-toolbar-left",children:[e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:ae,disabled:!U,title:"Go up (Backspace)","aria-label":"Go up one level",children:e.jsx(wt,{size:13})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:()=>w(d),disabled:S,title:"Refresh","aria-label":"Refresh",children:e.jsx(de,{size:13,className:S?"spin":""})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:P,title:"New folder","aria-label":"Create new folder",children:e.jsx(Ua,{size:13})}),e.jsxs("div",{className:"file-browser-chips",children:[e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:H,children:[e.jsx(qa,{size:11})," ",n]}),i&&e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:F,title:i,children:[e.jsx(Fa,{size:11})," ",i.split("/").filter(Boolean).at(-1)??"Projects"]})]})]}),T?e.jsxs("div",{className:"file-browser-mkdir",children:[e.jsx("input",{ref:W,type:"text",className:"file-browser-mkdir-input",placeholder:"Folder name",value:E,onChange:B=>{q(B.target.value),J(null)},onKeyDown:Q,"aria-label":"New folder name","aria-invalid":I?"true":void 0,"aria-describedby":I?"mkdir-error":void 0,disabled:R,maxLength:255}),I?e.jsx("span",{id:"mkdir-error",className:"file-browser-mkdir-error",role:"alert",children:I}):e.jsx("span",{className:"file-browser-mkdir-hint",children:"Enter to create, Esc to cancel"})]}):e.jsx("span",{className:"file-browser-count-hint",children:S?"…":`${$.length} in ${ee}`})]}),v&&e.jsxs("div",{className:"file-browser-error",children:[e.jsx(qs,{size:13}),e.jsx("span",{children:v}),e.jsx("button",{type:"button",className:"file-browser-retry",onClick:()=>w(d),children:"Retry"})]}),e.jsxs("div",{className:"file-browser-body",style:{height:o},children:[e.jsx("div",{className:"file-browser-pane file-browser-tree","aria-label":"Folder tree",children:S&&!c?e.jsx(fn,{}):e.jsx(Lt,{path:d,entries:V,expanded:p,childrenMap:k,onToggle:z,onNavigate:X,level:0})}),e.jsxs("div",{className:"file-browser-pane file-browser-flat","aria-label":"Directory contents",children:[e.jsxs("div",{className:"file-browser-flat-header",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"})]}),S&&!c?e.jsx(vn,{}):e.jsxs(e.Fragment,{children:[(c==null?void 0:c.truncated)&&e.jsxs("div",{className:"file-browser-truncated-banner",role:"status",children:["Showing first 500 of ",c.totalEntries," entries. Navigate into a subfolder to see more."]}),K.length===0?e.jsx("div",{className:"file-browser-empty",children:"This folder is empty"}):e.jsx("div",{className:"file-browser-flat-list",children:K.map((B,ce)=>{const le=B.isDir,fe=ce===g,me=B.path===s;return e.jsxs("div",{role:"option","aria-selected":me,className:["file-browser-row",le?"file-browser-row--dir":"file-browser-row--file",fe&&"file-browser-row--selected",me&&le&&"file-browser-row--active",!le&&"file-browser-row--disabled"].filter(Boolean).join(" "),onClick:()=>{le&&(m(ce),t(B.path))},onDoubleClick:()=>{le&&X(B)},title:B.path,children:[e.jsx("span",{className:"file-browser-row-icon",children:le?e.jsx(Ue,{size:13}):e.jsx(Ea,{size:13})}),e.jsx("span",{className:"file-browser-row-name",children:B.name}),e.jsx("span",{className:"file-browser-row-type",children:le?"Folder":""})]},B.path)})})]})]})]}),e.jsxs("div",{className:"file-browser-footer-hint",children:["Select a folder, then click Add. Use ",e.jsx("kbd",{children:"↑"})," ",e.jsx("kbd",{children:"↓"})," to navigate, ",e.jsx("kbd",{children:"Enter"})," to confirm."]})]})}function Lt({path:s,entries:t,expanded:a,childrenMap:i,onToggle:n,onNavigate:o,level:d}){return e.jsx("ul",{className:"file-browser-tree-list",role:"group",children:t.map(l=>{const p=a.has(l.path),h=i[l.path]??[];return e.jsxs("li",{className:"file-browser-tree-node",children:[e.jsxs("div",{className:["file-browser-tree-row",p&&"file-browser-tree-row--expanded"].filter(Boolean).join(" "),style:{paddingLeft:`${d*16+8}px`},children:[e.jsx("button",{type:"button",className:"file-browser-tree-toggle",onClick:g=>{g.stopPropagation(),n(l.path)},"aria-label":p?"Collapse":"Expand",children:(h.length>0,p?e.jsx(Ae,{size:11}):e.jsx(He,{size:11}))}),e.jsxs("button",{type:"button",className:"file-browser-tree-name",onClick:()=>o(l),title:l.path,children:[e.jsx(Ue,{size:12}),e.jsx("span",{children:l.name})]})]}),p&&h.length>0&&e.jsx(Lt,{path:l.path,entries:h,expanded:a,childrenMap:i,onToggle:n,onNavigate:o,level:d+1})]},l.path)})})}function fn(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[80,60,90,55,70].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}function vn(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[60,90,70,50,80,65].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}const Bs=[{id:"overview",label:"Overview",icon:Wa},{id:"chat",label:"Chat",icon:Ve},{id:"agents",label:"Agents",icon:Ee},{id:"artifacts",label:"Glyphs",icon:cs},{id:"tasks",label:"Tasks",icon:Oe},{id:"activity",label:"Activity",icon:ze},{id:"background",label:"Active",icon:sn},{id:"skills",label:"Skills",icon:Me},{id:"mods",label:"Mods",icon:ys},{id:"schedules",label:"Schedules",icon:Xe},{id:"history",label:"History",icon:ns},{id:"config",label:"Config",icon:$t},{id:"settings",label:"Settings",icon:ft}];function yn({activeTab:s,onTabChange:t,wsStatus:a,version:i,activeProject:n,projects:o,onProjectChange:d,onProjectsRefresh:l,onOpenSearch:p,settings:h,rightSlot:g,notificationsSlot:m,showTabs:c=!0,extraTabs:u}){return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"topbar-row",children:[e.jsxs("div",{className:"brand",children:[e.jsx("span",{className:"brand-logo","aria-hidden":"true",children:"ᛒ"}),e.jsx("span",{className:"brand-title",children:"Bizar"}),e.jsx("span",{className:"brand-version",children:i})]}),e.jsx(bn,{activeProject:n,projects:o,onChange:d,onRefresh:l,settings:h??null}),e.jsxs("button",{type:"button",className:"topbar-search",onClick:p,title:"Search (Ctrl/Cmd+K)","aria-label":"Open search",children:[e.jsx(Be,{size:14}),e.jsx("span",{className:"muted",children:"Search…"}),e.jsx("kbd",{children:"⌘K"})]}),e.jsx("div",{className:"topbar-spacer"}),e.jsxs("div",{className:"topbar-right",children:[m,g,e.jsxs("div",{className:ne("ws-status",`ws-${a}`),title:`WebSocket: ${a}`,children:[e.jsx("span",{className:"ws-dot"}),e.jsx("span",{className:"ws-label",children:a})]})]})]}),c&&e.jsxs("nav",{className:"tabs-row",role:"tablist",children:[Bs.map(k=>{const f=k.icon,S=k.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,className:ne("tab",S&&"tab-active"),onClick:()=>t(k.id),title:k.label,children:[e.jsx(f,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:k.label})]},k.id)}),u&&u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tab-separator","aria-hidden":"true"}),u.map(k=>{const f=k.icon,S=k.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,className:ne("tab","tab-mod",S&&"tab-active"),onClick:()=>t(k.id),title:`${k.label} (mod)`,children:[e.jsx(f,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:k.label}),e.jsx("span",{className:"tab-badge",children:"mod"})]},k.id)})]})]})]})}function bn({activeProject:s,projects:t,onChange:a,onRefresh:i,settings:n}){const[o,d]=r.useState(!1),l=ke();r.useEffect(()=>{if(!o)return;const h=()=>d(!1);return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[o]);const p=()=>{l.open({title:"Add project",children:e.jsx(kn,{settings:n,onAdd:async(h,g)=>{try{await M.post("/projects",{path:h,name:g}),i(),d(!1),l.close()}catch(m){alert(`Add failed: ${m.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(C,{variant:"ghost",onClick:()=>l.close(),children:"Cancel"})})})};return e.jsxs("div",{className:"project-selector",onClick:h=>h.stopPropagation(),children:[e.jsxs("button",{type:"button",className:"project-selector-btn",onClick:()=>d(h=>!h),title:"Switch active project","aria-haspopup":"menu","aria-expanded":o,children:[e.jsx(Ue,{size:14}),e.jsx("span",{className:"project-selector-name",children:(s==null?void 0:s.name)||"(no project)"}),e.jsx(Ae,{size:12})]}),o&&e.jsxs("div",{className:"project-selector-menu",children:[e.jsxs("div",{className:"project-selector-menu-head",children:[e.jsxs("span",{className:"muted",children:[t.length," project",t.length===1?"":"s"]}),e.jsxs("div",{className:"project-selector-menu-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:i,title:"Refresh","aria-label":"Refresh projects",children:e.jsx(de,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:p,title:"Add project","aria-label":"Add project",children:e.jsx(pe,{size:12})})]})]}),e.jsxs("ul",{className:"project-selector-list",children:[t.length===0&&e.jsx("li",{className:"muted project-selector-empty",children:"No projects. Add one to start."}),t.map(h=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:ne("project-selector-item",(s==null?void 0:s.id)===h.id&&"active"),onClick:()=>{a(h.id),d(!1)},children:[e.jsx("span",{className:"project-selector-item-name",children:h.name}),e.jsx("span",{className:"project-selector-item-status",children:h.status})]})},h.id))]})]})]})}function kn({settings:s,onAdd:t}){var m,c;const[a,i]=r.useState(((m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory)??""),[n,o]=r.useState(""),[d,l]=r.useState(!1),[p,h]=r.useState(null),g=async()=>{var u;if(a){l(!0),h(null);try{await M.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(k){const f=k;f.status===404?h("That folder no longer exists. Pick another."):h(((u=f.data)==null?void 0:u.message)??k.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Dt,{value:a,onChange:u=>{i(u),h(null)},projectsDirectory:(c=s==null?void 0:s.dashboard)==null?void 0:c.projectsDirectory,height:320}),p&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:p}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"topbar-add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"topbar-add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:u=>o(u.target.value)})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(C,{variant:"primary",onClick:g,disabled:!a||d,children:[d?e.jsx("span",{className:"btn-spinner"}):null,d?"Checking…":"Add"]})})]})}function Nn({tabs:s,activeTab:t,onTabChange:a}){const i=s.filter(o=>!o.isMod),n=s.filter(o=>o.isMod);return e.jsx("aside",{className:"sidebar","aria-label":"Primary navigation",children:e.jsxs("nav",{className:"sidebar-nav",role:"tablist",children:[i.map(o=>{const d=o.icon,l=o.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,className:ne("sidebar-tab",l&&"sidebar-tab-active"),onClick:()=>a(o.id),title:o.label,children:[e.jsx(d,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:o.label})]},o.id)}),n.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sidebar-section-divider","aria-hidden":"true"}),e.jsx("div",{className:"sidebar-section-label",children:"Mods"}),n.map(o=>{const d=o.icon,l=o.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,className:ne("sidebar-tab","sidebar-tab-mod",l&&"sidebar-tab-active"),onClick:()=>a(o.id),title:`${o.label} (mod)`,children:[e.jsx(d,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:o.label})]},o.id)})]})]})})}const Ts=[{id:"all",label:"All"},{id:"projects",label:"Projects"},{id:"agents",label:"Agents"},{id:"tasks",label:"Tasks"},{id:"mods",label:"Mods"},{id:"schedules",label:"Schedules"},{id:"commands",label:"Commands"},{id:"settings",label:"Settings"}],ct={all:null,projects:"project",agents:"agent",tasks:"task",mods:"mod",schedules:"schedule",commands:"command",settings:"setting"};function wn({open:s,onClose:t,onSelect:a}){const i=oe(),[n,o]=r.useState(""),[d,l]=r.useState("all"),[p,h]=r.useState([]),[g,m]=r.useState(!1),[c,u]=r.useState(0),k=r.useRef(null),f=r.useRef(null);if(r.useEffect(()=>{let y;return s&&(f.current=document.activeElement instanceof HTMLElement?document.activeElement:null,o(""),h([]),u(0),y=window.setTimeout(()=>{var T;return(T=k.current)==null?void 0:T.focus()},30)),()=>{if(y&&window.clearTimeout(y),!s)return;const T=f.current;T&&T.isConnected&&T.focus()}},[s]),r.useEffect(()=>{if(!s)return;if(!n.trim()){h([]),u(0);return}let y=!1;m(!0);const T=setTimeout(()=>{M.get(`/search?q=${encodeURIComponent(n)}&scope=${d}`).then(x=>{y||(h(x.results||[]),u(0))}).catch(x=>{y||i.error(`Search failed: ${x.message}`)}).finally(()=>!y&&m(!1))},150);return()=>{y=!0,clearTimeout(T)}},[n,d,s,i]),!s)return null;const S={};for(const y of p){const T=y.type.toLowerCase();S[T]=S[T]||[],S[T].push(y)}const b=[];for(const y of Ts.map(T=>T.id)){const T=ct[y];T&&S[T]&&b.push(...S[T])}const v=y=>{if(y.key==="Escape")t();else if(y.key==="ArrowDown"){if(y.preventDefault(),b.length===0)return;u(T=>Math.min(T+1,b.length-1))}else if(y.key==="ArrowUp"){if(y.preventDefault(),b.length===0)return;u(T=>Math.max(T-1,0))}else y.key==="Enter"&&b[c]&&(y.preventDefault(),a(b[c]),t())};return e.jsx("div",{className:"search-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"search-modal",role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{className:"search-modal-head",children:[e.jsx(Be,{size:14}),e.jsx("span",{id:"search-modal-title",className:"sr-only",children:"Search"}),e.jsx("input",{ref:k,className:"search-modal-input",placeholder:"Search tasks, agents, settings, projects…",value:n,onChange:y=>o(y.target.value),onKeyDown:v}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx($e,{size:14})})]}),e.jsx("div",{className:"search-modal-scopes",children:Ts.map(y=>e.jsx("button",{type:"button",className:ne("search-scope",d===y.id&&"search-scope-active"),onClick:()=>l(y.id),children:y.label},y.id))}),e.jsxs("div",{className:"search-modal-body",children:[g&&e.jsx("div",{className:"muted",children:"Searching…"}),!g&&n&&b.length===0&&e.jsx("div",{className:"muted",children:"No results."}),!g&&!n&&e.jsx("div",{className:"muted",children:"Type to search…"}),Ts.map(y=>{const T=ct[y.id];if(!T)return null;const x=S[T];return!x||x.length===0?null:e.jsxs("div",{className:"search-group",children:[e.jsx("div",{className:"search-group-head",children:y.label}),x.map(E=>{const q=b.indexOf(E);return e.jsxs("button",{type:"button",className:ne("search-result",q===c&&"search-result-active"),onMouseEnter:()=>u(q),onClick:()=>{a(E),t()},children:[e.jsx("span",{className:"search-result-type",children:E.type}),e.jsx("span",{className:"search-result-label",children:Sn(E)})]},`${E.type}-${q}`)})]},y.id)})]}),e.jsx("div",{className:"search-modal-foot",children:e.jsx("span",{className:"muted",children:"↑↓ navigate · ↵ open · esc close"})})]})})}function Sn(s){const t=s.item||{};if(s.type==="project")return`${t.name} — ${t.path}`;if(s.type==="agent")return`${t.name} — ${t.description||t.model||""}`;if(s.type==="task")return`${t.title} — ${t.status||""}`;if(s.type==="mod")return`${t.name} v${t.version} — ${t.description||""}`;if(s.type==="schedule")return`${t.name} (${t.type}: ${t.schedule})`;if(s.type==="command")return`${t.name} — ${t.description||""}`;if(s.type==="setting"){const a=t.value===null||t.value===void 0?"":typeof t.value=="string"?` = ${t.value}`:` = ${JSON.stringify(t.value)}`;return`${t.label}${a} — ${t.desc||""}`.trim()}return JSON.stringify(t).slice(0,80)}const Cn={info:Ns,success:ks,warning:De,error:qs};function zn({onCountChange:s,wsSubscribe:t}){const a=oe(),[i,n]=r.useState(!1),[o,d]=r.useState([]),[l,p]=r.useState(null),[h,g]=r.useState(!1),m=r.useRef(null),c=r.useRef(0),u=async()=>{var v;try{g(!0);const y=await M.get("/notifications?limit=200");d(y.notifications||[]),p(y.stats||null),c.current=((v=y.stats)==null?void 0:v.unread)||0,s==null||s(c.current)}catch(y){console.warn("[notifications] reload failed:",y.message)}finally{g(!1)}};r.useEffect(()=>{u()},[]),r.useEffect(()=>t?t(y=>{if(y.type==="notification:new"){const T=y.notification;d(x=>[T,...x.filter(E=>E.id!==T.id)]),T.read||(c.current+=1,p(x=>x?{...x,unread:(x.unread||0)+1}:{total:1,unread:1,lastTs:T.ts,counts:{[T.severity||"info"]:1}}),s==null||s(c.current))}else y.type==="notifications:change"&&u()}):void 0,[t]),r.useEffect(()=>{if(!i)return;const v=T=>{m.current&&(m.current.contains(T.target)||n(!1))},y=T=>{T.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",y)}},[i]);const k=async()=>{try{await M.post("/notifications/read-all",{}),d(v=>v.map(y=>({...y,read:!0}))),p(v=>v&&{...v,unread:0}),c.current=0,s==null||s(0),a.success("All notifications marked as read.",1500)}catch(v){a.error(`Failed: ${v.message}`)}},f=async v=>{try{await M.post(`/notifications/${encodeURIComponent(v)}/read`,{}),d(y=>y.map(T=>T.id===v?{...T,read:!0}:T)),p(y=>y&&{...y,unread:Math.max(0,(y.unread||1)-1)}),c.current=Math.max(0,c.current-1),s==null||s(c.current)}catch(y){a.error(`Failed: ${y.message}`)}},S=async v=>{try{await M.del(`/notifications/${encodeURIComponent(v)}`),d(y=>{const T=y.find(x=>x.id===v);return T&&!T.read&&(c.current=Math.max(0,c.current-1),p(x=>x&&{...x,unread:Math.max(0,x.unread-1)}),s==null||s(c.current)),y.filter(x=>x.id!==v)})}catch(y){a.error(`Failed: ${y.message}`)}},b=(l==null?void 0:l.unread)||0;return e.jsxs("div",{className:"notifications-root",ref:m,children:[e.jsxs("button",{type:"button",className:ne("topbar-icon-btn notifications-bell",i&&"is-open"),onClick:()=>n(v=>!v),title:"Notifications","aria-label":"Notifications","aria-haspopup":"true","aria-expanded":i,children:[e.jsx(ea,{size:16}),b>0&&e.jsx("span",{className:"notifications-badge",children:b>99?"99+":b})]}),i&&e.jsxs("div",{className:"notifications-panel",role:"dialog","aria-label":"Notifications",children:[e.jsxs("header",{className:"notifications-panel-head",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Notifications"}),b>0&&e.jsxs("span",{className:"muted text-sm",children:[" · ",b," unread"]})]}),e.jsxs("div",{className:"notifications-panel-head-actions",children:[e.jsxs(C,{size:"sm",variant:"ghost",onClick:k,disabled:b===0,children:[e.jsx(Ls,{size:12})," Mark all read"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>n(!1),"aria-label":"Close",title:"Close",children:e.jsx($e,{size:14})})]})]}),e.jsx("div",{className:"notifications-list",children:h&&o.length===0?e.jsx("div",{className:"notifications-empty muted",children:"Loading…"}):o.length===0?e.jsx("div",{className:"notifications-empty muted",children:"No notifications yet."}):o.map(v=>{const y=Cn[v.severity]||Ns;return e.jsxs("div",{className:ne("notification-item",!v.read&&"is-unread",`severity-${v.severity}`),children:[e.jsx(y,{size:14,className:`notification-icon severity-${v.severity}`}),e.jsxs("div",{className:"notification-body",children:[v.title&&e.jsx("div",{className:"notification-title",children:v.title}),e.jsx("div",{className:"notification-msg",children:v.message}),e.jsxs("div",{className:"notification-meta muted",children:[e.jsx("span",{className:"mono",children:v.source}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ve(v.ts)})]})]}),e.jsxs("div",{className:"notification-actions",children:[!v.read&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>f(v.id),title:"Mark as read","aria-label":"Mark as read",children:e.jsx(Ls,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",onClick:()=>S(v.id),title:"Remove","aria-label":"Remove",children:e.jsx($e,{size:12})})]})]},v.id)})}),e.jsx("footer",{className:"notifications-panel-foot",children:e.jsx("span",{className:"muted text-sm",children:l?`${l.total} total · last ${ve(l.lastTs||new Date().toISOString())}`:""})})]})]})}function Mn({data:s,onClose:t}){const a=s==null?void 0:s.enabled;s==null||s.previousEnabled;const i=s==null?void 0:s.mode,n=s==null?void 0:s.defaultTemplate,o=s==null?void 0:s.lastUsedSlug,d=i==="toggle";return e.jsxs("div",{children:[d?e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Visual plan mode has been ",e.jsx("strong",{children:a?"enabled":"disabled"}),".",a?" The agent will create a plan and wait for your feedback on complex tasks.":" The agent will work without a visual plan canvas."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:8,fontWeight:600},children:["Visual Plan: ",e.jsx("span",{style:{color:a?"var(--color-success)":"var(--color-muted)"},children:a?"ON":"OFF"})]}),e.jsx("p",{style:{lineHeight:1.6,color:"var(--color-muted)",fontSize:13},children:"When enabled, the agent creates a visual plan and waits for your feedback before proceeding with complex tasks."}),n&&e.jsxs("p",{style:{marginTop:8,fontSize:13,color:"var(--color-muted)"},children:["Default template: ",e.jsx("code",{children:n})]}),o&&e.jsxs("p",{style:{fontSize:13,color:"var(--color-muted)"},children:["Last used plan: ",e.jsx("code",{children:o})]}),e.jsxs("p",{style:{marginTop:12,fontSize:13,color:"var(--color-muted)"},children:["Use ",e.jsx("code",{children:"/visual-plan on"})," or ",e.jsx("code",{children:"/visual-plan off"})," to toggle."]})]}),e.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:e.jsx(C,{variant:"ghost",onClick:t,children:"Close"})})]})}const Tn=["blank","feature-design","bug-investigation","decision-record","horizontal","vertical"];function An({data:s,onClose:t}){const a=(s==null?void 0:s.templates)??Tn,i=(s==null?void 0:s.defaultTemplate)??"blank",[n,o]=r.useState(""),[d,l]=r.useState(i),[p,h]=r.useState(!1),[g,m]=r.useState(null),c=async()=>{if(!n.trim()){m("Slug is required.");return}if(!/^[a-z0-9][a-z0-9-]{0,63}$/.test(n)){m("Invalid slug. Use lowercase letters, numbers, and hyphens. Must start with an alphanumeric character.");return}h(!0),m(null);try{await M.post("/artifacts",{slug:n,template:d}),t()}catch(u){m(u.message),h(!1)}};return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:["Create a new visual plan. Plans are stored in ",e.jsx("code",{children:"artifacts/"})," in your worktree."]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-slug",children:"Plan slug"}),e.jsx("input",{id:"plan-slug",className:"input",type:"text",placeholder:"e.g. my-feature",value:n,onChange:u=>{o(u.target.value),m(null)},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-template",children:"Template"}),e.jsx("select",{id:"plan-template",className:"select",value:d,onChange:u=>l(u.target.value),children:a.map(u=>e.jsx("option",{value:u,children:u},u))})]}),g&&e.jsx("p",{style:{marginBottom:12,color:"var(--color-danger)",fontSize:13},children:g}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(C,{variant:"ghost",onClick:t,disabled:p,children:"Cancel"}),e.jsx(C,{variant:"primary",onClick:c,disabled:p||!n.trim(),children:p?"Creating…":"Create"})]})]})}function $n({data:s,onClose:t}){const a=(s==null?void 0:s.plans)??[],i=(s==null?void 0:s.count)??a.length,n=o=>{window.open(`/artifacts/${o}/`,"_blank")};return e.jsxs("div",{children:[a.length===0?e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:["No plans found in this worktree. Use ",e.jsx("code",{children:"/artifact new <slug>"})," to create one."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:12,fontSize:13,color:"var(--color-muted)"},children:[i," plan",i!==1?"s":""," in this worktree:"]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:a.map(o=>e.jsxs("li",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 0",borderBottom:"1px solid var(--color-border)"},children:[e.jsx("code",{style:{fontSize:13},children:o}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>n(o),children:"Open"})]},o))})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(C,{variant:"ghost",onClick:t,children:"Close"})})]})}function In({data:s,onClose:t}){const a=(s==null?void 0:s.commands)??[],i=(s==null?void 0:s.templates)??[],n=(s==null?void 0:s.statuses)??[];return e.jsxs("div",{children:[a.length>0?e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:16,fontSize:13},children:e.jsx("tbody",{children:a.map(o=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e.jsx("td",{style:{padding:"5px 8px 5px 0",whiteSpace:"nowrap"},children:e.jsx("code",{style:{fontSize:12},children:o.cmd})}),e.jsx("td",{style:{padding:"5px 0",color:"var(--color-muted)"},children:o.desc})]},o.cmd))})}):e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:"No commands available."}),i.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available templates:"}),e.jsx("p",{style:{fontSize:13},children:i.join(", ")})]}),n.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available statuses:"}),e.jsx("p",{style:{fontSize:13},children:n.join(", ")})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(C,{variant:"ghost",onClick:t,children:"Close"})})]})}function Rn({data:s,onClose:t}){const[a,i]=r.useState(!1),[n,o]=r.useState(null),d=async()=>{i(!0),o(null);try{const l=await M.post("/chat/audit",{});o(l)}catch(l){o({ok:!1,findings:[],error:l.message})}finally{i(!1)}};return e.jsx("div",{children:n===null?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:"Run a security audit of your Bizar agent configuration. The audit checks for common misconfigurations, exposed secrets, and insecure defaults."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(C,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(C,{variant:"primary",onClick:d,disabled:a,children:a?"Running…":"Run Audit"})]})]}):e.jsxs(e.Fragment,{children:[n.ok?e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:12,fontWeight:600,color:"var(--color-success)"},children:"Audit passed — no issues found."}),n.findings.length>0&&e.jsx("ul",{style:{marginBottom:16,paddingLeft:20},children:n.findings.map((l,p)=>e.jsx("li",{style:{marginBottom:4,fontSize:13},children:l},p))})]}):e.jsxs("p",{style:{marginBottom:16,color:"var(--color-danger)"},children:["Audit failed: ",n.error??"unknown error"]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(C,{variant:"ghost",onClick:t,children:"Close"})})]})})}function Dn({dialog:s,onClose:t}){if(!s.data)return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:`Command: ${s.command}`}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]});const{message:a,detail:i,url:n}=s.data;return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:a??`Command: ${s.command}`}),i&&e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:i}),n&&e.jsx("p",{style:{marginBottom:16},children:e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]})}function Ln({dialog:s,onClose:t}){switch(s.component){case"visual-artifact":return e.jsx(Mn,{data:s.data,onClose:t});case"artifact-create":return e.jsx(An,{data:s.data,onClose:t});case"artifact-list":return e.jsx($n,{data:s.data,onClose:t});case"help":return e.jsx(In,{data:s.data,onClose:t});case"audit":return e.jsx(Rn,{data:s.data,onClose:t});default:return e.jsx(Dn,{dialog:s,onClose:t})}}function te({variant:s="elevated",interactive:t=!1,className:a,children:i,...n}){return e.jsx("div",{className:ne("card",`card-${s}`,t&&"card-interactive",a),...n,children:i})}function ie({children:s,className:t}){return e.jsx("h3",{className:ne("card-title",t),children:s})}function re({children:s,className:t}){return e.jsx("div",{className:ne("card-meta",t),children:s})}function Ie({icon:s,title:t,message:a,action:i,className:n}){return e.jsxs("div",{className:ne("empty-state",n),children:[e.jsx("div",{className:"empty-icon",children:s??e.jsx(vs,{size:32})}),e.jsx("div",{className:"empty-title",children:t}),a&&e.jsx("div",{className:"empty-message",children:a}),i&&e.jsx("div",{className:"empty-action",children:i})]})}function Pn({snapshot:s,settings:t,setActiveTab:a,refreshSnapshot:i}){var X,ae,se;const n=oe(),o=ke(),d=r.useRef(null),[l,p]=r.useState(s.overview??null),[h,g]=r.useState(!s.overview),[m,c]=r.useState(s.projects||[]),[u,k]=r.useState(((X=s.activeProject)==null?void 0:X.id)||null),[f,S]=r.useState(s.mods||[]),[b,v]=r.useState(!1),[y,T]=r.useState(((ae=s.overview)==null?void 0:ae.recentActivity)??[]),[x,E]=r.useState(!1),[q,I]=r.useState(new Set);r.useEffect(()=>{let H=!1;return(async()=>{try{const F=await M.get("/activity/hidden");H||I(new Set(F.hidden||[]))}catch{}})(),()=>{H=!0}},[]);const J=(H,F)=>{const P=`${H.kind||""}|${H.ts||""}|${H.slug||H.title||""}|${F}`;let A=0;for(let D=0;D<P.length;D++)A=(A<<5)-A+P.charCodeAt(D)|0;return Math.abs(A).toString(16).padStart(8,"0").slice(0,16)},R=async H=>{const F=new Set(q);F.add(H),I(F);try{await M.post("/activity/hide",{keys:[H]})}catch(P){const A=new Set(q);I(A),n.error(`Hide failed: ${P.message}`)}},L=async()=>{if(!confirm("Hide every recent activity item from the overview? The full log stays in Settings → Activity Log."))return;const H=y.map((P,A)=>J(P,A)),F=new Set(q);H.forEach(P=>F.add(P)),I(F);try{await M.post("/activity/hide",{keys:H}),n.success(`Hidden ${H.length} item(s). Restore them in Settings → Activity Log.`)}catch(P){n.error(`Clear failed: ${P.message}`)}},W=async()=>{I(new Set);try{await M.del("/activity/hide"),n.success("All hidden activity restored to the overview.")}catch(H){n.error(`Restore failed: ${H.message}`)}};r.useEffect(()=>{var H;s.overview&&(p(s.overview),T(s.overview.recentActivity??[]),g(!1)),c(s.projects||[]),k(((H=s.activeProject)==null?void 0:H.id)||null),S(s.mods||[])},[s.overview,s.projects,s.activeProject,s.mods]),r.useEffect(()=>{let H;try{const F=M.getToken(),P=F?`/api/activity/stream?token=${encodeURIComponent(F)}`:"/api/activity/stream";H=new EventSource(P),H.addEventListener("snapshot",A=>{try{const D=JSON.parse(A.data);T(Array.isArray(D.events)?D.events.slice(0,50):[])}catch{}}),H.addEventListener("activity",A=>{try{const D=JSON.parse(A.data);T(Q=>[D,...Q].slice(0,50))}catch{}})}catch{}return()=>{try{H==null||H.close()}catch{}}},[]);const G=async()=>{n.info("Refreshing…",1500),await i();try{const H=await M.get("/projects");c(H.projects||[]),k(H.active||null)}catch{}},w=()=>{o.open({title:"Add project",children:e.jsx(En,{settings:t,onAdd:async(H,F)=>{try{const P=await M.post("/projects",{path:H,name:F});c(A=>[...A.filter(D=>D.id!==P.id),P]),n.success("Project added."),o.close()}catch(P){n.error(`Add failed: ${P.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(C,{variant:"ghost",onClick:()=>o.close(),children:"Cancel"})})})},$=async()=>{var H;try{const F=await M.post("/projects/auto-detect");c(F.projects||[]),k(F.active||null);const P=(H=F.projects)==null?void 0:H.find(A=>A.id===F.active);n.success(P?`Active: ${P.name}`:"Projects refreshed."),await i()}catch(F){n.error(`Auto-detect failed: ${F.message}`)}},V=async H=>{try{await M.post(`/projects/${encodeURIComponent(H)}/activate`),k(H),n.success("Project activated."),await i()}catch(F){n.error(`Activate failed: ${F.message}`)}},K=async H=>{if(confirm(`Remove project "${H}" from the registry?`))try{await M.del(`/projects/${encodeURIComponent(H)}`),c(F=>F.filter(P=>P.id!==H)),u===H&&k(null),n.success("Project removed.")}catch(F){n.error(`Remove failed: ${F.message}`)}};return h||!l?e.jsxs("div",{className:"view-loading",children:[e.jsx(ge,{size:"lg"}),e.jsx("p",{children:"Loading overview…"})]}):e.jsxs("div",{className:"view view-overview",children:[e.jsxs("div",{className:"overview-hero-noframe",children:[e.jsx("h1",{children:"What do you want to do?"}),e.jsx("p",{className:"overview-hero-subtitle",children:"Describe what you want — Odin will split it into tasks, create a plan, delegate to background agents, and track progress in real time."}),e.jsxs("form",{className:"overview-hero-form-noframe",onSubmit:async H=>{var P,A;H.preventDefault();const F=(((P=d.current)==null?void 0:P.value)||"").trim();if(F){v(!0);try{const D=await M.post("/tasks/submit",{title:F});n.success(`Odin split it into ${((A=D.subtasks)==null?void 0:A.length)||1} task(s)`),d.current&&(d.current.value=""),await i()}catch(D){n.error(`Failed: ${D.message}`)}finally{v(!1)}}},children:[e.jsx("textarea",{ref:d,className:"overview-input-hero",placeholder:"e.g. Implement user authentication with email + password, including registration, login, password reset, and integration tests. Use Bcrypt, JWT tokens, and the existing API style.",disabled:b}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-2)",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs(C,{type:"submit",variant:"primary",size:"lg",disabled:b,children:[b?e.jsx(ge,{size:"sm"}):e.jsx(Qe,{size:16}),"Submit to Odin"]}),e.jsxs("span",{className:"muted",style:{fontSize:12},children:[e.jsx(Me,{size:12,style:{display:"inline",verticalAlign:-2,color:"var(--accent)"}})," ","Odin + 12 specialist agents available"]})]})]}),e.jsx("div",{className:"overview-quick-actions-row",children:["Implement feature","Fix bug","Refactor","Investigate","Add tests","Document","Optimize","Deploy"].map(H=>e.jsx("button",{type:"button",className:"overview-quick-chip",onClick:()=>{d.current&&(d.current.value=H,d.current.focus())},children:H},H))})]}),e.jsxs("div",{className:"overview-feed",children:[e.jsxs("div",{className:"overview-feed-head",children:[e.jsx("h2",{children:"Recent activity"}),e.jsxs("div",{className:"overview-feed-head-actions",children:[q.size>0&&e.jsxs(C,{variant:"ghost",size:"sm",onClick:W,title:"Restore hidden items to this overview",children:[e.jsx(ls,{size:12})," Show ",q.size," hidden"]}),y.length>8&&e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>E(H=>!H),children:x?"Show less":"Show all"}),y.length>0&&e.jsxs(C,{variant:"ghost",size:"sm",onClick:L,title:"Hide every item from the overview (full log kept)",children:[e.jsx(lt,{size:12})," Hide all"]})]})]}),q.size>0&&e.jsxs("div",{className:"activity-hidden-banner",role:"status",children:[e.jsxs("span",{children:[e.jsx(lt,{size:12,style:{verticalAlign:-2,marginRight:6}}),q.size," item",q.size===1?"":"s"," hidden from the overview."]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:W,children:[e.jsx(ls,{size:12})," Show them again"]})]}),y.length===0?e.jsx("div",{className:"muted",style:{padding:"24px 0",fontSize:13},children:"No activity yet. Use the chat above or invoke a Bizar command to start a feed."}):e.jsxs("div",{className:ne("activity-feed-list-wrap",!x&&"activity-feed-list-wrap-collapsed"),children:[e.jsx("div",{className:"activity-feed-list",children:y.slice(0,30).map((H,F)=>{const P=J(H,F);return q.has(P)?null:e.jsx(Wn,{item:H,activityKey:P,onNavigate:a,onHide:R},`${H.ts}-${F}`)})}),!x&&y.length>8&&e.jsx("div",{className:"activity-feed-fade","aria-hidden":"true"})]})]}),e.jsxs(te,{className:"project-picker",children:[e.jsxs(ie,{children:[e.jsx(Ue,{size:14})," Projects",e.jsxs(C,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:w,children:[e.jsx(pe,{size:12})," Add"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:$,title:"Use the server's working directory",children:[e.jsx(pe,{size:12})," Auto-detect"]}),((se=t==null?void 0:t.dashboard)==null?void 0:se.projectsDirectory)&&e.jsxs(C,{variant:"ghost",size:"sm",title:`Scan ${t.dashboard.projectsDirectory} for projects`,onClick:async()=>{try{const H=await M.post("/projects/scan");H.error?n.error(H.error):n.success(`Added ${H.added.length}, skipped ${H.skipped}.`),await i();const F=await M.get("/projects");c(F.projects||[]),k(F.active||null)}catch(H){n.error(`Scan failed: ${H.message}`)}},children:[e.jsx(Ha,{size:12})," Scan"]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:G,title:"Refresh",children:e.jsx(de,{size:12})})]}),e.jsxs(re,{children:[m.length," project",m.length===1?"":"s"," ·"," ",l.counts.agents," agents ·"," ",l.counts.sessions," session",l.counts.sessions===1?"":"s"]}),m.length===0?e.jsx(Ie,{icon:e.jsx(Ue,{size:32}),title:"No projects yet",message:"Add a project to start tracking its tasks, plans, and schedules.",action:e.jsxs("div",{className:"empty-state-actions",children:[e.jsxs(C,{variant:"primary",onClick:$,children:[e.jsx(pe,{size:14})," Use current directory"]}),e.jsx(C,{variant:"secondary",onClick:w,children:"Add by path…"})]})}):e.jsx("div",{className:"project-grid",children:m.map(H=>e.jsx(On,{project:H,active:u===H.id,onOpen:()=>V(H.id),onRemove:()=>K(H.id)},H.id))})]}),e.jsxs("div",{className:"overview-cols",children:[e.jsxs(te,{children:[e.jsx(ie,{children:"Mods"}),e.jsxs(re,{children:["Extensions installed under ",e.jsx("code",{children:"~/.config/bizar/mods/"})]}),f.length===0?e.jsx("div",{className:"muted",children:"No mods installed."}):e.jsx("ul",{className:"mod-mini-list",children:f.map(H=>e.jsxs("li",{className:"mod-mini",children:[e.jsx("span",{className:"mod-mini-name",children:H.name}),e.jsxs("span",{className:"mod-mini-meta",children:["v",H.version," · ",H.type]}),e.jsx("span",{className:`mod-mini-pill ${H.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:H.enabled?"on":"off"})]},H.id))})]}),e.jsxs(te,{children:[e.jsx(ie,{children:"Environment"}),e.jsx(re,{children:"Runtime + paths"}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"Node"}),e.jsx("dd",{className:"mono",children:l.versions.node}),e.jsx("dt",{children:"Platform"}),e.jsx("dd",{className:"mono",children:l.versions.platform}),e.jsx("dt",{children:"Project root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.projectRoot,children:l.versions.projectRoot}),e.jsx("dt",{children:"Bizar root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.bizarRoot,children:l.versions.bizarRoot}),e.jsx("dt",{children:"Generated"}),e.jsx("dd",{className:"mono tabular-nums",children:vt(l.generatedAt)})]})]})]})]})}function En({settings:s,onAdd:t}){var m,c;const[a,i]=r.useState(((m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory)??""),[n,o]=r.useState(""),[d,l]=r.useState(!1),[p,h]=r.useState(null),g=async()=>{var u;if(a){l(!0),h(null);try{await M.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(k){const f=k;f.status===404?h("That folder no longer exists. Pick another."):h(((u=f.data)==null?void 0:u.message)??k.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Dt,{value:a,onChange:u=>{i(u),h(null)},projectsDirectory:(c=s==null?void 0:s.dashboard)==null?void 0:c.projectsDirectory,height:320}),p&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:p}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:u=>o(u.target.value)}),e.jsx("p",{className:"field-help",style:{marginTop:4},children:"Display name for this project. Defaults to the folder name."})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(C,{variant:"primary",onClick:g,disabled:!a||d,children:[d?e.jsx("span",{className:"btn-spinner"}):null,d?"Checking…":"Add"]})})]})}function On({project:s,active:t,onOpen:a,onRemove:i}){const n={active:"status-on",inactive:"status-neutral",error:"status-error"}[s.status]||"status-neutral";return e.jsxs("div",{className:`project-card ${t?"project-card-active":""}`,children:[e.jsxs("div",{className:"project-card-head",children:[e.jsx("span",{className:`project-card-status ${n}`,children:s.status}),e.jsx("div",{className:"project-card-name",children:s.name}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Remove project",title:"Remove",onClick:o=>{o.stopPropagation(),i()},children:e.jsx(ye,{size:12})})]}),e.jsx("div",{className:"project-card-path mono ellipsis",title:s.path,children:s.path}),e.jsx("div",{className:"project-card-meta",children:s.lastAccessed&&e.jsxs("span",{className:"muted",children:["Last opened ",ve(s.lastAccessed)]})}),e.jsx("div",{className:"project-card-actions",children:e.jsx(C,{variant:t?"ghost":"primary",size:"sm",onClick:a,children:t?e.jsxs(e.Fragment,{children:[e.jsx(Vs,{size:12})," Active"]}):e.jsx(e.Fragment,{children:"Open"})})})]})}function Bn(s){return s&&s.charAt(0).toUpperCase()+s.slice(1)}function Fn(s){const t=s.trim().toLowerCase().replace(/[:_]/g,"."),[a,i="updated"]=t.split("."),n={settings:"Settings",task:"Task",tasks:"Task",agent:"Agent",agents:"Agent",plan:"Plan",plans:"Plan",bg:"Background job",background:"Background job",session:"Session",mod:"Mod",mods:"Mod",provider:"Provider",providers:"Provider"},o={create:"created",created:"created",add:"added",added:"added",update:"updated",updated:"updated",delegate:"delegated",delegated:"delegated",invoke:"invoked",invoked:"invoked",restart:"restarted",restarted:"restarted",delete:"deleted",deleted:"deleted",remove:"removed",removed:"removed",archive:"archived",archived:"archived",restore:"restored",restored:"restored",complete:"completed",completed:"completed",fail:"failed",failed:"failed",error:"errored",stuck:"marked stuck"},d=n[a]||Bn(a.replace(/-/g," ")),l=o[i]||i.replace(/-/g," ");return`${d} ${l}`.trim()}function us(s,t){for(const a of t){const i=s[a];if(typeof i=="string"&&i.trim())return i.trim()}return""}function Un(s){const t=us(s,["message","text","prompt","title","name"]);if(t)return t;const a=[],i=us(s,["slug"]),n=us(s,["agent","author"]),o=us(s,["status"]);return i&&a.push(`Plan ${i}`),n&&a.push(n),o&&a.push(o),a.length?a.join(" · "):"No additional details."}function Hn(s){return ve(s)}function _n(s){const t=(s.kind||"").toLowerCase(),a=(s.status||"").toLowerCase();return t.includes("error")||a==="error"||a==="failure"?"error":t.includes("warn")||a==="blocked"?"warning":t.includes("done")||t.includes("success")||a==="done"?"success":"info"}function qn(s){const t=s.toLowerCase();return t==="task"?Oe:t==="agent"?Ee:t==="plan"?cs:t.includes("bg")||t.includes("background")||t.includes("job")?mn:t==="mod"?ys:t==="skill"?Me:t.includes("error")||t.includes("failure")?Ja:t.includes("warn")?De:ze}function Vn(s){const t=s.toLowerCase();return t==="task"?"tasks":t==="agent"?"agents":t==="plan"?"artifacts":t.includes("bg")||t.includes("background")?"activity":t==="mod"?"mods":t==="skill"?"skills":null}function Wn({item:s,activityKey:t,onNavigate:a,onHide:i}){const n=_n(s),o=qn(s.kind||""),d=Fn(s.kind||"activity"),l=Un(s),p=Vn(s.kind||""),h=n==="error"?"var(--error)":n==="warning"?"var(--warning)":n==="success"?"var(--success)":"var(--accent)";return e.jsxs("div",{className:ne("activity-feed-row",`activity-feed-row-${n}`),children:[e.jsxs("button",{type:"button",className:"activity-feed-row-main",onClick:()=>{p&&a(p)},title:p?`Open ${p}`:d,children:[e.jsx("div",{className:"activity-feed-icon",style:{color:h},children:e.jsx(o,{size:14})}),e.jsxs("div",{className:"activity-feed-body",children:[e.jsxs("div",{className:"activity-feed-title-row",children:[e.jsx("div",{className:"activity-feed-title",children:d}),e.jsx("div",{className:"activity-feed-time text-xs muted tabular-nums",children:Hn(s.ts)})]}),e.jsx("div",{className:"activity-feed-summary text-sm",children:l})]})]}),e.jsx("button",{type:"button",className:"activity-feed-hide-btn",onClick:()=>i(t),title:"Hide this from the overview (kept in Settings → Activity Log)","aria-label":"Hide from overview",children:e.jsx($e,{size:12})})]})}function Kn({session:s,mode:t,anchor:a,renameDraft:i,setRenameDraft:n,onEdit:o,onDeleteRequest:d,onConfirmDelete:l,onConfirmRename:p,onClose:h}){const g=r.useRef(null),m=Math.round(a.rect.bottom+2),c=Math.max(8,Math.round(window.innerWidth-a.rect.right));r.useEffect(()=>{const k=b=>{const v=b.target;!g.current||!v||g.current.contains(v)||h()},f=b=>{b.key==="Escape"&&h()},S=window.setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",f)},0);return()=>{window.clearTimeout(S),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",f)}},[h]),r.useEffect(()=>{if(t!=="rename")return;const k=window.setTimeout(()=>{var S;const f=(S=g.current)==null?void 0:S.querySelector("input.session-row-menu-input");f==null||f.focus(),f==null||f.select()},0);return()=>window.clearTimeout(k)},[t]);const u=e.jsxs("div",{ref:g,className:"session-row-menu",role:"menu","aria-label":`Options for ${s.title}`,style:{position:"fixed",top:m,right:c},onClick:k=>k.stopPropagation(),children:[t==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"session-row-menu-item",role:"menuitem",onClick:k=>{k.stopPropagation(),o()},children:[e.jsx(ln,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Rename"}),e.jsx("kbd",{children:"R"})]}),e.jsxs("button",{type:"button",className:"session-row-menu-item session-row-menu-item-danger",role:"menuitem",onClick:k=>{k.stopPropagation(),d()},children:[e.jsx(ye,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Delete"}),e.jsx("kbd",{children:"⌫"})]})]}),t==="rename"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Rename session"}),e.jsx("input",{type:"text",className:"session-row-menu-input",value:i,onChange:k=>n(k.target.value),onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),p()):k.key==="Escape"&&(k.preventDefault(),h())},onClick:k=>k.stopPropagation(),"aria-label":"New session name"}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:k=>{k.stopPropagation(),h()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:k=>{k.stopPropagation(),p()},children:"Save"})]})]}),t==="confirm-delete"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Delete this session?"}),e.jsxs("div",{className:"session-row-menu-inline-message",children:['"',s.title,'" and its sub-agents will be removed.']}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:k=>{k.stopPropagation(),h()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:k=>{k.stopPropagation(),l()},children:"Delete"})]})]})]});return sa.createPortal(u,document.body)}function Fs({node:s,depth:t=0,collapsible:a=!1,isLast:i=!0,open:n,onToggle:o}){var u;const[d,l]=r.useState(a),p=n!==void 0,h=p?n:d,g=k=>{p||l(k),o==null||o(k)},m=(((u=s.children)==null?void 0:u.length)??0)>0,c=e.jsxs(e.Fragment,{children:[a&&e.jsx("span",{className:`agent-node-chevron ${h?"open":""}`,"aria-hidden":!0,children:"›"}),e.jsx("span",{className:`agent-node-dot status-${s.status}`,"aria-hidden":!0}),e.jsx("span",{className:"agent-node-name",children:s.name}),s.role&&e.jsx("span",{className:"agent-node-role chat-mono",children:s.role}),e.jsx("span",{className:`agent-node-pill status-${s.status}`,children:s.status})]});return e.jsxs("div",{className:["agent-node",`depth-${t}`,`status-${s.status}`,h?"open":"closed",i?"last":""].filter(Boolean).join(" "),children:[a?e.jsx("button",{type:"button",className:`agent-node-head status-${s.status} collapsible`,onClick:k=>{k.stopPropagation(),g(!h)},"aria-expanded":h,children:c}):e.jsx("div",{className:`agent-node-head status-${s.status}`,children:c}),h&&e.jsxs(e.Fragment,{children:[s.summary&&e.jsx("div",{className:"agent-node-summary",children:s.summary}),m&&e.jsx("div",{className:"agent-node-children",children:s.children.map((k,f)=>e.jsx(Fs,{node:k,depth:t+1,collapsible:!1,isLast:f===s.children.length-1},k.id))})]})]})}function Gn(s){return s.tree!==void 0}function Yn(s){const t=s.open??!0;if(Gn(s))return e.jsx("div",{className:`agent-tree variant-${s.variant??"full"}`,children:e.jsx(Fs,{node:s.tree.root,depth:0,open:t})});const a=s.children??[];return e.jsx("div",{className:`agent-tree variant-${s.variant} agent-tree-children-only`,children:e.jsx("div",{className:"agent-tree-children-body",children:a.map((i,n)=>e.jsx(r.Fragment,{children:e.jsx(Fs,{node:i,depth:0,collapsible:!1,open:t,isLast:n===a.length-1})},i.id))})})}function Jn({children:s,variant:t="rail",open:a=!0}){return a?e.jsx(Yn,{variant:t,open:a,children:s}):null}const Xn=["Today","Yesterday","This week","Earlier"];function ot(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function Qn(s,t){const a=s.getTime()-t.getTime();return Math.floor(a/(1e3*60*60*24))}function Zn(s){const t=new Date,a=new Date(t);a.setDate(a.getDate()-1);const i=new Date(t);i.setDate(i.getDate()-7);const n={Today:[],Yesterday:[],"This week":[],Earlier:[]};for(const o of s){const d=new Date(Number(o.mtime)||Date.now());ot(d,t)?n.Today.push(o):ot(d,a)?n.Yesterday.push(o):Qn(t,d)<7?n["This week"].push(o):n.Earlier.push(o)}return n}function ei(s){return new Date(Number(s)||Date.now()).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function si({state:s,agent:t}){return s==="streaming"?e.jsx("span",{className:"session-state session-state-streaming",title:`${t||"Odin"} is typing…`}):s==="awaiting"?e.jsx("span",{className:"session-state session-state-awaiting",title:"Awaiting your reply","aria-hidden":!0}):s==="idle"?e.jsx("span",{className:"session-state session-state-idle","aria-hidden":!0}):null}function ti({sessions:s,opencodeSessions:t=[],activeSessionId:a,activeOpencodeSessionId:i,activeProject:n,creating:o,onCreateSession:d,onSelectSession:l,onSelectOpencodeSession:p,onRenameSession:h,onDeleteSession:g,groupBy:m}){var K;const c=r.useMemo(()=>[...s,...t],[s,t]),u=r.useMemo(()=>[...c].sort((X,ae)=>Number(ae.mtime??0)-Number(X.mtime??0)),[c]),k=r.useMemo(()=>m?m(u):Zn(u),[m,u]),[f,S]=r.useState({}),b=X=>f[X]===!0,[v,y]=r.useState(null),[T,x]=r.useState("main"),[E,q]=r.useState(""),[I,J]=r.useState(null),R=r.useRef({}),L=(X,ae="main")=>{const se=R.current[X];if(!se)return;const H=ae==="main"?se:se.querySelector(".chat-rail-item-menu-trigger")??se;if(J({id:X,rect:H.getBoundingClientRect()}),y(X),x(ae),ae==="rename"){const F=[...s,...t].find(P=>P.id===X);q((F==null?void 0:F.title)??(F==null?void 0:F.id)??"")}},W=()=>{y(null),x("main"),q(""),J(null)},G=X=>{if(X.source==="opencode"){p(X);return}l(X.id)},w=()=>{if(!I)return;const X=I.id,ae=E.trim();if(!ae){W();return}h==null||h(X,ae),W()},$=()=>{I&&(g==null||g(I.id),W())},V=m?Object.entries(k):Xn.filter(X=>{var ae;return(ae=k[X])==null?void 0:ae.length}).map(X=>[X,k[X]]);return e.jsxs("aside",{className:"chat-rail",children:[e.jsx("div",{className:"chat-rail-head",children:e.jsxs("button",{type:"button",className:"chat-new-btn",onClick:d,disabled:o||!n,title:n?"Create new session":"Pick a project first","aria-label":"Create new session",children:[e.jsx(pe,{size:14,"aria-hidden":!0}),e.jsx("span",{children:o?"Creating…":"New session"})]})}),u.length===0?e.jsx("div",{className:"chat-sessions-empty",children:e.jsx(ta,{icon:e.jsx(pe,{size:20,"aria-hidden":!0}),title:n?"No sessions yet":"No project",message:n?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions."})}):e.jsx("div",{className:"chat-rail-list",children:V.map(([X,ae])=>e.jsxs("div",{className:"chat-rail-group",children:[e.jsx("div",{className:"chat-rail-group-label",children:X}),ae.map(se=>{var Q,z;const H=se.source==="opencode",F=H?i===se.id:a===se.id,P=se.tree,A=!!((Q=P==null?void 0:P.root)!=null&&Q.children&&P.root.children.length>0),D=b(se.id);return e.jsxs(r.Fragment,{children:[e.jsxs("div",{ref:_=>{R.current[se.id]=_},role:"button",tabIndex:0,className:`chat-rail-item state-${se.state??"idle"}${F?" active":""}`,onClick:()=>G(se),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),G(se))},"aria-current":F?"true":void 0,children:[e.jsx(si,{state:se.state??"idle",agent:se.agent}),e.jsxs("div",{className:"chat-rail-item-title",children:[se.pinned&&e.jsx("span",{className:"chat-rail-pin","aria-hidden":!0,children:"★"}),H&&e.jsx(Ws,{size:11,style:{color:"var(--text-muted)",flexShrink:0},"aria-hidden":!0}),e.jsx("span",{className:"chat-ellipsis",children:se.title||se.id})]}),e.jsxs("div",{className:"chat-rail-item-meta",children:[e.jsx("span",{className:"chat-rail-item-meta-time",children:se.time??ei(se.mtime)}),(se.unread??0)>0&&e.jsx("span",{className:"chat-rail-badge",children:se.unread})]}),e.jsx("button",{type:"button",className:`chat-rail-item-menu-trigger${v===se.id?" open":""}`,"aria-label":`Session options for ${se.title||se.id}`,"aria-haspopup":"menu","aria-expanded":v===se.id,onClick:_=>{_.stopPropagation(),v===se.id?W():L(se.id,"main")},children:e.jsxs("svg",{viewBox:"0 0 14 14","aria-hidden":!0,children:[e.jsx("circle",{cx:"3",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"7",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"11",cy:"7",r:"1.2",fill:"currentColor"})]})}),F&&A&&e.jsx("button",{type:"button",className:`chat-rail-tree-chevron${D?" open":""}`,"aria-label":D?"Collapse sub-agents":"Expand sub-agents","aria-expanded":D,onClick:_=>{_.stopPropagation(),S(O=>({...O,[se.id]:!O[se.id]}))},children:e.jsx("svg",{viewBox:"0 0 10 10","aria-hidden":!0,children:e.jsx("polyline",{points:"3,1.5 7,5 3,8.5"})})})]}),F&&A&&D&&((z=P==null?void 0:P.root)==null?void 0:z.children)&&e.jsx(Jn,{children:P.root.children,variant:"rail",open:!0})]},H?`oc-${se.id}`:se.id)})]},X))}),v&&I&&e.jsx(Kn,{session:{id:I.id,title:((K=[...s,...t].find(X=>X.id===I.id))==null?void 0:K.title)??I.id},mode:T,anchor:I,renameDraft:E,setRenameDraft:q,onEdit:()=>L(v,"rename"),onDeleteRequest:()=>L(v,"confirm-delete"),onConfirmDelete:$,onConfirmRename:w,onClose:W})]})}function ai(s){const{text:t,sending:a,onSend:i}=s,[n,o]=r.useState(!1),d=()=>{t.trim()&&(o(!0),i(),window.setTimeout(()=>o(!1),320))};return e.jsxs("div",{className:"chat-composer-wrap",children:[e.jsx("div",{className:`chat-composer-pill${n?" takeoff":""}`,children:e.jsx(aa,{...s,onSend:d})}),e.jsxs("div",{className:"chat-composer-hint chat-muted",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"⏎"})," send"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"⇧⏎"})," newline"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"/"})," commands"]})]})]})}function As(s){return s.toLocaleString()}function ni({sessionId:s,messages:t,pinned:a,agent:i,model:n,agents:o,mcps:d,allCommands:l}){const p=(t==null?void 0:t.length)??0,h=(a==null?void 0:a.size)??0,g=0,m=128e3;return e.jsxs("aside",{className:"chat-info",children:[e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Session"}),e.jsx("div",{children:s||"Live"}),e.jsxs("div",{className:"chat-info-mono",children:[As(p)," message",p===1?"":"s",h>0&&` · ${h} pinned`]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Agent"}),e.jsx("div",{children:i||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Model"}),e.jsx("div",{className:"chat-mono chat-ellipsis",title:n,children:n||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Tokens"}),e.jsxs("div",{className:"chat-mono",children:[As(g)," / ",As(m)]}),e.jsx("div",{className:"chat-info-bar","aria-hidden":!0,children:e.jsx("div",{className:"chat-info-bar-fill",style:{width:`${Math.min(100,g/Math.max(1,m)*100)}%`}})})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Cost"}),e.jsxs("div",{className:"chat-mono",children:["$",0 .toFixed(4)]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ee,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," Attached agents"]}),o!=null&&o.length?e.jsx("div",{className:"chat-info-agents",children:o.map(u=>e.jsx("span",{className:"chat-info-agent",children:u.name},u.name))}):e.jsx("div",{className:"chat-info-mono",children:"None attached"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Fe,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," MCPs"]}),d!=null&&d.length?e.jsx("div",{className:"chat-info-agents",children:d.map(u=>e.jsx("span",{className:"chat-info-agent",children:u.id},u.id))}):e.jsx("div",{className:"chat-info-mono",children:"No MCPs configured"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(is,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," Slash commands"]}),e.jsxs("div",{className:"chat-info-mono",children:[(l==null?void 0:l.length)??0," available"]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ve,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Linked"]}),e.jsx("div",{className:"chat-info-mono",children:"No links yet"})]})]})}function ii({streaming:s,newMessageCount:t,onClick:a,streamingLabel:i="Odin is replying"}){return e.jsx("button",{type:"button",className:`jump-to-latest${s?" is-streaming":""}`,onClick:a,"aria-label":"Jump to latest message",title:"Jump to latest (⌘/Ctrl+End)",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"jump-dots","aria-hidden":!0,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{children:i}),t>0&&e.jsx("span",{className:"jump-badge jump-badge-live",children:"live"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ma,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Jump to latest"}),t>0&&e.jsxs("span",{className:"jump-badge",children:[t," new"]})]})})}function li({snapshot:s,settings:t,setActiveTab:a,initialTaskId:i,onClearTaskId:n}){const o=oe(),d=ke(),l=na(s,t,i??""),[p,h]=r.useState(""),[g,m]=r.useState(t.defaultAgent||"odin"),[c,u]=r.useState(t.defaultModel||""),[k,f]=r.useState([]),[S,b]=r.useState(!1),v=r.useRef(null),{allCommands:y,suggestions:T,setQuery:x}=ia(s);r.useEffect(()=>{x(p)},[p,x]);const E=()=>{var $;return($=v.current)==null?void 0:$.click()},q=$=>{const V=$.target.files;if(!V)return;const K=[];for(let X=0;X<V.length;X++)K.push(V[X].name);f(X=>{const ae=K.filter(se=>!X.includes(se));return[...X,...ae]}),v.current&&(v.current.value="")},I=()=>{const $=p.trim();$&&(h(""),x(""),l.onSend($,g,c,k),l.jumpToLatest())},J=async()=>{if(!S){if(!s.activeProject){o.warning("Pick a project in Overview to scope chat sessions.",4e3);return}b(!0);try{const $=await fetch("/chat/sessions",{method:"POST"}).then(V=>V.json());l.loadChat($.id),o.success(`Session ${$.id} created.`)}catch($){o.error(`Create failed: ${$.message}`)}finally{b(!1)}}},R=$=>{d.open({title:"Delete message?",children:e.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>d.close(),children:"Cancel"}),e.jsx(C,{variant:"danger",size:"sm",onClick:()=>{d.close(),l.deleteMessage($)},children:"Delete"})]})})},L=r.useMemo(()=>l.sessions.map($=>l.getSessionDisplay($)),[l.sessions,l.getSessionDisplay]),W=r.useMemo(()=>l.opencodeSessions.map($=>l.getSessionDisplay($)),[l.opencodeSessions,l.getSessionDisplay]),G=r.useMemo(()=>{const $=l.activeSource==="opencode"?l.activeOpencodeSessionId??"":l.sessionId;return $?L.find(V=>V.id===$)??W.find(V=>V.id===$)??null:null},[l.activeSource,l.activeOpencodeSessionId,l.sessionId,L,W]),w=(()=>{var K;const $=`${g||"Odin"} · ${((K=s.activeProject)==null?void 0:K.name)??"no project"}`,V=(G==null?void 0:G.state)??"idle";return V==="streaming"?`Replying · ${$}`:V==="awaiting"?`Your turn · ${$}`:`${$} · idle`})();return e.jsxs("div",{className:"chat-shell",children:[e.jsx(la,{activeProject:s.activeProject,sessionCount:l.sessions.length,sessionsOpen:!0,infoOpen:!0,onToggleSessions:()=>{},onToggleInfo:()=>{},onOpenOverview:()=>a==null?void 0:a("overview")}),e.jsxs("div",{className:"chat-page",children:[e.jsx(ti,{sessions:L,opencodeSessions:W,activeSessionId:l.sessionId,activeOpencodeSessionId:l.activeOpencodeSessionId,activeProject:s.activeProject,creating:S,onCreateSession:J,onSelectSession:l.selectBizarSession,onSelectOpencodeSession:$=>l.loadOpencodeSession($.id),onRenameSession:($,V)=>l.renameSession($,V),onDeleteSession:$=>l.deleteSession($)}),e.jsxs("section",{className:"chat-thread-section",children:[e.jsxs("div",{className:"chat-thread-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"chat-thread-title",children:(G==null?void 0:G.title)??l.sessionId??"New chat"}),e.jsxs("div",{className:`chat-thread-sub chat-muted state-${(G==null?void 0:G.state)??"idle"}`,children:[e.jsx("span",{className:"chat-thread-dot"}),w]})]}),e.jsx("div",{className:"chat-thread-actions",children:e.jsx("button",{className:"btn btn-ghost",title:"Rename",type:"button",children:e.jsx("span",{className:"mono",children:"rename"})})})]}),e.jsx("div",{className:"chat-thread-scroll",ref:l.listRef,onScroll:l.handleScroll,children:e.jsx(ra,{messages:l.activeSource==="opencode"?l.opencodeMessages:l.bizarMessages,loading:l.loading,activeProject:s.activeProject,sessionId:l.activeSource==="opencode"?l.activeOpencodeSessionId??l.sessionId:l.sessionId,pinned:l.pinned,onPickSuggestion:$=>h($),onCopy:$=>l.copyMessage($),onDelete:R,onTogglePin:l.togglePin,onRegenerate:l.onRegenerate})}),!l.stickToBottom&&e.jsx(ii,{streaming:(G==null?void 0:G.state)==="streaming",newMessageCount:l.newMessageCount,onClick:l.jumpToLatest}),e.jsx(ai,{agent:g,setAgent:m,model:c,setModel:u,text:p,setText:h,sending:l.sending,onSend:I,attachments:k,setAttachments:f,suggestions:T,onPickSuggestion:$=>h(`${$.split(" ")[0]} `),agents:s.agents||[],onAttach:E}),e.jsx("input",{ref:v,type:"file",multiple:!0,style:{display:"none"},onChange:q})]}),e.jsx(ni,{sessionId:l.activeSource==="opencode"?l.activeOpencodeSessionId??l.sessionId:l.sessionId,messages:l.activeSource==="opencode"?l.opencodeMessages:l.bizarMessages,pinned:l.pinned,agent:g,model:c,agents:s.agents||[],mcps:s.mcps||[],allCommands:y})]})]})}function Pe({kind:s="neutral",children:t,className:a,dot:i=!1}){return e.jsxs("span",{className:ne("badge",`badge-${s}`,a),children:[i&&e.jsx("span",{className:"badge-dot"}),t]})}const dt=["bash","read","edit","write","webfetch","websearch","task","glob","grep"],mt=["anthropic/claude-3-5-sonnet","anthropic/claude-3-5-haiku","openai/gpt-4o","openai/gpt-4o-mini","openrouter/minimax/minimax-m3","openrouter/minimax/minimax-m2.7"],xs=[{id:"reasoning",label:"Reasoning",color:"var(--accent)"},{id:"code",label:"Code",color:"var(--info)"},{id:"design",label:"Design",color:"var(--success)"},{id:"planning",label:"Planning",color:"var(--warning)"},{id:"gitops",label:"GitOps",color:"var(--error)"},{id:"analysis",label:"Analysis",color:"var(--text-dim)"}];function ri(s){var t;return((t=xs.find(a=>a.id===s))==null?void 0:t.color)||"var(--text-dim)"}function ci({status:s,isStuck:t}){const a=t?"var(--error)":s==="working"?"var(--info)":s==="error"?"var(--error)":"var(--text-dim)";return e.jsx("span",{className:"agent-status-dot",style:{background:a}})}function oi({agent:s}){if(s.isStuck)return e.jsx(Pe,{kind:"error",dot:!0,children:"stuck"});const t=s.status||"idle";return t==="working"?e.jsx(Pe,{kind:"info",dot:!0,children:"working"}):t==="error"?e.jsx(Pe,{kind:"error",dot:!0,children:"error"}):e.jsx(Pe,{kind:"neutral",dot:!0,children:"idle"})}function di({snapshot:s,refreshSnapshot:t}){const a=oe(),i=ke(),[n,o]=r.useState(s.agents||[]),[d,l]=r.useState(!s.agents),[p,h]=r.useState(""),[g,m]=r.useState("");r.useEffect(()=>{o(s.agents||[]),l(!s.agents)},[s.agents]);const c=async()=>{try{const x=await M.get("/agents");o(x.agents||[])}catch(x){a.error(`Agents load failed: ${x.message}`)}finally{l(!1)}},u=r.useMemo(()=>{let x=[...n];if(p&&(x=x.filter(E=>p==="__none__"?!E.category:(E.category||"")===p)),g){const E=g.toLowerCase();x=x.filter(q=>q.name.toLowerCase().includes(E)||(q.description||"").toLowerCase().includes(E)||(q.tags||[]).some(I=>I.toLowerCase().includes(E)))}return x.sort((E,q)=>E.name.localeCompare(q.name))},[n,p,g]),k=r.useMemo(()=>{const x=new Set;for(const E of n)for(const q of E.tags||[])x.add(q);return Array.from(x).sort()},[n]),f=()=>{let x=null,E=null,q=null,I=null,J=null,R=null,L=null,W=null,G=null;i.open({title:"New agent",width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsx("label",{className:"field-label",children:"Name (a-z, 0-9, dashes)"}),e.jsx("input",{ref:w=>x=w,className:"input",type:"text",placeholder:"my-agent",autoFocus:!0}),e.jsx("label",{className:"field-label",children:"Description"}),e.jsx("input",{ref:w=>{E=w},className:"input",type:"text",placeholder:"What does this agent do?"}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Model"}),e.jsxs("select",{ref:w=>q=w,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(provider default)"}),mt.map(w=>e.jsx("option",{value:w,children:w},w))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Mode"}),e.jsxs("select",{ref:w=>I=w,className:"select",defaultValue:"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",children:"Color"}),e.jsx("input",{ref:w=>J=w,className:"input",type:"color",defaultValue:"#8b5cf6"})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Category"}),e.jsxs("select",{ref:w=>G=w,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(none)"}),xs.map(w=>e.jsx("option",{value:w.id,children:w.label},w.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",children:"Tags (comma-separated)"}),e.jsx("input",{ref:w=>W=w,className:"input",type:"text",placeholder:"reasoning, code, planning"})]})]}),e.jsx("label",{className:"field-label",children:"Tools"}),e.jsx("div",{ref:w=>L=w,className:"agent-tools",children:dt.map(w=>e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:w}),e.jsx("span",{children:w})]},w))}),e.jsx("label",{className:"field-label",children:"System prompt"}),e.jsx("textarea",{ref:w=>R=w,className:"textarea",rows:6,placeholder:"You are a..."})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(C,{variant:"primary",onClick:async()=>{const w=((x==null?void 0:x.value)||"").trim();if(!/^[a-z0-9][a-z0-9-]{0,63}$/i.test(w)){a.warning("Invalid name (a-z, 0-9, dashes).");return}const $=[];L&&L.querySelectorAll('input[type="checkbox"]:checked').forEach(K=>{$.push(K.value)});const V=((W==null?void 0:W.value)||"").split(",").map(K=>K.trim()).filter(Boolean);try{const K=await M.post("/agents",{name:w,description:((E==null?void 0:E.value)||"").trim(),model:(q==null?void 0:q.value)||"",mode:(I==null?void 0:I.value)||"subagent",color:(J==null?void 0:J.value)||"",tools:$,tags:V,category:(G==null?void 0:G.value)||"",prompt:(R==null?void 0:R.value)||""});o(X=>[...X,K]),a.success("Agent created."),i.close(),await t()}catch(K){a.error(`Create failed: ${K.message}`)}},children:[e.jsx(Ze,{size:12})," Create"]})]})})},S=async x=>{let E=null,q=null,I=null,J=null,R=null,L=null,W=null,G=null;try{const w=await M.get(`/agents/${encodeURIComponent(x.name)}`);i.open({title:`Edit ${x.name}`,width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsxs("div",{className:"muted",children:["File: ",e.jsx("code",{children:w.path})]}),e.jsx("label",{className:"field-label",children:"Description"}),e.jsx("input",{ref:$=>{E=$},className:"input",type:"text",defaultValue:w.description}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Model"}),e.jsxs("select",{ref:$=>q=$,className:"select",defaultValue:w.model,children:[e.jsx("option",{value:"",children:"(provider default)"}),mt.map($=>e.jsx("option",{value:$,children:$},$))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Mode"}),e.jsxs("select",{ref:$=>I=$,className:"select",defaultValue:w.mode||"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",children:"Color"}),e.jsx("input",{ref:$=>J=$,className:"input",type:"color",defaultValue:w.color||"#8b5cf6"})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Category"}),e.jsxs("select",{ref:$=>G=$,className:"select",defaultValue:w.category||"",children:[e.jsx("option",{value:"",children:"(none)"}),xs.map($=>e.jsx("option",{value:$.id,children:$.label},$.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",children:"Tags (comma-separated)"}),e.jsx("input",{ref:$=>W=$,className:"input",type:"text",defaultValue:(w.tags||[]).join(", ")})]})]}),e.jsx("label",{className:"field-label",children:"Tools"}),e.jsx("div",{ref:$=>L=$,className:"agent-tools",children:dt.map($=>{var V;return e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:$,defaultChecked:(V=w.tools)==null?void 0:V.includes($)}),e.jsx("span",{children:$})]},$)})}),e.jsx("label",{className:"field-label",children:"System prompt"}),e.jsx("textarea",{ref:$=>R=$,className:"textarea",rows:8,defaultValue:w.prompt||""})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(C,{variant:"primary",onClick:async()=>{const $=[];L&&L.querySelectorAll('input[type="checkbox"]:checked').forEach(K=>{$.push(K.value)});const V=((W==null?void 0:W.value)||"").split(",").map(K=>K.trim()).filter(Boolean);try{const K=await M.put(`/agents/${encodeURIComponent(x.name)}`,{description:((E==null?void 0:E.value)||"").trim(),model:(q==null?void 0:q.value)||"",mode:(I==null?void 0:I.value)||"subagent",color:(J==null?void 0:J.value)||"",tools:$,tags:V,category:(G==null?void 0:G.value)||"",prompt:(R==null?void 0:R.value)||""});o(X=>X.map(ae=>ae.name===x.name?K:ae)),a.success("Agent saved."),i.close(),await t()}catch(K){a.error(`Save failed: ${K.message}`)}},children:[e.jsx(Ze,{size:12})," Save"]})]})})}catch(w){a.error(`Load failed: ${w.message}`)}},b=async x=>{if(confirm(`Delete agent "${x.name}"? This removes ${x.path}.`))try{await M.del(`/agents/${encodeURIComponent(x.name)}`),o(E=>E.filter(q=>q.name!==x.name)),a.success("Agent deleted.")}catch(E){a.error(`Delete failed: ${E.message}`)}},v=async x=>{let E=null;i.open({title:`Invoke ${x.name}`,children:e.jsxs("div",{className:"invoke-form",children:[e.jsxs("p",{className:"muted invoke-form-meta mono",children:[x.model||"—"," · ",x.path]}),e.jsx("p",{className:"invoke-form-desc",children:x.description}),e.jsx("label",{className:"field-label",htmlFor:"invoke-prompt",children:"Prompt"}),e.jsx("textarea",{ref:q=>E=q,id:"invoke-prompt",className:"textarea",rows:5,placeholder:"What should this agent do?",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(C,{variant:"primary",onClick:async()=>{const q=((E==null?void 0:E.value)||"").trim();if(!q){a.warning("Prompt is required.");return}try{await M.post(`/agents/${encodeURIComponent(x.name)}/invoke`,{prompt:q}),a.success(`Invoked ${x.name}.`),i.close()}catch(I){a.error(`Invoke failed: ${I.message}`)}},children:[e.jsx(Ks,{size:14})," Invoke"]})]})})},y=async x=>{try{const E=await M.post(`/agents/${encodeURIComponent(x.name)}/restart`);o(q=>q.map(I=>I.name===x.name?E:I)),a.success(`${x.name} restarted.`)}catch(E){a.error(`Restart failed: ${E.message}`)}},T=async(x,E)=>{try{const q=await M.post(`/agents/${encodeURIComponent(x.name)}/status`,{status:E});o(I=>I.map(J=>J.name===x.name?q:J))}catch(q){a.error(`Status update failed: ${q.message}`)}};return e.jsxs("div",{className:"view view-agents",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Ee,{size:18})," Agents (",u.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["The Norse pantheon — click ",e.jsx("kbd",{children:"Edit"})," to modify or ",e.jsx("kbd",{children:"Invoke"})," to dispatch."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsx("div",{className:"search-input",children:e.jsx("input",{className:"input",type:"text",placeholder:"Search…",value:g,onChange:x=>m(x.target.value)})}),e.jsxs("select",{className:"select select-sm",value:p,onChange:x=>h(x.target.value),children:[e.jsx("option",{value:"",children:"All categories"}),xs.map(x=>e.jsx("option",{value:x.id,children:x.label},x.id)),e.jsx("option",{value:"__none__",children:"(no category)"})]}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:c,children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(C,{variant:"primary",size:"sm",onClick:f,children:[e.jsx(pe,{size:14})," New agent"]})]})]}),k.length>0&&e.jsxs("div",{className:"agent-tags-row",children:[e.jsx(Os,{size:12}),k.map(x=>e.jsx("span",{className:"tag",children:x},x))]}),d?e.jsx("div",{className:"view-loading",children:e.jsx(ge,{size:"lg"})}):u.length===0?e.jsx(Ie,{icon:e.jsx(Ee,{size:32}),title:"No agents found",message:"Run bizar in the terminal to install Bizar."}):e.jsx("div",{className:"agent-grid",children:u.map(x=>e.jsx(mi,{agent:x,onInvoke:()=>v(x),onEdit:()=>S(x),onDelete:()=>b(x),onRestart:()=>y(x),onSetStatus:E=>T(x,E)},x.name))})]})}function mi({agent:s,onInvoke:t,onEdit:a,onDelete:i,onRestart:n,onSetStatus:o}){const[d,l]=r.useState(!1),p=ri(s.category),h=(s.status==="working"||!!s.currentTaskId)&&!s.isStuck;return e.jsxs(te,{variant:"elevated",interactive:!0,className:ne("agent-card",h&&"is-working",s.isStuck&&"is-stuck"),children:[e.jsxs("div",{className:"agent-card-head",children:[e.jsxs("div",{className:"agent-card-name",children:[e.jsx(ci,{status:s.status,isStuck:s.isStuck}),s.name]}),e.jsxs("div",{className:"agent-card-badges",children:[s.category&&e.jsx("span",{className:"agent-card-category",style:{background:`color-mix(in srgb, ${p} 18%, transparent)`,color:p},children:s.category}),e.jsx(oi,{agent:s})]})]}),e.jsx("p",{className:"agent-card-desc",children:yt(s.description,200)}),e.jsxs("div",{className:"agent-card-meta",children:[e.jsx("span",{className:"mono",title:s.model||"",children:s.model||"—"}),e.jsx("span",{className:"tabular-nums muted",children:ve(s.mtime)})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"agent-card-tags",children:s.tags.map(g=>e.jsx("span",{className:"agent-card-tag",children:g},g))}),(h||s.lastTask)&&e.jsxs("div",{className:"agent-card-activity",children:[s.currentTaskId&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(ze,{size:12}),e.jsx("span",{className:"muted",children:"Working on"}),e.jsx("code",{className:"mono",children:s.currentTaskId})]}),s.lastTask&&!s.currentTaskId&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(ks,{size:12}),e.jsx("span",{className:"muted",children:"Last"}),e.jsx("code",{className:"mono",children:s.lastTask.id}),e.jsx("span",{className:"muted tabular-nums",children:ve(s.lastTask.finishedAt)})]}),s.tasksTotal!=null&&s.tasksTotal>0&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(Ra,{size:12}),e.jsx("span",{className:"muted",children:"Success rate"}),e.jsxs("span",{className:"tabular-nums",children:[Math.round((s.successRate||0)*100),"%"]}),e.jsxs("span",{className:"muted tabular-nums",children:["(",s.tasksSucceeded,"/",s.tasksTotal,")"]})]})]}),s.lastError&&e.jsxs("div",{className:"agent-card-error",children:[e.jsx(De,{size:12}),e.jsxs("span",{className:"muted",children:["Last error: ",s.lastError.message]})]}),e.jsxs("div",{className:"agent-card-actions",children:[e.jsxs(C,{variant:"primary",size:"sm",onClick:t,children:[e.jsx(Ks,{size:12})," Invoke"]}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:a,children:[e.jsx(ds,{size:12})," Edit"]}),(s.isStuck||s.status==="working"||s.status==="error")&&e.jsxs(C,{variant:"ghost",size:"sm",onClick:n,title:"Reset agent status",children:[e.jsx(bt,{size:12})," Restart"]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:i,children:e.jsx(ye,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":d?"Collapse":"Expand",onClick:()=>l(g=>!g),style:{marginLeft:"auto"},children:d?e.jsx(Ae,{size:12}):e.jsx(He,{size:12})})]}),d&&e.jsxs("div",{className:"agent-card-expanded",children:[e.jsxs("div",{className:"agent-card-status-actions",children:[e.jsx("span",{className:"muted text-sm",children:"Set status:"}),e.jsx(C,{variant:s.status==="idle"?"primary":"ghost",size:"sm",onClick:()=>o("idle"),children:"Idle"}),e.jsx(C,{variant:s.status==="working"?"primary":"ghost",size:"sm",onClick:()=>o("working"),children:"Working"}),e.jsx(C,{variant:s.status==="error"?"primary":"ghost",size:"sm",onClick:()=>o("error"),children:"Error"})]}),e.jsxs("div",{className:"agent-card-meta",children:[e.jsx(Ue,{size:11}),e.jsx("code",{className:"mono agent-card-path",children:s.path})]})]})]})}function hi({id:s,children:t}){return e.jsx("div",{id:s,"data-block-id":s,className:ne("glyph-richtext"),style:Pt,children:e.jsx(kt,{remarkPlugins:[Nt],children:t})})}const ui={info:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",border:"var(--info)",fg:"var(--info)",icon:Ns,label:"Note"},warn:{bg:"var(--warning-soft, rgba(251, 191, 36, 0.15))",border:"var(--warning)",fg:"var(--warning)",icon:De,label:"Warning"},success:{bg:"var(--success-soft, rgba(52, 211, 153, 0.15))",border:"var(--success)",fg:"var(--success)",icon:ks,label:"Success"},danger:{bg:"var(--error-soft, rgba(248, 113, 113, 0.12))",border:"var(--error)",fg:"var(--error)",icon:zt,label:"Danger"}};function pi({id:s,tone:t="info",children:a}){const i=ui[t],n=i.icon;return e.jsxs("div",{id:s,"data-block-id":s,className:ne("glyph-callout",`glyph-callout-${t}`),style:{display:"flex",gap:12,padding:"12px 16px",margin:"12px 0",borderLeft:`3px solid ${i.border}`,background:i.bg,borderRadius:8,color:"var(--text)"},role:t==="danger"||t==="warn"?"alert":void 0,children:[e.jsx("div",{style:{flexShrink:0,color:i.fg,paddingTop:2},children:e.jsx(n,{size:18})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,color:i.fg,marginBottom:4},children:i.label}),e.jsx("div",{className:"glyph-richtext",style:{...Pt,fontSize:14},children:e.jsx(kt,{remarkPlugins:[Nt],children:a})})]})]})}function xi({id:s,items:t}){return e.jsx("ul",{id:s,"data-block-id":s,className:"glyph-checklist",style:{listStyle:"none",padding:0,margin:"12px 0",display:"flex",flexDirection:"column",gap:6},children:t.map(a=>e.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"6px 10px",borderRadius:6,background:"var(--bg-elev)",border:"1px solid var(--border)",fontSize:14},children:[e.jsx("span",{"aria-hidden":!0,style:{flexShrink:0,marginTop:1,width:16,height:16,borderRadius:4,border:`1.5px solid ${a.checked?"var(--success)":"var(--border-strong)"}`,background:a.checked?"var(--success)":"transparent",color:"var(--bg)",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:a.checked?e.jsx(Ls,{size:12,strokeWidth:3}):null}),e.jsx("span",{style:{color:a.checked?"var(--text-dim)":"var(--text)",textDecoration:a.checked?"line-through":"none",wordBreak:"break-word"},children:a.label})]},a.id))})}function ji({id:s,columns:t,rows:a}){return e.jsx("div",{id:s,"data-block-id":s,className:"glyph-table-wrap",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"auto",background:"var(--bg-elev)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map((i,n)=>e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",borderBottom:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text-dim)",fontWeight:600,fontSize:12,textTransform:"uppercase",letterSpacing:.3,whiteSpace:"nowrap"},children:i},n))})}),e.jsx("tbody",{children:a.map((i,n)=>e.jsx("tr",{style:{borderTop:n===0?"none":"1px solid var(--border)"},children:i.map((o,d)=>e.jsx("td",{style:{padding:"8px 12px",color:"var(--text)",verticalAlign:"top",wordBreak:"break-word"},children:o},d))},n))})]})})}function gi({id:s,tabs:t}){var o;const[a,i]=r.useState(((o=t[0])==null?void 0:o.id)??""),n=r.useMemo(()=>t.find(d=>d.id===a)??t[0],[t,a]);return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-codetabs",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[e.jsx("div",{role:"tablist",style:{display:"flex",gap:2,padding:4,background:"var(--bg)",borderBottom:"1px solid var(--border)",overflowX:"auto"},children:t.map(d=>{const l=d.id===(n==null?void 0:n.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>i(d.id),style:{padding:"6px 12px",fontSize:12,fontFamily:"var(--font-mono)",borderRadius:6,border:"none",cursor:"pointer",background:l?"var(--bg-elev)":"transparent",color:l?"var(--text-strong)":"var(--text-dim)",boxShadow:l?"0 0 0 1px var(--border)":"none",whiteSpace:"nowrap"},children:[e.jsx("span",{children:d.label}),d.language&&e.jsx("span",{style:{marginLeft:6,color:"var(--text-dim)",fontSize:11},children:d.language})]},d.id)})}),n&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:{margin:0,padding:14,overflowX:"auto",fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},children:e.jsx("code",{children:n.code})}),n.caption&&e.jsx("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",background:"var(--bg)"},children:n.caption})]})]})}function fi({id:s,title:t,question:a,options:i}){return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-decision",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)"},children:[t&&e.jsx("h3",{style:{margin:0,marginBottom:4,fontSize:15,fontWeight:600,color:"var(--text-strong)"},children:t}),a&&e.jsx("p",{style:{margin:0,marginBottom:12,fontSize:13,color:"var(--text-dim)"},children:a}),e.jsx("div",{style:{display:"grid",gap:10,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:i.map(n=>{const o=!!n.recommended;return e.jsxs("div",{style:{position:"relative",padding:12,borderRadius:8,border:o?"2px solid var(--success)":"1px solid var(--border)",background:o?"var(--success-soft)":"var(--bg)"},children:[o&&e.jsx("span",{style:{position:"absolute",top:-10,right:10,padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--bg)",background:"var(--success)",borderRadius:999},children:"Recommended"}),e.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-strong)",marginBottom:4},children:n.label}),e.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:n.detail})]},n.id)})})]})}function vi({id:s,questions:t}){const[a,i]=r.useState({});function n(o,d){i(l=>({...l,[o]:d}))}return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-openquestions",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",display:"flex",flexDirection:"column",gap:14},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-strong)"},children:"Open questions"}),t.map(o=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{htmlFor:`oq-${o.id}`,style:{fontSize:13,color:"var(--text)",fontWeight:500},children:o.label}),o.kind==="choice"&&e.jsxs("select",{id:`oq-${o.id}`,value:a[o.id]??"",onChange:d=>n(o.id,d.target.value),style:ht,children:[e.jsx("option",{value:"",children:"— select —"}),(o.options??[]).map(d=>e.jsx("option",{value:d,children:d},d))]}),o.kind==="text"&&e.jsx("input",{id:`oq-${o.id}`,type:"text",value:a[o.id]??"",onChange:d=>n(o.id,d.target.value),style:ht}),o.kind==="multi"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(o.options??[]).map(d=>{const l=a[o.id]??[],p=l.includes(d);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:p,onChange:()=>{const h=p?l.filter(g=>g!==d):[...l,d];n(o.id,h)}}),e.jsx("span",{children:d})]},d)})})]},o.id))]})}const ht={padding:"6px 10px",fontSize:13,borderRadius:6,border:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text)",fontFamily:"inherit"},yi={added:{bg:"var(--success-soft)",fg:"var(--success)",label:"A"},modified:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",fg:"var(--info)",label:"M"},removed:{bg:"var(--error-soft)",fg:"var(--error)",label:"D"},renamed:{bg:"rgba(139, 92, 246, 0.15)",fg:"var(--accent)",label:"R"}};function bi({id:s,title:t,entries:a}){return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-filetree",style:{margin:"12px 0",padding:t?14:8,border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-elev)"},children:[t&&e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4,marginBottom:8},children:t}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:2},children:a.map(i=>{const n=yi[i.change];return e.jsxs("li",{style:{display:"flex",alignItems:"center",gap:10,padding:"5px 8px",borderRadius:5,fontSize:13},children:[e.jsx("span",{"aria-label":i.change,title:i.change,style:{flexShrink:0,width:22,height:18,borderRadius:4,background:n.bg,color:n.fg,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,fontFamily:"var(--font-mono)"},children:n.label}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)",wordBreak:"break-all",flex:1},children:i.path}),i.note&&e.jsx("span",{style:{fontSize:12,color:"var(--text-dim)"},children:i.note})]},i.path)})})]})}function ki({id:s,filename:t,language:a,mode:i="unified",before:n,after:o}){const d=n.split(`
|
|
332
|
+
`),l=o.split(`
|
|
333
|
+
`),p=e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--bg)",borderBottom:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:[e.jsx(Js,{size:14}),e.jsx("span",{style:{color:"var(--text)"},children:t??"diff"}),a&&e.jsxs("span",{children:["· ",a]}),e.jsx("span",{style:{marginLeft:"auto",textTransform:"uppercase",letterSpacing:.3},children:i})]}),h={margin:0,padding:0,fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},g=(m,c,u)=>{const k={del:"var(--error-soft)",add:"var(--success-soft)",ctx:"transparent"},f={del:"var(--error)",add:"var(--success)",ctx:"var(--text-dim)"};return e.jsxs("div",{style:{display:"flex",padding:"0 12px",background:k[u]},children:[e.jsx("span",{style:{width:18,color:f[u],userSelect:"none",flexShrink:0},children:m}),e.jsx("span",{style:{whiteSpace:"pre",flex:1,overflowX:"auto"},children:c||" "})]})};return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-diff",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[p,i==="unified"?e.jsxs("pre",{style:h,children:[d.map((m,c)=>e.jsx("div",{children:g("-",m,"del")},`b${c}`)),l.map((m,c)=>e.jsx("div",{children:g("+",m,"add")},`a${c}`))]}):e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr"},children:[e.jsx("pre",{style:{...h,borderRight:"1px solid var(--border)"},children:d.map((m,c)=>e.jsx("div",{children:g("-",m,"del")},c))}),e.jsx("pre",{style:h,children:l.map((m,c)=>e.jsx("div",{children:g("+",m,"add")},c))})]})]})}const Ni={up:{fg:"var(--success)",Icon:Ae,label:"trending up"},down:{fg:"var(--error)",Icon:Ae,label:"trending down"},flat:{fg:"var(--text-dim)",Icon:Ya,label:"flat"}};function wi({id:s,label:t,value:a,trend:i,hint:n}){const o=i?Ni[i]:null;return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-stat",style:{padding:14,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",display:"flex",flexDirection:"column",gap:4,minWidth:140},children:[e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4},children:t}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[e.jsx("span",{style:{fontSize:24,fontWeight:700,color:"var(--text-strong)"},children:a}),o&&e.jsx("span",{"aria-label":o.label,style:{display:"inline-flex",alignItems:"center",color:o.fg,transform:o.Icon===Ae&&i==="up"?"rotate(180deg)":void 0},children:e.jsx(o.Icon,{size:14})})]}),n&&e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)"},children:n})]})}const Si={task:{stroke:"var(--info)",fill:"var(--bg-elev)",fg:"var(--text)"},decision:{stroke:"var(--warning)",fill:"var(--bg-elev)",fg:"var(--text)"},note:{stroke:"var(--border-strong)",fill:"var(--bg)",fg:"var(--text-dim)"}},Ne=160,Ce=56,Ke=60,Ge=80;function Ci({id:s,steps:t,connections:a=[]}){if(t.length===0)return e.jsx("div",{id:s,"data-block-id":s,className:"glyph-workflow",children:e.jsx(zi,{id:s})});const i=new Map(t.map(g=>[g.id,g])),n=Mi(t),o=Math.max(...n.map(g=>g.col))+1,d=Math.max(...n.map(g=>g.row))+1,l=o*(Ne+Ke)+Ke,p=d*(Ce+Ge)+Ge;function h(g){if(!i.get(g))return null;const c=n.find(u=>u.id===g);return c?{x:Ke+c.col*(Ne+Ke)+Ne/2,y:Ge+c.row*(Ce+Ge)+Ce/2}:null}return e.jsx("div",{id:s,"data-block-id":s,className:"glyph-workflow",style:{margin:"12px 0",padding:12,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",overflow:"auto"},children:e.jsxs("svg",{role:"img","aria-label":"Workflow diagram",width:l,height:p,style:{display:"block",maxWidth:"100%"},children:[e.jsx("defs",{children:e.jsx("marker",{id:`arrow-${s}`,viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:e.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--text-dim)"})})}),a.map((g,m)=>{const c=h(g.from),u=h(g.to);if(!c||!u)return null;const k=u.x-c.x,f=u.y-c.y,S=k>=0?c.x+Ne/2:c.x-Ne/2,b=k>=0?u.x-Ne/2:u.x+Ne/2,v=f>=0?c.y+Ce/2:c.y-Ce/2,y=f>=0?u.y-Ce/2:u.y+Ce/2,T=(S+b)/2,x=(v+y)/2;return e.jsxs("g",{children:[e.jsx("line",{x1:S,y1:v,x2:b,y2:y,stroke:"var(--text-dim)",strokeWidth:1.5,markerEnd:`url(#arrow-${s})`}),g.label&&e.jsx("text",{x:T,y:x-4,fontSize:10,fill:"var(--text-dim)",textAnchor:"middle",fontFamily:"var(--font-mono)",children:g.label})]},m)}),t.map(g=>{const m=n.find(S=>S.id===g.id);if(!m)return null;const c=Ke+m.col*(Ne+Ke),u=Ge+m.row*(Ce+Ge),k=Si[g.type];if(g.type==="decision"){const S=c+Ne/2,b=u+Ce/2,v=[[S,u],[c+Ne,b],[S,u+Ce],[c,b]].map(y=>y.join(",")).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:v,fill:k.fill,stroke:k.stroke,strokeWidth:2}),e.jsx("foreignObject",{x:c+8,y:b-14,width:Ne-16,height:28,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,fontSize:12,color:k.fg,textAlign:"center",lineHeight:1.2,fontStyle:"italic",height:"100%"},children:[e.jsx(Da,{size:11}),g.label]})})]},g.id)}const f=g.type==="note";return e.jsxs("g",{children:[e.jsx("rect",{x:c,y:u,width:Ne,height:Ce,rx:8,fill:k.fill,stroke:k.stroke,strokeWidth:f?1:2,strokeDasharray:f?"4 3":void 0}),e.jsx("foreignObject",{x:c+6,y:u+6,width:Ne-12,height:Ce-12,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:12,color:k.fg,textAlign:"center",lineHeight:1.25,fontStyle:f?"italic":"normal",height:"100%"},children:[f&&e.jsx(ca,{size:11}),g.label]})})]},g.id)})]})})}function zi({id:s}){return e.jsx("div",{id:s,style:{padding:20,textAlign:"center",color:"var(--text-dim)",fontSize:13},children:"No workflow steps."})}function Mi(s){return s.length===0?[]:s.map((t,a)=>({id:t.id,col:a,row:0}))}const Pt={fontSize:14,lineHeight:1.6,color:"var(--text)"};function Ti({id:s,title:t,x:a,y:i,w:n,h:o,html:d}){return e.jsxs("figure",{id:s,"data-block-id":s,className:"glyph-mockup",style:{width:n,minHeight:o},children:[t&&e.jsx("figcaption",{className:"glyph-mockup-title",children:t}),e.jsxs("div",{className:"glyph-mockup-frame",children:[e.jsxs("div",{className:"glyph-mockup-chrome",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("div",{className:"glyph-mockup-body",dangerouslySetInnerHTML:{__html:d}})]})]})}const Ai={overview:"Overview",implementation:"Implementation plan","implementation-plan":"Implementation plan",questions:"Open questions","open-questions":"Open questions","open-questions-for-you":"Open questions",comments:"Comments",handoff:"Handoff"};function $i(s){const t=[];let a={heading:null,blocks:[]};for(const i of s){const n=Ai[i.id]??null;n?((a.blocks.length>0||a.heading!==null)&&t.push(a),a={heading:n,blocks:[i]}):a.blocks.push(i)}return(a.blocks.length>0||a.heading!==null)&&t.push(a),t}function Ii({slug:s,onClose:t,onCommentAdded:a}){var se,H,F;const i=oe(),[n,o]=r.useState(null),[d,l]=r.useState([]),[p,h]=r.useState(!0),[g,m]=r.useState(null),[c,u]=r.useState(null),[k,f]=r.useState(!1),[S,b]=r.useState(!1),[v,y]=r.useState(null),[T,x]=r.useState(null),[E,q]=r.useState(""),[I,J]=r.useState(null),R=r.useRef(null),L=r.useMemo(()=>n?$i(n.blocks):[],[n]);r.useEffect(()=>{let P=!1;const A=5e3;return(async()=>{h(!0),m(null);try{const D=new Promise((O,j)=>setTimeout(()=>j(new Error("Request timed out after 5s")),A)),[Q,z]=await Promise.race([Promise.all([M.get(`/artifacts/${encodeURIComponent(s)}/render`),M.get(`/artifacts/${encodeURIComponent(s)}`)]),D]);if(P)return;o(Q);const _=(z==null?void 0:z.comments)??[];l(Array.isArray(_)?_:[])}catch(D){if(!P){const Q=D.message;m(Q),u(Q)}}finally{P||h(!1)}})(),()=>{P=!0}},[s]);function W(P){if(!R.current)return;P.preventDefault();const A=R.current.getBoundingClientRect();y({x:P.clientX,y:P.clientY,worldX:P.clientX-A.left,worldY:P.clientY-A.top})}async function G(){if(!(!T||!E.trim()))try{const P=await M.post(`/artifacts/${encodeURIComponent(s)}/comments`,{x:T.worldX,y:T.worldY,text:E.trim(),author:"drb0rk"});l(A=>[...A,{id:P.id??`cmt_${Date.now()}`,x:T.worldX,y:T.worldY,text:E.trim(),author:"drb0rk",created:new Date().toISOString()}]),x(null),q(""),y(null),a==null||a(),i.success("Comment added")}catch(P){i.error(`Failed to add comment: ${P.message}`)}}async function w(){if(!k){f(!0);try{const P=await M.post(`/artifacts/${encodeURIComponent(s)}/submit`,{answers:[],submitter:"drb0rk"});P!=null&&P.ok?(i.success("Sent to agent — feedback.md written, status=review"),a==null||a()):i.error("Submit failed: server did not return ok=true")}catch(P){i.error(`Submit failed: ${P.message}`)}finally{f(!1)}}}function $(){b(P=>!P)}const V=P=>{const A=P.id,D=P.data??{};switch(P.type){case"RichText":return e.jsx(hi,{id:A,children:P.childrenMarkdown??""},A);case"Callout":return e.jsx(pi,{id:A,tone:D.tone??"info",children:P.childrenMarkdown??""},A);case"Checklist":return e.jsx(xi,{id:A,items:D.items??[]},A);case"Table":return e.jsx(ji,{id:A,columns:D.columns??[],rows:D.rows??[]},A);case"CodeTabs":return e.jsx(gi,{id:A,tabs:D.tabs??[]},A);case"Decision":return e.jsx(fi,{id:A,title:D.title,question:D.question,options:D.options??[]},A);case"OpenQuestions":return e.jsx(vi,{id:A,questions:D.questions??[]},A);case"FileTree":return e.jsx(bi,{id:A,title:D.title,entries:D.entries??[]},A);case"Diff":return e.jsx(ki,{id:A,filename:D.filename,language:D.language,mode:D.mode??"unified",before:D.before??"",after:D.after??""},A);case"Stat":return e.jsx(wi,{id:A,label:D.label??"",value:D.value,trend:D.trend,hint:D.hint},A);case"Workflow":return e.jsx(Ci,{id:A,steps:D.steps??[],connections:D.connections},A);case"Mockup":return e.jsx(Ti,{id:A,title:D.title,x:D.x,y:D.y,w:D.w,h:D.h,html:D.html??""},A);case"Diagram":return e.jsx("div",{id:A,className:"glyph-block-placeholder",children:e.jsxs("em",{children:["[Diagram] ",A]})},A)}};if(p)return e.jsx("div",{className:"glyph-renderer glyph-renderer--loading",children:c?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Failed to load glyph."}),e.jsx("pre",{children:c})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ri,{})," Loading glyph…"]})});if(g||!n)return e.jsxs("div",{className:"glyph-renderer glyph-renderer--error",children:[e.jsx("strong",{children:"Failed to load glyph."}),e.jsx("pre",{children:g??"unknown error"})]});const K=((se=n.frontmatter)==null?void 0:se.title)??s,X=((H=n.frontmatter)==null?void 0:H.status)??"draft",ae=d.length;return e.jsxs("div",{className:`glyph-canvas ${S?"glyph-canvas--fullscreen":""}`,ref:R,onContextMenu:W,children:[e.jsxs("div",{className:"glyph-toolbar-floating",children:[e.jsxs("button",{className:"glyph-btn glyph-btn--primary glyph-btn--send",onClick:w,disabled:k,title:"Send comments + question answers to the agent — writes feedback.md, status=review",children:[e.jsx(Qe,{size:14}),e.jsx("span",{children:"Send to agent"}),e.jsx("span",{className:"glyph-btn-badge",children:ae})]}),e.jsx("span",{className:"glyph-toolbar-divider"}),e.jsx("button",{className:"glyph-icon-btn",title:"Share",onClick:()=>{typeof window<"u"&&navigator.clipboard&&(navigator.clipboard.writeText(window.location.href).catch(()=>{}),i.success("Link copied"))},children:e.jsx(an,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"Undo",disabled:!0,children:e.jsx(cn,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"Redo",disabled:!0,children:e.jsx(tn,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:S?"Exit fullscreen":"Fullscreen",onClick:$,children:e.jsx(Ga,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"More",children:e.jsx(La,{size:15})}),e.jsx("span",{className:"glyph-toolbar-divider"}),e.jsxs("button",{className:"glyph-icon-btn",title:"Comment count","aria-label":"Comment count",children:[e.jsx(Ve,{size:15}),e.jsx("span",{className:"glyph-icon-btn-count",children:ae})]}),t&&e.jsx("button",{className:"glyph-icon-btn glyph-icon-btn--close",title:"Close",onClick:t,"aria-label":"Close",children:e.jsx($e,{size:15})})]}),e.jsxs("div",{className:"glyph-canvas-content",children:[e.jsxs("header",{className:"glyph-canvas-title",children:[e.jsx("h1",{className:"glyph-title",children:K}),e.jsxs("div",{className:"glyph-meta",children:[e.jsx("span",{className:`glyph-status glyph-status--${X}`,children:X}),e.jsx("span",{className:"glyph-slug",children:s})]})]}),((F=n.errors)==null?void 0:F.length)>0&&e.jsxs("div",{className:"glyph-errors",children:[e.jsx("strong",{children:"Compiler warnings:"}),e.jsx("ul",{children:n.errors.map((P,A)=>e.jsx("li",{children:P},A))})]}),e.jsx("div",{className:"glyph-sections",children:L.map((P,A)=>e.jsxs("section",{className:`glyph-section ${P.heading?"glyph-section--headed":"glyph-section--plain"}`,children:[P.heading&&e.jsx("h2",{className:"glyph-section-heading",children:P.heading}),e.jsx("div",{className:"glyph-section-blocks",children:P.blocks.map(V)})]},`sec-${A}-${P.heading??"ungrouped"}`))})]}),d.map(P=>e.jsxs("button",{className:`glyph-pin ${I===P.id?"glyph-pin--active":""}`,style:{left:P.x,top:P.y},onClick:A=>{A.stopPropagation(),J(I===P.id?null:P.id)},title:P.text,children:[e.jsx(rt,{size:14}),I===P.id&&e.jsxs("div",{className:"glyph-pin-thread",children:[e.jsx("div",{className:"glyph-pin-text",children:P.text}),e.jsxs("div",{className:"glyph-pin-meta",children:[P.author??"anonymous"," · ",P.created?new Date(P.created).toLocaleString():""]})]})]},P.id)),v&&e.jsx("div",{className:"glyph-ctx-menu",style:{left:v.x,top:v.y},onClick:P=>P.stopPropagation(),children:e.jsxs("button",{className:"glyph-ctx-item",onClick:()=>{x({worldX:v.worldX,worldY:v.worldY}),y(null)},children:[e.jsx(rt,{size:14})," Add comment here"]})}),T&&e.jsx("div",{className:"glyph-modal-overlay",onClick:()=>x(null),children:e.jsxs("div",{className:"glyph-modal",onClick:P=>P.stopPropagation(),children:[e.jsxs("h3",{children:["Add comment at (",Math.round(T.worldX),", ",Math.round(T.worldY),")"]}),e.jsx("textarea",{autoFocus:!0,value:E,onChange:P=>q(P.target.value),placeholder:"What should the agent know about this area?",rows:4,className:"glyph-modal-textarea"}),e.jsxs("div",{className:"glyph-modal-actions",children:[e.jsx("button",{className:"glyph-btn glyph-btn--ghost",onClick:()=>x(null),children:"Cancel"}),e.jsx("button",{className:"glyph-btn glyph-btn--primary",onClick:G,disabled:!E.trim(),children:"Add comment"})]})]})})]})}function Ri(){return e.jsx("span",{className:"glyph-spinner","aria-label":"loading",children:"…"})}function Di(s){switch(s){case"approved":case"done":return"success";case"in-progress":case"doing":return"info";case"rejected":return"error";case"archived":return"warning";case"draft":default:return"neutral"}}function Li({snapshot:s,refreshSnapshot:t}){const a=oe(),[i,n]=r.useState(s.artifacts||[]),[o,d]=r.useState(!s.artifacts),[l,p]=r.useState(null),[h,g]=r.useState(""),[m,c]=r.useState(!1);r.useEffect(()=>{s.artifacts&&(n(s.artifacts),d(!1))},[s.artifacts]);const u=async()=>{try{const b=await M.get("/artifacts");n(b.artifacts||[]),d(!1)}catch(b){a.error(`Artifacts load failed: ${b.message}`),d(!1)}},k=r.useMemo(()=>{let b=i;if(h){const v=h.toLowerCase();b=b.filter(y=>(y.slug||"").toLowerCase().includes(v)||(y.title||"").toLowerCase().includes(v))}return m||(b=b.filter(v=>v.status!=="archived")),b},[i,h,m]),f=async(b,v)=>{try{const y=await M.post("/artifacts",{slug:b,title:v});a.success(`Artifact "${y.slug}" created.`),p(y.slug),await u()}catch(y){a.error(`Create failed: ${y.message}`)}},S=async b=>{if(confirm(`Delete artifact "${b}"? This removes the directory permanently.`))try{await M.del(`/artifacts/${encodeURIComponent(b)}`),a.success("Artifact deleted."),l===b&&p(null),await u()}catch(v){a.error(`Delete failed: ${v.message}`)}};return l?e.jsxs("div",{className:"artifact-glyph-overlay",children:[e.jsx("div",{className:"artifact-glyph-toolbar",children:e.jsxs(C,{variant:"ghost",onClick:()=>{p(null),u()},children:[e.jsx(wt,{size:14})," Back to artifacts"]})}),e.jsx(Ii,{slug:l,onClose:()=>{p(null),u()},onCommentAdded:()=>u()})]}):e.jsxs("div",{className:"view view-artifacts",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(cs,{size:18})," Glyphs (",i.length,")"]}),e.jsx("p",{className:"view-subtitle",children:"Visual artifacts with elements, connections, and threaded comments."})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Be,{size:14}),e.jsx("input",{className:"input",type:"text",placeholder:"Search…",value:h,onChange:b=>g(b.target.value)})]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>c(b=>!b),title:m?"Hide archived":"Show archived",children:[m?e.jsx(fs,{size:14}):e.jsx(gs,{size:14}),m?"Hide archived":"Show archived"]}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:u,children:[e.jsx(de,{size:14})," Refresh"]})]})]}),e.jsx(Pi,{onCreate:f}),o?e.jsx("div",{className:"view-loading",children:e.jsx(ge,{size:"lg"})}):k.length===0?e.jsx(Ie,{icon:e.jsx(cs,{size:32}),title:m?"No artifacts":"No artifacts yet",message:m?"No artifacts match your filter (try Show archived off).":"Create one above to get started."}):e.jsx("div",{className:"artifacts-grid",children:k.map(b=>e.jsx(Ei,{artifact:b,onOpen:()=>p(b.slug),onDelete:()=>S(b.slug)},b.slug))})]})}function Pi({onCreate:s}){const[t,a]=r.useState(""),[i,n]=r.useState("");return e.jsxs(te,{className:"new-artifact",children:[e.jsxs(ie,{children:[e.jsx(pe,{size:14})," New artifact"]}),e.jsx(re,{children:"Slug must be lowercase, may contain hyphens, 1–64 chars."}),e.jsxs("form",{className:"new-artifact-form",onSubmit:o=>{o.preventDefault(),t.trim()&&(s(t.trim(),i.trim()||void 0),a(""),n(""))},children:[e.jsx("input",{className:"input",type:"text",placeholder:"slug (e.g. dashboard-v3.1)",pattern:"[a-z0-9][a-z0-9-]{0,63}",required:!0,value:t,onChange:o=>a(o.target.value)}),e.jsx("input",{className:"input",type:"text",placeholder:"Title (optional)",value:i,onChange:o=>n(o.target.value)}),e.jsx(C,{variant:"primary",type:"submit",children:"Create"})]})]})}function Ei({artifact:s,onOpen:t,onDelete:a}){const i=Di(s.status||"draft");return e.jsxs(te,{variant:"elevated",interactive:!0,className:"artifact-card",onClick:t,children:[e.jsxs("div",{className:"artifact-card-head",children:[e.jsx("div",{className:"artifact-card-title",children:s.title||s.slug}),e.jsx(Pe,{kind:i,children:s.status||"draft"})]}),e.jsxs("div",{className:"artifact-card-slug mono",children:[s.slug," · ",s.source]}),e.jsxs("div",{className:"artifact-card-meta",children:[s.elementCount!=null&&e.jsxs("span",{children:[s.elementCount," elements"]}),s.commentCount!=null&&e.jsxs("span",{children:[" · ",s.commentCount," comments"]}),e.jsxs("span",{children:[" · edited ",ve(s.mtime)]})]}),e.jsxs("div",{className:"artifact-card-actions",children:[e.jsxs(C,{variant:"primary",size:"sm",onClick:n=>{n.stopPropagation(),t()},children:["Open",e.jsx(He,{size:12})]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:n=>{n.stopPropagation(),a()},children:[e.jsx(ye,{size:12})," Delete"]})]})]})}function Oi({children:s,className:t,onRemove:a}){return e.jsxs("span",{className:ne("tag",t),children:[s,a&&e.jsx("button",{type:"button",className:"tag-remove","aria-label":`Remove ${typeof s=="string"?s:"tag"}`,onClick:a,children:"×"})]})}const Bi={pending:"info",running:"accent",done:"success",failed:"error",killed:"neutral",timed_out:"warning"},Fi={pending:"Pending",running:"Running",done:"Done",failed:"Failed",killed:"Killed",timed_out:"Timed out"};function Et({status:s,dot:t}){const a=Bi[s]||"neutral",i=Fi[s]||s;return e.jsx(Pe,{kind:a,dot:t,children:i})}function Ui({instanceId:s,instanceName:t,onConfirm:a,onClose:i}){return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Instance ",e.jsx("code",{children:s}),t?e.jsxs(e.Fragment,{children:[" (",t,")"]}):null," will be terminated. This cannot be undone."]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(C,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(C,{variant:"danger",onClick:async()=>{await a(),i()},children:"Kill"})]})]})}function Ot(s,t,a,i,n){s.open({title:"Kill instance?",width:400,children:e.jsx(Ui,{instanceId:a,instanceName:i,onConfirm:async()=>{try{const d=await(await fetch(`/api/background/${encodeURIComponent(a)}`,{method:"DELETE"})).json();d.ok?(t.success(`Instance ${a} killed.`),n==null||n()):t.error(`Kill failed: ${d.error||"unknown error"}`)}catch(o){t.error(`Kill failed: ${o.message}`)}},onClose:()=>s.close()})})}function Hi(s){return M.urlWithToken(`/artifacts/${encodeURIComponent(s)}/content`)}function Bt(s,t){const a=Hi(t);window.open(a,"_blank","noopener,noreferrer")}function _i({task:s,agents:t,onPromote:a,onDelete:i,onEdit:n,onRefresh:o}){var g;const d=oe(),l=async()=>{try{await M.post(`/tasks/${encodeURIComponent(s.id)}/promote`),d.success("Promoted to queued.",1500),a(s.id)}catch(m){d.error(`Promote failed: ${m.message}`)}},p=async()=>{if(confirm("Delete this task?"))try{await M.del(`/tasks/${encodeURIComponent(s.id)}`),d.success("Deleted.",1500),i(s.id)}catch(m){d.error(`Delete failed: ${m.message}`)}},h={high:"var(--warning)",normal:"var(--info)",low:"var(--muted)"};return e.jsxs("div",{className:"backlog-item","data-task-id":s.id,children:[e.jsxs("div",{className:"backlog-item-head",children:[e.jsx("span",{className:"priority-dot",style:{background:h[s.priority]||"var(--info)"}}),e.jsx("span",{className:"backlog-item-title",children:s.title}),s.assignee&&e.jsxs("span",{className:"backlog-item-badge",children:["@",s.assignee]}),((g=s.tags)==null?void 0:g.length)>0&&e.jsx("span",{className:"backlog-item-badge",children:s.tags.join(", ")})]}),s.description&&e.jsx("div",{className:"backlog-item-desc",children:s.description.slice(0,120)}),e.jsxs("div",{className:"backlog-item-footer",children:[e.jsx("span",{className:"muted text-sm tabular-nums",children:ve(s.createdAt)}),e.jsxs("div",{className:"backlog-item-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",title:"Promote to queued",onClick:l,children:e.jsx(St,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn",title:"Edit",onClick:()=>n(s),children:e.jsx(Me,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",title:"Delete",onClick:p,children:e.jsx(ye,{size:13})})]})]})]})}function qi({agents:s,onRefresh:t}){const a=oe(),[i,n]=r.useState([]),[o,d]=r.useState(!1),l=async()=>{try{d(!0);const c=await M.get("/tasks/backlog");n(Array.isArray(c.tasks)?c.tasks:[])}catch(c){a.error(`Backlog load failed: ${c.message}`)}finally{d(!1)}};r.useEffect(()=>{l()},[]);const p=async c=>{n(u=>u.filter(k=>k.id!==c)),await t()},h=async c=>{n(u=>u.filter(k=>k.id!==c)),await t()},g=c=>{},m=async()=>{var c;if(i.length!==0)try{const k=((c=(await M.post("/tasks/promote-batch",{ids:i.map(f=>f.id)})).affected)==null?void 0:c.filter(f=>f.ok).length)??0;a.success(`Promoted ${k} task(s).`,2e3),n([]),await t()}catch(u){a.error(`Promote all failed: ${u.message}`)}};return e.jsxs("div",{className:"backlog-panel",children:[e.jsxs("div",{className:"backlog-panel-header",children:[e.jsxs("span",{className:"backlog-panel-title",children:[e.jsx(vs,{size:15}),"Backlog (",i.length,")"]}),e.jsxs("div",{className:"backlog-panel-header-actions",children:[i.length>0&&e.jsxs(C,{variant:"ghost",size:"sm",onClick:m,title:"Promote all to queued",children:[e.jsx(St,{size:12})," Promote all"]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:l,title:"Refresh backlog","aria-label":"Refresh backlog",children:e.jsx(de,{size:12,className:o?"animate-spin":""})})]})]}),o?e.jsx("div",{className:"backlog-empty",children:"Loading…"}):i.length===0?e.jsxs("div",{className:"backlog-empty",children:[e.jsx(vs,{size:28}),e.jsx("span",{children:"Backlog is empty."})]}):e.jsx("div",{className:"backlog-list",children:i.map(c=>e.jsx(_i,{task:c,agents:s,onPromote:p,onDelete:h,onEdit:g,onRefresh:t},c.id))})]})}const as=[{id:"queued",label:"Queued",kind:"info"},{id:"doing",label:"Doing",kind:"accent"},{id:"blocked",label:"Blocked",kind:"warning"},{id:"done",label:"Done",kind:"success"}];function ut(s,t){const a=s.status==="archived"||s.archived===!0;return t==="done"?s.status==="done"||a:!a&&s.status===t}const Xs=["low","normal","high"],Vi=[{id:"updated",label:"Last updated"},{id:"created",label:"Created"},{id:"priority",label:"Priority"},{id:"due",label:"Due date"}];function Wi({snapshot:s,refreshSnapshot:t,setActiveTab:a}){const i=oe(),n=ke(),[o,d]=r.useState(s.tasks||[]),[l,p]=r.useState(!s.tasks),[h,g]=r.useState(""),[m,c]=r.useState(""),[u,k]=r.useState(""),[f,S]=r.useState(""),[b,v]=r.useState("updated"),[y,T]=r.useState(!1),[x,E]=r.useState(new Set),[q,I]=r.useState(0),J=async(z={})=>{try{const _=z.archived?"?archived=only":"",O=await M.get(`/tasks${_}`);d(Array.isArray(O)?O:[])}catch(_){i.error(`Tasks load failed: ${_.message}`)}finally{p(!1)}};r.useEffect(()=>{s.tasks&&(d(s.tasks),p(!1))},[s.tasks]),r.useEffect(()=>{const z=setInterval(()=>I(_=>_+1),1e3);return()=>clearInterval(z)},[]);const R=r.useMemo(()=>{const z=new Set;for(const _ of o)for(const O of _.tags||[])z.add(O);return Array.from(z).sort()},[o]),L=r.useMemo(()=>{let z=o;if(m&&(z=z.filter(_=>(_.assignee||"")===m)),u&&(z=z.filter(_=>(_.priority||"normal")===u)),f&&(z=z.filter(_=>(_.tags||[]).includes(f))),h.trim()){const _=h.toLowerCase();z=z.filter(O=>{const j=(O.title||"").toLowerCase(),U=(O.description||"").toLowerCase(),ee=(O.tags||[]).join(" ").toLowerCase();return j.includes(_)||U.includes(_)||ee.includes(_)})}return z},[o,h,m,u,f]),W=r.useMemo(()=>{const z=[...L],_={high:0,normal:1,low:2};switch(b){case"priority":z.sort((O,j)=>(_[O.priority]??1)-(_[j.priority]??1));break;case"created":z.sort((O,j)=>new Date(j.createdAt).getTime()-new Date(O.createdAt).getTime());break;case"due":z.sort((O,j)=>{const U=O.dueDate?new Date(O.dueDate).getTime():1/0,ee=j.dueDate?new Date(j.dueDate).getTime():1/0;return U-ee});break;case"updated":default:z.sort((O,j)=>new Date(j.updatedAt).getTime()-new Date(O.updatedAt).getTime());break}return z},[L,b]),G=async(z,_)=>{const O=o.find(U=>U.id===z);if(!O)return;const j=O.status;d(U=>U.map(ee=>ee.id===z?{...ee,status:_}:ee));try{await M.patch(`/tasks/${encodeURIComponent(z)}/status`,{status:_}),i.success(`Moved to ${_}.`,1500)}catch(U){d(ee=>ee.map(B=>B.id===z?{...B,status:j}:B)),i.error(`Move failed: ${U.message}`)}},w=async z=>{if(confirm("Delete this task?"))try{await M.del(`/tasks/${encodeURIComponent(z)}`),d(_=>_.filter(O=>O.id!==z)),i.success("Task deleted.",1500)}catch(_){i.error(`Delete failed: ${_.message}`)}},$=async z=>{try{const _=await M.post(`/tasks/${encodeURIComponent(z)}/archive`);d(O=>O.filter(j=>j.id!==z)),i.success("Task archived.",1500)}catch(_){i.error(`Archive failed: ${_.message}`)}},V=async z=>{try{const _=await M.post(`/tasks/${encodeURIComponent(z)}/unarchive`);d(O=>O.map(j=>j.id===z?_:j)),i.success("Task restored.",1500)}catch(_){i.error(`Restore failed: ${_.message}`)}},K=async(z,_={})=>{if(x.size===0)return;const O=Array.from(x);try{const j=await M.post("/tasks/bulk",{ids:O,action:z,params:_}),U=j.affected.filter(B=>B.ok).length,ee=j.affected.length-U;z==="archive"||z==="delete"?d(B=>B.filter(ce=>!O.includes(ce.id))):await J(),i.success(`Bulk ${z}: ${U} ok${ee?`, ${ee} failed`:""}.`,2500),E(new Set)}catch(j){i.error(`Bulk failed: ${j.message}`)}},X=async z=>{try{const O=await M.put(`/tasks/${encodeURIComponent(z.id)}`,{assignee:"me"});d(j=>j.map(U=>U.id===z.id?O:U)),i.success("Assigned to me.",1200)}catch(_){i.error(`Assign failed: ${_.message}`)}},ae=async(z,_,O,j)=>{try{const U=await M.post(`/tasks/${encodeURIComponent(z.id)}/work`,{agent:_,status:O,complete:j});d(ee=>ee.map(B=>B.id===z.id?U:B)),i.success(`Marked ${O} by ${_}.`,1500)}catch(U){i.error(`Mark failed: ${U.message}`)}},se=z=>{E(_=>{const O=new Set(_);return O.has(z)?O.delete(z):O.add(z),O})},H=z=>{E(_=>{const O=new Set(_);return z.length>0&&z.every(U=>O.has(U))?(z.forEach(U=>O.delete(U)),O):(z.forEach(U=>O.add(U)),O)})},F=z=>{a("chat"),window.dispatchEvent(new CustomEvent("bizar:setChatTask",{detail:{taskId:z}}))},P=z=>{Bt(n,z)},[A,D]=r.useState(!1),Q=(s.tasks||[]).filter(z=>z.status==="backlog").length;return e.jsxs("div",{className:"view view-tasks",children:[e.jsx("header",{className:"view-header",children:e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Oe,{size:18})," Tasks (",W.length,")"]}),e.jsx("p",{className:"view-subtitle",children:"Personal kanban. Click a card for details (subtasks, deps, timer, comments, activity)."})]})}),e.jsxs("div",{className:"tasks-toolbar",children:[e.jsx("div",{className:"tasks-toolbar-group",children:e.jsxs("div",{className:"search-input",style:{width:200},children:[e.jsx(Be,{size:12}),e.jsx("input",{className:"input",type:"text",placeholder:"Search…",value:h,onChange:z=>g(z.target.value)}),h&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Clear search",onClick:()=>g(""),children:e.jsx($e,{size:12})})]})}),e.jsx("div",{className:"tasks-toolbar-divider"}),e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsx("span",{className:"tasks-toolbar-label",children:"Filter"}),e.jsxs("select",{className:"select select-sm",value:m,onChange:z=>c(z.target.value),title:"Assignee",children:[e.jsx("option",{value:"",children:"All assignees"}),e.jsx("option",{value:"me",children:"Me"}),(s.agents||[]).map(z=>e.jsxs("option",{value:z.name,children:["@",z.name]},z.name))]}),e.jsxs("select",{className:"select select-sm",value:u,onChange:z=>k(z.target.value),title:"Priority",children:[e.jsx("option",{value:"",children:"All priorities"}),Xs.map(z=>e.jsx("option",{value:z,children:z},z))]}),R.length>0&&e.jsxs("select",{className:"select select-sm",value:f,onChange:z=>S(z.target.value),title:"Tag",children:[e.jsx("option",{value:"",children:"All tags"}),R.map(z=>e.jsxs("option",{value:z,children:["#",z]},z))]})]}),e.jsx("div",{className:"tasks-toolbar-divider"}),e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsx("span",{className:"tasks-toolbar-label",children:"Sort"}),e.jsx("select",{className:"select select-sm",value:b,onChange:z=>v(z.target.value),title:"Sort by",children:Vi.map(z=>e.jsx("option",{value:z.id,children:z.label},z.id))})]}),e.jsx("div",{className:"tasks-toolbar-spacer"}),e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsxs(C,{variant:y?"primary":"ghost",size:"sm",onClick:()=>{T(z=>!z),J({archived:!y})},title:y?"Showing archived":"Show archived",children:[y?e.jsx(fs,{size:14}):e.jsx(gs,{size:14}),y?"Active":"Archived"]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>J(),title:"Refresh","aria-label":"Refresh tasks",children:e.jsx(de,{size:14})}),e.jsxs(C,{variant:"accent",size:"sm",onClick:()=>Ji(n,i,d,J,t),children:[e.jsx(Qe,{size:14})," Odin"]}),e.jsxs(C,{variant:"primary",size:"sm",onClick:()=>Hs(n,i,null,"queued",d,J,t,s.agents),children:[e.jsx(pe,{size:14})," Add"]}),Q>0&&e.jsxs(C,{variant:A?"accent":"ghost",size:"sm",onClick:()=>D(z=>!z),title:A?"Hide backlog":"Show backlog",children:[e.jsx(vs,{size:14}),"Backlog",e.jsx("span",{className:"badge",children:Q})]})]})]}),A&&Q>0&&e.jsx(qi,{agents:s.agents||[],onRefresh:t}),x.size>0&&e.jsxs("div",{className:"task-bulk-bar",children:[e.jsxs("span",{className:"text-sm",children:[e.jsx(Oe,{size:14})," ",x.size," selected"]}),e.jsxs("div",{className:"task-bulk-bar-actions",children:[e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>K("move",{status:"queued"}),children:"Queued"}),e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>K("move",{status:"doing"}),children:"Doing"}),e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>K("move",{status:"done"}),children:"Done"}),e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>K("priority",{priority:"high"}),children:"High"}),e.jsxs(C,{size:"sm",variant:"ghost",onClick:()=>K("archive"),children:[e.jsx(gs,{size:12})," Archive"]}),e.jsxs(C,{size:"sm",variant:"danger",onClick:()=>K("delete"),children:[e.jsx(ye,{size:12})," Delete"]}),e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>E(new Set),children:"Clear"})]})]}),l?e.jsx("div",{className:"view-loading",children:e.jsx(ge,{size:"lg"})}):e.jsx("div",{className:"kanban",children:as.map(z=>e.jsx(Ki,{column:z,tasks:W.filter(_=>ut(_,z.id)),selected:x,onToggleSelect:se,onToggleSelectAll:H,allTaskIdsInCol:W.filter(_=>ut(_,z.id)).map(_=>_.id),onMove:G,onDelete:w,onArchive:$,onUnarchive:V,onEdit:_=>Yi(n,i,_,d,J,t,s.agents,q),onAdd:()=>Hs(n,i,null,z.id,d,J,t,s.agents),onAssignMe:X,onMarkWorkedBy:ae,onOpenChat:F,onOpenArtifact:P,isArchivedView:y},z.id))})]})}function Ki({column:s,tasks:t,selected:a,onToggleSelect:i,onToggleSelectAll:n,allTaskIdsInCol:o,onMove:d,onDelete:l,onArchive:p,onUnarchive:h,onEdit:g,onAdd:m,onAssignMe:c,onMarkWorkedBy:u,onOpenChat:k,onOpenArtifact:f,isArchivedView:S}){const[b,v]=r.useState(!1),y=t.length>0&&o.every(T=>a.has(T));return e.jsxs("div",{className:ne("kanban-column",b&&"kanban-column-drop"),"data-column":s.id,onDragOver:T=>{T.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:T=>{T.preventDefault(),v(!1);const x=T.dataTransfer.getData("text/task-id");x&&d(x,s.id)},children:[e.jsxs("div",{className:"kanban-col-header",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>n(o),title:y?"Deselect all":"Select all","aria-label":y?"Deselect all":"Select all",children:y?e.jsx(Oe,{size:12}):e.jsx(It,{size:12})}),e.jsx(ie,{children:e.jsx(Pe,{kind:s.kind,dot:!0,children:s.label})}),e.jsx("span",{className:"kanban-col-count tabular-nums",children:t.length})]}),e.jsx("div",{className:"kanban-col-body",children:t.length===0?e.jsx("div",{className:"kanban-empty",children:"No tasks"}):t.map(T=>e.jsx(Gi,{task:T,focused:a.has(T.id),onFocus:()=>i(T.id),onMove:x=>{const q=as.findIndex(I=>I.id===T.status)+x;q>=0&&q<as.length&&d(T.id,as[q].id)},onEdit:()=>g(T),onDelete:()=>l(T.id),onArchive:()=>p(T.id),onUnarchive:()=>h(T.id),onAssignMe:()=>c(T),onMarkWorkedBy:(x,E,q)=>u(T,x,E,q),onOpenChat:k,onOpenArtifact:f,isArchivedView:S},T.id))}),!S&&e.jsx("footer",{className:"kanban-col-footer",children:e.jsxs(C,{variant:"ghost",size:"sm",onClick:m,className:"w-full",children:[e.jsx(pe,{size:12})," Add task"]})})]})}function Gi({task:s,focused:t,onFocus:a,onMove:i,onEdit:n,onDelete:o,onArchive:d,onUnarchive:l,onAssignMe:p,onMarkWorkedBy:h,onOpenChat:g,onOpenArtifact:m,isArchivedView:c}){var x,E,q;const u=oe(),k=ke(),f=s._timerStart,S=(s.workedBy||s.status==="doing")&&!c,b=s.metadata||{},v=!!(b.sessionId||b.bgInstanceId),T=(b.artifactIds||(b.artifactId?[b.artifactId]:[]))[0];return e.jsxs("div",{className:ne("task-card",`priority-${s.priority}`,t&&"task-card-focused",f?"task-card-timer is-working":null,S&&!f?"is-working":null),"data-task-id":s.id,"data-task-parent":s.parent||"",draggable:!c,onDragStart:I=>{I.dataTransfer.setData("text/task-id",s.id),I.dataTransfer.effectAllowed="move"},onClick:a,children:[e.jsxs("div",{className:"task-card-head",children:[e.jsx("button",{type:"button",className:ne("task-card-checkbox",t&&"task-card-checkbox-on"),"aria-label":t?"Deselect task":"Select task",title:t?"Deselect":"Select",onClick:I=>{I.stopPropagation(),a()},children:t?e.jsx(Oe,{size:13}):e.jsx(It,{size:13})}),e.jsx("span",{className:"priority-dot",style:{background:ma[s.priority]||"var(--info)"}}),e.jsx("div",{className:"task-card-title",children:s.title}),f&&e.jsxs("span",{className:"task-card-timer-pill",children:[e.jsx(Xe,{size:10})," running"]}),s.workedBy&&s.status==="doing"&&!f&&e.jsxs("span",{className:"task-card-timer-pill",title:`@${s.workedBy}`,children:[e.jsx(Ee,{size:10})," @",s.workedBy]}),s.recurring&&e.jsx("span",{className:"task-card-timer-pill",title:"Recurring",children:e.jsx(bt,{size:10})})]}),s.description&&e.jsx("div",{className:"task-card-desc",children:s.description.slice(0,160)}),e.jsxs("div",{className:"task-card-badges",children:[s.assignee&&!s.workedBy&&e.jsxs("span",{className:"task-card-badge",children:[e.jsx(Os,{size:10})," @",s.assignee]}),s.timeSpent?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(Xe,{size:10})," ",Us(s.timeSpent)]}):null,(x=s.dependencies)!=null&&x.length?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(Tt,{size:10})," ",s.dependencies.length]}):null,s.recurring?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(Ct,{size:10})," ",s.recurring.cron||s.recurring.freq||"recurring"]}):null,(E=s.comments)!=null&&E.length?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(Ve,{size:10})," ",s.comments.length]}):null,(q=s.attachments)!=null&&q.length?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(ha,{size:10})," ",s.attachments.length]}):null,b.bgInstanceId?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(ze,{size:10})," ",e.jsx(Et,{status:b.status||"pending"})]}):null]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"task-card-tags",children:s.tags.map(I=>e.jsx(Oi,{children:I},I))}),e.jsxs("div",{className:"task-card-footer",children:[e.jsx("span",{className:"task-card-time tabular-nums muted",children:ve(s.updatedAt||s.createdAt)}),e.jsxs("div",{className:"task-card-actions",onClick:I=>I.stopPropagation(),children:[!c&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Move left",title:"Move left",onClick:()=>i(-1),children:e.jsx($a,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Edit",title:"Open detail",onClick:n,children:e.jsx(Me,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Assign me",title:"Assign to me",onClick:p,children:e.jsx(Os,{size:14})}),v&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Open chat",title:"Open in chat",onClick:()=>g(s.id),children:e.jsx(Ve,{size:14})}),T&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Open artifact",title:"Open artifact",onClick:()=>m(T),children:e.jsx(ws,{size:14})}),c?e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Restore",title:"Restore",onClick:l,children:e.jsx(fs,{size:14})}):e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Archive",title:"Archive",onClick:d,children:e.jsx(gs,{size:14})}),b.bgInstanceId&&e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Kill background instance",title:"Kill background instance",onClick:()=>{Ot(k,u,b.bgInstanceId,s.title,()=>{const I=new CustomEvent("bizar:taskKilled",{detail:{taskId:s.id,bgInstanceId:b.bgInstanceId}});window.dispatchEvent(I)})},children:e.jsx(ze,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Delete",title:"Delete",onClick:o,children:e.jsx(ye,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Move right",title:"Move right",onClick:()=>i(1),children:e.jsx(He,{size:14})})]}),c&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Restore",title:"Restore",onClick:l,children:e.jsx(fs,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Delete",title:"Delete",onClick:o,children:e.jsx(ye,{size:14})})]})]})]})]})}function Us(s){if(!s)return"0m";const t=Math.floor(s/3600),a=Math.floor(s%3600/60);return t>0?`${t}h ${a}m`:`${a}m`}function Hs(s,t,a,i,n,o,d,l=[]){var v,y,T;let p=null,h=null,g=null,m=null,c=null,u=null,k=null,f=null,S=null;const b=async()=>{var V;const x=(p==null?void 0:p.value.trim())||"";if(!x){t.warning("Title is required."),p==null||p.focus();return}const E=(h==null?void 0:h.value.trim())||"",q=((V=m==null?void 0:m.querySelector('input[name="task-priority"]:checked'))==null?void 0:V.value)||"normal",I=(g==null?void 0:g.value.trim())||"",J=I?I.split(",").map(K=>K.trim()).filter(Boolean):[],R=(c==null?void 0:c.value)||i,L=((u==null?void 0:u.value)||"").trim()||null,W=(k==null?void 0:k.value)||"",G=(f==null?void 0:f.value.trim())||"",w=W==="custom"&&G?{freq:"custom",cron:G}:W&&W!=="none"?{freq:W}:null,$=(S==null?void 0:S.value)||null;try{if(a){const K=await M.put(`/tasks/${encodeURIComponent(a.id)}`,{title:x,description:E,tags:J,priority:q,status:R,assignee:L,recurring:w,dueDate:$});s.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),n(X=>X.map(ae=>ae.id===a.id?K:ae)),t.success("Task updated.",1500)}else{const K=await M.post("/tasks",{title:x,description:E,status:R,tags:J,priority:q,assignee:L,recurring:w,dueDate:$});s.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),n(X=>[K,...X]),t.success("Task created.",1500)}await d()}catch(K){t.error(`Save failed: ${K.message}`)}};s.open({title:a?"Edit task":"New task",width:560,children:e.jsxs("div",{className:"task-form",children:[e.jsx("label",{className:"field-label",htmlFor:"task-title",children:"Title *"}),e.jsx("input",{ref:x=>{p=x},id:"task-title",className:"input",type:"text",maxLength:200,placeholder:"What needs to be done?",defaultValue:(a==null?void 0:a.title)||"",autoFocus:!0}),e.jsx("label",{className:"field-label",htmlFor:"task-desc",children:"Description (markdown)"}),e.jsx("textarea",{ref:x=>{h=x},id:"task-desc",className:"textarea",rows:3,placeholder:"Markdown supported…",defaultValue:(a==null?void 0:a.description)||""}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-status",children:"Status"}),e.jsx("select",{ref:x=>{c=x},id:"task-status",className:"select",defaultValue:(a==null?void 0:a.status)||i,children:as.map(x=>e.jsx("option",{value:x.id,children:x.label},x.id))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Priority"}),e.jsx("div",{className:"radio-row",ref:x=>{m=x},children:Xs.map(x=>e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"task-priority",value:x,defaultChecked:((a==null?void 0:a.priority)||"normal")===x}),e.jsx("span",{className:"capitalize",children:x})]},x))})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-assignee",children:"Assignee"}),e.jsx("input",{ref:x=>{u=x},id:"task-assignee",className:"input",type:"text",placeholder:"odin, thor, me, …",list:"task-assignee-suggestions",defaultValue:(a==null?void 0:a.assignee)||""}),e.jsx("datalist",{id:"task-assignee-suggestions",children:l.map(x=>e.jsxs("option",{value:x.name,children:["@",x.name]},x.name))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-due",children:"Due date"}),e.jsx("input",{ref:x=>{S=x},id:"task-due",className:"input",type:"date",defaultValue:((v=a==null?void 0:a.dueDate)==null?void 0:v.slice(0,10))||""})]})]}),e.jsx("label",{className:"field-label",htmlFor:"task-tags",children:"Tags"}),e.jsx("input",{ref:x=>{g=x},id:"task-tags",className:"input",type:"text",placeholder:"comma-separated, e.g. bug, frontend",defaultValue:((a==null?void 0:a.tags)||[]).join(", ")}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-recur",children:"Recurring"}),e.jsxs("select",{ref:x=>{k=x},id:"task-recur",className:"select",defaultValue:((y=a==null?void 0:a.recurring)==null?void 0:y.freq)||"none",children:[e.jsx("option",{value:"none",children:"None"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"custom",children:"Custom (cron)"})]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-cron",children:"Cron expression"}),e.jsx("input",{ref:x=>{f=x},id:"task-cron",className:"input",type:"text",placeholder:"0 9 * * *",defaultValue:((T=a==null?void 0:a.recurring)==null?void 0:T.cron)||""})]})]})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>s.close(),children:"Cancel"}),e.jsx(C,{variant:"primary",onClick:b,children:a?"Save":"Create"})]})})}function Yi(s,t,a,i,n,o,d=[],l=0){let p=null,h=null,g=null;const m=async()=>{const b=((p==null?void 0:p.value)||"").trim();if(b)try{const v=await M.post(`/tasks/${encodeURIComponent(a.id)}/comments`,{text:b});i(y=>y.map(T=>T.id===a.id?v:T)),p&&(p.value=""),t.success("Comment added.",1200)}catch(v){t.error(`Comment failed: ${v.message}`)}},c=async()=>{try{const b=await M.post(`/tasks/${encodeURIComponent(a.id)}/timer/start`);i(v=>v.map(y=>y.id===a.id?b:y)),t.success("Timer started.",1200)}catch(b){t.error(`Start failed: ${b.message}`)}},u=async()=>{try{const b=await M.post(`/tasks/${encodeURIComponent(a.id)}/timer/stop`);i(v=>v.map(y=>y.id===a.id?b:y)),t.success("Timer stopped.",1200)}catch(b){t.error(`Stop failed: ${b.message}`)}},k=async()=>{const b=((h==null?void 0:h.value)||"").trim();if(!b)return;const v=[...a.dependencies||[],b];try{const y=await M.put(`/tasks/${encodeURIComponent(a.id)}`,{dependencies:v});i(T=>T.map(x=>x.id===a.id?y:x)),h&&(h.value=""),t.success("Dependency added.",1200)}catch(y){t.error(`Failed: ${y.message}`)}},f=async(b,v)=>{const y=(g==null?void 0:g.value)||"";if(!y){t.warning("Pick an agent first.");return}try{const T=await M.post(`/tasks/${encodeURIComponent(a.id)}/work`,{agent:y,status:b,complete:v});i(x=>x.map(E=>E.id===a.id?T:E)),t.success(`${b} by @${y}.`,1200)}catch(T){t.error(`Failed: ${T.message}`)}},S=a._timerStart?Math.floor((Date.now()-a._timerStart)/1e3)+(a.timeSpent||0):a.timeSpent||0;s.open({title:`Task — ${a.title}`,width:640,children:e.jsxs("div",{className:"task-detail",children:[e.jsxs("div",{className:"task-detail-meta",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Status:"})," ",a.status]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Priority:"})," ",a.priority]}),a.assignee&&e.jsxs("span",{children:[e.jsx("strong",{children:"Assignee:"})," @",a.assignee]}),a.workedBy&&e.jsxs("span",{children:[e.jsx("strong",{children:"Working:"})," ",e.jsxs("span",{className:"is-working",style:{display:"inline-block",padding:"0 6px"},children:["@",a.workedBy]})]}),a.dueDate&&e.jsxs("span",{children:[e.jsx("strong",{children:"Due:"})," ",a.dueDate.slice(0,10)]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Time:"})," ",Us(S)]})]}),a.description&&e.jsxs(te,{children:[e.jsx(ie,{children:"Description"}),e.jsx("div",{className:"task-detail-desc",children:a.description})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Ee,{size:14})," Mark as worked on by"]}),e.jsxs("div",{className:"task-detail-row",children:[e.jsxs("select",{ref:b=>{g=b},className:"select",defaultValue:a.workedBy||"",children:[e.jsx("option",{value:"",children:"(pick an agent)"}),d.map(b=>e.jsxs("option",{value:b.name,children:["@",b.name]},b.name))]}),e.jsxs(C,{variant:"primary",size:"sm",onClick:()=>f("doing",!1),children:[e.jsx(Ps,{size:12})," Start working"]}),e.jsxs(C,{variant:"success",size:"sm",onClick:()=>f("done",!0),children:[e.jsx(Oe,{size:12})," Complete"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>f("idle",!1),children:[e.jsx(it,{size:12})," Stop"]})]})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Xe,{size:14})," Time tracking"]}),e.jsxs("div",{className:"task-detail-row",children:[a._timerStart?e.jsxs(C,{variant:"secondary",size:"sm",onClick:u,className:"is-working",children:[e.jsx(it,{size:12})," Stop"]}):e.jsxs(C,{variant:"secondary",size:"sm",onClick:c,children:[e.jsx(Ps,{size:12})," Start"]}),e.jsxs("span",{className:ne("muted",a._timerStart?"is-working":null),children:[Us(S),a._timerStart&&" (running)"]})]})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Tt,{size:14})," Dependencies"]}),e.jsxs("div",{className:"task-detail-row",children:[e.jsx("input",{ref:b=>{h=b},className:"input",type:"text",placeholder:"task id (e.g. tsk_abc12345)"}),e.jsx(C,{variant:"secondary",size:"sm",onClick:k,children:"Add"})]}),e.jsxs("ul",{children:[(a.dependencies||[]).map(b=>e.jsx("li",{children:e.jsx("code",{children:b})},b)),(a.dependencies||[]).length===0&&e.jsx("li",{className:"muted",children:"No dependencies."})]})]}),a.recurring&&e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Ct,{size:14})," Recurring"]}),e.jsxs("div",{className:"muted",children:["Frequency: ",e.jsx("code",{children:a.recurring.freq||"custom"})," ",a.recurring.cron&&e.jsx("code",{children:a.recurring.cron})]}),a.recurring.lastGenerated&&e.jsxs("div",{className:"muted text-sm",children:["Last spawned: ",ve(a.recurring.lastGenerated)]})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Ve,{size:14})," Comments"]}),e.jsx("textarea",{ref:b=>{p=b},className:"textarea",rows:3,placeholder:"Add a comment…"}),e.jsx(C,{variant:"primary",size:"sm",onClick:m,children:"Post"}),e.jsxs("ul",{className:"task-comments",children:[(a.comments||[]).map(b=>e.jsxs("li",{children:[e.jsx("div",{className:"muted tabular-nums",children:ve(b.createdAt)}),e.jsx("div",{children:b.text})]},b.id)),(a.comments||[]).length===0&&e.jsx("li",{className:"muted",children:"No comments."})]})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(ze,{size:14})," Activity"]}),e.jsxs("ul",{className:"task-activity",children:[(a.activity||[]).slice().reverse().slice(0,20).map(b=>e.jsxs("li",{children:[e.jsx("span",{className:"muted tabular-nums",children:ve(b.ts)})," ",e.jsx("span",{className:"tag",children:b.type}),b.data&&typeof b.data=="object"?e.jsxs("code",{className:"muted",children:[" ",JSON.stringify(b.data)]}):null]},b.id)),(a.activity||[]).length===0&&e.jsx("li",{className:"muted",children:"No activity yet."})]})]})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>s.close(),children:"Close"}),e.jsxs(C,{variant:"primary",onClick:()=>{s.close(),Hs(s,t,a,a.status,i,n,o,d)},children:[e.jsx(Me,{size:12})," Edit basics"]})]})})}function Ji(s,t,a,i,n){let o=null,d=null,l=null,p=null;const h=async m=>{m&&typeof m.preventDefault=="function"&&m.preventDefault(),m&&typeof m.stopPropagation=="function"&&m.stopPropagation();const c=(d==null?void 0:d.value)||"";let u=((o==null?void 0:o.value)||"").trim();if(!u&&c.trim()&&(u=da(c),o&&(o.value=u)),!u){t.warning("Add a description so Odin knows what to do.");return}const k=(l==null?void 0:l.value)||"normal",f=((p==null?void 0:p.value)||"").split(",").map(S=>S.trim()).filter(Boolean);try{const S=await M.post("/tasks/submit",{title:u,description:c,priority:k,tags:f}),b=(S.subtasks||[]).length;t.success(b>1?`Odin split it into ${b} subtasks.`:"Task submitted to Odin."),s.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),a&&a(v=>[S.main,...S.subtasks||[],...v]),i&&await i(),n&&await n()}catch(S){t.error(`Submit failed: ${S.message}`)}},g=m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),h(m))};s.open({title:"Submit Task to Odin",width:560,children:e.jsxs("div",{className:"submit-task-form",children:[e.jsxs("label",{htmlFor:"submit-task-title",children:["Title ",e.jsx("span",{className:"field-hint",children:"(optional — auto-generated from description)"}),e.jsx("input",{id:"submit-task-title",ref:m=>{o=m},className:"input",type:"text",placeholder:"Leave blank to derive from description",autoFocus:!0,onKeyDown:g}),e.jsx("span",{className:"field-hint",children:"Odin will analyze this and split it into subtasks assigned to the best agent."})]}),e.jsxs("label",{htmlFor:"submit-task-desc",children:["Description",e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"flex-start"},children:[e.jsx("textarea",{id:"submit-task-desc",ref:m=>{d=m},className:"textarea",rows:5,placeholder:"Provide more detail (markdown ok)…",style:{flex:1}}),e.jsx("button",{type:"button",className:"btn btn-ghost btn-icon",style:{marginTop:0,flexShrink:0},title:"Enhance prompt with AI",onClick:async()=>{var c;if(!((c=d==null?void 0:d.value)!=null&&c.trim()))return;const m=await oa(d.value);m!==d.value&&(d.value=m)},children:e.jsx(Me,{size:14})})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("label",{htmlFor:"submit-task-priority",className:"task-form-field",children:["Priority",e.jsx("select",{id:"submit-task-priority",ref:m=>{l=m},className:"select",defaultValue:"normal",children:Xs.map(m=>e.jsx("option",{value:m,children:m},m))})]}),e.jsxs("label",{htmlFor:"submit-task-tags",className:"task-form-field",style:{flex:2},children:["Tags ",e.jsx("span",{className:"field-hint",children:"(comma-separated)"}),e.jsx("input",{id:"submit-task-tags",ref:m=>{p=m},className:"input",type:"text",placeholder:"backend, auth"})]})]})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>s.close(),children:"Cancel"}),e.jsxs(C,{variant:"primary",type:"button",onClick:m=>h(m),children:[e.jsx(Qe,{size:14})," Submit to Odin"]})]})})}const pt={"1m":60*1e3,"5m":5*60*1e3,"30m":30*60*1e3,"1h":60*60*1e3},we=56,Re=32,Ye=22,Xi=4,Qi=.9,$s={working:"var(--success)",running:"var(--success)",doing:"var(--info)",queued:"var(--info)",done:"var(--success)",success:"var(--success)",blocked:"var(--warning)",error:"var(--error)",failed:"var(--error)",stuck:"var(--warning)",killed:"var(--error)",idle:"var(--text-dim)",pending:"var(--info)",timed_out:"var(--warning)"};function Is(s){return s&&$s[s]||$s.idle}function ps(s,t=24){return s?s.length<=t?s:s.slice(0,t-1)+"…":""}function bs(s){if(s==null)return 0;if(typeof s=="number")return s;const t=new Date(s).getTime();return Number.isNaN(t)?0:t}function Rs(s){const t=s._timerStart;return typeof t=="number"&&t>0?t:bs(s.createdAt)||Date.now()}function Zi(s,t){return(s.status==="done"||s.status==="archived"||s.status==="failed"||s.status==="killed")&&(bs(s.completedAt)||bs(s.updatedAt))||t}function el(s){return typeof s.startedAt=="number"&&s.startedAt>0?s.startedAt:Date.now()}function sl(s,t){return(s.status==="done"||s.status==="success"||s.status==="killed"||s.status==="failed"||s.status==="error"||s.status==="timed_out")&&(s.completedAt||s.lastEventAt)||t}function tl(s){return s<=6e4?1e4:s<=3e5?3e4:s<=18e5?3e5:6e5}function al(s,t){const a=new Date(s);return t<=3e5?a.toLocaleTimeString("en-GB",{hour12:!1}):a.toLocaleTimeString("en-GB",{hour12:!1,hour:"2-digit",minute:"2-digit"})}function nl({snapshot:s,refreshSnapshot:t}){const a=oe(),i=r.useRef(null),[n,o]=r.useState("live"),[d,l]=r.useState("5m"),[p,h]=r.useState(()=>typeof window>"u"?!0:window.innerWidth>900),[g,m]=r.useState([]),[c,u]=r.useState([]),[k,f]=r.useState(!0),[S,b]=r.useState(0),[v,y]=r.useState(Date.now()),[T,x]=r.useState(()=>Date.now()-pt["5m"]*.1),[E,q]=r.useState({width:800,height:400}),[I,J]=r.useState(null),[R,L]=r.useState(""),[W,G]=r.useState([]),[w,$]=r.useState(""),[V,K]=r.useState("normal"),[X,ae]=r.useState(""),[se,H]=r.useState(""),[F,P]=r.useState(!1),[A,D]=r.useState(!1),[Q,z]=r.useState([]),_=ke(),O=s.agents||[],j=s.tasks||[],U=pt[d],ee=T,B=T+U,ce=r.useCallback(async()=>{try{const[N,Y]=await Promise.all([M.get("/background").catch(()=>({instances:[]})),M.get("/activity?limit=200").catch(()=>({events:[]}))]);m(N.instances||[]),u(Y.events||[])}catch(N){console.warn("activity reload failed:",N)}finally{f(!1)}},[]);r.useEffect(()=>{ce();const N=setInterval(ce,3e3);return()=>clearInterval(N)},[ce]),r.useEffect(()=>{b(N=>N+1)},[j.length,O.length]),r.useEffect(()=>{if(n==="pause")return;y(Date.now());const N=setInterval(()=>y(Date.now()),1e3);return()=>clearInterval(N)},[n,S]),r.useEffect(()=>{if(n==="pause")return;(v-T)/U>Qi&&x(v-U*.1)},[v,T,U,n]),r.useEffect(()=>{x(Date.now()-U*.1)},[d]),r.useEffect(()=>{n==="live"&&x(Date.now()-U*.1)},[n]),r.useLayoutEffect(()=>{const N=i.current;if(!N)return;const Y=new ResizeObserver(ue=>{for(const xe of ue){const{width:he,height:je}=xe.contentRect;q({width:Math.max(200,Math.floor(he)),height:Math.max(120,Math.floor(je))})}});return Y.observe(N),()=>Y.disconnect()},[]);const le=r.useMemo(()=>{const N=[];let Y=0;for(const he of g){const je=el(he),Se=sl(he,v);Se<ee||je>B||N.push({kind:"bg",id:`bg:${he.instanceId}`,index:Y++,label:`BG ${ps(he.promptPreview,20)||he.instanceId.slice(0,10)}`,sub:he.status||"pending",start:je,end:Se,data:he})}const ue=[...j].sort((he,je)=>Rs(he)-Rs(je)),xe=[];for(const he of ue){const je=Rs(he),Se=Zi(he,v);if(Se<ee||je>B)continue;let We=-1;for(let _e=0;_e<xe.length;_e++)if(xe[_e]<=je){xe[_e]=Se,We=_e;break}We===-1&&(xe.push(Se),We=xe.length-1),N.push({kind:"task",id:`task:${he.id}`,index:Y+We,label:ps(he.title,32),sub:he.status,start:je,end:Se,data:he})}return N},[g,j,v,ee,B]),fe=r.useMemo(()=>{const N=new Map;for(const Y of le)N.set(Y.id,Y);return N},[le]),me=r.useCallback(N=>U<=0?0:(N-ee)/U*E.width,[ee,U,E.width]),ms=r.useMemo(()=>{const N=tl(U),Y=[],ue=Math.floor(ee/N)*N;for(let xe=ue;xe<=B+N;xe+=N){if(xe<ee-N)continue;if(xe>B)break;const he=me(xe);he<-40||he>E.width+40||Y.push({t:xe,x:he,label:al(xe,U)})}return Y},[ee,B,U,E.width,me]),_t=r.useMemo(()=>{const N=[];for(const Y of le){if(Y.kind==="events")continue;const ue=Math.max(Y.start,ee),xe=Math.min(Y.end,B);if(xe<ee||ue>B)continue;const he=me(ue),je=me(xe),Se=Math.max(Xi,je-he),We=Re+Ye+Y.index*we+8,_e=we-16;let Te="doing";if(Y.kind==="bg"){const be=Y.data.status||"pending";be==="done"||be==="success"?Te="done":be==="failed"||be==="killed"||be==="error"?Te="failed":be==="queued"||be==="pending"?Te="queued":be==="blocked"||be==="stuck"?Te="blocked":Te="doing"}else{const be=Y.data.status;be==="done"||be==="archived"?Te="done":be==="failed"||be==="killed"?Te="failed":be==="queued"?Te="queued":be==="blocked"?Te="blocked":Te="doing"}const Xt=(I==null?void 0:I.id)===Y.id;N.push({id:Y.id,laneIndex:Y.index,x:he,y:We,w:Se,h:_e,label:Y.label,statusClass:Te,selected:Xt,data:Y.data,kind:Y.kind,start:Y.start,end:Y.end})}return N},[le,me,I,ee,B]),qt=r.useMemo(()=>{const N=[];for(const Y of c){const ue=bs(Y.ts);if(ue<ee-5e3||ue>B+5e3)continue;const xe=me(ue);let he=Re+12;if(Y.taskId){const je=fe.get(`task:${Y.taskId}`);je&&(he=Re+Ye+je.index*we+we/2)}else if(Y.nodeId){const je=String(Y.nodeId),Se=fe.get(je.startsWith("task:")||je.startsWith("bg:")?je:`task:${je}`);Se&&(he=Re+Ye+Se.index*we+we/2)}N.push({id:`${Y.ts}-${Y.kind}-${Y.author??""}-${Y.taskId??""}`,x:xe,y:he,kind:Y.kind||"event",ts:ue,text:String(Y.text||Y.kind||""),author:Y.author})}return N},[c,ee,B,me,fe]),Vt=r.useMemo(()=>le.map(N=>({id:N.id,y:Re+Ye+N.index*we,h:we})),[le]),hs=r.useMemo(()=>{const N=me(v);return Math.max(0,Math.min(E.width,N))},[me,v,E.width]),Wt=r.useCallback(N=>{const ue={id:N.id,kind:N.kind,label:N.label,status:N.statusClass,data:N.data};J(ue)},[]);r.useEffect(()=>{if(!I){G([]),H(""),z([]);return}L(""),$(""),ae(""),z([]),(async()=>{try{const N=await M.get(`/activity?nodeId=${encodeURIComponent(I.id)}&limit=50`);G(N.events||[])}catch{G([])}if(I.kind==="bg"){const N=I.data;try{const Y=await M.get(`/background/${encodeURIComponent(N.instanceId)}/output?lines=80`);H(Y.output||"")}catch{H("")}if(N.taskId)try{const Y=await M.get(`/tasks/${encodeURIComponent(N.taskId)}/artifacts`);z((Y.artifacts||[]).map(ue=>ue.id))}catch{z([])}}})()},[I]);const et=async()=>{if(!(!I||!R.trim())){D(!0);try{await M.post("/comments",{nodeId:I.id,text:R,author:"user"}),L("");const N=await M.get(`/activity?nodeId=${encodeURIComponent(I.id)}&limit=50`);G(N.events||[]),a.success("Comment added.")}catch(N){a.error(`Comment failed: ${N.message}`)}finally{D(!1)}}},Kt=async()=>{if(!(!I||!w.trim())){P(!0);try{await M.post(`/nodes/${encodeURIComponent(I.id)}/tasks`,{title:w,description:`Created from timeline selection ${I.id}.`,priority:V}),$(""),a.success("Task created."),await t()}catch(N){a.error(`Task create failed: ${N.message}`)}finally{P(!1)}}},st=async()=>{if(!I||I.kind!=="bg"||!X.trim())return;const N=I.data;try{const Y=await M.post(`/background/${encodeURIComponent(N.instanceId)}/message`,{message:X});Y.ok?(a.success("Message sent."),ae("")):a.warning(Y.error||"Send failed")}catch(Y){a.error(`Send failed: ${Y.message}`)}},Gt=async()=>{if(!I||I.kind!=="bg"||!confirm("Kill this bg instance session?"))return;const N=I.data;try{const Y=await M.del(`/background/${encodeURIComponent(N.instanceId)}`);Y.ok?a.success("Session killed."):a.warning(Y.error||"Kill failed"),await ce()}catch(Y){a.error(`Kill failed: ${Y.message}`)}},Yt=async()=>{if(!I||I.kind!=="bg")return;const N=I.data;try{const Y=await M.get(`/background/${encodeURIComponent(N.instanceId)}/output?lines=80`);H(Y.output||"")}catch{}};r.useEffect(()=>{const N=Y=>{Y.key==="Escape"&&J(null)};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[]);const Jt=()=>{b(N=>N+1),ce()},Cs=Re+Ye+le.length*we;return e.jsxs("div",{className:"view view-activity",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(ze,{size:18})," Activity"]}),e.jsx("p",{className:"view-subtitle",children:"Live timeline of agents, tasks, and background sessions. Active tasks pulse; the red line marks “now”."})]}),e.jsx("div",{className:"view-actions",children:e.jsxs("div",{className:"tl-mode-toggle",children:[e.jsxs(C,{variant:n==="live"?"primary":"secondary",size:"sm",onClick:()=>o(n==="live"?"pause":"live"),title:n==="live"?"Pause timeline":"Resume timeline",children:[n==="live"?e.jsx(ua,{size:14}):e.jsx(Ks,{size:14}),n==="live"?"Live":"Paused"]}),e.jsx("div",{className:"tl-zoom-group",children:["1m","5m","30m","1h"].map(N=>e.jsx("button",{type:"button",className:ne("tl-zoom-btn",d===N&&"tl-zoom-btn-active"),onClick:()=>l(N),title:`Zoom to ${N}`,children:N},N))}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:Jt,title:"Refresh",children:[e.jsx(de,{size:14})," Refresh"]})]})})]}),k&&e.jsx("div",{className:"view-loading",children:e.jsx(ge,{size:"lg"})}),!k&&O.length===0&&j.length===0&&g.length===0&&c.length===0?e.jsx(Ie,{icon:e.jsx(ze,{size:32}),title:"No activity yet",message:"Once agents, tasks, or background instances exist, they'll show up here on the timeline."}):e.jsx("div",{className:ne("tl-view",I&&"tl-view-detail-open"),children:e.jsxs("div",{className:ne("tl-body",!p&&"tl-body-stream-collapsed"),children:[e.jsxs("aside",{className:ne("tl-stream",!p&&"tl-stream-collapsed"),children:[e.jsxs("div",{className:"tl-stream-head",children:[e.jsxs("h3",{children:[e.jsx(ns,{size:13})," Live events"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>h(!1),title:"Hide event stream","aria-label":"Hide event stream",children:e.jsx(Xa,{size:14})})]}),e.jsx("div",{className:"tl-stream-list",children:c.length===0?e.jsx("div",{className:"tl-stream-empty",children:e.jsx("p",{children:"No events yet."})}):[...c].reverse().map((N,Y)=>{const ue=N.author?Ee:N.kind==="task"?Oe:N.kind==="bg"?zs:ze;return e.jsxs("div",{className:"tl-stream-event",children:[e.jsx("span",{className:"tl-stream-event-time",children:new Date(N.ts).toLocaleTimeString("en-GB",{hour12:!1})}),e.jsx("span",{className:"tl-stream-event-icon",style:{color:Is(N.kind)},children:e.jsx(ue,{size:12})}),e.jsx("span",{className:"tl-stream-event-text",children:N.author||N.text||N.kind})]},`${N.ts}-${Y}`)})})]}),e.jsxs("div",{className:"tl-canvas-wrap",ref:i,children:[e.jsxs("div",{className:"tl-canvas-toolbar",children:[e.jsxs("div",{className:"tl-canvas-toolbar-left",children:[!p&&e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>h(!0),title:"Show event stream",children:[e.jsx(Qa,{size:14})," Events"]}),e.jsx("span",{className:"tl-canvas-mode",children:n==="live"?"● Live":"⏸ Paused"}),e.jsxs("span",{className:"tl-canvas-range",children:[new Date(ee).toLocaleTimeString("en-GB",{hour12:!1})," →"," ",new Date(B).toLocaleTimeString("en-GB",{hour12:!1})]})]}),e.jsxs("div",{className:"tl-canvas-legend",children:[e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--success)"}})," active"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot tl-legend-dot-dashed",style:{borderColor:"var(--info)"}})," queued"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--warning)"}})," blocked"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--error)"}})," error"]}),e.jsx("span",{className:"tl-legend-sep"}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(Mt,{size:11})," agent"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(rn,{size:11})," task"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(zs,{size:11})," bg"]})]})]}),e.jsx("div",{className:"tl-canvas-scroll",children:e.jsxs("svg",{className:"tl-canvas",width:E.width,height:Math.max(E.height,Cs),role:"application","aria-label":"Activity timeline",children:[e.jsx("defs",{children:e.jsx("pattern",{id:"tl-canvas-grid",width:E.width,height:we,patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:`M 0 0 L 0 ${we}`,fill:"none",stroke:"var(--border)",strokeWidth:.5,opacity:.35})})}),e.jsx("rect",{width:"100%",height:"100%",fill:"url(#tl-canvas-grid)"}),Vt.map(N=>e.jsx("rect",{className:"tl-lane-bg",x:0,y:N.y,width:E.width,height:N.h,fill:N.id.charCodeAt(N.id.length-1)%2===0?"var(--bg-elev-2)":"var(--bg-elev)",opacity:.4},`bg-${N.id}`)),e.jsx("g",{className:"tl-time-axis",children:ms.map(N=>e.jsxs("g",{children:[e.jsx("line",{x1:N.x,y1:0,x2:N.x,y2:Cs,stroke:"var(--border)",strokeWidth:.5,strokeDasharray:"2,4",opacity:.5}),e.jsx("text",{x:N.x+4,y:Re-8,fontSize:10,fontFamily:"var(--font-mono)",fill:"var(--text-dim)",children:N.label})]},`tick-${N.t}`))}),le.map(N=>{const Y=Re+Ye+N.index*we+we/2;return e.jsxs("g",{className:"tl-lane-label-group",children:[e.jsx("text",{x:6,y:Y-2,className:"tl-lane-label",textAnchor:"start",children:ps(N.label,28)}),e.jsx("text",{x:6,y:Y+10,className:"tl-lane-label-sub",textAnchor:"start",children:N.sub})]},`label-${N.id}`)}),_t.map(N=>{const Y=Is(N.statusClass),ue=N.id===(I==null?void 0:I.id);return e.jsxs("g",{className:ne("tl-task-bar",`tl-task-bar-${N.statusClass}`,ue&&"tl-task-bar-selected"),onClick:()=>Wt(N),children:[e.jsx("rect",{x:N.x,y:N.y,width:N.w,height:N.h,rx:6,fill:Y,fillOpacity:N.statusClass==="done"?.35:N.statusClass==="queued"?.18:.85,stroke:Y,strokeWidth:ue?2.5:1.5,strokeOpacity:N.statusClass==="done"?.5:1,strokeDasharray:N.statusClass==="queued"?"4 4":void 0,style:{cursor:"pointer"}}),N.w>36&&e.jsx("text",{x:N.x+8,y:N.y+N.h/2+4,fontSize:11,fontFamily:"var(--font-sans)",fontWeight:500,fill:"var(--text-strong)",style:{pointerEvents:"none"},opacity:N.statusClass==="done"?.7:1,children:ps(N.label,Math.max(4,Math.floor(N.w/7)))})]},`bar-${N.id}`)}),qt.map(N=>{const Y=Is(N.kind);return e.jsxs("g",{className:"tl-event-marker-group",children:[e.jsx("line",{x1:N.x,y1:N.y-6,x2:N.x,y2:N.y+6,stroke:Y,strokeWidth:1.2,opacity:.7}),e.jsx("circle",{cx:N.x,cy:N.y,r:4,fill:Y,opacity:.9,children:e.jsx("title",{children:`${N.kind}${N.author?` · ${N.author}`:""} · ${new Date(N.ts).toLocaleTimeString("en-GB",{hour12:!1})}`})})]},`ev-${N.id}`)}),e.jsx("line",{className:"tl-now-line",x1:hs,y1:0,x2:hs,y2:Cs,stroke:"var(--error)",strokeWidth:1.5,opacity:.9}),e.jsxs("g",{className:"tl-now-marker",children:[e.jsx("circle",{cx:hs,cy:Re-4,r:4,fill:"var(--error)"}),e.jsx("text",{x:hs+6,y:Re-4,fontSize:10,fontWeight:700,fill:"var(--error)",fontFamily:"var(--font-mono)",children:"now"})]})]})})]}),I&&e.jsx("aside",{className:"tl-detail tl-detail-enter",children:e.jsxs(te,{children:[e.jsxs(ie,{children:[I.kind==="agent"&&e.jsx(Ee,{size:14}),I.kind==="task"&&e.jsx(Oe,{size:14}),I.kind==="bg"&&e.jsx(zs,{size:14}),I.label,e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>J(null),title:"Close","aria-label":"Close activity detail",style:{marginLeft:"auto"},children:e.jsx($e,{size:14})})]}),e.jsxs("div",{className:"tl-detail-meta",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"type"})," ",I.kind]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"status"})," ",e.jsx("code",{children:I.status})]}),I.kind==="agent"&&(()=>{const N=I.data;return e.jsxs(e.Fragment,{children:[N.role&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"role"})," ",N.role]}),N.model&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"model"})," ",N.model]})]})})(),I.kind==="task"&&(()=>{const N=I.data;return e.jsxs(e.Fragment,{children:[N.assignee&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"assignee"})," @",N.assignee]}),N.priority&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"priority"})," ",N.priority]}),N.createdAt&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"created"})," ",new Date(N.createdAt).toLocaleString()]})]})})(),I.kind==="bg"&&(()=>{const N=I.data;return e.jsxs(e.Fragment,{children:[N.startedAt&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"started"})," ",new Date(N.startedAt).toLocaleString()]}),N.tmuxSession&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"tmux"})," ",e.jsx("code",{children:N.tmuxSession})," ",N.tmuxActive?e.jsx("span",{className:"tag tag-success",children:"active"}):e.jsx("span",{className:"tag",children:"inactive"})]})]})})()]}),I.kind==="task"&&I.data.description&&e.jsx("div",{className:"tl-detail-desc",children:I.data.description}),I.kind==="bg"&&I.data.promptPreview&&e.jsx("div",{className:"tl-detail-desc",children:I.data.promptPreview}),I.kind==="bg"&&e.jsxs("div",{className:"tl-detail-bg",children:[e.jsx("pre",{className:"tl-bg-output",children:se||"(no output — start the session via tmux attach)"}),e.jsxs("div",{className:"tl-bg-output-actions",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:Yt,children:[e.jsx(de,{size:12})," Refresh output"]}),Q.length>0&&e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>Bt(_,Q[0]),children:[e.jsx(ws,{size:12})," Open artifact"]}),e.jsxs(C,{variant:"danger",size:"sm",onClick:Gt,children:[e.jsx(ye,{size:12})," Kill session"]})]}),e.jsxs("div",{className:"tl-form-row",children:[e.jsx("input",{className:"input",placeholder:"Send a message to this bg session…",value:X,onChange:N=>ae(N.target.value),onKeyDown:N=>{N.key==="Enter"&&st()}}),e.jsxs(C,{variant:"primary",size:"sm",disabled:!X.trim(),onClick:st,children:[e.jsx(Qe,{size:12})," Send"]})]})]}),I.kind!=="bg"&&e.jsxs("div",{className:"tl-detail-create",children:[e.jsx("div",{className:"field-label",children:"Create follow-up task"}),e.jsx("input",{className:"input",placeholder:"Task title",value:w,onChange:N=>$(N.target.value)}),e.jsxs("div",{className:"tl-form-row",children:[e.jsxs("select",{className:"select",value:V,onChange:N=>K(N.target.value),children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"})]}),e.jsxs(C,{variant:"primary",size:"sm",disabled:!w.trim()||F,onClick:Kt,children:[e.jsx(pe,{size:12})," Add task"]})]})]}),e.jsxs("div",{className:"tl-detail-comments",children:[e.jsxs("div",{className:"field-label",children:[e.jsx(Ve,{size:12})," Comments & activity"]}),e.jsxs("ul",{className:"comment-list",children:[W.length===0&&e.jsx("li",{className:"muted",children:"No comments yet."}),W.map((N,Y)=>e.jsxs("li",{className:"comment-item",children:[e.jsxs("div",{className:"comment-head",children:[e.jsx("strong",{children:N.author||"system"}),e.jsxs("span",{className:"muted",children:[N.kind," · ",new Date(N.ts).toLocaleString()]})]}),N.text&&e.jsx("div",{className:"comment-text",children:N.text}),N.taskId&&e.jsxs("div",{className:"muted",children:["→ task ",e.jsx("code",{children:String(N.taskId)})]})]},`c-${Y}`))]}),e.jsxs("div",{className:"comment-input-row",children:[e.jsx("input",{className:"input",placeholder:"Add a comment…",value:R,onChange:N=>L(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&et()}}),e.jsxs(C,{variant:"secondary",size:"sm",disabled:!R.trim()||A,onClick:et,children:[e.jsx(Qe,{size:12})," Post"]})]})]})]})},I.id)]})})]})}const il=[{id:"opencode",label:"OpenCode config",icon:Js,desc:"Edit opencode.json directly"},{id:"providers",label:"Providers",icon:Fe,desc:"AI providers + API keys"},{id:"mcps",label:"MCPs",icon:os,desc:"Model Context Protocol servers"},{id:"diagnostics",label:"Diagnostics",icon:Rt,desc:"Service health + counts"},{id:"memory",label:"Memory & LightRAG",icon:Ys,desc:"Configure Bizar Memory Service and the LightRAG embedding server."},{id:"export",label:"Export / Import",icon:Le,desc:"Download diagnostics bundle"}];function ll({snapshot:s,refreshSnapshot:t}){const a=oe();ke();const i=s.config,[n,o]=r.useState("opencode"),[d,l]=r.useState((i==null?void 0:i.raw)||(i!=null&&i.data?JSON.stringify(i.data,null,2):"")),[p,h]=r.useState({raw:(i==null?void 0:i.raw)||"",data:(i==null?void 0:i.data)??null,error:null}),[g,m]=r.useState(!1),[c,u]=r.useState(!1),[k,f]=r.useState((i==null?void 0:i.path)||""),S=r.useRef(null),[b,v]=r.useState(null),[y,T]=r.useState(null),[x,E]=r.useState([]),[q,I]=r.useState(s.providers||[]),[J,R]=r.useState(s.mcps||[]),L=r.useMemo(()=>at(d),[d]);r.useEffect(()=>{s.providers&&I(s.providers),s.mcps&&R(s.mcps)},[s.providers,s.mcps]);const W=async()=>{try{const F=await M.post("/config/reload"),P=F.raw||(F.data?JSON.stringify(F.data,null,2):"");l(P),h({raw:P,data:F.data??null,error:null}),m(!1),f(F.path||""),a.info("Config reloaded.",1500)}catch(F){a.error(`Reload failed: ${F.message}`)}},G=async()=>{try{const F=await M.get("/config/providers");I(F.providers||[])}catch(F){a.error(`Providers load failed: ${F.message}`)}},w=async()=>{try{const F=await M.get("/config/mcps");R(F.mcps||[])}catch(F){a.error(`MCPs load failed: ${F.message}`)}};r.useEffect(()=>{n==="providers"&&q.length===0&&G(),n==="mcps"&&J.length===0&&w(),n==="diagnostics"&&!b&&X(),n==="memory"&&ae()},[n]);const $=F=>{h(P=>{const A={raw:F,data:P.data,error:null};try{A.data=JSON.parse(F),A.error=null}catch(D){A.data=null,A.error=D.message}return A}),V(F)},V=r.useMemo(()=>pa(F=>{m(at(F)!==L)},100),[L]),K=async()=>{if(!(!p.data||p.error||c)){u(!0);try{const F=await M.put("/config",p.data),P=F.raw||JSON.stringify(F.data,null,2);l(P),h({raw:P,data:F.data??null,error:null}),m(!1),a.success("Config saved."),await t(),await G(),await w()}catch(F){a.error(`Save failed: ${F.message}`)}finally{u(!1)}}},X=async()=>{try{const F=await M.get("/diagnostics");v(F)}catch(F){a.error(`Diagnostics load failed: ${F.message}`)}},ae=async()=>{try{const F=await M.get("/memory/lightrag/status");T(F)}catch(F){a.error(`LightRAG status failed: ${F.message}`)}},se=async()=>{try{const F=await M.get("/memory/lightrag/log");E(F.lines||[])}catch{E([])}},H=()=>{const F={generatedAt:new Date().toISOString(),diagnostics:b,config:p.data,opencodeJsonPath:k,providers:q,mcps:J},P=new Blob([JSON.stringify(F,null,2)],{type:"application/json"}),A=URL.createObjectURL(P),D=document.createElement("a");D.href=A,D.download=`bizar-diagnostics-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,D.click(),URL.revokeObjectURL(A),a.success("Bundle downloaded.")};return e.jsxs("div",{className:"view view-config",children:[e.jsx("header",{className:"view-header",children:e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx($t,{size:18})," Config"]}),e.jsx("p",{className:"view-subtitle",children:"Manage OpenCode config, providers, MCPs, and diagnostics."})]})}),e.jsxs("div",{className:"config-layout",children:[e.jsx("nav",{className:"config-nav",role:"navigation","aria-label":"Config sections",children:il.map(F=>{const P=F.icon;return e.jsxs("button",{type:"button",className:ne("config-nav-item",n===F.id&&"config-nav-item-active"),onClick:()=>o(F.id),"aria-current":n===F.id?"page":void 0,children:[e.jsx(P,{size:14}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1},children:[e.jsx("span",{children:F.label}),e.jsx("span",{style:{fontSize:10,color:"var(--text-dim)",fontWeight:400},children:F.desc})]})]},F.id)})}),e.jsxs("div",{className:"config-content",children:[n==="opencode"&&e.jsx(cl,{parsed:p,dirty:g,saving:c,path:k,onReload:W,onSave:K,onChange:$,textareaRef:S}),n==="providers"&&e.jsx(xl,{providers:q,onChange:I,onReload:G}),n==="mcps"&&e.jsx(vl,{mcps:J,onChange:R,onReload:w}),n==="diagnostics"&&e.jsx(pl,{diagnostics:b,loading:!b,onReload:X}),n==="memory"&&e.jsx(Nl,{status:y,onReload:ae,logLines:x,onReloadLog:se}),n==="export"&&e.jsx(yl,{onDownload:H})]})]})]})}const rl=[{id:"model",label:"Model"},{id:"plugins",label:"Plugins"},{id:"tools",label:"Tools"},{id:"permissions",label:"Permissions"},{id:"hooks",label:"Hooks"},{id:"advanced",label:"Advanced"}];function cl({parsed:s,dirty:t,saving:a,path:i,onReload:n,onSave:o,onChange:d,textareaRef:l}){const[p,h]=r.useState("model"),g=s.data,m=c=>{if(!g)return;const u={...g,...c};d(JSON.stringify(u,null,2))};return e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Js,{size:14})," OpenCode config"]}),e.jsx(re,{children:e.jsx("code",{className:"mono ellipsis",style:{fontSize:11},children:i||"~/.config/opencode/opencode.json"})}),e.jsxs("div",{className:"view-actions",style:{marginBottom:12},children:[e.jsxs(C,{variant:"secondary",size:"sm",onClick:n,children:[e.jsx(de,{size:14})," Reload"]}),e.jsxs(C,{variant:"primary",size:"sm",disabled:!s.data||!!s.error||!t,onClick:o,children:[a?e.jsx("span",{className:"btn-spinner"}):e.jsx(Ze,{size:14}),"Save"]})]}),e.jsx("div",{className:"config-section-tabs",style:{display:"flex",gap:4,marginBottom:16,flexWrap:"wrap"},children:rl.map(c=>e.jsx("button",{type:"button",className:ne("tab-btn",p===c.id&&"active"),onClick:()=>h(c.id),children:c.label},c.id))}),p==="model"&&e.jsx(ol,{cfg:g,apply:m}),p==="plugins"&&e.jsx(dl,{cfg:g,apply:m}),p==="tools"&&e.jsx(ml,{cfg:g,apply:m}),p==="permissions"&&e.jsx(hl,{cfg:g,apply:m}),p==="hooks"&&e.jsx(ul,{cfg:g,apply:m}),p==="advanced"&&e.jsxs("div",{children:[e.jsx("div",{className:"config-grid-label",style:{marginBottom:8},children:s.error?e.jsx("span",{className:"text-error",children:s.error}):e.jsx("span",{className:"muted",children:"Raw JSON — edit with care"})}),e.jsx("textarea",{ref:l,className:ne("textarea config-textarea",s.error&&"invalid"),spellCheck:!1,value:s.raw,onChange:c=>d(c.target.value),style:{minHeight:300}})]})]})}function ol({cfg:s,apply:t}){const a=(s==null?void 0:s.model)||{};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx("p",{className:"muted text-sm",children:"Configure the default model used by OpenCode agents."}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Provider"}),e.jsx("input",{className:"input",value:String(a.provider||""),onChange:i=>t({model:{...a,provider:i.target.value}}),placeholder:"e.g. openai, anthropic, google"})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Model ID"}),e.jsx("input",{className:"input",value:String(a.model||""),onChange:i=>t({model:{...a,model:i.target.value}}),placeholder:"e.g. gpt-4o, claude-sonnet-4-20250514"})]}),!!a.apiKey&&e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"API Key"}),e.jsx("input",{className:"input",type:"password",value:String(a.apiKey||""),onChange:i=>t({model:{...a,apiKey:i.target.value}}),placeholder:"sk-..."})]}),!!a.baseURL&&e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Base URL"}),e.jsx("input",{className:"input",value:String(a.baseURL||""),onChange:i=>t({model:{...a,baseURL:i.target.value}}),placeholder:"https://api.openai.com/v1"})]})]})}function dl({cfg:s,apply:t}){const a=Array.isArray(s==null?void 0:s.plugins)?s.plugins:[],[i,n]=r.useState(null),[o,d]=r.useState({}),l=()=>{const g=[...a,{name:"",enabled:!0}];t({plugins:g})},p=g=>{const m=a.filter((c,u)=>u!==g);t({plugins:m})},h=(g,m)=>{const c=a.map((u,k)=>k===g?{...u,...m}:u);t({plugins:c}),n(null)};return e.jsxs("div",{children:[e.jsx("p",{className:"muted text-sm",style:{marginBottom:12},children:"Manage enabled plugins."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.length===0&&e.jsx("p",{className:"muted text-sm",children:"No plugins configured."}),a.map((g,m)=>e.jsx("div",{className:"config-list-row",children:i===m?e.jsxs("div",{style:{display:"flex",gap:8,flex:1,alignItems:"center"},children:[e.jsx("input",{className:"input",value:String(o.name||""),onChange:c=>d({...o,name:c.target.value}),placeholder:"plugin-name"}),e.jsxs("label",{style:{display:"flex",gap:4,fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:!!o.enabled,onChange:c=>d({...o,enabled:c.target.checked})}),"enabled"]}),e.jsx(C,{variant:"primary",size:"sm",onClick:()=>h(m,o),children:"Apply"}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>n(null),children:e.jsx($e,{size:12})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13},children:g.name||"unnamed"}),e.jsx("span",{className:ne("tag",g.enabled!==!1?"tag-success":"tag-neutral"),children:g.enabled!==!1?"enabled":"disabled"}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:4},children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>{n(m),d(g)},title:"Edit",children:e.jsx(ds,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn text-error",onClick:()=>p(m),title:"Remove",children:e.jsx(ye,{size:12})})]})]})},m))]}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:l,style:{marginTop:8},children:[e.jsx(pe,{size:12})," Add plugin"]})]})}function ml({cfg:s,apply:t}){const a=(s==null?void 0:s.tools)||{},i=d=>{t({tools:{...a,[d]:!a[d]}})},n=d=>{!d||a[d]!==void 0||t({tools:{...a,[d]:!0}})},o=d=>{const l={...a};delete l[d],t({tools:l})};return e.jsxs("div",{children:[e.jsx("p",{className:"muted text-sm",style:{marginBottom:12},children:"Enable or disable built-in tools."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[Object.keys(a).length===0&&e.jsx("p",{className:"muted text-sm",children:"No tools configured."}),Object.entries(a).map(([d,l])=>e.jsxs("div",{className:"config-list-row",children:[e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13},children:d}),e.jsxs("label",{style:{display:"flex",gap:4,alignItems:"center",fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:!!l,onChange:()=>i(d)}),"enabled"]}),e.jsx("button",{type:"button",className:"icon-btn text-error",style:{marginLeft:"auto"},onClick:()=>o(d),title:"Remove",children:e.jsx(ye,{size:12})})]},d))]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("input",{className:"input",placeholder:"tool-name",onKeyDown:d=>{d.key==="Enter"&&n(d.target.value.trim())}}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:d=>{var l,p;return n(((p=(l=d.currentTarget.closest("div"))==null?void 0:l.querySelector("input"))==null?void 0:p.value.trim())||"")},children:[e.jsx(pe,{size:12})," Add"]})]})]})}function hl({cfg:s,apply:t}){const a=(s==null?void 0:s.permissions)||{},[i,n]=r.useState("allow"),o=Array.isArray(a.allow)?a.allow:[],d=Array.isArray(a.deny)?a.deny:[],l=(g,m)=>c=>{c&&t({permissions:{...a,[m]:[...g,c]}})},p=(g,m,c)=>{t({permissions:{...a,[g]:m.filter((u,k)=>k!==c)}})},h=i==="allow"?o:d;return e.jsxs("div",{children:[e.jsx("p",{className:"muted text-sm",style:{marginBottom:12},children:"Allow or deny tool/scope rules."}),e.jsxs("div",{style:{display:"flex",gap:4,marginBottom:12},children:[e.jsxs("button",{type:"button",className:ne("tab-btn",i==="allow"&&"active"),onClick:()=>n("allow"),children:["Allow (",o.length,")"]}),e.jsxs("button",{type:"button",className:ne("tab-btn",i==="deny"&&"active"),onClick:()=>n("deny"),children:["Deny (",d.length,")"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[h.length===0&&e.jsxs("p",{className:"muted text-sm",children:["No ",i," rules."]}),h.map((g,m)=>e.jsxs("div",{className:"config-list-row",children:[e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13},children:g}),e.jsx("button",{type:"button",className:"icon-btn text-error",style:{marginLeft:"auto"},onClick:()=>p(i,h,m),children:e.jsx(ye,{size:12})})]},m))]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("input",{className:"input",placeholder:`${i} rule (e.g. tool:read, scope:filesystem)`,onKeyDown:g=>{if(g.key==="Enter"){const m=g.target.value.trim();m&&(l(h,i)(m),g.target.value="")}}}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:g=>{var u;const m=(u=g.currentTarget.closest("div"))==null?void 0:u.querySelector("input"),c=m==null?void 0:m.value.trim();c&&(l(h,i)(c),m.value="")},children:[e.jsx(pe,{size:12})," Add"]})]})]})}function ul({cfg:s,apply:t}){const a=(s==null?void 0:s.hooks)||{},i=(n,o)=>{t({hooks:{...a,[n]:o}})};return e.jsxs("div",{children:[e.jsx("p",{className:"muted text-sm",style:{marginBottom:12},children:"Configure pre/post tool hooks."}),Object.keys(a).length===0&&e.jsx("p",{className:"muted text-sm",children:"No hooks configured."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:["preTool","postTool","preAgent","postAgent"].map(n=>{const o=a[n];return e.jsxs("div",{className:"field-row",style:{alignItems:"flex-start"},children:[e.jsx("label",{className:"field-label",style:{minWidth:100},children:n}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1},children:e.jsx("input",{className:"input",value:typeof o=="object"&&o!==null&&"command"in o?String(o.command||""):"",onChange:d=>i(n,{command:d.target.value}),placeholder:`${n} command (e.g. node /path/to/hook.js)`})})]},n)})})]})}function pl({diagnostics:s,loading:t,onReload:a}){return e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Rt,{size:14})," Diagnostics"]}),e.jsxs(re,{children:["System health, file counts, recent errors."," ",e.jsx("button",{type:"button",className:"link-btn",onClick:a,children:"Refresh"})]}),t&&e.jsx("p",{className:"muted",children:"Loading diagnostics…"}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"diagnostics-grid",children:[e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Version"}),e.jsx("div",{className:"diagnostic-tile-value mono",children:s.version})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Uptime"}),e.jsxs("div",{className:"diagnostic-tile-value mono",children:[s.uptime,"s"]})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Node"}),e.jsx("div",{className:"diagnostic-tile-value mono",children:s.nodeVersion})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Platform"}),e.jsx("div",{className:"diagnostic-tile-value mono",children:s.platform})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Memory (heap)"}),e.jsxs("div",{className:"diagnostic-tile-value mono",children:[Math.round(s.memory.heapUsed/1024/1024),"MB"]})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Memory (RSS)"}),e.jsxs("div",{className:"diagnostic-tile-value mono",children:[Math.round(s.memory.rss/1024/1024),"MB"]})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Service"}),e.jsx("div",{className:"diagnostic-tile-value",children:s.service.running?e.jsxs("span",{className:"tag tag-success",children:["running (pid ",s.service.pid,")"]}):e.jsx("span",{className:"tag tag-neutral",children:"stopped"})})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Active project"}),e.jsx("div",{className:"diagnostic-tile-value mono",children:s.counts.activeProject||"—"})]})]}),e.jsxs("div",{className:"diagnostic-counts",children:[e.jsxs("span",{children:["agents: ",e.jsx("strong",{children:s.counts.agents})]}),e.jsxs("span",{children:["projects: ",e.jsx("strong",{children:s.counts.projects})]}),e.jsxs("span",{children:["mods: ",e.jsx("strong",{children:s.counts.mods})]}),e.jsxs("span",{children:["schedules: ",e.jsx("strong",{children:s.counts.schedules})]}),e.jsxs("span",{children:["tasks: ",e.jsx("strong",{children:s.counts.tasks})]}),e.jsxs("span",{children:["providers: ",e.jsx("strong",{children:s.counts.providers})]}),e.jsxs("span",{children:["mcps: ",e.jsx("strong",{children:s.counts.mcps})]})]}),e.jsxs("div",{className:"diagnostic-errors",children:[e.jsxs("div",{className:"muted",children:["Last ",s.errors.length," errors from service.log"]}),s.errors.length===0?e.jsx("p",{className:"muted",children:"No errors recorded."}):e.jsx("ul",{children:s.errors.map((i,n)=>e.jsxs("li",{className:"mono",children:[i.ts&&e.jsxs("span",{className:"muted",children:["[",i.ts,"] "]}),i.line]},n))})]})]})]})}function xl({providers:s,onChange:t,onReload:a}){const i=oe(),n=ke(),o=l=>{let p=null,h=null,g=null,m=null,c=null,u=null;const k=!!l,f=(l==null?void 0:l.id)||"",S=(l==null?void 0:l.name)||"",b=(l==null?void 0:l.baseURL)||"",v=(l==null?void 0:l.apiKey)||"",y=((l==null?void 0:l.models)||[]).join(", "),T=(l==null?void 0:l.enabled)!==!1;n.open({title:k?`Edit provider "${l.id}"`:"Add provider",children:e.jsxs("div",{children:[e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"ID (a-z, 0-9, dashes)"}),e.jsx("input",{ref:x=>p=x,className:"input",type:"text",defaultValue:f,placeholder:"anthropic",disabled:k})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Display name"}),e.jsx("input",{ref:x=>h=x,className:"input",type:"text",defaultValue:S,placeholder:"Anthropic"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Base URL"}),e.jsx("input",{ref:x=>g=x,className:"input",type:"text",defaultValue:b,placeholder:"https://api.anthropic.com"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsxs("label",{children:["API key",k&&" (leave masked value unchanged to keep)"]}),e.jsx("input",{ref:x=>m=x,className:"input",type:"password",defaultValue:v,placeholder:"sk-...",autoComplete:"off"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Models (comma-separated)"}),e.jsx("textarea",{ref:x=>c=x,className:"textarea",defaultValue:y,placeholder:"claude-sonnet-4-5, claude-opus-4-1",rows:3})]}),e.jsx("div",{className:"modal-form-row",children:e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{ref:x=>u=x,type:"checkbox",defaultChecked:T}),"Enabled"]})})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>n.close(),children:"Cancel"}),e.jsxs(C,{variant:"primary",onClick:async()=>{const x=((p==null?void 0:p.value)||"").trim(),E=((h==null?void 0:h.value)||"").trim(),q=((g==null?void 0:g.value)||"").trim(),I=(m==null?void 0:m.value)||"",R=((c==null?void 0:c.value)||"").split(/[,\n]/).map(W=>W.trim()).filter(Boolean),L=!!(u!=null&&u.checked);if(!x){i.warning("ID is required.");return}if(!/^[a-z0-9][a-z0-9_-]{0,63}$/i.test(x)){i.warning("ID must be a-z, 0-9, dashes.");return}try{const W={id:x,name:E||x,baseURL:q,apiKey:I,models:R,enabled:L};if(k){const G=await M.put(`/config/providers/${encodeURIComponent(x)}`,W);t(s.map(w=>w.id===x?G:w)),i.success(`Provider "${x}" updated.`)}else{const G=await M.post("/config/providers",W);t([...s,G]),i.success(`Provider "${x}" added.`)}n.close()}catch(W){i.error(`Save failed: ${W.message}`)}},children:[k?"Update":"Add"," provider"]})]})})},d=async l=>{if(confirm(`Remove provider "${l}"?`))try{await M.del(`/config/providers/${encodeURIComponent(l)}`),t(s.filter(p=>p.id!==l)),i.success("Provider removed.")}catch(p){i.error(`Remove failed: ${p.message}`)}};return e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Fe,{size:14})," Providers (",s.length,")"]}),e.jsxs(re,{children:["AI providers configured under ",e.jsx("code",{children:"opencode.json#provider"}),". Each provider has a base URL, API key, and a list of model IDs."]}),e.jsx(wl,{onAdd:(l,p,h,g)=>{o({id:l,name:p,baseURL:h,apiKey:g})}}),e.jsxs("div",{className:"view-actions",style:{marginBottom:12},children:[e.jsxs(C,{variant:"primary",size:"sm",onClick:()=>o(),children:[e.jsx(pe,{size:14})," Add provider"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(de,{size:14})," Refresh"]})]}),s.length===0?e.jsx(jl,{onAdd:()=>o()}):e.jsx("div",{className:"provider-list",children:s.map(l=>e.jsxs(te,{className:"provider-row",children:[e.jsxs("div",{className:"provider-row-head",children:[e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{className:"provider-name",children:l.name||l.id}),e.jsx("div",{className:"provider-id",children:l.id})]}),e.jsxs("div",{className:"provider-actions",children:[e.jsxs("label",{className:"toggle-row",title:"Enabled",children:[e.jsx("input",{type:"checkbox",checked:l.enabled!==!1,onChange:async p=>{try{const h=await M.put(`/config/providers/${encodeURIComponent(l.id)}`,{enabled:p.target.checked});t(s.map(g=>g.id===l.id?h:g))}catch(h){i.error(`Toggle failed: ${h.message}`)}}}),l.enabled!==!1?"on":"off"]}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Edit",title:"Edit",onClick:()=>o(l),children:e.jsx(ds,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Remove",title:"Remove",onClick:()=>d(l.id),children:e.jsx(ye,{size:12})})]})]}),e.jsxs("div",{className:"provider-meta",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Base URL:"})," ",e.jsx("code",{children:l.baseURL||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"API key:"})," ",e.jsx("code",{children:l.apiKey||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Models:"})," ",(l.models||[]).join(", ")||"—"]})]})]},l.id))})]})}function jl({onAdd:s}){return e.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"var(--text-dim)",border:"1px dashed var(--border)",borderRadius:"var(--radius-md)",display:"flex",flexDirection:"column",gap:8,alignItems:"center"},children:[e.jsx(Fe,{size:28}),e.jsx("div",{children:"No providers configured."}),e.jsx("div",{style:{fontSize:12},children:"Add a provider to connect an AI model."}),e.jsxs(C,{variant:"primary",size:"sm",onClick:s,children:[e.jsx(pe,{size:14})," Add your first provider"]})]})}function gl(s){const t={};for(const a of s.split(/\r?\n/)){const i=a.trim();if(!i||i.startsWith("#"))continue;const n=i.indexOf("=");if(n<=0)continue;const o=i.slice(0,n).trim(),d=i.slice(n+1).trim();o&&(t[o]=d)}return t}function fl(s){const t={};for(const a of s.split(/\r?\n/)){const i=a.trim();if(!i||i.startsWith("#"))continue;const n=i.indexOf(":");if(n<=0)continue;const o=i.slice(0,n).trim(),d=i.slice(n+1).trim();o&&(t[o]=d)}return t}function vl({mcps:s,onChange:t,onReload:a}){const i=oe(),n=ke(),o=l=>{let p=null,h=null,g=null,m=null,c=null,u=null,k=null,f=null,S=null;const b=!!l;l==null||l.type;const v=(l==null?void 0:l.type)==="remote"?"remote":"local",y=(l==null?void 0:l.command)||"",T=((l==null?void 0:l.args)||[]).join(" "),x=l!=null&&l.env?Object.entries(l.env).map(([R,L])=>`${R}=${L}`).join(`
|
|
334
|
+
`):"",E=(l==null?void 0:l.url)||"",q=l!=null&&l.headers?Object.entries(l.headers).map(([R,L])=>`${R}: ${L}`).join(`
|
|
335
|
+
`):"",I=!!(l!=null&&l.oauth),J=(l==null?void 0:l.enabled)!==!1;n.open({title:b?`Edit MCP "${l.id}"`:"Add MCP",children:e.jsxs("div",{children:[e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"ID (a-z, 0-9, dashes)"}),e.jsx("input",{ref:R=>p=R,className:"input",type:"text",defaultValue:(l==null?void 0:l.id)||"",placeholder:"supabase",disabled:b})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Type"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{ref:R=>R,type:"radio",name:"mcp-type",value:"local",defaultChecked:v==="local"}),"Local (stdio)"]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{ref:R=>h=R,type:"radio",name:"mcp-type",value:"remote",defaultChecked:v==="remote"}),"Remote (HTTP)"]})]})]}),e.jsxs("div",{"data-mcp-section":"local",children:[e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Command (binary to invoke)"}),e.jsx("input",{ref:R=>g=R,className:"input",type:"text",defaultValue:y,placeholder:"uvx --from semble[mcp] semble"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Extra args (space-separated)"}),e.jsx("input",{ref:R=>m=R,className:"input",type:"text",defaultValue:T,placeholder:"--port 8080"}),e.jsx("div",{className:"field-help",children:"These are appended after the command."})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Environment variables"}),e.jsx("textarea",{ref:R=>c=R,className:"textarea",defaultValue:x,placeholder:`API_KEY=xxx
|
|
336
|
+
DEBUG=true`,rows:3}),e.jsx("div",{className:"field-help",children:"One KEY=VALUE per line."})]})]}),e.jsxs("div",{"data-mcp-section":"remote",children:[e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"URL"}),e.jsx("input",{ref:R=>u=R,className:"input",type:"text",defaultValue:E,placeholder:"https://mcp.example.com/mcp"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Headers"}),e.jsx("textarea",{ref:R=>k=R,className:"textarea",defaultValue:q,placeholder:`Authorization: Bearer xxx
|
|
337
|
+
Content-Type: application/json`,rows:3}),e.jsx("div",{className:"field-help",children:'One "Key: Value" per line.'})]}),e.jsx("div",{className:"modal-form-row",children:e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{ref:R=>f=R,type:"checkbox",defaultChecked:I}),"Use OAuth (browser-based auth flow)"]})})]}),e.jsx("div",{className:"modal-form-row",children:e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{ref:R=>S=R,type:"checkbox",defaultChecked:J}),"Enabled"]})})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>n.close(),children:"Cancel"}),e.jsxs(C,{variant:"primary",onClick:async()=>{const R=((p==null?void 0:p.value)||"").trim(),L=!!(h!=null&&h.checked),W=((g==null?void 0:g.value)||"").trim(),G=((m==null?void 0:m.value)||"").trim(),w=G?G.split(/\s+/):[],$=gl((c==null?void 0:c.value)||""),V=((u==null?void 0:u.value)||"").trim(),K=fl((k==null?void 0:k.value)||""),X=!!(f!=null&&f.checked),ae=!!(S!=null&&S.checked);if(!R){i.warning("ID is required.");return}if(!/^[a-z0-9][a-z0-9_-]{0,63}$/i.test(R)){i.warning("ID must be a-z, 0-9, dashes.");return}try{const se={id:R,type:L?"remote":"local",command:W,args:w,env:$,url:V,headers:K,oauth:X,enabled:ae};if(b){const H=await M.put(`/config/mcps/${encodeURIComponent(R)}`,se);t(s.map(F=>F.id===R?H:F)),i.success(`MCP "${R}" updated.`)}else{const H=await M.post("/config/mcps",se);t([...s,H]),i.success(`MCP "${R}" added.`)}n.close()}catch(se){i.error(`Save failed: ${se.message}`)}},children:[b?"Update":"Add"," MCP"]})]})})},d=async l=>{if(confirm(`Remove MCP "${l}"?`))try{await M.del(`/config/mcps/${encodeURIComponent(l)}`),t(s.filter(p=>p.id!==l)),i.success("MCP removed.")}catch(p){i.error(`Remove failed: ${p.message}`)}};return e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(os,{size:14})," MCPs (",s.length,")"]}),e.jsxs(re,{children:["Model Context Protocol servers under ",e.jsx("code",{children:"opencode.json#mcp"}),". Local MCPs run as stdio subprocesses; remote MCPs are HTTP endpoints."]}),e.jsxs("div",{className:"view-actions",style:{marginBottom:12},children:[e.jsxs(C,{variant:"primary",size:"sm",onClick:()=>o(),children:[e.jsx(pe,{size:14})," Add MCP"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(de,{size:14})," Refresh"]})]}),s.length===0?e.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"var(--text-dim)",border:"1px dashed var(--border)",borderRadius:"var(--radius-md)",display:"flex",flexDirection:"column",gap:8,alignItems:"center"},children:[e.jsx(os,{size:28}),e.jsx("div",{children:"No MCPs configured."}),e.jsxs(C,{variant:"primary",size:"sm",onClick:()=>o(),children:[e.jsx(pe,{size:14})," Add your first MCP"]})]}):e.jsx("div",{className:"mcp-list",children:s.map(l=>e.jsxs(te,{className:"mcp-row",children:[e.jsxs("div",{className:"mcp-row-head",children:[e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{className:"mcp-name",children:l.id}),e.jsxs("div",{className:"mcp-id",children:[l.type==="remote"?"remote":"local"," ",l.enabled!==!1?"· enabled":"· disabled"]})]}),e.jsxs("div",{className:"mcp-actions",children:[e.jsxs("label",{className:"toggle-row",title:"Enabled",children:[e.jsx("input",{type:"checkbox",checked:l.enabled!==!1,onChange:async p=>{try{const h=await M.put(`/config/mcps/${encodeURIComponent(l.id)}`,{enabled:p.target.checked});t(s.map(g=>g.id===l.id?h:g))}catch(h){i.error(`Toggle failed: ${h.message}`)}}}),l.enabled!==!1?"on":"off"]}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Edit",title:"Edit",onClick:()=>o(l),children:e.jsx(ds,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Remove",title:"Remove",onClick:()=>d(l.id),children:e.jsx(ye,{size:12})})]})]}),e.jsx("div",{className:"mcp-meta",children:l.type==="remote"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"URL:"})," ",e.jsx("code",{children:l.url||"—"})]}),Object.keys(l.headers||{}).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Headers:"})," ",e.jsxs("code",{children:[Object.keys(l.headers||{}).length," header(s)"]})]}),l.oauth&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Auth:"})," ",e.jsx("code",{children:"OAuth"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Command:"})," ",e.jsx("code",{children:l.command||"—"})]}),l.args&&l.args.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Args:"})," ",e.jsx("code",{children:l.args.join(" ")})]}),l.env&&Object.keys(l.env).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Env:"})," ",e.jsxs("code",{children:[Object.keys(l.env).length," var(s)"]})]})]})})]},l.id))})]})}function yl({onDownload:s}){return e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Le,{size:14})," Export / Import"]}),e.jsx(re,{children:"Download a JSON bundle of diagnostics, configuration, providers, and MCPs for support requests or backup. Server-side imports are not yet implemented."}),e.jsx("div",{className:"view-actions",style:{marginTop:12},children:e.jsxs(C,{variant:"primary",onClick:s,children:[e.jsx(Le,{size:14})," Download diagnostics bundle"]})}),e.jsxs("div",{style:{marginTop:16,fontSize:12,color:"var(--text-dim)"},children:[e.jsx(Ys,{size:12,style:{display:"inline",verticalAlign:-2}})," Bundles include: opencode.json snapshot, providers list (with masked API keys), MCP list, recent service log errors, and active project metadata."]})]})}const bl=["ollama","openai","lollms","azure_openai","bedrock","gemini"],kl=["ollama","openai","azure_openai","bedrock","jina","gemini","voyageai"];function Nl({status:s,onReload:t,logLines:a,onReloadLog:i}){const n=oe(),[o,d]=r.useState(!1),[l,p]=r.useState(!1),[h,g]=r.useState(!1),[m,c]=r.useState(!1),[u,k]=r.useState(!1),[f,S]=r.useState({enabled:!0,host:"127.0.0.1",port:9621,workingDir:"",llmBinding:"ollama",embeddingBinding:"ollama",llmBindingHost:"",embeddingBindingHost:"",llmModel:"minimax/MiniMax-M3",embeddingModel:"text-embedding-3-small",apiKeySource:"env",apiKey:""}),[b,v]=r.useState(!1);r.useEffect(()=>{s&&(S(R=>({...R,enabled:!0,host:s.host,port:s.port,llmBinding:s.llmBinding,embeddingBinding:s.embeddingBinding,llmBindingHost:s.llmBindingHost||"",embeddingBindingHost:s.embeddingBindingHost||"",llmModel:s.llmModel,embeddingModel:s.embeddingModel,apiKeySource:"env",apiKey:""})),v(!1))},[s==null?void 0:s.running]);const y=(R,L)=>{S(W=>({...W,[R]:L})),v(!0)},T=async()=>{if(!o){d(!0);try{const R={enabled:f.enabled,host:f.host,port:f.port===""?9621:Number(f.port),workingDir:f.workingDir,llmBinding:f.llmBinding,embeddingBinding:f.embeddingBinding,llmBindingHost:f.llmBindingHost||null,embeddingBindingHost:f.embeddingBindingHost||null,llmModel:f.llmModel,embeddingModel:f.embeddingModel,apiKeySource:f.apiKeySource};f.apiKeySource==="file"&&f.apiKey!==""&&(R.apiKey=f.apiKey),f.apiKeySource==="env"&&(R.apiKey="<empty>"),await M.post("/memory/config",{patch:!0,lightrag:R}),n.success("LightRAG config saved."),v(!1),t()}catch(R){n.error(`Save failed: ${R.message}`)}finally{d(!1)}}},x=async()=>{if(!l){p(!0);try{const R=await M.post("/memory/lightrag/start");R.ok?n.success(`LightRAG started (pid ${R.pid}).`):n.error(`Start failed: ${R.error}`),t()}catch(R){n.error(`Start failed: ${R.message}`)}finally{p(!1)}}},E=async()=>{if(!h){g(!0);try{await M.post("/memory/lightrag/stop"),n.success("LightRAG stopped."),t()}catch(R){n.error(`Stop failed: ${R.message}`)}finally{g(!1)}}},q=async()=>{await E(),await x()},I=async()=>{u||(c(!0),await i(),c(!1)),k(R=>!R)},J=(s==null?void 0:s.running)??!1;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Ys,{size:14})," LightRAG Server"]}),e.jsxs(re,{children:["In-process embedding server for semantic memory search."," ",e.jsx("button",{type:"button",className:"link-btn",onClick:t,children:"Refresh"})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8,flexWrap:"wrap",alignItems:"center"},children:[J?e.jsxs("span",{className:"tag tag-success",children:["running ",s!=null&&s.pid?`(pid ${s.pid})`:""]}):e.jsx("span",{className:"tag tag-neutral",children:"stopped"}),s&&e.jsxs("span",{className:"mono text-sm muted",children:[s.host,":",s.port," · ",s.llmBinding," · ",s.embeddingModel]}),(s==null?void 0:s.lastError)&&e.jsxs("span",{className:"text-error text-sm",children:["⚠ ",s.lastError]})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:12,flexWrap:"wrap"},children:[J?e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"secondary",size:"sm",onClick:q,disabled:h||l,children:[e.jsx(de,{size:12})," Restart"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:E,disabled:h,children:[h?e.jsx(ge,{size:"sm"}):null,h?"Stopping…":"Stop"]})]}):e.jsxs(C,{variant:"primary",size:"sm",onClick:x,disabled:l,children:[l?e.jsx(ge,{size:"sm"}):e.jsx(de,{size:12}),l?"Starting…":"Start"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:I,children:[u?"Hide":"Show"," log"]})]}),u&&e.jsxs("div",{style:{marginTop:12},children:[e.jsxs("div",{className:"field-help",style:{marginBottom:6},children:["Last ",a.length," line(s)",e.jsx("button",{type:"button",className:"link-btn",style:{marginLeft:8},onClick:i,children:"Refresh"})]}),m?e.jsx("p",{className:"muted text-sm",children:"Loading…"}):a.length===0?e.jsx("p",{className:"muted text-sm",children:"No log output yet."}):e.jsx("pre",{className:"log-pre",children:a.join(`
|
|
338
|
+
`)})]})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(es,{size:14})," Bindings"]}),e.jsx(re,{children:"Choose the LLM and embedding provider bindings."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:12},children:[e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"LLM Binding"}),e.jsx("select",{className:"input",value:f.llmBinding,onChange:R=>y("llmBinding",R.target.value),children:bl.map(R=>e.jsx("option",{value:R,children:R},R))})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Embedding Binding"}),e.jsx("select",{className:"input",value:f.embeddingBinding,onChange:R=>y("embeddingBinding",R.target.value),children:kl.map(R=>e.jsx("option",{value:R,children:R},R))})]}),f.llmBinding!=="ollama"&&e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"LLM Binding Host"}),e.jsx("input",{className:"input",type:"text",value:f.llmBindingHost,onChange:R=>y("llmBindingHost",R.target.value),placeholder:"https://api.minimax.chat/v1"})]}),f.embeddingBinding!=="ollama"&&e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Embedding Binding Host"}),e.jsx("input",{className:"input",type:"text",value:f.embeddingBindingHost,onChange:R=>y("embeddingBindingHost",R.target.value),placeholder:"https://api.minimax.chat/v1"})]})]})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Fe,{size:14})," Models"]}),e.jsx(re,{children:"Model IDs for the LLM and embedding engine."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:12},children:[e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"LLM Model"}),e.jsx("input",{className:"input",type:"text",value:f.llmModel,onChange:R=>y("llmModel",R.target.value),placeholder:"minimax/MiniMax-M3"})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Embedding Model"}),e.jsx("input",{className:"input",type:"text",value:f.embeddingModel,onChange:R=>y("embeddingModel",R.target.value),placeholder:"text-embedding-3-small"})]})]})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(os,{size:14})," Connection"]}),e.jsx(re,{children:"Host, port, and working directory for the LightRAG server."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:12},children:[e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Host"}),e.jsx("input",{className:"input",type:"text",value:f.host,onChange:R=>y("host",R.target.value),placeholder:"127.0.0.1"})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Port"}),e.jsx("input",{className:"input",type:"number",min:1,max:65535,value:f.port,onChange:R=>y("port",R.target.value===""?"":Number(R.target.value)),placeholder:"9621"})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Working Dir"}),e.jsx("input",{className:"input",type:"text",value:f.workingDir,onChange:R=>y("workingDir",R.target.value),placeholder:".bizar/lightrag (default)"})]})]})]}),e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(es,{size:14})," Credentials"]}),e.jsx(re,{children:"API key source — set in your shell env, or stored in .bizar/memory.json."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:12},children:[e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Source"}),e.jsxs("select",{className:"input",value:f.apiKeySource,onChange:R=>y("apiKeySource",R.target.value),children:[e.jsx("option",{value:"env",children:"Environment variable (recommended)"}),e.jsx("option",{value:"file",children:"Stored in .bizar/memory.json"})]})]}),f.apiKeySource==="env"?e.jsxs("p",{className:"muted text-sm",style:{padding:"8px 0"},children:["Set ",e.jsx("code",{children:"OPENAI_API_KEY"})," (or provider-specific env var) in your shell before running reindex or queries."]}):e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"API Key"}),e.jsx("input",{className:"input",type:"password",value:f.apiKey,onChange:R=>y("apiKey",R.target.value),placeholder:s!=null&&s.running?"(unchanged — leave blank)":"sk-…",autoComplete:"off"})]})]})]}),e.jsx("div",{className:"view-actions",children:e.jsxs(C,{variant:"primary",disabled:!b||o,onClick:T,children:[o?e.jsx(ge,{size:"sm"}):e.jsx(Ze,{size:14}),o?"Saving…":"Save config"]})})]})}function wl({onAdd:s}){const t=oe(),[a,i]=r.useState(null),[n,o]=r.useState(!1),[d,l]=r.useState(!1),p=async c=>{o(!0);try{const u=await M.get(`/providers/auto-detect${c?"":"?probe=0"}`);i(u.providers||[]);const k=(u.providers||[]).filter(f=>f.status==="configured");k.length>0?t.success(`Detected ${k.length} configured provider${k.length===1?"":"s"}.`):t.info("No configured providers detected in env or config.")}catch(u){t.error(`Auto-detect failed: ${u.message}`)}finally{o(!1)}},h=c=>c==="configured"?e.jsx(es,{size:12,style:{color:"var(--success)"}}):c==="unknown"?e.jsx(De,{size:12,style:{color:"var(--warning)"}}):e.jsx($e,{size:12,style:{color:"var(--text-dim)"}}),g=(a||[]).filter(c=>c.status==="configured"),m=(a||[]).filter(c=>c.status!=="configured");return e.jsxs(te,{className:"autodetect-banner",children:[e.jsxs("div",{className:"autodetect-head",onClick:()=>l(c=>!c),children:[e.jsx(es,{size:14}),e.jsx("span",{className:"autodetect-title",children:"Auto-detect providers"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:a?`${g.length} configured · ${m.length} other`:"scan env vars + opencode.json for known keys"}),e.jsx("span",{className:"autodetect-spacer"}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),p(!0)},disabled:n,title:"Probe each provider's /models endpoint",children:[n?e.jsx(ge,{size:"sm"}):e.jsx(de,{size:12})," Detect"]}),d?e.jsx(Ae,{size:14}):e.jsx(He,{size:14})]}),d&&e.jsx("div",{className:"autodetect-body",children:a?e.jsxs("table",{className:"autodetect-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Provider"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Probe"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:a.map(c=>{var u,k,f;return e.jsxs("tr",{children:[e.jsxs("td",{children:[h(c.status)," ",e.jsx("span",{className:"autodetect-status",children:c.status})]}),e.jsxs("td",{children:[e.jsx("strong",{children:c.name})," ",e.jsx("span",{className:"muted mono",children:c.id})]}),e.jsx("td",{className:"muted",children:c.keySource||"—"}),e.jsx("td",{className:"muted",children:((u=c.probed)==null?void 0:u.modelCount)!=null?`${c.probed.modelCount} models`:(k=c.probed)!=null&&k.reason?c.probed.reason:(f=c.probed)!=null&&f.ok?"ok":"—"}),e.jsx("td",{children:c.status==="configured"&&e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>s(c.id,c.name,c.baseURL||""),title:"Add this provider to opencode.json",children:[e.jsx(pe,{size:10})," Add"]})})]},c.id)})})]}):e.jsxs("div",{className:"muted",style:{padding:12,fontSize:12},children:["Click ",e.jsx("strong",{children:"Detect"})," to scan env vars and opencode.json for known provider keys. Probes each provider's ",e.jsx("code",{children:"/models"})," endpoint with a 1.5s timeout."]})})]})}const Sl=[{id:"dark",label:"Dark",Icon:xa},{id:"light",label:"Light",Icon:ja},{id:"system",label:"System",Icon:ga}],Cl=[{name:"Purple",accent:"#8b5cf6"},{name:"Blue",accent:"#3b82f6"},{name:"Green",accent:"#10b981"},{name:"Orange",accent:"#f97316"},{name:"Red",accent:"#ef4444"},{name:"Pink",accent:"#ec4899"},{name:"Cyan",accent:"#06b6d4"},{name:"Mono",accent:"#6b7280"}],zl=["Inter","system-ui","Segoe UI","Roboto","JetBrains Mono","SF Mono","Cascadia Code"];function Ml(s){if(s<=0)return"expired";const t=Math.floor(s/1e3),a=Math.floor(t/60),i=t%60;return`${a}:${String(i).padStart(2,"0")}`}function Tl(){const s=oe(),[t,a]=r.useState(null),[i,n]=r.useState(!1),[o,d]=r.useState(null),[l,p]=r.useState(Date.now()),h=r.useCallback(async()=>{n(!0),d(null);try{const c=await M.post("/pair/start");a(c)}catch(c){d((c==null?void 0:c.message)||"Failed to start pairing"),s.error("Pairing failed.")}finally{n(!1)}},[s]);r.useEffect(()=>{if(!t)return;const c=setInterval(()=>p(Date.now()),1e3);return()=>clearInterval(c)},[t]);const g=t?t.expiresAt-l:0,m=t!=null&&g<=0;return e.jsxs(te,{id:"settings-updates","data-section":"updates",children:[e.jsxs(ie,{children:[e.jsx(fa,{size:14})," Companion App"]}),e.jsxs(re,{children:["Scan the QR with ",e.jsx("a",{href:"https://github.com/DrB0rk/BizarHarness",target:"_blank",rel:"noopener noreferrer",children:"Bizar Companion"})," to pair. Tokens expire after 5 minutes."]}),e.jsxs("div",{style:{display:"flex",gap:16,alignItems:"flex-start",flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:"0 0 auto"},children:t&&!m?e.jsx("div",{style:{background:"#fff",padding:12,borderRadius:12},children:e.jsx(va,{value:t.qrPayload,size:192,level:"M",includeMargin:!1})}):e.jsx("div",{style:{width:216,height:216,borderRadius:12,background:"var(--surface-2, #161b22)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted, #8b949e)",fontSize:12,textAlign:"center",padding:16,border:"1px dashed var(--border, #30363d)"},children:t&&m?"QR expired":"No QR generated yet"})}),e.jsxs("div",{style:{flex:"1 1 240px",minWidth:220},children:[!t&&e.jsxs(C,{variant:"primary",onClick:h,disabled:i,children:[e.jsx(ya,{size:14})," ",i?"Generating…":"Generate QR Code"]}),t&&!m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:10},children:[e.jsx("strong",{children:"Expires in"})," ",e.jsx("span",{className:"mono",children:Ml(g)})]}),e.jsxs("div",{style:{marginBottom:6},children:[e.jsx("strong",{children:"URL:"})," ",e.jsx("span",{className:"mono",style:{wordBreak:"break-all"},children:t.publicUrl})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("strong",{children:"Token:"})," ",e.jsxs("span",{className:"mono",style:{wordBreak:"break-all",fontSize:12},children:[t.token.slice(0,16),"…",t.token.slice(-6)]})]}),e.jsxs(C,{variant:"secondary",onClick:h,disabled:i,children:[e.jsx(de,{size:14})," Regenerate"]})]}),t&&m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{marginBottom:12,color:"var(--error, #f85149)"},children:"Token expired — generate a fresh QR to pair again."}),e.jsxs(C,{variant:"primary",onClick:()=>{a(null),h()},children:[e.jsx(de,{size:14})," Generate new QR"]})]}),o&&e.jsx("div",{style:{marginTop:10,color:"var(--error, #f85149)",fontSize:12},children:o})]})]})]})}const Al=[{id:"topnav",label:"Top nav"},{id:"sidebar",label:"Sidebar"},{id:"both",label:"Both"}];function $l(){const s=oe(),[t,a]=r.useState({current:{},latest:null,checking:!1,updating:!1,hasUpdates:!1,requiresRestart:!1,perPackage:{}});r.useEffect(()=>{const p=new Gs;return p.on(h=>{(h.type==="update:progress"||h.type==="update:log"||h.type==="update:complete")&&a(g=>{if(h.type==="update:complete")return{...g,updating:!1,requiresRestart:!!h.requiresRestart};if(h.type==="update:log"){const c=h,u=g.perPackage[c.pkg]||{logs:[]};return{...g,perPackage:{...g.perPackage,[c.pkg]:{...u,logs:[...(u.logs||[]).slice(-50),c.line]}}}}const m=h;return{...g,perPackage:{...g.perPackage,[m.pkg]:{...g.perPackage[m.pkg],status:m.status,error:m.error,newVersion:m.newVersion}}}})}),()=>p.close()},[]),r.useEffect(()=>{M.get("/updates/status").then(p=>a(h=>({...h,current:p.current}))).catch(p=>a(h=>({...h,error:p.message})))},[]);const i=async()=>{a(p=>({...p,checking:!0,error:void 0}));try{const p=await M.get("/updates/check");a(h=>({...h,checking:!1,current:p.current,latest:p.latest,hasUpdates:p.hasUpdates}))}catch(p){a(h=>({...h,checking:!1,error:p.message}))}},n=async()=>{if(confirm("Update Bizar packages? The dashboard will restart automatically.")){a(p=>({...p,updating:!0,requiresRestart:!1,perPackage:{},error:void 0}));try{await M.post("/updates/apply",{packages:["bizar","bizar-dash","bizar-plugin"]})}catch(p){a(h=>({...h,updating:!1,error:p.message}))}}},o=async()=>{if(confirm("Restart the dashboard? You will be disconnected briefly."))try{await M.post("/restart"),s.info("Restarting…",3e3),setTimeout(()=>window.location.reload(),3e3)}catch{s.error("Restart failed")}},d=[{id:"bizar",name:"Bizar CLI"},{id:"bizar-dash",name:"Dashboard"},{id:"bizar-plugin",name:"Opencode Plugin"}],l=t.checking||t.updating;return e.jsxs(te,{id:"settings-updates","data-section":"updates",children:[e.jsxs(ie,{children:[e.jsx(Le,{size:14})," Updates"]}),e.jsx(re,{children:"Check installed Bizar packages and apply dashboard updates."}),e.jsxs("div",{className:"updates-current",children:[e.jsx("h4",{children:"Installed versions"}),e.jsx("ul",{children:d.map(p=>e.jsxs("li",{children:[e.jsx("span",{children:p.name}),e.jsx("code",{className:"mono",children:t.current[p.id]||"—"})]},p.id))})]}),t.latest&&e.jsxs("div",{className:"updates-latest",children:[e.jsx("h4",{children:"Latest available"}),e.jsx("ul",{children:d.map(p=>{var c;const h=t.current[p.id],g=(c=t.latest)==null?void 0:c[p.id],m=h&&g&&h!==g;return e.jsxs("li",{className:m?"updates-outdated":"updates-current-version",children:[e.jsx("span",{children:p.name}),e.jsxs("code",{className:"mono",children:[g||"—",m&&e.jsx("span",{className:"updates-badge",children:"update available"})]})]},p.id)})})]}),t.updating&&e.jsx("div",{className:"updates-progress-rows",children:d.map(p=>{const h=t.perPackage[p.id]||{status:"idle",logs:[]};return e.jsxs("div",{className:"updates-pkg-row",children:[e.jsxs("div",{className:"updates-pkg-row-header",children:[e.jsx("span",{className:"updates-pkg-name",children:p.name}),e.jsxs("div",{className:"updates-pkg-status",children:[h.status==="starting"&&e.jsx("span",{className:"btn-spinner"}),h.status==="installing"&&e.jsx("span",{className:"btn-spinner"}),h.status==="done"&&e.jsx(Ia,{size:14,className:"icon-success"}),h.status==="error"&&e.jsx(qs,{size:14,className:"icon-error"}),e.jsx("span",{children:h.status}),h.newVersion&&e.jsxs("code",{className:"mono",style:{fontSize:11},children:["→ ",h.newVersion]})]})]}),h.logs.length>0&&e.jsxs("details",{className:"updates-pkg-logs",children:[e.jsxs("summary",{children:["npm output (",h.logs.length," lines)"]}),e.jsx("pre",{children:h.logs.join(`
|
|
339
|
+
`)})]}),h.status==="error"&&h.error&&e.jsxs("div",{className:"updates-pkg-error",children:[e.jsx(De,{size:12})," ",h.error]})]},p.id)})}),e.jsxs("div",{className:"updates-actions",children:[e.jsxs(C,{onClick:i,disabled:l,children:[t.checking?e.jsx("span",{className:"btn-spinner"}):e.jsx(de,{size:14}),"Check for updates"]}),e.jsxs(C,{variant:"primary",onClick:n,disabled:!t.hasUpdates||t.updating,children:[t.updating?e.jsx("span",{className:"btn-spinner"}):e.jsx(Le,{size:14}),t.updating?"Updating…":t.hasUpdates?"Update now":"Up to date"]}),t.requiresRestart&&e.jsxs(C,{variant:"danger",onClick:o,children:[e.jsx(de,{size:14})," Restart Dashboard"]})]}),t.error&&e.jsxs("div",{className:"updates-error",children:[e.jsx(De,{size:14}),e.jsx("span",{children:t.error})]})]})}function Il({settings:s,refreshSnapshot:t}){var P,A,D,Q,z,_,O;const a=oe(),[i,n]=r.useState(s),[o,d]=r.useState(!1),[l,p]=r.useState(!1),[h,g]=r.useState(null),[m,c]=r.useState({port:4321,https:!0,hostname:""}),[u,k]=r.useState({});r.useEffect(()=>{n(s),d(!1),s.theme&&Je(s.theme)},[s]),r.useEffect(()=>{h&&c({port:h.settings.port,https:h.settings.https!==!1,hostname:h.settings.hostname||""})},[h]),r.useEffect(()=>{M.get("/tailscale/status").then(g).catch(()=>{})},[]),r.useEffect(()=>{M.get("/settings/plugin-options").then(k).catch(()=>{})},[]);const f=j=>{n(U=>{const ee={...U,theme:{...U.theme,...j}};return Je(ee.theme),ee}),d(!0)},S=j=>{n(U=>({...U,ui:{...U.ui,...j}})),d(!0)},b=(j,U)=>{n(ee=>({...ee,[j]:U})),d(!0)},v=j=>{n(U=>({...U,notifications:{...U.notifications,...j}})),d(!0)},y=j=>{n(U=>({...U,agents:{...U.agents,...j}})),d(!0)},T=[{id:"theme",label:"Theme"},{id:"layout",label:"Layout"},{id:"general",label:"General"},{id:"service",label:"Service"},{id:"tailscale",label:"Tailscale"},{id:"notifications",label:"Notifications"},{id:"auth",label:"Auth"},{id:"agents",label:"Agents"},{id:"dashboard",label:"Dashboard"},{id:"background",label:"Background"},{id:"system-llm",label:"System LLM"},{id:"updates",label:"Updates"},{id:"activity-log",label:"Activity"},{id:"about",label:"About"}],[x,E]=r.useState(()=>{if(typeof window>"u")return null;const j=window.location.hash.replace(/^#settings-/,"");return T.some(U=>U.id===j)?j:null}),q=j=>{E(j);try{const U=j?`#settings-${j}`:window.location.pathname;if(history.replaceState(null,"",U),j){const ee=document.getElementById(`settings-${j}`);ee&&ee.scrollIntoView({behavior:"smooth",block:"start"})}else window.scrollTo({top:0,behavior:"smooth"})}catch{}},I=j=>{n(U=>({...U,dashboard:{...U.dashboard,...j}})),d(!0)},J=async()=>{p(!0);try{const j=await M.put("/settings",i);n(j.data),d(!1),ts(j.data.theme),Je(j.data.theme),a.success("Settings saved."),await t()}catch(j){a.error(`Save failed: ${j.message}`)}finally{p(!1)}},R=async()=>{try{const j=await M.get("/settings");n(j.data),d(!1),ts(j.data.theme),Je(j.data.theme),a.info("Settings reloaded.",1500)}catch(j){a.error(`Reload failed: ${j.message}`)}},L=async()=>{if(confirm("Reset all settings to defaults?"))try{const j=await M.post("/settings/reset");n(j.data),d(!1),ts(j.data.theme),Je(j.data.theme),a.success("Settings reset."),await t()}catch(j){a.error(`Reset failed: ${j.message}`)}},W=async()=>{try{h!=null&&h.settings.enabled?(await M.post("/tailscale/disable"),a.success("Tailscale serve disabled.")):(await M.post("/tailscale/enable",{port:m.port||4321,https:m.https,hostname:m.hostname||""}),a.success("Tailscale serve enabled."));const j=await M.get("/tailscale/status");g(j)}catch(j){a.error(`Tailscale failed: ${j.message}`)}},G=i.about||{version:"3.0.4",homepage:"https://github.com/DrB0rk/BizarHarness",license:"MIT"},[w,$]=r.useState(M.getToken()),[V,K]=r.useState(null),[X,ae]=r.useState("");r.useEffect(()=>{let j=!1;return(async()=>{try{const U=await M.probeAuthStatus();j||K(U)}catch{j||K({required:!0,loopback:!1,peer:""})}})(),()=>{j=!0}},[]);const se=async()=>{try{const j=await M.get("/auth/reveal");ae(j.token),$(j.token),M.setToken(j.token);try{await navigator.clipboard.writeText(j.token),a.success("Token copied to clipboard.")}catch{a.success("Token revealed — copy from the field below.")}}catch(j){a.error(`Reveal failed: ${j.message}`)}},H=async()=>{if(confirm("Regenerate the auth token? Anything still using the old token will start getting 401 errors immediately."))try{const j=await M.post("/auth/regenerate");ae(j.token),$(j.token),M.setToken(j.token);try{await navigator.clipboard.writeText(j.token),a.success("New token generated and copied to clipboard.")}catch{a.success("New token generated — copy from the field below. Old token is now invalid.")}}catch(j){a.error(`Regenerate failed: ${j.message}`)}},F=()=>{M.setToken(w.trim()),a.success("Token saved. The dashboard will use it on the next request.")};return e.jsxs("div",{className:"view view-settings",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(ft,{size:18})," Settings"]}),e.jsxs("p",{className:"view-subtitle",children:["Personal preferences. Changes are saved to"," ",e.jsx("code",{children:"~/.config/bizar/settings.json"}),"."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:L,children:[e.jsx(nt,{size:14})," Reset"]}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:R,children:[e.jsx(de,{size:14})," Reload"]}),e.jsxs(C,{variant:"primary",size:"sm",disabled:!o||l,onClick:J,children:[l?e.jsx("span",{className:"btn-spinner"}):e.jsx(Ze,{size:14}),l?"Saving…":"Save"]})]})]}),e.jsxs("nav",{className:"settings-subnav","aria-label":"Settings sections",children:[e.jsx("button",{type:"button",className:ne("settings-subnav-button","settings-subnav-button-all",x===null&&"settings-subnav-button-active"),onClick:()=>q(null),title:"Show all settings sections",children:"All"}),T.map(j=>e.jsx("button",{type:"button",className:ne("settings-subnav-button",x===j.id&&"settings-subnav-button-active"),onClick:()=>q(j.id),children:j.label},j.id))]}),e.jsxs("div",{className:ne("settings-grid",x&&"settings-grid-filtered"),"data-active-section":x||void 0,children:[x&&e.jsxs("div",{className:"settings-filter-banner",children:[e.jsxs("span",{children:["Showing only ",e.jsx("strong",{children:(P=T.find(j=>j.id===x))==null?void 0:P.label}),"."]}),e.jsx("button",{type:"button",className:"settings-filter-clear",onClick:()=>q(null),children:"Show all sections"})]}),e.jsx("div",{"data-section":"theme",style:{display:x===null||x==="theme"?"block":"none"},children:e.jsxs(te,{id:"settings-theme","data-section":"theme",children:[e.jsxs(ie,{children:[e.jsx(At,{size:14})," Theme"]}),e.jsx(re,{children:"Mode, accent, and colors. Live preview as you tweak."}),e.jsxs("div",{className:"field","data-setting-id":"theme.presets",children:[e.jsx("label",{className:"field-label",children:"Accent presets"}),e.jsx("div",{className:"theme-presets",children:Cl.map(j=>e.jsxs("button",{type:"button",className:ne("theme-preset",i.theme.accent===j.accent&&"theme-preset-active"),onClick:()=>f({accent:j.accent}),title:j.name,children:[e.jsx("span",{className:"theme-preset-swatch",style:{background:j.accent}}),e.jsx("span",{className:"theme-preset-name",children:j.name})]},j.name))})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.mode",children:[e.jsx("label",{className:"field-label",children:"Mode"}),e.jsx("div",{className:"theme-row",children:Sl.map(({id:j,label:U,Icon:ee})=>{const B=i.theme.mode===j;return e.jsxs("button",{type:"button",className:ne("theme-card",B&&"theme-card-active"),onClick:()=>f({mode:j}),children:[e.jsx(ee,{size:16}),e.jsx("span",{className:"theme-card-label",children:U}),e.jsx("span",{className:ne("theme-card-swatch",`theme-card-swatch-${j}`)})]},j)})})]}),e.jsxs("div",{className:"theme-colors",children:[e.jsxs("div",{className:"field","data-setting-id":"theme.accent",children:[e.jsx("label",{className:"field-label",children:"Accent"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.accent,onChange:j=>f({accent:j.target.value}),"aria-label":"Accent color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.accent,onChange:j=>f({accent:j.target.value})})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.success",children:[e.jsx("label",{className:"field-label",children:"Success"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.success,onChange:j=>f({success:j.target.value}),"aria-label":"Success color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.success,onChange:j=>f({success:j.target.value})})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.warning",children:[e.jsx("label",{className:"field-label",children:"Warning"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.warning,onChange:j=>f({warning:j.target.value}),"aria-label":"Warning color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.warning,onChange:j=>f({warning:j.target.value})})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.error",children:[e.jsx("label",{className:"field-label",children:"Error"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.error,onChange:j=>f({error:j.target.value}),"aria-label":"Error color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.error,onChange:j=>f({error:j.target.value})})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.info",children:[e.jsx("label",{className:"field-label",children:"Info"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.info,onChange:j=>f({info:j.target.value}),"aria-label":"Info color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.info,onChange:j=>f({info:j.target.value})})]})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.fontFamily",children:[e.jsx("label",{className:"field-label",children:"Font family"}),e.jsx("select",{className:"select",value:i.theme.fontFamily,onChange:j=>f({fontFamily:j.target.value}),children:zl.map(j=>e.jsx("option",{value:j,children:j},j))})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.fontSize",children:[e.jsxs("label",{className:"field-label",children:["Font size: ",i.theme.fontSize,"px"]}),e.jsx("input",{type:"range",min:12,max:20,value:i.theme.fontSize,onChange:j=>f({fontSize:Number(j.target.value)})})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"theme.compactMode",children:[e.jsx("input",{type:"checkbox",checked:i.theme.compactMode,onChange:j=>f({compactMode:j.target.checked})}),e.jsx("span",{children:"Compact mode (denser UI)"})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"theme.animations",children:[e.jsx("input",{type:"checkbox",checked:i.theme.animations,onChange:j=>f({animations:j.target.checked})}),e.jsx("span",{children:"Enable animations"})]})]})}),e.jsx("div",{"data-section":"updates",style:{display:x===null||x==="updates"?"block":"none"},children:e.jsx($l,{})}),e.jsx("div",{"data-section":"layout",style:{display:x===null||x==="layout"?"block":"none"},children:e.jsxs(te,{id:"settings-layout","data-section":"layout",children:[e.jsxs(ie,{children:[e.jsx(Za,{size:14})," UI layout"]}),e.jsx(re,{children:"Choose how the dashboard's navigation is presented."}),e.jsx("div",{className:"layout-row","data-setting-id":"ui.layout",children:Al.map(j=>e.jsx("button",{type:"button",className:ne("layout-card",i.ui.layout===j.id&&"layout-card-active"),onClick:()=>S({layout:j.id}),children:e.jsx("span",{className:"layout-card-label",children:j.label})},j.id))}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"ui.showHeader",children:[e.jsx("input",{type:"checkbox",checked:i.ui.showHeader,onChange:j=>S({showHeader:j.target.checked})}),e.jsx("span",{children:"Show header"})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"ui.showStatusBar",children:[e.jsx("input",{type:"checkbox",checked:i.ui.showStatusBar,onChange:j=>S({showStatusBar:j.target.checked})}),e.jsx("span",{children:"Show status bar"})]}),e.jsxs("div",{className:"field","data-setting-id":"ui.defaultTab",children:[e.jsx("label",{className:"field-label",children:"Default tab"}),e.jsxs("select",{className:"select",value:i.ui.defaultTab,onChange:j=>S({defaultTab:j.target.value}),children:[e.jsx("option",{value:"overview",children:"Overview"}),e.jsx("option",{value:"chat",children:"Chat"}),e.jsx("option",{value:"agents",children:"Agents"}),e.jsx("option",{value:"artifacts",children:"Plans"}),e.jsx("option",{value:"projects",children:"Projects"}),e.jsx("option",{value:"tasks",children:"Tasks"}),e.jsx("option",{value:"config",children:"Config"}),e.jsx("option",{value:"settings",children:"Settings"}),e.jsx("option",{value:"mods",children:"Mods"}),e.jsx("option",{value:"schedules",children:"Schedules"})]})]})]})}),e.jsx("div",{"data-section":"general",style:{display:x===null||x==="general"?"block":"none"},children:e.jsxs(te,{id:"settings-general","data-section":"general",children:[e.jsx(ie,{children:"General"}),e.jsx(re,{children:"Default agent + model override."}),e.jsxs("div",{className:"field","data-setting-id":"defaultAgent",children:[e.jsx("label",{className:"field-label",htmlFor:"set-default-agent",children:"Default agent"}),e.jsx("input",{id:"set-default-agent",className:"input",type:"text",placeholder:"e.g. odin",value:i.defaultAgent||"",onChange:j=>b("defaultAgent",j.target.value)})]}),e.jsxs("div",{className:"field","data-setting-id":"defaultModel",children:[e.jsx("label",{className:"field-label",htmlFor:"set-default-model",children:"Model override"}),e.jsx("input",{id:"set-default-model",className:"input",type:"text",placeholder:"(leave empty for provider default)",value:i.defaultModel||"",onChange:j=>b("defaultModel",j.target.value)})]})]})}),e.jsx("div",{"data-section":"service",style:{display:x===null||x==="service"?"block":"none"},children:e.jsxs(te,{id:"settings-service","data-section":"service",children:[e.jsxs(ie,{children:[e.jsx(Fe,{size:14})," Service"]}),e.jsx(re,{children:"Background daemon that runs schedules."}),e.jsx("div",{"data-setting-id":"service.enabled",children:h?e.jsxs("div",{className:"service-card",children:[e.jsxs("p",{children:["Status: ",e.jsx("strong",{children:h!=null&&h.settings.enabled?"enabled":"disabled"})," ","· Tailscale installed: ",e.jsx("strong",{children:h.installed?"yes":"no"})," ","· authenticated: ",e.jsx("strong",{children:h.authenticated?"yes":"no"})]}),e.jsxs("p",{className:"muted",children:["Use ",e.jsx("code",{children:"bizar service start"})," / ",e.jsx("code",{children:"bizar service stop"})," in your terminal to control the daemon."]})]}):e.jsx("p",{className:"muted",children:"Loading service status…"})})]})}),e.jsx("div",{"data-section":"tailscale",style:{display:x===null||x==="tailscale"?"block":"none"},children:e.jsxs(te,{id:"settings-tailscale","data-section":"tailscale",children:[e.jsxs(ie,{children:[e.jsx(os,{size:14})," Tailscale serve"]}),e.jsx(re,{children:"Expose the dashboard over your Tailscale network."}),h?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Installed: ",e.jsx("strong",{children:h.installed?"yes":"no"})," ",h.version&&e.jsxs("span",{className:"muted",children:["(",h.version,")"]})]}),e.jsxs("p",{children:["Authenticated: ",e.jsx("strong",{children:h.authenticated?"yes":"no"})]}),e.jsxs("p",{children:["Serve enabled: ",e.jsx("strong",{children:h.settings.enabled?"yes":"no"})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Port"}),e.jsx("input",{type:"number",className:"input",value:m.port,onChange:j=>c(U=>({...U,port:Number(j.target.value)||4321}))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Use HTTPS"}),e.jsx("input",{type:"checkbox",checked:m.https,onChange:j=>c(U=>({...U,https:j.target.checked}))})]})]}),e.jsx(C,{variant:"primary",onClick:W,children:h.settings.enabled?"Disable serve":"Enable serve"})]}):e.jsx("p",{className:"muted",children:"Loading Tailscale status…"})]})}),e.jsx("div",{"data-section":"notifications",style:{display:x===null||x==="notifications"?"block":"none"},children:e.jsxs(te,{id:"settings-notifications","data-section":"notifications",children:[e.jsx(ie,{children:"Notifications"}),e.jsx(re,{children:"Toast triggers inside the dashboard."}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"notifications.onAgentComplete",children:[e.jsx("input",{type:"checkbox",checked:!!i.notifications.onAgentComplete,onChange:j=>v({onAgentComplete:j.target.checked})}),e.jsx("span",{children:"Notify when an agent invocation completes"})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"notifications.onPlanApproval",children:[e.jsx("input",{type:"checkbox",checked:!!i.notifications.onPlanApproval,onChange:j=>v({onPlanApproval:j.target.checked})}),e.jsx("span",{children:"Notify when a plan needs approval"})]})]})}),e.jsx("div",{"data-section":"auth",style:{display:x===null||x==="auth"?"block":"none"},children:e.jsxs(te,{id:"settings-auth","data-section":"auth",children:[e.jsxs(ie,{children:[e.jsx(nn,{size:14})," Authentication"]}),e.jsx(re,{children:"Localhost and Tailscale browser access are auto-trusted via loopback. A bearer token is still available for non-loopback clients and forced-auth mode."}),e.jsxs("div",{className:"field","data-setting-id":"auth.status",children:[e.jsx("label",{className:"field-label",children:"Server status"}),e.jsxs("p",{style:{margin:"4px 0"},children:["Auth required:"," ",e.jsx("strong",{children:V?V.required?"yes":"no":"probing…"})]}),e.jsxs("p",{style:{margin:"4px 0"},children:["Connection:"," ",e.jsx("strong",{children:V?V.loopback?"loopback (auto-trusted)":"remote":"probing…"})]}),e.jsxs("p",{style:{margin:"4px 0"},children:["Peer address:"," ",V!=null&&V.peer?e.jsx("code",{children:V.peer}):e.jsx("span",{className:"muted",children:"probing…"})]}),e.jsxs("p",{className:"muted",style:{fontSize:12,margin:"4px 0"},children:["Localhost and Tailscale browser access are auto-trusted because the dashboard sees a loopback peer. Paste a token only for non-loopback API clients/scripts, or if you force auth for every connection with"," ",e.jsx("code",{children:"BIZAR_DASHBOARD_REQUIRE_AUTH=1"}),"."]}),e.jsxs("p",{className:"muted",style:{fontSize:12,margin:"4px 0"},children:["Dashboard tokens are generated on first boot and saved to"," ",e.jsx("code",{children:"~/.config/bizar/dashboard-secret"})," (mode 0600)."]})]}),e.jsxs("div",{className:"field","data-setting-id":"auth.token",children:[e.jsx("label",{className:"field-label",children:"Token (this browser)"}),e.jsx("input",{type:"password",className:"input mono",value:w,onChange:j=>$(j.target.value),placeholder:"Paste token from server stderr or another browser",spellCheck:!1,autoComplete:"off"}),e.jsxs("div",{className:"task-form-row",style:{marginTop:8},children:[e.jsxs(C,{variant:"secondary",size:"sm",onClick:F,children:[e.jsx(Va,{size:14})," Save token"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:se,children:[e.jsx(Ss,{size:14})," Reveal & copy server token"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:H,children:[e.jsx(nt,{size:14})," Regenerate"]})]}),X?e.jsxs("p",{className:"muted",style:{fontSize:12,marginTop:8},children:["Last revealed token (one-time): ",e.jsx("code",{className:"mono",children:X})]}):null,e.jsx("p",{className:"muted",style:{fontSize:12,marginTop:8},children:"Regenerating invalidates the current token immediately. Anything still using the old token will see 401 until it's updated."})]})]})}),e.jsx("div",{"data-section":"agents",style:{display:x===null||x==="agents"?"block":"none"},children:e.jsxs(te,{id:"settings-agents","data-section":"agents",children:[e.jsxs(ie,{children:[e.jsx(Fe,{size:14})," Agent Behavior"]}),e.jsx(re,{children:"Limits and timeouts for background agent dispatch."}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"agents-maxParallel",children:["Max parallel agents",e.jsx("span",{className:"meta-badge",children:"default: 6"})]}),e.jsx("input",{id:"agents-maxParallel",type:"number",min:1,max:20,value:((A=i.agents)==null?void 0:A.maxParallel)??6,onChange:j=>y({maxParallel:Math.max(1,Math.min(20,parseInt(j.target.value,10)||6))})})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"agents-stuckThresholdMs",children:["Stuck threshold (ms)",e.jsx("span",{className:"meta-badge",children:"default: 600000 (10 min)"})]}),e.jsx("input",{id:"agents-stuckThresholdMs",type:"number",min:6e4,max:36e5,step:6e4,value:((D=i.agents)==null?void 0:D.stuckThresholdMs)??6e5,onChange:j=>y({stuckThresholdMs:Math.max(6e4,Math.min(36e5,parseInt(j.target.value,10)||6e5))})})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"agents.autoRestart",children:[e.jsx("input",{type:"checkbox",checked:!!((Q=i.agents)!=null&&Q.autoRestart),onChange:j=>y({autoRestart:j.target.checked})}),e.jsx("span",{children:"Auto-restart stuck agents"})]})]})}),e.jsx("div",{"data-section":"dashboard",style:{display:x===null||x==="dashboard"?"block":"none"},children:e.jsxs(te,{id:"settings-dashboard","data-section":"dashboard",children:[e.jsxs(ie,{children:[e.jsx(rs,{size:14})," Dashboard"]}),e.jsxs(re,{children:["Controls how ",e.jsx("code",{children:"bizar"})," starts up."]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"dashboard.autoLaunchWeb",children:[e.jsx("input",{type:"checkbox",checked:i.dashboard.autoLaunchWeb!==!1,onChange:j=>I({autoLaunchWeb:j.target.checked})}),e.jsx("span",{children:"Auto-launch web UI alongside TUI"})]}),e.jsxs("div",{className:"field","data-setting-id":"dashboard.projectsDirectory",style:{marginTop:"var(--space-4)"},children:[e.jsx("label",{className:"field-label",htmlFor:"set-projects-directory",children:"Projects directory"}),e.jsx("input",{id:"set-projects-directory",className:"input",type:"text",placeholder:"/home/user/projects",value:i.dashboard.projectsDirectory??"",onChange:j=>I({projectsDirectory:j.target.value})}),e.jsx("p",{className:"field-help",children:"New projects created via the dashboard will land here, and existing project directories inside this folder are auto-recognized on startup."}),i.dashboard.projectsDirectory&&e.jsxs(e.Fragment,{children:[!/^\/|^[A-Za-z]:/.test(i.dashboard.projectsDirectory)&&e.jsx("p",{style:{color:"var(--warning)",fontSize:11,marginTop:4},children:"Path should be absolute (start with / on Linux/Mac, or a drive letter on Windows)."}),i.dashboard.projectsDirectory.includes("..")&&e.jsx("p",{style:{color:"var(--error)",fontSize:11,marginTop:4},children:"Path traversal not allowed — this will be rejected server-side."})]})]}),e.jsxs("div",{className:"field","data-setting-id":"dashboard.allowedRoots",style:{marginTop:"var(--space-4)"},children:[e.jsxs("label",{className:"field-label",htmlFor:"set-allowed-roots",children:["Additional allowed roots ",e.jsx("span",{className:"muted",children:"(advanced)"})]}),e.jsx("textarea",{id:"set-allowed-roots",className:"textarea",rows:4,placeholder:`/workspace
|
|
340
|
+
/srv/projects`,value:(i.dashboard.allowedRoots??[]).join(`
|
|
341
|
+
`),onChange:j=>{const U=j.target.value.split(`
|
|
342
|
+
`).map(ee=>ee.trim()).filter(Boolean);I({allowedRoots:U})}}),e.jsx("p",{className:"field-help",children:"Optional. Add filesystem roots beyond your home directory that the file browser and project scanner can access. Each path must be inside your home directory. One per line."}),(()=>{const j=(i.dashboard.allowedRoots??[]).join(`
|
|
343
|
+
`).split(`
|
|
344
|
+
`),U=[];return j.forEach((ee,B)=>{ee.trim()&&(/^\/|^[A-Za-z]:/.test(ee)||U.push({key:`noabs-${B}`,msg:e.jsxs("p",{style:{color:"var(--warning)",fontSize:11,marginTop:2},children:["Line ",B+1,': "',ee,'" — should be absolute (start with / or a drive letter).']})}),ee.includes("..")&&U.push({key:`dots-${B}`,msg:e.jsxs("p",{style:{color:"var(--error)",fontSize:11,marginTop:2},children:["Line ",B+1,': "',ee,`" — contains '..' (server will reject this).`]})}))}),U.map(ee=>ee.msg)})()]})]})}),e.jsx("div",{"data-section":"background",style:{display:x===null||x==="background"?"block":"none"},children:e.jsxs(te,{id:"settings-background","data-section":"background",children:[e.jsxs(ie,{children:[e.jsx(Fe,{size:14})," Background Agents"]}),e.jsx(re,{children:"Tune plugin options. Changes take effect on next plugin restart."}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-maxConcurrent",children:["Max concurrent instances",e.jsx("span",{className:"meta-badge",children:"default: 8"})]}),e.jsx("input",{id:"bg-maxConcurrent",type:"number",min:1,max:32,value:u.maxConcurrentInstances??8,onChange:j=>k(U=>({...U,maxConcurrentInstances:Math.max(1,Math.min(32,parseInt(j.target.value,10)||8))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"maxConcurrentInstances"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-toolCallCap",children:["Tool-call cap",e.jsx("span",{className:"meta-badge",children:"default: 500"})]}),e.jsx("input",{id:"bg-toolCallCap",type:"number",min:1,max:5e3,value:u.backgroundToolCallCap??500,onChange:j=>k(U=>({...U,backgroundToolCallCap:Math.max(1,Math.min(5e3,parseInt(j.target.value,10)||500))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundToolCallCap"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-stallTimeout",children:["Stall timeout (ms)",e.jsx("span",{className:"meta-badge",children:"default: 180000"})]}),e.jsx("input",{id:"bg-stallTimeout",type:"number",min:1e4,max:6e5,step:1e3,value:u.backgroundStallTimeoutMs??18e4,onChange:j=>k(U=>({...U,backgroundStallTimeoutMs:Math.max(1e4,Math.min(6e5,parseInt(j.target.value,10)||18e4))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundStallTimeoutMs"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-thinkingLoopTimeout",children:["Thinking-loop timeout (ms)",e.jsx("span",{className:"meta-badge",children:"default: 300000"})]}),e.jsx("input",{id:"bg-thinkingLoopTimeout",type:"number",min:3e4,max:9e5,step:1e3,value:u.backgroundThinkingLoopTimeoutMs??3e5,onChange:j=>k(U=>({...U,backgroundThinkingLoopTimeoutMs:Math.max(3e4,Math.min(9e5,parseInt(j.target.value,10)||3e5))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundThinkingLoopTimeoutMs"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-maxInterventions",children:["Max interventions",e.jsx("span",{className:"meta-badge",children:"default: 1"})]}),e.jsx("input",{id:"bg-maxInterventions",type:"number",min:1,max:3,value:u.backgroundMaxInterventions??1,onChange:j=>k(U=>({...U,backgroundMaxInterventions:Math.max(1,Math.min(3,parseInt(j.target.value,10)||1))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundMaxInterventions"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs(C,{variant:"secondary",size:"sm",onClick:async()=>{try{await M.put("/settings/plugin-options",u),a.success("Saved — restart opencode for changes to take effect.")}catch(j){a.error(`Save failed: ${j.message}`)}},children:[e.jsx(Ze,{size:14})," Save plugin options"]}),e.jsx(C,{variant:"secondary",size:"sm",onClick:async()=>{try{const U=await(await fetch("/api/background/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({maxAgeDays:7})})).json();a.success(`Cleaned up ${U.deleted} old instances.`)}catch(j){a.error(`Cleanup failed: ${j.message}`)}},children:"Cleanup old instances (>7 days)"})]}),e.jsx("div",{className:"form-row",children:e.jsxs("small",{children:["Plugin options are read at startup. Save changes and run ",e.jsx("code",{children:"bizar update"})," to apply."]})})]})})]}),e.jsx("div",{"data-section":"system-llm",style:{display:x===null||x==="system-llm"?"block":"none"},children:e.jsxs(te,{id:"settings-system-llm","data-section":"system-llm",children:[e.jsxs(ie,{children:[e.jsx(Me,{size:14})," System LLM API"]}),e.jsx(re,{children:"Configures the LLM used for automatic title generation, prompt enhancement, summarization, and other system-level calls."}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"systemLlm.enabled",children:[e.jsx("input",{type:"checkbox",checked:!!((z=i.systemLlm)!=null&&z.enabled),onChange:j=>{const U=i.systemLlm||{enabled:!0,provider:"opencode",model:"opencode/deepseek-v4-flash-free"};b("systemLlm",{...U,enabled:j.target.checked})}}),e.jsx("span",{children:"Enable system LLM calls"})]}),e.jsxs("div",{className:"field","data-setting-id":"systemLlm.provider",style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"set-system-llm-provider",children:"Provider"}),e.jsxs("select",{id:"set-system-llm-provider",className:"select",value:((_=i.systemLlm)==null?void 0:_.provider)||"opencode",onChange:j=>{const U=i.systemLlm||{enabled:!0,provider:"opencode",model:"opencode/deepseek-v4-flash-free"};b("systemLlm",{...U,provider:j.target.value})},children:[e.jsx("option",{value:"opencode",children:"Opencode"}),e.jsx("option",{value:"openrouter",children:"OpenRouter"}),e.jsx("option",{value:"minimax",children:"MiniMax"})]})]}),e.jsxs("div",{className:"field","data-setting-id":"systemLlm.model",children:[e.jsx("label",{className:"field-label",htmlFor:"set-system-llm-model",children:"Model"}),e.jsx("input",{id:"set-system-llm-model",className:"input mono",type:"text",placeholder:"opencode/deepseek-v4-flash-free",value:((O=i.systemLlm)==null?void 0:O.model)||"opencode/deepseek-v4-flash-free",onChange:j=>{const U=i.systemLlm||{enabled:!0,provider:"opencode",model:"opencode/deepseek-v4-flash-free"};b("systemLlm",{...U,model:j.target.value})}}),e.jsxs("p",{className:"field-help",children:["The API key is read from ",e.jsx("code",{children:"auth.json"})," for the selected provider. Leave the default model for best results."]})]}),e.jsxs("div",{style:{marginTop:"var(--space-4)"},children:[e.jsx("h4",{style:{margin:"0 0 var(--space-2)"},children:"Features using this API"}),e.jsxs("ul",{className:"settings-feature-list",style:{margin:0,paddingLeft:"var(--space-4)",lineHeight:1.8},children:[e.jsx("li",{children:"Auto-title generation for new chat sessions"}),e.jsx("li",{children:"Auto-title generation for new tasks"}),e.jsx("li",{children:'"Enhance prompt" button in the task input'}),e.jsx("li",{children:'"Enhance prompt" button in the chat composer'}),e.jsx("li",{className:"muted",style:{fontSize:12},children:"Future: summarization, name generation, and more"})]})]})]})}),e.jsx(Tl,{}),e.jsx("div",{style:{display:x===null||x==="activity-log"?"block":"none"},children:e.jsx("div",{"data-section":"activity-log",style:{display:x===null||x==="activity-log"?"block":"none"},children:e.jsx("section",{id:"settings-activity-log","data-section":"activity-log",className:"settings-section-wrap",children:e.jsx(Rl,{})})})}),e.jsx("div",{style:{display:x===null||x==="about"?"block":"none"},children:e.jsx("div",{"data-section":"about",style:{display:x===null||x==="about"?"block":"none"},children:e.jsxs(te,{id:"settings-about","data-section":"about",children:[e.jsxs(ie,{children:[e.jsx(Ns,{size:14})," About"]}),e.jsx(re,{children:"Build metadata."}),e.jsxs("dl",{className:"about-table",children:[e.jsx("dt",{children:"Version"}),e.jsx("dd",{className:"mono",children:G.version}),e.jsx("dt",{children:"Homepage"}),e.jsx("dd",{children:e.jsx("a",{href:G.homepage,target:"_blank",rel:"noopener noreferrer",children:G.homepage})}),e.jsx("dt",{children:"License"}),e.jsx("dd",{children:G.license})]})]})})})]})}function Rl(){const s=oe(),[t,a]=r.useState([]),[i,n]=r.useState(new Set),[o,d]=r.useState(!0),[l,p]=r.useState(""),[h,g]=r.useState(!0),m=r.useCallback(async()=>{d(!0);try{const[S,b]=await Promise.all([M.get("/activity"),M.get("/activity/hidden")]);a(Array.isArray(S.items)?S.items:[]),n(new Set(b.hidden||[]))}catch(S){s.error(`Load failed: ${S.message}`)}finally{d(!1)}},[s]);r.useEffect(()=>{m()},[m]);const c=(S,b)=>{const v=`${S.kind||""}|${S.ts||""}|${S.slug||""}|${b}`;let y=0;for(let T=0;T<v.length;T++)y=(y<<5)-y+v.charCodeAt(T)|0;return Math.abs(y).toString(16).padStart(8,"0").slice(0,16)},u=async()=>{try{await M.del("/activity/hide"),n(new Set),s.success("All hidden activity restored.")}catch(S){s.error(`Restore failed: ${S.message}`)}},k=async S=>{try{await M.del(`/activity/hide/${encodeURIComponent(S)}`);const b=new Set(i);b.delete(S),n(b)}catch(b){s.error(`Restore failed: ${b.message}`)}},f=t.filter((S,b)=>{const v=c(S,b);if(!h&&i.has(v))return!1;if(!l)return!0;const y=l.toLowerCase();return[S.kind,S.slug,S.message].some(T=>typeof T=="string"&&T.toLowerCase().includes(y))});return e.jsxs(te,{id:"settings-diagnostics","data-section":"diagnostics",children:[e.jsxs(ie,{children:[e.jsx(ze,{size:14})," Activity log",e.jsxs("span",{className:"muted",style:{fontWeight:400,marginLeft:8,fontSize:12},children:[t.length," total · ",i.size," hidden"]}),e.jsx(C,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:m,title:"Reload",children:e.jsx(de,{size:12})})]}),e.jsxs(re,{children:["Full history from ",e.jsx("code",{children:"~/.bizar/activity.log"}),". Hiding an item in the Overview only hides it there — the entry stays here."]}),e.jsxs("div",{className:"activity-log-toolbar",children:[e.jsxs("div",{className:"activity-log-search",children:[e.jsx(Be,{size:12}),e.jsx("input",{type:"text",className:"input",placeholder:"Filter by kind, slug, or message…",value:l,onChange:S=>p(S.target.value)})]}),e.jsxs("label",{className:"activity-log-toggle",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:S=>g(S.target.checked)}),"Show hidden"]}),e.jsxs(C,{variant:"ghost",size:"sm",disabled:i.size===0,onClick:u,title:"Restore all hidden items to the Overview",children:[e.jsx(ls,{size:12})," Restore all"]})]}),o?e.jsx("div",{className:"muted",style:{padding:"12px 0",fontSize:12},children:"Loading…"}):f.length===0?e.jsx("div",{className:"muted",style:{padding:"12px 0",fontSize:12},children:t.length===0?"No activity yet.":"No items match the current filter."}):e.jsxs("div",{className:"activity-log-table-wrap",children:[e.jsxs("table",{className:"activity-log-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Kind"}),e.jsx("th",{children:"Detail"}),e.jsx("th",{children:"Time"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:f.slice(0,200).map((S,b)=>{const v=c(S,b),y=i.has(v);return e.jsxs("tr",{className:ne(y&&"activity-log-row-hidden"),children:[e.jsx("td",{className:"activity-log-kind",children:S.kind||"activity"}),e.jsx("td",{className:"activity-log-detail",children:S.message||S.slug||"—"}),e.jsx("td",{className:"activity-log-time mono",children:S.ts?new Date(S.ts).toLocaleString():"—"}),e.jsx("td",{children:y?e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>k(v),title:"Restore to Overview",children:e.jsx(ls,{size:12})}):e.jsx("span",{className:"activity-log-state-tag",children:"shown"})})]},`${S.ts}-${b}`)})})]}),f.length>200&&e.jsxs("div",{className:"muted",style:{fontSize:11,padding:"8px 0"},children:["Showing first 200 of ",f.length,"."]})]})]})}function Dl({snapshot:s,refreshSnapshot:t}){const a=oe(),i=ke(),[n,o]=r.useState(Array.isArray(s.mods)?s.mods:[]),[d,l]=r.useState(!0),[p,h]=r.useState(null),[g,m]=r.useState([]),[c,u]=r.useState(null),[k,f]=r.useState(!1),[S,b]=r.useState(null),[v,y]=r.useState(!1),[T,x]=r.useState({}),E=async()=>{var w,$,V;y(!0);try{const K=await M.get("/mods/registry");b({source:((w=K.registry)==null?void 0:w.source)||"",version:($=K.registry)==null?void 0:$.version,updatedAt:(V=K.registry)==null?void 0:V.updatedAt,mods:K.mods||[]})}catch(K){b({source:"",mods:[],error:K.message})}finally{y(!1)}},q=async w=>{x($=>({...$,[w]:!0}));try{const $=await M.post("/mods",{id:w});o(V=>[...V.filter(K=>K.id!==$.id),$]),a.success(`Mod "${$.id}" installed from registry.`),await t()}catch($){a.error(`Install failed: ${$.message}`)}finally{x($=>({...$,[w]:!1}))}},I=async(w,$=!1)=>{x(V=>({...V,[w]:!0}));try{const V=await M.post(`/mods/${encodeURIComponent(w)}/upgrade`,{backup:$});o(X=>[...X.filter(ae=>ae.id!==V.mod.id),V.mod]);const K=V.backupPath?` (backup at ${V.backupPath})`:"";a.success(`Mod "${w}" upgraded v${V.from} → v${V.to}${K}.`),await t()}catch(V){a.error(`Upgrade failed: ${V.message}`)}finally{x(V=>({...V,[w]:!1}))}},J=async()=>{try{const w=await M.get("/mods");o(w.mods||[]);try{const $=await M.get("/mods/views");m($.views||[])}catch{m([])}}catch(w){a.error(`Mods load failed: ${w.message}`)}finally{l(!1)}};r.useEffect(()=>{J()},[]),r.useEffect(()=>{Array.isArray(s.mods)&&s.mods!==n&&o(s.mods)},[s.mods]);const R=()=>{let w=null;i.open({title:"Install mod",children:e.jsxs("div",{children:[e.jsxs("p",{className:"muted",children:["Provide the absolute path to a mod folder (one that contains a ",e.jsx("code",{children:"mod.json"}),"). The folder will be copied to"," ",e.jsx("code",{children:"~/.config/bizar/mods/<id>/"}),"."]}),e.jsx("label",{className:"field-label",children:"Path"}),e.jsx("input",{ref:$=>w=$,className:"input",type:"text",placeholder:"/path/to/my-mod",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsx(C,{variant:"primary",onClick:async()=>{const $=((w==null?void 0:w.value)||"").trim();if(!$){a.warning("Path is required.");return}try{const V=await M.post("/mods",{path:$});o(K=>[...K,V]),a.success(`Mod "${V.id}" installed.`),i.close(),await t()}catch(V){a.error(`Install failed: ${V.message}`)}},children:"Install"})]})})},L=async w=>{if(confirm(`Uninstall mod "${w}"? This removes the folder from ~/.config/bizar/mods/.`))try{await M.del(`/mods/${encodeURIComponent(w)}`),o($=>$.filter(V=>V.id!==w)),p===w&&h(null),a.success("Mod uninstalled.")}catch($){a.error(`Uninstall failed: ${$.message}`)}},W=async w=>{try{const $=await M.put(`/mods/${encodeURIComponent(w.id)}`,{enabled:!w.enabled});o(V=>V.map(K=>K.id===w.id?$:K)),a.success(`Mod ${$.enabled?"enabled":"disabled"}.`)}catch($){a.error(`Toggle failed: ${$.message}`)}},G=n.find(w=>w.id===p)||null;return d?e.jsx("div",{className:"view-loading",children:e.jsx(ge,{size:"lg"})}):e.jsxs("div",{className:"view view-mods",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(ys,{size:18})," Mods (",n.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["Extensions installed in ",e.jsx("code",{children:"~/.config/bizar/mods/"}),". Mods can add agents, commands, routes, and views."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(C,{variant:"secondary",size:"sm",onClick:J,children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(C,{variant:"primary",size:"sm",onClick:R,children:[e.jsx(pe,{size:14})," Install mod"]})]})]}),n.length===0?e.jsx(Ie,{icon:e.jsx(ys,{size:32}),title:"No mods installed",message:"Mods are folders with a mod.json. Install one to extend Bizar with custom agents, commands, and views."}):e.jsxs("div",{className:"mods-layout",children:[e.jsx("div",{className:"mods-list",children:n.map(w=>e.jsxs("div",{className:ne("mod-list-item",p===w.id&&"mod-list-item-active"),onClick:()=>h(w.id),children:[e.jsxs("div",{className:"mod-list-item-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mod-list-item-name",children:w.name}),e.jsxs("div",{className:"mod-list-item-meta",children:["v",w.version," · ",w.type," · ",w.author]})]}),e.jsxs("div",{className:"mod-list-item-actions",onClick:$=>$.stopPropagation(),children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Toggle enabled",title:w.enabled?"Disable":"Enable",onClick:()=>W(w),children:e.jsx(Vs,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Uninstall",title:"Uninstall",onClick:()=>L(w.id),children:e.jsx(ye,{size:12})})]})]}),e.jsx("div",{className:"mod-list-item-desc ellipsis-2",title:w.description,children:w.description}),e.jsx("div",{className:"mod-list-item-status",children:e.jsx("span",{className:`mod-mini-pill ${w.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:w.enabled?"enabled":"disabled"})})]},w.id))}),G&&e.jsx(Ll,{mod:G})]}),e.jsxs(te,{className:"mods-registry-card",children:[e.jsxs("div",{className:"mods-registry-head",onClick:()=>{!S&&!v&&E(),f(w=>!w)},children:[e.jsx(rs,{size:14}),e.jsx("span",{className:"mods-registry-title",children:"Mod registry"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:S!=null&&S.mods?`${S.mods.length} available`:"click to browse"}),e.jsx("span",{className:"mods-registry-spacer"}),k?e.jsx(Ae,{size:14}):e.jsx(He,{size:14})]}),k&&e.jsx("div",{className:"mods-registry-body",children:v?e.jsx("div",{className:"muted",style:{padding:12,fontSize:12},children:"Loading registry…"}):S!=null&&S.error?e.jsxs("div",{className:"mods-registry-error",children:[e.jsx(es,{size:12})," Could not load registry: ",S.error]}):!S||S.mods.length===0?e.jsx("div",{className:"muted",style:{padding:12,fontSize:12},children:"No mods listed in the registry yet."}):e.jsxs(e.Fragment,{children:[S.source&&e.jsxs("div",{className:"muted",style:{fontSize:11,marginBottom:8},children:["Source: ",e.jsx("code",{children:S.source})]}),e.jsx("div",{className:"mods-registry-grid",children:S.mods.map(w=>{const $=n.some(K=>K.id===w.id),V=!!T[w.id];return e.jsxs("div",{className:"mod-registry-card",children:[e.jsxs("div",{className:"mod-registry-card-head",children:[e.jsx("div",{className:"mod-registry-card-name",children:w.name}),w.latest&&e.jsxs("span",{className:ne("mod-registry-version",w.upgradeAvailable&&"mod-registry-version-upgrade"),children:["v",w.latest,w.upgradeAvailable?" ↑":""]})]}),w.description&&e.jsx("div",{className:"mod-registry-card-desc",children:w.description}),e.jsxs("div",{className:"mod-registry-card-meta",children:[w.author&&e.jsxs("span",{className:"muted",children:["by ",w.author]}),w.homepage&&e.jsx("a",{href:w.homepage,target:"_blank",rel:"noopener noreferrer",className:"mod-registry-link",children:"homepage"})]}),(w.permissions||[]).length>0&&e.jsxs("div",{className:"mod-registry-perms",children:[e.jsx(es,{size:10}),(w.permissions||[]).slice(0,4).map(K=>e.jsx("span",{className:"mod-registry-perm",children:K},K)),(w.permissions||[]).length>4&&e.jsxs("span",{className:"mod-registry-perm-more",children:["+",w.permissions.length-4]})]}),e.jsxs("div",{className:"mod-registry-card-actions",children:[!$&&e.jsx(C,{variant:"primary",size:"sm",disabled:V,onClick:()=>q(w.id),title:"Install from registry",children:V?e.jsx(ge,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{size:12})," Install"]})}),$&&w.upgradeAvailable&&e.jsx(C,{variant:"primary",size:"sm",disabled:V,onClick:()=>I(w.id),title:`Upgrade from v${w.installedVersion||"?"} to v${w.upgradeAvailable}`,children:V?e.jsx(ge,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{size:12})," Upgrade to v",w.upgradeAvailable]})}),$&&!w.upgradeAvailable&&e.jsxs(C,{variant:"ghost",size:"sm",disabled:!0,title:`Installed v${w.installedVersion||"?"}`,children:["Installed v",w.installedVersion||"?"]})]})]},w.id)})})]})})]}),g.length>0&&e.jsxs(te,{className:"mod-views-hint",children:[e.jsxs(ie,{children:[e.jsx(rs,{size:14})," Mod views"]}),e.jsxs(re,{children:[g.length," mod-supplied view",g.length===1?"":"s"," are now available in the sidebar navigation. Look for the ",e.jsx("strong",{children:"Mods"})," section at the bottom of the sidebar."]})]}),c&&e.jsxs("div",{className:"mod-iframe-panel",children:[e.jsxs("div",{className:"mod-iframe-header",children:[e.jsxs("span",{children:["Mod view — ",e.jsx("a",{href:c,target:"_blank",rel:"noreferrer",children:c})]}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close iframe",onClick:()=>u(null),children:e.jsx($e,{size:14})})]}),e.jsx("iframe",{src:c,className:"mod-iframe",title:"Mod view",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"})]})]})}function Ll({mod:s}){const t=oe(),[a,i]=r.useState(null),[n,o]=r.useState(!1),[d,l]=r.useState(!1),[p,h]=r.useState(null),g=async()=>{o(!0);try{const c=await M.get(`/mods/${s.id}/instructions`);i(c),l(!0)}catch(c){t.error(`Failed to load instructions: ${c.message}`)}finally{o(!1)}},m=async()=>{try{const c=await M.post(`/mods/${s.id}/instructions/reinstall`,{});t.success(`Reinstalled: ${c.counts.agents} agents, ${c.counts.commands} commands, ${c.counts.skills} skills, ${c.counts.instructions} instructions.`),await g()}catch(c){t.error(`Reinstall failed: ${c.message}`)}};return e.jsxs(te,{className:"mod-details",children:[e.jsxs(ie,{children:[e.jsx(ws,{size:14})," Mod details — ",s.name]}),e.jsx(re,{children:e.jsx("code",{children:s.path})}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"ID"}),e.jsx("dd",{className:"mono",children:s.id}),e.jsx("dt",{children:"Version"}),e.jsx("dd",{className:"mono",children:s.version}),e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"mono",children:s.type}),e.jsx("dt",{children:"Author"}),e.jsx("dd",{className:"mono",children:s.author||"—"}),e.jsx("dt",{children:"Bizar"}),e.jsx("dd",{className:"mono",children:s.bizar||"*"}),e.jsx("dt",{children:"Enabled"}),e.jsx("dd",{children:s.enabled?"yes":"no"}),e.jsx("dt",{children:"Permissions"}),e.jsxs("dd",{children:[(s.permissions||[]).map(c=>e.jsx("span",{className:"tag",children:c},c)),(s.permissions||[]).length===0&&e.jsx("span",{className:"muted",children:"(none)"})]})]}),e.jsxs("div",{className:"mod-files",children:[e.jsx("div",{className:"muted",children:"Files"}),e.jsx("ul",{children:(s.files||[]).map(c=>e.jsxs("li",{children:[e.jsx("span",{className:"mod-file-cat",children:c.category}),e.jsx("span",{className:"mono",children:c.path})]},c.path))})]}),e.jsxs("div",{className:"mod-instructions",children:[e.jsxs("div",{className:"mod-instructions-head",onClick:()=>{!a&&!n&&g(),l(c=>!c)},children:[e.jsx(Pa,{size:14}),e.jsx("span",{children:"Installed instructions"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:a?`${a.total} files`:"click to view"}),e.jsx("span",{className:"mod-instructions-spacer"}),d?e.jsx(Ae,{size:14}):e.jsx(He,{size:14})]}),d&&a&&e.jsxs("div",{className:"mod-instructions-body",children:[a.agents.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(on,{size:11})," Agents (",a.agents.length,")"]}),a.agents.map(c=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(u=>u===c.filename?null:c.filename),children:[e.jsx("span",{className:"mono",children:c.filename}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",c.fullPath]})]}),p===c.filename&&e.jsx("pre",{className:"mod-instructions-content",children:c.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},c.filename))]}),a.commands.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(is,{size:11})," Commands (",a.commands.length,")"]}),a.commands.map(c=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(u=>u===c.filename?null:c.filename),children:[e.jsx("span",{className:"mono",children:c.filename}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",c.fullPath]})]}),p===c.filename&&e.jsx("pre",{className:"mod-instructions-content",children:c.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},c.filename))]}),a.skills.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(ba,{size:11})," Skills (",a.skills.length,")"]}),a.skills.map(c=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(u=>u===c.name?null:c.name),children:[e.jsx("span",{className:"mono",children:c.name}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",c.fullPath]})]}),p===c.name&&e.jsx("pre",{className:"mod-instructions-content",children:c.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},c.name))]}),a.total===0&&e.jsxs("div",{className:"muted",style:{padding:8,fontSize:12},children:["This mod did not install any instruction files. Mods install instructions by shipping a top-level ",e.jsx("code",{children:"INSTRUCTIONS.md"}),", an ",e.jsx("code",{children:"agents/"})," directory, a ",e.jsx("code",{children:"commands/"})," directory, or a ",e.jsx("code",{children:"skills/"})," directory."]}),e.jsx("div",{className:"mod-instructions-actions",children:e.jsxs(C,{variant:"ghost",size:"sm",onClick:m,children:[e.jsx(de,{size:11})," Reinstall from mod folder"]})})]})]})]})}function Pl({viewId:s,reloadKey:t,setActiveTab:a}){const i=oe(),[n,o]=r.useState(null),[d,l]=r.useState(!0),[p,h]=r.useState(0);if(r.useEffect(()=>{let g=!1;return(async()=>{try{const m=await M.get("/mods/views");if(g)return;const c=(m.views||[]).find(u=>u.id===s);o(c||null)}catch(m){i.error(`Failed to load mod view: ${m.message}`)}finally{g||l(!1)}})(),()=>{g=!0}},[s,i]),d)return e.jsx(Ie,{title:"Loading mod view…"});if(!n)return e.jsx(Ie,{title:"Mod view not found",message:`No view with id "${s}" is currently installed.`,action:e.jsx(C,{onClick:()=>a("mods"),variant:"primary",size:"sm",children:"Open Mods"})});if(n.kind==="iframe"){const g=`/api/mods/${n.modId}/web/index.html?t=${p+(t||0)}`;return e.jsxs("div",{className:"mod-view-iframe-pane",children:[e.jsxs("div",{className:"mod-view-iframe-header",children:[e.jsxs("span",{className:"mod-view-iframe-label",children:[e.jsx(rs,{size:14}),n.label,e.jsxs("span",{className:"muted",style:{fontSize:11,fontWeight:400},children:["by ",n.modId]})]}),e.jsxs("div",{className:"mod-view-iframe-actions",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>h(m=>m+1),title:"Reload this view",children:[e.jsx(de,{size:11})," Reload"]}),e.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"icon-btn",title:"Open in new tab",children:e.jsx(Ws,{size:12})})]})]}),e.jsx("iframe",{src:g,className:"mod-view-iframe",title:n.label},p+(t||0))]})}if(n.component){const g=n.component,m=n.modId,c=r.lazy(()=>ka(()=>import(`/api/mods/${encodeURIComponent(m)}/views/${encodeURIComponent(g)}`),[]).then(u=>({default:u.default??(()=>null)})));return e.jsxs("div",{className:"mod-view-tab-pane",children:[e.jsx("div",{className:"mod-view-iframe-header",children:e.jsxs("span",{className:"mod-view-iframe-label",children:[e.jsx(Es,{size:14}),n.label,e.jsxs("span",{className:"muted",style:{fontSize:11,fontWeight:400},children:["by ",n.modId]})]})}),e.jsx("div",{className:"mod-view-tab-body",children:e.jsx(El,{modId:n.modId,component:n.component,children:e.jsx(r.Suspense,{fallback:e.jsxs("div",{style:{padding:24},children:[e.jsx(ge,{size:"md"})," ",e.jsx("span",{className:"muted",children:"Loading mod view…"})]}),children:e.jsx(c,{})})})})]})}return e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Es,{size:14})," ",n.label]}),e.jsxs(re,{children:["by ",n.modId]}),n.description&&e.jsx("p",{className:"muted",style:{marginTop:8},children:n.description}),e.jsxs("p",{className:"muted",style:{fontSize:12,marginTop:12},children:["This mod declared a tab view but did not provide a component path in views/registry.json. Add a ",e.jsx("code",{children:"component"})," field (e.g. ",e.jsx("code",{children:'"MyView.js"'}),") and ship the file under ",e.jsx("code",{children:"views/"}),"."]}),e.jsx("div",{style:{marginTop:12},children:e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>a("mods"),children:"Open Mods page"})})]})}class El extends r.Component{constructor(){super(...arguments);tt(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(){}render(){return this.state.error?e.jsxs("div",{className:"mod-view-error",children:[e.jsx(De,{size:16}),e.jsx("strong",{children:"Failed to render mod view"}),e.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:6},children:[this.props.modId," → ",this.props.component,": ",this.state.error.message]})]}):this.props.children}}const Ol=["interval","cron","once"],Bl=["command","agent","webhook"],_s=[{value:"UTC",label:"UTC"},{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"Europe/London",label:"Europe/London (UK)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}],Fl=Array.from({length:12},(s,t)=>t*5),Qs=Array.from({length:24},(s,t)=>({value:t,label:t===0?"12 AM":t<12?`${t} AM`:t===12?"12 PM":`${t-12} PM`})),Zs=[{value:"*",label:"Every day"},{value:"0",label:"Sunday"},{value:"1",label:"Monday"},{value:"2",label:"Tuesday"},{value:"3",label:"Wednesday"},{value:"4",label:"Thursday"},{value:"5",label:"Friday"},{value:"6",label:"Saturday"}],Ft=[{value:"s",label:"seconds"},{value:"m",label:"minutes"},{value:"h",label:"hours"},{value:"d",label:"days"}];function Ut(s){if(typeof s!="string")return null;const t=s.trim().split(/\s+/);if(t.length!==5)return null;const[a,i,,,n]=t,o=parseInt(a,10),d=parseInt(i,10);if(!Number.isFinite(o)||!Number.isFinite(d)||a!==String(o)||i!==String(d))return null;const l=n==="*"?"*":parseInt(n,10);return l===null||n!=="*"&&!Number.isFinite(l)?null:{minute:o,hour:d,dow:n==="*"?"*":String(l)}}function Ul(s){if(typeof s!="string")return null;const t=/^(\d+)\s*([smhd])$/i.exec(s.trim());return t?{n:parseInt(t[1],10),unit:t[2].toLowerCase()}:null}function Hl(s){var o,d;if(!s)return{name:"",type:"cron",cronMinute:0,cronHour:13,cronDow:"0",showAdvanced:!1,rawCron:"0 13 * * 0",intervalN:30,intervalUnit:"m",onceAt:"",timezone:"UTC",customTimezone:"",actionType:"agent",actionTarget:"",actionPrompt:"",skipIfBudgetLow:!1,maxConcurrent:6,enabled:!0,humanLabel:""};const t=s.type==="cron"?Ut(s.schedule):null,a=s.type==="interval"?Ul(s.schedule):null,i=s.timezone||"UTC",n=_s.some(l=>l.value===i);return{name:s.name||"",type:s.type,cronMinute:(t==null?void 0:t.minute)??0,cronHour:(t==null?void 0:t.hour)??9,cronDow:(t==null?void 0:t.dow)??"*",showAdvanced:!t,rawCron:s.schedule,intervalN:(a==null?void 0:a.n)??30,intervalUnit:(a==null?void 0:a.unit)??"m",onceAt:s.type==="once"?_l(s.schedule):"",timezone:n?i:"Other…",customTimezone:n?"":i,actionType:s.action.type,actionTarget:s.action.target||"",actionPrompt:s.action.prompt||"",skipIfBudgetLow:!!((o=s.budgetCheck)!=null&&o.skipIfBudgetLow),maxConcurrent:Number.isFinite((d=s.budgetCheck)==null?void 0:d.maxConcurrent)?s.budgetCheck.maxConcurrent:6,enabled:s.enabled!==!1,humanLabel:""}}function _l(s){if(!s)return"";try{const t=new Date(s);if(Number.isNaN(t.getTime()))return"";const a=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${a(t.getMonth()+1)}-${a(t.getDate())}T${a(t.getHours())}:${a(t.getMinutes())}`}catch{return""}}function ql(s){var a,i,n;if(s.type==="cron"){if(s.showAdvanced)return{schedule:s.rawCron.trim(),humanLabel:s.humanLabel||s.rawCron.trim()};const o=`${s.cronMinute} ${s.cronHour} * * ${s.cronDow}`,d=((a=Zs.find(g=>g.value===s.cronDow))==null?void 0:a.label)||"",l=((i=Qs.find(g=>g.value===s.cronHour))==null?void 0:i.label)||`${s.cronHour}`,p=String(s.cronMinute).padStart(2,"0"),h=d==="Every day"?`Every day at ${l.replace(" ","")} (min ${p})`:`Every ${d} at ${l.replace(" ","")} (min ${p})`;return{schedule:o,humanLabel:s.humanLabel||h}}if(s.type==="interval"){const o=((n=Ft.find(l=>l.value===s.intervalUnit))==null?void 0:n.label)||s.intervalUnit;return{schedule:`${s.intervalN}${s.intervalUnit}`,humanLabel:s.humanLabel||`Every ${s.intervalN} ${o}`}}return s.onceAt?{schedule:new Date(s.onceAt).toISOString(),humanLabel:s.humanLabel||new Date(s.onceAt).toLocaleString()}:{schedule:"",humanLabel:s.humanLabel||""}}function Vl({snapshot:s,refreshSnapshot:t}){var c;const a=oe(),i=ke(),[n,o]=r.useState(s.schedules||[]),[d,l]=r.useState(!s.schedules),p=async()=>{try{const u=await M.get("/projects/active/schedules");o(u.schedules||[])}catch(u){a.error(`Schedules load failed: ${u.message}`)}finally{l(!1)}};r.useEffect(()=>{var u;if((u=s.schedules)!=null&&u.length||s.schedules){o(s.schedules||[]),l(!1);return}p()},[s.schedules]);const h=u=>{i.open({title:u?`Edit schedule: ${u.name}`:"New schedule",width:640,children:e.jsx(Wl,{initial:u,onClose:i.close,onSubmitted:async k=>{o(f=>{const S=f.findIndex(v=>v.id===k.id);if(S===-1)return[...f,k];const b=f.slice();return b[S]=k,b}),a.success(u?"Schedule updated.":"Schedule created."),i.close(),await t()},onError:k=>a.error(k)})})},g=async u=>{var k;try{const f=await M.post(`/schedules/${encodeURIComponent(u.id)}/run`);a.success(f.ok?"Schedule ran.":`Run failed: ${((k=f.runResult)==null?void 0:k.error)||"unknown"}`),await p()}catch(f){a.error(`Run failed: ${f.message}`)}},m=async u=>{if(confirm(`Delete schedule "${u.name}"?`))try{await M.del(`/schedules/${encodeURIComponent(u.id)}`),o(k=>k.filter(f=>f.id!==u.id)),a.success("Schedule deleted.")}catch(k){a.error(`Delete failed: ${k.message}`)}};return d?e.jsx("div",{className:"view-loading",children:e.jsx(ge,{size:"lg"})}):e.jsxs("div",{className:"view view-schedules",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Xe,{size:18})," Schedules (",n.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["Recurring tasks for the active project: ",e.jsx("strong",{children:((c=s.activeProject)==null?void 0:c.name)||"(none)"}),". Service daemon runs them at the right time."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(C,{variant:"secondary",size:"sm",onClick:p,children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(C,{variant:"primary",size:"sm",onClick:()=>h(),children:[e.jsx(pe,{size:14})," New schedule"]})]})]}),n.length===0?e.jsx(Ie,{icon:e.jsx(Xe,{size:32}),title:"No schedules",message:s.activeProject?"Add a schedule to run commands, webhooks, or agent tasks on a cron / interval / one-shot basis.":"Activate a project first to scope schedules."}):e.jsx("div",{className:"schedule-grid",children:n.map(u=>{var k;return e.jsxs(te,{className:"schedule-card",children:[e.jsxs("div",{className:"schedule-card-head",children:[e.jsxs("div",{children:[e.jsx(ie,{children:u.name}),e.jsxs(re,{children:[e.jsx("code",{children:u.type})," ·"," ",e.jsx("span",{title:u.schedule,children:Kl(u)||u.schedule}),u.timezone&&u.timezone!=="UTC"?e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{children:u.timezone})]}):null," · ",e.jsx("span",{className:u.enabled?"status-on":"status-neutral",children:u.enabled?"enabled":"disabled"})]})]}),e.jsxs("div",{className:"schedule-card-actions",children:[e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>h(u),children:[e.jsx(ds,{size:12})," Edit"]}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>g(u),children:[e.jsx(Ps,{size:12})," Run now"]}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Delete",title:"Delete",onClick:()=>m(u),children:e.jsx(ye,{size:12})})]})]}),e.jsxs("div",{className:"schedule-card-action",children:[e.jsx("span",{className:"muted",children:"action:"})," ",e.jsxs("code",{children:[u.action.type," ",u.action.target]}),u.action.type==="agent"&&u.action.prompt&&e.jsxs("div",{className:"schedule-card-prompt",children:[e.jsx("span",{className:"muted",children:"prompt:"})," ",u.action.prompt]})]}),((k=u.budgetCheck)==null?void 0:k.skipIfBudgetLow)&&e.jsxs("div",{className:"schedule-card-budget",children:[e.jsx("span",{className:"muted",children:"budget gate:"})," ","skip if concurrent ≥ ",u.budgetCheck.maxConcurrent??6]}),e.jsxs("div",{className:"schedule-card-times",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"last"})," ",u.lastRun?ve(u.lastRun):"—",u.lastResult&&e.jsx("span",{className:`tag ${xt(u.lastResult)}`,children:u.lastResult}),u.lastError&&e.jsxs("span",{className:"muted schedule-card-error",title:u.lastError,children:[" ","— ",jt(u.lastError,80)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"next"})," ",u.nextRun?e.jsx("span",{title:new Date(u.nextRun).toISOString(),children:Gl(u.nextRun,u.timezone)}):"—",u.nextRun&&e.jsxs("span",{className:"muted",children:[" · ",ve(u.nextRun)]})]})]}),u.history&&u.history.length>0&&e.jsxs("details",{className:"schedule-card-history",children:[e.jsxs("summary",{children:[e.jsx(ns,{size:12})," ",u.history.length," run",u.history.length===1?"":"s"]}),e.jsx("ul",{children:u.history.slice(-10).reverse().map((f,S)=>e.jsxs("li",{children:[e.jsx("span",{className:"tabular-nums muted",children:ve(f.ts)})," ",e.jsx("span",{className:`tag ${xt(f.result)}`,children:f.result}),f.error&&e.jsxs("span",{className:"muted",children:[" — ",jt(f.error,80)]})]},S))})]})]},u.id)})})]})}function Wl({initial:s,onClose:t,onSubmitted:a,onError:i}){const[n,o]=r.useState(()=>Hl(s)),[d,l]=r.useState(!1),p=r.useMemo(()=>_s.some(m=>m.value===n.timezone)?n.timezone:"Other…",[n.timezone]),h=(m,c)=>{o(u=>({...u,[m]:c}))},g=async m=>{m.preventDefault();const c=n.name.trim();if(!c){i("Name is required.");return}const u=ql(n);if(!u.schedule){i("Schedule value is required.");return}if(!n.actionTarget.trim()){i("Action target is required.");return}const k=n.timezone==="Other…"?n.customTimezone.trim():n.timezone,f={type:n.actionType,target:n.actionTarget.trim()};n.actionType==="agent"&&n.actionPrompt.trim()&&(f.prompt=n.actionPrompt.trim());const S={name:c,type:n.type,schedule:u.schedule,timezone:k||"UTC",action:f,budgetCheck:{maxConcurrent:n.maxConcurrent,skipIfBudgetLow:n.skipIfBudgetLow},enabled:n.enabled};l(!0);try{const b=s?await M.put(`/schedules/${encodeURIComponent(s.id)}`,S):await M.post("/schedules",S);await a(b)}catch(b){i(`${s?"Update":"Create"} failed: ${b.message}`)}finally{l(!1)}};return e.jsxs("form",{className:"schedule-form",onSubmit:g,children:[e.jsx("label",{className:"field-label",children:"Name"}),e.jsx("input",{className:"input",type:"text",placeholder:"Weekly code review",value:n.name,onChange:m=>h("name",m.target.value),autoFocus:!0}),e.jsx("div",{className:"task-form-row",children:e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Type"}),e.jsx("select",{className:"select",value:n.type,onChange:m=>h("type",m.target.value),children:Ol.map(m=>e.jsx("option",{value:m,children:m},m))})]})}),n.type==="cron"&&e.jsxs("div",{className:"schedule-cron-group",children:[!n.showAdvanced&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Day of week"}),e.jsx("select",{className:"select",value:n.cronDow,onChange:m=>h("cronDow",m.target.value),children:Zs.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Hour"}),e.jsx("select",{className:"select",value:String(n.cronHour),onChange:m=>h("cronHour",parseInt(m.target.value,10)),children:Qs.map(m=>e.jsx("option",{value:String(m.value),children:m.label},m.value))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Minute"}),e.jsx("select",{className:"select",value:String(n.cronMinute),onChange:m=>h("cronMinute",parseInt(m.target.value,10)),children:Fl.map(m=>e.jsx("option",{value:String(m),children:String(m).padStart(2,"0")},m))})]})]})}),n.showAdvanced&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Cron expression"}),e.jsx("input",{className:"input",type:"text",value:n.rawCron,onChange:m=>h("rawCron",m.target.value),placeholder:"0 13 * * 0"})]}),e.jsxs("button",{type:"button",className:"link-btn",onClick:()=>h("showAdvanced",!n.showAdvanced),children:[e.jsx(Ae,{size:12,style:{transform:n.showAdvanced?"rotate(180deg)":"none",transition:"transform 0.15s"}}),n.showAdvanced?"Hide advanced":"Advanced (raw cron)"]})]}),n.type==="interval"&&e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Every"}),e.jsx("input",{className:"input",type:"number",min:1,value:n.intervalN,onChange:m=>h("intervalN",parseInt(m.target.value,10)||1)})]}),e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Unit"}),e.jsx("select",{className:"select",value:n.intervalUnit,onChange:m=>h("intervalUnit",m.target.value),children:Ft.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))})]})]}),n.type==="once"&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Run at"}),e.jsx("input",{className:"input",type:"datetime-local",value:n.onceAt,onChange:m=>h("onceAt",m.target.value)})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Timezone"}),e.jsxs("select",{className:"select",value:p,onChange:m=>h("timezone",m.target.value),children:[_s.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value)),e.jsx("option",{value:"Other…",children:"Other…"})]})]}),n.timezone==="Other…"&&e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"IANA name"}),e.jsx("input",{className:"input",type:"text",placeholder:"Europe/Paris",value:n.customTimezone,onChange:m=>h("customTimezone",m.target.value)})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Action"}),e.jsx("select",{className:"select",value:n.actionType,onChange:m=>h("actionType",m.target.value),children:Bl.map(m=>e.jsx("option",{value:m,children:m},m))})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",children:"Target"}),e.jsx("input",{className:"input",type:"text",placeholder:n.actionType==="webhook"?"https://...":n.actionType==="agent"?"agent name or task ref":"echo hi",value:n.actionTarget,onChange:m=>h("actionTarget",m.target.value)})]})]}),n.actionType==="agent"&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Prompt (what to send the agent)"}),e.jsx("textarea",{className:"input",rows:3,placeholder:"Review open PRs for stale code review comments and nudge reviewers.",value:n.actionPrompt,onChange:m=>h("actionPrompt",m.target.value)})]}),e.jsxs("fieldset",{className:"schedule-budget-card",children:[e.jsx("legend",{children:"Budget pre-flight"}),e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",checked:n.skipIfBudgetLow,onChange:m=>h("skipIfBudgetLow",m.target.checked)}),e.jsx("span",{children:"Skip this run when too many background tasks are already running."})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Max concurrent bg tasks"}),e.jsx("input",{className:"input",type:"number",min:1,max:64,value:n.maxConcurrent,onChange:m=>h("maxConcurrent",parseInt(m.target.value,10)||6),disabled:!n.skipIfBudgetLow})]})]}),e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",checked:n.enabled,onChange:m=>h("enabled",m.target.checked)}),e.jsx("span",{children:"Enabled"})]}),e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",type:"button",onClick:t,disabled:d,children:"Cancel"}),e.jsx(C,{variant:"primary",type:"submit",disabled:d,children:s?"Save":"Create"})]})]})}function Kl(s){var o,d;if(s.type!=="cron")return s.schedule;const t=Ut(s.schedule);if(!t)return s.schedule;const a=((o=Zs.find(l=>l.value===t.dow))==null?void 0:o.label)||"",i=((d=Qs.find(l=>l.value===t.hour))==null?void 0:d.label)||`${t.hour}`,n=String(t.minute).padStart(2,"0");return a==="Every day"?`Every day at ${i} :${n}`:`Every ${a} at ${i} :${n}`}function Gl(s,t){try{return new Date(s).toLocaleString(void 0,{timeZone:t||void 0,weekday:"long",hour:"numeric",minute:"2-digit",month:"short",day:"numeric"})}catch{return new Date(s).toLocaleString()}}function xt(s){return s==="success"?"tag-success":s==="skipped"?"tag-warning":"tag-error"}function jt(s,t){return s.length<=t?s:s.slice(0,t-1)+"…"}const js={all:Me,languages:Na,frameworks:Mt,tools:dn,testing:Ba,design:At,reasoning:Aa,planning:cs,gitops:_a,docs:Ta};function Yl({snapshot:s,refreshSnapshot:t}){const a=oe(),i=ke(),[n,o]=r.useState([]),[d,l]=r.useState([]),[p,h]=r.useState(!0),[g,m]=r.useState("all"),[c,u]=r.useState(""),[k,f]=r.useState(null),[S,b]=r.useState(!1),[v,y]=r.useState(null),[T,x]=r.useState(new Set(["all","languages","frameworks"])),E=async()=>{h(!0);try{const L=await M.get("/skills");o(L.skills||[]),l(L.categories||[])}catch(L){a.error(`Skills load failed: ${L.message}`)}finally{h(!1)}};r.useEffect(()=>{E()},[]),r.useEffect(()=>{if(!c.trim()){f(null);return}b(!0);const L=setTimeout(async()=>{try{const W=await M.get(`/skills/search?q=${encodeURIComponent(c.trim())}`);f(W.results||[])}catch(W){a.error(`Search failed: ${W.message}`)}finally{b(!1)}},280);return()=>clearTimeout(L)},[c,a]);const q=r.useMemo(()=>{let L=n;return g!=="all"&&(L=L.filter(W=>(W.category||"tools")===g)),L},[n,g]),I=async L=>{if(confirm(`Install skill "${L.name}"?
|
|
345
|
+
|
|
346
|
+
${L.installCmd||`skills add ${L.id}`}`)){y(L.id);try{await M.post("/skills/install",{name:L.name,source:L.id}),a.success(`Installed ${L.name}.`),f(W=>(W==null?void 0:W.filter(G=>G.id!==L.id))||W),await E()}catch(W){a.error(`Install failed: ${W.message}`)}finally{y(null)}}},J=async L=>{try{L.enabled!==!1?(await M.post(`/skills/${encodeURIComponent(L.id)}/disable`),a.success(`Disabled ${L.name}.`)):(await M.post(`/skills/${encodeURIComponent(L.id)}/enable`),a.success(`Enabled ${L.name}.`)),await E()}catch(W){a.error(`Toggle failed: ${W.message}`)}},R=L=>{let W;W=e.jsxs("div",{className:"skill-detail",children:[e.jsx("p",{className:"muted text-sm mono skill-detail-source",children:L.source}),e.jsx("p",{className:"skill-detail-desc",children:L.description||"No description."}),e.jsxs("div",{className:"skill-detail-meta",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Category:"})," ",L.category]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Version:"})," ",e.jsx("code",{children:L.version})]}),L.path&&e.jsxs("span",{children:[e.jsx("strong",{children:"Path:"})," ",e.jsx("code",{children:L.path})]})]}),L.tags&&L.tags.length>0&&e.jsx("div",{className:"skill-detail-tags",children:L.tags.map(G=>e.jsx("span",{className:"tag",children:G},G))}),L.installCmd&&e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Install command"}),e.jsx("pre",{className:"skill-detail-cmd mono",children:L.installCmd})]})]}),i.open({title:L.name,width:560,children:W,footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(C,{variant:"ghost",onClick:()=>i.close(),children:"Close"}),!L.installed&&e.jsxs(C,{variant:"primary",onClick:()=>{i.close(),I(L)},loading:v===L.id,children:[e.jsx(Le,{size:12})," Install"]})]})})};return e.jsxs("div",{className:"view view-skills",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Me,{size:18})," Skills"]}),e.jsxs("p",{className:"view-subtitle",children:["Installed skills + browse the registry. Powered by the ",e.jsx("code",{children:"skills"})," CLI."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Be,{size:14}),e.jsx("input",{className:"input",type:"text",placeholder:"Browse new skills…",value:c,onChange:L=>u(L.target.value)}),c&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Clear search",onClick:()=>u(""),title:"Clear",children:e.jsx(zt,{size:12})})]}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:E,children:[e.jsx(de,{size:14})," Refresh"]})]})]}),c.trim()&&e.jsxs("section",{className:"skills-section",children:[e.jsxs("h3",{className:"skills-section-title",children:[e.jsx(Be,{size:14})," Search results",S&&e.jsx(ge,{size:"sm"})]}),S?e.jsx("div",{className:"skills-grid",children:[0,1,2].map(L=>e.jsx("div",{className:"skill-card skill-card-skeleton"},L))}):k&&k.length===0?e.jsx(Ie,{icon:e.jsx(Be,{size:28}),title:"No matches",message:`No skills match "${c}".`}):e.jsx("div",{className:"skills-grid",children:(k||[]).map(L=>e.jsx(gt,{skill:L,onShow:()=>R(L),onInstall:()=>I(L),installing:v===L.id,installed:!!n.find(W=>W.id===L.id)},`search-${L.id}`))})]}),!c.trim()&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"skills-categories",children:d.map(L=>{const W=js[L.id]||Me,G=n.filter(w=>(w.category||"tools")===L.id).length;return e.jsxs("button",{type:"button",className:ne("skill-category",g===L.id&&"skill-category-active"),onClick:()=>m(L.id),children:[e.jsx(W,{size:14}),e.jsx("span",{children:L.label}),G>0&&e.jsx("span",{className:"skill-category-count",children:G})]},L.id)})}),e.jsxs("section",{className:"skills-section",children:[e.jsxs("h3",{className:"skills-section-title",children:[e.jsx(ks,{size:14})," Installed"]}),p?e.jsx("div",{className:"view-loading",children:e.jsx(ge,{size:"lg"})}):e.jsx("div",{className:"skills-categories-list",children:d.map(L=>{const W=q.filter(w=>(w.category||"tools")===L.id);if(W.length===0)return null;const G=T.has(L.id);return e.jsxs("details",{className:"skills-category",open:G,onToggle:w=>{const $=w.currentTarget;x(V=>{const K=new Set(V);return $.open?K.add(L.id):K.delete(L.id),K})},children:[e.jsxs("summary",{className:"skills-category-summary",children:[e.jsxs("span",{className:"skills-category-name",children:[js[L.id]&&(()=>{const w=js[L.id];return e.jsx(w,{size:14})})(),L.label]}),e.jsx("span",{className:"skill-category-count",children:W.length})]}),e.jsx("div",{className:"skills-grid",children:W.map(w=>e.jsx(gt,{skill:w,onShow:()=>R(w),onToggle:()=>J(w)},w.id))})]},L.id)})})]})]})]})}function gt({skill:s,onShow:t,onInstall:a,onToggle:i,installing:n,installed:o}){const d=js[s.category]||Me,l=s.enabled!==!1;return e.jsxs(te,{variant:"elevated",interactive:!0,className:ne("skill-card",!l&&"skill-card-disabled"),children:[e.jsxs("div",{className:"skill-card-head",children:[e.jsx("div",{className:"skill-card-icon",style:{background:"color-mix(in srgb, var(--accent) 12%, transparent)"},children:e.jsx(d,{size:18})}),e.jsxs("div",{className:"skill-card-title-area",children:[e.jsx("div",{className:"skill-card-title",children:s.name}),e.jsx("div",{className:"skill-card-source mono",children:s.source})]}),o?e.jsx(Pe,{kind:l?"success":"neutral",children:l?"on":"off"}):e.jsx(Pe,{kind:"accent",children:"new"})]}),e.jsx("p",{className:"skill-card-desc",children:s.description||"No description."}),e.jsxs("div",{className:"skill-card-meta",children:[e.jsxs("span",{className:"mono text-sm",children:["v",s.version]}),s.category&&e.jsx("span",{className:"text-sm muted",children:s.category}),s.tags&&s.tags.length>0&&s.tags.slice(0,3).map(p=>e.jsx("span",{className:"skill-card-tag",children:p},p))]}),e.jsxs("div",{className:"skill-card-actions",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(Ws,{size:12})," Details"]}),o&&i&&e.jsxs(C,{variant:l?"ghost":"secondary",size:"sm",onClick:i,title:l?"Disable":"Enable",children:[l?e.jsx(en,{size:12}):e.jsx(Vs,{size:12}),l?"Disable":"Enable"]}),!o&&a&&e.jsxs(C,{variant:"primary",size:"sm",onClick:a,loading:n,children:[e.jsx(Le,{size:12})," Install"]})]})]})}const ss=[{id:"1h",label:"Last hour",ms:60*60*1e3},{id:"1d",label:"Last day",ms:24*60*60*1e3},{id:"7d",label:"Last 7 days",ms:7*24*60*60*1e3},{id:"30d",label:"Last 30 days",ms:30*24*60*60*1e3},{id:"all",label:"All time",ms:0}];function Jl({snapshot:s}){var S,b;const t=oe(),[a,i]=r.useState(null),[n,o]=r.useState(!0),[d,l]=r.useState("1d"),[p,h]=r.useState(new Set),[g,m]=r.useState(0),c=async v=>{try{const y=v?`?since=${encodeURIComponent(v)}&limit=1000`:"?limit=1000",T=await M.get(`/history${y}`);i(T),h(new Set(T.projects.filter(x=>T.events.some(E=>E.projectId===x.id)).map(x=>x.id)))}catch(y){t.error(`History load failed: ${y.message}`)}finally{o(!1)}};r.useEffect(()=>{o(!0);const v=ss.find(y=>y.id===d)||ss[1];if(v.ms>0){const y=new Date(Date.now()-v.ms).toISOString();c(y)}else c()},[d]),r.useEffect(()=>{const v=setInterval(()=>m(y=>y+1),3e4);return()=>clearInterval(v)},[]);const u=new Map;for(const v of(a==null?void 0:a.events)||[]){const y=v.projectId||"global";u.has(y)||u.set(y,[]),u.get(y).push(v)}const k=v=>{h(y=>{const T=new Set(y);return T.has(v)?T.delete(v):T.add(v),T})},f=()=>{if(!a)return;const v=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),y=URL.createObjectURL(v),T=document.createElement("a");T.href=y,T.download=`bizar-history-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,T.click(),URL.revokeObjectURL(y),t.success("History exported.")};return e.jsxs("div",{className:"view view-history","data-tick":g,children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(ns,{size:18})," History"]}),e.jsxs("p",{className:"view-subtitle",children:["Cross-project history of events, tasks, and plans.",((S=a==null?void 0:a.stats)==null?void 0:S.lastTs)&&e.jsxs(e.Fragment,{children:[" · last event ",ve(a.stats.lastTs)]})]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsx(Oa,{size:14,style:{color:"var(--text-dim)"}}),e.jsx("select",{className:"select select-sm",value:d,onChange:v=>l(v.target.value),title:"Time range",children:ss.map(v=>e.jsx("option",{value:v.id,children:v.label},v.id))})]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>{o(!0);const v=ss.find(y=>y.id===d)||ss[1];v.ms>0?c(new Date(Date.now()-v.ms).toISOString()):c()},children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:f,children:[e.jsx(Le,{size:14})," Export"]})]})]}),n&&e.jsxs("div",{className:"view-loading",children:[e.jsx(ge,{size:"lg"}),e.jsx("p",{children:"Loading history…"})]}),!n&&a&&e.jsxs("div",{className:"history-list",children:[a.projects.length===0&&e.jsxs(te,{children:[e.jsxs(ie,{children:[e.jsx(Ue,{size:14})," No projects"]}),e.jsx(re,{children:"Register a project in Overview to start tracking history."})]}),a.projects.map(v=>{const y=u.get(v.id)||[],T=p.has(v.id);return e.jsxs(te,{className:"history-project",children:[e.jsxs("div",{className:"history-project-head",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0,flex:1},children:[e.jsxs("div",{className:"history-project-name",children:[e.jsx(Ue,{size:16})," ",v.name]}),e.jsx("div",{className:"history-project-meta",children:v.path})]}),e.jsxs("div",{className:"history-project-stats",children:[e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:v.tasks.done}),e.jsxs("span",{className:"muted",children:["/ ",v.tasks.total," done"]})]}),v.tasks.doing>0&&e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:v.tasks.doing}),e.jsx("span",{className:"muted",children:"doing"})]}),v.tasks.blocked>0&&e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:v.tasks.blocked}),e.jsx("span",{className:"muted",children:"blocked"})]}),e.jsxs("span",{className:"history-project-stat",children:[e.jsx(ws,{size:11})," ",e.jsx("span",{className:"history-project-stat-num",children:v.plans}),e.jsxs("span",{className:"muted",children:[" plan",v.plans===1?"":"s"]})]}),v.lastAccessed&&e.jsx("span",{className:"history-project-stat",children:e.jsxs("span",{className:"muted",children:["last opened ",ve(v.lastAccessed)]})})]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>k(v.id),"aria-label":T?"Collapse":"Expand",children:T?e.jsx(Ae,{size:14}):e.jsx(He,{size:14})})]}),T&&e.jsx("div",{className:"history-timeline-mini",children:y.length===0?e.jsx("div",{className:"muted",style:{padding:"12px 8px",fontSize:12},children:"No events in this time range."}):y.slice(-100).reverse().map((x,E)=>e.jsxs("div",{className:"history-timeline-row",children:[e.jsx("span",{className:"history-timeline-ts",children:new Date(x.ts).toLocaleTimeString()}),e.jsx("span",{className:"history-timeline-kind",children:x.kind||"event"}),e.jsxs("span",{className:"history-timeline-msg",title:String(x.text||x.title||""),children:[x.author?`@${x.author} `:"",String(x.text??x.title??x.name??"")]})]},E))})]},v.id)}),u.has("global")&&e.jsxs(te,{className:"history-project",children:[e.jsx("div",{className:"history-project-head",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0,flex:1},children:[e.jsxs("div",{className:"history-project-name",children:[e.jsx(ns,{size:16})," Global events"]}),e.jsx("div",{className:"history-project-meta",children:"Activity not tied to a specific project"})]})}),e.jsx("div",{className:"history-timeline-mini",children:(u.get("global")||[]).slice(-100).reverse().map((v,y)=>e.jsxs("div",{className:"history-timeline-row",children:[e.jsx("span",{className:"history-timeline-ts",children:new Date(v.ts).toLocaleTimeString()}),e.jsx("span",{className:"history-timeline-kind",children:v.kind||"event"}),e.jsxs("span",{className:"history-timeline-msg",title:String(v.text||v.title||""),children:[v.author?`@${v.author} `:"",String(v.text??v.title??v.name??"")]})]},y))})]}),((b=a.stats)==null?void 0:b.counts)&&Object.keys(a.stats.counts).length>0&&e.jsxs(te,{children:[e.jsx(ie,{children:"Event counts by kind"}),e.jsxs(re,{children:[a.stats.lines," total lines in log"]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:8},children:Object.entries(a.stats.counts).sort((v,y)=>y[1]-v[1]).slice(0,30).map(([v,y])=>e.jsxs("span",{className:ne("tag","tag-neutral"),style:{fontFamily:"var(--font-mono)"},children:[v,": ",y]},v))})]})]})]})}function Xl({instance:s}){const t=oe(),[a,i]=r.useState(!1),n=s.tmuxSession,o=n?`tmux attach -t ${n}`:null,d=async()=>{if(o)try{await navigator.clipboard.writeText(o),t.success("Attach command copied")}catch{t.error("Could not copy to clipboard")}},l=async()=>{if(!(!s.instanceId||!n)){i(!0);try{const p=await M.post(`/background/${encodeURIComponent(s.instanceId)}/open-terminal`,{emulator:"system"});if(p.ok)t.success("Opening terminal…");else if(t.error(p.error||"Failed to open terminal"),o)try{await navigator.clipboard.writeText(o),t.success("Command copied to clipboard")}catch{}}catch(p){if(t.error(`Failed: ${p.message}`),o)try{await navigator.clipboard.writeText(o),t.success("Command copied to clipboard")}catch{}}finally{i(!1)}}};return n?e.jsxs(te,{variant:"outlined",className:"bg-tmux-card",children:[e.jsxs("div",{className:"bg-tmux-card-header",children:[e.jsx(is,{size:14}),e.jsx("span",{children:"tmux session"}),s.tmuxActive!==!1?e.jsx("span",{className:"badge badge-success",children:"live"}):e.jsx("span",{className:"badge badge-warning",children:"inactive"})]}),e.jsx("code",{className:"mono bg-tmux-session-name",children:n}),e.jsx("p",{className:"muted bg-tmux-hint",children:"Attach to the agent's tmux session from a terminal on the host running the dashboard."}),e.jsxs("div",{className:"bg-tmux-card-actions",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:d,title:"Copy attach command",children:[e.jsx(Ss,{size:14})," Copy"]}),e.jsxs(C,{variant:"primary",size:"sm",onClick:l,loading:a,title:"Open in system terminal",children:[e.jsx(is,{size:14})," Open terminal"]})]})]}):e.jsxs(te,{variant:"outlined",className:"bg-tmux-card bg-tmux-card-warn",children:[e.jsxs("div",{className:"bg-tmux-card-header",children:[e.jsx(De,{size:14}),e.jsx("span",{children:"No tmux session"})]}),e.jsx("p",{className:"bg-tmux-hint muted",children:"This instance does not have a tmux session attached. Sessions are created automatically when a background agent starts."})]})}const Ql=5e3,Zl=2e3,er=120;function sr(s){return s.status==="pending"||s.status==="running"}function tr(s){if(!Number.isFinite(s)||s<0)return"—";const t=Math.floor(s/1e3),a=Math.floor(t/3600),i=Math.floor(t%3600/60),n=t%60;return a>0?`${a}h ${i}m ${n}s`:i>0?`${i}m ${n}s`:`${n}s`}function ar(s){const t=oe(),a=ke(),[i,n]=r.useState([]),[o,d]=r.useState(!0),[l,p]=r.useState(null),[,h]=r.useState(0),g=r.useCallback(async()=>{try{const f=await M.get("/background");n(Array.isArray(f==null?void 0:f.instances)?f.instances:[]),p(null)}catch(f){p((f==null?void 0:f.message)||"Failed to load background agents.")}finally{d(!1)}},[]);r.useEffect(()=>{g();const f=setInterval(g,Ql);return()=>clearInterval(f)},[g]),r.useEffect(()=>{const f=setInterval(()=>h(S=>(S+1)%1e6),1e3);return()=>clearInterval(f)},[]),r.useEffect(()=>{const f=new Gs,S=f.on(b=>{const v=b.type;(v==="background:change"||v==="background:cleanup")&&g()});return()=>{S(),f.close()}},[g]);const m=i.filter(sr),c=f=>{ir(a,f)},u=async f=>{try{const S=await M.get(`/background/${encodeURIComponent(f.instanceId)}/tmux`);rr(a,S)}catch(S){t.error(`Tmux info failed: ${S.message}`)}},k=f=>{Ot(a,t,f.instanceId,f.agent||f.prompt,()=>{n(S=>S.filter(b=>b.instanceId!==f.instanceId))})};return o?e.jsx("div",{className:"bg-active-view",children:e.jsxs("div",{className:"bg-active-loading",children:[e.jsx(ge,{size:"md"}),e.jsx("span",{children:"Loading background agents…"})]})}):l?e.jsx("div",{className:"bg-active-view",children:e.jsx(Ie,{icon:e.jsx(ze,{size:32}),title:"Couldn't load background agents",message:l,action:e.jsxs(C,{variant:"primary",onClick:g,children:[e.jsx(de,{size:14})," Retry"]})})}):e.jsxs("div",{className:"bg-active-view",children:[e.jsxs("div",{className:"bg-active-header",children:[e.jsxs("div",{className:"bg-active-header-text",children:[e.jsx("h2",{className:"bg-active-title",children:"Active Background Agents"}),e.jsxs("p",{className:"bg-active-subtitle muted",children:[m.length," active · ",i.length," total in store"]})]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:g,title:"Refresh now",children:[e.jsx(de,{size:14})," Refresh"]})]}),m.length===0?e.jsx(Ie,{icon:e.jsx(ze,{size:32}),title:"No active background agents",message:"Spawn one from the Agents tab or via the bizar_spawn_background tool."}):e.jsx("div",{className:"bg-active-list",children:m.map(f=>e.jsx(nr,{inst:f,onViewOutput:()=>c(f),onOpenTmux:()=>u(f),onKill:()=>k(f)},f.instanceId))})]})}function nr({inst:s,onViewOutput:t,onOpenTmux:a,onKill:i}){const n=typeof s.startedAt=="number"?s.startedAt:0,o=n?vt(n):"—",d=n?Date.now()-n:0,l=yt(s.prompt,er);return e.jsxs(te,{className:"bg-active-card",variant:"elevated",children:[e.jsxs("div",{className:"bg-active-card-top",children:[e.jsxs("div",{className:"bg-active-card-id",children:[e.jsx("code",{className:"mono",children:s.instanceId}),e.jsx(Et,{status:s.status||"pending",dot:!0})]}),e.jsxs("div",{className:"bg-active-card-agent",children:[e.jsx("span",{className:"bg-active-card-agent-label",children:"Agent"}),e.jsx("span",{className:"bg-active-card-agent-name",children:s.agent||"unknown"})]})]}),l&&e.jsx("div",{className:"bg-active-prompt",children:l}),s.currentStep&&e.jsxs("div",{className:"bg-active-step",children:[e.jsx("span",{className:"bg-active-step-label",children:"Step:"}),e.jsx("span",{className:"bg-active-step-value",children:s.currentStep})]}),typeof s.progress=="number"&&e.jsxs("div",{className:"progress-bar","aria-label":"Progress",children:[e.jsx("div",{className:"progress-fill",style:{width:`${Math.max(0,Math.min(100,s.progress))}%`}}),e.jsxs("span",{className:"progress-label",children:[Math.round(s.progress),"%"]})]}),e.jsxs("div",{className:"bg-active-meta",children:[e.jsxs("span",{title:o,children:[e.jsx("strong",{children:"Started:"})," ",o]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Duration:"})," ",tr(d)]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Tool calls:"})," ",s.toolCallCount??0]}),s.tmuxSession&&e.jsxs("span",{className:ne(s.tmuxActive&&"bg-active-meta-tmux-live"),children:[e.jsx("strong",{children:"tmux:"})," ",e.jsx("code",{className:"mono",children:s.tmuxSession}),s.tmuxActive?" · live":""]})]}),e.jsxs("div",{className:"bg-active-actions",children:[e.jsxs(C,{variant:"secondary",size:"sm",onClick:t,children:[e.jsx(ls,{size:14})," View output"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(is,{size:14})," Open in tmux"]}),e.jsxs(C,{variant:"danger",size:"sm",onClick:i,children:[e.jsx(ye,{size:14})," Kill"]})]}),e.jsx(Xl,{instance:s})]})}function ir(s,t){s.open({title:`Output — ${t.agent||t.instanceId}`,width:720,children:e.jsx(lr,{instanceId:t.instanceId})})}function lr({instanceId:s}){const t=oe(),[a,i]=r.useState(""),[n,o]=r.useState(!0),[d,l]=r.useState(null),[p,h]=r.useState(!0),g=r.useRef(null),m=r.useRef(!0),c=r.useCallback(async()=>{try{const f=await M.get(`/background/${encodeURIComponent(s)}/output?lines=200`);i((f==null?void 0:f.output)??""),h((f==null?void 0:f.available)!==!1),l(null)}catch(f){l((f==null?void 0:f.message)||"Failed to load output.")}finally{o(!1)}},[s]);r.useEffect(()=>{c();const f=setInterval(c,Zl);return()=>clearInterval(f)},[c]),r.useEffect(()=>{var f;m.current&&((f=g.current)==null||f.scrollIntoView({behavior:"auto",block:"end"}))},[a]);const u=f=>{const S=f.currentTarget,b=S.scrollHeight-S.scrollTop-S.clientHeight<24;m.current=b},k=async()=>{try{await navigator.clipboard.writeText(a),t.success("Output copied.")}catch{}};return e.jsxs("div",{className:"bg-output-modal",children:[e.jsxs("div",{className:"bg-output-toolbar",children:[e.jsx("span",{className:"muted",children:p?`${a.length} chars · auto-refresh 2s`:"Output unavailable"}),e.jsxs("div",{className:"bg-output-toolbar-actions",children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:c,title:"Refresh now",children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:k,disabled:!a,children:[e.jsx(Ss,{size:14})," Copy"]})]})]}),n&&!a?e.jsxs("div",{className:"bg-output-loading",children:[e.jsx(Ka,{size:16,className:"spin"})," Loading…"]}):d?e.jsx("div",{className:"bg-output-error",children:d}):a?e.jsxs("div",{className:"bg-output-scroll",onScroll:u,children:[e.jsx("pre",{className:"bg-output-pre mono",children:e.jsx("code",{children:a})}),e.jsx("div",{ref:g})]}):e.jsx("div",{className:"bg-output-empty muted",children:"No output captured yet."})]})}function rr(s,t){const a=t.attachCommand||t.session||"";s.open({title:"Attach to tmux",width:520,children:e.jsx(cr,{info:t,cmd:a})})}function cr({info:s,cmd:t}){const[a,i]=r.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(t),i(!0),window.setTimeout(()=>i(!1),1500)}catch{}};return e.jsx("div",{className:"bg-tmux-modal",children:t?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"bg-tmux-meta",children:[s.exists?e.jsx("span",{className:"badge badge-success",children:"session live"}):e.jsxs("span",{className:"badge badge-warning",children:["session not running",s.reason?` — ${s.reason}`:""]}),s.session&&e.jsxs("span",{className:"bg-tmux-session muted",children:["· session ",e.jsx("code",{className:"mono",children:s.session})]})]}),e.jsx("label",{className:"field-label",children:"Attach command"}),e.jsxs("div",{className:"bg-tmux-command-row",children:[e.jsx("code",{className:"bg-tmux-command mono",children:t}),e.jsxs(C,{variant:"secondary",size:"sm",onClick:n,children:[e.jsx(Ss,{size:14})," ",a?"Copied":"Copy"]})]}),e.jsx("p",{className:"muted bg-tmux-hint",children:"Paste this into a terminal on the host running the dashboard. The dashboard itself does not open terminals."})]}):e.jsx("p",{className:"muted",children:"No tmux session attached to this instance."})})}const Ds={overview:Pn,chat:li,agents:di,artifacts:Li,tasks:Wi,activity:nl,background:ar,config:ll,settings:Il,mods:Dl,schedules:Vl,skills:Yl,history:Jl},or="v3.21.0";function dr(s,t,a,i){if(Ds[s]){const d=Ds[s];return e.jsx(d,{...t})}const n=a.find(d=>d.id===s);if(n)return e.jsx(Pl,{viewId:n.id,reloadKey:i,activeTab:t.activeTab,setActiveTab:t.setActiveTab});const o=Ds.overview;return e.jsx(o,{...t})}function mr(){return e.jsx(wa,{children:e.jsx(Sa,{children:e.jsx(hr,{})})})}function hr(){var H,F,P;const s=oe(),t=ke(),{isModalOpen:a}=t,i=r.useRef(!1),[n,o]=r.useState("overview"),[d,l]=r.useState(null),[p,h]=r.useState(null),[g,m]=r.useState("connecting"),[c,u]=r.useState(null),[k,f]=r.useState(!1),[S,b]=r.useState([]),[v,y]=r.useState(!1),[T,x]=r.useState([]),[E,q]=r.useState(0),I=r.useRef(null),[J,R]=r.useState(null);r.useEffect(()=>{let A=!1;return(async()=>{try{const D=await M.get("/mods/views");if(A)return;x(D.views||[])}catch{A||x([])}})(),()=>{A=!0}},[E,d==null?void 0:d.mods]),r.useEffect(()=>{if(!J)return;const A=J.on(D=>{((D==null?void 0:D.type)==="mod:change"||(D==null?void 0:D.type)==="mod:enabled"||(D==null?void 0:D.type)==="mod:installed")&&q(Q=>Q+1)});return()=>A()},[J]),r.useEffect(()=>{p!=null&&p.theme&&(ts(p.theme),Je(p.theme))},[p==null?void 0:p.theme]),r.useEffect(()=>{i.current=a},[a]),r.useEffect(()=>{var Q;if(((Q=p==null?void 0:p.theme)==null?void 0:Q.mode)!=="system")return;const A=window.matchMedia("(prefers-color-scheme: light)"),D=()=>ts(p.theme.mode);return A.addEventListener("change",D),()=>A.removeEventListener("change",D)},[(H=p==null?void 0:p.theme)==null?void 0:H.mode]),r.useEffect(()=>{let A=!1;const D=()=>Promise.all([M.get("/snapshot").catch(()=>null),M.get("/settings").catch(()=>null),M.get("/agents/stuck").catch(()=>null)]),Q=(z,_,O)=>{z&&l(z),_!=null&&_.data&&h(_.data),O!=null&&O.stuck&&b(O.stuck)};return(async()=>{try{const z=await M.probeAuthStatus(),[_,O,j]=await D();if(A||(Q(_,O,j),_||O))return;if(!z.loopback){u("Dashboard server unreachable.");return}if(await new Promise(ce=>setTimeout(ce,1e3)),A)return;const[U,ee,B]=await D();if(A)return;Q(U,ee,B),!U&&!ee&&u("Dashboard server unreachable.")}catch(z){if(A)return;const _=(z==null?void 0:z.message)??"unknown error";u(_),s.error(`Failed to load: ${_}`)}})(),()=>{A=!0}},[s]),r.useEffect(()=>{let A=!1;return M.get("/settings").then(D=>{var z,_;if(A)return;const Q=(_=(z=D==null?void 0:D.data)==null?void 0:z.ui)==null?void 0:_.defaultTab;Q&&o(Q)}).catch(()=>{}),()=>{A=!0}},[]),r.useEffect(()=>{let A=!1;const D=async()=>{try{const z=await M.get("/agents/stuck");A||b(_=>{const O=z.stuck||[];return _.length===0&&O.length>0&&s.warning(`${O.length} agent${O.length===1?"":"s"} stuck`,5e3),O})}catch{}},Q=setInterval(D,3e4);return D(),()=>{A=!0,clearInterval(Q)}},[]),r.useEffect(()=>{const A=new Gs;I.current=A,R(A);const D=A.onStatus(z=>m(z)),Q=A.on(z=>{var _;if(z.type==="snapshot"&&"data"in z&&z.data)l(O=>({...O??{},...z.data}));else if(z.type==="change"){const O=z,j=((_=O.path)==null?void 0:_.split("/").pop())||O.path||"";s.info(`File changed: ${j}`,2500),M.get("/snapshot").then(U=>l(ee=>({...ee??{},...U}))).catch(()=>{})}else if(z.type==="tasks:change"){const O=z;l(j=>{if(!j)return j;const U=(j.tasks||[]).map(B=>B.id===O.task.id?O.task:B),ee=U.some(B=>B.id===O.task.id);return{...j,tasks:ee?U:[O.task,...U]}})}else if(z.type==="tasks:delete"){const O=z;l(j=>j&&{...j,tasks:(j.tasks||[]).filter(U=>U.id!==O.id)})}else if(z.type==="settings:change"){const O=z;O.settings&&h(O.settings)}else if(z.type==="project:change")M.get("/snapshot").then(O=>l(j=>({...j??{},...O}))).catch(()=>{});else if(z.type==="agents:change"||z.type==="schedules:change")M.get("/snapshot").then(O=>l(j=>({...j??{},...O}))).catch(()=>{});else if(z.type==="agent:status"||z.type==="agent:restarted"){const O=z;l(j=>{if(!j)return j;const U=(j.agents||[]).map(ee=>ee.name===O.agent.name?O.agent:ee);return{...j,agents:U}})}else if(z.type==="artifact:change")M.get("/artifacts").then(O=>{l(j=>j&&{...j,artifacts:O.artifacts||[]})}).catch(()=>{});else if(z.type==="agent:stuck")b(z.agents||[]);else if(z.type==="dialog:show"){const O=z;O.dialog&&t.open({title:O.dialog.title,width:520,children:e.jsx(Ln,{dialog:O.dialog,onClose:()=>t.close()})})}});return()=>{D(),Q(),A.close(),R(null)}},[s]);const L=r.useCallback(A=>J?J.on(A):()=>{},[J]),W=r.useRef(0);r.useEffect(()=>{const A=()=>{W.current=Date.now()+1500};return document.addEventListener("mousedown",A,!0),document.addEventListener("click",A,!0),document.addEventListener("focusin",A,!0),document.addEventListener("keydown",A,!0),()=>{document.removeEventListener("mousedown",A,!0),document.removeEventListener("click",A,!0),document.removeEventListener("focusin",A,!0),document.removeEventListener("keydown",A,!0)}},[]),r.useEffect(()=>{const A={};Bs.forEach((Q,z)=>{A[String(z+1)]=Q.id});const D=Q=>{var ce,le,fe,me;if((Q.metaKey||Q.ctrlKey)&&Q.key.toLowerCase()==="k"){Q.preventDefault(),f(!0);return}if(Q.key==="/"&&!Q.metaKey&&!Q.ctrlKey){const ms=(le=(ce=Q.target)==null?void 0:ce.tagName)==null?void 0:le.toLowerCase();if(ms!=="input"&&ms!=="textarea"&&!((fe=Q.target)!=null&&fe.isContentEditable)){Q.preventDefault(),f(!0);return}}const z=document.activeElement;if(!z||z===document.body||z===document.documentElement)return;const O=Q.target,j=(me=O==null?void 0:O.tagName)==null?void 0:me.toLowerCase(),U=j==="input"||j==="textarea"||j==="select"||j==="button"||j==="option"||j==="label"||!!(O!=null&&O.isContentEditable);let ee=!1;if(O&&typeof O.closest=="function"&&(ee=!!O.closest('form, [role="dialog"], [contenteditable], [data-no-key]')),Q.repeat||i.current||U||ee||Q.metaKey||Q.ctrlKey||Q.altKey||Q.shiftKey||Date.now()<W.current)return;const B=A[Q.key];B&&(Q.preventDefault(),o(B))};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[]);const G=r.useMemo(()=>async()=>{try{const A=await M.get("/snapshot");l(D=>({...D??{},...A}))}catch(A){s.error(`Refresh failed: ${A.message}`)}},[s]),w=r.useMemo(()=>{const A=T.map(D=>({id:D.id,label:D.label,icon:D.kind==="iframe"?rs:Es,isMod:!0,modId:D.modId}));return[...Bs,...A]},[T]),$=r.useMemo(()=>d&&p?dr(n,{snapshot:d,settings:p,activeTab:n,setActiveTab:o,refreshSnapshot:G},T,E):null,[n,d,p,T,E,G]),V=async()=>{try{const A=await M.get("/projects");l(D=>{var Q;return D&&{...D,projects:A.projects||[],activeProject:((Q=A.projects)==null?void 0:Q.find(z=>z.id===A.active))||null}})}catch(A){s.error(`Projects refresh failed: ${A.message}`)}},K=async A=>{try{await M.post(`/projects/${encodeURIComponent(A)}/activate`),l(D=>D&&{...D,activeProject:D.projects.find(Q=>Q.id===A)||null})}catch(D){s.error(`Activate failed: ${D.message}`)}},X=A=>{const D=A.type;if(D==="agent")o("agents");else if(D==="task")o("tasks");else if(D==="mod")o("mods");else if(D==="schedule")o("schedules");else if(D==="project"){const Q=A.item.id;K(Q)}else if(D==="command")s.info(`/${A.item.name} — run from the TUI`,2500);else if(D==="setting"){const Q=A.item.id||A.item.path||"";o("settings");const z=_=>{if(_<=0)return;const O=Q?document.querySelector(`[data-setting-id="${CSS.escape(Q)}"]`):null;O?(O.scrollIntoView({behavior:"smooth",block:"center"}),O.classList.remove("setting-flash"),O.offsetWidth,O.classList.add("setting-flash"),window.setTimeout(()=>O.classList.remove("setting-flash"),1500)):window.setTimeout(()=>z(_-1),80)};window.setTimeout(()=>z(15),60)}},ae=((F=p==null?void 0:p.ui)==null?void 0:F.layout)||"topnav",se=((P=p==null?void 0:p.ui)==null?void 0:P.showHeader)!==!1;return e.jsxs("div",{className:"app","data-layout":ae,"data-active-tab":n,children:[se&&e.jsx(yn,{activeTab:n,onTabChange:o,wsStatus:g,version:or,activeProject:(d==null?void 0:d.activeProject)||null,projects:(d==null?void 0:d.projects)||[],onProjectChange:K,onProjectsRefresh:V,onOpenSearch:()=>f(!0),settings:p,notificationsSlot:e.jsx(zn,{wsSubscribe:L}),showTabs:ae==="topnav",extraTabs:w}),S.length>0&&!v&&e.jsxs("div",{className:"stuck-banner",role:"alert",children:[e.jsx(De,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:S.length})," agent",S.length===1?"":"s"," stuck:"," ",e.jsx("span",{className:"mono",children:S.map(A=>A.name).join(", ")})]}),e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>{o("agents"),y(!0)},children:"Review"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Dismiss",onClick:()=>y(!0),children:e.jsx($e,{size:14})})]}),e.jsxs("div",{className:"layout-body",children:[ae!=="topnav"&&e.jsx(Nn,{tabs:w,activeTab:n,onTabChange:o}),e.jsxs("main",{className:"content",children:[c&&e.jsxs("div",{className:"boot-error",children:[e.jsx("h2",{children:"Dashboard unavailable"}),e.jsx("p",{children:c}),e.jsxs("p",{className:"boot-error-hint",children:["Make sure the Bizar dashboard server is running. Try"," ",e.jsx("code",{children:"bizar-dash start"})," in your terminal."]})]}),!c&&(!d||!p)&&e.jsxs("div",{className:"loading",children:[e.jsx(ge,{size:"lg"}),e.jsx("p",{children:"Loading Bizar…"})]}),$]})]}),e.jsx(wn,{open:k,onClose:()=>f(!1),onSelect:X})]})}function ur(){const[s,t]=r.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-width: 767px)").matches);return r.useEffect(()=>{const a=window.matchMedia("(max-width: 767px)"),i=n=>t(n.matches);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),s?e.jsx(za,{}):e.jsx(mr,{})}const Ht=document.getElementById("root");if(!Ht)throw new Error("Root element #root not found");Ca(Ht).render(e.jsx(r.StrictMode,{children:e.jsx(ur,{})}));
|
|
347
|
+
//# sourceMappingURL=main-C4Dq4wTz.js.map
|