agent-relay 1.1.0 → 1.2.3

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.
Files changed (567) hide show
  1. package/.gitattributes +3 -0
  2. package/.nvmrc +1 -0
  3. package/.trajectories/completed/2026-01/traj_1dviorhnkcb5.json +65 -0
  4. package/.trajectories/completed/2026-01/traj_1dviorhnkcb5.md +37 -0
  5. package/.trajectories/completed/2026-01/traj_1k5if5snst2e.json +65 -0
  6. package/.trajectories/completed/2026-01/traj_1k5if5snst2e.md +37 -0
  7. package/.trajectories/completed/2026-01/traj_1rp3rges5811.json +49 -0
  8. package/.trajectories/completed/2026-01/traj_1rp3rges5811.md +31 -0
  9. package/.trajectories/completed/2026-01/traj_22bhyulruouw.json +113 -0
  10. package/.trajectories/completed/2026-01/traj_22bhyulruouw.md +57 -0
  11. package/.trajectories/completed/2026-01/traj_2dao7ddgnta0.json +53 -0
  12. package/.trajectories/completed/2026-01/traj_2dao7ddgnta0.md +32 -0
  13. package/.trajectories/completed/2026-01/traj_3t0440mjeunc.json +26 -0
  14. package/.trajectories/completed/2026-01/traj_3t0440mjeunc.md +6 -0
  15. package/.trajectories/completed/2026-01/traj_45x9494d9xnr.json +47 -0
  16. package/.trajectories/completed/2026-01/traj_45x9494d9xnr.md +32 -0
  17. package/.trajectories/completed/2026-01/traj_4aa0bb77s4nh.json +53 -0
  18. package/.trajectories/completed/2026-01/traj_4aa0bb77s4nh.md +32 -0
  19. package/.trajectories/completed/2026-01/traj_5lhmzq8rxpqv.json +59 -0
  20. package/.trajectories/completed/2026-01/traj_5lhmzq8rxpqv.md +33 -0
  21. package/.trajectories/completed/2026-01/traj_5vr4e9erb1fs.json +53 -0
  22. package/.trajectories/completed/2026-01/traj_5vr4e9erb1fs.md +32 -0
  23. package/.trajectories/completed/2026-01/traj_6fgiwdoklvym.json +48 -0
  24. package/.trajectories/completed/2026-01/traj_6fgiwdoklvym.md +24 -0
  25. package/.trajectories/completed/2026-01/traj_7ludwvz45veh.json +209 -0
  26. package/.trajectories/completed/2026-01/traj_7ludwvz45veh.md +97 -0
  27. package/.trajectories/completed/2026-01/traj_9921cuhel0pj.json +48 -0
  28. package/.trajectories/completed/2026-01/traj_9921cuhel0pj.md +24 -0
  29. package/.trajectories/completed/2026-01/traj_ajs7zqfux4wc.json +49 -0
  30. package/.trajectories/completed/2026-01/traj_ajs7zqfux4wc.md +23 -0
  31. package/.trajectories/completed/2026-01/traj_cvtqhlwcq9s0.json +53 -0
  32. package/.trajectories/completed/2026-01/traj_cvtqhlwcq9s0.md +32 -0
  33. package/.trajectories/completed/2026-01/traj_cxofprm2m2en.json +49 -0
  34. package/.trajectories/completed/2026-01/traj_cxofprm2m2en.md +31 -0
  35. package/.trajectories/completed/2026-01/traj_d2hhz3k0vrhn.json +26 -0
  36. package/.trajectories/completed/2026-01/traj_d2hhz3k0vrhn.md +6 -0
  37. package/.trajectories/completed/2026-01/traj_dfuvww9pege5.json +59 -0
  38. package/.trajectories/completed/2026-01/traj_dfuvww9pege5.md +37 -0
  39. package/.trajectories/completed/2026-01/traj_g0fisy9h51mf.json +77 -0
  40. package/.trajectories/completed/2026-01/traj_g0fisy9h51mf.md +42 -0
  41. package/.trajectories/completed/2026-01/traj_gjdre5voouod.json +53 -0
  42. package/.trajectories/completed/2026-01/traj_gjdre5voouod.md +32 -0
  43. package/.trajectories/completed/2026-01/traj_gtlyqtta3x8l.json +25 -0
  44. package/.trajectories/completed/2026-01/traj_gtlyqtta3x8l.md +15 -0
  45. package/.trajectories/completed/2026-01/traj_h4xijiuip3w4.json +101 -0
  46. package/.trajectories/completed/2026-01/traj_h4xijiuip3w4.md +44 -0
  47. package/.trajectories/completed/2026-01/traj_hhxte7w4gjjx.json +22 -0
  48. package/.trajectories/completed/2026-01/traj_hhxte7w4gjjx.md +5 -0
  49. package/.trajectories/completed/2026-01/traj_hpungyhoj6v5.json +53 -0
  50. package/.trajectories/completed/2026-01/traj_hpungyhoj6v5.md +32 -0
  51. package/.trajectories/completed/2026-01/traj_m2xkjv0w2sq7.json +25 -0
  52. package/.trajectories/completed/2026-01/traj_m2xkjv0w2sq7.md +15 -0
  53. package/.trajectories/completed/2026-01/traj_noq5zbvnrdvz.json +53 -0
  54. package/.trajectories/completed/2026-01/traj_noq5zbvnrdvz.md +32 -0
  55. package/.trajectories/completed/2026-01/traj_ntbs6ppopf46.json +53 -0
  56. package/.trajectories/completed/2026-01/traj_ntbs6ppopf46.md +32 -0
  57. package/.trajectories/completed/2026-01/traj_ozd98si6a7ns.json +48 -0
  58. package/.trajectories/completed/2026-01/traj_ozd98si6a7ns.md +24 -0
  59. package/.trajectories/completed/2026-01/traj_prdza7a5cxp5.json +53 -0
  60. package/.trajectories/completed/2026-01/traj_prdza7a5cxp5.md +32 -0
  61. package/.trajectories/completed/2026-01/traj_qb3twvvywfwi.json +77 -0
  62. package/.trajectories/completed/2026-01/traj_qb3twvvywfwi.md +42 -0
  63. package/.trajectories/completed/2026-01/traj_qft54mi7nfor.json +53 -0
  64. package/.trajectories/completed/2026-01/traj_qft54mi7nfor.md +32 -0
  65. package/.trajectories/completed/2026-01/traj_qx9uhf8whhxo.json +83 -0
  66. package/.trajectories/completed/2026-01/traj_qx9uhf8whhxo.md +47 -0
  67. package/.trajectories/completed/2026-01/traj_rd9toccj18a0.json +59 -0
  68. package/.trajectories/completed/2026-01/traj_rd9toccj18a0.md +37 -0
  69. package/.trajectories/completed/2026-01/traj_rt4fiw3ecp50.json +48 -0
  70. package/.trajectories/completed/2026-01/traj_rt4fiw3ecp50.md +16 -0
  71. package/.trajectories/completed/2026-01/traj_st8j35b0hrlc.json +59 -0
  72. package/.trajectories/completed/2026-01/traj_st8j35b0hrlc.md +37 -0
  73. package/.trajectories/completed/2026-01/traj_t1yy8m7hbuxp.json +53 -0
  74. package/.trajectories/completed/2026-01/traj_t1yy8m7hbuxp.md +32 -0
  75. package/.trajectories/completed/2026-01/traj_tmux_orchestrator_analysis.json +84 -0
  76. package/.trajectories/completed/2026-01/traj_tmux_orchestrator_analysis.md +109 -0
  77. package/.trajectories/completed/2026-01/traj_u9n9eqasw16k.json +53 -0
  78. package/.trajectories/completed/2026-01/traj_u9n9eqasw16k.md +32 -0
  79. package/.trajectories/completed/2026-01/traj_v87hypnongqx.json +71 -0
  80. package/.trajectories/completed/2026-01/traj_v87hypnongqx.md +42 -0
  81. package/.trajectories/completed/2026-01/traj_wkp2fgzdyinb.json +53 -0
  82. package/.trajectories/completed/2026-01/traj_wkp2fgzdyinb.md +32 -0
  83. package/.trajectories/completed/2026-01/traj_x14t8w8rn7xg.json +20 -0
  84. package/.trajectories/completed/2026-01/traj_x14t8w8rn7xg.md +6 -0
  85. package/.trajectories/completed/2026-01/traj_xnwbznkvv8ua.json +175 -0
  86. package/.trajectories/completed/2026-01/traj_xnwbznkvv8ua.md +82 -0
  87. package/.trajectories/completed/2026-01/traj_ysjc8zaeqtd3.json +47 -0
  88. package/.trajectories/completed/2026-01/traj_ysjc8zaeqtd3.md +32 -0
  89. package/.trajectories/completed/2026-01/traj_yvdadtvdgnz3.json +59 -0
  90. package/.trajectories/completed/2026-01/traj_yvdadtvdgnz3.md +37 -0
  91. package/.trajectories/completed/2026-01/traj_z0vcw1wrzide.json +53 -0
  92. package/.trajectories/completed/2026-01/traj_z0vcw1wrzide.md +32 -0
  93. package/.trajectories/index.json +314 -0
  94. package/ARCHITECTURE.md +1245 -0
  95. package/README.md +1 -1
  96. package/TESTING.md +278 -0
  97. package/deploy/init-db.sql +5 -0
  98. package/deploy/scripts/setup-fly-workspaces.sh +69 -0
  99. package/deploy/scripts/setup-railway.sh +75 -0
  100. package/deploy/workspace/entrypoint-browser.sh +118 -0
  101. package/deploy/workspace/entrypoint.sh +348 -0
  102. package/deploy/workspace/git-credential-relay +111 -0
  103. package/dist/bridge/spawner.d.ts +53 -0
  104. package/dist/bridge/spawner.js +203 -19
  105. package/dist/bridge/types.d.ts +12 -0
  106. package/dist/cli/index.js +618 -5
  107. package/dist/cloud/api/auth.d.ts +3 -2
  108. package/dist/cloud/api/auth.js +10 -98
  109. package/dist/cloud/api/billing.js +30 -9
  110. package/dist/cloud/api/cli-pty-runner.d.ts +54 -0
  111. package/dist/cloud/api/cli-pty-runner.js +119 -0
  112. package/dist/cloud/api/codex-auth-helper.d.ts +15 -0
  113. package/dist/cloud/api/codex-auth-helper.js +100 -0
  114. package/dist/cloud/api/generic-webhooks.d.ts +8 -0
  115. package/dist/cloud/api/generic-webhooks.js +129 -0
  116. package/dist/cloud/api/git.d.ts +8 -0
  117. package/dist/cloud/api/git.js +152 -0
  118. package/dist/cloud/api/github-app.d.ts +11 -0
  119. package/dist/cloud/api/github-app.js +189 -0
  120. package/dist/cloud/api/middleware/planLimits.d.ts +7 -0
  121. package/dist/cloud/api/middleware/planLimits.js +39 -1
  122. package/dist/cloud/api/monitoring.d.ts +11 -0
  123. package/dist/cloud/api/monitoring.js +578 -0
  124. package/dist/cloud/api/nango-auth.d.ts +9 -0
  125. package/dist/cloud/api/nango-auth.js +377 -0
  126. package/dist/cloud/api/onboarding.d.ts +8 -1
  127. package/dist/cloud/api/onboarding.js +313 -119
  128. package/dist/cloud/api/policy.d.ts +8 -0
  129. package/dist/cloud/api/policy.js +229 -0
  130. package/dist/cloud/api/providers.js +114 -42
  131. package/dist/cloud/api/repos.d.ts +1 -0
  132. package/dist/cloud/api/repos.js +186 -0
  133. package/dist/cloud/api/test-helpers.d.ts +10 -0
  134. package/dist/cloud/api/test-helpers.js +575 -0
  135. package/dist/cloud/api/webhooks.d.ts +8 -0
  136. package/dist/cloud/api/webhooks.js +645 -0
  137. package/dist/cloud/api/workspaces.js +320 -12
  138. package/dist/cloud/billing/plans.js +32 -19
  139. package/dist/cloud/billing/types.d.ts +9 -3
  140. package/dist/cloud/config.d.ts +9 -2
  141. package/dist/cloud/config.js +13 -4
  142. package/dist/cloud/db/drizzle.d.ts +84 -1
  143. package/dist/cloud/db/drizzle.js +470 -0
  144. package/dist/cloud/db/index.d.ts +9 -4
  145. package/dist/cloud/db/index.js +11 -3
  146. package/dist/cloud/db/schema.d.ts +3283 -556
  147. package/dist/cloud/db/schema.js +314 -1
  148. package/dist/cloud/index.d.ts +1 -0
  149. package/dist/cloud/index.js +2 -0
  150. package/dist/cloud/provisioner/index.d.ts +56 -0
  151. package/dist/cloud/provisioner/index.js +676 -34
  152. package/dist/cloud/server.d.ts +1 -0
  153. package/dist/cloud/server.js +362 -13
  154. package/dist/cloud/services/auto-scaler.d.ts +152 -0
  155. package/dist/cloud/services/auto-scaler.js +439 -0
  156. package/dist/cloud/services/capacity-manager.d.ts +148 -0
  157. package/dist/cloud/services/capacity-manager.js +449 -0
  158. package/dist/cloud/services/ci-agent-spawner.d.ts +49 -0
  159. package/dist/cloud/services/ci-agent-spawner.js +373 -0
  160. package/dist/cloud/services/index.d.ts +12 -0
  161. package/dist/cloud/services/index.js +15 -0
  162. package/dist/cloud/services/mention-handler.d.ts +65 -0
  163. package/dist/cloud/services/mention-handler.js +405 -0
  164. package/dist/cloud/services/nango.d.ts +186 -0
  165. package/dist/cloud/services/nango.js +344 -0
  166. package/dist/cloud/services/persistence.d.ts +131 -0
  167. package/dist/cloud/services/persistence.js +200 -0
  168. package/dist/cloud/services/planLimits.d.ts +37 -0
  169. package/dist/cloud/services/planLimits.js +86 -5
  170. package/dist/cloud/services/scaling-orchestrator.d.ts +159 -0
  171. package/dist/cloud/services/scaling-orchestrator.js +502 -0
  172. package/dist/cloud/services/scaling-policy.d.ts +121 -0
  173. package/dist/cloud/services/scaling-policy.js +415 -0
  174. package/dist/cloud/vault/index.js +1 -1
  175. package/dist/cloud/webhooks/index.d.ts +24 -0
  176. package/dist/cloud/webhooks/index.js +29 -0
  177. package/dist/cloud/webhooks/parsers/github.d.ts +8 -0
  178. package/dist/cloud/webhooks/parsers/github.js +234 -0
  179. package/dist/cloud/webhooks/parsers/index.d.ts +23 -0
  180. package/dist/cloud/webhooks/parsers/index.js +30 -0
  181. package/dist/cloud/webhooks/parsers/linear.d.ts +9 -0
  182. package/dist/cloud/webhooks/parsers/linear.js +258 -0
  183. package/dist/cloud/webhooks/parsers/slack.d.ts +9 -0
  184. package/dist/cloud/webhooks/parsers/slack.js +214 -0
  185. package/dist/cloud/webhooks/responders/github.d.ts +8 -0
  186. package/dist/cloud/webhooks/responders/github.js +73 -0
  187. package/dist/cloud/webhooks/responders/index.d.ts +23 -0
  188. package/dist/cloud/webhooks/responders/index.js +30 -0
  189. package/dist/cloud/webhooks/responders/linear.d.ts +9 -0
  190. package/dist/cloud/webhooks/responders/linear.js +149 -0
  191. package/dist/cloud/webhooks/responders/slack.d.ts +20 -0
  192. package/dist/cloud/webhooks/responders/slack.js +178 -0
  193. package/dist/cloud/webhooks/router.d.ts +25 -0
  194. package/dist/cloud/webhooks/router.js +504 -0
  195. package/dist/cloud/webhooks/rules-engine.d.ts +24 -0
  196. package/dist/cloud/webhooks/rules-engine.js +287 -0
  197. package/dist/cloud/webhooks/types.d.ts +186 -0
  198. package/dist/cloud/webhooks/types.js +8 -0
  199. package/dist/continuity/formatter.d.ts +51 -0
  200. package/dist/continuity/formatter.js +313 -0
  201. package/dist/continuity/handoff-store.d.ts +67 -0
  202. package/dist/continuity/handoff-store.js +472 -0
  203. package/dist/continuity/index.d.ts +45 -0
  204. package/dist/continuity/index.js +48 -0
  205. package/dist/continuity/ledger-store.d.ts +110 -0
  206. package/dist/continuity/ledger-store.js +500 -0
  207. package/dist/continuity/manager.d.ts +178 -0
  208. package/dist/continuity/manager.js +562 -0
  209. package/dist/continuity/parser.d.ts +76 -0
  210. package/dist/continuity/parser.js +579 -0
  211. package/dist/continuity/types.d.ts +180 -0
  212. package/dist/continuity/types.js +9 -0
  213. package/dist/daemon/agent-manager.d.ts +27 -0
  214. package/dist/daemon/agent-manager.js +107 -6
  215. package/dist/daemon/agent-registry.d.ts +32 -0
  216. package/dist/daemon/agent-registry.js +42 -2
  217. package/dist/daemon/api.d.ts +12 -0
  218. package/dist/daemon/api.js +131 -2
  219. package/dist/daemon/cli-auth.d.ts +67 -0
  220. package/dist/daemon/cli-auth.js +537 -0
  221. package/dist/daemon/cloud-sync.js +9 -7
  222. package/dist/daemon/orchestrator.js +30 -0
  223. package/dist/daemon/router.d.ts +5 -0
  224. package/dist/daemon/router.js +78 -26
  225. package/dist/daemon/server.d.ts +5 -0
  226. package/dist/daemon/server.js +9 -1
  227. package/dist/daemon/services/browser-testing.d.ts +88 -0
  228. package/dist/daemon/services/browser-testing.js +244 -0
  229. package/dist/daemon/services/container-spawner.d.ts +135 -0
  230. package/dist/daemon/services/container-spawner.js +313 -0
  231. package/dist/daemon/types.d.ts +5 -1
  232. package/dist/dashboard/out/404.html +1 -1
  233. package/dist/dashboard/out/_next/static/chunks/116-2502180def231162.js +1 -0
  234. package/dist/dashboard/out/_next/static/chunks/282-980c2eb8fff20123.js +1 -0
  235. package/dist/dashboard/out/_next/static/chunks/699-3b1cd6618a45d259.js +1 -0
  236. package/dist/dashboard/out/_next/static/chunks/724-2dae7627550ab88f.js +9 -0
  237. package/dist/dashboard/out/_next/static/chunks/766-1f2dd8cb7f766b0b.js +1 -0
  238. package/dist/dashboard/out/_next/static/chunks/app/app/onboarding/page-3fdfa60e53f2810d.js +1 -0
  239. package/dist/dashboard/out/_next/static/chunks/app/app/page-e6381e5a6e1fbcfd.js +1 -0
  240. package/dist/dashboard/out/_next/static/chunks/app/connect-repos/page-3538dfe0ffe984b8.js +1 -0
  241. package/dist/dashboard/out/_next/static/chunks/app/history/{page-b6edd4dde8d08194.js → page-abb9ab2d329f56e9.js} +1 -1
  242. package/dist/dashboard/out/_next/static/chunks/app/layout-c0d118c0f92d969c.js +1 -0
  243. package/dist/dashboard/out/_next/static/chunks/app/login/page-c22d080201cbd9fb.js +1 -0
  244. package/dist/dashboard/out/_next/static/chunks/app/metrics/page-67a3e98d9a43a6ed.js +1 -0
  245. package/dist/dashboard/out/_next/static/chunks/app/page-77e9c65420a06cfb.js +1 -0
  246. package/dist/dashboard/out/_next/static/chunks/app/pricing/page-b08ed1c34d14434a.js +1 -0
  247. package/dist/dashboard/out/_next/static/chunks/app/providers/page-e88bc117ef7671c3.js +1 -0
  248. package/dist/dashboard/out/_next/static/chunks/app/signup/page-68d34f50baa8ab6b.js +1 -0
  249. package/dist/dashboard/out/_next/static/chunks/e868780c-48e5f147c90a3a41.js +18 -0
  250. package/dist/dashboard/out/_next/static/chunks/{main-app-5d692157a8eb1fd9.js → main-app-6e8e8d3ef4e0192a.js} +1 -1
  251. package/dist/dashboard/out/_next/static/chunks/{main-c2f423b9c9f4591b.js → main-ed4e1fb6f29c34cf.js} +1 -1
  252. package/dist/dashboard/out/_next/static/chunks/webpack-1cdd8ed57114d5e1.js +1 -0
  253. package/dist/dashboard/out/_next/static/css/29852f26181969a0.css +1 -0
  254. package/dist/dashboard/out/_next/static/css/7c3ae9e8617d42a5.css +1 -0
  255. package/dist/dashboard/out/app/onboarding.html +1 -0
  256. package/dist/dashboard/out/app/onboarding.txt +7 -0
  257. package/dist/dashboard/out/app.html +1 -14
  258. package/dist/dashboard/out/app.txt +2 -2
  259. package/dist/dashboard/out/connect-repos.html +1 -0
  260. package/dist/dashboard/out/connect-repos.txt +7 -0
  261. package/dist/dashboard/out/history.html +1 -1
  262. package/dist/dashboard/out/history.txt +2 -2
  263. package/dist/dashboard/out/index.html +1 -1
  264. package/dist/dashboard/out/index.txt +2 -2
  265. package/dist/dashboard/out/login.html +6 -0
  266. package/dist/dashboard/out/login.txt +7 -0
  267. package/dist/dashboard/out/metrics.html +1 -1
  268. package/dist/dashboard/out/metrics.txt +2 -2
  269. package/dist/dashboard/out/pricing.html +3 -3
  270. package/dist/dashboard/out/pricing.txt +2 -2
  271. package/dist/dashboard/out/providers.html +1 -0
  272. package/dist/dashboard/out/providers.txt +7 -0
  273. package/dist/dashboard/out/signup.html +6 -0
  274. package/dist/dashboard/out/signup.txt +7 -0
  275. package/dist/dashboard-server/server.js +1308 -8
  276. package/dist/hooks/emitter.d.ts +40 -0
  277. package/dist/hooks/emitter.js +63 -0
  278. package/dist/hooks/index.d.ts +3 -0
  279. package/dist/hooks/index.js +3 -0
  280. package/dist/hooks/registry.d.ts +173 -0
  281. package/dist/hooks/registry.js +476 -0
  282. package/dist/hooks/trajectory-hooks.d.ts +52 -0
  283. package/dist/hooks/trajectory-hooks.js +183 -0
  284. package/dist/hooks/types.d.ts +141 -0
  285. package/dist/index.d.ts +2 -0
  286. package/dist/index.js +3 -0
  287. package/dist/memory/adapters/index.d.ts +8 -0
  288. package/dist/memory/adapters/index.js +8 -0
  289. package/dist/memory/adapters/inmemory.d.ts +59 -0
  290. package/dist/memory/adapters/inmemory.js +195 -0
  291. package/dist/memory/adapters/supermemory.d.ts +71 -0
  292. package/dist/memory/adapters/supermemory.js +338 -0
  293. package/dist/memory/factory.d.ts +48 -0
  294. package/dist/memory/factory.js +143 -0
  295. package/dist/memory/index.d.ts +32 -0
  296. package/dist/memory/index.js +32 -0
  297. package/dist/memory/memory-hooks.d.ts +60 -0
  298. package/dist/memory/memory-hooks.js +313 -0
  299. package/dist/memory/service.d.ts +49 -0
  300. package/dist/memory/service.js +146 -0
  301. package/dist/memory/types.d.ts +195 -0
  302. package/dist/memory/types.js +8 -0
  303. package/dist/policy/agent-policy.d.ts +225 -0
  304. package/dist/policy/agent-policy.js +665 -0
  305. package/dist/policy/cloud-policy-fetcher.d.ts +12 -0
  306. package/dist/policy/cloud-policy-fetcher.js +64 -0
  307. package/dist/resiliency/crash-insights.d.ts +156 -0
  308. package/dist/resiliency/crash-insights.js +492 -0
  309. package/dist/resiliency/gossip-health.d.ts +137 -0
  310. package/dist/resiliency/gossip-health.js +241 -0
  311. package/dist/resiliency/index.d.ts +5 -0
  312. package/dist/resiliency/index.js +5 -0
  313. package/dist/resiliency/leader-watchdog.d.ts +109 -0
  314. package/dist/resiliency/leader-watchdog.js +189 -0
  315. package/dist/resiliency/memory-monitor.d.ts +172 -0
  316. package/dist/resiliency/memory-monitor.js +593 -0
  317. package/dist/resiliency/stateless-lead.d.ts +149 -0
  318. package/dist/resiliency/stateless-lead.js +308 -0
  319. package/dist/resiliency/supervisor.d.ts +38 -0
  320. package/dist/resiliency/supervisor.js +122 -0
  321. package/dist/shared/cli-auth-config.d.ts +91 -0
  322. package/dist/shared/cli-auth-config.js +264 -0
  323. package/dist/storage/adapter.d.ts +1 -1
  324. package/dist/trajectory/config.d.ts +84 -0
  325. package/dist/trajectory/config.js +163 -0
  326. package/dist/trajectory/index.d.ts +8 -0
  327. package/dist/trajectory/index.js +8 -0
  328. package/dist/trajectory/integration.d.ts +292 -0
  329. package/dist/trajectory/integration.js +834 -0
  330. package/dist/utils/logger.js +1 -1
  331. package/dist/utils/project-namespace.d.ts +24 -0
  332. package/dist/utils/project-namespace.js +84 -0
  333. package/dist/wrapper/parser.d.ts +10 -0
  334. package/dist/wrapper/parser.js +100 -33
  335. package/dist/wrapper/pty-wrapper.d.ts +197 -16
  336. package/dist/wrapper/pty-wrapper.js +943 -106
  337. package/dist/wrapper/shared.d.ts +165 -0
  338. package/dist/wrapper/shared.js +270 -0
  339. package/dist/wrapper/tmux-wrapper.d.ts +73 -11
  340. package/dist/wrapper/tmux-wrapper.js +541 -120
  341. package/package.json +16 -16
  342. package/scripts/postinstall.js +60 -0
  343. package/test-push.txt +1 -0
  344. package/bin/tmux +0 -0
  345. package/dist/bridge/config.d.ts.map +0 -1
  346. package/dist/bridge/config.js.map +0 -1
  347. package/dist/bridge/index.d.ts.map +0 -1
  348. package/dist/bridge/index.js.map +0 -1
  349. package/dist/bridge/multi-project-client.d.ts.map +0 -1
  350. package/dist/bridge/multi-project-client.js.map +0 -1
  351. package/dist/bridge/shadow-cli.d.ts.map +0 -1
  352. package/dist/bridge/shadow-cli.js.map +0 -1
  353. package/dist/bridge/shadow-config.d.ts.map +0 -1
  354. package/dist/bridge/shadow-config.js.map +0 -1
  355. package/dist/bridge/spawner.d.ts.map +0 -1
  356. package/dist/bridge/spawner.js.map +0 -1
  357. package/dist/bridge/teams-config.d.ts.map +0 -1
  358. package/dist/bridge/teams-config.js.map +0 -1
  359. package/dist/bridge/types.d.ts.map +0 -1
  360. package/dist/bridge/types.js.map +0 -1
  361. package/dist/bridge/utils.d.ts.map +0 -1
  362. package/dist/bridge/utils.js.map +0 -1
  363. package/dist/cli/index.d.ts.map +0 -1
  364. package/dist/cli/index.js.map +0 -1
  365. package/dist/cloud/api/auth.d.ts.map +0 -1
  366. package/dist/cloud/api/auth.js.map +0 -1
  367. package/dist/cloud/api/billing.d.ts.map +0 -1
  368. package/dist/cloud/api/billing.js.map +0 -1
  369. package/dist/cloud/api/coordinators.d.ts.map +0 -1
  370. package/dist/cloud/api/coordinators.js.map +0 -1
  371. package/dist/cloud/api/daemons.d.ts.map +0 -1
  372. package/dist/cloud/api/daemons.js.map +0 -1
  373. package/dist/cloud/api/middleware/planLimits.d.ts.map +0 -1
  374. package/dist/cloud/api/middleware/planLimits.js.map +0 -1
  375. package/dist/cloud/api/onboarding.d.ts.map +0 -1
  376. package/dist/cloud/api/onboarding.js.map +0 -1
  377. package/dist/cloud/api/providers.d.ts.map +0 -1
  378. package/dist/cloud/api/providers.js.map +0 -1
  379. package/dist/cloud/api/repos.d.ts.map +0 -1
  380. package/dist/cloud/api/repos.js.map +0 -1
  381. package/dist/cloud/api/teams.d.ts.map +0 -1
  382. package/dist/cloud/api/teams.js.map +0 -1
  383. package/dist/cloud/api/usage.d.ts.map +0 -1
  384. package/dist/cloud/api/usage.js.map +0 -1
  385. package/dist/cloud/api/workspaces.d.ts.map +0 -1
  386. package/dist/cloud/api/workspaces.js.map +0 -1
  387. package/dist/cloud/billing/index.d.ts.map +0 -1
  388. package/dist/cloud/billing/index.js.map +0 -1
  389. package/dist/cloud/billing/plans.d.ts.map +0 -1
  390. package/dist/cloud/billing/plans.js.map +0 -1
  391. package/dist/cloud/billing/service.d.ts.map +0 -1
  392. package/dist/cloud/billing/service.js.map +0 -1
  393. package/dist/cloud/billing/types.d.ts.map +0 -1
  394. package/dist/cloud/billing/types.js.map +0 -1
  395. package/dist/cloud/config.d.ts.map +0 -1
  396. package/dist/cloud/config.js.map +0 -1
  397. package/dist/cloud/db/drizzle.d.ts.map +0 -1
  398. package/dist/cloud/db/drizzle.js.map +0 -1
  399. package/dist/cloud/db/index.d.ts.map +0 -1
  400. package/dist/cloud/db/index.js.map +0 -1
  401. package/dist/cloud/db/schema.d.ts.map +0 -1
  402. package/dist/cloud/db/schema.js.map +0 -1
  403. package/dist/cloud/index.d.ts.map +0 -1
  404. package/dist/cloud/index.js.map +0 -1
  405. package/dist/cloud/provisioner/index.d.ts.map +0 -1
  406. package/dist/cloud/provisioner/index.js.map +0 -1
  407. package/dist/cloud/server.d.ts.map +0 -1
  408. package/dist/cloud/server.js.map +0 -1
  409. package/dist/cloud/services/coordinator.d.ts.map +0 -1
  410. package/dist/cloud/services/coordinator.js.map +0 -1
  411. package/dist/cloud/services/planLimits.d.ts.map +0 -1
  412. package/dist/cloud/services/planLimits.js.map +0 -1
  413. package/dist/cloud/vault/index.d.ts.map +0 -1
  414. package/dist/cloud/vault/index.js.map +0 -1
  415. package/dist/daemon/agent-manager.d.ts.map +0 -1
  416. package/dist/daemon/agent-manager.js.map +0 -1
  417. package/dist/daemon/agent-registry.d.ts.map +0 -1
  418. package/dist/daemon/agent-registry.js.map +0 -1
  419. package/dist/daemon/api.d.ts.map +0 -1
  420. package/dist/daemon/api.js.map +0 -1
  421. package/dist/daemon/auth.d.ts.map +0 -1
  422. package/dist/daemon/auth.js.map +0 -1
  423. package/dist/daemon/cloud-sync.d.ts.map +0 -1
  424. package/dist/daemon/cloud-sync.js.map +0 -1
  425. package/dist/daemon/connection.d.ts.map +0 -1
  426. package/dist/daemon/connection.js.map +0 -1
  427. package/dist/daemon/index.d.ts.map +0 -1
  428. package/dist/daemon/index.js.map +0 -1
  429. package/dist/daemon/orchestrator.d.ts.map +0 -1
  430. package/dist/daemon/orchestrator.js.map +0 -1
  431. package/dist/daemon/registry.d.ts.map +0 -1
  432. package/dist/daemon/registry.js.map +0 -1
  433. package/dist/daemon/router.d.ts.map +0 -1
  434. package/dist/daemon/router.js.map +0 -1
  435. package/dist/daemon/server.d.ts.map +0 -1
  436. package/dist/daemon/server.js.map +0 -1
  437. package/dist/daemon/types.d.ts.map +0 -1
  438. package/dist/daemon/types.js.map +0 -1
  439. package/dist/daemon/workspace-manager.d.ts.map +0 -1
  440. package/dist/daemon/workspace-manager.js.map +0 -1
  441. package/dist/dashboard/out/_next/static/chunks/693-7b3301d8f6bc5014.js +0 -1
  442. package/dist/dashboard/out/_next/static/chunks/713-f78477eb185f1f4d.js +0 -1
  443. package/dist/dashboard/out/_next/static/chunks/766-e53e1cfe39b0b5b5.js +0 -1
  444. package/dist/dashboard/out/_next/static/chunks/900-037c64bfd797fb2a.js +0 -1
  445. package/dist/dashboard/out/_next/static/chunks/app/app/page-e3d9e1f4466b9bae.js +0 -1
  446. package/dist/dashboard/out/_next/static/chunks/app/layout-2433bb48965f4333.js +0 -1
  447. package/dist/dashboard/out/_next/static/chunks/app/metrics/page-e68825a81db67ba1.js +0 -1
  448. package/dist/dashboard/out/_next/static/chunks/app/page-cc108bf68c8a657f.js +0 -1
  449. package/dist/dashboard/out/_next/static/chunks/app/pricing/page-d80e03a5297f95b6.js +0 -1
  450. package/dist/dashboard/out/_next/static/chunks/webpack-a5acc2831d094776.js +0 -1
  451. package/dist/dashboard/out/_next/static/css/79b80143647a07d7.css +0 -1
  452. package/dist/dashboard/out/_next/static/css/8cf277370ad48cfe.css +0 -1
  453. package/dist/dashboard-server/metrics.d.ts.map +0 -1
  454. package/dist/dashboard-server/metrics.js.map +0 -1
  455. package/dist/dashboard-server/needs-attention.d.ts.map +0 -1
  456. package/dist/dashboard-server/needs-attention.js.map +0 -1
  457. package/dist/dashboard-server/server.d.ts.map +0 -1
  458. package/dist/dashboard-server/server.js.map +0 -1
  459. package/dist/dashboard-server/start.d.ts.map +0 -1
  460. package/dist/dashboard-server/start.js.map +0 -1
  461. package/dist/hooks/inbox-check/hook.d.ts.map +0 -1
  462. package/dist/hooks/inbox-check/hook.js.map +0 -1
  463. package/dist/hooks/inbox-check/index.d.ts.map +0 -1
  464. package/dist/hooks/inbox-check/index.js.map +0 -1
  465. package/dist/hooks/inbox-check/types.d.ts.map +0 -1
  466. package/dist/hooks/inbox-check/types.js.map +0 -1
  467. package/dist/hooks/inbox-check/utils.d.ts.map +0 -1
  468. package/dist/hooks/inbox-check/utils.js.map +0 -1
  469. package/dist/hooks/index.d.ts.map +0 -1
  470. package/dist/hooks/index.js.map +0 -1
  471. package/dist/hooks/types.d.ts.map +0 -1
  472. package/dist/hooks/types.js.map +0 -1
  473. package/dist/index.d.ts.map +0 -1
  474. package/dist/index.js.map +0 -1
  475. package/dist/protocol/framing.d.ts.map +0 -1
  476. package/dist/protocol/framing.js.map +0 -1
  477. package/dist/protocol/index.d.ts.map +0 -1
  478. package/dist/protocol/index.js.map +0 -1
  479. package/dist/protocol/types.d.ts.map +0 -1
  480. package/dist/protocol/types.js.map +0 -1
  481. package/dist/resiliency/context-persistence.d.ts.map +0 -1
  482. package/dist/resiliency/context-persistence.js.map +0 -1
  483. package/dist/resiliency/health-monitor.d.ts.map +0 -1
  484. package/dist/resiliency/health-monitor.js.map +0 -1
  485. package/dist/resiliency/index.d.ts.map +0 -1
  486. package/dist/resiliency/index.js.map +0 -1
  487. package/dist/resiliency/logger.d.ts.map +0 -1
  488. package/dist/resiliency/logger.js.map +0 -1
  489. package/dist/resiliency/metrics.d.ts.map +0 -1
  490. package/dist/resiliency/metrics.js.map +0 -1
  491. package/dist/resiliency/provider-context.d.ts.map +0 -1
  492. package/dist/resiliency/provider-context.js.map +0 -1
  493. package/dist/resiliency/supervisor.d.ts.map +0 -1
  494. package/dist/resiliency/supervisor.js.map +0 -1
  495. package/dist/state/agent-state.d.ts.map +0 -1
  496. package/dist/state/agent-state.js.map +0 -1
  497. package/dist/storage/adapter.d.ts.map +0 -1
  498. package/dist/storage/adapter.js.map +0 -1
  499. package/dist/storage/sqlite-adapter.d.ts.map +0 -1
  500. package/dist/storage/sqlite-adapter.js.map +0 -1
  501. package/dist/utils/agent-config.d.ts.map +0 -1
  502. package/dist/utils/agent-config.js.map +0 -1
  503. package/dist/utils/command-resolver.d.ts.map +0 -1
  504. package/dist/utils/command-resolver.js.map +0 -1
  505. package/dist/utils/index.d.ts.map +0 -1
  506. package/dist/utils/index.js.map +0 -1
  507. package/dist/utils/logger.d.ts.map +0 -1
  508. package/dist/utils/logger.js.map +0 -1
  509. package/dist/utils/name-generator.d.ts.map +0 -1
  510. package/dist/utils/name-generator.js.map +0 -1
  511. package/dist/utils/project-namespace.d.ts.map +0 -1
  512. package/dist/utils/project-namespace.js.map +0 -1
  513. package/dist/utils/tmux-resolver.d.ts.map +0 -1
  514. package/dist/utils/tmux-resolver.js.map +0 -1
  515. package/dist/utils/update-checker.d.ts.map +0 -1
  516. package/dist/utils/update-checker.js.map +0 -1
  517. package/dist/wrapper/client.d.ts.map +0 -1
  518. package/dist/wrapper/client.js.map +0 -1
  519. package/dist/wrapper/inbox.d.ts.map +0 -1
  520. package/dist/wrapper/inbox.js.map +0 -1
  521. package/dist/wrapper/index.d.ts.map +0 -1
  522. package/dist/wrapper/index.js.map +0 -1
  523. package/dist/wrapper/parser.d.ts.map +0 -1
  524. package/dist/wrapper/parser.js.map +0 -1
  525. package/dist/wrapper/pty-wrapper.d.ts.map +0 -1
  526. package/dist/wrapper/pty-wrapper.js.map +0 -1
  527. package/dist/wrapper/tmux-wrapper.d.ts.map +0 -1
  528. package/dist/wrapper/tmux-wrapper.js.map +0 -1
  529. package/docs/AGENTS.md +0 -513
  530. package/docs/ARCHITECTURE_DECISIONS.md +0 -175
  531. package/docs/CHANGELOG.md +0 -11
  532. package/docs/CLI-SIMPLIFICATION-COMPLETE.md +0 -48
  533. package/docs/CLOUD-ARCHITECTURE.md +0 -652
  534. package/docs/CLOUD-ONBOARDING-DESIGN.md +0 -1983
  535. package/docs/COMPETITIVE_ANALYSIS.md +0 -897
  536. package/docs/CONTRIBUTING.md +0 -151
  537. package/docs/DESIGN_BRIDGE_STAFFING.md +0 -878
  538. package/docs/DESIGN_V2.md +0 -1079
  539. package/docs/INTEGRATION-GUIDE.md +0 -926
  540. package/docs/MONETIZATION.md +0 -1679
  541. package/docs/PROPOSAL-trajectories.md +0 -1582
  542. package/docs/PROTOCOL.md +0 -325
  543. package/docs/SCALING_ANALYSIS.md +0 -280
  544. package/docs/TESTING_PRESENCE_FEATURES.md +0 -327
  545. package/docs/TMUX_IMPLEMENTATION_NOTES.md +0 -364
  546. package/docs/TMUX_IMPROVEMENTS.md +0 -968
  547. package/docs/agent-relay-snippet.md +0 -168
  548. package/docs/competitive-analysis-mcp-agent-mail.md +0 -389
  549. package/docs/dashboard-v2-plan.md +0 -179
  550. package/docs/guides/CLOUD.md +0 -236
  551. package/docs/guides/LOCAL.md +0 -535
  552. package/docs/guides/SELF-HOSTED.md +0 -494
  553. package/docs/proposals/shadow-as-subagent.md +0 -765
  554. package/docs/proposals/slack-bot-integration.md +0 -1457
  555. package/docs/removable-code-analysis.md +0 -24
  556. package/scripts/dev/PUBLIC_RELEASE_PLAN.md +0 -88
  557. package/scripts/dev/dev-team-setup.sh +0 -431
  558. package/scripts/e2e-test.sh +0 -119
  559. package/scripts/games/game-protocol.md +0 -79
  560. package/scripts/games/hearts-setup.sh +0 -264
  561. package/scripts/tictactoe-setup.sh +0 -181
  562. /package/dist/dashboard/out/_next/static/chunks/{117-b2cd8d6485aacf2b.js → 117-f7b8ab0809342e77.js} +0 -0
  563. /package/dist/dashboard/out/_next/static/chunks/{648-8f3f26864ce515e5.js → 648-5cc6e1921389a58a.js} +0 -0
  564. /package/dist/dashboard/out/_next/static/chunks/app/_not-found/{page-0b990dbb71d72a98.js → page-53b8a69f76db17d0.js} +0 -0
  565. /package/dist/dashboard/out/_next/static/chunks/{fd9d1056-bf46c09eb57e019c.js → fd9d1056-609918ca7b6280bb.js} +0 -0
  566. /package/dist/dashboard/out/_next/static/{6HHWb2ZmnJ4OSm0zUP7h4 → wPgKJtcOmTFLpUncDg16A}/_buildManifest.js +0 -0
  567. /package/dist/dashboard/out/_next/static/{6HHWb2ZmnJ4OSm0zUP7h4 → wPgKJtcOmTFLpUncDg16A}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[693],{693:function(e,t,r){r.d(t,{g:function(){return t5}});var n=r(7437),s=r(2265),a=r(637);function o(e){let t=new Map;for(let r of e){let e=r.team||(0,a.oU)(r.name),n=(0,a.GW)(r.name),s=t.get(e);s||(s={prefix:e,displayName:d(e),color:n,agents:[],isExpanded:!0},t.set(e,s)),s.agents.push(r)}let r=Array.from(t.values()).sort((e,t)=>e.prefix.localeCompare(t.prefix));for(let e of r)e.agents.sort((e,t)=>e.name.localeCompare(t.name));return r}function l(e){let t=e.split("-").filter(Boolean);return 0===t.length?e:d(t[t.length-1])}function i(e){return e.split("-").filter(Boolean).map(d).join(" > ")}function c(e,t){return t?e.filter(e=>(function(e,t){if(!t)return!0;let r=t.toLowerCase(),n=e.toLowerCase();return!!n.includes(r)||n.split("-").some(e=>e.includes(r))})(e.name,t)):e}function d(e){return e?e.charAt(0).toUpperCase()+e.slice(1):e}function x(e){let t=0,r=0,n=0;for(let s of e)"online"===s.status?t++:"offline"===s.status&&r++,s.needsAttention&&n++;return{total:e.length,online:t,offline:r,needsAttention:n}}function u(e){let{isProcessing:t,processingStartedAt:r,size:a="medium",showElapsed:o=!1,showLabel:l=!1}=e,[i,c]=(0,s.useState)(0);if((0,s.useEffect)(()=>{if(!t||!r){c(0);return}let e=()=>{c(Date.now()-r)};e();let n=setInterval(e,1e3);return()=>clearInterval(n)},[t,r]),!t)return null;let d={small:"w-1 h-1",medium:"w-1.5 h-1.5",large:"w-2 h-2"};return(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-accent-purple",title:"Processing...",children:[(0,n.jsxs)("span",{className:"inline-flex items-center ".concat({small:"gap-0.5",medium:"gap-1",large:"gap-1.5"}[a]),children:[(0,n.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"0ms",animationDuration:"800ms"}}),(0,n.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"150ms",animationDuration:"800ms"}}),(0,n.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"300ms",animationDuration:"800ms"}})]}),l&&(0,n.jsx)("span",{className:"text-xs font-medium text-accent-purple",children:"thinking"}),o&&i>0&&(0,n.jsx)("span",{className:"text-xs text-accent-purple/70",children:(e=>{let t=Math.floor(e/1e3);return t<60?"".concat(t,"s"):"".concat(Math.floor(t/60),"m ").concat(t%60,"s")})(i)})]})}function m(e){let{isProcessing:t}=e;return t?(0,n.jsx)("span",{className:"thinking-dot-inline",title:"Processing...",children:(0,n.jsx)("span",{className:"thinking-dot-pulse"})}):null}function h(e){let{agent:t,isSelected:r=!1,showBreadcrumb:s=!1,compact:o=!1,displayNameOverride:c,onClick:d,onMessageClick:x,onReleaseClick:h,onLogsClick:b}=e,j=(0,a.GW)(t.name),y=(0,a.hP)(t.name),v=c||l(t.name),w=a.yh[t.status]||a.yh.offline,N="online"===t.status,k=function(e,t){if(t)return"Processing - Agent is actively working";switch(e){case"online":return"Connected - Agent is online and ready";case"offline":return"Disconnected - Agent is not connected";case"busy":return"Busy - Agent is occupied with a task";case"processing":return"Processing - Agent is actively working";case"error":return"Error - Agent encountered an error";case"attention":return"Attention - Agent requires user input";default:return"Status: ".concat(e)}}(t.status,t.isProcessing),C=()=>{null==d||d(t)},S=e=>{e.stopPropagation(),null==h||h(t)},A=e=>{e.stopPropagation(),null==b||b(t)};return o?(0,n.jsxs)("div",{className:"\n group relative flex items-center gap-3 py-2.5 px-3 rounded-lg cursor-pointer\n transition-all duration-300 ease-out\n hover:bg-gradient-to-r hover:from-[rgba(255,255,255,0.03)] hover:to-transparent\n ".concat(r?"bg-gradient-to-r from-[rgba(255,255,255,0.06)] to-transparent":"","\n "),onClick:C,style:{borderLeft:r?"2px solid ".concat(j.primary):"2px solid transparent",boxShadow:r?"inset 4px 0 12px -4px ".concat(j.primary,"40"):"none"},children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("div",{className:"\n w-8 h-8 rounded-lg flex items-center justify-center font-bold text-[11px] tracking-wide\n transition-all duration-300 relative overflow-hidden\n ".concat(N?"shadow-lg":"opacity-60","\n "),style:{background:"linear-gradient(135deg, ".concat(j.primary,", ").concat(j.primary,"99)"),boxShadow:N?"0 2px 12px ".concat(j.primary,"50"):"none"},children:[(0,n.jsx)("div",{className:"absolute inset-0 opacity-30",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 50%)"}}),(0,n.jsx)("span",{className:"relative z-10",style:{color:j.text},children:y})]}),N&&(0,n.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-bg-primary",style:{backgroundColor:w,boxShadow:"0 0 8px ".concat(w)},title:k})]}),(0,n.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"\n text-[13px] font-semibold tracking-tight truncate transition-colors duration-200\n ".concat(N?"text-text-primary":"text-text-secondary","\n "),children:v}),!c&&(0,n.jsx)("span",{className:"text-[10px] text-text-muted truncate font-mono opacity-70",children:i(t.name)})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[t.isSpawned&&b&&(0,n.jsx)("button",{className:"relative bg-transparent border border-transparent text-text-dim p-1.5 cursor-pointer flex items-center justify-center rounded-md transition-all duration-200 opacity-0 group-hover:opacity-100 hover:bg-accent-cyan/10 hover:border-accent-cyan/30 hover:text-accent-cyan hover:shadow-[0_0_12px_rgba(0,217,255,0.25)]",onClick:A,title:"View logs",children:(0,n.jsx)(f,{})}),t.isSpawned&&h&&(0,n.jsx)("button",{className:"relative bg-transparent border border-transparent text-text-dim p-1.5 cursor-pointer flex items-center justify-center rounded-md transition-all duration-200 opacity-0 group-hover:opacity-100 hover:bg-error/10 hover:border-error/30 hover:text-error hover:shadow-[0_0_12px_rgba(255,68,68,0.25)]",onClick:S,title:"Kill agent",children:(0,n.jsx)(g,{})}),t.isProcessing?(0,n.jsx)("div",{title:k,children:(0,n.jsx)(m,{isProcessing:!0})}):(0,n.jsx)("div",{className:"\n w-2 h-2 rounded-full transition-all duration-300\n ".concat(N?"animate-pulse":"","\n "),style:{backgroundColor:w,boxShadow:N?"0 0 6px ".concat(w):"none"},title:k}),t.needsAttention&&(0,n.jsx)("div",{className:"w-2 h-2 rounded-full bg-warning animate-pulse shadow-[0_0_8px_rgba(255,107,53,0.5)]",title:"Needs Attention - Agent requires user input or has pending decisions"})]})]}):(0,n.jsxs)("div",{className:"\n rounded-lg p-3 cursor-pointer transition-all duration-200\n hover:shadow-md hover:-translate-y-px\n ".concat(r?"border-2 shadow-[0_0_0_2px_rgba(74,158,255,0.15)]":"border","\n "),onClick:C,style:{backgroundColor:j.light,borderColor:j.primary},children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center font-semibold text-sm relative",style:{backgroundColor:j.primary},children:[(0,n.jsx)("span",{style:{color:j.text},children:y}),(0,n.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-white",style:{backgroundColor:w},title:k})]}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:v}),t.needsAttention&&(0,n.jsx)("span",{className:"bg-red-500 text-white text-[10px] font-bold w-4 h-4 rounded-full flex items-center justify-center",title:"Needs Attention - Agent requires user input or has pending decisions",children:"!"})]}),s?(0,n.jsx)("span",{className:"text-xs text-text-muted truncate block",children:i(t.name)}):(0,n.jsx)("span",{className:"text-xs text-text-muted truncate block",children:t.name})]})]}),t.isProcessing&&(0,n.jsxs)("div",{className:"mt-2 p-2 bg-indigo-50 rounded flex items-center gap-2 border border-indigo-200",children:[(0,n.jsx)(u,{isProcessing:!0,processingStartedAt:t.processingStartedAt,size:"medium",showElapsed:!0}),(0,n.jsx)("span",{className:"text-xs text-indigo-500 font-medium",children:"Thinking..."})]}),t.currentTask&&!t.isProcessing&&(0,n.jsxs)("div",{className:"mt-2 p-2 bg-bg-hover rounded text-xs",children:[(0,n.jsx)("span",{className:"text-text-muted mr-1",children:"Working on:"}),(0,n.jsx)("span",{className:"text-text-primary",children:t.currentTask})]}),(0,n.jsxs)("div",{className:"mt-3 flex justify-between items-center",children:[(0,n.jsxs)("div",{className:"flex gap-2 text-xs text-text-muted",children:[t.cli&&(0,n.jsx)("span",{className:"bg-bg-hover py-0.5 px-1.5 rounded",children:t.cli}),void 0!==t.messageCount&&t.messageCount>0&&(0,n.jsxs)("span",{style:{color:j.primary},children:[t.messageCount," msgs"]}),t.isSpawned&&(0,n.jsx)("span",{className:"bg-accent-light text-accent text-[10px] py-0.5 px-1.5 rounded uppercase font-medium",children:"spawned"})]}),(0,n.jsxs)("div",{className:"flex gap-1.5",children:[t.isSpawned&&b&&(0,n.jsx)("button",{className:"relative bg-gradient-to-b from-[#1a2a3a] to-[#0f1a2a] text-accent-cyan border border-[#204060] rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 shadow-[inset_0_1px_0_rgba(0,217,255,0.1),0_2px_4px_rgba(0,0,0,0.3)] overflow-hidden hover:bg-gradient-to-b hover:from-[#204060] hover:to-[#1a3a50] hover:border-accent-cyan hover:shadow-[inset_0_1px_0_rgba(0,217,255,0.2),0_0_12px_rgba(0,217,255,0.4),0_2px_8px_rgba(0,0,0,0.4)] hover:scale-105 active:scale-[0.98]",onClick:A,title:"View logs",children:(0,n.jsx)(f,{})}),t.isSpawned&&h&&(0,n.jsx)("button",{className:"relative bg-gradient-to-b from-[#3a1a1a] to-[#2a0f0f] text-[#ff6b6b] border border-[#4a2020] rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 shadow-[inset_0_1px_0_rgba(255,107,107,0.1),0_2px_4px_rgba(0,0,0,0.3)] overflow-hidden hover:bg-gradient-to-b hover:from-[#4a2020] hover:to-[#3a1515] hover:border-[#ff4444] hover:text-[#ff4444] hover:shadow-[inset_0_1px_0_rgba(255,68,68,0.2),0_0_12px_rgba(255,68,68,0.4),0_2px_8px_rgba(0,0,0,0.4)] hover:scale-105 active:scale-[0.98]",onClick:S,title:"Release agent",children:(0,n.jsx)(g,{})}),x&&(0,n.jsx)("button",{className:"text-white border-none rounded py-1 px-2 cursor-pointer flex items-center justify-center transition-opacity duration-200 hover:opacity-90",style:{backgroundColor:j.primary},onClick:e=>{e.stopPropagation(),null==x||x(t)},title:"Send message",children:(0,n.jsx)(p,{})})]})]})]})}function p(){return(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function g(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",className:"release-icon",children:[(0,n.jsx)("path",{d:"M12 22c5.523 0 10-4.477 10-10a9.96 9.96 0 0 0-3-7.141",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M12 22C6.477 22 2 17.523 2 12a9.96 9.96 0 0 1 3-7.141",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,n.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function f(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function b(e){let{agents:t,selectedAgent:r,searchQuery:a="",onAgentSelect:l,onAgentMessage:i,onReleaseClick:d,onLogsClick:x,compact:u=!1,showGroupStats:m=!0}=e,[h,p]=(0,s.useState)(new Set),[g,f]=(0,s.useState)(!0),b=(0,s.useMemo)(()=>c(t,a),[t,a]),y=(0,s.useMemo)(()=>o(b),[b]);(0,s.useMemo)(()=>{0===h.size&&y.length>0&&p(new Set(y.map(e=>e.prefix)))},[y]);let N=e=>{p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};return 0===t.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,n.jsx)(v,{}),(0,n.jsx)("p",{children:"No agents connected"})]}):0===b.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,n.jsx)(w,{}),(0,n.jsxs)("p",{children:['No agents match "',a,'"']})]}):(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[y.length>1&&(0,n.jsxs)("div",{className:"flex justify-between items-center py-2 px-3 text-xs text-text-muted",children:[(0,n.jsxs)("span",{children:[b.length," agents"]}),(0,n.jsx)("button",{className:"bg-transparent border-none text-accent cursor-pointer text-xs hover:underline",onClick:()=>{g?p(new Set):p(new Set(y.map(e=>e.prefix))),f(!g)},children:g?"Collapse all":"Expand all"})]}),y.map(e=>(0,n.jsx)(j,{group:e,isExpanded:h.has(e.prefix),selectedAgent:r,compact:u,showStats:m,onToggle:()=>N(e.prefix),onAgentSelect:l,onAgentMessage:i,onReleaseClick:d,onLogsClick:x},e.prefix))]})}function j(e){let{group:t,isExpanded:r,selectedAgent:s,compact:o,showStats:i,onToggle:c,onAgentSelect:d,onAgentMessage:u,onReleaseClick:m,onLogsClick:p}=e,g=i?x(t.agents):null;if(1===t.agents.length&&t.agents[0].name.toLowerCase()===t.prefix.toLowerCase()){let e=t.agents[0];return(0,n.jsx)("div",{className:"mb-1 py-1 px-2",children:(0,n.jsx)(h,{agent:e,isSelected:e.name===s,compact:o,onClick:d,onMessageClick:u,onReleaseClick:m,onLogsClick:p},e.name)})}return(0,n.jsxs)("div",{className:"mb-1",children:[(0,n.jsxs)("button",{className:"flex items-center gap-2 w-full py-2 px-3 bg-transparent border-none cursor-pointer text-sm text-left rounded transition-colors duration-200 relative hover:bg-[var(--group-light)]",onClick:c,style:{"--group-color":t.color.primary,"--group-light":t.color.light},children:[(0,n.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{backgroundColor:t.color.primary}}),(0,n.jsx)(y,{expanded:r}),(0,n.jsx)("span",{className:"font-semibold text-text-primary",children:t.displayName}),(0,n.jsxs)("span",{className:"text-text-muted font-normal",children:["(",t.agents.length,")"]}),i&&g&&(0,n.jsxs)("div",{className:"ml-auto flex gap-2",children:[g.online>0&&(0,n.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted",title:"".concat(g.online," agent").concat(g.online>1?"s":""," online"),children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.yh.online}}),g.online]}),g.needsAttention>0&&(0,n.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted",title:"".concat(g.needsAttention," agent").concat(g.needsAttention>1?"s":""," need").concat(1===g.needsAttention?"s":""," attention"),children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.yh.attention}}),g.needsAttention]})]})]}),r&&(0,n.jsx)("div",{className:"py-1 pl-4 flex flex-col gap-1",children:t.agents.map(e=>(0,n.jsx)(h,{agent:e,isSelected:e.name===s,compact:o,displayNameOverride:l(e.name),onClick:d,onMessageClick:u,onReleaseClick:m,onLogsClick:p},e.name))})]})}function y(e){let{expanded:t}=e;return(0,n.jsx)("svg",{className:"text-text-muted transition-transform duration-200 ".concat(t?"rotate-90":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function v(){return(0,n.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,n.jsx)("circle",{cx:"12",cy:"8",r:"5"}),(0,n.jsx)("path",{d:"M20 21a8 8 0 1 0-16 0"})]})}function w(){return(0,n.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function N(e){return e.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}function k(e){let{projects:t,localAgents:r=[],bridgeAgents:a=[],currentProject:o,selectedAgent:l,searchQuery:i="",onProjectSelect:c,onAgentSelect:d,onReleaseClick:x,onLogsClick:u,compact:m=!1}=e,[h,p]=(0,s.useState)(()=>new Set(t.map(e=>e.id))),g=(0,s.useMemo)(()=>{let e=i.toLowerCase().trim();if(!e)return{projects:t,localAgents:r,bridgeAgents:a};let n=r.filter(t=>{var r;return t.name.toLowerCase().includes(e)||(null===(r=t.currentTask)||void 0===r?void 0:r.toLowerCase().includes(e))}),s=a.filter(t=>{var r;return t.name.toLowerCase().includes(e)||(null===(r=t.currentTask)||void 0===r?void 0:r.toLowerCase().includes(e))});return{projects:t.map(t=>{var r;let n=(null===(r=t.name)||void 0===r?void 0:r.toLowerCase().includes(e))||t.path.toLowerCase().includes(e),s=t.agents.filter(t=>{var r;return t.name.toLowerCase().includes(e)||(null===(r=t.currentTask)||void 0===r?void 0:r.toLowerCase().includes(e))});return n||s.length>0?{...t,agents:n?t.agents:s}:null}).filter(Boolean),localAgents:n,bridgeAgents:s}},[t,r,a,i]),f=e=>{p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},b=g.localAgents.length+g.projects.reduce((e,t)=>e+t.agents.length,0);if(0===b&&0===t.length&&0===r.length)return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-[#888] text-center",children:[(0,n.jsx)(D,{}),(0,n.jsx)("p",{children:"No projects or agents"})]});if(0===b&&i)return(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-[#888] text-center",children:[(0,n.jsx)(M,{}),(0,n.jsxs)("p",{children:['No results for "',i,'"']})]});let j=g.projects.length>1;return(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[j&&g.bridgeAgents.length>0&&(0,n.jsx)(S,{agents:g.bridgeAgents,selectedAgent:l,compact:m,onAgentSelect:e=>null==d?void 0:d(e),onReleaseClick:x,onLogsClick:u}),!j&&g.localAgents.length>0&&(0,n.jsx)(C,{project:{id:"__local__",path:"",name:"Local",agents:g.localAgents},isExpanded:h.has("__local__"),isCurrentProject:!0,selectedAgent:l,compact:m,onToggle:()=>f("__local__"),onAgentSelect:e=>null==d?void 0:d(e),onReleaseClick:x,onLogsClick:u}),g.projects.map(e=>(0,n.jsx)(C,{project:e,isExpanded:h.has(e.id),isCurrentProject:e.id===o,selectedAgent:l,compact:m,isBridgeMode:j,onToggle:()=>f(e.id),onProjectSelect:()=>null==c?void 0:c(e),onAgentSelect:t=>null==d?void 0:d(t,e),onReleaseClick:x,onLogsClick:u},e.id))]})}function C(e){var t;let{project:r,isExpanded:o,isCurrentProject:l,selectedAgent:i,compact:c,isBridgeMode:d=!1,onToggle:x,onProjectSelect:u,onAgentSelect:m,onReleaseClick:p,onLogsClick:g}=e,[f,b]=(0,s.useState)(new Set),j=(0,s.useMemo)(()=>{let e=0,t=0;for(let n of r.agents)"online"===n.status&&e++,n.needsAttention&&t++;return{online:e,needsAttention:t,total:r.agents.length}},[r.agents]),{teams:y,ungroupedAgents:v}=(0,s.useMemo)(()=>{let e=new Map,t=[];for(let n of r.agents)if(n.team){let t=e.get(n.team)||[];t.push(n),e.set(n.team,t)}else t.push(n);return{teams:Array.from(e.entries()).map(e=>{let[t,r]=e;return{name:t,agents:r}}).sort((e,t)=>e.name.localeCompare(t.name)),ungroupedAgents:t}},[r.agents]),w=e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};(0,s.useEffect)(()=>{o&&0===f.size&&y.length>0&&b(new Set(y.map(e=>e.name)))},[o,y,f]);let k=(0,a.GW)(r.name||r.id),C=r.name||r.path.split("/").pop()||r.id;return(0,n.jsxs)("div",{className:"mb-1",children:[(0,n.jsxs)("button",{className:"group flex items-center gap-2 w-full py-2.5 px-3 bg-none border-none cursor-pointer text-[13px] text-left rounded-md transition-colors duration-200 relative text-[#e8e8e8] hover:bg-[var(--project-light)] ".concat(l?"bg-[rgba(0,255,200,0.08)]":""),onClick:x,onDoubleClick:u,style:{"--project-color":k.primary,"--project-light":k.light},children:[(0,n.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{background:k.primary}}),(0,n.jsx)(L,{expanded:o}),(0,n.jsx)(W,{color:k.primary}),(0,n.jsx)("span",{className:"font-semibold text-[#e8e8e8] whitespace-nowrap overflow-hidden text-ellipsis",children:C}),(0,n.jsxs)("span",{className:"text-[#888] font-normal flex-shrink-0",children:["(",j.total,")"]}),(0,n.jsxs)("div",{className:"ml-auto flex gap-2 flex-shrink-0",children:[j.online>0&&(0,n.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-[#666]",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.yh.online}}),j.online]}),j.needsAttention>0&&(0,n.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-[#666]",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.yh.attention}}),j.needsAttention]})]}),(null===(t=r.lead)||void 0===t?void 0:t.connected)&&(0,n.jsx)("span",{className:"text-[#ffd700] text-xs ml-1",title:"Lead: ".concat(r.lead.name),children:"★"}),d&&!l&&u&&(0,n.jsx)("button",{className:"ml-2 py-1 px-2 text-[10px] font-medium bg-accent-cyan/20 text-accent-cyan rounded border-none cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity hover:bg-accent-cyan/30",onClick:e=>{e.stopPropagation(),u()},title:"Switch to this project",children:"Switch"})]}),o&&(0,n.jsxs)("div",{className:"py-1 pl-5 flex flex-col gap-1",children:[y.map(e=>(0,n.jsxs)("div",{className:"mb-0.5",children:[(0,n.jsxs)("button",{className:"flex items-center gap-1.5 w-full py-1.5 px-2 bg-none border-none cursor-pointer text-xs text-left rounded transition-colors duration-200 text-[#b8b8b8] hover:bg-white/5",onClick:()=>w(e.name),children:[(0,n.jsx)(L,{expanded:f.has(e.name)}),(0,n.jsx)(E,{}),(0,n.jsx)("span",{className:"font-medium text-[#b8b8b8]",children:e.name}),(0,n.jsxs)("span",{className:"text-[#666] font-normal",children:["(",e.agents.length,")"]})]}),f.has(e.name)&&(0,n.jsx)("div",{className:"py-0.5 pl-4 flex flex-col gap-1",children:e.agents.map(t=>(0,n.jsx)(h,{agent:t,isSelected:t.name===i,compact:c,displayNameOverride:function(e,t){let r=e.toLowerCase(),n=t.toLowerCase().replace(/-?team$/i,"");if(n&&r.startsWith(n+"-")||n&&r.startsWith(n+"_"))return N(e.substring(n.length+1));let s=e.split("-");return s.length>1?N(s[s.length-1]):N(e)}(t.name,e.name),onClick:m,onReleaseClick:p,onLogsClick:g},t.name))})]},e.name)),v.map(e=>(0,n.jsx)(h,{agent:e,isSelected:e.name===i,compact:c,onClick:m,onReleaseClick:p,onLogsClick:g},e.name))]})]})}function S(e){let{agents:t,selectedAgent:r,compact:a,onAgentSelect:o,onReleaseClick:l,onLogsClick:i}=e,[c,d]=(0,s.useState)(!0);return(0,n.jsxs)("div",{className:"mb-2",children:[(0,n.jsxs)("button",{className:"flex items-center gap-2 w-full py-2.5 px-3 bg-none border-none cursor-pointer text-[13px] text-left rounded-md transition-colors duration-200 relative text-[#e8e8e8] hover:bg-[rgba(168,85,247,0.1)]",onClick:()=>d(!c),children:[(0,n.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{background:"#a855f7"}}),(0,n.jsx)(L,{expanded:c}),(0,n.jsx)(A,{}),(0,n.jsx)("span",{className:"font-semibold text-[#e8e8e8]",children:"Bridge"}),(0,n.jsxs)("span",{className:"text-[#888] font-normal flex-shrink-0",children:["(",t.length,")"]})]}),c&&(0,n.jsx)("div",{className:"py-1 pl-5 flex flex-col gap-1",children:t.map(e=>(0,n.jsx)(h,{agent:e,isSelected:e.name===r,compact:a,onClick:o,onReleaseClick:l,onLogsClick:i},e.name))})]})}function A(){return(0,n.jsxs)("svg",{className:"flex-shrink-0 text-[#a855f7]",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,n.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,n.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,n.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,n.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,n.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function L(e){let{expanded:t}=e;return(0,n.jsx)("svg",{className:"transition-transform duration-200 text-[#888] flex-shrink-0 ".concat(t?"rotate-90":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function W(e){let{color:t}=e;return(0,n.jsx)("svg",{className:"flex-shrink-0",style:{color:t},width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function E(){return(0,n.jsxs)("svg",{className:"text-[#888] flex-shrink-0",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,n.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,n.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,n.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function D(){return(0,n.jsx)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:(0,n.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function M(){return(0,n.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function _(e){let{threads:t,currentThread:r,onThreadSelect:s,totalUnreadCount:a=0,isCollapsed:o=!1,onToggleCollapse:l}=e;return 0===t.length?null:(0,n.jsxs)("div",{className:"px-2 py-2",children:[(0,n.jsxs)("button",{className:"w-full flex items-center justify-between px-2 py-2 mb-1.5 bg-transparent border-none cursor-pointer rounded-lg transition-all duration-200 hover:bg-gradient-to-r hover:from-[rgba(255,255,255,0.03)] hover:to-transparent",onClick:l,"aria-expanded":!o,"aria-label":o?"Expand threads":"Collapse threads",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(R,{isCollapsed:o}),(0,n.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Threads"}),(0,n.jsxs)("span",{className:"text-xs text-text-dim font-mono",children:["(",t.length,")"]})]}),a>0&&(0,n.jsx)("span",{className:"min-w-[18px] h-[18px] flex items-center justify-center text-[10px] font-bold bg-accent-cyan text-bg-deep rounded-full px-1.5",style:{boxShadow:"0 0 8px rgba(0, 217, 255, 0.5)"},children:a>99?"99+":a})]}),!o&&(0,n.jsx)("div",{className:"space-y-1",children:t.map(e=>(0,n.jsx)(B,{thread:e,isSelected:r===e.id,onClick:()=>s(e.id)},e.id))})]})}function B(e){let{thread:t,isSelected:r,onClick:s}=e,a=t.unreadCount>0,o=function(e){let t=new Date(e),r=new Date().getTime()-t.getTime(),n=Math.floor(r/6e4),s=Math.floor(r/36e5),a=Math.floor(r/864e5);return n<1?"now":n<60?"".concat(n,"m"):s<24?"".concat(s,"h"):a<7?"".concat(a,"d"):t.toLocaleDateString([],{month:"short",day:"numeric"})}(t.lastMessage.timestamp);return(0,n.jsxs)("button",{className:"\n group w-full flex items-center gap-3 px-2.5 py-2.5 rounded-lg text-left transition-all duration-200 cursor-pointer border-none\n hover:bg-gradient-to-r hover:from-[rgba(255,255,255,0.03)] hover:to-transparent\n ".concat(r?"bg-gradient-to-r from-[rgba(255,255,255,0.06)] to-transparent":"bg-transparent","\n "),onClick:s,style:{borderLeft:r?"2px solid #00d9ff":"2px solid transparent",boxShadow:r?"inset 4px 0 12px -4px rgba(0, 217, 255, 0.25)":"none"},children:[(0,n.jsxs)("div",{className:"\n relative shrink-0 w-8 h-8 rounded-lg flex items-center justify-center overflow-hidden transition-all duration-200\n ".concat(a?"text-accent-cyan":"text-text-muted","\n "),style:{background:a?"linear-gradient(135deg, rgba(0, 217, 255, 0.2), rgba(0, 217, 255, 0.1))":"rgba(255, 255, 255, 0.03)",boxShadow:a?"0 0 8px rgba(0, 217, 255, 0.2)":"none"},children:[(0,n.jsx)("div",{className:"absolute inset-0 opacity-20",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%)"}}),(0,n.jsx)(T,{})]}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"\n text-[13px] truncate transition-colors duration-200\n ".concat(a?"font-semibold text-text-primary":"text-text-secondary group-hover:text-text-primary","\n "),children:t.name}),a&&(0,n.jsx)("span",{className:"shrink-0 min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-bold bg-accent-cyan text-bg-deep rounded-full px-1",style:{boxShadow:"0 0 6px rgba(0, 217, 255, 0.4)"},children:t.unreadCount>99?"99+":t.unreadCount})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-text-muted font-mono",children:[(0,n.jsx)("span",{className:"truncate",children:t.participants.slice(0,2).join(", ")}),t.participants.length>2&&(0,n.jsxs)("span",{className:"text-text-dim",children:["+",t.participants.length-2]}),(0,n.jsx)("span",{className:"text-text-dim opacity-50",children:"\xb7"}),(0,n.jsx)("span",{className:"text-text-dim",children:o})]})]})]})}function T(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function R(e){let{isCollapsed:t}=e;return(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-text-muted transition-transform duration-200 ".concat(t?"":"rotate-90"),children:(0,n.jsx)("polyline",{points:"9 18 15 12 9 6"})})}var P=r(6272);let F="agent-relay-threads-collapsed";function U(e){let{agents:t,bridgeAgents:r=[],projects:a=[],currentProject:o,selectedAgent:l,viewMode:i,isFleetAvailable:c,isConnected:d,isOpen:x=!1,activeThreads:u=[],currentThread:m,totalUnreadThreadCount:h=0,onAgentSelect:p,onProjectSelect:g,onViewModeChange:f,onSpawnClick:j,onReleaseClick:y,onLogsClick:v,onThreadSelect:w,onClose:N}=e,[C,S]=(0,s.useState)(""),[A,L]=(0,s.useState)(()=>{try{let e=localStorage.getItem(F);return"true"===e}catch(e){return!1}});(0,s.useEffect)(()=>{try{localStorage.setItem(F,String(A))}catch(e){}},[A]);let W=a.length>0;return(0,n.jsxs)("aside",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"p-4 border-b border-border-subtle",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,n.jsx)(P.K7,{size:28,withGlow:!0}),(0,n.jsx)("h1",{className:"text-lg font-display font-semibold m-0 text-text-primary",children:"Agent Relay"}),(0,n.jsx)(O,{isConnected:d}),(0,n.jsx)("button",{className:"md:hidden ml-auto p-2 -mr-2 bg-transparent border-none text-text-muted cursor-pointer rounded-lg transition-colors hover:bg-bg-hover hover:text-text-primary",onClick:N,"aria-label":"Close sidebar",children:(0,n.jsx)(V,{})})]}),c&&(0,n.jsxs)("div",{className:"flex bg-bg-tertiary rounded-lg p-1",children:[(0,n.jsx)("button",{className:"\n flex-1 py-2 px-4 bg-transparent border-none text-xs font-medium cursor-pointer rounded-md transition-all duration-150\n ".concat("local"===i?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>null==f?void 0:f("local"),children:"Local"}),(0,n.jsx)("button",{className:"\n flex-1 py-2 px-4 bg-transparent border-none text-xs font-medium cursor-pointer rounded-md transition-all duration-150\n ".concat("fleet"===i?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>null==f?void 0:f("fleet"),children:"Fleet"})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 py-2.5 px-3 bg-bg-tertiary m-3 rounded-lg border border-border-subtle focus-within:border-accent-cyan/50 transition-colors",children:[(0,n.jsx)(z,{}),(0,n.jsx)("input",{type:"text",placeholder:"Search agents...",value:C,onChange:e=>S(e.target.value),className:"flex-1 bg-transparent border-none text-text-primary text-sm outline-none placeholder:text-text-muted"}),C&&(0,n.jsx)("button",{className:"bg-transparent border-none text-text-muted cursor-pointer p-1 flex items-center justify-center hover:text-text-secondary rounded transition-colors",onClick:()=>S(""),children:(0,n.jsx)(H,{})})]}),u.length>0&&(0,n.jsx)("div",{className:"border-b border-border-subtle",children:(0,n.jsx)(_,{threads:u,currentThread:m,onThreadSelect:e=>null==w?void 0:w(e),totalUnreadCount:h,isCollapsed:A,onToggleCollapse:()=>L(!A)})}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto px-2",children:W?(0,n.jsx)(k,{projects:a,localAgents:t,bridgeAgents:r,currentProject:o,selectedAgent:l,searchQuery:C,onProjectSelect:g,onAgentSelect:p,onReleaseClick:y,onLogsClick:v,compact:!0}):(0,n.jsx)(b,{agents:t,selectedAgent:l,searchQuery:C,onAgentSelect:e=>null==p?void 0:p(e),onReleaseClick:y,onLogsClick:v,compact:!0,showGroupStats:!0})}),(0,n.jsx)("div",{className:"p-4 border-t border-border-subtle",children:(0,n.jsxs)("button",{className:"w-full py-3 px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold text-sm cursor-pointer flex items-center justify-center gap-2 rounded-lg transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:j,children:[(0,n.jsx)(I,{}),"Spawn Agent"]})})]})}function O(e){let{isConnected:t}=e;return(0,n.jsxs)("div",{className:"flex items-center gap-1.5 ml-auto",children:[(0,n.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(t?"bg-success animate-pulse-glow":"bg-text-dim")}),(0,n.jsx)("span",{className:"text-xs text-text-muted",children:t?"Live":"Offline"})]})}function z(){return(0,n.jsxs)("svg",{className:"text-text-muted",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function H(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function I(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function V(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function G(e){var t;let{currentChannel:r,selectedAgent:s,projects:o=[],currentProject:l,onCommandPaletteOpen:c,onSettingsClick:d,onHistoryClick:x,onNewConversationClick:u,onCoordinatorClick:m,onMenuClick:h,hasUnreadNotifications:p}=e,g="general"===r,f=s?(0,a.GW)(s.name):null,b=o.length>1,j=(null==l?void 0:l.name)||(null==l?void 0:null===(t=l.path)||void 0===t?void 0:t.split("/").pop());return(0,n.jsxs)("header",{className:"h-[52px] bg-bg-secondary border-b border-border-subtle flex items-center justify-between px-4",children:[(0,n.jsxs)("button",{className:"hidden max-md:flex items-center justify-center w-11 h-11 bg-transparent border-none text-text-primary cursor-pointer rounded-lg transition-colors hover:bg-bg-hover relative",onClick:h,"aria-label":"Open menu",children:[(0,n.jsx)(X,{}),p&&(0,n.jsx)("span",{className:"absolute top-1.5 right-1.5 w-2.5 h-2.5 bg-error rounded-full animate-pulse shadow-[0_0_8px_rgba(239,68,68,0.6)]"})]}),(0,n.jsx)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:g?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-accent-cyan text-lg font-mono",children:"#"}),(0,n.jsx)("span",{className:"font-display font-semibold text-base text-text-primary max-md:max-w-[150px] max-md:truncate",children:"general"}),(0,n.jsx)("span",{className:"text-text-muted text-sm ml-2 pl-3 border-l border-border-subtle max-md:hidden",children:"All agent communications"})]}):s?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center font-semibold text-xs border-2",style:{backgroundColor:null==f?void 0:f.primary,borderColor:null==f?void 0:f.primary,boxShadow:"0 0 12px ".concat(null==f?void 0:f.primary,"40")},children:(0,n.jsx)("span",{style:{color:null==f?void 0:f.text},children:(0,a.hP)(s.name)})}),(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("span",{className:"font-display font-semibold text-base text-text-primary max-md:max-w-[150px] max-md:truncate",children:s.name}),(0,n.jsx)("span",{className:"text-text-muted text-xs font-mono max-md:hidden",children:i(s.name)})]}),s.status&&(0,n.jsx)("span",{className:"text-xs py-1 px-2.5 rounded-full font-medium ml-2 ".concat("online"===s.status?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"),children:s.status})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-accent-cyan text-lg font-mono",children:"@"}),(0,n.jsx)("span",{className:"font-display font-semibold text-base text-text-primary",children:r})]})}),b&&(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-bg-tertiary/80 border border-border-subtle rounded-lg max-md:hidden",children:[(0,n.jsx)(Y,{}),(0,n.jsxs)("span",{className:"text-xs text-text-secondary",children:[(0,n.jsx)("span",{className:"text-accent-cyan font-semibold",children:o.length})," projects"]}),j&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-border-subtle",children:"•"}),(0,n.jsx)("span",{className:"text-xs text-text-primary font-medium truncate max-w-[120px]",children:j})]})]}),!b&&j&&(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-bg-tertiary/50 rounded-lg max-md:hidden",children:[(0,n.jsx)(Q,{}),(0,n.jsx)("span",{className:"text-xs text-text-primary font-medium truncate max-w-[150px]",children:j})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("button",{className:"flex items-center gap-2 py-2 px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-lg text-sm cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:u,title:"Start new conversation (⌘N)",children:[(0,n.jsx)(K,{}),(0,n.jsx)("span",{className:"max-md:hidden",children:"New Message"})]}),(0,n.jsxs)("button",{className:"flex items-center gap-2 py-2 px-3 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary text-sm cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-text-primary",onClick:c,title:"Command Palette (⌘K)",children:[(0,n.jsx)($,{}),(0,n.jsx)("span",{className:"max-md:hidden",children:"Search"}),(0,n.jsx)("kbd",{className:"bg-bg-card border border-border-subtle rounded px-1.5 py-0.5 text-xs text-text-muted font-mono max-md:hidden",children:"⌘K"})]}),(0,n.jsx)("button",{className:"flex items-center justify-center p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan",onClick:x,title:"Message History",children:(0,n.jsx)(q,{})}),b&&(0,n.jsx)("button",{className:"flex items-center justify-center p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-purple",onClick:m,title:"Coordinator Agent",children:(0,n.jsx)(ee,{})}),(0,n.jsx)("a",{href:"/metrics",className:"flex items-center justify-center p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-orange no-underline",title:"Fleet Metrics",children:(0,n.jsx)(J,{})}),(0,n.jsx)("button",{className:"flex items-center justify-center p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-purple",onClick:d,title:"Settings",children:(0,n.jsx)(Z,{})})]})]})}function K(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,n.jsx)("path",{d:"M12 20h9"}),(0,n.jsx)("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}function $(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function q(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function J(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M3 3v18h18"}),(0,n.jsx)("path",{d:"M18 17V9"}),(0,n.jsx)("path",{d:"M13 17V5"}),(0,n.jsx)("path",{d:"M8 17v-3"})]})}function Z(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function X(){return(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,n.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,n.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}function Y(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-cyan",children:[(0,n.jsx)("circle",{cx:"5",cy:"12",r:"3"}),(0,n.jsx)("circle",{cx:"19",cy:"12",r:"3"}),(0,n.jsx)("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),(0,n.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"12",cy:"19",r:"2"}),(0,n.jsx)("line",{x1:"12",y1:"7",x2:"12",y2:"10"}),(0,n.jsx)("line",{x1:"12",y1:"14",x2:"12",y2:"17"})]})}function Q(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-muted",children:(0,n.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function ee(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,n.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,n.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,n.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,n.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,n.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}var et=r(2500),er=r(9880);function en(e){let{status:t,size:r="small"}=e;if(!t)return null;let s={small:"w-3.5 h-3.5",medium:"w-4 h-4"}[r];return"sending"===t||"unread"===t?(0,n.jsx)("span",{className:"inline-flex items-center justify-center ".concat(s," text-text-muted"),title:"Sending...",children:(0,n.jsx)(es,{className:s})}):"acked"===t||"read"===t?(0,n.jsx)("span",{className:"inline-flex items-center justify-center ".concat(s," text-success"),title:"Delivered",children:(0,n.jsx)(ea,{className:s})}):null}function es(e){let{className:t}=e;return(0,n.jsxs)("svg",{className:"animate-pulse ".concat(t),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,n.jsx)("path",{d:"M8 5v3l2 1",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ea(e){let{className:t}=e;return(0,n.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M3 8l3 3 7-7",strokeLinecap:"round",strokeLinejoin:"round"})})}let eo={claude:{icon:"◈",color:"#00d9ff"},codex:{icon:"⬡",color:"#ff6b35"},gemini:{icon:"◇",color:"#a855f7"},openai:{icon:"◆",color:"#10a37f"},default:{icon:"●",color:"#00d9ff"}};function el(e){let{messages:t,currentChannel:r,onThreadClick:a,highlightedMessageId:o,agents:l=[],currentUser:i}=e,c=new Map;for(let e of l)e.isProcessing&&c.set(e.name,{isProcessing:!0,processingStartedAt:e.processingStartedAt});let d=(0,s.useRef)(null),[x,u]=(0,s.useState)(!0),m=(0,s.useRef)(0),h=(0,s.useRef)(r),p=(0,s.useRef)(!1),g=(0,s.useRef)(!1),f=t.filter(e=>"general"===r?"*"===e.to||e.isBroadcast||"general"===e.channel:e.from===r||e.to===r),b=f.length;if(b>m.current){let e=f[f.length-1],t=(null==e?void 0:e.from)==="Dashboard"||i&&(null==e?void 0:e.from)===i.displayName;(t||x)&&(p.current=!0,t&&!x&&u(!0))}m.current=b;let j=(0,s.useCallback)(()=>{if(!d.current||g.current)return;let e=d.current,t=e.scrollHeight-e.scrollTop-e.clientHeight;t<50&&!x?u(!0):t>150&&x&&u(!1)},[x]);return((0,s.useLayoutEffect)(()=>{if(p.current&&d.current){p.current=!1,g.current=!0;let e=d.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{g.current=!1},50)})}},[f.length]),(0,s.useLayoutEffect)(()=>{if(r!==h.current&&(h.current=r,m.current=f.length,u(!0),d.current)){g.current=!0;let e=d.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{g.current=!1},50)})}},[r,f.length]),0===f.length)?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center",children:[(0,n.jsx)(eh,{}),(0,n.jsx)("h3",{className:"m-0 mb-2 text-base font-display text-text-secondary",children:"No messages yet"}),(0,n.jsx)("p",{className:"m-0 text-sm",children:"general"===r?"Broadcast messages will appear here":"Messages with ".concat(r," will appear here")})]}):(0,n.jsx)("div",{className:"flex flex-col gap-1 p-4 bg-bg-secondary h-full overflow-y-auto",ref:d,onScroll:j,children:f.map(e=>{let t=("Dashboard"===e.from||i&&e.from===i.displayName)&&"*"!==e.to?c.get(e.to):void 0;return(0,n.jsx)(ei,{message:e,isHighlighted:e.id===o,onThreadClick:a,recipientProcessing:t,currentUser:i},e.id)})})}function ei(e){let{message:t,isHighlighted:r,onThreadClick:a,recipientProcessing:o,currentUser:l}=e,i=function(e){let t=new Date(e),r=new Date;if(t.toDateString()===r.toDateString())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});let n=new Date(r);return(n.setDate(n.getDate()-1),t.toDateString()===n.toDateString())?"Yesterday ".concat(t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(t.timestamp),c="Dashboard"===t.from||l&&t.from===l.displayName,d=c&&l?{icon:"",color:"#a855f7"}:function(e){let t=e.toLowerCase();if(t.includes("claude")||t.includes("anthropic"))return eo.claude;if(t.includes("codex")||t.includes("openai")||t.includes("gpt"))return eo.codex;if(t.includes("gemini")||t.includes("google")||t.includes("bard"))return eo.gemini;let r=e.split("").reduce((e,t)=>e+t.charCodeAt(0),0),n=Object.keys(eo).filter(e=>"default"!==e);return eo[n[r%n.length]]}(t.from),x=c&&l?l.displayName:t.from,m=t.replyCount&&t.replyCount>0,h=c&&("acked"===t.status||"read"===t.status)&&(null==o?void 0:o.isProcessing);return(0,n.jsxs)("div",{className:"\n group flex gap-3 py-3 px-4 rounded-xl transition-all duration-150\n hover:bg-bg-card/50\n ".concat(r?"bg-warning-light/20 border-l-2 border-l-warning pl-3":"","\n "),children:[c&&(null==l?void 0:l.avatarUrl)?(0,n.jsx)("img",{src:l.avatarUrl,alt:x,className:"shrink-0 w-10 h-10 rounded-xl border-2 object-cover",style:{borderColor:d.color,boxShadow:"0 0 16px ".concat(d.color,"30")}}):(0,n.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-xl flex items-center justify-center text-lg font-medium border-2",style:{backgroundColor:"".concat(d.color,"15"),borderColor:d.color,color:d.color,boxShadow:"0 0 16px ".concat(d.color,"30")},children:d.icon}),(0,n.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[(0,n.jsx)("span",{className:"font-display font-semibold text-sm",style:{color:d.color},children:x}),"*"!==t.to&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-text-dim text-xs",children:"→"}),(0,n.jsx)("span",{className:"font-medium text-sm text-accent-cyan",children:t.to})]}),t.thread&&(0,n.jsx)("span",{className:"text-xs py-0.5 px-2 rounded-full font-mono font-medium bg-accent-purple/20 text-accent-purple",children:t.thread}),"*"===t.to&&(0,n.jsx)("span",{className:"text-xs py-0.5 px-2 rounded-full uppercase font-medium bg-warning/20 text-warning",children:"broadcast"}),(0,n.jsx)("span",{className:"text-text-dim text-xs ml-auto font-mono",children:i}),c&&(0,n.jsx)(en,{status:t.status,size:"small"}),h&&(0,n.jsx)(u,{isProcessing:!0,processingStartedAt:null==o?void 0:o.processingStartedAt,size:"small",showLabel:!0}),(0,n.jsxs)("button",{className:"\n inline-flex items-center gap-1.5 p-1.5 rounded-lg transition-all duration-150 cursor-pointer border-none\n ".concat(m||t.thread?"text-accent-cyan bg-accent-cyan/10 hover:bg-accent-cyan/20":"text-text-muted bg-transparent opacity-0 group-hover:opacity-100 hover:text-accent-cyan hover:bg-accent-cyan/10","\n "),onClick:()=>null==a?void 0:a(t.thread||t.id),title:t.thread?"View thread: ".concat(t.thread):m?"".concat(t.replyCount," ").concat(1===t.replyCount?"reply":"replies"):"Reply in thread",children:[(0,n.jsx)(ep,{}),m&&(0,n.jsx)("span",{className:"text-xs font-medium",children:t.replyCount})]})]}),(0,n.jsx)("div",{className:"text-sm leading-relaxed text-text-primary whitespace-pre-wrap break-words",children:function(e){let t=e.replace(/\\n/g,"\n").replace(/\r\n/g,"\n").replace(/\r/g,"\n"),r=function(e){let t;let r=[],n=/```(\w*)\n([\s\S]*?)```/g,s=0;for(;null!==(t=n.exec(e));){if(t.index>s){let n=eu(e.slice(s,t.index));r.push(...n)}r.push({type:"code",language:t[1]||"text",content:t[2]}),s=t.index+t[0].length}if(s<e.length){let t=eu(e.slice(s));r.push(...t)}return 0===r.length?eu(e):r}(t);return 1===r.length&&"text"===r[0].type?t.split("\n").map((e,t)=>(0,n.jsxs)(s.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),em(e)]},t)):r.map((e,t)=>{if("code"===e.type)return(0,n.jsx)(ex,{code:e.content,language:e.language||"text"},t);if("table"===e.type)return(0,n.jsx)("pre",{className:"font-mono text-xs leading-relaxed whitespace-pre overflow-x-auto my-2 p-3 bg-bg-tertiary/50 rounded-lg border border-border-subtle",children:e.content},t);let r=e.content.split("\n");return(0,n.jsx)("span",{children:r.map((e,t)=>(0,n.jsxs)(s.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),em(e)]},t))},t)})}(t.content)}),t.attachments&&t.attachments.length>0&&(0,n.jsx)(ec,{attachments:t.attachments})]})]})}function ec(e){let{attachments:t}=e,[r,a]=(0,s.useState)(null),o=t.filter(e=>e.mimeType.startsWith("image/"));return 0===o.length?null:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>a(e),className:"relative group cursor-pointer bg-transparent border-0 p-0",title:"View ".concat(e.filename),children:[(0,n.jsx)("img",{src:e.data||e.url,alt:e.filename,className:"max-h-48 max-w-xs rounded-lg border border-border-subtle object-cover transition-all duration-150 group-hover:border-accent-cyan/50 group-hover:shadow-[0_0_8px_rgba(0,217,255,0.2)]",loading:"lazy"}),(0,n.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 rounded-lg transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",children:(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",className:"drop-shadow-lg",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,n.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,n.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]},e.id))}),r&&(0,n.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>a(null),children:(0,n.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,n.jsx)("img",{src:r.data||r.url,alt:r.filename,className:"max-w-full max-h-[90vh] rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()}),(0,n.jsx)("button",{type:"button",onClick:()=>a(null),className:"absolute -top-3 -right-3 w-8 h-8 bg-bg-tertiary border border-border-subtle rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-card transition-colors shadow-lg",title:"Close",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,n.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-3 bg-gradient-to-t from-black/60 to-transparent rounded-b-lg",children:(0,n.jsx)("p",{className:"text-white text-sm truncate",children:r.filename})})]})})]})}let ed={...er.Z,'pre[class*="language-"]':{...er.Z['pre[class*="language-"]'],background:"rgba(15, 23, 42, 0.8)",margin:"0.5rem 0",padding:"1rem",borderRadius:"0.5rem",border:"1px solid rgba(148, 163, 184, 0.1)",fontSize:"0.75rem",lineHeight:"1.5"},'code[class*="language-"]':{...er.Z['code[class*="language-"]'],background:"transparent",fontSize:"0.75rem"}};function ex(e){let{code:t,language:r}=e,[a,o]=(0,s.useState)(!1),l=(0,s.useCallback)(async()=>{try{await navigator.clipboard.writeText(t),o(!0),setTimeout(()=>o(!1),2e3)}catch(e){console.error("Failed to copy:",e)}},[t]),i=r.toLowerCase().replace(/^(js|jsx)$/,"javascript").replace(/^(ts|tsx)$/,"typescript").replace(/^(py)$/,"python").replace(/^(rb)$/,"ruby").replace(/^(sh|shell|zsh)$/,"bash");return(0,n.jsxs)("div",{className:"relative group my-2",children:[(0,n.jsxs)("div",{className:"absolute top-2 right-2 flex items-center gap-2 z-10",children:[r&&"text"!==r&&(0,n.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-cyan/20 text-accent-cyan font-mono",children:r}),(0,n.jsx)("button",{onClick:l,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-1 rounded bg-bg-tertiary hover:bg-bg-card text-text-muted hover:text-text-primary border border-border-subtle",title:"Copy code",children:a?"✓ Copied":"Copy"})]}),(0,n.jsx)(et.Z,{language:i,style:ed,customStyle:{margin:0,background:"rgba(15, 23, 42, 0.8)"},showLineNumbers:t.split("\n").length>3,lineNumberStyle:{minWidth:"2.5em",paddingRight:"1em",color:"rgba(148, 163, 184, 0.4)",userSelect:"none"},children:t.trim()})]})}function eu(e){let t=e.split("\n"),r=[],n=null;for(let e of t){let t=(e.match(/\|/g)||[]).length>=2||e.trim().startsWith("|")&&e.trim().endsWith("|")||/^[\s|:-]+$/.test(e)&&e.includes("-")&&e.includes("|")?"table":"text";n&&n.type===t?n.content+="\n"+e:(n&&r.push(n),n={type:t,content:e})}return n&&r.push(n),r}function em(e){let t=/(https?:\/\/[^\s]+)/g;return e.split(t).map((e,r)=>t.test(e)?(0,n.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan no-underline hover:underline",children:e},r):e)}function eh(){return(0,n.jsx)("svg",{className:"mb-4 opacity-50 text-text-muted",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ep(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function eg(e){let{originalMessage:t,replies:r,onClose:a,onReply:o,isSending:l=!1,currentUser:i}=e,[c,d]=(0,s.useState)(""),x=(0,s.useRef)(null),u=(0,s.useRef)(null);(0,s.useEffect)(()=>{requestAnimationFrame(()=>{var e;null===(e=x.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})})},[r.length]),(0,s.useEffect)(()=>{var e;null===(e=u.current)||void 0===e||e.focus()},[null==t?void 0:t.id]);let m=async e=>{e.preventDefault(),c.trim()&&!l&&await o(c.trim())&&d("")};return t?(0,n.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary border-l border-border",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg-secondary",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(ej,{}),(0,n.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:"Thread"}),(0,n.jsxs)("span",{className:"text-text-muted text-xs",children:[r.length," ",1===r.length?"reply":"replies"]})]}),(0,n.jsx)("button",{onClick:a,className:"p-1.5 rounded hover:bg-bg-hover transition-colors text-text-muted hover:text-text-primary",title:"Close thread",children:(0,n.jsx)(ey,{})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,n.jsx)("div",{className:"p-4 border-b border-border",children:(0,n.jsx)(ef,{message:t,isOriginal:!0,currentUser:i})}),(0,n.jsxs)("div",{className:"p-4 space-y-3",children:[0===r.length?(0,n.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No replies yet. Be the first to reply!"}):r.map(e=>(0,n.jsx)(ef,{message:e,currentUser:i},e.id)),(0,n.jsx)("div",{ref:x})]})]}),(0,n.jsx)("div",{className:"p-4 border-t border-border bg-bg-secondary",children:(0,n.jsxs)("form",{onSubmit:m,className:"flex gap-2",children:[(0,n.jsx)("textarea",{ref:u,value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),m(e))},placeholder:"Reply to thread...",disabled:l,rows:1,className:"flex-1 py-2 px-3 bg-bg-primary border border-border rounded-md text-sm text-text-primary resize-none min-h-[40px] max-h-[100px] overflow-y-auto focus:outline-none focus:border-accent transition-colors placeholder:text-text-muted"}),(0,n.jsx)("button",{type:"submit",disabled:!c.trim()||l,className:"px-4 py-2 bg-accent text-white rounded-md text-sm font-medium transition-colors hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",children:l?"Sending...":"Reply"})]})})]}):null}function ef(e){let{message:t,isOriginal:r,currentUser:o}=e,l=(0,a.GW)(t.from),i=function(e){let t=new Date(e),r=new Date;return t.toDateString()===r.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(t.timestamp),c="Dashboard"===t.from||o&&t.from===o.displayName,d=c&&o?o.displayName:t.from;return(0,n.jsxs)("div",{className:"flex gap-3 ".concat(r?"":"pl-2"),children:[c&&(null==o?void 0:o.avatarUrl)?(0,n.jsx)("img",{src:o.avatarUrl,alt:d,className:"shrink-0 w-8 h-8 rounded-lg object-cover"}):(0,n.jsx)("div",{className:"shrink-0 w-8 h-8 rounded-lg flex items-center justify-center font-semibold text-xs",style:{backgroundColor:l.primary,color:l.text},children:(0,a.hP)(t.from)}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,n.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:d}),"*"!==t.to&&!r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-text-muted text-xs",children:"→"}),(0,n.jsx)("span",{className:"text-sm text-accent",children:t.to})]}),(0,n.jsx)("span",{className:"text-text-muted text-xs",children:i}),r&&(0,n.jsx)("span",{className:"text-[10px] py-0.5 px-1.5 rounded bg-accent-light text-accent font-medium",children:"Original"})]}),(0,n.jsx)("div",{className:"text-sm leading-relaxed text-text-primary whitespace-pre-wrap break-words",children:t.content.replace(/\\n/g,"\n").replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n").map((e,t)=>(0,n.jsxs)(s.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),function(e){let t=/(https?:\/\/[^\s]+)/g;return e.split(t).map((e,r)=>t.test(e)?(0,n.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:e},r):e)}(e)]},t))}),t.attachments&&t.attachments.length>0&&(0,n.jsx)(eb,{attachments:t.attachments})]})]})}function eb(e){let{attachments:t}=e,[r,a]=(0,s.useState)(null),o=t.filter(e=>e.mimeType.startsWith("image/"));return 0===o.length?null:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>a(e),className:"relative group cursor-pointer bg-transparent border-0 p-0",title:"View ".concat(e.filename),children:[(0,n.jsx)("img",{src:e.data||e.url,alt:e.filename,className:"max-h-32 max-w-[200px] rounded-lg border border-border object-cover transition-all duration-150 group-hover:border-accent/50 group-hover:shadow-md",loading:"lazy"}),(0,n.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 rounded-lg transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",children:(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",className:"drop-shadow-lg",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,n.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,n.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]},e.id))}),r&&(0,n.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>a(null),children:(0,n.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,n.jsx)("img",{src:r.data||r.url,alt:r.filename,className:"max-w-full max-h-[90vh] rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()}),(0,n.jsx)("button",{type:"button",onClick:()=>a(null),className:"absolute -top-3 -right-3 w-8 h-8 bg-bg-primary border border-border rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-secondary transition-colors shadow-lg",title:"Close",children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,n.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-3 bg-gradient-to-t from-black/60 to-transparent rounded-b-lg",children:(0,n.jsx)("p",{className:"text-white text-sm truncate",children:r.filename})})]})})]})}function ej(){return(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-primary",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function ey(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}let ev=["projects","agents","actions","navigation","settings"];function ew(e){return e.isOpen?(0,n.jsx)(eN,{...e}):null}function eN(e){let{onClose:t,agents:r,projects:a=[],currentProject:o,onAgentSelect:l,onProjectSelect:i,onSpawnClick:c,onSettingsClick:d,onGeneralClick:x,customCommands:u=[]}=e,[m,h]=(0,s.useState)(""),[p,g]=(0,s.useState)(0),f=(0,s.useRef)(p),b=(0,s.useRef)(null),j=(0,s.useRef)(null),y=(0,s.useRef)([]);(0,s.useEffect)(()=>{f.current=p},[p]);let v=(0,s.useMemo)(()=>[...a.map(e=>{let r=e.name||e.path.split("/").pop()||e.id,s=e.id===o;return{id:"project-".concat(e.id),label:r,description:s?"Current project • ".concat(e.agents.length," agents"):"".concat(e.agents.length," agents"),category:"projects",icon:(0,n.jsx)(eE,{}),action:()=>{null==i||i(e),t()}}}),...r.map(e=>({id:"agent-".concat(e.name),label:e.name,description:e.currentTask||e.status,category:"agents",icon:(0,n.jsx)(ek,{name:e.name}),action:()=>{l(e),t()}})),{id:"spawn-agent",label:"Spawn Agent",description:"Launch a new agent instance",category:"actions",icon:(0,n.jsx)(eS,{}),shortcut:"⌘⇧S",action:()=>{c(),t()}},{id:"broadcast",label:"Broadcast Message",description:"Send message to all agents",category:"actions",icon:(0,n.jsx)(eA,{}),action:()=>{t()}},{id:"nav-general",label:"Go to #general",description:"View all broadcast messages",category:"navigation",icon:(0,n.jsx)(eL,{}),action:()=>{null==x||x(),t()}},...d?[{id:"settings",label:"Settings",description:"Configure dashboard preferences",category:"settings",icon:(0,n.jsx)(eW,{}),shortcut:"⌘,",action:()=>{d(),t()}}]:[],...u],[r,a,o,l,i,c,d,x,t,u]),w=(0,s.useMemo)(()=>{if(!m.trim())return v;let e=m.toLowerCase();return v.filter(t=>{var r;return t.label.toLowerCase().includes(e)||(null===(r=t.description)||void 0===r?void 0:r.toLowerCase().includes(e))||t.category.toLowerCase().includes(e)})},[v,m]),N=(0,s.useMemo)(()=>{let e={};for(let t of w)e[t.category]||(e[t.category]=[]),e[t.category].push(t);return e},[w]),k=(0,s.useMemo)(()=>ev.flatMap(e=>N[e]||[]),[N]);(0,s.useEffect)(()=>{g(0)},[m]),(0,s.useEffect)(()=>{h(""),g(0)},[]),(0,s.useEffect)(()=>{let e=y.current[p];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})},[p]),(0,s.useEffect)(()=>{let e=e=>{switch(e.key){case"ArrowDown":e.preventDefault(),g(e=>Math.min(e+1,k.length-1));break;case"ArrowUp":e.preventDefault(),g(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),k[f.current]&&k[f.current].action();break;case"Escape":e.preventDefault(),t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[k,p,t]);let C={projects:"Projects",agents:"Agents",actions:"Actions",navigation:"Navigation",settings:"Settings"},S=0;return(0,n.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:t,children:(0,n.jsxs)("div",{className:"bg-sidebar-bg border border-sidebar-border rounded-xl w-[560px] max-w-[90vw] max-h-[60vh] flex flex-col shadow-modal animate-slide-down",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,n.jsx)(eC,{}),(0,n.jsx)("input",{ref:b,autoFocus:!0,type:"text",className:"flex-1 border-none text-base font-sans outline-none bg-transparent text-text-primary placeholder:text-text-muted",placeholder:"Search commands, agents...",value:m,onChange:e=>h(e.target.value)}),(0,n.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",children:"ESC"})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-2",ref:j,children:0===k.length?(0,n.jsxs)("div",{className:"py-8 text-center text-text-muted text-sm",children:['No results for "',m,'"']}):ev.map(e=>{let t=N[e];return(null==t?void 0:t.length)?(0,n.jsxs)("div",{className:"mb-2",children:[(0,n.jsx)("div",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider py-2 px-3",children:C[e]||e}),t.map(e=>{let t=S++;return(0,n.jsxs)("button",{ref:e=>{y.current[t]=e},className:"\n flex items-center gap-3 w-full py-2.5 px-3 border-none rounded-lg cursor-pointer text-left font-sans transition-colors duration-100\n ".concat(t===p?"bg-accent-light border border-accent/30":"bg-transparent hover:bg-sidebar-border","\n "),onClick:e.action,onMouseEnter:()=>g(t),children:[(0,n.jsx)("span",{className:"flex items-center justify-center w-7 h-7 text-text-muted",children:e.icon}),(0,n.jsxs)("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.label}),e.description&&(0,n.jsx)("span",{className:"text-xs text-text-muted truncate",children:e.description})]}),e.shortcut&&(0,n.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",children:e.shortcut})]},e.id)})]},e):null})})]})})}function ek(e){let{name:t}=e,r=(0,a.GW)(t);return(0,n.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs font-semibold",style:{backgroundColor:r.primary,color:r.text},children:(0,a.hP)(t)})}function eC(){return(0,n.jsxs)("svg",{className:"text-text-muted shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function eS(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function eA(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,n.jsx)("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]})}function eL(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,n.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,n.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,n.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function eW(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function eE(){return(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}let eD=[{id:"claude",name:"Claude",command:"claude",description:"Claude Code CLI agent",icon:"\uD83E\uDD16"},{id:"codex",name:"Codex",command:"codex",description:"OpenAI Codex agent",icon:"⚡"},{id:"custom",name:"Custom",command:"",description:"Custom command",icon:"\uD83D\uDD27"}];function eM(e){let{isOpen:t,onClose:r,onSpawn:o,existingAgents:l,isSpawning:i=!1,error:c}=e,[d,x]=(0,s.useState)(eD[0]),[u,m]=(0,s.useState)(""),[h,p]=(0,s.useState)(""),[g,f]=(0,s.useState)(""),[b,j]=(0,s.useState)(""),[y,v]=(0,s.useState)(!1),[w,N]=(0,s.useState)(""),[k,C]=(0,s.useState)(""),[S,A]=(0,s.useState)(["EXPLICIT_ASK"]),[L,W]=(0,s.useState)(null),E=(0,s.useRef)(null),D="custom"===d.id?h:d.command,M=(0,s.useMemo)(()=>(function(e){let t=e.trim().split(" ")[0].toLowerCase();return t.startsWith("claude")||"codex"===t||"opencode"===t?"subagent":"process"})(D),[D]),_=(0,s.useCallback)(()=>{let e="claude"===d.id?"claude":d.id,t=1;for(;l.includes("".concat(e,"-").concat(t));)t++;return"".concat(e,"-").concat(t)},[d,l]);(0,s.useEffect)(()=>{t&&(x(eD[0]),m(""),p(""),f(""),j(""),v(!1),N(""),C(""),A(["EXPLICIT_ASK"]),W(null),setTimeout(()=>{var e;return null===(e=E.current)||void 0===e?void 0:e.focus()},100))},[t]);let B=(0,s.useCallback)(e=>e.trim()?/^[a-zA-Z][a-zA-Z0-9-]*$/.test(e)?l.includes(e)?"An agent with this name already exists":null:"Name must start with a letter and contain only letters, numbers, and hyphens":"Name is required",[l]),T=async e=>{e.preventDefault();let t=u.trim()||_(),n=B(t);if(n){W(n);return}if(!D.trim()){W("Command is required");return}if(y&&!w){W("Please select an agent to shadow");return}W(null),await o({name:t,command:D.trim(),cwd:g.trim()||void 0,team:b.trim()||void 0,shadowMode:M,shadowOf:y?w:void 0,shadowAgent:k.trim()||void 0,shadowTriggers:y?S:void 0,shadowSpeakOn:y?S:void 0})&&r()};if(!t)return null;let R=u?(0,a.GW)(u):(0,a.GW)(_()),P=c||L;return(0,n.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,n.jsxs)("div",{className:"bg-bg-primary border border-border rounded-xl w-[480px] max-w-[90vw] max-h-[90vh] overflow-y-auto shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),r())},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-border",children:[(0,n.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Spawn New Agent"}),(0,n.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,"aria-label":"Close",children:(0,n.jsx)(e_,{})})]}),(0,n.jsxs)("form",{onSubmit:T,className:"p-6",children:[(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",children:"Agent Type"}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:eD.map(e=>(0,n.jsxs)("button",{type:"button",className:"\n flex flex-col items-center gap-1 py-3 px-2 border-2 rounded-lg cursor-pointer font-sans transition-all duration-150\n ".concat(d.id===e.id?"bg-accent/10 border-accent":"bg-bg-hover border-transparent hover:bg-bg-active","\n "),onClick:()=>x(e),children:[(0,n.jsx)("span",{className:"text-2xl",children:e.icon}),(0,n.jsx)("span",{className:"text-sm font-semibold text-text-primary",children:e.name}),(0,n.jsx)("span",{className:"text-xs text-text-muted text-center",children:e.description})]},e.id))})]}),(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-name",children:"Agent Name"}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-lg flex items-center justify-center text-sm font-semibold",style:{backgroundColor:R.primary,color:R.text},children:(0,a.hP)(u||_())}),(0,n.jsx)("input",{ref:E,id:"agent-name",type:"text",className:"flex-1 py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:_(),value:u,onChange:e=>{m(e.target.value),W(null)},disabled:i})]})]}),(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsxs)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-team",children:["Team ",(0,n.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,n.jsx)("input",{id:"agent-team",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., frontend, backend, infra",value:b,onChange:e=>j(e.target.value),disabled:i})]}),"custom"===d.id&&(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-command",children:"Command"}),(0,n.jsx)("input",{id:"agent-command",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., python agent.py",value:h,onChange:e=>p(e.target.value),disabled:i})]}),(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsxs)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-cwd",children:["Working Directory ",(0,n.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,n.jsx)("input",{id:"agent-cwd",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"Current directory",value:g,onChange:e=>f(e.target.value),disabled:i})]}),(0,n.jsxs)("div",{className:"mb-5 p-4 border border-border rounded-lg bg-bg-hover/50",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-semibold text-text-primary",children:"Shadow Mode"}),(0,n.jsxs)("span",{className:"text-xs text-text-muted",children:["Shadow execution: ","subagent"===M?"Subagent (in-process)":"Process (separate)"]})]}),(0,n.jsx)("button",{type:"button",className:"\n relative w-11 h-6 rounded-full transition-colors duration-200\n ".concat(y?"bg-accent":"bg-bg-active","\n "),onClick:()=>v(!y),disabled:i,"aria-pressed":y,children:(0,n.jsx)("span",{className:"\n absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform duration-200 shadow-sm\n ".concat(y?"translate-x-5":"translate-x-0","\n ")})})]}),y&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-text-secondary mb-2",htmlFor:"shadow-of",children:"Shadow Agent"}),(0,n.jsxs)("select",{id:"shadow-of",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:w,onChange:e=>N(e.target.value),disabled:i,children:[(0,n.jsx)("option",{value:"",children:"Select an agent to shadow..."}),l.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})]}),(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsxs)("label",{className:"block text-sm font-medium text-text-secondary mb-2",htmlFor:"shadow-agent",children:["Shadow Agent Profile ",(0,n.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,n.jsx)("input",{id:"shadow-agent",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., shadow-reviewer",value:k,onChange:e=>C(e.target.value),disabled:i})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Speak When"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-2",children:[{value:"EXPLICIT_ASK",label:"Explicit Ask",description:"When directly asked"},{value:"SESSION_END",label:"Session End",description:"When session ends"},{value:"CODE_WRITTEN",label:"Code Written",description:"When code is written"},{value:"REVIEW_REQUEST",label:"Review Request",description:"When review requested"},{value:"ALL_MESSAGES",label:"All Messages",description:"On every message"}].map(e=>(0,n.jsx)("button",{type:"button",className:"\n py-1.5 px-3 rounded-md text-xs font-medium transition-all duration-150 border\n ".concat(S.includes(e.value)?"bg-accent/20 border-accent text-accent":"bg-bg-primary border-border text-text-secondary hover:bg-bg-active hover:text-text-primary","\n "),onClick:()=>{S.includes(e.value)?A(S.filter(t=>t!==e.value)):A([...S,e.value])},disabled:i,title:e.description,children:e.label},e.value))})]})]})]}),P&&(0,n.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-error/10 border border-error/30 rounded-md text-error text-sm mb-5",children:[(0,n.jsx)(eB,{}),(0,n.jsx)("span",{children:P})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[(0,n.jsx)("button",{type:"button",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-bg-hover text-text-secondary hover:bg-bg-active hover:text-text-primary disabled:opacity-50 disabled:cursor-not-allowed",onClick:r,disabled:i,children:"Cancel"}),(0,n.jsx)("button",{type:"submit",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-accent text-white hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",disabled:i,children:i?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eR,{}),"Spawning..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eT,{}),"Spawn Agent"]})})]})]})]})})}function e_(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function eB(){return(0,n.jsxs)("svg",{className:"shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function eT(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),(0,n.jsx)("path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),(0,n.jsx)("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),(0,n.jsx)("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function eR(){return(0,n.jsx)("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function eP(e){let{isOpen:t,onClose:r,onSend:o,agents:l,isSending:i=!1,error:c,preselectedAgent:d}=e,[x,u]=(0,s.useState)(""),[m,h]=(0,s.useState)(""),[p,g]=(0,s.useState)(""),[f,b]=(0,s.useState)(null),j=(0,s.useRef)(null),y=(0,s.useRef)(null),v=(0,s.useMemo)(()=>{if(!p.trim())return l;let e=p.toLowerCase();return l.filter(t=>{var r,n;return t.name.toLowerCase().includes(e)||(null===(r=t.role)||void 0===r?void 0:r.toLowerCase().includes(e))||(null===(n=t.team)||void 0===n?void 0:n.toLowerCase().includes(e))})},[l,p]);(0,s.useEffect)(()=>{t&&(u(d||""),h(""),g(""),b(null),setTimeout(()=>{var e,t;d?null===(e=j.current)||void 0===e||e.focus():null===(t=y.current)||void 0===t||t.focus()},100))},[t,d]);let w=async e=>{if(e.preventDefault(),!x){b("Please select an agent");return}if(!m.trim()){b("Please enter a message");return}b(null),await o(x,m.trim())&&r()},N=(0,s.useCallback)(e=>{u(e),b(null),setTimeout(()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()},50)},[]);if(!t)return null;let k=c||f,C=l.find(e=>e.name===x),S=C?(0,a.GW)(C.name):null;return(0,n.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,n.jsxs)("div",{className:"bg-bg-primary border border-border rounded-xl w-[520px] max-w-[90vw] max-h-[85vh] overflow-hidden shadow-modal animate-slide-up flex flex-col",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),r())},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-border shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"w-9 h-9 rounded-lg bg-accent/10 flex items-center justify-center",children:(0,n.jsx)(eF,{})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"New Conversation"}),(0,n.jsx)("p",{className:"m-0 text-xs text-text-muted",children:"Start a direct message with an agent"})]})]}),(0,n.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,"aria-label":"Close",children:(0,n.jsx)(eU,{})})]}),(0,n.jsxs)("form",{onSubmit:w,className:"flex flex-col flex-1 overflow-hidden",children:[(0,n.jsxs)("div",{className:"p-5 border-b border-border",children:[(0,n.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",children:"To"}),x?(0,n.jsxs)("div",{className:"flex items-center gap-3 p-3 bg-bg-hover rounded-lg",children:[(0,n.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-lg flex items-center justify-center text-sm font-semibold",style:{backgroundColor:null==S?void 0:S.primary,color:null==S?void 0:S.text},children:(0,a.hP)(x)}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"font-semibold text-text-primary",children:x}),(null==C?void 0:C.role)&&(0,n.jsx)("div",{className:"text-xs text-text-muted truncate",children:C.role})]}),(0,n.jsx)("button",{type:"button",className:"flex items-center justify-center w-8 h-8 bg-bg-active border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-tertiary hover:text-text-primary",onClick:()=>{u(""),setTimeout(()=>{var e;return null===(e=y.current)||void 0===e?void 0:e.focus()},50)},"aria-label":"Change agent",children:(0,n.jsx)(ez,{})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"relative mb-3",children:[(0,n.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted",children:(0,n.jsx)(eO,{})}),(0,n.jsx)("input",{ref:y,type:"text",className:"w-full py-2.5 pl-10 pr-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent placeholder:text-text-muted",placeholder:"Search agents...",value:p,onChange:e=>g(e.target.value)})]}),(0,n.jsx)("div",{className:"max-h-[200px] overflow-y-auto border border-border rounded-lg",children:0===v.length?(0,n.jsx)("div",{className:"p-4 text-center text-text-muted text-sm",children:p?"No agents found":"No agents available"}):(0,n.jsxs)("div",{className:"divide-y divide-border",children:[(0,n.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 p-3 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-bg-hover text-left",onClick:()=>N("*"),children:[(0,n.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-warning/20 flex items-center justify-center",children:(0,n.jsx)(eH,{})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"font-semibold text-text-primary",children:"Everyone"}),(0,n.jsx)("div",{className:"text-xs text-text-muted",children:"Broadcast to all agents"})]})]}),v.map(e=>{let t=(0,a.GW)(e.name);return(0,n.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 p-3 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-bg-hover text-left",onClick:()=>N(e.name),children:[(0,n.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg flex items-center justify-center text-xs font-semibold",style:{backgroundColor:t.primary,color:t.text},children:(0,a.hP)(e.name)}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-semibold text-text-primary",children:e.name}),(0,n.jsx)("span",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-muted")})]}),(e.role||e.team)&&(0,n.jsxs)("div",{className:"text-xs text-text-muted truncate",children:[e.role,e.role&&e.team&&" - ",e.team]})]})]},e.name)})]})})]})]}),(0,n.jsxs)("div",{className:"p-5 flex-1 overflow-hidden flex flex-col",children:[(0,n.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"message",children:"Message"}),(0,n.jsx)("textarea",{ref:j,id:"message",className:"flex-1 min-h-[120px] w-full py-3 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent resize-none placeholder:text-text-muted",placeholder:"*"===x?"Write a message to all agents...":x?"Write a message to ".concat(x,"..."):"Select an agent first...",value:m,onChange:e=>{h(e.target.value),b(null)},disabled:i||!x})]}),k&&(0,n.jsxs)("div",{className:"flex items-center gap-2 mx-5 mb-4 p-3 bg-error/10 border border-error/30 rounded-md text-error text-sm",children:[(0,n.jsx)(eV,{}),(0,n.jsx)("span",{children:k})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 p-5 pt-0 border-t border-border",children:[(0,n.jsx)("button",{type:"button",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-bg-hover text-text-secondary hover:bg-bg-active hover:text-text-primary disabled:opacity-50 disabled:cursor-not-allowed",onClick:r,disabled:i,children:"Cancel"}),(0,n.jsx)("button",{type:"submit",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-accent text-white hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",disabled:i||!x||!m.trim(),children:i?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eG,{}),"Sending..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eI,{}),"Send Message"]})})]})]})]})})}function eF(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent",children:[(0,n.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),(0,n.jsx)("line",{x1:"9",y1:"10",x2:"15",y2:"10"})]})}function eU(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function eO(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function ez(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,n.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]})}function eH(){return(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-warning",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,n.jsx)("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]})}function eI(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,n.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function eV(){return(0,n.jsxs)("svg",{className:"shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function eG(){return(0,n.jsx)("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}let eK={theme:"system",notifications:{enabled:!0,sound:!0,desktop:!1,mentionsOnly:!1},display:{compactMode:!1,showTimestamps:!0,showAvatars:!0,animationsEnabled:!0},connection:{autoReconnect:!0,reconnectDelay:3e3,keepAliveInterval:3e4}};function e$(e){let{isOpen:t,onClose:r,settings:a,onSettingsChange:o,onResetSettings:l}=e,[i,c]=(0,s.useState)("appearance"),d=(0,s.useCallback)((e,t,r)=>{let n=a[e];o({...a,[e]:{...n,[t]:r}})},[a,o]),x=(0,s.useCallback)(e=>{o({...a,theme:e})},[a,o]);return t?(0,n.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,n.jsxs)("div",{className:"bg-bg-secondary rounded-xl w-[500px] max-w-[90vw] max-h-[80vh] flex flex-col shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border",children:[(0,n.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Settings"}),(0,n.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,children:(0,n.jsx)(eJ,{})})]}),(0,n.jsxs)("div",{className:"flex gap-1 py-3 px-6 border-b border-border bg-bg-tertiary",children:[(0,n.jsxs)("button",{className:"flex items-center gap-1.5 py-2 px-3.5 bg-transparent border-none rounded-md text-[13px] cursor-pointer font-[inherit] transition-all duration-150 ".concat("appearance"===i?"bg-accent text-white":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>c("appearance"),children:[(0,n.jsx)(eZ,{}),"Appearance"]}),(0,n.jsxs)("button",{className:"flex items-center gap-1.5 py-2 px-3.5 bg-transparent border-none rounded-md text-[13px] cursor-pointer font-[inherit] transition-all duration-150 ".concat("notifications"===i?"bg-accent text-white":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>c("notifications"),children:[(0,n.jsx)(eX,{}),"Notifications"]}),(0,n.jsxs)("button",{className:"flex items-center gap-1.5 py-2 px-3.5 bg-transparent border-none rounded-md text-[13px] cursor-pointer font-[inherit] transition-all duration-150 ".concat("connection"===i?"bg-accent text-white":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>c("connection"),children:[(0,n.jsx)(eY,{}),"Connection"]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:["appearance"===i&&(0,n.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,n.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Theme"}),(0,n.jsx)("div",{className:"flex gap-2",children:["light","dark","system"].map(e=>(0,n.jsxs)("button",{className:"flex flex-col items-center gap-1.5 py-4 px-5 border-2 rounded-lg text-xs cursor-pointer font-[inherit] transition-all duration-150 flex-1 ".concat(a.theme===e?"bg-accent-light border-accent text-accent":"bg-bg-hover border-transparent text-text-secondary hover:bg-bg-active"),onClick:()=>x(e),children:["light"===e&&(0,n.jsx)(eQ,{}),"dark"===e&&(0,n.jsx)(e0,{}),"system"===e&&(0,n.jsx)(e1,{}),(0,n.jsx)("span",{children:e.charAt(0).toUpperCase()+e.slice(1)})]},e))})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,n.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Display Options"}),(0,n.jsx)(eq,{label:"Compact mode",description:"Show more content in less space",checked:a.display.compactMode,onChange:e=>d("display","compactMode",e)}),(0,n.jsx)(eq,{label:"Show timestamps",description:"Display time for each message",checked:a.display.showTimestamps,onChange:e=>d("display","showTimestamps",e)}),(0,n.jsx)(eq,{label:"Show avatars",description:"Display agent avatars in messages",checked:a.display.showAvatars,onChange:e=>d("display","showAvatars",e)}),(0,n.jsx)(eq,{label:"Enable animations",description:"Smooth transitions and effects",checked:a.display.animationsEnabled,onChange:e=>d("display","animationsEnabled",e)})]})]}),"notifications"===i&&(0,n.jsx)("div",{className:"flex flex-col gap-6",children:(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,n.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Notification Preferences"}),(0,n.jsx)(eq,{label:"Enable notifications",description:"Receive alerts for new messages",checked:a.notifications.enabled,onChange:e=>d("notifications","enabled",e)}),(0,n.jsx)(eq,{label:"Sound alerts",description:"Play sound for new messages",checked:a.notifications.sound,onChange:e=>d("notifications","sound",e),disabled:!a.notifications.enabled}),(0,n.jsx)(eq,{label:"Desktop notifications",description:"Show system notifications",checked:a.notifications.desktop,onChange:e=>d("notifications","desktop",e),disabled:!a.notifications.enabled}),(0,n.jsx)(eq,{label:"Mentions only",description:"Only notify when mentioned",checked:a.notifications.mentionsOnly,onChange:e=>d("notifications","mentionsOnly",e),disabled:!a.notifications.enabled})]})}),"connection"===i&&(0,n.jsx)("div",{className:"flex flex-col gap-6",children:(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,n.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Connection Settings"}),(0,n.jsx)(eq,{label:"Auto-reconnect",description:"Automatically reconnect on disconnect",checked:a.connection.autoReconnect,onChange:e=>d("connection","autoReconnect",e)}),(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-3 bg-bg-hover rounded-lg",children:[(0,n.jsx)("label",{className:"text-sm font-medium text-text-primary",children:"Reconnect delay (ms)"}),(0,n.jsx)("input",{type:"number",className:"py-2 px-3 border border-border rounded-md text-sm font-[inherit] outline-none transition-colors duration-150 bg-bg-tertiary text-text-primary focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:a.connection.reconnectDelay,onChange:e=>d("connection","reconnectDelay",parseInt(e.target.value)||3e3),min:1e3,max:3e4,step:1e3,disabled:!a.connection.autoReconnect})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-3 bg-bg-hover rounded-lg",children:[(0,n.jsx)("label",{className:"text-sm font-medium text-text-primary",children:"Keep-alive interval (ms)"}),(0,n.jsx)("input",{type:"number",className:"py-2 px-3 border border-border rounded-md text-sm font-[inherit] outline-none transition-colors duration-150 bg-bg-tertiary text-text-primary focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:a.connection.keepAliveInterval,onChange:e=>d("connection","keepAliveInterval",parseInt(e.target.value)||3e4),min:5e3,max:12e4,step:5e3})]})]})})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between py-4 px-6 border-t border-border",children:[l&&(0,n.jsx)("button",{className:"py-2 px-4 bg-transparent border border-border rounded-md text-[13px] text-text-secondary cursor-pointer font-[inherit] transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:l,children:"Reset to defaults"}),(0,n.jsx)("button",{className:"py-2 px-5 bg-accent border-none rounded-md text-[13px] font-medium text-white cursor-pointer font-[inherit] transition-colors duration-150 hover:bg-accent-hover",onClick:r,children:"Done"})]})]})}):null}function eq(e){let{label:t,description:r,checked:s,onChange:a,disabled:o}=e;return(0,n.jsxs)("div",{className:"flex items-center justify-between p-3 bg-bg-hover rounded-lg ".concat(o?"opacity-50":""),children:[(0,n.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-text-primary",children:t}),(0,n.jsx)("span",{className:"text-xs text-text-muted",children:r})]}),(0,n.jsx)("button",{className:"w-11 h-6 border-none rounded-xl cursor-pointer relative transition-colors duration-200 ".concat(s?"bg-accent":"bg-border-medium"," ").concat(o?"cursor-not-allowed":""),onClick:()=>!o&&a(!s),disabled:o,role:"switch","aria-checked":s,children:(0,n.jsx)("span",{className:"absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.2)] ".concat(s?"translate-x-5":"")})})]})}function eJ(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function eZ(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"13.5",cy:"6.5",r:".5"}),(0,n.jsx)("circle",{cx:"17.5",cy:"10.5",r:".5"}),(0,n.jsx)("circle",{cx:"8.5",cy:"7.5",r:".5"}),(0,n.jsx)("circle",{cx:"6.5",cy:"12.5",r:".5"}),(0,n.jsx)("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.555C21.965 6.012 17.461 2 12 2z"})]})}function eX(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,n.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}function eY(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M5 12.55a11 11 0 0 1 14.08 0"}),(0,n.jsx)("path",{d:"M1.42 9a16 16 0 0 1 21.16 0"}),(0,n.jsx)("path",{d:"M8.53 16.11a6 6 0 0 1 6.95 0"}),(0,n.jsx)("line",{x1:"12",y1:"20",x2:"12.01",y2:"20"})]})}function eQ(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,n.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,n.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,n.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,n.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,n.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,n.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,n.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,n.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})}function e0(){return(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}function e1(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,n.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,n.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}var e2=r(9116);function e5(e){let{isOpen:t,onClose:r}=e,[a,o]=(0,s.useState)("conversations"),[l,i]=(0,s.useState)([]),[c,d]=(0,s.useState)([]),[x,u]=(0,s.useState)([]),[m,h]=(0,s.useState)(null),[p,g]=(0,s.useState)(!1),[f,b]=(0,s.useState)(null),[j,y]=(0,s.useState)(""),[v,w]=(0,s.useState)(""),[N,k]=(0,s.useState)(null);(0,s.useEffect)(()=>{t&&(async()=>{let e=await e2.hi.getHistoryStats();e.success&&e.data&&h(e.data)})()},[t]),(0,s.useEffect)(()=>{t&&(async()=>{g(!0),b(null);try{if("conversations"===a){let e=await e2.hi.getHistoryConversations();e.success&&e.data?i(e.data.conversations):b(e.error||"Failed to fetch conversations")}else if("sessions"===a){let e=await e2.hi.getHistorySessions({agent:v||void 0,limit:50});e.success&&e.data?d(e.data.sessions):b(e.error||"Failed to fetch sessions")}else if("messages"===a){let r={limit:100,order:"desc"};if(j&&(r.search=j),N){let[n,s]=N.participants,a=await e2.hi.getHistoryMessages({...r,from:n,to:s}),o=await e2.hi.getHistoryMessages({...r,from:s,to:n});if(a.success&&o.success){var e,t;let r=[...(null===(e=a.data)||void 0===e?void 0:e.messages)||[],...(null===(t=o.data)||void 0===t?void 0:t.messages)||[]].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime());u(r)}}else{let e=await e2.hi.getHistoryMessages(r);e.success&&e.data?u(e.data.messages):b(e.error||"Failed to fetch messages")}}}catch(e){b("Failed to load data")}finally{g(!1)}})()},[t,a,v,j,N]);let C=(0,s.useCallback)(e=>{k(e),o("messages")},[]),S=(0,s.useCallback)(()=>{k(null),o("conversations")},[]);return t?(0,n.jsx)("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50",children:(0,n.jsxs)("div",{className:"bg-bg-primary rounded-lg shadow-xl w-[90vw] max-w-4xl h-[80vh] flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex items-center gap-4",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold text-text-primary",children:"Conversation History"}),m&&(0,n.jsxs)("div",{className:"flex gap-4 text-sm text-text-muted",children:[(0,n.jsxs)("span",{children:[m.messageCount," messages"]}),(0,n.jsxs)("span",{children:[m.sessionCount," sessions"]}),(0,n.jsxs)("span",{children:[m.uniqueAgents," agents"]})]})]}),(0,n.jsx)("button",{onClick:r,className:"p-2 text-text-muted hover:text-text-primary rounded transition-colors","aria-label":"Close",children:(0,n.jsx)(te,{})})]}),(0,n.jsxs)("div",{className:"flex items-center gap-4 p-4 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex gap-1 bg-bg-secondary rounded-md p-1",children:[(0,n.jsx)(e4,{active:"conversations"===a,onClick:()=>{k(null),o("conversations")},children:"Conversations"}),(0,n.jsx)(e4,{active:"sessions"===a,onClick:()=>o("sessions"),children:"Sessions"}),(0,n.jsx)(e4,{active:"messages"===a,onClick:()=>o("messages"),children:"Messages"})]}),"messages"===a&&(0,n.jsx)("div",{className:"flex-1 max-w-xs",children:(0,n.jsx)("input",{type:"text",placeholder:"Search messages...",value:j,onChange:e=>y(e.target.value),className:"w-full px-3 py-2 bg-bg-secondary border border-border rounded-md text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent"})}),"sessions"===a&&(0,n.jsx)("div",{className:"flex-1 max-w-xs",children:(0,n.jsx)("input",{type:"text",placeholder:"Filter by agent...",value:v,onChange:e=>w(e.target.value),className:"w-full px-3 py-2 bg-bg-secondary border border-border rounded-md text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent"})}),N&&(0,n.jsxs)("button",{onClick:S,className:"flex items-center gap-1 px-3 py-2 text-sm text-text-muted hover:text-text-primary",children:[(0,n.jsx)(tt,{})," Back to conversations"]})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)(tr,{})}):f?(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-error",children:f}):"conversations"===a?(0,n.jsx)(e3,{conversations:l,onConversationClick:C}):"sessions"===a?(0,n.jsx)(e6,{sessions:c}):(0,n.jsx)(e9,{messages:x,conversationTitle:N?"".concat(N.participants[0]," & ").concat(N.participants[1]):void 0})})]})}):null}function e4(e){let{active:t,onClick:r,children:s}=e;return(0,n.jsx)("button",{onClick:r,className:"px-3 py-1.5 text-sm rounded transition-colors ".concat(t?"bg-accent text-white":"text-text-muted hover:text-text-primary hover:bg-bg-primary"),children:s})}function e3(e){let{conversations:t,onConversationClick:r}=e;return 0===t.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No conversations found"}):(0,n.jsx)("div",{className:"space-y-2",children:t.map((e,t)=>(0,n.jsxs)("div",{onClick:()=>r(e),className:"p-4 bg-bg-secondary rounded-lg cursor-pointer hover:bg-bg-tertiary transition-colors",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-medium text-text-primary",children:e.participants.join(" & ")}),(0,n.jsxs)("span",{className:"text-xs px-2 py-0.5 bg-accent/10 text-accent rounded-full",children:[e.messageCount," messages"]})]}),(0,n.jsx)("span",{className:"text-xs text-text-muted",children:e7(e.lastTimestamp)})]}),(0,n.jsx)("p",{className:"text-sm text-text-muted truncate",children:e.lastMessage})]},t))})}function e6(e){let{sessions:t}=e;return 0===t.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No sessions found"}):(0,n.jsx)("div",{className:"space-y-2",children:t.map(e=>(0,n.jsxs)("div",{className:"p-4 bg-bg-secondary rounded-lg",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-medium text-text-primary",children:e.agentName}),e.cli&&(0,n.jsx)("span",{className:"text-xs px-2 py-0.5 bg-bg-tertiary text-text-muted rounded",children:e.cli}),(0,n.jsx)(e8,{isActive:e.isActive,closedBy:e.closedBy})]}),(0,n.jsx)("span",{className:"text-xs text-text-muted",children:e.duration})]}),(0,n.jsxs)("div",{className:"flex items-center gap-4 text-sm text-text-muted",children:[(0,n.jsx)("span",{children:new Date(e.startedAt).toLocaleString()}),(0,n.jsxs)("span",{children:[e.messageCount," messages"]})]}),e.summary&&(0,n.jsx)("p",{className:"mt-2 text-sm text-text-muted truncate",children:e.summary})]},e.id))})}function e8(e){let{isActive:t,closedBy:r}=e;if(t)return(0,n.jsx)("span",{className:"text-xs px-2 py-0.5 bg-success/10 text-success rounded-full",children:"Active"});let s={agent:"bg-text-muted/10 text-text-muted",disconnect:"bg-warning/10 text-warning",error:"bg-error/10 text-error"},a=r?s[r]:s.agent;return(0,n.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(a),children:r?({agent:"Closed",disconnect:"Disconnected",error:"Error"})[r]:"Ended"})}function e9(e){let{messages:t,conversationTitle:r}=e;return 0===t.length?(0,n.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No messages found"}):(0,n.jsxs)("div",{className:"space-y-4",children:[r&&(0,n.jsx)("h3",{className:"text-lg font-medium text-text-primary mb-4",children:r}),t.map(e=>(0,n.jsxs)("div",{className:"p-4 bg-bg-secondary rounded-lg",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-medium text-accent",children:e.from}),(0,n.jsx)("span",{className:"text-text-muted",children:"to"}),(0,n.jsx)("span",{className:"font-medium text-text-primary",children:"*"===e.to?"Everyone":e.to}),e.isBroadcast&&(0,n.jsx)("span",{className:"text-xs px-2 py-0.5 bg-accent/10 text-accent rounded-full",children:"Broadcast"}),e.isUrgent&&(0,n.jsx)("span",{className:"text-xs px-2 py-0.5 bg-error/10 text-error rounded-full",children:"Urgent"})]}),(0,n.jsx)("span",{className:"text-xs text-text-muted",children:e7(e.timestamp)})]}),(0,n.jsx)("p",{className:"text-sm text-text-primary whitespace-pre-wrap",children:e.content}),e.thread&&(0,n.jsxs)("div",{className:"mt-2 text-xs text-text-muted",children:["Thread: ",e.thread.slice(0,8),"..."]})]},e.id))]})}function e7(e){let t=new Date(e),r=new Date().getTime()-t.getTime(),n=Math.floor(r/6e4),s=Math.floor(r/36e5),a=Math.floor(r/864e5);return n<1?"just now":n<60?"".concat(n,"m ago"):s<24?"".concat(s,"h ago"):a<7?"".concat(a,"d ago"):t.toLocaleDateString()}function te(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tt(){return(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("polyline",{points:"15 18 9 12 15 6"})})}function tr(){return(0,n.jsx)("svg",{className:"animate-spin text-accent",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function tn(e,t){let r=e.substring(0,t).match(/(?:^|[\s(])@(\S*)$/);return r?r[1]:null}function ts(e,t,r){let n=e.substring(0,r),s=e.substring(r),a=n.match(/(?:^|[\s(])@(\S*)$/);if(a){let r=a.index||0,n=a[0].charAt(0),o=e.substring(0,"@"===n?r:r+1),l="@".concat(t," "),i=o.length+l.length;return{value:o+l+s,cursorPosition:i}}return{value:e,cursorPosition:r}}function ta(e){let{agents:t,humanUsers:r=[],inputValue:o,cursorPosition:l,onSelect:i,onClose:c,isVisible:d}=e,[x,u]=(0,s.useState)(0),m=(0,s.useRef)(null),h=(0,s.useMemo)(()=>tn(o,l),[o,l]),p=(0,s.useMemo)(()=>{let e=new Map;return t.forEach(t=>{if(t.team){let r=e.get(t.team)||[];r.push(t),e.set(t.team,r)}}),e},[t]),g=(0,s.useMemo)(()=>{if(null===h)return[];let e=h.toLowerCase(),n=[];("*".includes(e)||"everyone".includes(e)||"all".includes(e)||"broadcast".includes(e)||""===e)&&n.push({name:"*",displayName:"@everyone",description:"Broadcast to all agents",isBroadcast:!0});let s=e.startsWith("team:")||e.startsWith("team"),a=e.startsWith("team:")?e.substring(5):e.replace(/^team/,"");(s||""===e)&&p.forEach((t,r)=>{let s=r.toLowerCase();(""===a||s.includes(a)||"team:".concat(s).includes(e))&&n.push({name:"team:".concat(r),displayName:"@team:".concat(r),description:"".concat(t.length," agent").concat(1!==t.length?"s":"",": ").concat(t.map(e=>e.name).join(", ")),isTeam:!0,memberCount:t.length})});let o=new Set(t.map(e=>e.name.toLowerCase()));return r.filter(t=>{let r=t.username.toLowerCase();return r.includes(e)&&!o.has(r)}).forEach(e=>{n.push({name:e.username,displayName:"@".concat(e.username),description:"Human user",isHuman:!0,avatarUrl:e.avatarUrl})}),t.filter(t=>t.name.toLowerCase().includes(e)).forEach(e=>{n.push({name:e.name,displayName:"@".concat(e.name),description:e.team?"".concat(e.status||"Agent"," \xb7 ").concat(e.team):e.status||"Agent"})}),n},[h,t,r,p]);(0,s.useEffect)(()=>{u(0)},[g.length]),(0,s.useEffect)(()=>{if(!m.current)return;let e=m.current.querySelector('[data-selected="true"]');e&&e.scrollIntoView({block:"nearest"})},[x]);let f=(0,s.useCallback)(e=>{if(d&&0!==g.length)switch(e.key){case"ArrowDown":e.preventDefault(),u(e=>(e+1)%g.length);break;case"ArrowUp":e.preventDefault(),u(e=>(e-1+g.length)%g.length);break;case"Enter":case"Tab":e.preventDefault();let t=g[x];if(t){let e=ts(o,t.name,l);i(t.name,e.value)}break;case"Escape":e.preventDefault(),c()}},[d,g,x,o,l,i,c]);(0,s.useEffect)(()=>{if(d)return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[d,f]);let b=(0,s.useCallback)(e=>{let t=ts(o,e.name,l);i(e.name,t.value)},[o,l,i]);return d&&0!==g.length?(0,n.jsx)("div",{className:"absolute bottom-full left-0 right-0 max-h-[200px] overflow-y-auto bg-[#1a1d21] border border-white/10 rounded-lg shadow-[0_-4px_20px_rgba(0,0,0,0.4)] z-[100] mb-1",ref:m,children:g.map((e,t)=>(0,n.jsxs)("div",{"data-selected":t===x,className:"flex items-center gap-2.5 py-2 px-3 cursor-pointer transition-colors duration-150 ".concat(t===x?"bg-white/[0.08]":"hover:bg-white/[0.08]"),onClick:()=>b(e),onMouseEnter:()=>u(t),children:[e.isHuman&&e.avatarUrl?(0,n.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-7 h-7 rounded-md object-cover"}):(0,n.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-white text-[11px] font-semibold",style:{background:e.isBroadcast?"var(--color-warning, #f59e0b)":e.isTeam?"var(--color-accent-purple, #a855f7)":e.isHuman?"#a855f7":(0,a.GW)(e.name).primary},children:e.isBroadcast?"*":e.isTeam?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,n.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,n.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,n.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}):e.isHuman?(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),(0,n.jsx)("circle",{cx:"12",cy:"7",r:"4"})]}):(0,a.hP)(e.name)}),(0,n.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-[#d1d2d3]",children:e.displayName}),(0,n.jsx)("span",{className:"text-xs text-[#8d8d8e] truncate",children:e.description})]})]},e.name))}):null}function to(e,t){let r=e.substring(0,t).match(/(?:^|[\s(])@(\S*)$/);if(r){let e=r[1];if(e.includes("/")||/\.[a-zA-Z0-9]{1,10}$/.test(e))return e}return null}function tl(e,t,r){let n=e.substring(0,r),s=e.substring(r),a=n.match(/(?:^|[\s(])@(\S*)$/);if(a){let r=a.index||0,n=a[0].charAt(0);return e.substring(0,"@"===n?r:r+1)+"@".concat(t," ")+s}return e}let ti=new Map;function tc(e){let{inputValue:t,cursorPosition:r,onSelect:a,onClose:o,isVisible:l,apiBase:i=""}=e,[c,d]=(0,s.useState)(0),[x,u]=(0,s.useState)([]),[m,h]=(0,s.useState)(!1),[p,g]=(0,s.useState)(null),f=(0,s.useRef)(null),b=(0,s.useRef)(null),j=(0,s.useMemo)(()=>to(t,r),[t,r]);(0,s.useEffect)(()=>{if(!l||null===j){u([]);return}let e=j||"__root__",t=ti.get(e);if(t&&Date.now()-t.timestamp<3e4){u(t.files),g(null);return}b.current&&b.current.abort();let r=new AbortController;b.current=r;let n=setTimeout(async()=>{h(!0),g(null);try{let t=j||"",n=await fetch("".concat(i,"/api/files?q=").concat(encodeURIComponent(t),"&limit=15"),{signal:r.signal});if(!n.ok)throw Error("Failed to fetch files");let s=((await n.json()).files||[]).map(e=>({path:e.path,name:e.name,isDirectory:e.isDirectory||!1}));ti.set(e,{files:s,timestamp:Date.now()}),u(s)}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;g("Failed to load files"),u([])}finally{h(!1)}},150);return()=>{clearTimeout(n),r.abort()}},[l,j,i]),(0,s.useEffect)(()=>{d(0)},[x.length]),(0,s.useEffect)(()=>{if(!f.current)return;let e=f.current.querySelector('[data-selected="true"]');e&&e.scrollIntoView({block:"nearest"})},[c]);let y=(0,s.useCallback)(e=>{if(l&&0!==x.length)switch(e.key){case"ArrowDown":e.preventDefault(),d(e=>(e+1)%x.length);break;case"ArrowUp":e.preventDefault(),d(e=>(e-1+x.length)%x.length);break;case"Enter":case"Tab":e.preventDefault();let n=x[c];if(n){let e=tl(t,n.path,r);a(n.path,e)}break;case"Escape":e.preventDefault(),o()}},[l,x,c,t,r,a,o]);(0,s.useEffect)(()=>{if(l)return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[l,y]);let v=(0,s.useCallback)(e=>{let n=tl(t,e.path,r);a(e.path,n)},[t,r,a]);return l&&(0!==x.length||m||p)?(0,n.jsxs)("div",{className:"absolute bottom-full left-0 right-0 max-h-[240px] overflow-y-auto bg-[#1a1d21] border border-white/10 rounded-lg shadow-[0_-4px_20px_rgba(0,0,0,0.4)] z-[100] mb-1",ref:f,children:[(0,n.jsxs)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-[#8d8d8e] border-b border-white/5 flex items-center gap-2",children:[(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,n.jsx)("polyline",{points:"13 2 13 9 20 9"})]}),"Files ",j&&(0,n.jsxs)("span",{className:"text-[#6b6b6c]",children:['matching "',j,'"']})]}),m&&0===x.length&&(0,n.jsxs)("div",{className:"px-3 py-4 text-sm text-[#8d8d8e] text-center",children:[(0,n.jsx)("svg",{className:"animate-spin mx-auto mb-2",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})}),"Searching files..."]}),p&&(0,n.jsx)("div",{className:"px-3 py-4 text-sm text-red-400 text-center",children:p}),x.map((e,t)=>(0,n.jsxs)("div",{"data-selected":t===c,className:"flex items-center gap-2.5 py-2 px-3 cursor-pointer transition-colors duration-150 ".concat(t===c?"bg-white/[0.08]":"hover:bg-white/[0.08]"),onClick:()=>v(e),onMouseEnter:()=>d(t),children:[(0,n.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-[#8d8d8e]",style:{background:e.isDirectory?"rgba(251, 191, 36, 0.15)":"rgba(96, 165, 250, 0.15)"},children:e.isDirectory?(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#fbbf24",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}):(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#60a5fa",strokeWidth:"2",children:[(0,n.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,n.jsx)("polyline",{points:"13 2 13 9 20 9"})]})}),(0,n.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-[#d1d2d3] truncate",children:e.name}),(0,n.jsx)("span",{className:"text-xs text-[#6b6b6c] truncate",children:e.path})]})]},e.path)),!m&&!p&&0===x.length&&j&&(0,n.jsxs)("div",{className:"px-3 py-4 text-sm text-[#8d8d8e] text-center",children:['No files found matching "',j,'"']})]}):null}function td(e){let{workspaces:t,activeWorkspaceId:r,onSelect:a,onAddWorkspace:o,isLoading:l=!1}=e,[i,c]=(0,s.useState)(!1),d=(0,s.useRef)(null),x=t.find(e=>e.id===r);return(0,s.useEffect)(()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&c(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,n.jsxs)("div",{className:"relative w-full",ref:d,children:[(0,n.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-2.5 bg-[#2a2a3e] border border-[#3a3a4e] rounded-lg text-[#e8e8e8] text-sm cursor-pointer transition-all hover:bg-[#3a3a4e] hover:border-[#4a4a5e] disabled:opacity-60 disabled:cursor-not-allowed",onClick:()=>c(!i),disabled:l,children:[l?(0,n.jsx)("span",{className:"flex-1 text-left text-[#666]",children:"Loading..."}):x?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tx,{provider:x.provider}),(0,n.jsx)("span",{className:"flex-1 text-left font-medium",children:x.name}),x.gitBranch&&(0,n.jsxs)("span",{className:"flex items-center gap-1 text-xs text-[#888] bg-white/5 px-1.5 py-0.5 rounded",children:[(0,n.jsx)(th,{}),x.gitBranch]})]}):(0,n.jsx)("span",{className:"flex-1 text-left text-[#666]",children:"Select workspace..."}),(0,n.jsx)(tm,{isOpen:i})]}),i&&(0,n.jsxs)("div",{className:"absolute top-[calc(100%+4px)] left-0 right-0 bg-[#1a1a2e] border border-[#3a3a4e] rounded-lg shadow-[0_10px_40px_rgba(0,0,0,0.4)] z-[1000] overflow-hidden",children:[(0,n.jsx)("div",{className:"max-h-[300px] overflow-y-auto",children:0===t.length?(0,n.jsxs)("div",{className:"py-6 px-4 text-center text-[#666] text-[13px] leading-relaxed",children:["No workspaces added yet.",(0,n.jsx)("br",{}),"Add a repository to get started."]}):t.map(e=>(0,n.jsxs)("button",{className:"w-full flex items-center gap-2.5 px-3 py-2.5 bg-transparent border-none text-[#e8e8e8] text-sm cursor-pointer transition-colors text-left hover:bg-white/5 ".concat(e.id===r?"bg-[rgba(0,200,150,0.1)]":""),onClick:()=>{a(e),c(!1)},children:[(0,n.jsx)(tx,{provider:e.provider}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col gap-0.5 min-w-0",children:[(0,n.jsx)("span",{className:"font-medium",children:e.name}),(0,n.jsx)("span",{className:"text-[11px] text-[#666] overflow-hidden text-ellipsis whitespace-nowrap",children:e.path})]}),(0,n.jsx)(tu,{status:e.status})]},e.id))}),(0,n.jsx)("div",{className:"p-2 border-t border-[#3a3a4e]",children:(0,n.jsxs)("button",{className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-transparent border border-dashed border-[#3a3a4e] rounded-md text-[#888] text-[13px] cursor-pointer transition-all hover:bg-white/5 hover:border-[#4a4a5e] hover:text-[#e8e8e8]",onClick:o,children:[(0,n.jsx)(tp,{}),"Add Workspace"]})})]})]})}function tx(e){let{provider:t}=e,r={claude:"\uD83E\uDD16",codex:"\uD83E\uDDE0",gemini:"✨",generic:"\uD83D\uDCC1"};return(0,n.jsx)("span",{className:"text-base",title:t,children:r[t]||r.generic})}function tu(e){let{status:t}=e,r={active:"bg-green-500",inactive:"bg-gray-500",error:"bg-red-500"};return(0,n.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat(r[t]||r.inactive),title:t})}function tm(e){let{isOpen:t}=e;return(0,n.jsx)("svg",{className:"text-[#666] transition-transform ".concat(t?"rotate-180":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function th(){return(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,n.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]})}function tp(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function tg(e){let{isOpen:t,onClose:r,onAdd:a,isAdding:o=!1,error:l}=e,[i,c]=(0,s.useState)(""),[d,x]=(0,s.useState)(""),[u,m]=(0,s.useState)(null),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{t&&h.current&&h.current.focus()},[t]),(0,s.useEffect)(()=>{t||(c(""),x(""),m(null))},[t]);let p=async e=>{if(e.preventDefault(),!i.trim()){m("Path is required");return}try{await a(i.trim(),d.trim()||void 0),r()}catch(e){m(e instanceof Error?e.message:"Failed to add workspace")}};if(!t)return null;let g=l||u;return(0,n.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[9999] backdrop-blur-sm",onClick:r,onKeyDown:e=>{"Escape"===e.key&&r()},children:(0,n.jsxs)("div",{className:"bg-[#1a1a2e] border border-[#3a3a4e] rounded-xl p-6 min-w-[450px] max-w-[90vw] shadow-[0_20px_60px_rgba(0,0,0,0.5)]",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,n.jsx)("h2",{className:"m-0 text-lg font-semibold text-[#e8e8e8]",children:"Add Workspace"}),(0,n.jsx)("button",{className:"bg-transparent border-none text-[#666] cursor-pointer p-1 flex items-center justify-center rounded transition-all hover:bg-white/10 hover:text-[#e8e8e8]",onClick:r,children:(0,n.jsx)(tf,{})})]}),(0,n.jsxs)("form",{onSubmit:p,children:[(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("label",{htmlFor:"workspace-path",className:"block mb-2 text-[13px] font-medium text-[#e8e8e8]",children:"Repository Path"}),(0,n.jsx)("input",{ref:h,id:"workspace-path",type:"text",value:i,onChange:e=>{c(e.target.value),m(null)},placeholder:"/path/to/repository",disabled:o,autoComplete:"off",className:"w-full px-3 py-2.5 bg-[#2a2a3e] border border-[#3a3a4e] rounded-md text-[#e8e8e8] text-sm outline-none transition-colors box-border focus:border-[#00c896] placeholder:text-[#666] disabled:opacity-60 disabled:cursor-not-allowed"}),(0,n.jsx)("p",{className:"mt-1.5 text-xs text-[#666] leading-relaxed",children:"Enter the full path to your repository. Use ~ for home directory."})]}),(0,n.jsxs)("div",{className:"mb-5",children:[(0,n.jsx)("label",{htmlFor:"workspace-name",className:"block mb-2 text-[13px] font-medium text-[#e8e8e8]",children:"Display Name (optional)"}),(0,n.jsx)("input",{id:"workspace-name",type:"text",value:d,onChange:e=>x(e.target.value),placeholder:"My Project",disabled:o,autoComplete:"off",className:"w-full px-3 py-2.5 bg-[#2a2a3e] border border-[#3a3a4e] rounded-md text-[#e8e8e8] text-sm outline-none transition-colors box-border focus:border-[#00c896] placeholder:text-[#666] disabled:opacity-60 disabled:cursor-not-allowed"}),(0,n.jsx)("p",{className:"mt-1.5 text-xs text-[#666] leading-relaxed",children:"A friendly name for this workspace. Defaults to the folder name."})]}),g&&(0,n.jsx)("div",{className:"px-3 py-2.5 bg-red-500/10 border border-red-500/30 rounded-md text-red-500 text-[13px] mb-5",children:g}),(0,n.jsxs)("div",{className:"flex gap-3 justify-end mt-6",children:[(0,n.jsx)("button",{type:"button",className:"px-5 py-2.5 rounded-md text-sm font-medium cursor-pointer transition-all bg-transparent border border-[#3a3a4e] text-[#e8e8e8] hover:bg-white/5 disabled:opacity-50 disabled:cursor-not-allowed",onClick:r,disabled:o,children:"Cancel"}),(0,n.jsx)("button",{type:"submit",className:"px-5 py-2.5 rounded-md text-sm font-medium cursor-pointer transition-all bg-[#00c896] border-none text-[#1a1a2e] hover:bg-[#00a87d] disabled:opacity-50 disabled:cursor-not-allowed",disabled:o||!i.trim(),children:o?"Adding...":"Add Workspace"})]})]})]})})}function tf(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}let tb=0;function tj(){return"log-".concat(Date.now(),"-").concat(++tb)}function ty(e){let{agentName:t,mode:r="panel",maxHeight:o="500px",showHeader:l=!0,autoScrollDefault:i=!0,onClose:c,onExpand:d,className:x=""}=e,[u,m]=(0,s.useState)(""),[h,p]=(0,s.useState)(!1),[g,f]=(0,s.useState)(i),[b,j]=(0,s.useState)("all"),y=(0,s.useRef)(null),v=(0,s.useRef)(null),{logs:w,isConnected:N,isConnecting:k,error:C,connect:S,disconnect:A,clear:L}=function(e){let{agentName:t,maxLines:r=5e3,autoConnect:n=!0,reconnect:a=!0,maxReconnectAttempts:o=1/0}=e,[l,i]=(0,s.useState)([]),[c,d]=(0,s.useState)(!1),[x,u]=(0,s.useState)(!1),[m,h]=(0,s.useState)(null),p=(0,s.useRef)(null),g=(0,s.useRef)(0),f=(0,s.useRef)(null),b=(0,s.useRef)(t),j=(0,s.useRef)(!0),y=(0,s.useRef)(!1),v=(0,s.useRef)(new WeakMap),w=(0,s.useRef)(new WeakMap);b.current=t;let N=(0,s.useCallback)(()=>{var e,t;if(j.current=!0,(null===(e=p.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN||(null===(t=p.current)||void 0===t?void 0:t.readyState)===WebSocket.CONNECTING||y.current)return;y.current=!0,u(!0),h(null);let n=function(e){let t="/ws/logs/".concat(encodeURIComponent(e)),r="https:"===window.location.protocol?"wss:":"ws:",{hostname:n,port:s}=window.location;return"".concat(r,"//").concat(window.location.host).concat(t)}(b.current);try{let e=new WebSocket(n);p.current=e,v.current.set(e,!1),w.current.set(e,!1),e.onopen=()=>{y.current=!1,d(!0),u(!1),h(null),g.current=0,i(e=>[...e,{id:tj(),timestamp:Date.now(),content:"Connected to ".concat(b.current," log stream"),type:"system",agentName:b.current}])},e.onclose=t=>{var r,n;let s=null!==(r=v.current.get(e))&&void 0!==r&&r,l=null!==(n=w.current.get(e))&&void 0!==n&&n;if(y.current=!1,d(!1),u(!1),p.current=null,f.current&&(clearTimeout(f.current),f.current=null),!s&&4404!==t.code){if(!t.wasClean&&l){let e=j.current&&a&&g.current<o;i(r=>[...r,{id:tj(),timestamp:Date.now(),content:e?"Lost connection to log stream (code: ".concat(t.code,"). Reconnecting..."):"Disconnected from log stream (code: ".concat(t.code,")"),type:"system",agentName:b.current}])}if(j.current&&a&&g.current<o){let e=Math.min(1e3*Math.pow(2,g.current),3e4);g.current++,f.current=setTimeout(()=>{N()},e)}}},e.onerror=()=>{y.current=!1,h(Error("WebSocket connection error")),u(!1)},e.onmessage=t=>{try{let n=JSON.parse(t.data);if("error"===n.type){h(Error(n.error||"Failed to stream logs for ".concat(n.agent||b.current))),i(e=>[...e,{id:tj(),timestamp:Date.now(),content:"Error: ".concat(n.error||"Unknown error"),type:"system",agentName:n.agent||b.current}]);return}if("subscribed"===n.type){console.log("[useAgentLogs] Subscribed to ".concat(n.agent));return}if("history"===n.type&&Array.isArray(n.lines)){n.lines.length>0&&w.current.set(e,!0),i(e=>{let t=n.lines.map(e=>({id:tj(),timestamp:Date.now(),content:e,type:"stdout",agentName:n.agent||b.current}));return[...e,...t].slice(-r)});return}"string"==typeof n?(w.current.set(e,!0),i(e=>[...e,{id:tj(),timestamp:Date.now(),content:n,type:"stdout",agentName:b.current}].slice(-r))):"log"===n.type||"output"===n.type?(w.current.set(e,!0),i(e=>{let t="stderr"===n.stream?"stderr":"stdout";return[...e,{id:tj(),timestamp:n.timestamp||Date.now(),content:n.content||n.data||n.message||"",type:t,agentName:n.agentName||b.current}].slice(-r)})):n.lines&&Array.isArray(n.lines)&&(w.current.set(e,!0),i(e=>{let t=n.lines.map(e=>{let t="object"==typeof e&&"stderr"===e.type?"stderr":"stdout";return{id:tj(),timestamp:Date.now(),content:"string"==typeof e?e:e.content,type:t,agentName:b.current}});return[...e,...t].slice(-r)}))}catch(n){"string"==typeof t.data&&(w.current.set(e,!0),i(e=>[...e,{id:tj(),timestamp:Date.now(),content:t.data,type:"stdout",agentName:b.current}].slice(-r)))}}}catch(e){y.current=!1,h(e instanceof Error?e:Error("Failed to create WebSocket")),u(!1)}},[r,a,o]),k=(0,s.useCallback)(()=>{j.current=!1,f.current&&(clearTimeout(f.current),f.current=null),p.current&&(v.current.set(p.current,!0),p.current.close(),p.current=null),y.current=!1,d(!1),u(!1)},[]),C=(0,s.useCallback)(()=>{i([])},[]);return(0,s.useEffect)(()=>(n&&t&&N(),()=>{k()}),[t,n,N,k]),{logs:l,isConnected:c,isConnecting:x,error:m,connect:N,disconnect:k,clear:C}}({agentName:t,autoConnect:!0}),W=(0,a.GW)(t),E=(0,s.useMemo)(()=>{let e=w;if("all"!==b&&(e=e.filter(e=>e.type===b)),u.trim()){let t=u.toLowerCase();e=e.filter(e=>e.content.toLowerCase().includes(t))}return e},[w,b,u]);(0,s.useEffect)(()=>{if(g&&y.current){let e=y.current;e.scrollTop=e.scrollHeight}},[w,g]);let D=(0,s.useCallback)(()=>{if(!y.current)return;let e=y.current,t=e.scrollHeight-e.scrollTop-e.clientHeight<50;t&&!g?f(!0):!t&&g&&f(!1)},[g]);return((0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&"panel"===r&&(e.preventDefault(),p(!0),setTimeout(()=>{var e;return null===(e=v.current)||void 0===e?void 0:e.focus()},0)),"Escape"===e.key&&h&&(p(!1),m(""))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,h]),"inline"===r)?(0,n.jsxs)("div",{className:"log-viewer-inline rounded-lg overflow-hidden border border-[#2a2d35] ".concat(x),style:{background:"linear-gradient(180deg, #0d0f14 0%, #12151c 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.02), 0 4px 12px rgba(0,0,0,0.3)"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#2a2d35]",style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(tk,{}),(0,n.jsx)("span",{className:"text-xs font-medium",style:{color:W.primary},children:"Live logs"}),(0,n.jsx)(tw,{isConnected:N,isConnecting:k})]}),(0,n.jsx)("div",{className:"flex items-center gap-1",children:(0,n.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#21262d] text-[#8b949e] hover:text-accent-cyan transition-all duration-200 hover:shadow-[0_0_8px_rgba(0,217,255,0.15)]",onClick:d,title:"Expand",children:(0,n.jsx)(tL,{})})})]}),(0,n.jsxs)("div",{className:"font-mono text-xs leading-relaxed p-3 overflow-y-auto",style:{maxHeight:"150px"},ref:y,onScroll:D,children:[E.slice(-20).map(e=>(0,n.jsx)(tv,{log:e,compact:!0},e.id)),0===E.length&&(0,n.jsxs)("div",{className:"text-[#484f58] italic flex items-center gap-2",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58] animate-pulse"}),"Waiting for output..."]})]})]}):(0,n.jsxs)("div",{className:"log-viewer-panel flex flex-col rounded-xl overflow-hidden border border-[#2a2d35] shadow-2xl ".concat(x),style:{background:"linear-gradient(180deg, #0d0f14 0%, #0a0c10 100%)",boxShadow:"0 0 60px -15px ".concat(W.primary,"25, 0 25px 50px -12px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255,255,255,0.02)")},children:[l&&(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[#21262d]",style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsxs)("div",{className:"flex gap-1.5",children:[(0,n.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#ff5f56] border border-[#e0443e] transition-shadow hover:shadow-[0_0_8px_rgba(255,95,86,0.5)]"}),(0,n.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#ffbd2e] border border-[#dea123] transition-shadow hover:shadow-[0_0_8px_rgba(255,189,46,0.5)]"}),(0,n.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27c93f] border border-[#1aab29] transition-shadow hover:shadow-[0_0_8px_rgba(39,201,63,0.5)]"})]})}),(0,n.jsx)("div",{className:"w-px h-4 bg-[#30363d]"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(tk,{}),(0,n.jsx)("span",{className:"text-sm font-semibold",style:{color:W.primary},children:t}),(0,n.jsx)(tw,{isConnected:N,isConnecting:k})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("button",{className:"p-1.5 rounded-lg transition-all duration-200 ".concat(h?"bg-accent-cyan/20 text-accent-cyan shadow-[0_0_12px_rgba(0,217,255,0.25)]":"hover:bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9]"),onClick:()=>{p(!h),h||setTimeout(()=>{var e;return null===(e=v.current)||void 0===e?void 0:e.focus()},0)},title:"Search (Cmd+F)",children:(0,n.jsx)(tC,{})}),(0,n.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9] transition-all duration-200 hover:shadow-[0_0_8px_rgba(255,255,255,0.1)]",onClick:L,title:"Clear logs",children:(0,n.jsx)(tS,{})}),(0,n.jsx)("button",{className:"p-1.5 rounded-lg transition-all duration-200 ".concat(g?"bg-[#3fb950]/20 text-[#3fb950] shadow-[0_0_12px_rgba(63,185,80,0.25)]":"hover:bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9]"),onClick:()=>f(!g),title:g?"Auto-scroll ON":"Auto-scroll OFF",children:(0,n.jsx)(tA,{})}),(0,n.jsx)("button",{className:"p-1.5 rounded-lg transition-all duration-200 ".concat(N?"hover:bg-[#f85149]/10 text-[#8b949e] hover:text-[#f85149] hover:shadow-[0_0_8px_rgba(248,81,73,0.2)]":"bg-[#3fb950]/20 text-[#3fb950] shadow-[0_0_12px_rgba(63,185,80,0.25)]"),onClick:N?A:S,title:N?"Disconnect":"Connect",children:N?(0,n.jsx)(tD,{}):(0,n.jsx)(tE,{})}),c&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"w-px h-4 bg-[#30363d] mx-1"}),(0,n.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#f85149]/10 text-[#8b949e] hover:text-[#f85149] transition-all duration-200 hover:shadow-[0_0_8px_rgba(248,81,73,0.2)]",onClick:c,title:"Close",children:(0,n.jsx)(tW,{})})]})]})]}),h&&(0,n.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-[#21262d] bg-[#161b22]",children:[(0,n.jsx)(tC,{}),(0,n.jsx)("input",{ref:v,type:"text",className:"flex-1 bg-transparent border-none text-sm text-[#c9d1d9] placeholder:text-[#484f58] outline-none font-mono",placeholder:"Search logs...",value:u,onChange:e=>m(e.target.value)}),(0,n.jsx)("div",{className:"flex items-center gap-1",children:["all","stdout","stderr","system"].map(e=>(0,n.jsx)("button",{className:"px-2 py-0.5 text-xs rounded transition-colors ".concat(b===e?"bg-[#238636] text-white":"bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9]"),onClick:()=>j(e),children:e},e))}),(0,n.jsxs)("span",{className:"text-xs text-[#484f58] tabular-nums",children:[E.length," / ",w.length]})]}),C&&(0,n.jsxs)("div",{className:"px-4 py-2 bg-[#3d1d20] border-b border-[#f85149]/30 text-sm text-[#f85149] flex items-center gap-2",children:[(0,n.jsx)(tM,{}),(0,n.jsx)("span",{children:C.message}),(0,n.jsx)("button",{className:"ml-auto text-xs px-2 py-0.5 rounded bg-[#f85149]/20 hover:bg-[#f85149]/30 transition-colors",onClick:S,children:"Retry"})]}),(0,n.jsx)("div",{ref:y,className:"flex-1 overflow-y-auto overflow-x-hidden font-mono text-sm p-4",style:{maxHeight:o},onScroll:D,children:0===E.length?(0,n.jsx)("div",{className:"flex flex-col items-center justify-center h-full text-[#484f58] gap-3",children:k?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t_,{}),(0,n.jsxs)("span",{children:["Connecting to ",t,"..."]})]}):0===w.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tk,{size:32}),(0,n.jsx)("span",{children:"Waiting for output..."})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(tC,{}),(0,n.jsxs)("span",{children:['No matches for "',u,'"']})]})}):(0,n.jsx)("div",{className:"space-y-px",children:E.map((e,t)=>(0,n.jsx)(tv,{log:e,showTimestamp:!0,isHighlighted:!!(u&&e.content.toLowerCase().includes(u.toLowerCase())),searchQuery:u,lineNumber:t+1},e.id))})}),(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-t border-[#21262d] text-xs",style:{background:"linear-gradient(180deg, #0d1117 0%, #0a0c10 100%)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("span",{className:"tabular-nums font-mono text-[#6e7681]",children:[w.length," lines"]}),!g&&(0,n.jsxs)("button",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-accent-cyan/10 text-accent-cyan transition-all duration-200 hover:bg-accent-cyan/20 hover:shadow-[0_0_8px_rgba(0,217,255,0.2)]",onClick:()=>{f(!0),y.current&&(y.current.scrollTop=y.current.scrollHeight)},children:[(0,n.jsx)(tA,{}),(0,n.jsx)("span",{className:"font-medium",children:"Jump to bottom"})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-[#6e7681] font-mono uppercase tracking-wider text-[10px]",children:"PTY stream"}),(0,n.jsx)("div",{className:"w-2 h-2 rounded-full transition-all duration-300 ".concat(N?"bg-[#3fb950]":k?"bg-[#d29922] animate-pulse":"bg-[#484f58]"),style:{boxShadow:N?"0 0 8px rgba(63,185,80,0.6)":"none"}})]})]})]})}function tv(e){let{log:t,compact:r=!1,showTimestamp:a=!1,isHighlighted:o=!1,searchQuery:l="",lineNumber:i}=e,[c,d]=(0,s.useState)(!1),x=new Date(t.timestamp).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),u=!r&&t.content.length>200,m=()=>{switch(t.type){case"stderr":return"text-[#f85149]";case"system":return"text-[#58a6ff] italic";case"input":return"text-[#d29922]";default:return"text-[#c9d1d9]"}};if(r)return(0,n.jsx)("div",{className:"".concat(m()," leading-5 whitespace-pre-wrap break-all min-w-0 overflow-hidden"),children:tN(t.content)});let h=u&&!c?t.content.slice(0,150)+"...":t.content;return(0,n.jsxs)("div",{className:"group flex gap-2 py-1 px-2 -mx-2 rounded-md transition-all duration-150 ".concat(o?"bg-[#634d00]/30 border-l-2 border-[#ffdf5d]":"hover:bg-[#161b22]/80 border-l-2 border-transparent"),children:[void 0!==i&&(0,n.jsx)("span",{className:"w-10 text-right text-[#484f58] select-none shrink-0 tabular-nums font-mono text-[11px] opacity-60 group-hover:opacity-100 transition-opacity",children:i}),a&&(0,n.jsx)("span",{className:"text-[#484f58] select-none shrink-0 tabular-nums font-mono text-[11px] opacity-80 group-hover:opacity-100 transition-opacity",children:x}),(0,n.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,n.jsx)("span",{className:"whitespace-pre-wrap break-all leading-relaxed ".concat(m()),children:(e=>{if(!l||!l.trim())return tN(e);let t=RegExp("(".concat(l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),")"),"gi");return e.split(t).map((e,t)=>e.toLowerCase()===l.toLowerCase()?(0,n.jsx)("mark",{className:"bg-[#634d00] text-[#ffdf5d] rounded px-0.5",children:e},t):tN(e))})(h)}),u&&(0,n.jsx)("button",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded bg-[#21262d] text-[#8b949e] hover:text-accent-cyan hover:bg-[#30363d] transition-all duration-200",onClick:()=>d(!c),children:c?"▲ Collapse":"▼ Show more (".concat(t.content.length," chars)")})]}),"stderr"===t.type&&(0,n.jsx)("span",{className:"shrink-0 text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded",style:{color:"#f85149",background:"rgba(248, 81, 73, 0.15)"},children:"err"})]})}function tw(e){let{isConnected:t,isConnecting:r}=e;return r?(0,n.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#d29922]/20 text-[10px] text-[#d29922] uppercase tracking-wider",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#d29922] animate-pulse"}),"connecting"]}):t?(0,n.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#238636]/20 text-[10px] text-[#3fb950] uppercase tracking-wider",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#3fb950] shadow-[0_0_4px_rgba(63,185,80,0.5)]"}),"live"]}):(0,n.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#484f58]/20 text-[10px] text-[#484f58] uppercase tracking-wider",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58]"}),"offline"]})}function tN(e){let t;let r=e.replace(/\x1b\].*?(?:\x07|\x1b\\)/g,"").replace(/\x1b\[[0-9;?]*[A-LNS-Zsu]/gi,"").replace(/\x1b[78()]/g,"").replace(/\r/g,"").replace(/^\[\??\d+[hlKJHfABCDGPXsu]/gm,""),s=/\x1b\[(\d+(?:;\d+)*)m/g;if(!s.test(r))return r;s.lastIndex=0;let a=[],o=0,l={};for(;null!==(t=s.exec(r));){t.index>o&&a.push((0,n.jsx)("span",{style:l,children:r.slice(o,t.index)},"text-".concat(o)));let e=t[1].split(";").map(Number);l={...l,...function(e){let t={};for(let r of e)switch(r){case 0:return{};case 1:t.fontWeight="bold";break;case 2:t.opacity="0.7";break;case 3:t.fontStyle="italic";break;case 4:t.textDecoration="underline";break;case 30:t.color="#484f58";break;case 31:t.color="#f85149";break;case 32:t.color="#3fb950";break;case 33:t.color="#d29922";break;case 34:t.color="#58a6ff";break;case 35:t.color="#bc8cff";break;case 36:t.color="#39c5cf";break;case 37:t.color="#c9d1d9";break;case 90:t.color="#6e7681";break;case 91:t.color="#ff7b72";break;case 92:t.color="#56d364";break;case 93:t.color="#e3b341";break;case 94:t.color="#79c0ff";break;case 95:t.color="#d2a8ff";break;case 96:t.color="#56d4dd";break;case 97:t.color="#f0f6fc"}return t}(e)},o=t.index+t[0].length}return o<r.length&&a.push((0,n.jsx)("span",{style:l,children:r.slice(o)},"text-".concat(o))),a.length>0?(0,n.jsx)(n.Fragment,{children:a}):r}function tk(e){let{size:t=16}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#8b949e]",children:[(0,n.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function tC(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-[#8b949e]",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function tS(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function tA(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("polyline",{points:"19 12 12 19 5 12"})]})}function tL(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,n.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,n.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,n.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}function tW(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tE(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})}function tD(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,n.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]})}function tM(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function t_(){return(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"animate-spin",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"32",strokeLinecap:"round",className:"text-[#484f58]"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"32",strokeDashoffset:"24",strokeLinecap:"round",className:"text-[#3fb950]"})]})}function tB(e){let{agent:t,position:r="right",isOpen:o,onClose:l,onAgentChange:i,availableAgents:c=[]}=e,d=(0,a.GW)(t.name);return((0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&o&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,l]),(0,s.useEffect)(()=>{if(o&&"fullscreen"===r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o,r]),o)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"fixed inset-0 bg-black/60 z-[1099] animate-fade-in",onClick:l}),(0,n.jsxs)("div",{className:"flex flex-col ".concat((()=>{switch(r){case"right":return"animate-slide-in-right";case"bottom":return"animate-slide-in-bottom";case"fullscreen":return"animate-fade-in"}})()),style:(()=>{let e={position:"fixed",zIndex:1100,background:"linear-gradient(180deg, #0d0f14 0%, #0a0c10 100%)"};switch(r){case"right":return{...e,top:0,right:0,bottom:0,width:"600px",maxWidth:"100vw",borderLeft:"1px solid #21262d",boxShadow:"-20px 0 60px rgba(0, 0, 0, 0.5)"};case"bottom":return{...e,left:0,right:0,bottom:0,height:"400px",maxHeight:"60vh",borderTop:"1px solid #21262d",boxShadow:"0 -20px 60px rgba(0, 0, 0, 0.5)"};case"fullscreen":return{...e,inset:0}}})(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-[#21262d]",style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,n.jsxs)("div",{className:"flex items-center gap-4",children:[(0,n.jsxs)("div",{className:"relative shrink-0 w-11 h-11 rounded-xl flex items-center justify-center text-sm font-bold overflow-hidden",style:{backgroundColor:d.primary,color:d.text,boxShadow:"0 0 24px ".concat(d.primary,"50, inset 0 1px 0 rgba(255,255,255,0.2)")},children:[(0,n.jsx)("div",{className:"absolute inset-0 opacity-30",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.35) 0%, transparent 50%)"}}),(0,n.jsx)("span",{className:"relative z-10",children:(0,a.hP)(t.name)})]}),(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold m-0",style:{color:d.primary},children:t.name}),(0,n.jsx)("span",{className:"px-2.5 py-0.5 rounded-md text-[10px] uppercase tracking-wider font-medium ".concat("online"===t.status?"bg-[#3fb950]/15 text-[#3fb950]":"busy"===t.status?"bg-[#d29922]/15 text-[#d29922]":"bg-[#484f58]/15 text-[#484f58]"),style:{boxShadow:"online"===t.status?"0 0 8px rgba(63,185,80,0.2)":"none"},children:t.status})]}),t.currentTask&&(0,n.jsx)("span",{className:"text-sm text-[#8b949e] truncate max-w-[300px] mt-0.5",children:t.currentTask})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[c.length>1&&i&&(0,n.jsx)(tT,{agents:c,currentAgent:t,onSelect:i}),(0,n.jsxs)("div",{className:"flex items-center gap-1 bg-[#21262d]/80 rounded-lg p-1 border border-[#30363d]/50",children:[(0,n.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("right"===r?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Sidebar view",children:(0,n.jsx)(tP,{})}),(0,n.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("bottom"===r?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Bottom panel",children:(0,n.jsx)(tF,{})}),(0,n.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("fullscreen"===r?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Fullscreen",children:(0,n.jsx)(tU,{})})]}),(0,n.jsx)("button",{className:"p-2 rounded-lg text-[#8b949e] hover:text-[#f85149] hover:bg-[#f85149]/10 transition-all duration-200 hover:shadow-[0_0_8px_rgba(248,81,73,0.2)]",onClick:l,children:(0,n.jsx)(tR,{})})]})]}),(0,n.jsx)("div",{className:"flex-1 min-h-0",children:(0,n.jsx)(ty,{agentName:t.name,mode:"panel",showHeader:!1,maxHeight:"100%",className:"h-full rounded-none border-none"})})]}),(0,n.jsx)("style",{children:"\n @keyframes slideInRight {\n from {\n transform: translateX(100%);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n }\n\n @keyframes slideInBottom {\n from {\n transform: translateY(100%);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n }\n\n .animate-slide-in-right {\n animation: slideInRight 0.3s cubic-bezier(0.32, 0.72, 0, 1);\n }\n\n .animate-slide-in-bottom {\n animation: slideInBottom 0.3s cubic-bezier(0.32, 0.72, 0, 1);\n }\n "})]}):null}function tT(e){let{agents:t,currentAgent:r,onSelect:o}=e,[l,i]=s.useState(!1),c=s.useRef(null);return(0,s.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.jsxs)("div",{className:"relative",ref:c,children:[(0,n.jsxs)("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#21262d] hover:bg-[#30363d] rounded-lg text-sm text-[#c9d1d9] transition-colors",onClick:()=>i(!l),children:[(0,n.jsx)("span",{children:"Switch agent"}),(0,n.jsx)(tO,{})]}),l&&(0,n.jsx)("div",{className:"absolute right-0 top-full mt-2 w-64 bg-[#161b22] border border-[#30363d] rounded-lg shadow-xl overflow-hidden z-10",children:(0,n.jsx)("div",{className:"max-h-64 overflow-y-auto",children:t.map(e=>{let t=(0,a.GW)(e.name),s=e.name===r.name;return(0,n.jsxs)("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left transition-colors ".concat(s?"bg-[#238636]/20":"hover:bg-[#21262d]"),onClick:()=>{o(e),i(!1)},children:[(0,n.jsx)("div",{className:"w-8 h-8 rounded flex items-center justify-center text-xs font-semibold shrink-0",style:{backgroundColor:t.primary,color:t.text},children:(0,a.hP)(e.name)}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-sm text-[#c9d1d9] truncate",children:e.name}),(0,n.jsx)("div",{className:"text-xs text-[#8b949e]",children:e.status})]}),s&&(0,n.jsx)(tz,{})]},e.name)})})})]})}function tR(){return(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tP(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}function tF(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,n.jsx)("line",{x1:"3",y1:"15",x2:"21",y2:"15"})]})}function tU(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,n.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,n.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,n.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}function tO(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function tz(){return(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3fb950",strokeWidth:"2",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function tH(e){let{typingUsers:t}=e;return 0===t.length?null:(0,n.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-sm text-[#8d8d8e]",children:[(0,n.jsx)("div",{className:"flex -space-x-1.5",children:t.slice(0,3).map(e=>(0,n.jsx)("div",{className:"relative",title:e.username,children:e.avatarUrl?(0,n.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-5 h-5 rounded-full border border-[#1a1d21]"}):(0,n.jsx)("div",{className:"w-5 h-5 rounded-full bg-[#a855f7] border border-[#1a1d21] flex items-center justify-center text-[9px] text-white font-medium",children:e.username.charAt(0).toUpperCase()})},e.username))}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[1===t.length?"".concat(t[0].username," is typing"):2===t.length?"".concat(t[0].username," and ").concat(t[1].username," are typing"):"".concat(t[0].username," and ").concat(t.length-1," others are typing"),(0,n.jsxs)("span",{className:"flex gap-0.5",children:[(0,n.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"0ms"}}),(0,n.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"150ms"}}),(0,n.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})]})]})}function tI(e){let{onlineUsers:t,onUserClick:r,maxAvatars:a=4}=e,[o,l]=(0,s.useState)(!1),i=(0,s.useRef)(null);if((0,s.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&l(!1)};return o&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]),0===t.length)return null;let c=t.slice(0,a),d=Math.max(0,t.length-a);return(0,n.jsxs)("div",{className:"relative",ref:i,children:[(0,n.jsxs)("button",{onClick:()=>l(!o),className:"flex items-center gap-1.5 px-2 py-1 rounded-md hover:bg-white/[0.05] transition-colors",title:"".concat(t.length," user").concat(1!==t.length?"s":""," online"),children:[(0,n.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),(0,n.jsxs)("div",{className:"flex -space-x-1.5",children:[c.map(e=>(0,n.jsx)("div",{className:"relative ring-2 ring-[#1a1d21] rounded-full",title:e.username,children:e.avatarUrl?(0,n.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-6 h-6 rounded-full object-cover"}):(0,n.jsx)("div",{className:"w-6 h-6 rounded-full bg-[#a855f7] flex items-center justify-center text-[10px] text-white font-medium",children:e.username.charAt(0).toUpperCase()})},e.username)),d>0&&(0,n.jsxs)("div",{className:"w-6 h-6 rounded-full bg-[#3d4043] ring-2 ring-[#1a1d21] flex items-center justify-center text-[10px] text-[#d1d2d3] font-medium",children:["+",d]})]}),(0,n.jsxs)("span",{className:"text-xs text-[#8d8d8e]",children:[t.length," online"]})]}),o&&(0,n.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-[#1a1d21] border border-white/10 rounded-lg shadow-xl z-50 max-h-[300px] overflow-y-auto",children:[(0,n.jsx)("div",{className:"p-2 border-b border-white/10",children:(0,n.jsx)("h3",{className:"text-sm font-medium text-[#d1d2d3]",children:"Online Users"})}),(0,n.jsx)("div",{className:"py-1",children:t.map(e=>(0,n.jsxs)("button",{onClick:()=>{null==r||r(e),l(!1)},className:"w-full flex items-center gap-3 px-3 py-2 hover:bg-white/[0.05] transition-colors text-left",children:[(0,n.jsxs)("div",{className:"relative",children:[e.avatarUrl?(0,n.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-8 h-8 rounded-full object-cover"}):(0,n.jsx)("div",{className:"w-8 h-8 rounded-full bg-[#a855f7] flex items-center justify-center text-xs text-white font-medium",children:e.username.charAt(0).toUpperCase()}),(0,n.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-green-500 rounded-full border-2 border-[#1a1d21]"})]}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium text-[#d1d2d3] truncate",children:e.username}),(0,n.jsxs)("div",{className:"text-xs text-[#8d8d8e]",children:["Online since ",function(e){let t=new Date(e),r=new Date;return t.toDateString()===r.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(e.connectedAt)]})]})]},e.username))})]})]})}function tV(e){let{user:t,onClose:r,onMention:a}=e,o=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return t&&window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,r]);let l=(0,s.useRef)(!1);if((0,s.useEffect)(()=>{t&&(l.current=!0)},[t]),(0,s.useEffect)(()=>{let e=e=>{if(l.current){l.current=!1;return}o.current&&!o.current.contains(e.target)&&r()};if(t)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[t,r]),!t)return null;let i="https://github.com/".concat(t.username);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40"}),(0,n.jsxs)("div",{ref:o,className:"fixed right-0 top-0 h-full w-80 bg-[#1a1d21] border-l border-white/10 shadow-2xl z-50 flex flex-col animate-slide-in-right",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,n.jsx)("h2",{className:"text-lg font-semibold text-[#d1d2d3]",children:"Profile"}),(0,n.jsx)("button",{onClick:r,className:"p-1 hover:bg-white/10 rounded-md transition-colors",title:"Close",children:(0,n.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,n.jsxs)("div",{className:"flex flex-col items-center p-6 border-b border-white/10",children:[(0,n.jsxs)("div",{className:"relative mb-4",children:[t.avatarUrl?(0,n.jsx)("img",{src:t.avatarUrl,alt:t.username,className:"w-24 h-24 rounded-full object-cover border-4 border-[#a855f7]/30"}):(0,n.jsx)("div",{className:"w-24 h-24 rounded-full bg-[#a855f7] flex items-center justify-center text-3xl text-white font-bold border-4 border-[#a855f7]/30",children:t.username.charAt(0).toUpperCase()}),(0,n.jsx)("div",{className:"absolute bottom-1 right-1 w-5 h-5 bg-green-500 rounded-full border-4 border-[#1a1d21]"})]}),(0,n.jsx)("h3",{className:"text-xl font-semibold text-[#d1d2d3] mb-1",children:t.username}),(0,n.jsxs)("span",{className:"text-sm text-green-400 flex items-center gap-1.5",children:[(0,n.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),"Online"]})]}),(0,n.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Online Since"}),(0,n.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:tG(t.connectedAt)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Last Active"}),(0,n.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:tG(t.lastSeen)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"GitHub"}),(0,n.jsxs)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 mt-1 text-sm text-[#a855f7] hover:text-[#c084fc] transition-colors",children:[(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"@",t.username,(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,n.jsx)("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3"})})]})]})]})}),(0,n.jsxs)("div",{className:"p-4 border-t border-white/10 space-y-2",children:[(0,n.jsxs)("button",{onClick:()=>{null==a||a(t.username),r()},className:"w-full flex items-center justify-center gap-2 py-2.5 bg-[#a855f7] hover:bg-[#9333ea] text-white font-medium rounded-lg transition-colors",children:[(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,n.jsx)("path",{d:"M16 8v5a3 3 0 006 0v-1a10 10 0 10-3.92 7.94"})]}),"Mention @",t.username]}),(0,n.jsxs)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"w-full flex items-center justify-center gap-2 py-2.5 border border-white/20 text-[#d1d2d3] hover:bg-white/5 font-medium rounded-lg transition-colors",children:[(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"View on GitHub"]})]})]})]})}function tG(e){return new Date(e).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function tK(e){let{isOpen:t,onClose:r,projects:a,isCloudMode:o=!1,hasArchitect:l=!1,onArchitectSpawned:i}=e,[c,d]=(0,s.useState)([]),[x,u]=(0,s.useState)(!1),[m,h]=(0,s.useState)(null),[p,g]=(0,s.useState)(!1),[f,b]=(0,s.useState)(""),[j,y]=(0,s.useState)(new Set),[v,w]=(0,s.useState)(!1),[N,k]=(0,s.useState)("claude");(0,s.useEffect)(()=>{t&&o&&C()},[t,o]);let C=async()=>{u(!0),h(null);try{let e=await fetch("/api/project-groups");if(e.ok){let t=await e.json();d(t.groups||[])}else h("Failed to load project groups")}catch(e){h("Failed to load project groups")}finally{u(!1)}},S=async()=>{if(f.trim()&&0!==j.size){u(!0),h(null);try{let e=await fetch("/api/project-groups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:f,repositoryIds:Array.from(j)})});if(e.ok){let t=await e.json();t.group&&(d(e=>[...e,t.group]),g(!1),b(""),y(new Set))}else h("Failed to create project group")}catch(e){h("Failed to create project group")}finally{u(!1)}}},A=async(e,t)=>{h(null);try{let r="/api/project-groups/".concat(e,"/coordinator/").concat(t?"enable":"disable");(await fetch(r,{method:"POST"})).ok?d(r=>r.map(r=>r.id===e?{...r,coordinator:{...r.coordinator,enabled:t,status:t?"starting":"stopped"}}:r)):h("Failed to ".concat(t?"enable":"disable"," coordinator"))}catch(e){h("Failed to ".concat(t?"enable":"disable"," coordinator"))}},L=async e=>{if(window.confirm("Delete this project group? The coordinator will be stopped."))try{(await fetch("/api/project-groups/".concat(e),{method:"DELETE"})).ok?d(t=>t.filter(t=>t.id!==e)):h("Failed to delete project group")}catch(e){h("Failed to delete project group")}},W=e=>{y(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};if(!t)return null;let E=async()=>{w(!0),h(null);try{let e=await fetch("/api/spawn/architect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:N})}),t=await e.json();e.ok&&t.success?(null==i||i(),r()):h(t.error||"Failed to spawn Architect")}catch(e){h("Failed to spawn Architect")}finally{w(!1)}};if(!o){let e=a.length>1;return(0,n.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,n.jsxs)("div",{className:"bg-bg-secondary rounded-xl w-[500px] max-w-[90vw] max-h-[80vh] flex flex-col shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border-subtle",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(tJ,{}),(0,n.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Coordinator Agent"})]}),(0,n.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,children:(0,n.jsx)(tZ,{})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[m&&(0,n.jsx)("div",{className:"bg-error/10 border border-error/30 rounded-lg p-3 mb-4 text-error text-sm",children:m}),e&&(0,n.jsxs)("div",{className:"bg-gradient-to-r from-accent-purple/10 to-accent-cyan/10 border border-accent-purple/30 rounded-lg p-4 mb-4",children:[(0,n.jsxs)("h3",{className:"text-sm font-semibold text-text-primary mb-3 flex items-center gap-2",children:[(0,n.jsx)(tJ,{}),"Spawn Architect"]}),l?(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-success",children:[(0,n.jsx)(t0,{}),"Architect is running"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"text-sm text-text-secondary mb-4",children:["Spawn an Architect agent to coordinate across your ",a.length," connected projects."]}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("select",{className:"flex-1 py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-purple/50",value:N,onChange:e=>k(e.target.value),children:[(0,n.jsx)("option",{value:"claude",children:"Claude (default)"}),(0,n.jsx)("option",{value:"claude:opus",children:"Claude Opus"}),(0,n.jsx)("option",{value:"claude:sonnet",children:"Claude Sonnet"}),(0,n.jsx)("option",{value:"codex",children:"Codex"})]}),(0,n.jsx)("button",{className:"py-2 px-4 bg-gradient-to-r from-accent-purple to-accent-cyan text-bg-deep rounded-md text-sm font-semibold hover:shadow-lg transition-all disabled:opacity-50",onClick:E,disabled:v,children:v?"Spawning...":"Spawn"})]})]})]}),!e&&(0,n.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 mb-4 border border-border-subtle",children:[(0,n.jsx)("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Not in Bridge Mode"}),(0,n.jsx)("p",{className:"text-sm text-text-secondary",children:"The Architect coordinates multiple projects. Start bridge mode to enable:"}),(0,n.jsxs)("div",{className:"bg-bg-card rounded-lg p-3 font-mono text-sm mt-3",children:[(0,n.jsx)("span",{className:"text-text-muted",children:"$"})," ",(0,n.jsx)("span",{className:"text-accent-cyan",children:"relay bridge"})," ",(0,n.jsx)("span",{className:"text-accent-orange",children:"~/project1 ~/project2"})]})]}),(0,n.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 mb-4",children:[(0,n.jsx)("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"CLI Alternative"}),(0,n.jsxs)("p",{className:"text-sm text-text-secondary mb-3",children:["You can also spawn the Architect via CLI with the ",(0,n.jsx)("code",{className:"bg-bg-card px-1.5 py-0.5 rounded text-accent-cyan",children:"--architect"})," flag:"]}),(0,n.jsxs)("div",{className:"bg-bg-card rounded-lg p-3 font-mono text-sm",children:[(0,n.jsx)("span",{className:"text-text-muted",children:"$"})," ",(0,n.jsx)("span",{className:"text-accent-cyan",children:"relay bridge"})," ",(0,n.jsx)("span",{className:"text-accent-orange",children:"~/project1 ~/project2"})," ",(0,n.jsx)("span",{className:"text-accent-purple",children:"--architect"})]})]})]}),(0,n.jsx)("div",{className:"flex justify-end py-4 px-6 border-t border-border-subtle",children:(0,n.jsx)("button",{className:"py-2 px-5 bg-bg-tertiary border border-border-subtle rounded-md text-sm text-text-secondary cursor-pointer transition-colors duration-150 hover:bg-bg-hover",onClick:r,children:"Close"})})]})})}return(0,n.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,n.jsxs)("div",{className:"bg-bg-secondary rounded-xl w-[600px] max-w-[90vw] max-h-[80vh] flex flex-col shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border-subtle",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(tJ,{}),(0,n.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Coordinator Agents"})]}),(0,n.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,children:(0,n.jsx)(tZ,{})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[m&&(0,n.jsx)("div",{className:"bg-error/10 border border-error/30 rounded-lg p-3 mb-4 text-error text-sm",children:m}),x&&0===c.length?(0,n.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,n.jsx)(tq,{})}):(0,n.jsxs)(n.Fragment,{children:[c.length>0&&(0,n.jsxs)("div",{className:"space-y-3 mb-6",children:[(0,n.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Project Groups"}),c.map(e=>{var t,r,s,a;return(0,n.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-border-subtle",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-semibold text-text-primary",children:e.name}),(0,n.jsxs)("span",{className:"text-xs text-text-muted",children:[e.repositoryIds.length," repos"]})]}),(0,n.jsx)("button",{className:"text-text-muted hover:text-error transition-colors p-1",onClick:()=>L(e.id),title:"Delete group",children:(0,n.jsx)(tY,{})})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(t$,{status:(null===(t=e.coordinator)||void 0===t?void 0:t.status)||"stopped"}),(null===(r=e.coordinator)||void 0===r?void 0:r.name)&&(0,n.jsx)("span",{className:"text-sm text-text-secondary",children:e.coordinator.name})]}),(0,n.jsxs)("button",{className:"py-1.5 px-3 rounded-md text-xs font-medium transition-colors ".concat((null===(s=e.coordinator)||void 0===s?void 0:s.enabled)?"bg-error/20 text-error hover:bg-error/30":"bg-accent-cyan/20 text-accent-cyan hover:bg-accent-cyan/30"),onClick:()=>{var t;return A(e.id,!(null===(t=e.coordinator)||void 0===t?void 0:t.enabled))},children:[(null===(a=e.coordinator)||void 0===a?void 0:a.enabled)?"Stop":"Start"," Coordinator"]})]})]},e.id)})]}),p?(0,n.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-accent-cyan/30",children:[(0,n.jsx)("h4",{className:"text-sm font-semibold text-text-primary mb-4",children:"Create Project Group"}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Group Name"}),(0,n.jsx)("input",{type:"text",className:"w-full py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-cyan/50",placeholder:"e.g., Frontend Team",value:f,onChange:e=>b(e.target.value)})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Select Projects"}),(0,n.jsxs)("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:[a.map(e=>(0,n.jsxs)("label",{className:"flex items-center gap-2 p-2 bg-bg-card rounded-md cursor-pointer hover:bg-bg-hover",children:[(0,n.jsx)("input",{type:"checkbox",className:"accent-accent-cyan",checked:j.has(e.id),onChange:()=>W(e.id)}),(0,n.jsx)("span",{className:"text-sm text-text-primary",children:e.name||e.path})]},e.id)),0===a.length&&(0,n.jsx)("p",{className:"text-sm text-text-muted py-4 text-center",children:"No projects available. Add workspaces first."})]})]}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)("button",{className:"py-2 px-4 bg-transparent border border-border-subtle rounded-md text-sm text-text-secondary hover:bg-bg-hover",onClick:()=>{g(!1),b(""),y(new Set)},children:"Cancel"}),(0,n.jsx)("button",{className:"py-2 px-4 bg-accent-cyan text-bg-deep rounded-md text-sm font-medium hover:bg-accent-cyan/90 disabled:opacity-50",onClick:S,disabled:!f.trim()||0===j.size||x,children:"Create Group"})]})]})]}):(0,n.jsxs)("button",{className:"w-full py-3 px-4 border-2 border-dashed border-border-subtle rounded-lg text-text-muted hover:border-accent-cyan/50 hover:text-accent-cyan transition-colors flex items-center justify-center gap-2",onClick:()=>g(!0),children:[(0,n.jsx)(tX,{}),"Create Project Group"]}),(0,n.jsxs)("div",{className:"mt-6 p-4 bg-bg-tertiary/50 rounded-lg border border-border-subtle",children:[(0,n.jsxs)("h4",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center gap-2",children:[(0,n.jsx)(tQ,{}),"What is a Coordinator?"]}),(0,n.jsx)("p",{className:"text-sm text-text-secondary",children:"A coordinator is a high-level AI agent that oversees multiple projects. It can delegate tasks to project leads, ensure consistency across codebases, and manage cross-project dependencies."})]})]})]})]})})}function t$(e){let{status:t}=e,r={stopped:"bg-text-muted/20 text-text-muted",starting:"bg-accent-orange/20 text-accent-orange",running:"bg-success/20 text-success",error:"bg-error/20 text-error"};return(0,n.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium ".concat(r[t]||r.stopped),children:t})}function tq(){return(0,n.jsx)("svg",{className:"animate-spin h-6 w-6 text-accent-cyan",viewBox:"0 0 24 24",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function tJ(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,n.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,n.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,n.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,n.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,n.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,n.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function tZ(){return(0,n.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tX(){return(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function tY(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function tQ(){return(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function t0(){return(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"text-success",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})})}let t1={url:"",autoConnect:!0,reconnect:!0,maxReconnectAttempts:10,reconnectDelay:1e3},t2=(0,s.createContext)(void 0);function t5(e){var t,r,l,i;let{wsUrl:d,orchestratorUrl:u}=e,{data:m,isConnected:h,error:p}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={...t1,...e},[r,n]=(0,s.useState)(null),[a,o]=(0,s.useState)(!1),[l,i]=(0,s.useState)(null),c=(0,s.useRef)(null),d=(0,s.useRef)(0),x=(0,s.useRef)(null),u=(0,s.useCallback)(()=>{var e;if((null===(e=c.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN)return;let r=t.url||function(){let e="https:"===window.location.protocol?"wss:":"ws:";return"".concat(e,"//").concat(window.location.host,"/ws")}();try{let e=new WebSocket(r);e.onopen=()=>{o(!0),i(null),d.current=0},e.onclose=()=>{if(o(!1),c.current=null,t.reconnect&&d.current<t.maxReconnectAttempts){let e=Math.min(t.reconnectDelay*Math.pow(2,d.current),3e4);d.current++,x.current=setTimeout(()=>{u()},e)}},e.onerror=e=>{i(Error("WebSocket connection error")),console.error("[useWebSocket] Error:",e)},e.onmessage=e=>{try{let t=JSON.parse(e.data);n(t)}catch(e){console.error("[useWebSocket] Failed to parse message:",e)}},c.current=e}catch(e){i(e instanceof Error?e:Error("Failed to create WebSocket"))}},[t.url,t.reconnect,t.maxReconnectAttempts,t.reconnectDelay]),m=(0,s.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null),c.current&&(c.current.close(),c.current=null),o(!1)},[]);return(0,s.useEffect)(()=>(t.autoConnect&&u(),()=>{m()}),[t.autoConnect,u,m]),{data:r,isConnected:a,error:l,connect:u,disconnect:m}}({url:d}),{workspaces:g,activeWorkspaceId:f,agents:b,isConnected:j,isLoading:y,error:v,switchWorkspace:w,addWorkspace:N,removeWorkspace:k,spawnAgent:C,stopAgent:S}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{apiUrl:t="http://localhost:3456",enabled:r=!1}=e,[n,a]=(0,s.useState)([]),[o,l]=(0,s.useState)(),[i,c]=(0,s.useState)([]),[d,x]=(0,s.useState)(!1),[u,m]=(0,s.useState)(r),[h,p]=(0,s.useState)(null),g=(0,s.useRef)(null),f=(0,s.useRef)(),b=t.replace(/^http/,"ws"),j=(0,s.useCallback)(async()=>{if(r)try{m(!0),p(null);let e=await fetch("".concat(t,"/workspaces"));if(!e.ok)throw Error("Failed to fetch workspaces: ".concat(e.statusText));let r=await e.json();if(a(r.workspaces.map(e=>({...e,lastActiveAt:new Date(e.lastActiveAt)}))),l(r.activeWorkspaceId),r.activeWorkspaceId){let e=await fetch("".concat(t,"/workspaces/").concat(r.activeWorkspaceId,"/agents"));if(e.ok){let t=await e.json();c(t.agents.map(e=>({...e,spawnedAt:new Date(e.spawnedAt)})))}}}catch(e){p(e instanceof Error?e:Error(String(e)))}finally{m(!1)}},[t,r]);(0,s.useEffect)(()=>{if(!r)return;let e=()=>{try{let t=new WebSocket(b);t.onopen=()=>{x(!0),p(null)},t.onmessage=e=>{try{let r=JSON.parse(e.data);if("init"===r.type){var t;a(r.data.workspaces.map(e=>({...e,lastActiveAt:new Date(e.lastActiveAt)}))),l(r.data.activeWorkspaceId),c((null===(t=r.data.agents)||void 0===t?void 0:t.map(e=>({...e,spawnedAt:new Date(e.spawnedAt)})))||[]),m(!1)}else"event"===r.type&&y(r.data)}catch(e){console.error("Failed to parse WebSocket message:",e)}},t.onclose=()=>{x(!1),g.current=null,f.current=setTimeout(e,3e3)},t.onerror=e=>{console.error("WebSocket error:",e),t.close()},g.current=t}catch(t){p(t instanceof Error?t:Error(String(t))),f.current=setTimeout(e,3e3)}};return j().then(e),()=>{f.current&&clearTimeout(f.current),g.current&&g.current.close()}},[b,j,r]);let y=(0,s.useCallback)(e=>{switch(e.type){case"workspace:added":a(t=>[...t,e.data]);break;case"workspace:removed":a(t=>t.filter(t=>t.id!==e.workspaceId));break;case"workspace:updated":a(t=>t.map(t=>t.id===e.workspaceId?{...t,...e.data}:t));break;case"workspace:switched":l(e.data.currentId);break;case"agent:spawned":c(t=>[...t,e.data]);break;case"agent:stopped":case"agent:crashed":c(t=>t.filter(t=>t.name!==e.data.name));break;case"agent:restarted":c(t=>t.map(t=>t.name===e.data.name?{...t,status:"running",restartCount:t.restartCount+1}:t))}},[]),v=(0,s.useCallback)(async e=>{let r=await fetch("".concat(t,"/workspaces/").concat(e,"/switch"),{method:"POST"});if(!r.ok)throw Error("Failed to switch workspace: ".concat(r.statusText));let n=await fetch("".concat(t,"/workspaces/").concat(e,"/agents"));n.ok&&c((await n.json()).agents.map(e=>({...e,spawnedAt:new Date(e.spawnedAt)})))},[t]),w=(0,s.useCallback)(async(e,r)=>{let n=await fetch("".concat(t,"/workspaces"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,name:r})});if(!n.ok)throw Error((await n.json()).error||"Failed to add workspace");return n.json()},[t]),N=(0,s.useCallback)(async e=>{let r=await fetch("".concat(t,"/workspaces/").concat(e),{method:"DELETE"});if(!r.ok)throw Error("Failed to remove workspace: ".concat(r.statusText))},[t]),k=(0,s.useCallback)(async(e,r,n)=>{if(!o)throw Error("No active workspace");let s=await fetch("".concat(t,"/workspaces/").concat(o,"/agents"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,task:r,provider:n})});if(!s.ok)throw Error((await s.json()).error||"Failed to spawn agent");return s.json()},[t,o]),C=(0,s.useCallback)(async e=>{if(!o)throw Error("No active workspace");let r=await fetch("".concat(t,"/workspaces/").concat(o,"/agents/").concat(e),{method:"DELETE"});if(!r.ok)throw Error("Failed to stop agent: ".concat(r.statusText))},[t,o]);return{workspaces:n,activeWorkspaceId:o,agents:i,isConnected:d,isLoading:u,error:h,switchWorkspace:v,addWorkspace:w,removeWorkspace:N,spawnAgent:k,stopAgent:C,refresh:j}}({apiUrl:u}),A=(0,s.useContext)(t2),L=(null==A?void 0:A.user)?{displayName:A.user.githubUsername,avatarUrl:A.user.avatarUrl}:void 0,{onlineUsers:W,typingUsers:E,sendTyping:D,isConnected:M}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{currentUser:t,wsUrl:r,autoConnect:n=!0}=e,[a,o]=(0,s.useState)([]),[l,i]=(0,s.useState)([]),[c,d]=(0,s.useState)(!1),x=(0,s.useRef)(null),u=(0,s.useRef)(null),m=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=setInterval(()=>{let e=Date.now();i(t=>t.filter(t=>e-t.startedAt<3e3))},1e3);return()=>clearInterval(e)},[]);let h=(0,s.useCallback)(()=>{var e;if(!t||(null===(e=x.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN)return;let n=r||function(){let e="https:"===window.location.protocol?"wss:":"ws:";return"".concat(e,"//").concat(window.location.host,"/ws/presence")}();try{let e=new WebSocket(n);e.onopen=()=>{d(!0),e.send(JSON.stringify({type:"presence",action:"join",user:{username:t.username,avatarUrl:t.avatarUrl}}))},e.onclose=()=>{d(!1),x.current=null,u.current=setTimeout(()=>{h()},2e3)},e.onerror=e=>{console.error("[usePresence] Error:",e)},e.onmessage=e=>{try{let r=JSON.parse(e.data);switch(r.type){case"presence_list":o(r.users||[]);break;case"presence_join":o(e=>[...e.filter(e=>e.username!==r.user.username),r.user]);break;case"presence_leave":o(e=>e.filter(e=>e.username!==r.username)),i(e=>e.filter(e=>e.username!==r.username));break;case"typing":if(r.username===(null==t?void 0:t.username))break;r.isTyping?i(e=>[...e.filter(e=>e.username!==r.username),{username:r.username,avatarUrl:r.avatarUrl,startedAt:Date.now()}]):i(e=>e.filter(e=>e.username!==r.username))}}catch(e){console.error("[usePresence] Failed to parse message:",e)}},x.current=e}catch(e){console.error("[usePresence] Failed to create WebSocket:",e)}},[t,r]),p=(0,s.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),x.current&&(x.current.readyState===WebSocket.OPEN&&t&&x.current.send(JSON.stringify({type:"presence",action:"leave",username:t.username})),x.current.close(),x.current=null),d(!1)},[t]),g=(0,s.useCallback)(e=>{x.current&&x.current.readyState===WebSocket.OPEN&&t&&(m.current&&(clearTimeout(m.current),m.current=null),x.current.send(JSON.stringify({type:"typing",isTyping:e,username:t.username,avatarUrl:t.avatarUrl})),e&&(m.current=setTimeout(()=>{m.current=null,g(!1)},3e3)))},[t]);return(0,s.useEffect)(()=>(n&&t&&h(),()=>{p()}),[n,t,h,p]),(0,s.useEffect)(()=>{let e=()=>{var e;(null===(e=x.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN&&t&&x.current.send(JSON.stringify({type:"presence",action:"leave",username:t.username}))};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[t]),{onlineUsers:a,typingUsers:l,sendTyping:g,isConnected:c}}({currentUser:L?{username:L.displayName,avatarUrl:L.avatarUrl}:void 0}),[_,B]=(0,s.useState)(null),[T,R]=(0,s.useState)("local"),[P,F]=(0,s.useState)([]),[O,z]=(0,s.useState)(),[H,I]=(0,s.useState)(!1),[V,K]=(0,s.useState)(!1),[$,q]=(0,s.useState)(null),[J,Z]=(0,s.useState)(!1),[X,Y]=(0,s.useState)(!1),[Q,ee]=(0,s.useState)(null),[et,er]=(0,s.useState)(!1),[en,es]=(0,s.useState)(!1),[ea,eo]=(0,s.useState)(eK),[ei,ec]=(0,s.useState)(!1),[ed,ex]=(0,s.useState)(!1),[eu,em]=(0,s.useState)(null),[eh,ep]=(0,s.useState)(!1),[ef,eb]=(0,s.useState)(!1),[ej,ey]=(0,s.useState)(!1),ev=(0,s.useRef)(0),eN=(0,s.useRef)(!0),ek=(0,s.useCallback)(()=>{window.innerWidth<=768&&eb(!1)},[]),{agents:eC,groups:eS,selectedAgent:eA,selectAgent:eL,searchQuery:eW,setSearchQuery:eE,totalCount:eD,onlineCount:e_,needsAttentionCount:eB}=function(e){let{agents:t,initialSelected:r,initialSearchQuery:n=""}=e,[l,i]=(0,s.useState)(null!=r?r:null),[d,u]=(0,s.useState)(n),m=(0,s.useMemo)(()=>c(t,d),[t,d]),h=(0,s.useMemo)(()=>o(m),[m]),p=(0,s.useMemo)(()=>[...m].sort((e,t)=>e.name.localeCompare(t.name)),[m]),g=(0,s.useMemo)(()=>{var e;return null!==(e=t.find(e=>e.name===l))&&void 0!==e?e:null},[t,l]),f=(0,s.useMemo)(()=>{let e=x(t);return{totalCount:e.total,onlineCount:e.online,needsAttentionCount:e.needsAttention}},[t]),b=(0,s.useCallback)(e=>{i(e)},[]),j=(0,s.useCallback)(e=>t.find(t=>t.name===e),[t]),y=(0,s.useCallback)(e=>({...e,color:(0,a.GW)(e.name)}),[]);return{agents:m,groups:h,sortedAgents:p,selectedAgent:g,selectAgent:b,searchQuery:d,setSearchQuery:u,...f,getAgentByName:j,getAgentWithColor:y}}({agents:null!==(l=null==m?void 0:m.agents)&&void 0!==l?l:[]}),{messages:eT,threadMessages:eR,currentChannel:eF,setCurrentChannel:eU,currentThread:eO,setCurrentThread:ez,activeThreads:eH,totalUnreadThreadCount:eI,sendMessage:eV,isSending:eG,sendError:eq}=function(e){let{messages:t,currentChannel:r="general",senderName:n}=e,[a,o]=(0,s.useState)(r),[l,i]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),[x,u]=(0,s.useState)(null),[m,h]=(0,s.useState)(new Map),p=(0,s.useMemo)(()=>{let e=new Set(t.map(e=>e.id)),r=t.filter(t=>!t.thread||!e.has(t.thread));return"general"===a?r:r.filter(e=>e.from===a||e.to===a)},[t,a]),g=(0,s.useCallback)(e=>t.filter(t=>t.thread===e),[t]),f=(0,s.useMemo)(()=>{let e=new Map,r=new Set(t.map(e=>e.id));for(let r of t)if(r.thread){let t=e.get(r.thread)||[];t.push(r),e.set(r.thread,t)}let n=[];for(let[s,a]of e.entries()){let e=[...a].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),o=[...new Set(a.flatMap(e=>[e.from,e.to]))].filter(e=>"*"!==e),l=m.get(s),i=a.filter(e=>"Dashboard"!==e.from&&!e.isRead&&(!l||new Date(e.timestamp).getTime()>l)).length,c=s;if(r.has(s)){let e=t.find(e=>e.id===s);if(e){let t=e.content.split("\n")[0];c=t.length>30?t.substring(0,30)+"...":t}}n.push({id:s,name:c,lastMessage:e[0],messageCount:a.length,unreadCount:i,participants:o})}return n.sort((e,t)=>new Date(t.lastMessage.timestamp).getTime()-new Date(e.lastMessage.timestamp).getTime())},[t,m]),b=(0,s.useCallback)(e=>{i(e),e&&h(t=>{let r=new Map(t);return r.set(e,Date.now()),r})},[]),j=(0,s.useMemo)(()=>f.filter(e=>e.unreadCount>0).length,[f]),y=(0,s.useMemo)(()=>{let e=t.filter(e=>!e.isRead).length;return{totalCount:t.length,unreadCount:e}},[t]);return{messages:p,threadMessages:g,currentChannel:a,setCurrentChannel:o,currentThread:l,setCurrentThread:b,activeThreads:f,totalUnreadThreadCount:j,sendMessage:(0,s.useCallback)(async(e,t,r,s)=>{d(!0),u(null);try{let a={to:e,message:t,thread:r,attachments:s};n&&(a.from=n);let o=await fetch("/api/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),l=await o.json();if(o.ok&&l.success)return!0;return u(l.error||"Failed to send message"),!1}catch(e){return u("Network error"),!1}finally{d(!1)}},[n]),isSending:c,sendError:x,...y}}({messages:null!==(i=null==m?void 0:m.messages)&&void 0!==i?i:[],senderName:null==L?void 0:L.displayName}),eJ=(0,s.useMemo)(()=>{var e;let t=new Set(eC.map(e=>e.name.toLowerCase())),r=new Map;for(let n of(L&&r.set(L.displayName.toLowerCase(),{username:L.displayName,avatarUrl:L.avatarUrl}),null!==(e=null==m?void 0:m.messages)&&void 0!==e?e:[])){let e=n.from;!e||"Dashboard"===e||"*"===e||t.has(e.toLowerCase())||r.has(e.toLowerCase())||r.set(e.toLowerCase(),{username:e})}return Array.from(r.values())},[null==m?void 0:m.messages,eC,L]);(0,s.useEffect)(()=>{if(!(window.innerWidth<=768)){ey(!1);return}let e=eT.length;!ef&&e>ev.current&&ey(!0),eN.current=!ef},[eT.length,ef]),(0,s.useEffect)(()=>{ef&&(ey(!1),ev.current=eT.length)},[ef,eT.length]),(0,s.useEffect)(()=>{ev.current=eT.length},[]);let eZ=!!(null==m?void 0:null===(r=m.fleet)||void 0===r?void 0:null===(t=r.servers)||void 0===t?void 0:t.length)||g.length>0;(0,s.useEffect)(()=>{g.length>0&&(F(g.map(e=>({id:e.id,path:e.path,name:e.name,agents:b.filter(t=>t.workspaceId===e.id).map(e=>({name:e.name,status:"running"===e.status?"online":"offline",isSpawned:!0,cli:e.provider})),lead:void 0}))),z(f))},[g,b,f]),(0,s.useEffect)(()=>{if(g.length>0)return;let e=async()=>{let e=await e2.hi.getBridgeData();if(e.success&&e.data){let t=e.data;if(t.projects&&t.projects.length>0){let e=t.projects.map(e=>({id:e.id,path:e.path,name:e.name||e.path.split("/").pop(),agents:(e.agents||[]).map(e=>({name:e.name,status:"online"===e.status||"active"===e.status?"online":"offline",currentTask:e.task,cli:e.cli})),lead:e.lead}));F(e),!O&&e.length>0&&z(e[0].id)}}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[g.length,O]);let eX=["architect"],{bridgeAgents:eY,projectAgents:eQ}=(0,s.useMemo)(()=>{let e=[],t=[];for(let r of eC)eX.includes(r.name.toLowerCase())?e.push(r):t.push(r);return{bridgeAgents:e,projectAgents:t}},[eC]),e0=(0,s.useMemo)(()=>0===P.length||0===new Set(eQ.map(e=>e.name.toLowerCase())).size?P:P.map((e,t)=>{if(0===t||e.id===O){let t=new Set(e.agents.map(e=>e.name.toLowerCase())),r=eQ.filter(e=>!t.has(e.name.toLowerCase()));return{...e,agents:[...e.agents,...r]}}return e}),[P,eQ,O]),e1=(0,s.useMemo)(()=>e0.length>0?[]:eQ,[e0,eQ]),e4=(0,s.useCallback)(async e=>{try{await w(e.id)}catch(e){console.error("Failed to switch workspace:",e)}},[w]),e3=(0,s.useCallback)(async(e,t)=>{Y(!0),ee(null);try{await N(e,t),Z(!1)}catch(e){throw ee(e instanceof Error?e.message:"Failed to add workspace"),e}finally{Y(!1)}},[N]),e6=(0,s.useCallback)(e=>{z(e.id),g.length>0&&w(e.id).catch(e=>{console.error("Failed to switch workspace:",e)}),e.agents.length>0&&(eL(e.agents[0].name),eU(e.agents[0].name)),ek()},[eL,eU,ek,g.length,w]),e8=(0,s.useCallback)(e=>{eL(e.name),eU(e.name),ek()},[eL,eU,ek]),e9=(0,s.useCallback)(()=>{q(null),I(!0)},[]),e7=(0,s.useCallback)(()=>{es(!0)},[]),te=(0,s.useCallback)(()=>{ec(!0)},[]),tt=(0,s.useCallback)(()=>{ex(!0)},[]),tr=(0,s.useCallback)(()=>{ep(!0)},[]),tn=(0,s.useCallback)(async(e,t)=>{let r=await eV(e,t);if(r){if("*"===e)eL(null),eU("general");else{let t=eC.find(t=>t.name===e);t?(eL(t.name),eU(t.name)):eU(e)}}return r},[eV,eL,eU,eC]),ts=(0,s.useCallback)(async e=>{K(!0),q(null);try{if(g.length>0&&f)return await C(e.name,void 0,e.command),!0;let t=await e2.hi.spawnAgent({name:e.name,cli:e.command,team:e.team,shadowMode:e.shadowMode,shadowOf:e.shadowOf,shadowAgent:e.shadowAgent,shadowTriggers:e.shadowTriggers,shadowSpeakOn:e.shadowSpeakOn});if(!t.success)return q(t.error||"Failed to spawn agent"),!1;return!0}catch(e){return q(e instanceof Error?e.message:"Failed to spawn agent"),!1}finally{K(!1)}},[g.length,f,C]),ta=(0,s.useCallback)(async e=>{if(e.isSpawned&&window.confirm('Are you sure you want to release agent "'.concat(e.name,'"?')))try{if(g.length>0&&f){await S(e.name);return}let t=await e2.hi.releaseAgent(e.name);t.success||console.error("Failed to release agent:",t.error)}catch(e){console.error("Failed to release agent:",e)}},[g.length,f,S]),to=(0,s.useCallback)(e=>{em(e)},[]),tl=(0,s.useCallback)(()=>{er(!0)},[]),ti=(0,s.useCallback)(()=>{er(!1)},[]);return s.useEffect(()=>{let e=e=>{let t;t="system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,document.documentElement.setAttribute("data-theme",t)};if(e(ea.theme),"system"===ea.theme){let t=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>e("system");return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}},[ea.theme]),s.useEffect(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),er(!0)),(e.metaKey||e.ctrlKey)&&e.shiftKey&&"s"===e.key&&(e.preventDefault(),e9()),(e.metaKey||e.ctrlKey)&&"n"===e.key&&(e.preventDefault(),tt()),"Escape"===e.key&&(er(!1),I(!1),ex(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[e9,tt]),(0,n.jsxs)("div",{className:"flex h-screen bg-bg-deep font-sans text-text-primary",children:[(0,n.jsx)("div",{className:"\n fixed inset-0 bg-black/60 backdrop-blur-sm z-[999] transition-opacity duration-200\n md:hidden\n ".concat(ef?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none","\n "),onClick:()=>eb(!1)}),(0,n.jsxs)("div",{className:"\n flex flex-col w-[280px] max-md:w-[85vw] max-md:max-w-[280px] h-screen bg-bg-primary border-r border-border-subtle\n fixed left-0 top-0 z-[1000] transition-transform duration-200\n md:relative md:translate-x-0 md:flex-shrink-0\n ".concat(ef?"translate-x-0":"-translate-x-full","\n "),children:[(0,n.jsx)("div",{className:"p-3 border-b border-sidebar-border",children:(0,n.jsx)(td,{workspaces:g,activeWorkspaceId:f,onSelect:e4,onAddWorkspace:()=>Z(!0),isLoading:y})}),(0,n.jsx)(U,{agents:e1,bridgeAgents:eY,projects:e0,currentProject:O,selectedAgent:null==eA?void 0:eA.name,viewMode:T,isFleetAvailable:eZ,isConnected:h||j,isOpen:ef,activeThreads:eH,currentThread:eO,totalUnreadThreadCount:eI,onAgentSelect:e8,onProjectSelect:e6,onViewModeChange:R,onSpawnClick:e9,onReleaseClick:ta,onLogsClick:to,onThreadSelect:ez,onClose:()=>eb(!1)})]}),(0,n.jsxs)("main",{className:"flex-1 flex flex-col min-w-0 bg-bg-secondary/50 overflow-hidden",children:[(0,n.jsxs)("div",{className:"sticky top-0 z-50 flex-shrink-0",children:[(0,n.jsx)(G,{currentChannel:eF,selectedAgent:eA,projects:e0,currentProject:e0.find(e=>e.id===O)||null,onCommandPaletteOpen:tl,onSettingsClick:e7,onHistoryClick:te,onNewConversationClick:tt,onCoordinatorClick:tr,onMenuClick:()=>eb(!0),hasUnreadNotifications:ej}),L&&W.length>0&&(0,n.jsx)("div",{className:"flex items-center justify-end px-4 py-1 bg-bg-tertiary/80 border-b border-border-subtle",children:(0,n.jsx)(tI,{onlineUsers:W,onUserClick:B})})]}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,n.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto ".concat(eO?"hidden md:block md:flex-[2]":""),children:p?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center px-4",children:[(0,n.jsx)(t6,{}),(0,n.jsx)("h2",{className:"m-0 mb-2 font-display text-text-primary",children:"Connection Error"}),(0,n.jsx)("p",{className:"text-text-secondary",children:p.message}),(0,n.jsx)("button",{className:"mt-6 py-3 px-6 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-xl cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:()=>window.location.reload(),children:"Retry Connection"})]}):m?(0,n.jsx)(el,{messages:eT,currentChannel:eF,onThreadClick:e=>ez(e),highlightedMessageId:null!=eO?eO:void 0,agents:null==m?void 0:m.agents,currentUser:L}):(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center",children:[(0,n.jsx)(t3,{}),(0,n.jsx)("p",{className:"font-display text-text-secondary",children:"Connecting to dashboard..."})]})}),eO&&(()=>{let e=eT.find(e=>e.id===eO),t=!e;if(!e){var r;e=null!==(r=eT.filter(e=>e.thread===eO).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())[0])&&void 0!==r?r:null}return(0,n.jsx)("div",{className:"w-full md:w-[400px] md:min-w-[320px] md:max-w-[500px] flex-shrink-0",children:(0,n.jsx)(eg,{originalMessage:null!=e?e:null,replies:eR(eO),onClose:()=>ez(null),onReply:async r=>{let n="*";return!t&&e&&(n="Dashboard"===e.from||L&&e.from===L.displayName?e.to:e.from),eV(n,r,eO)},isSending:eG,currentUser:L})})})()]}),E.length>0&&(0,n.jsx)("div",{className:"px-4 bg-bg-tertiary border-t border-border-subtle",children:(0,n.jsx)(tH,{typingUsers:E})}),(0,n.jsx)("div",{className:"p-4 bg-bg-tertiary border-t border-border-subtle",children:(0,n.jsx)(t4,{recipient:"general"===eF?"*":eF,agents:eC,humanUsers:eJ,onSend:eV,onTyping:D,isSending:eG,error:eq})})]}),(0,n.jsx)(ew,{isOpen:et,onClose:ti,agents:eC,projects:P,currentProject:O,onAgentSelect:e8,onProjectSelect:e6,onSpawnClick:e9,onGeneralClick:()=>{eL(null),eU("general")}}),(0,n.jsx)(eM,{isOpen:H,onClose:()=>I(!1),onSpawn:ts,existingAgents:eC.map(e=>e.name),isSpawning:V,error:$}),(0,n.jsx)(e$,{isOpen:en,onClose:()=>es(!1),settings:ea,onSettingsChange:eo,onResetSettings:()=>eo(eK)}),(0,n.jsx)(tg,{isOpen:J,onClose:()=>{Z(!1),ee(null)},onAdd:e3,isAdding:X,error:Q}),(0,n.jsx)(e5,{isOpen:ei,onClose:()=>ec(!1)}),(0,n.jsx)(eP,{isOpen:ed,onClose:()=>ex(!1),onSend:tn,agents:eC,isSending:eG,error:eq}),eu&&(0,n.jsx)(tB,{agent:eu,isOpen:!0,onClose:()=>em(null),availableAgents:eC,onAgentChange:em}),(0,n.jsx)(tV,{user:_,onClose:()=>B(null),onMention:e=>{B(null)}}),(0,n.jsx)(tK,{isOpen:eh,onClose:()=>ep(!1),projects:e0,isCloudMode:!!L,hasArchitect:eY.some(e=>"architect"===e.name.toLowerCase()),onArchitectSpawned:()=>{ep(!1)}})]})}function t4(e){let{recipient:t,agents:r,humanUsers:a,onSend:o,onTyping:l,isSending:i,error:c}=e,[d,x]=(0,s.useState)(""),[u,m]=(0,s.useState)(0),[h,p]=(0,s.useState)(!1),[g,f]=(0,s.useState)(!1),[b,j]=(0,s.useState)([]),y=(0,s.useRef)(null),v=(0,s.useRef)(null),w=(0,s.useCallback)(async e=>{for(let t of e){let e=crypto.randomUUID(),r=URL.createObjectURL(t);j(n=>[...n,{id:e,file:t,preview:r,isUploading:!0}]);try{let r=await e2.hi.uploadAttachment(t);r.success&&r.data?j(t=>t.map(t=>t.id===e?{...t,isUploading:!1,uploadedId:r.data.attachment.id}:t)):j(t=>t.map(t=>t.id===e?{...t,isUploading:!1,error:r.error||"Upload failed"}:t))}catch(t){j(t=>t.map(t=>t.id===e?{...t,isUploading:!1,error:"Upload failed"}:t))}}},[]),N=(0,s.useCallback)(e=>{if(!e||0===e.length)return;let t=Array.from(e).filter(e=>e.type.startsWith("image/"));t.length>0&&w(t)},[w]),k=(0,s.useCallback)(e=>{let t=e.clipboardData;if(!t)return;let r=[];if(t.files&&t.files.length>0&&(r=Array.from(t.files).filter(e=>e.type.startsWith("image/"))),0===r.length&&t.items){for(let e of Array.from(t.items))if("file"===e.kind&&e.type.startsWith("image/")){let t=e.getAsFile();t&&r.push(t)}}r.length>0&&(e.preventDefault(),w(r))},[w]),C=(0,s.useCallback)(e=>{j(t=>{let r=t.find(t=>t.id===e);return r&&URL.revokeObjectURL(r.preview),t.filter(t=>t.id!==e)})},[]),S=async e=>{let r,n;e.preventDefault();let s=d.trim().length>0,a=b.length>0;if(!s&&!a||i||b.some(e=>e.isUploading))return;let l=b.filter(e=>e.uploadedId).map(e=>e.uploadedId),c=d.match(/^@(\S+)\s*([\s\S]*)/);if(c){let e=c[1];n=c[2]||"","*"===e||"everyone"===e.toLowerCase()||"all"===e.toLowerCase()?r="*":e.toLowerCase().startsWith("team:")?r=e:e.includes("/")||/\.(ts|tsx|js|jsx|json|md|py|go|rs|java|c|cpp|h|css|html|yaml|yml|toml)$/i.test(e)?(r=t,n=d):r=e}else r=t,n=d;!n.trim()&&l.length>0&&(n="[Screenshot attached]"),await o(r,n||d,void 0,l.length>0?l:void 0)&&(b.forEach(e=>URL.revokeObjectURL(e.preview)),x(""),j([]),p(!1),f(!1))},A=(d.trim()||b.length>0)&&!i&&!b.some(e=>e.isUploading);return(0,n.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:S,children:[b.length>0&&(0,n.jsx)("div",{className:"flex flex-wrap gap-2 p-2 bg-bg-card rounded-lg border border-border-subtle",children:b.map(e=>(0,n.jsxs)("div",{className:"relative group",children:[(0,n.jsx)("img",{src:e.preview,alt:e.file.name,className:"h-16 w-auto rounded-lg object-cover ".concat(e.isUploading?"opacity-50":""," ").concat(e.error?"border-2 border-error":"")}),e.isUploading&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,n.jsx)("svg",{className:"animate-spin h-5 w-5 text-accent-cyan",viewBox:"0 0 24 24",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}),e.error&&(0,n.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-error/90 text-white text-[10px] px-1 py-0.5 truncate",children:e.error}),(0,n.jsx)("button",{type:"button",onClick:()=>C(e.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-bg-tertiary border border-border-subtle rounded-full flex items-center justify-center text-text-muted hover:text-error hover:border-error transition-colors opacity-0 group-hover:opacity-100",title:"Remove",children:(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e.id))}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("input",{ref:v,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>N(e.target.files)}),(0,n.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=v.current)||void 0===e?void 0:e.click()},className:"p-2.5 bg-bg-card border border-border-subtle rounded-xl text-text-muted hover:text-accent-cyan hover:border-accent-cyan/50 transition-colors",title:"Attach screenshot (or paste from clipboard)",children:(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,n.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,n.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}),(0,n.jsxs)("div",{className:"flex-1 relative",children:[(0,n.jsx)(ta,{agents:r,humanUsers:a,inputValue:d,cursorPosition:u,onSelect:(e,t)=>{x(t),p(!1),f(!1),setTimeout(()=>{if(y.current){y.current.focus();let e=t.indexOf(" ")+1;y.current.setSelectionRange(e,e)}},0)},onClose:()=>p(!1),isVisible:h}),(0,n.jsx)(tc,{inputValue:d,cursorPosition:u,onSelect:(e,t)=>{x(t),f(!1),p(!1),setTimeout(()=>{if(y.current){y.current.focus();let e=t.indexOf(" ",1)+1;y.current.setSelectionRange(e,e)}},0)},onClose:()=>f(!1),isVisible:g}),(0,n.jsx)("textarea",{ref:y,className:"w-full py-3 px-4 bg-bg-card border border-border-subtle rounded-xl text-sm font-sans text-text-primary outline-none transition-all duration-200 resize-none min-h-[44px] max-h-[120px] overflow-y-auto focus:border-accent-cyan/50 focus:shadow-[0_0_0_3px_rgba(0,217,255,0.1)] placeholder:text-text-muted",placeholder:"Message ".concat("*"===t?"everyone":"@"+t,"... (@ for agents/files)"),value:d,onChange:e=>{let t=e.target.value,r=e.target.selectionStart||0;if(x(t),m(r),null==l||l(t.trim().length>0),null!==to(t,r)){f(!0),p(!1);return}if(null!==tn(t,r)){p(!0),f(!1);return}p(!1),f(!1)},onKeyDown:e=>{(!h&&!g||"ArrowDown"!==e.key&&"ArrowUp"!==e.key&&"Tab"!==e.key)&&("Enter"!==e.key||e.shiftKey||h||g||(e.preventDefault(),(d.trim()||b.length>0)&&!i&&S(e)))},onPaste:k,onSelect:e=>m(e.target.selectionStart||0),disabled:i,rows:1})]}),(0,n.jsx)("button",{type:"submit",className:"py-3 px-5 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-xl text-sm cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-none",disabled:!A,title:i?"Sending...":b.some(e=>e.isUploading)?"Uploading...":"Send message",children:i?(0,n.jsx)("span",{children:"Sending..."}):b.some(e=>e.isUploading)?(0,n.jsx)("span",{children:"Uploading..."}):(0,n.jsxs)("span",{className:"flex items-center gap-2",children:["Send",(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,n.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})]})}),c&&(0,n.jsx)("span",{className:"text-error text-xs ml-2",children:c})]})]})}function t3(){return(0,n.jsx)("svg",{className:"animate-spin mb-4 text-accent-cyan",width:"28",height:"28",viewBox:"0 0 24 24",children:(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function t6(){return(0,n.jsxs)("svg",{className:"text-error mb-4",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,n.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}},6272:function(e,t,r){r.d(t,{K7:function(){return s}});var n=r(7437);function s(e){let{size:t=24,className:r="",withGlow:s=!1}=e;return(0,n.jsxs)("svg",{width:t,height:t,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"\n transition-all duration-300\n ".concat(s?"drop-shadow-[0_0_8px_rgba(0,217,255,0.3)]":"","\n ").concat(r,"\n "),"aria-label":"Agent Relay Logo",role:"img",children:[(0,n.jsx)("path",{d:"M30 80 L 50 20 L 70 80",stroke:"#00d9ff",strokeWidth:"5",strokeLinejoin:"round",strokeLinecap:"round",fill:"none"}),(0,n.jsx)("line",{x1:"40",y1:"50",x2:"60",y2:"50",stroke:"#00d9ff",strokeWidth:"5",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M50 20 L 50 80",stroke:"#00ffc8",strokeWidth:"2.5",strokeLinecap:"round",opacity:"0.7"}),(0,n.jsx)("path",{d:"M50 20 C 80 20 80 50 50 50 L 80 80",stroke:"#00ffc8",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",opacity:"0.7"})]})}r(2265)}}]);