agent-relay 2.0.22 → 2.0.23

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 (391) hide show
  1. package/bin/relay-pty-linux-arm64 +0 -0
  2. package/dist/src/cli/index.d.ts +3 -3
  3. package/dist/src/cli/index.js +31 -100
  4. package/package.json +22 -29
  5. package/packages/api-types/package.json +1 -1
  6. package/packages/bridge/package.json +8 -8
  7. package/packages/cli-tester/package.json +1 -1
  8. package/packages/cloud/dist/server.js +25 -4
  9. package/packages/cloud/package.json +6 -6
  10. package/packages/config/package.json +2 -2
  11. package/packages/continuity/package.json +1 -1
  12. package/packages/daemon/dist/orchestrator.js +19 -1
  13. package/packages/daemon/package.json +12 -12
  14. package/packages/hooks/package.json +4 -4
  15. package/packages/mcp/package.json +2 -2
  16. package/packages/memory/package.json +2 -2
  17. package/packages/policy/package.json +2 -2
  18. package/packages/protocol/package.json +1 -1
  19. package/packages/resiliency/package.json +1 -1
  20. package/packages/sdk/package.json +2 -2
  21. package/packages/spawner/package.json +1 -1
  22. package/packages/state/package.json +1 -1
  23. package/packages/storage/package.json +2 -2
  24. package/packages/telemetry/package.json +1 -1
  25. package/packages/trajectory/package.json +2 -2
  26. package/packages/user-directory/package.json +2 -2
  27. package/packages/utils/dist/update-checker.js +4 -0
  28. package/packages/utils/package.json +1 -1
  29. package/packages/wrapper/package.json +6 -6
  30. package/deploy/workspace/codex.config.toml +0 -20
  31. package/deploy/workspace/entrypoint-browser.sh +0 -118
  32. package/deploy/workspace/entrypoint.sh +0 -612
  33. package/deploy/workspace/gh-credential-relay +0 -90
  34. package/deploy/workspace/gh-relay +0 -156
  35. package/deploy/workspace/git-credential-relay +0 -330
  36. package/deploy/workspace/git-credential-relay.test.sh +0 -230
  37. package/dist/dashboard/out/404.html +0 -1
  38. package/dist/dashboard/out/_next/static/91mkGYq3qbG8WHE6VytQ8/_buildManifest.js +0 -1
  39. package/dist/dashboard/out/_next/static/91mkGYq3qbG8WHE6VytQ8/_ssgManifest.js +0 -1
  40. package/dist/dashboard/out/_next/static/chunks/116-a883fca163f3a5bc.js +0 -1
  41. package/dist/dashboard/out/_next/static/chunks/117-c8afed19e821a35d.js +0 -2
  42. package/dist/dashboard/out/_next/static/chunks/282-980c2eb8fff20123.js +0 -1
  43. package/dist/dashboard/out/_next/static/chunks/320-a6304232cd0ee2ce.js +0 -1
  44. package/dist/dashboard/out/_next/static/chunks/532-bace199897eeab37.js +0 -9
  45. package/dist/dashboard/out/_next/static/chunks/631-16b905e5920f9b59.js +0 -1
  46. package/dist/dashboard/out/_next/static/chunks/648-acb2ff9f77cbfbd3.js +0 -1
  47. package/dist/dashboard/out/_next/static/chunks/766-2aea80818f7eb0d8.js +0 -1
  48. package/dist/dashboard/out/_next/static/chunks/83-26d2bde54616ee90.js +0 -1
  49. package/dist/dashboard/out/_next/static/chunks/847-f1f467060f32afff.js +0 -1
  50. package/dist/dashboard/out/_next/static/chunks/891-5cb1513eeb97a891.js +0 -1
  51. package/dist/dashboard/out/_next/static/chunks/app/_not-found/page-60501fddbafba9dc.js +0 -1
  52. package/dist/dashboard/out/_next/static/chunks/app/app/onboarding/page-9914652442f7e4fb.js +0 -1
  53. package/dist/dashboard/out/_next/static/chunks/app/app/page-366fb7c078d4e9e0.js +0 -1
  54. package/dist/dashboard/out/_next/static/chunks/app/cloud/link/page-fa1d5842aa90e8a6.js +0 -1
  55. package/dist/dashboard/out/_next/static/chunks/app/complete-profile/page-dd64bbdf66b639cd.js +0 -1
  56. package/dist/dashboard/out/_next/static/chunks/app/connect-repos/page-113060009ef35bc2.js +0 -1
  57. package/dist/dashboard/out/_next/static/chunks/app/history/page-9965d2483011b846.js +0 -1
  58. package/dist/dashboard/out/_next/static/chunks/app/layout-6b91e33784c20610.js +0 -1
  59. package/dist/dashboard/out/_next/static/chunks/app/login/page-435eceb0073be027.js +0 -1
  60. package/dist/dashboard/out/_next/static/chunks/app/metrics/page-1e37ef8e73940b40.js +0 -1
  61. package/dist/dashboard/out/_next/static/chunks/app/page-8119d4246743574e.js +0 -1
  62. package/dist/dashboard/out/_next/static/chunks/app/pricing/page-9db3ebdfa567a7c9.js +0 -1
  63. package/dist/dashboard/out/_next/static/chunks/app/providers/page-ecb16ffd3b36262b.js +0 -1
  64. package/dist/dashboard/out/_next/static/chunks/app/providers/setup/[provider]/page-4dbe33f0f7691b7c.js +0 -1
  65. package/dist/dashboard/out/_next/static/chunks/app/signup/page-c7a0a28341365ae0.js +0 -1
  66. package/dist/dashboard/out/_next/static/chunks/e868780c-48e5f147c90a3a41.js +0 -18
  67. package/dist/dashboard/out/_next/static/chunks/fd9d1056-609918ca7b6280bb.js +0 -1
  68. package/dist/dashboard/out/_next/static/chunks/framework-f66176bb897dc684.js +0 -1
  69. package/dist/dashboard/out/_next/static/chunks/main-311c3db74dcfadb7.js +0 -1
  70. package/dist/dashboard/out/_next/static/chunks/main-app-fdbeb09028f57c9f.js +0 -1
  71. package/dist/dashboard/out/_next/static/chunks/pages/_app-72b849fbd24ac258.js +0 -1
  72. package/dist/dashboard/out/_next/static/chunks/pages/_error-7ba65e1336b92748.js +0 -1
  73. package/dist/dashboard/out/_next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  74. package/dist/dashboard/out/_next/static/chunks/webpack-1cdd8ed57114d5e1.js +0 -1
  75. package/dist/dashboard/out/_next/static/css/4034f236dd1a3178.css +0 -1
  76. package/dist/dashboard/out/_next/static/css/6892f8422896ef7a.css +0 -1
  77. package/dist/dashboard/out/alt-logos/agent-relay-logo-128.png +0 -0
  78. package/dist/dashboard/out/alt-logos/agent-relay-logo-256.png +0 -0
  79. package/dist/dashboard/out/alt-logos/agent-relay-logo-32.png +0 -0
  80. package/dist/dashboard/out/alt-logos/agent-relay-logo-512.png +0 -0
  81. package/dist/dashboard/out/alt-logos/agent-relay-logo-64.png +0 -0
  82. package/dist/dashboard/out/alt-logos/agent-relay-logo.svg +0 -45
  83. package/dist/dashboard/out/alt-logos/logo.svg +0 -38
  84. package/dist/dashboard/out/alt-logos/monogram-logo-128.png +0 -0
  85. package/dist/dashboard/out/alt-logos/monogram-logo-256.png +0 -0
  86. package/dist/dashboard/out/alt-logos/monogram-logo-32.png +0 -0
  87. package/dist/dashboard/out/alt-logos/monogram-logo-512.png +0 -0
  88. package/dist/dashboard/out/alt-logos/monogram-logo-64.png +0 -0
  89. package/dist/dashboard/out/alt-logos/monogram-logo.svg +0 -38
  90. package/dist/dashboard/out/app/onboarding.html +0 -1
  91. package/dist/dashboard/out/app/onboarding.txt +0 -7
  92. package/dist/dashboard/out/app.html +0 -1
  93. package/dist/dashboard/out/app.txt +0 -7
  94. package/dist/dashboard/out/apple-icon.png +0 -0
  95. package/dist/dashboard/out/cloud/link.html +0 -1
  96. package/dist/dashboard/out/cloud/link.txt +0 -7
  97. package/dist/dashboard/out/complete-profile.html +0 -5
  98. package/dist/dashboard/out/complete-profile.txt +0 -7
  99. package/dist/dashboard/out/connect-repos.html +0 -1
  100. package/dist/dashboard/out/connect-repos.txt +0 -7
  101. package/dist/dashboard/out/history.html +0 -1
  102. package/dist/dashboard/out/history.txt +0 -7
  103. package/dist/dashboard/out/index.html +0 -1
  104. package/dist/dashboard/out/index.txt +0 -7
  105. package/dist/dashboard/out/login.html +0 -5
  106. package/dist/dashboard/out/login.txt +0 -7
  107. package/dist/dashboard/out/metrics.html +0 -1
  108. package/dist/dashboard/out/metrics.txt +0 -7
  109. package/dist/dashboard/out/pricing.html +0 -13
  110. package/dist/dashboard/out/pricing.txt +0 -7
  111. package/dist/dashboard/out/providers/setup/claude.html +0 -1
  112. package/dist/dashboard/out/providers/setup/claude.txt +0 -8
  113. package/dist/dashboard/out/providers/setup/codex.html +0 -1
  114. package/dist/dashboard/out/providers/setup/codex.txt +0 -8
  115. package/dist/dashboard/out/providers/setup/cursor.html +0 -1
  116. package/dist/dashboard/out/providers/setup/cursor.txt +0 -8
  117. package/dist/dashboard/out/providers.html +0 -1
  118. package/dist/dashboard/out/providers.txt +0 -7
  119. package/dist/dashboard/out/signup.html +0 -6
  120. package/dist/dashboard/out/signup.txt +0 -7
  121. package/dist/src/dashboard-server/index.d.ts +0 -8
  122. package/dist/src/dashboard-server/index.js +0 -8
  123. package/packages/dashboard/README.md +0 -48
  124. package/packages/dashboard/dist/health-worker-manager.d.ts +0 -62
  125. package/packages/dashboard/dist/health-worker-manager.js +0 -144
  126. package/packages/dashboard/dist/health-worker.d.ts +0 -9
  127. package/packages/dashboard/dist/health-worker.js +0 -79
  128. package/packages/dashboard/dist/index.d.ts +0 -20
  129. package/packages/dashboard/dist/index.js +0 -19
  130. package/packages/dashboard/dist/metrics.d.ts +0 -105
  131. package/packages/dashboard/dist/metrics.js +0 -193
  132. package/packages/dashboard/dist/needs-attention.d.ts +0 -24
  133. package/packages/dashboard/dist/needs-attention.js +0 -78
  134. package/packages/dashboard/dist/server.d.ts +0 -25
  135. package/packages/dashboard/dist/server.js +0 -5270
  136. package/packages/dashboard/dist/start.d.ts +0 -6
  137. package/packages/dashboard/dist/start.js +0 -13
  138. package/packages/dashboard/dist/types/threading.d.ts +0 -8
  139. package/packages/dashboard/dist/types/threading.js +0 -2
  140. package/packages/dashboard/dist/user-bridge.d.ts +0 -154
  141. package/packages/dashboard/dist/user-bridge.js +0 -372
  142. package/packages/dashboard/package.json +0 -65
  143. package/packages/dashboard/ui/app/app/onboarding/page.tsx +0 -394
  144. package/packages/dashboard/ui/app/app/page.tsx +0 -667
  145. package/packages/dashboard/ui/app/apple-icon.png +0 -0
  146. package/packages/dashboard/ui/app/cloud/link/page.tsx +0 -464
  147. package/packages/dashboard/ui/app/complete-profile/page.tsx +0 -204
  148. package/packages/dashboard/ui/app/connect-repos/page.tsx +0 -410
  149. package/packages/dashboard/ui/app/favicon.png +0 -0
  150. package/packages/dashboard/ui/app/globals.css +0 -59
  151. package/packages/dashboard/ui/app/history/page.tsx +0 -658
  152. package/packages/dashboard/ui/app/layout.tsx +0 -25
  153. package/packages/dashboard/ui/app/login/page.tsx +0 -424
  154. package/packages/dashboard/ui/app/metrics/page.tsx +0 -751
  155. package/packages/dashboard/ui/app/page.tsx +0 -59
  156. package/packages/dashboard/ui/app/pricing/page.tsx +0 -7
  157. package/packages/dashboard/ui/app/providers/page.tsx +0 -193
  158. package/packages/dashboard/ui/app/providers/setup/[provider]/ProviderSetupClient.tsx +0 -148
  159. package/packages/dashboard/ui/app/providers/setup/[provider]/constants.ts +0 -35
  160. package/packages/dashboard/ui/app/providers/setup/[provider]/page.tsx +0 -42
  161. package/packages/dashboard/ui/app/signup/page.tsx +0 -533
  162. package/packages/dashboard/ui/index.ts +0 -49
  163. package/packages/dashboard/ui/landing/LandingPage.tsx +0 -713
  164. package/packages/dashboard/ui/landing/PricingPage.tsx +0 -559
  165. package/packages/dashboard/ui/landing/index.ts +0 -6
  166. package/packages/dashboard/ui/landing/styles.css +0 -2850
  167. package/packages/dashboard/ui/lib/agent-merge.ts +0 -35
  168. package/packages/dashboard/ui/lib/api.ts +0 -1155
  169. package/packages/dashboard/ui/lib/cloudApi.ts +0 -877
  170. package/packages/dashboard/ui/lib/colors.ts +0 -218
  171. package/packages/dashboard/ui/lib/hierarchy.ts +0 -242
  172. package/packages/dashboard/ui/lib/stuckDetection.ts +0 -142
  173. package/packages/dashboard/ui/next-env.d.ts +0 -5
  174. package/packages/dashboard/ui/next.config.js +0 -41
  175. package/packages/dashboard/ui/package-lock.json +0 -2882
  176. package/packages/dashboard/ui/package.json +0 -33
  177. package/packages/dashboard/ui/postcss.config.js +0 -5
  178. package/packages/dashboard/ui/react-components/ActivityFeed.tsx +0 -216
  179. package/packages/dashboard/ui/react-components/AddWorkspaceModal.tsx +0 -170
  180. package/packages/dashboard/ui/react-components/AgentCard.tsx +0 -587
  181. package/packages/dashboard/ui/react-components/AgentList.tsx +0 -411
  182. package/packages/dashboard/ui/react-components/AgentProfilePanel.tsx +0 -564
  183. package/packages/dashboard/ui/react-components/App.tsx +0 -3033
  184. package/packages/dashboard/ui/react-components/BillingPanel.tsx +0 -922
  185. package/packages/dashboard/ui/react-components/BillingResult.tsx +0 -447
  186. package/packages/dashboard/ui/react-components/BroadcastComposer.tsx +0 -690
  187. package/packages/dashboard/ui/react-components/ChannelAdminPanel.tsx +0 -773
  188. package/packages/dashboard/ui/react-components/ChannelBrowser.tsx +0 -385
  189. package/packages/dashboard/ui/react-components/ChannelChat.tsx +0 -261
  190. package/packages/dashboard/ui/react-components/ChannelSidebar.tsx +0 -399
  191. package/packages/dashboard/ui/react-components/CloudSessionProvider.tsx +0 -130
  192. package/packages/dashboard/ui/react-components/CommandPalette.tsx +0 -815
  193. package/packages/dashboard/ui/react-components/ConfirmationDialog.tsx +0 -133
  194. package/packages/dashboard/ui/react-components/ConversationHistory.tsx +0 -518
  195. package/packages/dashboard/ui/react-components/CoordinatorPanel.tsx +0 -944
  196. package/packages/dashboard/ui/react-components/DecisionQueue.tsx +0 -717
  197. package/packages/dashboard/ui/react-components/DirectMessageView.tsx +0 -164
  198. package/packages/dashboard/ui/react-components/FileAutocomplete.tsx +0 -368
  199. package/packages/dashboard/ui/react-components/FleetOverview.tsx +0 -278
  200. package/packages/dashboard/ui/react-components/LogViewer.tsx +0 -310
  201. package/packages/dashboard/ui/react-components/LogViewerPanel.tsx +0 -482
  202. package/packages/dashboard/ui/react-components/Logo.tsx +0 -284
  203. package/packages/dashboard/ui/react-components/MentionAutocomplete.tsx +0 -384
  204. package/packages/dashboard/ui/react-components/MessageComposer.tsx +0 -457
  205. package/packages/dashboard/ui/react-components/MessageList.tsx +0 -649
  206. package/packages/dashboard/ui/react-components/MessageSenderName.tsx +0 -91
  207. package/packages/dashboard/ui/react-components/MessageStatusIndicator.tsx +0 -142
  208. package/packages/dashboard/ui/react-components/NewConversationModal.tsx +0 -400
  209. package/packages/dashboard/ui/react-components/NotificationToast.tsx +0 -488
  210. package/packages/dashboard/ui/react-components/OnlineUsersIndicator.tsx +0 -164
  211. package/packages/dashboard/ui/react-components/Pagination.tsx +0 -124
  212. package/packages/dashboard/ui/react-components/PricingPlans.tsx +0 -386
  213. package/packages/dashboard/ui/react-components/ProjectList.tsx +0 -625
  214. package/packages/dashboard/ui/react-components/ProviderAuthFlow.tsx +0 -853
  215. package/packages/dashboard/ui/react-components/ProviderConnectionList.tsx +0 -378
  216. package/packages/dashboard/ui/react-components/ProvisioningProgress.tsx +0 -730
  217. package/packages/dashboard/ui/react-components/RepoAccessPanel.tsx +0 -549
  218. package/packages/dashboard/ui/react-components/ServerCard.tsx +0 -202
  219. package/packages/dashboard/ui/react-components/SessionExpiredModal.tsx +0 -128
  220. package/packages/dashboard/ui/react-components/SpawnModal.tsx +0 -804
  221. package/packages/dashboard/ui/react-components/TaskAssignmentUI.tsx +0 -375
  222. package/packages/dashboard/ui/react-components/TerminalProviderSetup.tsx +0 -608
  223. package/packages/dashboard/ui/react-components/ThemeProvider.tsx +0 -325
  224. package/packages/dashboard/ui/react-components/ThinkingIndicator.tsx +0 -231
  225. package/packages/dashboard/ui/react-components/ThreadList.tsx +0 -198
  226. package/packages/dashboard/ui/react-components/ThreadPanel.tsx +0 -346
  227. package/packages/dashboard/ui/react-components/TrajectoryViewer.tsx +0 -698
  228. package/packages/dashboard/ui/react-components/TypingIndicator.tsx +0 -69
  229. package/packages/dashboard/ui/react-components/UsageBanner.tsx +0 -231
  230. package/packages/dashboard/ui/react-components/UserProfilePanel.tsx +0 -233
  231. package/packages/dashboard/ui/react-components/WorkspaceContext.tsx +0 -107
  232. package/packages/dashboard/ui/react-components/WorkspaceSelector.tsx +0 -234
  233. package/packages/dashboard/ui/react-components/WorkspaceStatusIndicator.tsx +0 -370
  234. package/packages/dashboard/ui/react-components/XTermInteractive.tsx +0 -510
  235. package/packages/dashboard/ui/react-components/XTermLogViewer.tsx +0 -719
  236. package/packages/dashboard/ui/react-components/channels/ChannelDialogs.tsx +0 -1411
  237. package/packages/dashboard/ui/react-components/channels/ChannelHeader.tsx +0 -317
  238. package/packages/dashboard/ui/react-components/channels/ChannelMessageList.tsx +0 -463
  239. package/packages/dashboard/ui/react-components/channels/ChannelViewV1.tsx +0 -146
  240. package/packages/dashboard/ui/react-components/channels/MessageInput.tsx +0 -288
  241. package/packages/dashboard/ui/react-components/channels/SearchInput.tsx +0 -172
  242. package/packages/dashboard/ui/react-components/channels/SearchResults.tsx +0 -336
  243. package/packages/dashboard/ui/react-components/channels/api.ts +0 -697
  244. package/packages/dashboard/ui/react-components/channels/index.ts +0 -76
  245. package/packages/dashboard/ui/react-components/channels/mockApi.ts +0 -344
  246. package/packages/dashboard/ui/react-components/channels/types.ts +0 -566
  247. package/packages/dashboard/ui/react-components/hooks/index.ts +0 -57
  248. package/packages/dashboard/ui/react-components/hooks/useAgentLogs.ts +0 -394
  249. package/packages/dashboard/ui/react-components/hooks/useAgents.ts +0 -127
  250. package/packages/dashboard/ui/react-components/hooks/useBroadcastDedup.ts +0 -86
  251. package/packages/dashboard/ui/react-components/hooks/useChannelAdmin.ts +0 -329
  252. package/packages/dashboard/ui/react-components/hooks/useChannelBrowser.ts +0 -239
  253. package/packages/dashboard/ui/react-components/hooks/useChannelCommands.ts +0 -138
  254. package/packages/dashboard/ui/react-components/hooks/useChannels.ts +0 -328
  255. package/packages/dashboard/ui/react-components/hooks/useDebounce.ts +0 -29
  256. package/packages/dashboard/ui/react-components/hooks/useDirectMessage.ts +0 -141
  257. package/packages/dashboard/ui/react-components/hooks/useMessages.ts +0 -309
  258. package/packages/dashboard/ui/react-components/hooks/useOrchestrator.ts +0 -364
  259. package/packages/dashboard/ui/react-components/hooks/usePinnedAgents.ts +0 -140
  260. package/packages/dashboard/ui/react-components/hooks/usePresence.ts +0 -340
  261. package/packages/dashboard/ui/react-components/hooks/useRecentRepos.ts +0 -130
  262. package/packages/dashboard/ui/react-components/hooks/useSession.ts +0 -209
  263. package/packages/dashboard/ui/react-components/hooks/useTrajectory.ts +0 -265
  264. package/packages/dashboard/ui/react-components/hooks/useWebSocket.ts +0 -169
  265. package/packages/dashboard/ui/react-components/hooks/useWorkspaceMembers.ts +0 -120
  266. package/packages/dashboard/ui/react-components/hooks/useWorkspaceRepos.ts +0 -73
  267. package/packages/dashboard/ui/react-components/hooks/useWorkspaceStatus.ts +0 -237
  268. package/packages/dashboard/ui/react-components/index.ts +0 -81
  269. package/packages/dashboard/ui/react-components/layout/Header.tsx +0 -355
  270. package/packages/dashboard/ui/react-components/layout/RepoContextHeader.tsx +0 -361
  271. package/packages/dashboard/ui/react-components/layout/Sidebar.archive.test.tsx +0 -126
  272. package/packages/dashboard/ui/react-components/layout/Sidebar.test.tsx +0 -691
  273. package/packages/dashboard/ui/react-components/layout/Sidebar.tsx +0 -930
  274. package/packages/dashboard/ui/react-components/layout/index.ts +0 -7
  275. package/packages/dashboard/ui/react-components/settings/BillingSettingsPanel.tsx +0 -564
  276. package/packages/dashboard/ui/react-components/settings/SettingsPage.tsx +0 -544
  277. package/packages/dashboard/ui/react-components/settings/TeamSettingsPanel.tsx +0 -560
  278. package/packages/dashboard/ui/react-components/settings/WorkspaceSettingsPanel.tsx +0 -1386
  279. package/packages/dashboard/ui/react-components/settings/index.ts +0 -11
  280. package/packages/dashboard/ui/react-components/settings/types.ts +0 -53
  281. package/packages/dashboard/ui/react-components/utils/messageFormatting.tsx +0 -370
  282. package/packages/dashboard/ui/tailwind.config.js +0 -148
  283. package/packages/dashboard/ui/types/index.ts +0 -304
  284. package/packages/dashboard/ui/types/threading.ts +0 -7
  285. package/packages/dashboard/ui-dist/404.html +0 -1
  286. package/packages/dashboard/ui-dist/_next/static/91mkGYq3qbG8WHE6VytQ8/_buildManifest.js +0 -1
  287. package/packages/dashboard/ui-dist/_next/static/91mkGYq3qbG8WHE6VytQ8/_ssgManifest.js +0 -1
  288. package/packages/dashboard/ui-dist/_next/static/T2rV14eEU5OweDeV29SvG/_buildManifest.js +0 -1
  289. package/packages/dashboard/ui-dist/_next/static/T2rV14eEU5OweDeV29SvG/_ssgManifest.js +0 -1
  290. package/packages/dashboard/ui-dist/_next/static/chunks/116-a883fca163f3a5bc.js +0 -1
  291. package/packages/dashboard/ui-dist/_next/static/chunks/117-c8afed19e821a35d.js +0 -2
  292. package/packages/dashboard/ui-dist/_next/static/chunks/282-980c2eb8fff20123.js +0 -1
  293. package/packages/dashboard/ui-dist/_next/static/chunks/320-a6304232cd0ee2ce.js +0 -1
  294. package/packages/dashboard/ui-dist/_next/static/chunks/532-bace199897eeab37.js +0 -9
  295. package/packages/dashboard/ui-dist/_next/static/chunks/631-16b905e5920f9b59.js +0 -1
  296. package/packages/dashboard/ui-dist/_next/static/chunks/648-acb2ff9f77cbfbd3.js +0 -1
  297. package/packages/dashboard/ui-dist/_next/static/chunks/766-2aea80818f7eb0d8.js +0 -1
  298. package/packages/dashboard/ui-dist/_next/static/chunks/83-26d2bde54616ee90.js +0 -1
  299. package/packages/dashboard/ui-dist/_next/static/chunks/847-f1f467060f32afff.js +0 -1
  300. package/packages/dashboard/ui-dist/_next/static/chunks/891-5cb1513eeb97a891.js +0 -1
  301. package/packages/dashboard/ui-dist/_next/static/chunks/app/_not-found/page-60501fddbafba9dc.js +0 -1
  302. package/packages/dashboard/ui-dist/_next/static/chunks/app/app/onboarding/page-9914652442f7e4fb.js +0 -1
  303. package/packages/dashboard/ui-dist/_next/static/chunks/app/app/page-366fb7c078d4e9e0.js +0 -1
  304. package/packages/dashboard/ui-dist/_next/static/chunks/app/cloud/link/page-fa1d5842aa90e8a6.js +0 -1
  305. package/packages/dashboard/ui-dist/_next/static/chunks/app/complete-profile/page-dd64bbdf66b639cd.js +0 -1
  306. package/packages/dashboard/ui-dist/_next/static/chunks/app/connect-repos/page-113060009ef35bc2.js +0 -1
  307. package/packages/dashboard/ui-dist/_next/static/chunks/app/history/page-9965d2483011b846.js +0 -1
  308. package/packages/dashboard/ui-dist/_next/static/chunks/app/layout-6b91e33784c20610.js +0 -1
  309. package/packages/dashboard/ui-dist/_next/static/chunks/app/login/page-435eceb0073be027.js +0 -1
  310. package/packages/dashboard/ui-dist/_next/static/chunks/app/metrics/page-1e37ef8e73940b40.js +0 -1
  311. package/packages/dashboard/ui-dist/_next/static/chunks/app/page-8119d4246743574e.js +0 -1
  312. package/packages/dashboard/ui-dist/_next/static/chunks/app/pricing/page-9db3ebdfa567a7c9.js +0 -1
  313. package/packages/dashboard/ui-dist/_next/static/chunks/app/providers/page-ecb16ffd3b36262b.js +0 -1
  314. package/packages/dashboard/ui-dist/_next/static/chunks/app/providers/setup/[provider]/page-4dbe33f0f7691b7c.js +0 -1
  315. package/packages/dashboard/ui-dist/_next/static/chunks/app/signup/page-c7a0a28341365ae0.js +0 -1
  316. package/packages/dashboard/ui-dist/_next/static/chunks/e868780c-48e5f147c90a3a41.js +0 -18
  317. package/packages/dashboard/ui-dist/_next/static/chunks/fd9d1056-609918ca7b6280bb.js +0 -1
  318. package/packages/dashboard/ui-dist/_next/static/chunks/framework-f66176bb897dc684.js +0 -1
  319. package/packages/dashboard/ui-dist/_next/static/chunks/main-311c3db74dcfadb7.js +0 -1
  320. package/packages/dashboard/ui-dist/_next/static/chunks/main-app-fdbeb09028f57c9f.js +0 -1
  321. package/packages/dashboard/ui-dist/_next/static/chunks/pages/_app-72b849fbd24ac258.js +0 -1
  322. package/packages/dashboard/ui-dist/_next/static/chunks/pages/_error-7ba65e1336b92748.js +0 -1
  323. package/packages/dashboard/ui-dist/_next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  324. package/packages/dashboard/ui-dist/_next/static/chunks/webpack-1cdd8ed57114d5e1.js +0 -1
  325. package/packages/dashboard/ui-dist/_next/static/css/4034f236dd1a3178.css +0 -1
  326. package/packages/dashboard/ui-dist/_next/static/css/6892f8422896ef7a.css +0 -1
  327. package/packages/dashboard/ui-dist/_next/static/l8L2OscDSR2vsMIlWcC48/_buildManifest.js +0 -1
  328. package/packages/dashboard/ui-dist/_next/static/l8L2OscDSR2vsMIlWcC48/_ssgManifest.js +0 -1
  329. package/packages/dashboard/ui-dist/alt-logos/agent-relay-logo-128.png +0 -0
  330. package/packages/dashboard/ui-dist/alt-logos/agent-relay-logo-256.png +0 -0
  331. package/packages/dashboard/ui-dist/alt-logos/agent-relay-logo-32.png +0 -0
  332. package/packages/dashboard/ui-dist/alt-logos/agent-relay-logo-512.png +0 -0
  333. package/packages/dashboard/ui-dist/alt-logos/agent-relay-logo-64.png +0 -0
  334. package/packages/dashboard/ui-dist/alt-logos/agent-relay-logo.svg +0 -45
  335. package/packages/dashboard/ui-dist/alt-logos/logo.svg +0 -38
  336. package/packages/dashboard/ui-dist/alt-logos/monogram-logo-128.png +0 -0
  337. package/packages/dashboard/ui-dist/alt-logos/monogram-logo-256.png +0 -0
  338. package/packages/dashboard/ui-dist/alt-logos/monogram-logo-32.png +0 -0
  339. package/packages/dashboard/ui-dist/alt-logos/monogram-logo-512.png +0 -0
  340. package/packages/dashboard/ui-dist/alt-logos/monogram-logo-64.png +0 -0
  341. package/packages/dashboard/ui-dist/alt-logos/monogram-logo.svg +0 -38
  342. package/packages/dashboard/ui-dist/app/onboarding.html +0 -1
  343. package/packages/dashboard/ui-dist/app/onboarding.txt +0 -7
  344. package/packages/dashboard/ui-dist/app.html +0 -1
  345. package/packages/dashboard/ui-dist/app.txt +0 -7
  346. package/packages/dashboard/ui-dist/apple-icon.png +0 -0
  347. package/packages/dashboard/ui-dist/cloud/link.html +0 -1
  348. package/packages/dashboard/ui-dist/cloud/link.txt +0 -7
  349. package/packages/dashboard/ui-dist/complete-profile.html +0 -5
  350. package/packages/dashboard/ui-dist/complete-profile.txt +0 -7
  351. package/packages/dashboard/ui-dist/connect-repos.html +0 -1
  352. package/packages/dashboard/ui-dist/connect-repos.txt +0 -7
  353. package/packages/dashboard/ui-dist/history.html +0 -1
  354. package/packages/dashboard/ui-dist/history.txt +0 -7
  355. package/packages/dashboard/ui-dist/index.html +0 -1
  356. package/packages/dashboard/ui-dist/index.txt +0 -7
  357. package/packages/dashboard/ui-dist/login.html +0 -5
  358. package/packages/dashboard/ui-dist/login.txt +0 -7
  359. package/packages/dashboard/ui-dist/metrics.html +0 -1
  360. package/packages/dashboard/ui-dist/metrics.txt +0 -7
  361. package/packages/dashboard/ui-dist/pricing.html +0 -13
  362. package/packages/dashboard/ui-dist/pricing.txt +0 -7
  363. package/packages/dashboard/ui-dist/providers/setup/claude.html +0 -1
  364. package/packages/dashboard/ui-dist/providers/setup/claude.txt +0 -8
  365. package/packages/dashboard/ui-dist/providers/setup/codex.html +0 -1
  366. package/packages/dashboard/ui-dist/providers/setup/codex.txt +0 -8
  367. package/packages/dashboard/ui-dist/providers/setup/cursor.html +0 -1
  368. package/packages/dashboard/ui-dist/providers/setup/cursor.txt +0 -8
  369. package/packages/dashboard/ui-dist/providers.html +0 -1
  370. package/packages/dashboard/ui-dist/providers.txt +0 -7
  371. package/packages/dashboard/ui-dist/signup.html +0 -6
  372. package/packages/dashboard/ui-dist/signup.txt +0 -7
  373. package/packages/dashboard-server/dist/health-worker-manager.d.ts +0 -62
  374. package/packages/dashboard-server/dist/health-worker-manager.js +0 -144
  375. package/packages/dashboard-server/dist/health-worker.d.ts +0 -9
  376. package/packages/dashboard-server/dist/health-worker.js +0 -79
  377. package/packages/dashboard-server/dist/index.d.ts +0 -18
  378. package/packages/dashboard-server/dist/index.js +0 -17
  379. package/packages/dashboard-server/dist/metrics.d.ts +0 -105
  380. package/packages/dashboard-server/dist/metrics.js +0 -193
  381. package/packages/dashboard-server/dist/needs-attention.d.ts +0 -24
  382. package/packages/dashboard-server/dist/needs-attention.js +0 -78
  383. package/packages/dashboard-server/dist/server.d.ts +0 -25
  384. package/packages/dashboard-server/dist/server.js +0 -5158
  385. package/packages/dashboard-server/dist/start.d.ts +0 -6
  386. package/packages/dashboard-server/dist/start.js +0 -13
  387. package/packages/dashboard-server/dist/types/threading.d.ts +0 -8
  388. package/packages/dashboard-server/dist/types/threading.js +0 -2
  389. package/packages/dashboard-server/dist/user-bridge.d.ts +0 -158
  390. package/packages/dashboard-server/dist/user-bridge.js +0 -390
  391. package/packages/dashboard-server/package.json +0 -55
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[320],{9165:function(e,t,r){r.d(t,{Zk:function(){return i},_V:function(){return o},xv:function(){return d}});var s=r(9116);let n=new Set,a=null;function o(){return a}function l(e){let t=e.headers.get("X-CSRF-Token");t&&(a=t,(0,s.aM)(t))}function i(e){return n.add(e),()=>n.delete(e)}async function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let r={"Content-Type":"application/json",...t.headers};t.method&&"GET"!==t.method&&a&&(r["X-CSRF-Token"]=a);let s=await fetch(e,{...t,credentials:"include",headers:r});l(s);let o=await s.json();if(401===s.status||"object"==typeof o&&null!==o&&("SESSION_EXPIRED"===o.code||"USER_NOT_FOUND"===o.code)){let e={error:o.error||"Session expired",code:o.code||"SESSION_EXPIRED",message:o.message||"Your session has expired. Please log in again."};return!function(e){for(let t of n)try{t(e)}catch(e){console.error("[cloudApi] Session expired listener error:",e)}}(e),{success:!1,error:e.message,sessionExpired:!0}}if(!s.ok)return{success:!1,error:o.error||"Request failed with status ".concat(s.status)};return{success:!0,data:o}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Network error"}}}let d={async getNangoLoginSession(){try{let e=await fetch("/api/auth/nango/login-session",{credentials:"include"});l(e);let t=await e.json();if(!e.ok)return{success:!1,error:t.error||"Failed to create login session"};return{success:!0,data:t}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Network error"}}},async checkNangoLoginStatus(e){try{let t=await fetch("/api/auth/nango/login-status/".concat(encodeURIComponent(e)),{credentials:"include"});l(t);let r=await t.json();if(!t.ok)return{success:!1,error:r.error||"Failed to check login status"};return{success:!0,data:r}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Network error"}}},getNangoRepoSession:async()=>c("/api/auth/nango/repo-session"),checkNangoRepoStatus:async e=>c("/api/auth/nango/repo-status/".concat(encodeURIComponent(e))),async checkSession(){try{let e=await fetch("/api/auth/session",{credentials:"include"});return l(e),await e.json()}catch(e){return{authenticated:!1,code:"SESSION_ERROR",message:"Failed to check session status"}}},getMe:async()=>c("/api/auth/me"),async logout(){try{let e={};a&&(e["X-CSRF-Token"]=a);let t=await fetch("/api/auth/logout",{method:"POST",credentials:"include",headers:e});return await t.json()}catch(e){return{success:!1,error:"Network error"}}},getWorkspaces:async()=>c("/api/workspaces"),getWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e))),createWorkspace:async e=>c("/api/workspaces",{method:"POST",body:JSON.stringify(e)}),getPrimaryWorkspace:async()=>c("/api/workspaces/primary"),getWorkspaceSummary:async()=>c("/api/workspaces/summary"),getAccessibleWorkspaces:async()=>c("/api/workspaces/accessible"),getWorkspaceStatus:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/status")),wakeupWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/wakeup"),{method:"POST"}),restartWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/restart"),{method:"POST"}),getProviders:async e=>c("/api/providers?workspaceId=".concat(encodeURIComponent(e))),disconnectProvider:async(e,t)=>c("/api/providers/".concat(encodeURIComponent(e),"?workspaceId=").concat(encodeURIComponent(t)),{method:"DELETE"}),getWorkspaceMembers:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/members")),getRepoCollaborators:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/repo-collaborators")),async inviteMember(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"member";return c("/api/workspaces/".concat(encodeURIComponent(e),"/members"),{method:"POST",body:JSON.stringify({githubUsername:t,role:r})})},getPendingInvites:async()=>c("/api/invites"),acceptInvite:async e=>c("/api/invites/".concat(encodeURIComponent(e),"/accept"),{method:"POST"}),declineInvite:async e=>c("/api/invites/".concat(encodeURIComponent(e),"/decline"),{method:"POST"}),updateMemberRole:async(e,t,r)=>c("/api/workspaces/".concat(encodeURIComponent(e),"/members/").concat(encodeURIComponent(t)),{method:"PATCH",body:JSON.stringify({role:r})}),removeMember:async(e,t)=>c("/api/workspaces/".concat(encodeURIComponent(e),"/members/").concat(encodeURIComponent(t)),{method:"DELETE"}),getBillingPlans:async()=>c("/api/billing/plans"),getSubscription:async()=>c("/api/billing/subscription"),async createCheckoutSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"month";return c("/api/billing/checkout",{method:"POST",body:JSON.stringify({tier:e,interval:t})})},createBillingPortal:async()=>c("/api/billing/portal",{method:"POST"}),async changeSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"month";return c("/api/billing/change",{method:"POST",body:JSON.stringify({tier:e,interval:t})})},cancelSubscription:async()=>c("/api/billing/cancel",{method:"POST"}),resumeSubscription:async()=>c("/api/billing/resume",{method:"POST"}),getInvoices:async()=>c("/api/billing/invoices"),stopWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/stop"),{method:"POST"}),deleteWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e)),{method:"DELETE"}),addReposToWorkspace:async(e,t)=>c("/api/workspaces/".concat(encodeURIComponent(e),"/repos"),{method:"POST",body:JSON.stringify({repositoryIds:t})}),setCustomDomain:async(e,t)=>c("/api/workspaces/".concat(encodeURIComponent(e),"/domain"),{method:"POST",body:JSON.stringify({domain:t})}),verifyCustomDomain:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/domain/verify"),{method:"POST"}),removeCustomDomain:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/domain"),{method:"DELETE"}),getWorkspaceDetails:async e=>c("/api/workspaces/".concat(encodeURIComponent(e))),getRepos:async()=>c("/api/github-app/repos"),syncRepo:async e=>c("/api/repos/".concat(encodeURIComponent(e),"/sync"),{method:"POST"})}},637:function(e,t,r){r.d(t,{GW:function(){return i},hP:function(){return c},oU:function(){return l},yh:function(){return a}});let s={backend:{primary:"#1264a3",light:"#e8f4fd",dark:"#0d4f82",text:"#ffffff"},frontend:{primary:"#7c3aed",light:"#f3e8ff",dark:"#5b21b6",text:"#ffffff"},infra:{primary:"#ea580c",light:"#fff7ed",dark:"#c2410c",text:"#ffffff"},lead:{primary:"#2bac76",light:"#ecfdf5",dark:"#059669",text:"#ffffff"},test:{primary:"#0d9488",light:"#f0fdfa",dark:"#0f766e",text:"#ffffff"},data:{primary:"#dc2626",light:"#fef2f2",dark:"#b91c1c",text:"#ffffff"},api:{primary:"#2563eb",light:"#eff6ff",dark:"#1d4ed8",text:"#ffffff"},worker:{primary:"#9333ea",light:"#faf5ff",dark:"#7e22ce",text:"#ffffff"},monitor:{primary:"#0891b2",light:"#ecfeff",dark:"#0e7490",text:"#ffffff"},security:{primary:"#be123c",light:"#fff1f2",dark:"#9f1239",text:"#ffffff"}},n=[{primary:"#6366f1",light:"#eef2ff",dark:"#4f46e5",text:"#ffffff"},{primary:"#ec4899",light:"#fdf2f8",dark:"#db2777",text:"#ffffff"},{primary:"#14b8a6",light:"#f0fdfa",dark:"#0d9488",text:"#ffffff"},{primary:"#f59e0b",light:"#fffbeb",dark:"#d97706",text:"#000000"},{primary:"#8b5cf6",light:"#f5f3ff",dark:"#7c3aed",text:"#ffffff"},{primary:"#06b6d4",light:"#ecfeff",dark:"#0891b2",text:"#ffffff"},{primary:"#f43f5e",light:"#fff1f2",dark:"#e11d48",text:"#ffffff"},{primary:"#84cc16",light:"#f7fee7",dark:"#65a30d",text:"#000000"}],a={online:"#22c55e",offline:"#6b7280",busy:"#eab308",processing:"#6366f1",error:"#ef4444",attention:"#ef4444",stuck:"#f97316"};function o(e){return e.toLowerCase().split("-").filter(Boolean)}function l(e){return o(e)[0]||e.toLowerCase()}function i(e){let t=l(e);return t in s?s[t]:n[function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(t)%n.length]}function c(e){let t=o(e);return 0===t.length?e.substring(0,2).toUpperCase():t.length>=2?(t[0][0]+t[1][0]).toUpperCase():t[0].substring(0,2).toUpperCase()}},7320:function(e,t,r){r.d(t,{fM:function(){return nM},gV:function(){return nD}});var s=r(7437),n=r(2265);function a(e){let{event:t,onClick:r}=e,n=function(e){switch(e){case"agent_spawned":return"\uD83D\uDE80";case"agent_released":return"\uD83D\uDED1";case"agent_online":return"\uD83D\uDFE2";case"agent_offline":return"⚫";case"user_joined":case"user_left":return"\uD83D\uDC4B";case"broadcast":return"\uD83D\uDCE2";case"error":return"⚠️";default:return"\uD83D\uDCCC"}}(t.type),a=function(e){switch(e){case"agent_spawned":case"agent_online":return"text-green-400";case"agent_released":return"text-red-400";case"agent_offline":case"user_left":return"text-gray-400";case"user_joined":return"text-cyan-400";case"broadcast":return"text-yellow-400";case"error":return"text-red-500";default:return"text-text-muted"}}(t.type);return(0,s.jsxs)("div",{className:"flex items-start gap-3 p-3 rounded-lg hover:bg-bg-hover transition-colors ".concat(r?"cursor-pointer":""),onClick:r,children:[(0,s.jsx)("div",{className:"flex-shrink-0 w-8 h-8 flex items-center justify-center",children:t.actorAvatarUrl?(0,s.jsx)("img",{src:t.actorAvatarUrl,alt:t.actor,className:"w-8 h-8 rounded-full"}):(0,s.jsx)("span",{className:"text-lg",children:n})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium ".concat(a),children:t.actor}),(0,s.jsx)("span",{className:"text-text-muted text-sm",children:t.title})]}),t.description&&(0,s.jsx)("p",{className:"text-text-muted text-sm mt-1 line-clamp-2",children:t.description}),t.metadata&&Object.keys(t.metadata).length>0&&(()=>{let e=t.metadata.cli,r=t.metadata.task;return(0,s.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[null!=e&&(0,s.jsx)("span",{className:"px-2 py-0.5 bg-bg-secondary rounded text-xs text-text-muted",children:String(e)}),null!=r&&(0,s.jsx)("span",{className:"px-2 py-0.5 bg-bg-secondary rounded text-xs text-text-muted truncate max-w-[200px]",children:String(r)})]})})()]}),(0,s.jsx)("div",{className:"flex-shrink-0 text-xs text-text-muted",children:function(e){let t=new Date,r=new Date(e),s=Math.floor((t.getTime()-r.getTime())/1e3),n=Math.floor(s/60),a=Math.floor(n/60),o=Math.floor(a/24);return s<60?"just now":n<60?"".concat(n,"m ago"):a<24?"".concat(a,"h ago"):o<7?"".concat(o,"d ago"):r.toLocaleDateString()}(t.timestamp)})]})}function o(){return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center p-8",children:[(0,s.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCCB"}),(0,s.jsx)("h3",{className:"text-lg font-medium text-text-primary mb-2",children:"No activity yet"}),(0,s.jsx)("p",{className:"text-text-muted text-sm max-w-xs",children:"Activity will appear here as agents spawn, users join, and broadcasts are sent."})]})}function l(e){let{events:t,maxEvents:r=100,onEventClick:l}=e,i=(0,n.useMemo)(()=>[...t].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()).slice(0,r),[t,r]);return 0===i.length?(0,s.jsx)(o,{}):(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"flex-shrink-0 px-4 py-3 border-b border-border-subtle",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-primary",children:"Activity"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:[i.length," event",1!==i.length?"s":""]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:(0,s.jsx)("div",{className:"space-y-1",children:i.map(e=>(0,s.jsx)(a,{event:e,onClick:l?()=>l(e):void 0},e.id))})})]})}let i="agent-relay-pinned-agents";var c=r(9165);let d={autoRefresh:!0,refreshInterval:3e4,autoWakeup:!1,onStatusChange:()=>{}};function x(){var e,t,r,s,a;let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=null!==(e=o.autoRefresh)&&void 0!==e?e:d.autoRefresh,i=null!==(t=o.refreshInterval)&&void 0!==t?t:d.refreshInterval,x=null!==(r=o.autoWakeup)&&void 0!==r?r:d.autoWakeup,u=(0,n.useRef)(null!==(s=o.onStatusChange)&&void 0!==s?s:d.onStatusChange);u.current=null!==(a=o.onStatusChange)&&void 0!==a?a:d.onStatusChange;let[m,h]=(0,n.useState)(null),[p,g]=(0,n.useState)(!1),[b,f]=(0,n.useState)(!0),[y,j]=(0,n.useState)(!1),[v,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),L=(0,n.useRef)(null),M=(0,n.useRef)(!0),D=(0,n.useRef)(null),A=(0,n.useCallback)(async()=>{try{f(!0),S(null);let e=await c.xv.getPrimaryWorkspace();if(!M.current)return;if(e.success){if(g(e.data.exists),w(e.data.statusMessage),k(e.data.actionNeeded||null),e.data.workspace){let t=e.data.workspace;h(t),D.current&&D.current!==t.status&&u.current(t.status,!1),D.current=t.status}else h(null)}else S(e.error)}catch(e){M.current&&S("Failed to fetch workspace status")}finally{M.current&&f(!1)}},[]),E=(0,n.useRef)(i);E.current=i;let W=(0,n.useRef)(l);W.current=l;let T=(0,n.useCallback)(async()=>{if(!(null==m?void 0:m.id))return{success:!1,message:"No workspace to wake up"};try{j(!0),S(null);let e=await c.xv.wakeupWorkspace(m.id);if(!M.current)return{success:!1,message:"Component unmounted"};if(e.success)return e.data.wasRestarted&&(w(e.data.message),k(null),u.current("starting",!0),L.current&&clearInterval(L.current),L.current=setInterval(A,5e3),setTimeout(()=>{M.current&&L.current&&(clearInterval(L.current),W.current&&(L.current=setInterval(A,E.current)))},12e4)),{success:!0,message:e.data.message};return S(e.error),{success:!1,message:e.error}}catch(t){let e=t instanceof Error?t.message:"Failed to wake up workspace";return M.current&&S(e),{success:!1,message:e}}finally{M.current&&j(!1)}},[null==m?void 0:m.id,A]);return(0,n.useEffect)(()=>(M.current=!0,A(),()=>{M.current=!1}),[A]),(0,n.useEffect)(()=>{if(l)return L.current=setInterval(A,i),()=>{L.current&&(clearInterval(L.current),L.current=null)}},[l,i,A]),(0,n.useEffect)(()=>{x&&(null==m?void 0:m.isStopped)&&!y&&T()},[x,null==m?void 0:m.isStopped,y,T]),{workspace:m,exists:p,isLoading:b,isWakingUp:y,statusMessage:v,actionNeeded:N,error:C,refresh:A,wakeup:T}}var u=r(637);function m(e){let t=new Map;for(let r of e){let e=r.team||(0,u.oU)(r.name),s=(0,u.GW)(r.name),n=t.get(e);n||(n={prefix:e,displayName:b(e),color:s,agents:[],isExpanded:!0},t.set(e,n)),n.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 h(e){let t=e.split("-").filter(Boolean);return 0===t.length?e:b(t[t.length-1])}function p(e){return e.split("-").filter(Boolean).map(b).join(" > ")}function g(e,t){return t?e.filter(e=>(function(e,t){if(!t)return!0;let r=t.toLowerCase(),s=e.toLowerCase();return!!s.includes(r)||s.split("-").some(e=>e.includes(r))})(e.name,t)):e}function b(e){return e?e.charAt(0).toUpperCase()+e.slice(1):e}function f(e){let t=0,r=0,s=0;for(let n of e)"online"===n.status?t++:"offline"===n.status&&r++,n.needsAttention&&s++;return{total:e.length,online:t,offline:r,needsAttention:s}}function y(e){let{isProcessing:t,processingStartedAt:r,size:a="medium",showElapsed:o=!1,showLabel:l=!1}=e,[i,c]=(0,n.useState)(0);if((0,n.useEffect)(()=>{if(!t||!r){c(0);return}let e=()=>{c(Date.now()-r)};e();let s=setInterval(e,1e3);return()=>clearInterval(s)},[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,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-accent-purple",title:"Processing...",children:[(0,s.jsxs)("span",{className:"inline-flex items-center ".concat({small:"gap-0.5",medium:"gap-1",large:"gap-1.5"}[a]),children:[(0,s.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"0ms",animationDuration:"800ms"}}),(0,s.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"150ms",animationDuration:"800ms"}}),(0,s.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"300ms",animationDuration:"800ms"}})]}),l&&(0,s.jsx)("span",{className:"text-xs font-medium text-accent-purple",children:"thinking"}),o&&i>0&&(0,s.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 j(e){let{isProcessing:t}=e;return t?(0,s.jsx)("span",{className:"thinking-dot-inline",title:"Processing...",children:(0,s.jsx)("span",{className:"thinking-dot-pulse"})}):null}function v(e){if(e<6e4)return"<1m";let t=Math.floor(e/6e4);if(t<60)return"".concat(t,"m");let r=Math.floor(t/60),s=t%60;return 0===s?"".concat(r,"h"):"".concat(r,"h ").concat(s,"m")}function w(e){let{agent:t,isSelected:r=!1,showBreadcrumb:n=!1,compact:a=!1,displayNameOverride:o,isPinned:l=!1,isMaxPinned:i=!1,onClick:c,onMessageClick:d,onReleaseClick:x,onLogsClick:m,onProfileClick:g,onPinToggle:b}=e,f=(0,u.GW)(t.name),w=(0,u.hP)(t.name),D=o||h(t.name),A=!t.lastMessageReceivedAt||t.lastOutputAt&&t.lastOutputAt>=t.lastMessageReceivedAt?0:Date.now()-t.lastMessageReceivedAt,E=t.isStuck||A>0,W=E?u.yh.stuck:u.yh[t.status]||u.yh.offline,T="online"===t.status,P=function(e,t,r,s){if(r&&s)return"Stuck - Agent received message ".concat(v(s)," ago but hasn't responded");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";case"stuck":return"Stuck - Agent may be blocked or unresponsive";default:return"Status: ".concat(e)}}(t.status,t.isProcessing,E,A),B=()=>{null==c||c(t)},_=e=>{e.stopPropagation(),null==x||x(t)},I=e=>{e.stopPropagation(),null==m||m(t)},R=e=>{e.stopPropagation(),null==g||g(t)},U=e=>{e.stopPropagation(),null==b||b(t)};return a?(0,s.jsxs)("div",{className:"\n group relative flex items-start 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:B,style:{borderLeft:r?"2px solid ".concat(f.primary):"2px solid transparent",boxShadow:r?"inset 4px 0 12px -4px ".concat(f.primary,"40"):"none"},children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.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(T?"shadow-lg":"opacity-60","\n "),style:{background:"linear-gradient(135deg, ".concat(f.primary,", ").concat(f.primary,"99)"),boxShadow:T?"0 2px 12px ".concat(f.primary,"50"):"none"},children:[(0,s.jsx)("div",{className:"absolute inset-0 opacity-30",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 50%)"}}),(0,s.jsx)("span",{className:"relative z-10",style:{color:f.text},children:w})]}),T&&(0,s.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:P})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-start gap-1.5 flex-wrap",children:[(0,s.jsx)("span",{className:"\n text-[13px] font-semibold tracking-tight transition-colors duration-200\n whitespace-normal break-words leading-snug\n ".concat(T?"text-text-primary":"text-text-secondary","\n "),children:D}),t.isLocal&&(0,s.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-medium uppercase tracking-wider bg-gradient-to-r from-orange-500/20 to-amber-500/20 text-orange-400 border border-orange-500/30",title:"Local agent from ".concat(t.daemonName||"linked daemon"),children:"Local"}),l&&(0,s.jsx)("span",{className:"inline-flex items-center text-amber-400",title:"Pinned to top",children:(0,s.jsx)(M,{size:12,filled:!0})})]}),!o&&(0,s.jsx)("span",{className:"text-[10px] text-text-muted truncate font-mono opacity-70 mt-0.5",children:t.isLocal?t.daemonName||t.machineId:p(t.name)}),(0,s.jsxs)("div",{className:"mt-2 flex items-center flex-wrap gap-2",children:[b&&(0,s.jsx)("button",{className:"\n relative bg-transparent border border-transparent p-1.5 cursor-pointer\n flex items-center justify-center rounded-md transition-all duration-200\n ".concat(l?"text-amber-400 hover:bg-amber-400/10 hover:border-amber-400/30":"text-text-dim hover:bg-amber-400/10 hover:border-amber-400/30 hover:text-amber-400","\n ").concat(!l&&i?"opacity-40 cursor-not-allowed":"","\n hover:shadow-[0_0_12px_rgba(251,191,36,0.25)]\n "),onClick:U,title:l?"Unpin from top":i?"Maximum pins reached (5)":"Pin to top",disabled:!l&&i,children:(0,s.jsx)(M,{size:16,filled:l})}),g&&(0,s.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-100 hover:bg-[#a855f7]/10 hover:border-[#a855f7]/30 hover:text-[#a855f7] hover:shadow-[0_0_12px_rgba(168,85,247,0.25)]",onClick:R,title:"View profile",children:(0,s.jsx)(L,{})}),t.isSpawned&&m&&(0,s.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-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:I,title:"View logs",children:(0,s.jsx)(C,{})}),t.isSpawned&&x&&(0,s.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-100 hover:bg-error/10 hover:border-error/30 hover:text-error hover:shadow-[0_0_12px_rgba(255,68,68,0.25)]",onClick:_,title:"Kill agent",children:(0,s.jsx)(k,{})}),t.isProcessing?(0,s.jsx)("div",{title:P,children:(0,s.jsx)(j,{isProcessing:!0})}):(0,s.jsx)("div",{className:"\n w-2 h-2 rounded-full transition-all duration-300\n ".concat(T?"animate-pulse":"","\n "),style:{backgroundColor:W,boxShadow:T?"0 0 6px ".concat(W):"none"},title:P}),t.needsAttention&&(0,s.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"}),E&&(0,s.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-[#f97316]/20 text-[#f97316] text-[10px] font-medium animate-pulse",title:P,children:[(0,s.jsx)(S,{}),(0,s.jsx)("span",{children:v(A)})]})]})]})]}):(0,s.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:B,style:{backgroundColor:f.light,borderColor:f.primary},children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center font-semibold text-sm relative",style:{backgroundColor:f.primary},children:[(0,s.jsx)("span",{style:{color:f.text},children:w}),(0,s.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-white",style:{backgroundColor:W},title:P})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:D}),t.isLocal&&(0,s.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-medium uppercase tracking-wider bg-gradient-to-r from-orange-500/20 to-amber-500/20 text-orange-400 border border-orange-500/30",title:"Local agent from ".concat(t.daemonName||"linked daemon"),children:"Local"}),l&&(0,s.jsx)("span",{className:"inline-flex items-center text-amber-400",title:"Pinned to top",children:(0,s.jsx)(M,{size:14,filled:!0})}),t.needsAttention&&(0,s.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:"!"}),E&&(0,s.jsxs)("span",{className:"bg-[#f97316] text-white text-[10px] font-bold px-1.5 py-0.5 rounded flex items-center gap-1",title:P,children:[(0,s.jsx)(S,{})," ",v(A)]})]}),n?(0,s.jsx)("span",{className:"text-xs text-text-muted truncate block",children:t.isLocal?t.daemonName||t.machineId:p(t.name)}):(0,s.jsx)("span",{className:"text-xs text-text-muted truncate block",children:t.isLocal?t.daemonName||t.machineId:t.name}),t.agentId&&(0,s.jsxs)("span",{className:"text-[10px] text-text-muted font-mono opacity-70",title:"Agent ID (use to resume)",children:["ID: ",t.agentId]})]})]}),t.isProcessing&&(0,s.jsxs)("div",{className:"mt-2 p-2 bg-indigo-50 rounded flex items-center gap-2 border border-indigo-200",children:[(0,s.jsx)(y,{isProcessing:!0,processingStartedAt:t.processingStartedAt,size:"medium",showElapsed:!0}),(0,s.jsx)("span",{className:"text-xs text-indigo-500 font-medium",children:"Thinking..."})]}),t.currentTask&&!t.isProcessing&&(0,s.jsxs)("div",{className:"mt-2 p-2 bg-bg-hover rounded text-xs",children:[(0,s.jsx)("span",{className:"text-text-muted mr-1",children:"Working on:"}),(0,s.jsx)("span",{className:"text-text-primary line-clamp-2",title:t.currentTask,children:t.currentTask})]}),(0,s.jsxs)("div",{className:"mt-3 flex justify-between items-center",children:[(0,s.jsxs)("div",{className:"flex gap-2 text-xs text-text-muted",children:[t.cli&&(0,s.jsx)("span",{className:"bg-bg-hover py-0.5 px-1.5 rounded",children:t.cli}),void 0!==t.messageCount&&t.messageCount>0&&(0,s.jsxs)("span",{style:{color:f.primary},children:[t.messageCount," msgs"]}),t.isSpawned&&(0,s.jsx)("span",{className:"bg-accent-light text-accent text-[10px] py-0.5 px-1.5 rounded uppercase font-medium",children:"spawned"})]}),(0,s.jsxs)("div",{className:"flex gap-1.5",children:[b&&(0,s.jsx)("button",{className:"\n relative bg-gradient-to-b rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 overflow-hidden\n ".concat(l?"from-[#3a2a1a] to-[#2a1f0f] text-amber-400 border border-amber-600/50 shadow-[inset_0_1px_0_rgba(251,191,36,0.1),0_2px_4px_rgba(0,0,0,0.3)] hover:shadow-[inset_0_1px_0_rgba(251,191,36,0.2),0_0_12px_rgba(251,191,36,0.4),0_2px_8px_rgba(0,0,0,0.4)]":"from-[#2a2a2a] to-[#1a1a1a] text-text-muted border border-[#404040] shadow-[inset_0_1px_0_rgba(255,255,255,0.05),0_2px_4px_rgba(0,0,0,0.3)] hover:from-[#3a2a1a] hover:to-[#2a1f0f] hover:text-amber-400 hover:border-amber-600/50 hover:shadow-[inset_0_1px_0_rgba(251,191,36,0.1),0_0_12px_rgba(251,191,36,0.3),0_2px_8px_rgba(0,0,0,0.4)]","\n ").concat(!l&&i?"opacity-40 cursor-not-allowed":"hover:scale-105","\n active:scale-[0.98]\n "),onClick:U,title:l?"Unpin from top":i?"Maximum pins reached (5)":"Pin to top",disabled:!l&&i,children:(0,s.jsx)(M,{size:16,filled:l})}),g&&(0,s.jsx)("button",{className:"relative bg-gradient-to-b from-[#2a1a3a] to-[#1a0f2a] text-[#a855f7] border border-[#402060] 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(168,85,247,0.1),0_2px_4px_rgba(0,0,0,0.3)] overflow-hidden hover:bg-gradient-to-b hover:from-[#402060] hover:to-[#301a50] hover:border-[#a855f7] hover:shadow-[inset_0_1px_0_rgba(168,85,247,0.2),0_0_12px_rgba(168,85,247,0.4),0_2px_8px_rgba(0,0,0,0.4)] hover:scale-105 active:scale-[0.98]",onClick:R,title:"View profile",children:(0,s.jsx)(L,{})}),t.isSpawned&&m&&(0,s.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:I,title:"View logs",children:(0,s.jsx)(C,{})}),t.isSpawned&&x&&(0,s.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:_,title:"Release agent",children:(0,s.jsx)(k,{})}),d&&(0,s.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:f.primary},onClick:e=>{e.stopPropagation(),null==d||d(t)},title:"Send message",children:(0,s.jsx)(N,{})})]})]})]})}function N(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.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 k(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",className:"release-icon",children:[(0,s.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,s.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,s.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function C(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,s.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function S(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function L(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"12",cy:"7",r:"4"})]})}function M(e){let{size:t=16,filled:r=!1}=e;return(0,s.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:r?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M12 17v5"}),(0,s.jsx)("path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4.76Z"})]})}function D(e){let{agents:t,selectedAgent:r,searchQuery:a="",pinnedAgents:o=[],isMaxPinned:l=!1,onAgentSelect:i,onAgentMessage:c,onReleaseClick:d,onLogsClick:x,onProfileClick:u,onPinToggle:h,compact:p=!1,showGroupStats:b=!0}=e,[f,y]=(0,n.useState)(new Set),[j,v]=(0,n.useState)(!0),[N,k]=(0,n.useState)(!0),C=(0,n.useMemo)(()=>g(t.filter(e=>!e.name.startsWith("__setup__")&&"_DashboardUI"!==e.name),a),[t,a]),{pinnedAgentsList:S,unpinnedAgents:L}=(0,n.useMemo)(()=>{let e=[],t=[];for(let r of C)o.includes(r.name)?e.push(r):t.push(r);return e.sort((e,t)=>o.indexOf(e.name)-o.indexOf(t.name)),{pinnedAgentsList:e,unpinnedAgents:t}},[C,o]),M=(0,n.useMemo)(()=>m(L),[L]);(0,n.useMemo)(()=>{0===f.size&&M.length>0&&y(new Set(M.map(e=>e.prefix)))},[M]);let D=e=>{y(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};return 0===t.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,s.jsx)(W,{}),(0,s.jsx)("p",{children:"No agents connected"})]}):0===C.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,s.jsx)(T,{}),(0,s.jsxs)("p",{children:['No agents match "',a,'"']})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[M.length>1&&(0,s.jsxs)("div",{className:"flex justify-between items-center py-2 px-3 text-xs text-text-muted",children:[(0,s.jsxs)("span",{children:[C.length," agents"]}),(0,s.jsx)("button",{className:"bg-transparent border-none text-accent cursor-pointer text-xs hover:underline",onClick:()=>{j?y(new Set):y(new Set(M.map(e=>e.prefix))),v(!j)},children:j?"Collapse all":"Expand all"})]}),S.length>0&&(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.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-amber-400/5",onClick:()=>k(!N),children:[(0,s.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm bg-amber-400"}),(0,s.jsx)(P,{expanded:N}),(0,s.jsx)(B,{}),(0,s.jsx)("span",{className:"font-semibold text-amber-400",children:"Pinned"}),(0,s.jsxs)("span",{className:"text-text-muted font-normal",children:["(",S.length,")"]})]}),N&&(0,s.jsx)("div",{className:"py-1 pl-4 flex flex-col gap-1",children:S.map(e=>(0,s.jsx)(w,{agent:e,isSelected:e.name===r,compact:p,isPinned:!0,isMaxPinned:l,onClick:i,onMessageClick:c,onReleaseClick:d,onLogsClick:x,onProfileClick:u,onPinToggle:h},e.name))})]}),M.map(e=>(0,s.jsx)(A,{group:e,isExpanded:f.has(e.prefix),selectedAgent:r,compact:p,showStats:b,pinnedAgents:o,isMaxPinned:l,onToggle:()=>D(e.prefix),onAgentSelect:i,onAgentMessage:c,onReleaseClick:d,onLogsClick:x,onProfileClick:u,onPinToggle:h},e.prefix))]})}function A(e){let{group:t,isExpanded:r,selectedAgent:n,compact:a,showStats:o,pinnedAgents:l=[],isMaxPinned:i=!1,onToggle:c,onAgentSelect:d,onAgentMessage:x,onReleaseClick:m,onLogsClick:p,onProfileClick:g,onPinToggle:b}=e,y=o?f(t.agents):null;if(1===t.agents.length&&t.agents[0].name.toLowerCase()===t.prefix.toLowerCase()){let e=t.agents[0];return(0,s.jsx)("div",{className:"mb-1 py-1 px-2",children:(0,s.jsx)(w,{agent:e,isSelected:e.name===n,compact:a,isPinned:l.includes(e.name),isMaxPinned:i,onClick:d,onMessageClick:x,onReleaseClick:m,onLogsClick:p,onProfileClick:g,onPinToggle:b},e.name)})}return(0,s.jsxs)("div",{className:"mb-1",children:[(0,s.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,s.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{backgroundColor:t.color.primary}}),(0,s.jsx)(E,{expanded:r}),(0,s.jsx)("span",{className:"font-semibold text-text-primary",children:t.displayName}),(0,s.jsxs)("span",{className:"text-text-muted font-normal",children:["(",t.agents.length,")"]}),o&&y&&(0,s.jsxs)("div",{className:"ml-auto flex gap-2",children:[y.online>0&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted",title:"".concat(y.online," agent").concat(y.online>1?"s":""," online"),children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:u.yh.online}}),y.online]}),y.needsAttention>0&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted",title:"".concat(y.needsAttention," agent").concat(y.needsAttention>1?"s":""," need").concat(1===y.needsAttention?"s":""," attention"),children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:u.yh.attention}}),y.needsAttention]})]})]}),r&&(0,s.jsx)("div",{className:"py-1 pl-4 flex flex-col gap-1",children:t.agents.map(e=>(0,s.jsx)(w,{agent:e,isSelected:e.name===n,compact:a,displayNameOverride:h(e.name),isPinned:l.includes(e.name),isMaxPinned:i,onClick:d,onMessageClick:x,onReleaseClick:m,onLogsClick:p,onProfileClick:g,onPinToggle:b},e.name))})]})}function E(e){let{expanded:t}=e;return(0,s.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,s.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function W(){return(0,s.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,s.jsx)("circle",{cx:"12",cy:"8",r:"5"}),(0,s.jsx)("path",{d:"M20 21a8 8 0 1 0-16 0"})]})}function T(){return(0,s.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function P(e){let{expanded:t}=e;return(0,s.jsx)("svg",{className:"text-amber-400 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,s.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function B(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-400",children:[(0,s.jsx)("path",{d:"M12 17v5"}),(0,s.jsx)("path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4.76Z"})]})}function _(e){return e.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}function I(e){let{projects:t,localAgents:r=[],bridgeAgents:a=[],currentProject:o,selectedAgent:l,searchQuery:i="",onProjectSelect:c,onAgentSelect:d,onReleaseClick:x,onLogsClick:u,onProfileClick:m,compact:h=!1}=e,[p,g]=(0,n.useState)(()=>new Set(t.map(e=>e.id))),b=e=>e.filter(e=>!e.name.startsWith("__setup__")&&"_DashboardUI"!==e.name),f=(0,n.useMemo)(()=>{let e=i.toLowerCase().trim(),s=b(r),n=b(a),o=t.map(e=>({...e,agents:b(e.agents)}));if(!e)return{projects:o,localAgents:s,bridgeAgents:n};let l=s.filter(t=>{var r;return t.name.toLowerCase().includes(e)||(null===(r=t.currentTask)||void 0===r?void 0:r.toLowerCase().includes(e))}),c=n.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:o.map(t=>{var r;let s=(null===(r=t.name)||void 0===r?void 0:r.toLowerCase().includes(e))||t.path.toLowerCase().includes(e),n=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 s||n.length>0?{...t,agents:s?t.agents:n}:null}).filter(Boolean),localAgents:l,bridgeAgents:c}},[t,r,a,i]),y=e=>{g(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},j=f.localAgents.length+f.projects.reduce((e,t)=>e+t.agents.length,0);if(0===j&&0===t.length&&0===r.length)return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-[#888] text-center",children:[(0,s.jsx)(G,{}),(0,s.jsx)("p",{children:"No projects or agents"})]});if(0===j&&i)return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-[#888] text-center",children:[(0,s.jsx)(V,{}),(0,s.jsxs)("p",{children:['No results for "',i,'"']})]});let v=f.projects.length>1;return(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[v&&f.bridgeAgents.length>0&&(0,s.jsx)(U,{agents:f.bridgeAgents,selectedAgent:l,compact:h,onAgentSelect:e=>null==d?void 0:d(e),onReleaseClick:x,onLogsClick:u,onProfileClick:m}),!v&&f.localAgents.length>0&&(0,s.jsx)(R,{project:{id:"__local__",path:"",name:"Local",agents:f.localAgents},isExpanded:p.has("__local__"),isCurrentProject:!0,selectedAgent:l,compact:h,onToggle:()=>y("__local__"),onAgentSelect:e=>null==d?void 0:d(e),onReleaseClick:x,onLogsClick:u}),f.projects.map(e=>(0,s.jsx)(R,{project:e,isExpanded:p.has(e.id),isCurrentProject:e.id===o,selectedAgent:l,compact:h,isBridgeMode:v,onToggle:()=>y(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 R(e){var t;let{project:r,isExpanded:a,isCurrentProject:o,selectedAgent:l,compact:i,isBridgeMode:c=!1,onToggle:d,onProjectSelect:x,onAgentSelect:m,onReleaseClick:h,onLogsClick:p,onProfileClick:g}=e,[b,f]=(0,n.useState)(new Set),y=(0,n.useMemo)(()=>{let e=0,t=0;for(let s of r.agents)"online"===s.status&&e++,s.needsAttention&&t++;return{online:e,needsAttention:t,total:r.agents.length}},[r.agents]),{teams:j,ungroupedAgents:v}=(0,n.useMemo)(()=>{let e=new Map,t=[];for(let s of r.agents)if(s.team){let t=e.get(s.team)||[];t.push(s),e.set(s.team,t)}else t.push(s);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]),N=e=>{f(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};(0,n.useEffect)(()=>{a&&0===b.size&&j.length>0&&f(new Set(j.map(e=>e.name)))},[a,j,b]);let k=(0,u.GW)(r.name||r.id),C=r.name||r.path.split("/").pop()||r.id;return(0,s.jsxs)("div",{className:"mb-1",children:[(0,s.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(o?"bg-[rgba(0,255,200,0.08)]":""),onClick:d,onDoubleClick:x,style:{"--project-color":k.primary,"--project-light":k.light},children:[(0,s.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{background:k.primary}}),(0,s.jsx)(O,{expanded:a}),(0,s.jsx)(H,{color:k.primary}),(0,s.jsx)("span",{className:"font-semibold text-[#e8e8e8] whitespace-nowrap overflow-hidden text-ellipsis",children:C}),(0,s.jsxs)("span",{className:"text-[#888] font-normal flex-shrink-0",children:["(",y.total,")"]}),(0,s.jsxs)("div",{className:"ml-auto flex gap-2 flex-shrink-0",children:[y.online>0&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-[#666]",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:u.yh.online}}),y.online]}),y.needsAttention>0&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-[#666]",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:u.yh.attention}}),y.needsAttention]})]}),(null===(t=r.lead)||void 0===t?void 0:t.connected)&&(0,s.jsx)("span",{className:"text-[#ffd700] text-xs ml-1",title:"Lead: ".concat(r.lead.name),children:"★"}),c&&!o&&x&&(0,s.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(),x()},title:"Switch to this project",children:"Switch"})]}),a&&(0,s.jsxs)("div",{className:"py-1 pl-5 flex flex-col gap-1",children:[j.map(e=>(0,s.jsxs)("div",{className:"mb-0.5",children:[(0,s.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:()=>N(e.name),children:[(0,s.jsx)(O,{expanded:b.has(e.name)}),(0,s.jsx)(z,{}),(0,s.jsx)("span",{className:"font-medium text-[#b8b8b8]",children:e.name}),(0,s.jsxs)("span",{className:"text-[#666] font-normal",children:["(",e.agents.length,")"]})]}),b.has(e.name)&&(0,s.jsx)("div",{className:"py-0.5 pl-4 flex flex-col gap-1",children:e.agents.map(t=>(0,s.jsx)(w,{agent:t,isSelected:t.name===l,compact:i,displayNameOverride:function(e,t){let r=e.toLowerCase(),s=t.toLowerCase().replace(/-?team$/i,"");if(s&&r.startsWith(s+"-")||s&&r.startsWith(s+"_"))return _(e.substring(s.length+1));let n=e.split("-");return n.length>1?_(n[n.length-1]):_(e)}(t.name,e.name),onClick:m,onReleaseClick:h,onLogsClick:p,onProfileClick:g},t.name))})]},e.name)),v.map(e=>(0,s.jsx)(w,{agent:e,isSelected:e.name===l,compact:i,onClick:m,onReleaseClick:h,onLogsClick:p,onProfileClick:g},e.name))]})]})}function U(e){let{agents:t,selectedAgent:r,compact:a,onAgentSelect:o,onReleaseClick:l,onLogsClick:i,onProfileClick:c}=e,[d,x]=(0,n.useState)(!0);return(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.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:()=>x(!d),children:[(0,s.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{background:"#a855f7"}}),(0,s.jsx)(O,{expanded:d}),(0,s.jsx)(F,{}),(0,s.jsx)("span",{className:"font-semibold text-[#e8e8e8]",children:"Bridge"}),(0,s.jsxs)("span",{className:"text-[#888] font-normal flex-shrink-0",children:["(",t.length,")"]})]}),d&&(0,s.jsx)("div",{className:"py-1 pl-5 flex flex-col gap-1",children:t.map(e=>(0,s.jsx)(w,{agent:e,isSelected:e.name===r,compact:a,onClick:o,onReleaseClick:l,onLogsClick:i,onProfileClick:c},e.name))})]})}function F(){return(0,s.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,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,s.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function O(e){let{expanded:t}=e;return(0,s.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,s.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function H(e){let{color:t}=e;return(0,s.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,s.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 z(){return(0,s.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,s.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,s.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,s.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function G(){return(0,s.jsx)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:(0,s.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 V(){return(0,s.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Z(e){let{threads:t,currentThread:r,onThreadSelect:n,totalUnreadCount:a=0,isCollapsed:o=!1,onToggleCollapse:l}=e;return 0===t.length?null:(0,s.jsxs)("div",{className:"px-2 py-2",children:[(0,s.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,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(q,{isCollapsed:o}),(0,s.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Threads"}),(0,s.jsxs)("span",{className:"text-xs text-text-dim font-mono",children:["(",t.length,")"]})]}),a>0&&(0,s.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,s.jsx)("div",{className:"space-y-1",children:t.map(e=>(0,s.jsx)(K,{thread:e,isSelected:r===e.id,onClick:()=>n(e.id)},e.id))})]})}function K(e){let{thread:t,isSelected:r,onClick:n}=e,a=t.unreadCount>0,o=function(e){let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/6e4),n=Math.floor(r/36e5),a=Math.floor(r/864e5);return s<1?"now":s<60?"".concat(s,"m"):n<24?"".concat(n,"h"):a<7?"".concat(a,"d"):t.toLocaleDateString([],{month:"short",day:"numeric"})}(t.lastMessage.timestamp);return(0,s.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:n,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,s.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,s.jsx)("div",{className:"absolute inset-0 opacity-20",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%)"}}),(0,s.jsx)(J,{})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.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,s.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,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-text-muted font-mono",children:[(0,s.jsx)("span",{className:"truncate",children:t.participants.slice(0,2).join(", ")}),t.participants.length>2&&(0,s.jsxs)("span",{className:"text-text-dim",children:["+",t.participants.length-2]}),(0,s.jsx)("span",{className:"text-text-dim opacity-50",children:"\xb7"}),(0,s.jsx)("span",{className:"text-text-dim",children:o})]})]})]})}function J(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.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 q(e){let{isCollapsed:t}=e;return(0,s.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,s.jsx)("polyline",{points:"9 18 15 12 9 6"})})}var $=r(6272);let Y="agent-relay-threads-collapsed",X="agent-relay-sidebar-tab",Q="agent-relay-channels-collapsed";function ee(e){var t;let{agents:r,bridgeAgents:a=[],projects:o=[],currentUserName:l,humanUnreadCounts:c={},currentProject:d,selectedAgent:u,viewMode:m,isFleetAvailable:h,isConnected:p,isOpen:g=!1,activeThreads:b=[],currentThread:f,totalUnreadThreadCount:y=0,isActivitySelected:j=!1,activityUnreadCount:v=0,onActivitySelect:w,channels:N=[],archivedChannels:k=[],selectedChannelId:C,onChannelSelect:S,onArchiveChannel:L,onUnarchiveChannel:M,onCreateChannel:A,onInviteToChannel:E,onAgentSelect:W,onHumanSelect:T,onProjectSelect:P,onViewModeChange:B,onSpawnClick:_,onReleaseClick:R,onLogsClick:U,onProfileClick:F,onThreadSelect:O,onClose:H,onSettingsClick:z,onTrajectoryClick:G,hasActiveTrajectory:V,onFleetClick:K,isFleetViewActive:J,onCoordinatorClick:q,hasMultipleProjects:ee}=e,[ev,ew]=(0,n.useState)(""),[eN,ek]=(0,n.useState)(()=>{try{let e=localStorage.getItem(X);return"team"===e?"team":"agents"}catch(e){return"agents"}}),[eC,eS]=(0,n.useState)(()=>{try{let e=localStorage.getItem(Y);return"true"===e}catch(e){return!1}}),[eL,eM]=(0,n.useState)(()=>{try{let e=localStorage.getItem(Q);return null===e||"true"===e}catch(e){return!0}});(0,n.useEffect)(()=>{try{localStorage.setItem(X,eN)}catch(e){}},[eN]),(0,n.useEffect)(()=>{try{localStorage.setItem(Y,String(eC))}catch(e){}},[eC]),(0,n.useEffect)(()=>{try{localStorage.setItem(Q,String(eL))}catch(e){}},[eL]);let eD=N.reduce((e,t)=>e+t.unreadCount,0),eA=N.length>0,eE=!!eA&&eL,eW=k.length>0,[eT,eP]=(0,n.useState)(!0),[eB,e_]=(0,n.useState)(null);(0,n.useEffect)(()=>{e_(null)},[C]);let eI=r.filter(e=>!e.isHuman&&"_DashboardUI"!==e.name),eR=r.filter(e=>e.isHuman&&"_DashboardUI"!==e.name&&(!l||e.name.toLowerCase()!==l.toLowerCase())),eU=eR.filter(e=>!ev||e.name.toLowerCase().includes(ev.toLowerCase())),{pinnedAgents:eF,togglePin:eO,isMaxPinned:eH}=function(){let[e,t]=(0,n.useState)(()=>(function(){try{if("undefined"==typeof localStorage)return[];let e=localStorage.getItem(i);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t.slice(0,5)}}catch(e){}return[]})());(0,n.useEffect)(()=>{!function(e){try{if("undefined"==typeof localStorage)return;localStorage.setItem(i,JSON.stringify(e))}catch(e){}}(e)},[e]);let r=(0,n.useCallback)(t=>e.includes(t),[e]),s=(0,n.useCallback)(r=>{let{newPinned:s,success:n}=e.includes(r)?{newPinned:e,success:!0}:e.length>=5?{newPinned:e,success:!1}:{newPinned:[...e,r],success:!0};return s!==e&&t(s),n},[e]),a=(0,n.useCallback)(e=>{t(t=>t.filter(t=>t!==e))},[]),o=(0,n.useCallback)(e=>{r(e)?a(e):s(e)},[r,s,a]),l=(0,n.useMemo)(()=>e.length>=5,[e]);return{pinnedAgents:e,isPinned:r,togglePin:o,pin:s,unpin:a,isMaxPinned:l,maxPinned:5}}(),{workspace:ez}=x(),eG=null!==(t=null==ez?void 0:ez.isStopped)&&void 0!==t&&t,eV=o.length>0;return(0,s.jsxs)("aside",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsx)("div",{className:"p-3 sm:p-4 border-b border-border-subtle",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3",children:[(0,s.jsx)($.K7,{size:24,withGlow:!0}),(0,s.jsx)("h1",{className:"text-base sm:text-lg font-display font-semibold m-0 text-text-primary",children:"Agent Relay"}),(0,s.jsx)(et,{isConnected:p}),(0,s.jsx)("button",{className:"md:hidden ml-auto p-2 -mr-1 sm:-mr-2 bg-transparent border-none text-text-muted cursor-pointer rounded-lg transition-colors hover:bg-bg-hover hover:text-text-primary active:bg-bg-hover",onClick:H,"aria-label":"Close sidebar",children:(0,s.jsx)(eu,{})})]})}),eR.length>0&&(0,s.jsxs)("div",{className:"flex bg-bg-tertiary rounded-lg p-1 mx-3 mt-3",children:[(0,s.jsxs)("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 flex items-center justify-center gap-1.5\n ".concat("agents"===eN?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>ek("agents"),children:[(0,s.jsx)(eh,{}),"Agents",eI.length>0&&(0,s.jsxs)("span",{className:"text-[10px] opacity-70",children:["(",eI.length,")"]})]}),(0,s.jsxs)("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 flex items-center justify-center gap-1.5\n ".concat("team"===eN?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>ek("team"),children:[(0,s.jsx)(ep,{}),"Team",eR.length>0&&(0,s.jsxs)("span",{className:"text-[10px] opacity-70",children:["(",eR.length,")"]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 py-2 sm:py-2.5 px-2 sm:px-3 bg-bg-tertiary m-2 sm:m-3 rounded-lg border border-border-subtle focus-within:border-accent-cyan/50 transition-colors",children:[(0,s.jsx)(er,{}),(0,s.jsx)("input",{type:"text",placeholder:"agents"===eN?"Search agents...":"Search team...",value:ev,onChange:e=>ew(e.target.value),className:"flex-1 bg-transparent border-none text-text-primary text-sm outline-none placeholder:text-text-muted"}),ev&&(0,s.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 active:text-text-secondary",onClick:()=>ew(""),children:(0,s.jsx)(es,{})})]}),b.length>0&&(0,s.jsx)("div",{className:"border-b border-border-subtle",children:(0,s.jsx)(Z,{threads:b,currentThread:f,onThreadSelect:e=>null==O?void 0:O(e),totalUnreadCount:y,isCollapsed:eC,onToggleCollapse:()=>eS(!eC)})}),(0,s.jsx)("div",{className:"border-b border-border-subtle px-2 py-2",children:(0,s.jsxs)("button",{onClick:w,className:"\n w-full flex items-center gap-2 px-2 py-2 rounded-lg text-left text-sm transition-colors\n ".concat(j?"bg-accent-cyan/10 text-text-primary border border-accent-cyan/30":"hover:bg-bg-hover text-text-secondary hover:text-text-primary border border-transparent","\n "),children:[(0,s.jsx)(ej,{}),(0,s.jsx)("span",{className:"flex-1 ".concat(v>0?"font-semibold text-text-primary":""),children:"Activity"}),v>0&&(0,s.jsx)("span",{className:"text-[11px] font-semibold px-1.5 py-0.5 rounded-full bg-accent-cyan/20 text-accent-cyan",children:v})]})}),!eG&&(0,s.jsxs)("div",{className:"border-b border-border-subtle",children:[(0,s.jsxs)("button",{className:"w-full flex items-center justify-between px-3 py-2 text-xs font-semibold text-text-muted uppercase tracking-wide hover:bg-bg-hover transition-colors",onClick:()=>eM(!eL),children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(ec,{}),"Channels",eD>0&&(0,s.jsx)("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded-full bg-accent-cyan/20 text-accent-cyan",children:eD})]}),(0,s.jsx)(ed,{className:"transition-transform ".concat(eE?"":"rotate-180")})]}),!eE&&(0,s.jsxs)("div",{className:"px-2 pb-2 space-y-0.5 max-h-40 md:max-h-none overflow-y-auto",children:[N.map(e=>(0,s.jsxs)("div",{className:"group relative",children:[(0,s.jsxs)("button",{onClick:()=>null==S?void 0:S(e),className:"\n w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-sm transition-colors\n ".concat(C===e.id?"bg-accent-cyan/10 text-text-primary":"hover:bg-bg-hover text-text-secondary hover:text-text-primary","\n "),children:[(0,s.jsx)("span",{className:"text-text-muted",children:"#"}),(0,s.jsx)("span",{className:"flex-1 truncate ".concat(e.unreadCount>0?"font-semibold text-text-primary":""),children:e.name}),e.unreadCount>0&&(0,s.jsx)("span",{className:"\n text-[11px] font-semibold px-1.5 py-0.5 rounded-full min-w-[18px] text-center\n ".concat(e.hasMentions?"bg-red-500/20 text-red-400":"bg-accent-cyan/20 text-accent-cyan","\n "),children:e.unreadCount})]}),(E||L)&&(0,s.jsx)("button",{onClick:t=>{t.stopPropagation(),e_(eB===e.id?null:e.id)},title:"Channel actions",className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",children:(0,s.jsx)(ex,{})}),eB===e.id&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-30 bg-bg-elevated border border-border-subtle rounded-lg shadow-lg py-1 min-w-[160px]",children:[E&&(0,s.jsxs)(en,{onClick:()=>{E(e),e_(null)},children:[(0,s.jsx)(eo,{}),(0,s.jsx)("span",{children:"Invite members"})]}),L&&(0,s.jsxs)(en,{onClick:()=>{L(e),e_(null)},children:[(0,s.jsx)(el,{}),(0,s.jsx)("span",{children:"Archive"})]})]})]},e.id)),A&&(0,s.jsxs)("button",{onClick:A,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-sm text-text-muted hover:bg-bg-hover hover:text-text-secondary transition-colors",children:[(0,s.jsx)(ea,{}),(0,s.jsx)("span",{children:eA?"Add channel":"Create your first channel"})]})]}),eW&&(0,s.jsxs)("div",{className:"mt-1 border-t border-border-subtle",children:[(0,s.jsxs)("button",{className:"w-full flex items-center justify-between px-3 py-2 text-xs font-semibold text-text-muted uppercase tracking-wide hover:bg-bg-hover transition-colors",onClick:()=>eP(!eT),children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(el,{}),"Archived",(0,s.jsxs)("span",{className:"text-[10px] opacity-80",children:["(",k.length,")"]})]}),(0,s.jsx)(ed,{className:"transition-transform ".concat(eT?"":"rotate-180")})]}),!eT&&(0,s.jsx)("div",{className:"px-2 pb-2 space-y-0.5 max-h-32 md:max-h-none overflow-y-auto",children:k.map(e=>(0,s.jsxs)("div",{className:"group relative",children:[(0,s.jsxs)("button",{onClick:()=>null==S?void 0:S(e),className:"\n w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-left text-sm transition-colors\n ".concat(C===e.id?"bg-bg-tertiary text-text-primary":"hover:bg-bg-hover text-text-secondary hover:text-text-primary","\n "),children:[(0,s.jsx)("span",{className:"text-text-muted",children:"#"}),(0,s.jsx)("span",{className:"flex-1 truncate",children:e.name}),(0,s.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full bg-border-subtle text-text-muted",children:"Archived"})]}),M&&(0,s.jsxs)("button",{onClick:t=>{t.stopPropagation(),M(e)},title:"Unarchive channel",className:"absolute right-1 top-1/2 -translate-y-1/2 px-2 py-1 rounded-md bg-bg-tertiary text-text-secondary hover:text-text-primary hover:bg-bg-hover transition-colors text-xs flex items-center gap-1",children:[(0,s.jsx)(ei,{}),(0,s.jsx)("span",{children:"Unarchive"})]})]},e.id))})]})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto px-2",children:["team"===eN&&eR.length>0?(0,s.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[eU.map(e=>(0,s.jsxs)("button",{onClick:()=>T?T(e):null==W?void 0:W(e),className:"\n flex items-center gap-3 p-3 rounded-lg border transition-all duration-150 text-left w-full\n ".concat(u===e.name?"bg-accent-cyan/10 border-accent-cyan/30":"bg-bg-tertiary border-border-subtle hover:border-accent-cyan/30 hover:bg-bg-hover","\n "),children:[e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-9 h-9 rounded-full object-cover"}):(0,s.jsx)("div",{className:"w-9 h-9 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white font-medium text-sm",children:e.name.charAt(0).toUpperCase()}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.role||"Team Member"})]}),c[e.name]>0&&(0,s.jsx)("span",{className:"text-[11px] font-semibold px-2 py-0.5 rounded-full bg-accent-cyan/20 text-accent-cyan",children:c[e.name]}),(0,s.jsx)("div",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-dim")})]},e.name)),0===eU.length&&(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,s.jsx)(er,{}),(0,s.jsxs)("p",{className:"mt-3",children:['No team members match "',ev,'"']})]})]}):eV?(0,s.jsx)(I,{projects:o,localAgents:eI,bridgeAgents:a,currentProject:d,selectedAgent:u,searchQuery:ev,onProjectSelect:P,onAgentSelect:W,onReleaseClick:R,onLogsClick:U,onProfileClick:F,compact:!0}):(0,s.jsx)(D,{agents:eI,selectedAgent:u,searchQuery:ev,pinnedAgents:eF,isMaxPinned:eH,onAgentSelect:e=>null==W?void 0:W(e),onReleaseClick:R,onLogsClick:U,onProfileClick:F,onPinToggle:e=>eO(e.name),compact:!0,showGroupStats:!0}),"agents"===eN&&eR.length>0&&(0,s.jsxs)("div",{className:"mt-4 mb-2 pt-3 border-t border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-1 pb-2",children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wide text-text-muted font-semibold m-0",children:"Direct messages"}),(0,s.jsxs)("span",{className:"text-[11px] text-text-muted",children:[eU.length," member",1===eU.length?"":"s"]})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1",children:eU.length>0?eU.map(e=>(0,s.jsxs)("button",{onClick:()=>T?T(e):null==W?void 0:W(e),className:"\n flex items-center gap-3 p-2.5 rounded-lg border transition-all duration-150 text-left w-full\n ".concat(u===e.name?"bg-accent-cyan/10 border-accent-cyan/30":"bg-bg-tertiary border-border-subtle hover:border-accent-cyan/30 hover:bg-bg-hover","\n "),children:[e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-8 h-8 rounded-full object-cover"}):(0,s.jsx)("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white font-medium text-xs",children:e.name.charAt(0).toUpperCase()}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),(0,s.jsx)("p",{className:"text-[11px] text-text-muted truncate",children:e.role||"Team Member"})]}),c[e.name]>0&&(0,s.jsx)("span",{className:"text-[11px] font-semibold px-2 py-0.5 rounded-full bg-accent-cyan/20 text-accent-cyan",children:c[e.name]}),(0,s.jsx)("div",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-dim")})]},e.name)):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 px-3 text-text-muted text-center",children:[(0,s.jsx)(er,{}),(0,s.jsxs)("p",{className:"mt-2 text-xs",children:['No team members match "',ev,'"']})]})})]})]}),(0,s.jsxs)("div",{className:"md:hidden border-t border-border-subtle p-3",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted font-medium mb-2 px-1",children:"Quick Actions"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[K&&(0,s.jsxs)("button",{className:"flex items-center gap-2 p-2.5 rounded-lg border text-sm transition-all duration-150 ".concat(J?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>{K(),null==H||H()},children:[(0,s.jsx)(eg,{}),(0,s.jsx)("span",{children:"Fleet"})]}),G&&(0,s.jsxs)("button",{className:"flex items-center gap-2 p-2.5 rounded-lg border text-sm transition-all duration-150 relative ".concat(V?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>{G(),null==H||H()},children:[(0,s.jsx)(eb,{}),(0,s.jsx)("span",{children:"Trajectory"}),V&&(0,s.jsx)("span",{className:"absolute top-1 right-1 w-2 h-2 bg-accent-cyan rounded-full animate-pulse"})]}),ee&&q&&(0,s.jsxs)("button",{className:"flex items-center gap-2 p-2.5 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary text-sm transition-all duration-150 hover:bg-bg-hover hover:text-accent-purple",onClick:()=>{q(),null==H||H()},children:[(0,s.jsx)(ef,{}),(0,s.jsx)("span",{children:"Coordinator"})]}),(0,s.jsxs)("a",{href:"/metrics",className:"flex items-center gap-2 p-2.5 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary text-sm transition-all duration-150 hover:bg-bg-hover hover:text-accent-orange no-underline",onClick:()=>null==H?void 0:H(),children:[(0,s.jsx)(ey,{}),(0,s.jsx)("span",{children:"Metrics"})]})]})]}),(0,s.jsxs)("div",{className:"p-3 sm:p-4 border-t border-border-subtle space-y-2",children:[(0,s.jsxs)("button",{className:"w-full py-2.5 sm:py-3 px-3 sm: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 active:scale-[0.98]",onClick:_,children:[(0,s.jsx)(ea,{}),"Spawn Agent"]}),(0,s.jsxs)("button",{className:"w-full py-2 sm:py-2.5 px-3 sm:px-4 bg-bg-tertiary text-text-secondary text-sm cursor-pointer flex items-center justify-center gap-2 rounded-lg border border-border-subtle transition-all duration-150 hover:bg-bg-hover hover:text-text-primary hover:border-border-subtle active:bg-bg-hover",onClick:z,children:[(0,s.jsx)(em,{}),"Settings"]})]})]})}function et(e){let{isConnected:t}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-1.5 ml-auto",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(t?"bg-success animate-pulse-glow":"bg-text-dim")}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:t?"Live":"Offline"})]})}function er(){return(0,s.jsxs)("svg",{className:"text-text-muted",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function es(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function en(e){let{onClick:t,children:r}=e;return(0,s.jsx)("button",{onClick:t,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-text-secondary hover:bg-bg-hover hover:text-text-primary transition-colors",children:r})}function ea(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function eo(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"8.5",cy:"7",r:"4"}),(0,s.jsx)("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),(0,s.jsx)("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]})}function el(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M3 7h18"}),(0,s.jsx)("path",{d:"M5 7v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7"}),(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"4",rx:"1"}),(0,s.jsx)("line",{x1:"10",y1:"12",x2:"14",y2:"12"})]})}function ei(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M3 7h18"}),(0,s.jsx)("path",{d:"M5 7v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7"}),(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"4",rx:"1"}),(0,s.jsx)("path",{d:"M12 11v6"}),(0,s.jsx)("path",{d:"M9 14l3-3 3 3"})]})}function ec(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,s.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,s.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,s.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function ed(e){let{className:t}=e;return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function ex(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"5",cy:"12",r:"1"}),(0,s.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,s.jsx)("circle",{cx:"19",cy:"12",r:"1"})]})}function eu(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function em(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.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 eh(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,s.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,s.jsx)("path",{d:"M12 7v4"}),(0,s.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,s.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function ep(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,s.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,s.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function eg(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function eb(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4"})})}function ef(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,s.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function ey(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M3 3v18h18"}),(0,s.jsx)("path",{d:"M18 17V9"}),(0,s.jsx)("path",{d:"M13 17V5"}),(0,s.jsx)("path",{d:"M8 17v-3"})]})}function ej(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})}function ev(e){let{projects:t,recentProjects:r=[],currentProject:a,onProjectChange:o}=e,[l,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(-1),x=(0,n.useRef)(null),u=(0,n.useRef)([]),m=t.length>1,h=new Set(r.map(e=>e.id)),p=t.filter(e=>!h.has(e.id)),g=[...r,...p],b=e=>{if(!e)return"No project";if(e.name)return e.name;let t=e.path.split("/").filter(Boolean);return t.length>=2?"".concat(t[t.length-2],"/").concat(t[t.length-1]):t[t.length-1]||e.id};return((0,n.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&i(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.useEffect)(()=>{let e=e=>{if(l)switch(e.key){case"Escape":i(!1),d(-1);break;case"ArrowDown":e.preventDefault(),d(e=>{var t;let r=e<g.length-1?e+1:0;return null===(t=u.current[r])||void 0===t||t.focus(),r});break;case"ArrowUp":e.preventDefault(),d(e=>{var t;let r=e>0?e-1:g.length-1;return null===(t=u.current[r])||void 0===t||t.focus(),r});break;case"Enter":c>=0&&c<g.length&&(o(g[c]),i(!1),d(-1))}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l,c,g,o]),(0,n.useEffect)(()=>{if(l){let e=g.findIndex(e=>e.id===(null==a?void 0:a.id));d(e>=0?e:0)}else d(-1)},[l,g,a]),0===t.length)?null:(0,s.jsxs)("div",{className:"relative",ref:x,children:[(0,s.jsxs)("button",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150 border ".concat(m?"bg-bg-tertiary/80 border-border-subtle hover:bg-bg-elevated hover:border-border-medium cursor-pointer":"bg-transparent border-transparent cursor-default"),onClick:()=>m&&i(!l),disabled:!m,"aria-expanded":l,"aria-haspopup":"listbox",children:[(0,s.jsx)(ek,{}),(0,s.jsx)("span",{className:"text-text-primary truncate max-w-[200px]",children:b(a)}),m&&(0,s.jsx)(eC,{isOpen:l})]}),l&&m&&(0,s.jsxs)("div",{className:"absolute top-[calc(100%+4px)] left-0 min-w-[280px] bg-bg-primary border border-border-subtle rounded-xl shadow-[0_10px_40px_rgba(0,0,0,0.4)] z-[1000] overflow-hidden",children:[(0,s.jsx)("div",{className:"px-3 py-2 border-b border-border-subtle",children:(0,s.jsx)("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wider",children:"Switch Project"})}),(0,s.jsxs)("div",{className:"max-h-[300px] overflow-y-auto",role:"listbox",children:[r.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"px-3 py-1.5 bg-bg-tertiary/50",children:(0,s.jsxs)("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wider flex items-center gap-1.5",children:[(0,s.jsx)(eN,{}),"Recent"]})}),(0,s.jsx)("div",{className:"py-1",children:r.map((e,t)=>(0,s.jsx)(ew,{project:e,index:t,isActive:(null==a?void 0:a.id)===e.id,isFocused:c===t,formatProjectName:b,buttonRefs:u,onSelect:()=>{o(e),i(!1)}},e.id))})]}),p.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"px-3 py-1.5 bg-bg-tertiary/50",children:(0,s.jsx)("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wider",children:r.length>0?"All Projects":"Projects"})}),(0,s.jsx)("div",{className:"py-1",children:p.map((e,t)=>{let n=r.length+t;return(0,s.jsx)(ew,{project:e,index:n,isActive:(null==a?void 0:a.id)===e.id,isFocused:c===n,formatProjectName:b,buttonRefs:u,onSelect:()=>{o(e),i(!1)}},e.id)})})]})]})]})]})}function ew(e){var t,r;let{project:n,index:a,isActive:o,isFocused:l,formatProjectName:i,buttonRefs:c,onSelect:d}=e,x=i(n),u=(null===(t=n.agents)||void 0===t?void 0:t.length)||0;return(0,s.jsxs)("button",{ref:e=>{c.current[a]=e},className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors border-none cursor-pointer ".concat(o?"bg-accent-cyan/10 text-accent-cyan":l?"bg-bg-hover text-text-primary":"bg-transparent text-text-primary hover:bg-bg-hover"),onClick:d,role:"option","aria-selected":o,tabIndex:l?0:-1,children:[(0,s.jsx)(ek,{className:o?"text-accent-cyan":"text-text-muted"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-medium text-sm truncate",children:x}),(0,s.jsx)("div",{className:"text-xs text-text-muted truncate",children:n.path})]}),(0,s.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(o?"bg-accent-cyan/20 text-accent-cyan":"bg-bg-tertiary text-text-muted"),children:[u," ",1===u?"agent":"agents"]}),(null===(r=n.lead)||void 0===r?void 0:r.connected)&&(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-success animate-pulse",title:"Lead: ".concat(n.lead.name)}),o&&(0,s.jsx)(eS,{})]})}function eN(){return(0,s.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function ek(e){let{className:t="text-text-muted"}=e;return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,s.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 eC(e){let{isOpen:t}=e;return(0,s.jsx)("svg",{className:"text-text-muted transition-transform duration-150 ".concat(t?"rotate-180":""),width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function eS(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-cyan",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function eL(e){let{expanded:t=!1,autoWakeup:r=!1,onWakeup:a,onStatusChange:o,className:l=""}=e,[i,c]=(0,n.useState)(!1),[d,u]=(0,n.useState)(""),{workspace:m,exists:h,isLoading:p,isWakingUp:g,statusMessage:b,actionNeeded:f,wakeup:y}=x({autoWakeup:r,onStatusChange:(e,t)=>{null==o||o(e),t?(u("Workspace is starting up..."),c(!0),setTimeout(()=>c(!1),5e3)):"running"===e&&(u("Workspace is ready!"),c(!0),setTimeout(()=>c(!1),3e3))}}),j=(0,n.useCallback)(async()=>{let e=await y();e.success&&(null==a||a(),u(e.message),c(!0),setTimeout(()=>c(!1),5e3))},[y,a]),v=h?p&&!m?{color:"text-text-muted",bgColor:"bg-bg-tertiary",borderColor:"border-border-subtle",icon:(0,s.jsx)(eT,{}),label:"Loading...",pulseColor:null}:(null==m?void 0:m.isRunning)?{color:"text-success",bgColor:"bg-success/10",borderColor:"border-success/30",icon:(0,s.jsx)(eM,{}),label:"Running",pulseColor:"bg-success"}:(null==m?void 0:m.isStopped)?{color:"text-amber-400",bgColor:"bg-amber-400/10",borderColor:"border-amber-400/30",icon:(0,s.jsx)(eD,{}),label:"Stopped",pulseColor:null}:(null==m?void 0:m.isProvisioning)||g?{color:"text-accent-cyan",bgColor:"bg-accent-cyan/10",borderColor:"border-accent-cyan/30",icon:(0,s.jsx)(eA,{}),label:g?"Starting...":"Provisioning",pulseColor:"bg-accent-cyan"}:(null==m?void 0:m.hasError)?{color:"text-error",bgColor:"bg-error/10",borderColor:"border-error/30",icon:(0,s.jsx)(eE,{}),label:"Error",pulseColor:null}:{color:"text-text-muted",bgColor:"bg-bg-tertiary",borderColor:"border-border-subtle",icon:(0,s.jsx)(eW,{}),label:"Unknown",pulseColor:null}:{color:"text-text-muted",bgColor:"bg-bg-tertiary",borderColor:"border-border-subtle",icon:(0,s.jsx)(eW,{}),label:"No workspace",pulseColor:null};return t?(0,s.jsxs)("div",{className:"rounded-lg border ".concat(v.borderColor," ").concat(v.bgColor," p-4 ").concat(l),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:v.color,children:v.icon}),(0,s.jsx)("span",{className:"text-sm font-semibold ".concat(v.color),children:"Workspace Status"})]}),v.pulseColor&&(0,s.jsx)("span",{className:"w-2.5 h-2.5 rounded-full ".concat(v.pulseColor," animate-pulse")})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Name"}),(0,s.jsx)("span",{className:"text-sm text-text-primary font-medium truncate max-w-[150px]",children:(null==m?void 0:m.name)||"None"})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Status"}),(0,s.jsx)("span",{className:"text-sm font-medium ".concat(v.color),children:v.label})]}),b&&(0,s.jsx)("p",{className:"text-xs text-text-muted mt-2",children:b}),"wakeup"===f&&!g&&(0,s.jsx)("button",{onClick:j,className:"w-full mt-3 px-3 py-2 text-sm font-medium text-amber-400 bg-amber-400/10 border border-amber-400/30 rounded-lg hover:bg-amber-400/20 transition-colors",children:"Wake up workspace"}),"check_error"===f&&(0,s.jsx)("a",{href:"/workspaces/".concat(null==m?void 0:m.id),className:"block w-full mt-3 px-3 py-2 text-sm font-medium text-center text-error bg-error/10 border border-error/30 rounded-lg hover:bg-error/20 transition-colors no-underline",children:"View error details"})]}),i&&(0,s.jsx)("div",{className:"mt-3 px-3 py-2 bg-bg-card border border-border-medium rounded-lg text-sm text-text-primary animate-in fade-in",children:d})]}):(0,s.jsxs)("div",{className:"relative ".concat(l),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg border ".concat(v.bgColor," ").concat(v.borderColor," cursor-default"),title:b||v.label,children:[(0,s.jsx)("span",{className:v.color,children:v.icon}),(0,s.jsx)("span",{className:"text-xs font-medium ".concat(v.color," truncate max-w-[100px]"),title:b||v.label,children:v.label}),v.pulseColor&&(0,s.jsx)("span",{className:"w-2 h-2 rounded-full ".concat(v.pulseColor," animate-pulse")})]}),"wakeup"===f&&!g&&(0,s.jsx)("button",{onClick:j,className:"ml-2 px-2 py-1 text-xs font-medium text-amber-400 bg-amber-400/10 border border-amber-400/30 rounded hover:bg-amber-400/20 transition-colors",children:"Wake up"}),i&&(0,s.jsx)("div",{className:"absolute top-full mt-2 left-0 z-50 px-3 py-2 bg-bg-card border border-border-medium rounded-lg shadow-lg text-sm text-text-primary whitespace-nowrap animate-in fade-in slide-in-from-top-2",children:d})]})}function eM(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})}function eD(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("rect",{x:"6",y:"6",width:"12",height:"12"})})}function eA(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:(0,s.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function eE(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,s.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}function eW(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),(0,s.jsx)("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function eT(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),(0,s.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]})}function eP(e){let{currentChannel:t,selectedAgent:r,projects:n=[],currentProject:a,recentProjects:o=[],viewMode:l,selectedChannelName:i,onProjectChange:c,onCommandPaletteOpen:d,onSettingsClick:x,onHistoryClick:m,onNewConversationClick:h,onCoordinatorClick:g,onFleetClick:b,isFleetViewActive:f,onTrajectoryClick:y,hasActiveTrajectory:j,onMenuClick:v,hasUnreadNotifications:w}=e,N="channels"===l,k=N&&i?i:t,C=r?(0,u.GW)(r.name):null,S=n.length>1;return(0,s.jsxs)("header",{className:"h-[52px] bg-bg-secondary border-b border-border-subtle flex items-center justify-between px-2 sm:px-4",children:[(0,s.jsxs)("button",{className:"flex md:hidden items-center justify-center w-10 h-10 sm:w-11 sm:h-11 bg-transparent border-none text-text-primary cursor-pointer rounded-lg transition-colors hover:bg-bg-hover active:bg-bg-hover relative flex-shrink-0",onClick:v,"aria-label":"Open menu",children:[(0,s.jsx)(eH,{}),w&&(0,s.jsx)("span",{className:"absolute top-1 right-1 sm:top-1.5 sm: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)]"})]}),n.length>0&&c&&(0,s.jsx)("div",{className:"max-md:hidden mr-3",children:(0,s.jsx)(ev,{projects:n,recentProjects:o,currentProject:null!=a?a:null,onProjectChange:c})}),n.length>0&&c&&(0,s.jsx)("div",{className:"w-px h-6 bg-border-subtle mr-3 max-md:hidden"}),(0,s.jsx)(eL,{className:"max-md:hidden mr-3"}),(0,s.jsx)("div",{className:"w-px h-6 bg-border-subtle mr-3 max-md:hidden"}),(0,s.jsx)("div",{className:"flex items-center gap-2 sm:gap-3 flex-1 min-w-0",children:N&&i?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-accent-cyan text-base sm:text-lg font-mono",children:"#"}),(0,s.jsx)("span",{className:"font-display font-semibold text-sm sm:text-base text-text-primary truncate max-w-[100px] sm:max-w-none",children:i})]}):"general"===k?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-accent-cyan text-base sm:text-lg font-mono",children:"#"}),(0,s.jsx)("span",{className:"font-display font-semibold text-sm sm:text-base text-text-primary truncate max-w-[100px] sm:max-w-none",children:"general"}),(0,s.jsx)("span",{className:"text-text-muted text-sm ml-2 pl-3 border-l border-border-subtle hidden md:inline",children:"All agent communications"})]}):r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-7 h-7 sm:w-8 sm:h-8 rounded-lg flex items-center justify-center font-semibold text-[10px] sm:text-xs border-2 flex-shrink-0",style:{backgroundColor:null==C?void 0:C.primary,borderColor:null==C?void 0:C.primary,boxShadow:"0 0 12px ".concat(null==C?void 0:C.primary,"40")},children:(0,s.jsx)("span",{style:{color:null==C?void 0:C.text},children:(0,u.hP)(r.name)})}),(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,s.jsx)("span",{className:"font-display font-semibold text-sm sm:text-base text-text-primary truncate",children:r.name}),(0,s.jsx)("span",{className:"text-text-muted text-xs font-mono hidden md:block truncate",children:p(r.name)})]}),r.status&&(0,s.jsx)("span",{className:"hidden sm:inline text-xs py-1 px-2.5 rounded-full font-medium ml-2 flex-shrink-0 truncate max-w-[80px] ".concat("online"===r.status?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"),title:r.status,children:r.status})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-accent-cyan text-base sm:text-lg font-mono",children:"@"}),(0,s.jsx)("span",{className:"font-display font-semibold text-sm sm:text-base text-text-primary truncate",children:t})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2",children:[(0,s.jsxs)("button",{className:"flex items-center gap-1 sm:gap-2 py-1.5 sm:py-2 px-2 sm:px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-lg text-xs sm:text-sm cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:h,title:"Start new conversation (⌘N)",children:[(0,s.jsx)(eB,{}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"New"}),(0,s.jsx)("span",{className:"hidden md:inline",children:"Message"})]}),(0,s.jsxs)("button",{className:"flex items-center gap-1 sm:gap-2 py-1.5 sm:py-2 px-2 sm:px-3 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary text-xs sm:text-sm cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-text-primary",onClick:d,title:"Command Palette (⌘K)",children:[(0,s.jsx)(e_,{}),(0,s.jsx)("span",{className:"hidden md:inline",children:"Search"}),(0,s.jsx)("kbd",{className:"hidden md:inline bg-bg-card border border-border-subtle rounded px-1.5 py-0.5 text-xs text-text-muted font-mono",children:"⌘K"})]}),(0,s.jsx)("button",{className:"hidden sm:flex items-center justify-center p-1.5 sm: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:m,title:"Message History",children:(0,s.jsx)(eI,{})}),S&&(0,s.jsx)("button",{className:"hidden md: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:g,title:"Coordinator Agent",children:(0,s.jsx)(ez,{})}),b&&(0,s.jsx)("button",{className:"hidden sm:flex items-center justify-center p-1.5 sm:p-2 border rounded-lg cursor-pointer transition-all duration-150 ".concat(f?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan"),onClick:b,title:f?"Back to Chat":"Fleet Overview",children:(0,s.jsx)(eU,{})}),y&&(0,s.jsxs)("button",{className:"hidden md:flex items-center justify-center p-2 border rounded-lg cursor-pointer transition-all duration-150 relative ".concat(j?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan"),onClick:y,title:"Trajectory Viewer",children:[(0,s.jsx)(eF,{}),j&&(0,s.jsx)("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-accent-cyan rounded-full animate-pulse"})]}),(0,s.jsx)("a",{href:"/metrics",className:"hidden sm:flex items-center justify-center p-1.5 sm: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,s.jsx)(eR,{})}),(0,s.jsx)("button",{className:"flex items-center justify-center p-1.5 sm: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:x,title:"Settings",children:(0,s.jsx)(eO,{})})]})]})}function eB(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,s.jsx)("path",{d:"M12 20h9"}),(0,s.jsx)("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}function e_(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function eI(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function eR(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M3 3v18h18"}),(0,s.jsx)("path",{d:"M18 17V9"}),(0,s.jsx)("path",{d:"M13 17V5"}),(0,s.jsx)("path",{d:"M8 17v-3"})]})}function eU(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function eF(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4"})})}function eO(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.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 eH(){return(0,s.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,s.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,s.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}function ez(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,s.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function eG(e){let{status:t,size:r="small"}=e;if(!t)return null;let n={small:"w-3.5 h-3.5",medium:"w-4 h-4"}[r];return"sending"===t||"unread"===t?(0,s.jsx)("span",{className:"inline-flex items-center justify-center ".concat(n," text-text-muted"),title:"Sending...",children:(0,s.jsx)(eV,{className:n})}):"acked"===t||"read"===t?(0,s.jsx)("span",{className:"inline-flex items-center justify-center ".concat(n," text-success"),title:"Delivered",children:(0,s.jsx)(eZ,{className:n})}):"failed"===t?(0,s.jsx)("span",{className:"inline-flex items-center justify-center ".concat(n," text-error"),title:"Delivery failed",children:(0,s.jsx)(eK,{className:n})}):null}function eV(e){let{className:t}=e;return(0,s.jsxs)("svg",{className:"animate-pulse ".concat(t),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,s.jsx)("path",{d:"M8 5v3l2 1",strokeLinecap:"round",strokeLinejoin:"round"})]})}function eZ(e){let{className:t}=e;return(0,s.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M3 8l3 3 7-7",strokeLinecap:"round",strokeLinejoin:"round"})})}function eK(e){let{className:t}=e;return(0,s.jsxs)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,s.jsx)("line",{x1:"8",y1:"5",x2:"8",y2:"8",strokeLinecap:"round"}),(0,s.jsx)("circle",{cx:"8",cy:"11",r:"0.5",fill:"currentColor",stroke:"none"})]})}function eJ(e){let{displayName:t,color:r,isCurrentUser:a=!1,agent:o,userPresence:l,onAgentClick:i,onUserClick:c,className:d=""}=e,x=(0,n.useCallback)(()=>{o&&i?i(o):l&&c&&c(l)},[o,l,i,c]);return o&&i||l&&c?(0,s.jsx)("button",{type:"button",onClick:x,className:"\n font-display font-semibold text-sm\n bg-transparent border-none p-0 m-0\n cursor-pointer\n transition-all duration-150\n hover:underline hover:decoration-current hover:decoration-1 hover:underline-offset-2\n focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-accent-cyan/50 focus:rounded-sm\n ".concat(d,"\n "),style:{color:r},title:"View ".concat(o?"agent":"user"," profile: ").concat(t),children:t}):(0,s.jsx)("span",{className:"font-display font-semibold text-sm ".concat(d),style:{color:r},children:t})}var eq=r(6270);let e$={claude:{icon:"◈",color:"#00d9ff"},codex:{icon:"⬡",color:"#ff6b35"},gemini:{icon:"◇",color:"#a855f7"},openai:{icon:"◆",color:"#10a37f"},default:{icon:"●",color:"#00d9ff"}};function eY(e){let t=e.toLowerCase();if(t.includes("claude")||t.includes("anthropic"))return e$.claude;if(t.includes("codex")||t.includes("openai")||t.includes("gpt"))return e$.codex;if(t.includes("gemini")||t.includes("google")||t.includes("bard"))return e$.gemini;let r=e.split("").reduce((e,t)=>e+t.charCodeAt(0),0),s=Object.keys(e$).filter(e=>"default"!==e);return e$[s[r%s.length]]}function eX(e){let{messages:t,currentChannel:r,onThreadClick:a,highlightedMessageId:o,currentThread:l,agents:i=[],currentUser:c,skipChannelFilter:d=!1,autoScrollDefault:x=!0,showTimestamps:u=!0,compactMode:m=!1,onAgentClick:h,onUserClick:p,onlineUsers:g=[]}=e,b=new Map;for(let e of i)e.isProcessing&&b.set(e.name,{isProcessing:!0,processingStartedAt:e.processingStartedAt});let f=new Map,y=(0,n.useRef)(null),[j,v]=(0,n.useState)(x),w=(0,n.useRef)(0),N=(0,n.useRef)(r),k=(0,n.useRef)(!1),C=(0,n.useRef)(!1);(0,n.useEffect)(()=>{v(x)},[x]);let S=t.filter(e=>l?e.id===l||e.thread===l:!!d||(r===nM?"*"===e.to||e.isBroadcast:"general"===r||"#general"===r?"general"===e.channel||"#general"===e.channel||"#general"===e.to||"general"===e.to:e.from===r||e.to===r)),L=r===nM?function(e){let t=new Set,r=[];for(let s of e){if(!(!0===s.isBroadcast||"*"===s.to)){r.push(s);continue}let e=function(e){let t=Math.floor(new Date(e.timestamp).getTime()/1e3);return"".concat(e.from,":").concat(t,":").concat(e.content)}(s);t.has(e)||(t.add(e),r.push(s))}return r}(S):S;for(let e of L)("Dashboard"===e.from||c&&e.from===c.displayName)&&"*"!==e.to&&f.set(e.to,e.id);let M=L.length;if(M>w.current){let e=L[L.length-1],t=(null==e?void 0:e.from)==="Dashboard"||c&&(null==e?void 0:e.from)===c.displayName;x&&(t||j)&&(k.current=!0,t&&!j&&v(!0))}w.current=M;let D=(0,n.useCallback)(()=>{if(!y.current||C.current||!x)return;let e=y.current,t=e.scrollHeight-e.scrollTop-e.clientHeight;t<50&&!j?v(!0):t>150&&j&&v(!1)},[j]);return((0,n.useLayoutEffect)(()=>{if(k.current&&y.current){k.current=!1,C.current=!0;let e=y.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{C.current=!1},50)})}},[L.length]),(0,n.useLayoutEffect)(()=>{if(r!==N.current&&(N.current=r,w.current=L.length,v(!0),y.current)){C.current=!0;let e=y.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{C.current=!1},50)})}},[r,L.length]),0===L.length)?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center",children:[(0,s.jsx)(e1,{}),(0,s.jsx)("h3",{className:"m-0 mb-2 text-base font-display text-text-secondary",children:"No messages yet"}),(0,s.jsx)("p",{className:"m-0 text-sm",children:"general"===r?"Broadcast messages will appear here":"Messages with ".concat(r," will appear here")})]}):(0,s.jsx)("div",{className:"flex flex-col bg-bg-secondary h-full overflow-y-auto ".concat(m?"gap-0.5 p-1.5 sm:p-2":"gap-1 p-2 sm:p-4"),ref:y,onScroll:D,children:L.map(e=>{let t=("Dashboard"===e.from||c&&e.from===c.displayName)&&"*"!==e.to&&f.get(e.to)===e.id?b.get(e.to):void 0;return(0,s.jsx)(eQ,{message:e,isHighlighted:e.id===o,onThreadClick:a,recipientProcessing:t,currentUser:c,showTimestamps:u,compactMode:m,agents:i,onlineUsers:g,onAgentClick:h,onUserClick:p},e.id)})})}function eQ(e){var t,r,n;let{message:a,isHighlighted:o,onThreadClick:l,recipientProcessing:i,currentUser:c,showTimestamps:d=!0,compactMode:x=!1,agents:u=[],onlineUsers:m=[],onAgentClick:h,onUserClick:p}=e,g=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 s=new Date(r);return(s.setDate(s.getDate()-1),t.toDateString()===s.toDateString())?"Yesterday ".concat(t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(a.timestamp),b="Dashboard"===a.from||c&&a.from===c.displayName,f=b&&c?{icon:"",color:"#a855f7"}:eY(a.from),j=b&&c?c.displayName:a.from,v=null!==(n=null!==(r=null===(t=a.threadSummary)||void 0===t?void 0:t.replyCount)&&void 0!==r?r:a.replyCount)&&void 0!==n?n:0,w=v>0,N=u.find(e=>e.name.toLowerCase()===a.from.toLowerCase()&&!e.isHuman),k=m.find(e=>e.username.toLowerCase()===a.from.toLowerCase()),C="*"!==a.to?u.find(e=>e.name.toLowerCase()===a.to.toLowerCase()&&!e.isHuman):void 0,S="*"!==a.to?m.find(e=>e.username.toLowerCase()===a.to.toLowerCase()):void 0,L=C?eY(a.to):void 0,M=b&&("acked"===a.status||"read"===a.status)&&(null==i?void 0:i.isProcessing);return(0,s.jsxs)("div",{className:"\n group flex rounded-xl transition-all duration-150\n ".concat(x?"gap-2 py-1.5 px-2":"gap-2 sm:gap-3 py-2 sm:py-3 px-2 sm:px-4","\n hover:bg-bg-card/50\n ").concat(o?"bg-warning-light/20 border-l-2 border-l-warning pl-2 sm:pl-3":"","\n "),children:[b&&(null==c?void 0:c.avatarUrl)?(0,s.jsx)("img",{src:c.avatarUrl,alt:j,className:"shrink-0 rounded-lg sm:rounded-xl border-2 object-cover ".concat(x?"w-7 h-7 sm:w-8 sm:h-8":"w-8 h-8 sm:w-10 sm:h-10"),style:{borderColor:f.color,boxShadow:"0 0 16px ".concat(f.color,"30")}}):(null==k?void 0:k.avatarUrl)?(0,s.jsx)("img",{src:k.avatarUrl,alt:j,className:"shrink-0 rounded-lg sm:rounded-xl border-2 object-cover ".concat(x?"w-7 h-7 sm:w-8 sm:h-8":"w-8 h-8 sm:w-10 sm:h-10"),style:{borderColor:f.color,boxShadow:"0 0 16px ".concat(f.color,"30")}}):(0,s.jsx)("div",{className:"shrink-0 rounded-lg sm:rounded-xl flex items-center justify-center font-medium border-2 ".concat(x?"w-7 h-7 sm:w-8 sm:h-8 text-sm sm:text-base":"w-8 h-8 sm:w-10 sm:h-10 text-base sm:text-lg"),style:{backgroundColor:"".concat(f.color,"15"),borderColor:f.color,color:f.color,boxShadow:"0 0 16px ".concat(f.color,"30")},children:f.icon}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap ".concat(x?"mb-1":"mb-1.5"),children:[(0,s.jsx)(eJ,{displayName:j,color:f.color,isCurrentUser:b,agent:N,userPresence:k,onAgentClick:h,onUserClick:p}),"*"!==a.to&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-dim text-xs",children:"→"}),(0,s.jsx)(eJ,{displayName:a.to,color:(null==L?void 0:L.color)||"#00d9ff",agent:C,userPresence:S,onAgentClick:h,onUserClick:p})]}),a.thread&&(0,s.jsx)("span",{className:"text-xs py-0.5 px-2 rounded-full font-mono font-medium bg-accent-purple/20 text-accent-purple",children:a.thread}),"*"===a.to&&(0,s.jsx)("span",{className:"text-xs py-0.5 px-2 rounded-full uppercase font-medium bg-warning/20 text-warning",children:"broadcast"}),d&&(0,s.jsx)("span",{className:"text-text-dim text-xs ml-auto font-mono",children:g}),b&&(0,s.jsx)(eG,{status:a.status,size:"small"}),M&&(0,s.jsx)(y,{isProcessing:!0,processingStartedAt:null==i?void 0:i.processingStartedAt,size:"small",showLabel:!0}),(0,s.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(w||a.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==l?void 0:l(a.thread||a.id),title:a.thread?"View thread: ".concat(a.thread):w?"".concat(v," ").concat(1===v?"reply":"replies"):"Reply in thread",children:[(0,s.jsx)(e2,{}),w&&(0,s.jsx)("span",{className:"text-xs font-medium",children:v})]})]}),(0,s.jsx)("div",{className:"text-sm leading-relaxed text-text-primary whitespace-pre-wrap break-words",children:(0,eq.y)(a.content)}),a.attachments&&a.attachments.length>0&&(0,s.jsx)(e0,{attachments:a.attachments})]})]})}function e0(e){let{attachments:t}=e,[r,a]=(0,n.useState)(null),o=t.filter(e=>e.mimeType.startsWith("image/"));return 0===o.length?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(e=>(0,s.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,s.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,s.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,s.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",className:"drop-shadow-lg",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,s.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,s.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]},e.id))}),r&&(0,s.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>a(null),children:(0,s.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,s.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,s.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,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,s.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,s.jsx)("p",{className:"text-white text-sm truncate",children:r.filename})})]})})]})}function e1(){return(0,s.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,s.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 e2(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.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 e5(e){let{originalMessage:t,replies:r,onClose:a,onReply:o,isSending:l=!1,currentUser:i,showTimestamps:c=!0}=e,[d,x]=(0,n.useState)(""),u=(0,n.useRef)(null),m=(0,n.useRef)(null);(0,n.useEffect)(()=>{requestAnimationFrame(()=>{var e;null===(e=u.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})})},[r.length]),(0,n.useEffect)(()=>{var e;null===(e=m.current)||void 0===e||e.focus()},[null==t?void 0:t.id]);let h=async e=>{e.preventDefault(),d.trim()&&!l&&await o(d.trim())&&x("")};return t?(0,s.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary border-l border-border",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg-secondary",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(e6,{}),(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:"Thread"}),(0,s.jsxs)("span",{className:"text-text-muted text-xs",children:[r.length," ",1===r.length?"reply":"replies"]})]}),(0,s.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,s.jsx)(e8,{})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border",children:(0,s.jsx)(e4,{message:t,isOriginal:!0,currentUser:i,showTimestamps:c})}),(0,s.jsxs)("div",{className:"p-4 space-y-3",children:[0===r.length?(0,s.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,s.jsx)(e4,{message:e,currentUser:i,showTimestamps:c},e.id)),(0,s.jsx)("div",{ref:u})]})]}),(0,s.jsx)("div",{className:"p-4 border-t border-border bg-bg-secondary",children:(0,s.jsxs)("form",{onSubmit:h,className:"flex gap-2",children:[(0,s.jsx)("textarea",{ref:m,value:d,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),h(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,s.jsx)("button",{type:"submit",disabled:!d.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 e4(e){let{message:t,isOriginal:r,currentUser:n,showTimestamps:a=!0}=e,o=(0,u.GW)(t.from),l=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),i="Dashboard"===t.from||n&&t.from===n.displayName,c=i&&n?n.displayName:t.from;return(0,s.jsxs)("div",{className:"flex gap-3 ".concat(r?"":"pl-2"),children:[i&&(null==n?void 0:n.avatarUrl)?(0,s.jsx)("img",{src:n.avatarUrl,alt:c,className:"shrink-0 w-8 h-8 rounded-lg object-cover"}):(0,s.jsx)("div",{className:"shrink-0 w-8 h-8 rounded-lg flex items-center justify-center font-semibold text-xs",style:{backgroundColor:o.primary,color:o.text},children:(0,u.hP)(t.from)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:c}),"*"!==t.to&&!r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-muted text-xs",children:"→"}),(0,s.jsx)("span",{className:"text-sm text-accent",children:t.to})]}),a&&(0,s.jsx)("span",{className:"text-text-muted text-xs",children:l}),r&&(0,s.jsx)("span",{className:"text-[10px] py-0.5 px-1.5 rounded bg-accent-light text-accent font-medium",children:"Original"})]}),(0,s.jsx)("div",{className:"text-sm leading-relaxed text-text-primary whitespace-pre-wrap break-words",children:(0,eq.y)(t.content)}),t.attachments&&t.attachments.length>0&&(0,s.jsx)(e3,{attachments:t.attachments})]})]})}function e3(e){let{attachments:t}=e,[r,a]=(0,n.useState)(null),o=t.filter(e=>e.mimeType.startsWith("image/"));return 0===o.length?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(e=>(0,s.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,s.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,s.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,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",className:"drop-shadow-lg",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,s.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,s.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]},e.id))}),r&&(0,s.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>a(null),children:(0,s.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,s.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,s.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,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,s.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,s.jsx)("p",{className:"text-white text-sm truncate",children:r.filename})})]})})]})}function e6(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-primary",children:(0,s.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 e8(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}let e9=["projects","agents","actions","channels","navigation","settings"],e7={critical:{label:"Critical",beadsPriority:0,color:"#ef4444"},high:{label:"High",beadsPriority:1,color:"#f97316"},medium:{label:"Medium",beadsPriority:2,color:"#f59e0b"},low:{label:"Low",beadsPriority:3,color:"#6366f1"}};function te(e){return e.isOpen?(0,s.jsx)(tt,{...e}):null}function tt(e){let{onClose:t,agents:r,projects:a=[],currentProject:o,onAgentSelect:l,onProjectSelect:i,onSpawnClick:c,onTaskCreate:d,onSettingsClick:x,onGeneralClick:m,customCommands:h=[]}=e,[p,g]=(0,n.useState)(""),[b,f]=(0,n.useState)(0),[y,j]=(0,n.useState)(null),v=(0,n.useRef)(b),w=(0,n.useRef)(null),N=(0,n.useRef)(null),k=(0,n.useRef)([]),[C,S]=(0,n.useState)("search"),[L,M]=(0,n.useState)(null),[D,A]=(0,n.useState)(""),[E,W]=(0,n.useState)("medium"),[T,P]=(0,n.useState)(!1),B=(0,n.useMemo)(()=>r.filter(e=>"offline"!==e.status&&"error"!==e.status),[r]),_=(0,n.useMemo)(()=>{if(!p.trim())return B;let e=p.toLowerCase();return B.filter(t=>t.name.toLowerCase().includes(e))},[B,p]),I=(0,n.useCallback)(()=>{S("task-select-agent"),g(""),f(0),M(null),A(""),W("medium")},[]),R=(0,n.useCallback)(async()=>{if(L&&D.trim()&&d){P(!0);try{await d({agentName:L.name,title:D.trim(),priority:E}),t()}catch(e){console.error("Failed to create task:",e)}finally{P(!1)}}},[L,D,E,d,t]);(0,n.useEffect)(()=>{v.current=b},[b]);let U=(0,n.useMemo)(()=>[...[...a].sort((e,t)=>{let r=e.id===o,s=t.id===o;if(r&&!s)return -1;if(!r&&s)return 1;let n=e.name||e.path.split("/").pop()||e.id,a=t.name||t.path.split("/").pop()||t.id;return n.localeCompare(a)}).map(e=>{let r=e.name||e.path.split("/").pop()||e.id,n=e.id===o;return{id:"project-".concat(e.id),label:r,description:n?"Current project • ".concat(e.agents.length," agents"):"".concat(e.agents.length," agents"),category:"projects",icon:n?(0,s.jsx)(tc,{}):(0,s.jsx)(ti,{}),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,s.jsx)(tr,{name:e.name}),action:()=>{l(e),t()}})),{id:"spawn-agent",label:"Spawn Agent",description:"Launch a new agent instance",category:"actions",icon:(0,s.jsx)(tn,{}),shortcut:"⌘⇧S",action:()=>{c(),t()}},{id:"broadcast",label:"Broadcast Message",description:"Send message to all agents",category:"actions",icon:(0,s.jsx)(ta,{}),action:()=>{t()}},...d?[{id:"assign-task",label:"Assign Task",description:"Create a task for an agent (creates bead)",category:"actions",icon:(0,s.jsx)(td,{}),shortcut:"⌘⇧T",action:()=>{I()}}]:[],{id:"nav-general",label:"Go to #general",description:"View all broadcast messages",category:"navigation",icon:(0,s.jsx)(to,{}),action:()=>{null==m||m(),t()}},...x?[{id:"settings",label:"Settings",description:"Configure dashboard preferences",category:"settings",icon:(0,s.jsx)(tl,{}),shortcut:"⌘,",action:()=>{x(),t()}}]:[],...h],[r,a,o,l,i,c,x,m,t,h]),F=(0,n.useMemo)(()=>{let e=U;if(y&&(e=e.filter(e=>e.category===y)),p.trim()){let t=p.toLowerCase();e=e.filter(e=>{var r;return e.label.toLowerCase().includes(t)||(null===(r=e.description)||void 0===r?void 0:r.toLowerCase().includes(t))||e.category.toLowerCase().includes(t)})}return e},[U,p,y]),O=(0,n.useMemo)(()=>{let e={};for(let t of F)e[t.category]||(e[t.category]=[]),e[t.category].push(t);return e},[F]),H=(0,n.useMemo)(()=>e9.flatMap(e=>O[e]||[]),[O]);(0,n.useEffect)(()=>{f(0)},[p]),(0,n.useEffect)(()=>{g(""),f(0),j(null),S("search"),M(null),A(""),W("medium")},[]),(0,n.useEffect)(()=>{let e=k.current[b];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})},[b]),(0,n.useEffect)(()=>{let e=e=>{if("task-details"===C){"Escape"===e.key?(e.preventDefault(),S("task-select-agent"),g("")):"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),R());return}if("task-select-agent"===C){switch(e.key){case"ArrowDown":e.preventDefault(),f(e=>Math.min(e+1,_.length-1));break;case"ArrowUp":e.preventDefault(),f(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),_[v.current]&&(M(_[v.current]),S("task-details"),g(""));break;case"Escape":e.preventDefault(),S("search"),g("")}return}switch(e.key){case"ArrowDown":e.preventDefault(),f(e=>Math.min(e+1,H.length-1));break;case"ArrowUp":e.preventDefault(),f(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),H[v.current]&&H[v.current].action();break;case"Tab":e.preventDefault(),j(t=>{if(null===t)return e9[0];let r=e9.indexOf(t);return e.shiftKey?0===r?null:e9[r-1]:r===e9.length-1?null:e9[r+1]}),f(0);break;case"Escape":e.preventDefault(),y?(j(null),f(0)):t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[H,_,C,b,y,t,R]);let z={projects:"Projects",agents:"Agents",actions:"Actions",navigation:"Navigation",settings:"Settings"},G=0;if("task-select-agent"===C)return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:()=>{S("search"),g("")},children:(0,s.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,s.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,s.jsx)("button",{className:"p-1 rounded hover:bg-sidebar-border text-text-muted",onClick:()=>{S("search"),g("")},children:(0,s.jsx)(tx,{})}),(0,s.jsx)(td,{}),(0,s.jsx)("input",{ref:w,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:"Select agent to assign task...",value:p,onChange:e=>{g(e.target.value),f(0)}}),(0,s.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,s.jsx)("div",{className:"flex-1 overflow-y-auto p-2",ref:N,children:0===_.length?(0,s.jsx)("div",{className:"py-8 text-center text-text-muted text-sm",children:p?'No agents matching "'.concat(p,'"'):"No available agents"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider py-2 px-3",children:"Select Agent"}),_.map((e,t)=>{let r=(0,u.GW)(e.name);return(0,s.jsxs)("button",{ref:e=>{k.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===b?"bg-accent-light border border-accent/30":"bg-transparent hover:bg-sidebar-border","\n "),onClick:()=>{M(e),S("task-details"),g("")},onMouseEnter:()=>f(t),children:[(0,s.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,u.hP)(e.name)}),(0,s.jsxs)("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted truncate",children:e.currentTask||e.status})]})]},e.name)})]})})]})});if("task-details"===C&&L){let e=(0,u.GW)(L.name);return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:()=>{S("task-select-agent"),g("")},children:(0,s.jsxs)("div",{className:"bg-sidebar-bg border border-sidebar-border rounded-xl w-[560px] max-w-[90vw] flex flex-col shadow-modal animate-slide-down",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,s.jsx)("button",{className:"p-1 rounded hover:bg-sidebar-border text-text-muted",onClick:()=>{S("task-select-agent"),g("")},children:(0,s.jsx)(tx,{})}),(0,s.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs font-semibold",style:{backgroundColor:e.primary,color:e.text},children:(0,u.hP)(L.name)}),(0,s.jsxs)("span",{className:"text-base font-medium text-text-primary",children:["Assign task to ",L.name]})]}),(0,s.jsxs)("div",{className:"p-4 flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Task Title"}),(0,s.jsx)("input",{autoFocus:!0,type:"text",value:D,onChange:e=>A(e.target.value),placeholder:"What needs to be done?",className:"w-full px-3 py-2 text-sm bg-bg-tertiary border border-sidebar-border rounded-md text-text-primary placeholder:text-text-dim focus:outline-none focus:border-accent-cyan"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Priority"}),(0,s.jsx)("div",{className:"flex gap-2",children:Object.keys(e7).map(e=>{let t=e7[e],r=E===e;return(0,s.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs font-medium rounded-md border transition-all ".concat(r?"border-transparent text-white":"border-sidebar-border text-text-muted hover:border-sidebar-hover"),style:{backgroundColor:r?t.color:"transparent"},onClick:()=>W(e),children:t.label},e)})}),(0,s.jsxs)("p",{className:"text-xs text-text-dim mt-1.5",children:["Maps to beads priority P",e7[E].beadsPriority]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-sidebar-border",children:[(0,s.jsx)("button",{type:"button",className:"px-4 py-2 text-sm text-text-muted hover:text-text-primary transition-colors",onClick:()=>{S("task-select-agent"),g("")},children:"Back"}),(0,s.jsx)("button",{type:"button",disabled:!D.trim()||T,onClick:R,className:"px-4 py-2 text-sm font-medium bg-accent-cyan text-bg-deep rounded-md hover:bg-accent-cyan/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:T?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tu,{}),"Creating..."]}):(0,s.jsxs)(s.Fragment,{children:["Create Task",(0,s.jsx)("kbd",{className:"bg-black/20 rounded px-1 py-0.5 text-[10px]",children:"⌘↵"})]})})]})]})]})})}return(0,s.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,s.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,s.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,s.jsx)(ts,{}),y&&(0,s.jsxs)("button",{onClick:()=>{j(null),f(0)},className:"flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-accent-cyan/20 text-accent-cyan rounded-md hover:bg-accent-cyan/30 transition-colors",children:[z[y],(0,s.jsx)("span",{className:"text-accent-cyan/60",children:"\xd7"})]}),(0,s.jsx)("input",{ref:w,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:y?"Search ".concat(z[y].toLowerCase(),"..."):"Search commands, agents...",value:p,onChange:e=>g(e.target.value)}),(0,s.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",title:"Cycle categories",children:"Tab"}),(0,s.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,s.jsx)("div",{className:"flex-1 overflow-y-auto p-2",ref:N,children:0===H.length?(0,s.jsxs)("div",{className:"py-8 text-center text-text-muted text-sm",children:['No results for "',p,'"']}):e9.map(e=>{let t=O[e];return(null==t?void 0:t.length)?(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.jsx)("div",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider py-2 px-3",children:z[e]||e}),t.map(e=>{let t=G++;return(0,s.jsxs)("button",{ref:e=>{k.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===b?"bg-accent-light border border-accent/30":"bg-transparent hover:bg-sidebar-border","\n "),onClick:e.action,onMouseEnter:()=>f(t),children:[(0,s.jsx)("span",{className:"flex items-center justify-center w-7 h-7 text-text-muted",children:e.icon}),(0,s.jsxs)("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.label}),e.description&&(0,s.jsx)("span",{className:"text-xs text-text-muted truncate",children:e.description})]}),e.shortcut&&(0,s.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 tr(e){let{name:t}=e,r=(0,u.GW)(t);return(0,s.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,u.hP)(t)})}function ts(){return(0,s.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,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function tn(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function ta(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,s.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 to(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,s.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,s.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,s.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function tl(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.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 ti(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.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 tc(){return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:(0,s.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,s.jsx)("svg",{className:"absolute -bottom-0.5 -right-0.5 text-accent-cyan bg-sidebar-bg rounded-full",width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})]})}function td(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-muted",children:[(0,s.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,s.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}function tx(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"15 18 9 12 15 6"})})}function tu(){return(0,s.jsx)("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}let tm=[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"}],th=[{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2-codex-high",label:"GPT-5.2 Codex High"},{value:"gpt-5.2-codex-low",label:"GPT-5.2 Codex Low"},{value:"gpt-5.2-codex-xhigh",label:"GPT-5.2 Codex Extra High"},{value:"gpt-5.2-codex-fast",label:"GPT-5.2 Codex Fast"},{value:"gpt-5.2-codex-high-fast",label:"GPT-5.2 Codex High Fast"},{value:"gpt-5.2-codex-low-fast",label:"GPT-5.2 Codex Low Fast"},{value:"gpt-5.2-codex-xhigh-fast",label:"GPT-5.2 Codex Extra High Fast"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"gemini-3-flash",label:"Gemini 3 Flash"},{value:"composer-1",label:"Composer 1"},{value:"grok",label:"Grok"}],tp=[{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex Mini"},{value:"gpt-5.2",label:"GPT-5.2"}],tg=[{id:"claude",name:"Claude",command:"claude",description:"Claude Code CLI agent",icon:"\uD83E\uDD16",providerId:"anthropic",supportsModelSelection:!0},{id:"codex",name:"Codex",command:"codex",description:"OpenAI Codex agent",icon:"⚡",providerId:"codex",supportsModelSelection:!0},{id:"gemini",name:"Gemini",command:"gemini",description:"Google Gemini CLI agent",icon:"\uD83D\uDC8E",providerId:"google"},{id:"opencode",name:"OpenCode",command:"opencode",description:"OpenCode AI agent",icon:"\uD83D\uDD37",providerId:"opencode",comingSoon:!0},{id:"droid",name:"Droid",command:"droid",description:"Factory Droid agent",icon:"\uD83E\uDD16",providerId:"droid",comingSoon:!0},{id:"cursor",name:"Cursor",command:"cursor",description:"Cursor AI agent",icon:"\uD83D\uDCDD",providerId:"cursor",supportsModelSelection:!0},{id:"custom",name:"Custom",command:"",description:"Custom command",icon:"\uD83D\uDD27",providerId:null}];function tb(e){let{isOpen:t,onClose:r,onSpawn:a,existingAgents:o,isSpawning:l=!1,error:i,isCloudMode:d=!1,workspaceId:x}=e,[m,h]=(0,n.useState)(tg[0]),[p,g]=(0,n.useState)(""),[b,f]=(0,n.useState)(""),[y,j]=(0,n.useState)("sonnet"),[v,w]=(0,n.useState)("opus-4.5-thinking"),[N,k]=(0,n.useState)("gpt-5.2-codex"),[C,S]=(0,n.useState)(""),[L,M]=(0,n.useState)(""),[D,A]=(0,n.useState)(!1),[E,W]=(0,n.useState)(""),[T,P]=(0,n.useState)(""),[B,_]=(0,n.useState)(["EXPLICIT_ASK"]),[I,R]=(0,n.useState)(null),U=(0,n.useRef)(null),F=(0,n.useMemo)(()=>"custom"===m.id?b:"claude"===m.id?"".concat(m.command," --model ").concat(y):"cursor"===m.id?"".concat(m.command," --model ").concat(v):"codex"===m.id?"".concat(m.command," --model ").concat(N):m.command,[m,b,y,v,N]),O=(0,n.useMemo)(()=>(function(e){let t=e.trim().split(" ")[0].toLowerCase();return t.startsWith("claude")||"codex"===t||"opencode"===t||"gemini"===t||"droid"===t||"cursor"===t?"subagent":"process"})(F),[F]),[H,z]=(0,n.useState)(new Set),[G,V]=(0,n.useState)(!1),Z=(0,n.useMemo)(()=>!d||!m.providerId||("codex"===m.providerId?H.has("codex")||H.has("openai"):H.has(m.providerId)),[d,m.providerId,H]),K=(0,n.useMemo)(()=>{if(!m.providerId)return null;let e=m.command;if(!["claude","codex"].includes(e))return x?"/providers?workspace=".concat(x):"/providers";{let t="/providers/setup/".concat(e);return x?"".concat(t,"?workspace=").concat(x):t}},[m,x]);(0,n.useEffect)(()=>{t&&d&&x&&(async()=>{V(!0);try{let e=await c.xv.getProviders(x);if(e.success&&e.data.providers){let t=new Set(e.data.providers.filter(e=>e.isConnected).map(e=>e.id));z(t)}}catch(e){console.error("Failed to fetch provider credentials:",e)}finally{V(!1)}})()},[t,d,x]);let J=(0,n.useCallback)(()=>{let e="claude"===m.id?"claude":m.id,t=1;for(;o.includes("".concat(e,"-").concat(t));)t++;return"".concat(e,"-").concat(t)},[m,o]);(0,n.useEffect)(()=>{t&&(h(tg[0]),g(""),f(""),j("sonnet"),w("opus-4.5-thinking"),k("gpt-5.2-codex"),S(""),M(""),A(!1),W(""),P(""),_(["EXPLICIT_ASK"]),R(null),setTimeout(()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.focus()},100))},[t]);let q=(0,n.useCallback)(e=>e.trim()?/^[a-zA-Z][a-zA-Z0-9-]*$/.test(e)?o.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",[o]),$=async e=>{e.preventDefault();let t=p.trim()||J(),s=q(t);if(s){R(s);return}if(!F.trim()){R("Command is required");return}if(D&&!E){R("Please select an agent to shadow");return}R(null),await a({name:t,command:F.trim(),cwd:C.trim()||void 0,team:L.trim()||void 0,shadowMode:O,shadowOf:D?E:void 0,shadowAgent:T.trim()||void 0,shadowTriggers:D?B:void 0,shadowSpeakOn:D?B:void 0})&&r()};if(!t)return null;let Y=p?(0,u.GW)(p):(0,u.GW)(J()),X=i||I;return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,s.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,s.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-border",children:[(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Spawn New Agent"}),(0,s.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,s.jsx)(tf,{})})]}),(0,s.jsxs)("form",{onSubmit:$,className:"p-6",children:[(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",children:"Agent Type"}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:tg.map(e=>(0,s.jsxs)("button",{type:"button",disabled:e.comingSoon,className:"\n flex flex-col items-center gap-1 py-3 px-2 border-2 rounded-lg font-sans transition-all duration-150 relative\n ".concat(e.comingSoon?"opacity-50 cursor-not-allowed bg-bg-hover border-transparent":m.id===e.id?"bg-accent/10 border-accent cursor-pointer":"bg-bg-hover border-transparent hover:bg-bg-active cursor-pointer","\n "),onClick:()=>!e.comingSoon&&h(e),children:[e.comingSoon&&(0,s.jsx)("span",{className:"absolute top-1 right-1 px-1.5 py-0.5 bg-amber-400/20 text-amber-400 text-[10px] font-medium rounded",children:"Soon"}),(0,s.jsx)("span",{className:"text-2xl ".concat(e.comingSoon?"grayscale":""),children:e.icon}),(0,s.jsx)("span",{className:"text-sm font-semibold text-text-primary",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted text-center",children:e.description})]},e.id))})]}),"claude"===m.id&&(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"claude-model",children:"Model"}),(0,s.jsx)("select",{id:"claude-model",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:y,onChange:e=>j(e.target.value),disabled:l,children:tm.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})]}),"cursor"===m.id&&(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"cursor-model",children:"Model"}),(0,s.jsx)("select",{id:"cursor-model",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:v,onChange:e=>w(e.target.value),disabled:l,children:th.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})]}),"codex"===m.id&&(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"codex-model",children:"Model"}),(0,s.jsx)("select",{id:"codex-model",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:N,onChange:e=>k(e.target.value),disabled:l,children:tp.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-name",children:"Agent Name"}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-lg flex items-center justify-center text-sm font-semibold",style:{backgroundColor:Y.primary,color:Y.text},children:(0,u.hP)(p||J())}),(0,s.jsx)("input",{ref:U,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:J(),value:p,onChange:e=>{g(e.target.value),R(null)},disabled:l})]})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-team",children:["Team ",(0,s.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,s.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:L,onChange:e=>M(e.target.value),disabled:l})]}),"custom"===m.id&&(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-command",children:"Command"}),(0,s.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:b,onChange:e=>f(e.target.value),disabled:l})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-cwd",children:["Working Directory ",(0,s.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,s.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:C,onChange:e=>S(e.target.value),disabled:l})]}),(0,s.jsxs)("div",{className:"mb-5 p-4 border border-border rounded-lg bg-bg-hover/50",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary",children:"Shadow Mode"}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["Shadow execution: ","subagent"===O?"Subagent (in-process)":"Process (separate)"]})]}),(0,s.jsx)("button",{type:"button",className:"\n relative w-11 h-6 rounded-full transition-colors duration-200\n ".concat(D?"bg-accent":"bg-bg-active","\n "),onClick:()=>A(!D),disabled:l,"aria-pressed":D,children:(0,s.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(D?"translate-x-5":"translate-x-0","\n ")})})]}),D&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-text-secondary mb-2",htmlFor:"shadow-of",children:"Shadow Agent"}),(0,s.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:E,onChange:e=>W(e.target.value),disabled:l,children:[(0,s.jsx)("option",{value:"",children:"Select an agent to shadow..."}),o.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("label",{className:"block text-sm font-medium text-text-secondary mb-2",htmlFor:"shadow-agent",children:["Shadow Agent Profile ",(0,s.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,s.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:T,onChange:e=>P(e.target.value),disabled:l})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Speak When"}),(0,s.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,s.jsx)("button",{type:"button",className:"\n py-1.5 px-3 rounded-md text-xs font-medium transition-all duration-150 border\n ".concat(B.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:()=>{B.includes(e.value)?_(B.filter(t=>t!==e.value)):_([...B,e.value])},disabled:l,title:e.description,children:e.label},e.value))})]})]})]}),d&&!Z&&!G&&m.providerId&&(0,s.jsx)("div",{className:"p-4 bg-amber-400/10 border border-amber-400/30 rounded-lg mb-5",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"shrink-0 w-8 h-8 rounded-lg bg-amber-400/20 flex items-center justify-center",children:(0,s.jsx)(tw,{})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("h4",{className:"text-sm font-semibold text-amber-400 mb-1",children:[m.name," credentials required"]}),(0,s.jsxs)("p",{className:"text-xs text-text-secondary mb-3",children:["Connect your ",m.name," account to spawn ",m.name," agents. This enables secure access to the AI provider's API."]}),(0,s.jsxs)("a",{href:K||"#",className:"inline-flex items-center gap-2 py-2 px-4 bg-amber-400 text-bg-deep font-semibold rounded-md text-sm hover:bg-amber-500 transition-colors",children:[(0,s.jsx)(tw,{}),"Connect ",m.name]})]})]})}),d&&G&&(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-bg-hover rounded-md text-text-muted text-sm mb-5",children:[(0,s.jsx)(tv,{}),(0,s.jsx)("span",{children:"Checking provider credentials..."})]}),X&&(0,s.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,s.jsx)(ty,{}),(0,s.jsx)("span",{children:X})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[(0,s.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:l,children:"Cancel"}),(0,s.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:l||d&&!Z,title:!Z&&d?"Connect ".concat(m.name," credentials first"):void 0,children:l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tv,{}),"Spawning..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tj,{}),"Spawn Agent"]})})]})]})]})})}function tf(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function ty(){return(0,s.jsxs)("svg",{className:"shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function tj(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.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,s.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,s.jsx)("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),(0,s.jsx)("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function tv(){return(0,s.jsx)("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function tw(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,s.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function tN(e){let{isOpen:t,onClose:r,onSend:a,agents:o,isSending:l=!1,error:i,preselectedAgent:c}=e,[d,x]=(0,n.useState)(""),[m,h]=(0,n.useState)(""),[p,g]=(0,n.useState)(""),[b,f]=(0,n.useState)(null),y=(0,n.useRef)(null),j=(0,n.useRef)(null),v=(0,n.useMemo)(()=>{if(!p.trim())return o;let e=p.toLowerCase();return o.filter(t=>{var r,s;return t.name.toLowerCase().includes(e)||(null===(r=t.role)||void 0===r?void 0:r.toLowerCase().includes(e))||(null===(s=t.team)||void 0===s?void 0:s.toLowerCase().includes(e))})},[o,p]);(0,n.useEffect)(()=>{t&&(x(c||""),h(""),g(""),f(null),setTimeout(()=>{var e,t;c?null===(e=y.current)||void 0===e||e.focus():null===(t=j.current)||void 0===t||t.focus()},100))},[t,c]);let w=async e=>{if(e.preventDefault(),!d){f("Please select an agent");return}if(!m.trim()){f("Please enter a message");return}f(null),await a(d,m.trim())&&r()},N=(0,n.useCallback)(e=>{x(e),f(null),setTimeout(()=>{var e;return null===(e=y.current)||void 0===e?void 0:e.focus()},50)},[]);if(!t)return null;let k=i||b,C=o.find(e=>e.name===d),S=C?(0,u.GW)(C.name):null;return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,s.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,s.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-border shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-9 h-9 rounded-lg bg-accent/10 flex items-center justify-center",children:(0,s.jsx)(tk,{})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"New Conversation"}),(0,s.jsx)("p",{className:"m-0 text-xs text-text-muted",children:"Start a direct message with an agent"})]})]}),(0,s.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,s.jsx)(tC,{})})]}),(0,s.jsxs)("form",{onSubmit:w,className:"flex flex-col flex-1 overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-5 border-b border-border",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",children:"To"}),d?(0,s.jsxs)("div",{className:"flex items-center gap-3 p-3 bg-bg-hover rounded-lg",children:[(0,s.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,u.hP)(d)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-semibold text-text-primary",children:d}),(null==C?void 0:C.role)&&(0,s.jsx)("div",{className:"text-xs text-text-muted truncate",children:C.role})]}),(0,s.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:()=>{x(""),setTimeout(()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()},50)},"aria-label":"Change agent",children:(0,s.jsx)(tL,{})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative mb-3",children:[(0,s.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted",children:(0,s.jsx)(tS,{})}),(0,s.jsx)("input",{ref:j,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,s.jsx)("div",{className:"max-h-[200px] overflow-y-auto border border-border rounded-lg",children:0===v.length?(0,s.jsx)("div",{className:"p-4 text-center text-text-muted text-sm",children:p?"No agents found":"No agents available"}):(0,s.jsxs)("div",{className:"divide-y divide-border",children:[(0,s.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,s.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-warning/20 flex items-center justify-center",children:(0,s.jsx)(tM,{})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-semibold text-text-primary",children:"Everyone"}),(0,s.jsx)("div",{className:"text-xs text-text-muted",children:"Broadcast to all agents"})]})]}),v.map(e=>{let t=(0,u.GW)(e.name);return(0,s.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,s.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,u.hP)(e.name)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-semibold text-text-primary",children:e.name}),(0,s.jsx)("span",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-muted")})]}),(e.role||e.team)&&(0,s.jsxs)("div",{className:"text-xs text-text-muted truncate",children:[e.role,e.role&&e.team&&" - ",e.team]})]})]},e.name)})]})})]})]}),(0,s.jsxs)("div",{className:"p-5 flex-1 overflow-hidden flex flex-col",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"message",children:"Message"}),(0,s.jsx)("textarea",{ref:y,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:"*"===d?"Write a message to all agents...":d?"Write a message to ".concat(d,"..."):"Select an agent first...",value:m,onChange:e=>{h(e.target.value),f(null)},disabled:l||!d})]}),k&&(0,s.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,s.jsx)(tA,{}),(0,s.jsx)("span",{children:k})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 p-5 pt-0 border-t border-border",children:[(0,s.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:l,children:"Cancel"}),(0,s.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:l||!d||!m.trim(),children:l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tE,{}),"Sending..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tD,{}),"Send Message"]})})]})]})]})})}function tk(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent",children:[(0,s.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,s.jsx)("line",{x1:"9",y1:"10",x2:"15",y2:"10"})]})}function tC(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tS(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function tL(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,s.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]})}function tM(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-warning",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,s.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 tD(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,s.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function tA(){return(0,s.jsxs)("svg",{className:"shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function tE(){return(0,s.jsx)("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}var tW=r(3083),tT=r(4736),tP=r(282);function tB(e){let{workspaces:t=[],onWorkspaceCreated:r,onOpenWorkspace:a,csrfToken:o,className:l=""}=e,[i,c]=(0,n.useState)([]),[d,x]=(0,n.useState)("idle"),[u,m]=(0,n.useState)(null),[h,p]=(0,n.useState)(!1),[g,b]=(0,n.useState)(null),[f,y]=(0,n.useState)(""),[j,v]=(0,n.useState)("all"),w=(0,n.useRef)(null),[N,k]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),[L,M]=(0,n.useState)(null),D=new Map;t.forEach(e=>{e.repositoryFullName&&D.set(e.repositoryFullName,e)});let A=(0,n.useCallback)(async()=>{x("loading"),m(null),p(!1);try{let e=await fetch("/api/repos/accessible?perPage=100",{credentials:"include"});if(!e.ok){let t=await e.json();if("NANGO_NOT_CONNECTED"===t.code)throw p(!0),Error("GitHub not connected. Connect your GitHub account to see your repositories.");throw Error(t.error||"Failed to fetch repositories")}let t=await e.json();c(t.repositories||[]),x("loaded")}catch(e){console.error("Error fetching accessible repos:",e),m(e instanceof Error?e.message:"Failed to load repositories"),x("error")}},[]);(0,n.useEffect)(()=>{A()},[A]),(0,n.useEffect)(()=>{if(!h)return;let e=!0;return(async()=>{try{let t=await fetch("/api/auth/nango/login-session",{credentials:"include"}),r=await t.json();if(!e)return;t.ok&&r.sessionToken&&(w.current=new tP.ZP({connectSessionToken:r.sessionToken}),k(!0))}catch(e){console.error("Failed to initialize Nango:",e)}})(),()=>{e=!1}},[h]);let E=async()=>{if(!w.current){M("GitHub connection not available. Please refresh the page.");return}S(!0),M(null);try{let e=await w.current.auth("github");if(e&&"connectionId"in e){let t=async function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(r>30)throw Error("Authentication timed out. Please try again.");let s=await fetch("/api/auth/nango/login-status/".concat(e.connectionId),{credentials:"include"});if((await s.json()).ready){S(!1),p(!1),A();return}return await new Promise(e=>setTimeout(e,1e3)),t(r+1)};await t()}else throw Error("No connection ID returned")}catch(t){var e;if(console.error("GitHub auth error:",t),"user_cancelled"===t.type||(null===(e=t.message)||void 0===e?void 0:e.includes("closed"))){S(!1),fetch("/api/auth/nango/login-session",{credentials:"include"}).then(e=>e.json()).then(e=>{e.sessionToken&&(w.current=new tP.ZP({connectSessionToken:e.sessionToken}))});return}M(t.message||"Failed to connect GitHub"),S(!1)}},W=(0,n.useCallback)(async e=>{b(e),m(null);try{let t={"Content-Type":"application/json"};o&&(t["X-CSRF-Token"]=o);let s=await fetch("/api/workspaces/quick",{method:"POST",credentials:"include",headers:t,body:JSON.stringify({repositoryFullName:e})}),n=await s.json();if(!s.ok)throw Error(n.error||"Failed to create workspace");null==r||r(n.workspaceId,e)}catch(e){console.error("Error creating workspace:",e),m(e instanceof Error?e.message:"Failed to create workspace")}finally{b(null)}},[o,r]),T=i.filter(e=>{if(f&&!e.fullName.toLowerCase().includes(f.toLowerCase()))return!1;let t=D.has(e.fullName);return("with-workspace"!==j||!!t)&&("without-workspace"!==j||!t)});return"loading"===d?(0,s.jsx)("div",{className:"flex items-center justify-center py-12 ".concat(l),children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsxs)("svg",{className:"w-8 h-8 text-accent-cyan animate-spin mx-auto",fill:"none",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,s.jsx)("p",{className:"mt-4 text-text-muted",children:"Loading repositories..."})]})}):"error"===d?h?(0,s.jsx)("div",{className:"p-6 ".concat(l),children:(0,s.jsxs)("div",{className:"bg-bg-tertiary border border-border-subtle rounded-xl p-8 text-center",children:[(0,s.jsx)("div",{className:"w-16 h-16 mx-auto mb-4 bg-bg-hover rounded-full flex items-center justify-center",children:(0,s.jsx)(tR,{className:"w-8 h-8 text-text-muted"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold text-text-primary mb-2",children:"Connect GitHub"}),(0,s.jsx)("p",{className:"text-text-muted mb-6 max-w-md mx-auto",children:"Connect your GitHub account to see your repositories and enable agent access to your code."}),L&&(0,s.jsx)("p",{className:"text-error text-sm mb-4",children:L}),(0,s.jsx)("button",{onClick:E,disabled:!N||C,className:"px-6 py-3 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-medium rounded-lg hover:shadow-glow-cyan transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:C?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Connecting..."]}):N?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(tR,{className:"w-5 h-5"}),"Connect GitHub Account"]}):(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:"w-5 h-5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading..."]})})]})}):(0,s.jsx)("div",{className:"p-6 ".concat(l),children:(0,s.jsxs)("div",{className:"bg-error/10 border border-error/20 rounded-xl p-4 text-center",children:[(0,s.jsx)("div",{className:"w-12 h-12 mx-auto mb-3 bg-error/20 rounded-full flex items-center justify-center",children:(0,s.jsx)("svg",{className:"w-6 h-6 text-error",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),(0,s.jsx)("p",{className:"text-error mb-4",children:u}),(0,s.jsx)("button",{onClick:A,className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary hover:bg-bg-hover transition-colors",children:"Try Again"})]})}):(0,s.jsxs)("div",{className:l,children:[(0,s.jsxs)("div",{className:"p-4 border-b border-border-subtle",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-primary mb-1",children:"Repository Access"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Repositories you have access to on GitHub. Create workspaces to enable dashboard and chat access."})]}),u&&(0,s.jsx)("div",{className:"mx-4 mt-4 p-3 bg-error/10 border border-error/20 rounded-lg",children:(0,s.jsx)("p",{className:"text-error text-sm",children:u})}),(0,s.jsx)("div",{className:"p-4 border-b border-border-subtle",children:(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3",children:[(0,s.jsxs)("div",{className:"flex-1 relative",children:[(0,s.jsx)(t_,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted"}),(0,s.jsx)("input",{type:"text",placeholder:"Search repositories...",value:f,onChange:e=>y(e.target.value),className:"w-full pl-10 pr-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-cyan/50 transition-colors"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("button",{onClick:()=>v("all"),className:"px-3 py-2 text-sm rounded-lg border transition-colors ".concat("all"===j?"bg-accent-cyan/10 border-accent-cyan/30 text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-muted hover:text-text-primary"),children:["All (",i.length,")"]}),(0,s.jsx)("button",{onClick:()=>v("with-workspace"),className:"px-3 py-2 text-sm rounded-lg border transition-colors ".concat("with-workspace"===j?"bg-success/10 border-success/30 text-success":"bg-bg-tertiary border-border-subtle text-text-muted hover:text-text-primary"),children:"With Access"}),(0,s.jsx)("button",{onClick:()=>v("without-workspace"),className:"px-3 py-2 text-sm rounded-lg border transition-colors ".concat("without-workspace"===j?"bg-warning/10 border-warning/30 text-warning":"bg-bg-tertiary border-border-subtle text-text-muted hover:text-text-primary"),children:"No Access"})]})]})}),(0,s.jsx)("div",{className:"max-h-[500px] overflow-y-auto",children:0===T.length?(0,s.jsx)("div",{className:"py-12 text-center text-text-muted",children:f?(0,s.jsxs)("p",{children:['No repositories match "',f,'"']}):"all"!==j?(0,s.jsx)("p",{children:"No repositories in this category"}):(0,s.jsx)("p",{children:"No repositories found. Connect your GitHub account to see your repos."})}):(0,s.jsx)("div",{className:"divide-y divide-border-subtle",children:T.map(e=>{var t;let r=(t=e.permissions).admin?{level:"admin",label:"Admin",color:"text-accent-purple bg-accent-purple/10 border-accent-purple/30"}:t.push?{level:"write",label:"Write",color:"text-accent-cyan bg-accent-cyan/10 border-accent-cyan/30"}:{level:"read",label:"Read",color:"text-text-muted bg-bg-tertiary border-border-subtle"},n=D.get(e.fullName),o=g===e.fullName;return(0,s.jsxs)("div",{className:"flex items-center gap-4 p-4 hover:bg-bg-hover/50 transition-colors",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-bg-tertiary border border-border-subtle flex items-center justify-center flex-shrink-0",children:(0,s.jsx)(tI,{className:"text-text-muted"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,s.jsx)("p",{className:"font-medium text-text-primary truncate",children:e.fullName}),e.isPrivate&&(0,s.jsx)("span",{className:"px-1.5 py-0.5 text-xs bg-bg-tertiary border border-border-subtle rounded text-text-muted",children:"Private"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"px-2 py-0.5 text-xs rounded-full border ".concat(r.color),children:r.label}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:e.defaultBranch})]})]}),(0,s.jsx)("div",{className:"flex-shrink-0",children:n?(0,s.jsx)("button",{onClick:()=>null==a?void 0:a(n.id),className:"px-4 py-2 text-sm rounded-lg border transition-colors ".concat("running"===n.status?"bg-success/10 border-success/30 text-success hover:bg-success/20":"provisioning"===n.status?"bg-accent-cyan/10 border-accent-cyan/30 text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-muted hover:bg-bg-hover"),children:"running"===n.status?"Open Dashboard":"provisioning"===n.status?"Starting...":"stopped"===n.status?"Start":"View"}):(0,s.jsx)("button",{onClick:()=>W(e.fullName),disabled:o,className:"px-4 py-2 text-sm bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-medium rounded-lg hover:shadow-glow-cyan transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:o?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Creating..."]}):"Enable Access"})})]},e.id)})})}),(0,s.jsx)("div",{className:"p-4 border-t border-border-subtle bg-bg-tertiary/50",children:(0,s.jsxs)("p",{className:"text-xs text-text-muted text-center",children:["Showing ",T.length," of ",i.length," repositories you have GitHub access to.",(0,s.jsx)("button",{onClick:A,className:"ml-2 text-accent-cyan hover:underline",children:"Refresh"})]})})]})}function t_(e){let{className:t=""}=e;return(0,s.jsxs)("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function tI(e){let{className:t=""}=e;return(0,s.jsx)("svg",{className:t,width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:(0,s.jsx)("path",{d:"M2 2.5A2.5 2.5 0 014.5 0h8.75a.75.75 0 01.75.75v12.5a.75.75 0 01-.75.75h-2.5a.75.75 0 110-1.5h1.75v-2h-8a1 1 0 00-.714 1.7.75.75 0 01-1.072 1.05A2.495 2.495 0 012 11.5v-9zm10.5-1V9h-8c-.356 0-.694.074-1 .208V2.5a1 1 0 011-1h8z"})})}function tR(e){let{className:t=""}=e;return(0,s.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})})}let tU=[{id:"anthropic",name:"anthropic",displayName:"Claude",description:"Claude Code - recommended for code tasks",color:"#D97757",cliCommand:"claude",apiKeyUrl:"https://console.anthropic.com/settings/keys",apiKeyName:"API key",supportsOAuth:!0},{id:"codex",name:"openai",displayName:"Codex",description:"Codex - OpenAI coding assistant",color:"#10A37F",cliCommand:"codex login",apiKeyUrl:"https://platform.openai.com/api-keys",apiKeyName:"API key",supportsOAuth:!0,supportsDeviceFlow:!0},{id:"google",name:"google",displayName:"Gemini",description:"Gemini - Google AI coding assistant",color:"#4285F4",cliCommand:"gemini",supportsOAuth:!0},{id:"opencode",name:"opencode",displayName:"OpenCode",description:"OpenCode - AI coding assistant",color:"#00D4AA",cliCommand:"opencode",supportsOAuth:!0,comingSoon:!0},{id:"droid",name:"factory",displayName:"Droid",description:"Droid - Factory AI coding agent",color:"#6366F1",cliCommand:"droid",supportsOAuth:!0,comingSoon:!0},{id:"cursor",name:"cursor",displayName:"Cursor",description:"Cursor - AI-first code editor agent",color:"#7C3AED",cliCommand:"agent",supportsOAuth:!0}];function tF(e){var t;let{workspaceId:r,csrfToken:a,onClose:o}=e,[l,i]=(0,n.useState)(null),[d,x]=(0,n.useState)([]),[u,m]=(0,n.useState)(!0),[h,p]=(0,n.useState)(null),[g,b]=(0,n.useState)("general"),[f,y]=(0,n.useState)({}),[j,v]=(0,n.useState)(null),[w,N]=(0,n.useState)(""),[k,C]=(0,n.useState)(null),[S,L]=(0,n.useState)({}),[M,D]=(0,n.useState)({}),[A,E]=(0,n.useState)({anthropic:!0,cursor:!0,google:!0}),[W,T]=(0,n.useState)(null),[P,B]=(0,n.useState)(null),[_,I]=(0,n.useState)(""),[R,U]=(0,n.useState)(!1),[F,O]=(0,n.useState)(null),[H,z]=(0,n.useState)(null);(0,n.useEffect)(()=>{!async function(){m(!0),p(null);let[e,t,s]=await Promise.all([c.xv.getWorkspaceDetails(r),c.xv.getRepos(),c.xv.getProviders(r)]);if(e.success?(i(e.data),e.data.customDomain&&I(e.data.customDomain)):p(e.error),t.success&&x(t.data.repositories),s.success){let e={openai:"codex"},t={};s.data.providers.forEach(r=>{if(r.isConnected){t[r.id]=!0;let s=e[r.id];s&&(t[s]=!0)}}),y(t)}m(!1)}()},[r]);let G=e=>{C(null),v(e.id)},V=(0,n.useCallback)(async e=>{if(window.confirm("Are you sure you want to disconnect ".concat(e.displayName,"? This will remove the authentication and delete credential files from the workspace."))){T(e.id),C(null);try{let t=await c.xv.disconnectProvider(e.id,r);t.success?y(t=>{let r={...t};return delete r[e.id],r}):C(t.error)}catch(e){C(e instanceof Error?e.message:"Failed to disconnect provider")}finally{T(null)}}},[r]),Z=async e=>{if(!w.trim()){C("Please enter an API key");return}C(null),v(e.id);try{let t={"Content-Type":"application/json"};a&&(t["X-CSRF-Token"]=a);let s=await fetch("/api/onboarding/token/".concat(e.id),{method:"POST",credentials:"include",headers:t,body:JSON.stringify({token:w.trim(),workspaceId:r})});if(!s.ok){let e=await s.json();throw Error(e.error||"Failed to connect")}y(t=>({...t,[e.id]:!0})),N(""),v(null),L(t=>({...t,[e.id]:!1}))}catch(e){C(e instanceof Error?e.message:"Failed to connect"),v(null)}},K=(0,n.useCallback)(async()=>{if(!l||!window.confirm("Are you sure you want to restart this workspace?"))return;let e=await c.xv.restartWorkspace(l.id);if(e.success){let e=await c.xv.getWorkspaceDetails(r);e.success&&i(e.data)}else p(e.error)},[l,r]),J=(0,n.useCallback)(async()=>{if(!l||!window.confirm("Are you sure you want to stop this workspace?"))return;let e=await c.xv.stopWorkspace(l.id);if(e.success){let e=await c.xv.getWorkspaceDetails(r);e.success&&i(e.data)}else p(e.error)},[l,r]),q=(0,n.useCallback)(async e=>{if(!l)return;let t=await c.xv.addReposToWorkspace(l.id,[e]);if(t.success){let e=await c.xv.getWorkspaceDetails(r);e.success&&i(e.data)}else p(t.error)},[l,r]),$=(0,n.useCallback)(async e=>{if(!l)return;B(e),p(null);let t=await c.xv.syncRepo(e);if(t.success){let e=await c.xv.getWorkspaceDetails(r);e.success&&i(e.data)}else p(t.error);B(null)},[l,r]),Y=(0,n.useCallback)(async()=>{if(!l||!_.trim())return;U(!0),O(null),z(null);let e=await c.xv.setCustomDomain(l.id,_.trim());if(e.success){z(e.data.instructions);let t=await c.xv.getWorkspaceDetails(r);t.success&&i(t.data)}else O(e.error);U(!1)},[l,_,r]),X=(0,n.useCallback)(async()=>{if(!l)return;U(!0),O(null);let e=await c.xv.verifyCustomDomain(l.id);if(e.success){let t=await c.xv.getWorkspaceDetails(r);t.success&&i(t.data),"active"===e.data.status&&z(null)}else O(e.error);U(!1)},[l,r]),Q=(0,n.useCallback)(async()=>{if(!l||!window.confirm("Are you sure you want to remove the custom domain?"))return;U(!0);let e=await c.xv.removeCustomDomain(l.id);if(e.success){I(""),z(null);let e=await c.xv.getWorkspaceDetails(r);e.success&&i(e.data)}else O(e.error);U(!1)},[l,r]),ee=(0,n.useCallback)(async()=>{if(!l||!window.confirm('Are you sure you want to delete "'.concat(l.name,'"? This action cannot be undone.'))||!window.confirm("This will permanently delete all workspace data. Are you absolutely sure?"))return;let e=await c.xv.deleteWorkspace(l.id);e.success?window.location.href="/app/onboarding?reason=deleted":p(e.error)},[l]);if(u)return(0,s.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-full border-2 border-accent-cyan/20 border-t-accent-cyan animate-spin"}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-accent-cyan/40 animate-pulse"})})]}),(0,s.jsx)("span",{className:"ml-4 text-text-muted font-mono text-sm tracking-wide",children:"LOADING WORKSPACE CONFIG..."})]});if(h&&!l)return(0,s.jsx)("div",{className:"p-6",children:(0,s.jsxs)("div",{className:"p-4 bg-error/10 border border-error/30 rounded-lg text-error flex items-center gap-3",children:[(0,s.jsx)(tY,{}),(0,s.jsx)("span",{children:h})]})});if(!l)return null;let et=d.filter(e=>!l.repositories.some(t=>t.id===e.id)),er=[{id:"general",label:"General",icon:(0,s.jsx)(tZ,{})},{id:"providers",label:"AI Providers",icon:(0,s.jsx)(tK,{})},{id:"repos",label:"Repositories",icon:(0,s.jsx)(tJ,{})},{id:"github-access",label:"GitHub Access",icon:(0,s.jsx)(t$,{})},{id:"domain",label:"Domain",icon:(0,s.jsx)(tq,{})},{id:"danger",label:"Danger",icon:(0,s.jsx)(tY,{})}];return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary",children:[(0,s.jsx)("div",{className:"flex gap-1 p-2 sm:p-3 border-b border-border-subtle bg-gradient-to-b from-bg-tertiary to-bg-primary overflow-x-auto scrollbar-hide scroll-smooth snap-x snap-mandatory touch-pan-x",style:{WebkitOverflowScrolling:"touch"},children:er.map(e=>(0,s.jsxs)("button",{onClick:()=>b(e.id),className:"flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-2 sm:py-2.5 rounded-lg text-xs sm:text-sm font-medium transition-all duration-200 whitespace-nowrap shrink-0 snap-start ".concat(g===e.id?"bg-accent-cyan/15 text-accent-cyan border border-accent-cyan/30 shadow-[0_0_12px_rgba(0,217,255,0.15)]":"text-text-secondary hover:bg-bg-hover hover:text-text-primary border border-transparent"),children:[(0,s.jsx)("span",{className:g===e.id?"text-accent-cyan":"text-text-muted",children:e.icon}),e.label]},e.id))}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[h&&(0,s.jsxs)("div",{className:"mb-6 p-4 bg-error/10 border border-error/30 rounded-lg text-error text-sm flex items-center gap-3",children:[(0,s.jsx)(tY,{}),(0,s.jsx)("span",{className:"flex-1",children:h}),(0,s.jsx)("button",{onClick:()=>p(null),className:"text-error/60 hover:text-error",children:(0,s.jsx)(t5,{})})]}),"general"===g&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(tO,{title:"Workspace Overview",subtitle:"Core configuration and status"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsx)(tH,{label:"Name",value:l.name}),(0,s.jsx)(tH,{label:"Status",value:l.status.charAt(0).toUpperCase()+l.status.slice(1),valueColor:"running"===l.status?"text-success":"stopped"===l.status?"text-amber-400":"error"===l.status?"text-error":"text-text-muted",indicator:"running"===l.status}),(0,s.jsx)(tH,{label:"Public URL",value:l.publicUrl||"Not available",mono:!0}),(0,s.jsx)(tH,{label:"Compute Provider",value:l.computeProvider.charAt(0).toUpperCase()+l.computeProvider.slice(1)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(tO,{title:"Actions",subtitle:"Manage workspace state"}),(0,s.jsxs)("div",{className:"flex gap-3 mt-4",children:["running"===l.status&&(0,s.jsx)(tz,{onClick:J,variant:"warning",icon:(0,s.jsx)(tQ,{}),children:"Stop Workspace"}),(0,s.jsx)(tz,{onClick:K,variant:"primary",icon:(0,s.jsx)(t0,{}),children:"Restart Workspace"})]})]})]}),"providers"===g&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(tO,{title:"AI Providers",subtitle:"Connect AI providers to spawn agents in this workspace"}),k&&(0,s.jsxs)("div",{className:"p-4 bg-error/10 border border-error/30 rounded-lg text-error text-sm flex items-center gap-3",children:[(0,s.jsx)(tY,{}),(0,s.jsx)("span",{children:k})]}),(0,s.jsx)("div",{className:"space-y-4",children:tU.map(e=>(0,s.jsxs)("div",{className:"p-5 bg-bg-tertiary rounded-xl border border-border-subtle transition-all duration-200 ".concat(e.comingSoon?"opacity-60":"hover:border-border-medium"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white font-bold text-lg shadow-lg ".concat(e.comingSoon?"grayscale":""),style:{backgroundColor:e.color,boxShadow:e.comingSoon?"none":"0 4px 20px ".concat(e.color,"40")},children:e.displayName[0]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"text-base font-semibold text-text-primary flex items-center gap-2",children:[e.displayName,e.comingSoon&&(0,s.jsx)("span",{className:"px-2 py-0.5 bg-amber-400/20 text-amber-400 text-xs font-medium rounded-full",children:"Coming Soon"})]}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:e.description})]})]}),e.comingSoon?(0,s.jsx)("div",{className:"px-4 py-2 bg-bg-card rounded-full border border-border-subtle",children:(0,s.jsx)("span",{className:"text-sm text-text-muted",children:"Not available yet"})}):f[e.id]?(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 bg-success/15 rounded-full border border-success/30",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-success animate-pulse"}),(0,s.jsx)("span",{className:"text-sm font-medium text-success",children:"Connected"})]}),(0,s.jsx)("button",{onClick:()=>V(e),disabled:W===e.id,className:"px-3 py-2 text-xs font-medium text-error/80 hover:text-error hover:bg-error/10 rounded-lg border border-transparent hover:border-error/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed",title:"Disconnect ".concat(e.displayName),children:W===e.id?"Disconnecting...":"Disconnect"})]}):null]}),!f[e.id]&&!e.comingSoon&&(0,s.jsx)("div",{className:"mt-5 pt-5 border-t border-border-subtle",children:j!==e.id||S[e.id]?S[e.id]?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("input",{type:"password",placeholder:"Enter ".concat(e.displayName," ").concat(e.apiKeyName||"API key"),value:j===e.id?w:"",onChange:t=>{v(e.id),N(t.target.value)},onFocus:()=>v(e.id),className:"flex-1 px-4 py-3 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-cyan focus:ring-1 focus:ring-accent-cyan/30 transition-all"}),(0,s.jsx)("button",{onClick:()=>Z(e),disabled:j!==e.id||!w.trim(),className:"px-5 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-lg text-sm hover:bg-accent-cyan/90 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:"Connect"})]}),e.apiKeyUrl&&(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Get your API key from"," ",(0,s.jsx)("a",{href:e.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan hover:underline",children:new URL(e.apiKeyUrl).hostname})]}),e.supportsOAuth&&(0,s.jsx)("button",{onClick:()=>L(t=>({...t,[e.id]:!1})),className:"text-xs text-text-muted hover:text-text-secondary transition-colors",children:"← Back to OAuth login"})]}):e.supportsOAuth?(0,s.jsxs)("div",{className:"space-y-3",children:["codex"===e.id&&(0,s.jsxs)("div",{className:"p-3 bg-accent-cyan/10 border border-accent-cyan/30 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-accent-cyan font-medium mb-1",children:"CLI-assisted authentication"}),(0,s.jsx)("p",{className:"text-xs text-accent-cyan/80",children:"Codex auth uses a CLI command to capture the OAuth callback locally. Click the button below and we'll show you a command with a unique session token to run in your terminal before signing in with OpenAI."})]}),e.supportsDeviceFlow&&(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-text-secondary cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:M[e.id]||!1,onChange:t=>D(r=>({...r,[e.id]:t.target.checked})),className:"w-4 h-4 rounded border-border-subtle bg-bg-card text-accent-cyan focus:ring-accent-cyan/30 cursor-pointer"}),"Use device flow (easier for containers/headless)"]}),(0,s.jsxs)("button",{onClick:()=>G(e),disabled:null!==j,className:"w-full py-3 px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold rounded-lg text-sm 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 transition-all duration-200 flex items-center justify-center gap-2",children:[(0,s.jsx)(tX,{}),"Connect with ",e.displayName]}),e.apiKeyUrl&&(0,s.jsx)("button",{onClick:()=>L(t=>({...t,[e.id]:!0})),className:"w-full text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Or enter API key manually"})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("input",{type:"password",placeholder:"Enter ".concat(e.displayName," ").concat(e.apiKeyName||"API key"),value:j===e.id?w:"",onChange:t=>{v(e.id),N(t.target.value)},onFocus:()=>v(e.id),className:"flex-1 px-4 py-3 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-cyan focus:ring-1 focus:ring-accent-cyan/30 transition-all"}),(0,s.jsx)("button",{onClick:()=>Z(e),disabled:j!==e.id||!w.trim(),className:"px-5 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-lg text-sm hover:bg-accent-cyan/90 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:"Connect"})]}),e.apiKeyUrl&&(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Get your API key from"," ",(0,s.jsx)("a",{href:e.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan hover:underline",children:new URL(e.apiKeyUrl).hostname})]}),(0,s.jsxs)("p",{className:"text-xs text-amber-400/80",children:["OAuth not available for ",e.displayName," in container environments"]})]}):A[e.id]?(0,s.jsx)(tT.$,{provider:{id:e.id,name:e.name,displayName:e.displayName,color:e.color},workspaceId:r,csrfToken:a,maxHeight:"350px",onSuccess:()=>{y(t=>({...t,[e.id]:!0})),v(null)},onCancel:()=>{v(null)},onError:e=>{C(e),v(null)},onConnectAnother:()=>{y(t=>({...t,[e.id]:!0})),v(null)}}):(0,s.jsx)(tW.j,{provider:{id:e.id,name:e.name,displayName:e.displayName,color:e.color,requiresUrlCopy:"codex"===e.id,supportsDeviceFlow:e.supportsDeviceFlow},workspaceId:r,csrfToken:a,useDeviceFlow:M[e.id]||!1,onSuccess:()=>{y(t=>({...t,[e.id]:!0})),v(null)},onCancel:()=>{v(null)},onError:e=>{C(e),v(null)}})}),(0,s.jsx)("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["CLI: ",(0,s.jsx)("code",{className:"px-2 py-1 bg-bg-card rounded font-mono",children:e.cliCommand})]})})]},e.id))})]}),"repos"===g&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(tO,{title:"Connected Repositories",subtitle:"Repositories linked to this workspace"}),(0,s.jsx)("div",{className:"space-y-3",children:l.repositories.length>0?l.repositories.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 bg-bg-tertiary rounded-lg border border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-bg-card flex items-center justify-center",children:(0,s.jsx)(tJ,{})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary",children:e.fullName}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.lastSyncedAt?"Synced ".concat(new Date(e.lastSyncedAt).toLocaleDateString()):"Not synced"})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("button",{onClick:()=>$(e.id),disabled:P===e.id||"running"!==l.status,className:"px-3 py-1.5 bg-accent-cyan/10 border border-accent-cyan/30 text-accent-cyan rounded-lg text-xs font-semibold hover:bg-accent-cyan/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5",title:"running"!==l.status?"Workspace must be running to sync":"Sync repository",children:P===e.id?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t3,{spinning:!0}),"Syncing..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t3,{}),"Sync"]})}),(0,s.jsx)(tG,{status:e.syncStatus})]})]},e.id)):(0,s.jsxs)("div",{className:"p-6 bg-bg-tertiary rounded-lg border border-border-subtle border-dashed text-center",children:[(0,s.jsx)(tJ,{className:"w-8 h-8 mx-auto mb-3 text-text-muted"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No repositories connected"})]})}),et.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tO,{title:"Available Repositories",subtitle:"Add more repositories to this workspace"}),(0,s.jsx)("div",{className:"space-y-3",children:et.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 bg-bg-tertiary rounded-lg border border-border-subtle hover:border-accent-cyan/30 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-bg-card flex items-center justify-center",children:(0,s.jsx)(tJ,{})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary",children:e.fullName}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.isPrivate?"Private":"Public"})]})]}),(0,s.jsx)("button",{onClick:()=>q(e.id),className:"px-4 py-2 bg-accent-cyan/10 border border-accent-cyan/30 text-accent-cyan rounded-lg text-xs font-semibold hover:bg-accent-cyan/20 transition-colors",children:"Add to Workspace"})]},e.id))})]})]}),"github-access"===g&&(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)(tO,{title:"GitHub Repository Access",subtitle:"Repositories you have access to via your GitHub account"}),(0,s.jsx)(tB,{workspaces:l&&(null===(t=l.repositories)||void 0===t?void 0:t.length)>0?[{id:l.id,name:l.name,repositoryFullName:l.repositories[0].fullName,status:l.status}]:[],onWorkspaceCreated:(e,t)=>{c.xv.getWorkspaceDetails(e).then(e=>{e.success&&i(e.data)})},onOpenWorkspace:e=>{o&&o()},csrfToken:a,className:"bg-bg-tertiary rounded-xl border border-border-subtle overflow-hidden"})]}),"domain"===g&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(tO,{title:"Custom Domain",subtitle:"Connect your own domain to this workspace"}),(0,s.jsx)("div",{className:"p-5 bg-gradient-to-r from-accent-purple/10 to-accent-cyan/10 border border-accent-purple/20 rounded-xl",children:(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-accent-purple/20 flex items-center justify-center",children:(0,s.jsx)(tq,{className:"text-accent-purple"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-semibold text-text-primary",children:"Premium Feature"}),(0,s.jsx)("p",{className:"text-xs text-text-secondary",children:"Requires Team or Enterprise plan"})]})]})}),l.customDomain?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"p-5 bg-bg-tertiary rounded-xl border border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide font-semibold",children:"Current Domain"}),(0,s.jsx)(tG,{status:l.customDomainStatus||"pending"})]}),(0,s.jsx)("p",{className:"text-lg font-mono text-text-primary",children:l.customDomain})]}),"pending"===l.customDomainStatus&&(0,s.jsx)(tz,{onClick:X,disabled:R,variant:"primary",icon:(0,s.jsx)(t1,{}),fullWidth:!0,children:R?"Verifying...":"Verify DNS Configuration"}),(0,s.jsx)(tz,{onClick:Q,disabled:R,variant:"danger",icon:(0,s.jsx)(t2,{}),fullWidth:!0,children:"Remove Custom Domain"})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-2 block",children:"Domain Name"}),(0,s.jsx)("input",{type:"text",value:_,onChange:e=>I(e.target.value),placeholder:"workspace.yourdomain.com",className:"w-full px-4 py-3 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary font-mono placeholder:text-text-muted focus:outline-none focus:border-accent-cyan focus:ring-1 focus:ring-accent-cyan/30 transition-all"})]}),(0,s.jsx)(tz,{onClick:Y,disabled:R||!_.trim(),variant:"primary",icon:(0,s.jsx)(tq,{}),fullWidth:!0,children:R?"Setting up...":"Set Custom Domain"})]}),F&&(0,s.jsx)("div",{className:"p-4 bg-error/10 border border-error/30 rounded-lg text-error text-sm",children:F}),H&&(0,s.jsxs)("div",{className:"p-5 bg-bg-tertiary rounded-xl border border-border-subtle space-y-4",children:[(0,s.jsxs)("h4",{className:"text-sm font-semibold text-text-primary flex items-center gap-2",children:[(0,s.jsx)(t4,{}),"DNS Configuration Required"]}),(0,s.jsx)("p",{className:"text-xs text-text-secondary",children:"Add the following DNS record to your domain provider:"}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,s.jsx)(tV,{label:"Type",value:H.type}),(0,s.jsx)(tV,{label:"Name",value:H.name}),(0,s.jsx)(tV,{label:"Value",value:H.value})]})]})]}),"danger"===g&&(0,s.jsx)("div",{className:"space-y-8",children:(0,s.jsxs)("div",{className:"p-6 bg-error/5 border-2 border-error/20 rounded-xl",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-error/20 flex items-center justify-center",children:(0,s.jsx)(tY,{className:"text-error"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-base font-semibold text-error",children:"Danger Zone"}),(0,s.jsx)("p",{className:"text-xs text-text-secondary",children:"These actions are destructive and cannot be undone"})]})]}),(0,s.jsx)("div",{className:"p-5 border border-error/30 rounded-lg bg-bg-primary",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-semibold text-text-primary",children:"Delete Workspace"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Permanently delete this workspace and all its data"})]}),(0,s.jsx)("button",{onClick:ee,className:"px-5 py-2.5 bg-error text-white rounded-lg text-sm font-semibold hover:bg-error/90 transition-colors",children:"Delete Workspace"})]})})]})})]})]})}function tO(e){let{title:t,subtitle:r}=e;return(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide",children:t}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:r})]})}function tH(e){let{label:t,value:r,valueColor:n="text-text-primary",mono:a=!1,indicator:o=!1}=e;return(0,s.jsxs)("div",{className:"p-4 bg-bg-tertiary rounded-lg border border-border-subtle",children:[(0,s.jsx)("label",{className:"text-xs text-text-muted uppercase tracking-wide font-medium",children:t}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[o&&(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-success animate-pulse"}),(0,s.jsx)("p",{className:"text-sm font-medium ".concat(n," ").concat(a?"font-mono":""," break-all"),children:r})]})]})}function tz(e){let{children:t,onClick:r,disabled:n,variant:a,icon:o,fullWidth:l}=e;return(0,s.jsxs)("button",{onClick:r,disabled:n,className:"".concat(l?"w-full":""," px-5 py-2.5 border rounded-lg text-sm font-semibold transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 ").concat({primary:"bg-accent-cyan/10 border-accent-cyan/30 text-accent-cyan hover:bg-accent-cyan/20",warning:"bg-amber-400/10 border-amber-400/30 text-amber-400 hover:bg-amber-400/20",danger:"bg-error/10 border-error/30 text-error hover:bg-error/20"}[a]),children:[o,t]})}function tG(e){let{status:t}=e;return(0,s.jsx)("span",{className:"text-xs px-3 py-1 rounded-full border ".concat({synced:"bg-success/15 text-success border-success/30",active:"bg-success/15 text-success border-success/30",syncing:"bg-accent-cyan/15 text-accent-cyan border-accent-cyan/30",verifying:"bg-accent-cyan/15 text-accent-cyan border-accent-cyan/30",pending:"bg-amber-400/15 text-amber-400 border-amber-400/30",error:"bg-error/15 text-error border-error/30"}[t]||"bg-bg-hover text-text-muted border-border-subtle"),children:t})}function tV(e){let{label:t,value:r}=e;return(0,s.jsxs)("div",{className:"p-3 bg-bg-card rounded-lg",children:[(0,s.jsx)("label",{className:"text-xs text-text-muted block mb-1",children:t}),(0,s.jsx)("p",{className:"font-mono text-sm text-text-primary break-all",children:r})]})}function tZ(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.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 tK(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),(0,s.jsx)("path",{d:"M2 17l10 5 10-5"}),(0,s.jsx)("path",{d:"M2 12l10 5 10-5"})]})}function tJ(e){let{className:t=""}=e;return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-text-muted ".concat(t),children:(0,s.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 tq(e){let{className:t=""}=e;return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),(0,s.jsx)("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}function t$(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.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"})})}function tY(e){let{className:t=""}=e;return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,s.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,s.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function tX(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,s.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function tQ(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("rect",{x:"6",y:"6",width:"12",height:"12"})})}function t0(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M23 4v6h-6"}),(0,s.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}function t1(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function t2(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,s.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 t5(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function t4(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function t3(){let{spinning:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e?"animate-spin":"",children:[(0,s.jsx)("path",{d:"M23 4v6h-6"}),(0,s.jsx)("path",{d:"M1 20v-6h6"}),(0,s.jsx)("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10"}),(0,s.jsx)("path",{d:"M20.49 15a9 9 0 0 1-14.85 3.36L1 14"})]})}let t6={owner:"bg-accent-purple/20 text-accent-purple",admin:"bg-accent-cyan/20 text-accent-cyan",member:"bg-success/20 text-success",viewer:"bg-bg-hover text-text-muted"},t8={owner:"Full access, can delete workspace and transfer ownership",admin:"Can manage members, settings, and all workspace features",member:"Can use workspace, spawn agents, and send messages",viewer:"Read-only access to workspace activity"};function t9(e){var t;let{workspaceId:r,currentUserId:a}=e,[o,l]=(0,n.useState)([]),[i,d]=(0,n.useState)([]),[x,u]=(0,n.useState)([]),[m,h]=(0,n.useState)(!0),[p,g]=(0,n.useState)(!0),[b,f]=(0,n.useState)(null),[y,j]=(0,n.useState)(null),[v,w]=(0,n.useState)(!1),[N,k]=(0,n.useState)(""),[C,S]=(0,n.useState)("member"),[L,M]=(0,n.useState)(!1),[D,A]=(0,n.useState)(null),[E,W]=(0,n.useState)(null);(0,n.useEffect)(()=>{(async function(){h(!0),f(null);let[e,t]=await Promise.all([c.xv.getWorkspaceMembers(r),c.xv.getPendingInvites()]);e.success?l(e.data.members):f(e.error),t.success&&d(t.data.invites.filter(e=>e.workspaceId===r)),h(!1)})()},[r]),(0,n.useEffect)(()=>{(async function(){g(!0);let e=await c.xv.getRepoCollaborators(r);e.success&&u(e.data.collaborators||[]),g(!1)})()},[r]);let T=(0,n.useCallback)(async()=>{if(!N.trim()){A("Please enter a GitHub username");return}M(!0),A(null);let e=await c.xv.inviteMember(r,N.trim(),C);if(e.success){let e=await c.xv.getWorkspaceMembers(r);e.success&&l(e.data.members),k(""),w(!1),j("Invitation sent to ".concat(N)),setTimeout(()=>j(null),3e3)}else A(e.error);M(!1)},[r,N,C]),P=(0,n.useCallback)(async(e,t)=>{W(e);let s=await c.xv.updateMemberRole(r,e,t);s.success?(l(r=>r.map(r=>r.id===e?{...r,role:t}:r)),j("Role updated successfully"),setTimeout(()=>j(null),3e3)):f(s.error),W(null)},[r]),B=(0,n.useCallback)(async e=>{var t;if(!window.confirm("Are you sure you want to remove ".concat((null===(t=e.user)||void 0===t?void 0:t.githubUsername)||"this member"," from the workspace?")))return;let s=await c.xv.removeMember(r,e.id);s.success?(l(t=>t.filter(t=>t.id!==e.id)),j("Member removed successfully"),setTimeout(()=>j(null),3e3)):f(s.error)},[r]),_=null===(t=o.find(e=>e.userId===a))||void 0===t?void 0:t.role,I="owner"===_||"admin"===_;return m?(0,s.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,s.jsx)(t7,{}),(0,s.jsx)("span",{className:"ml-3 text-text-muted",children:"Loading team members..."})]}):(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide",children:"Team Members"}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:[o.length," member",1!==o.length?"s":""]})]}),I&&(0,s.jsxs)("button",{onClick:()=>w(!v),className:"px-3 md:px-4 py-2 bg-accent-cyan text-bg-deep rounded-lg text-xs md:text-sm font-medium hover:bg-accent-cyan/90 transition-colors flex items-center justify-center gap-2 w-full sm:w-auto",children:[(0,s.jsx)(re,{}),"Invite Member"]})]}),b&&(0,s.jsxs)("div",{className:"p-3 bg-error/10 border border-error/30 rounded-lg text-error text-sm",children:[b,(0,s.jsx)("button",{onClick:()=>f(null),className:"ml-2 text-error/70 hover:text-error",children:"\xd7"})]}),y&&(0,s.jsx)("div",{className:"p-3 bg-success/10 border border-success/30 rounded-lg text-success text-sm",children:y}),v&&(0,s.jsxs)("div",{className:"p-4 bg-bg-tertiary rounded-lg border border-border-subtle space-y-4",children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-text-primary",children:"Invite New Member"}),D&&(0,s.jsx)("div",{className:"p-2 bg-error/10 border border-error/30 rounded text-error text-xs",children:D}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"GitHub Username"}),(0,s.jsx)("input",{type:"text",value:N,onChange:e=>k(e.target.value),placeholder:"username",className:"w-full px-3 py-2 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-cyan"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Role"}),(0,s.jsxs)("select",{value:C,onChange:e=>S(e.target.value),className:"w-full px-3 py-2 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:[(0,s.jsx)("option",{value:"admin",children:"Admin"}),(0,s.jsx)("option",{value:"member",children:"Member"}),(0,s.jsx)("option",{value:"viewer",children:"Viewer"})]})]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:t8[C]}),(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,s.jsx)("button",{onClick:T,disabled:L||!N.trim(),className:"px-4 py-2 bg-accent-cyan text-bg-deep rounded-lg text-sm font-medium hover:bg-accent-cyan/90 disabled:opacity-50 transition-colors",children:L?"Sending...":"Send Invitation"}),(0,s.jsx)("button",{onClick:()=>{w(!1),k(""),A(null)},className:"px-4 py-2 bg-bg-hover text-text-secondary rounded-lg text-sm font-medium hover:text-text-primary transition-colors",children:"Cancel"})]})]}),(0,s.jsx)("div",{className:"space-y-2",children:o.map(e=>{var t,r,n,o,l,i;return(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 p-3 md:p-4 bg-bg-tertiary rounded-lg",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(null===(t=e.user)||void 0===t?void 0:t.avatarUrl)?(0,s.jsx)("img",{src:e.user.avatarUrl,alt:e.user.githubUsername,className:"w-9 h-9 md:w-10 md:h-10 rounded-full"}):(0,s.jsx)("div",{className:"w-9 h-9 md:w-10 md:h-10 rounded-full bg-accent-cyan/20 flex items-center justify-center text-accent-cyan font-bold text-xs md:text-sm",children:(null===(o=e.user)||void 0===o?void 0:null===(n=o.githubUsername)||void 0===n?void 0:null===(r=n[0])||void 0===r?void 0:r.toUpperCase())||"?"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary truncate",children:(null===(l=e.user)||void 0===l?void 0:l.githubUsername)||"Unknown User"}),e.isPending&&(0,s.jsx)("span",{className:"text-[10px] px-2 py-0.5 bg-amber-400/20 text-amber-400 rounded-full",children:"Pending"}),e.userId===a&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"(you)"})]}),(null===(i=e.user)||void 0===i?void 0:i.email)&&(0,s.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.user.email})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3 ml-12 sm:ml-0",children:[I&&"owner"!==e.role&&e.userId!==a?(0,s.jsxs)("select",{value:e.role,onChange:t=>P(e.id,t.target.value),disabled:E===e.id,className:"px-2 md:px-3 py-1 md:py-1.5 rounded-full text-[10px] md:text-xs font-medium border-none cursor-pointer ".concat(t6[e.role]," focus:outline-none"),children:[(0,s.jsx)("option",{value:"admin",children:"Admin"}),(0,s.jsx)("option",{value:"member",children:"Member"}),(0,s.jsx)("option",{value:"viewer",children:"Viewer"})]}):(0,s.jsx)("span",{className:"px-2 md:px-3 py-1 md:py-1.5 rounded-full text-[10px] md:text-xs font-medium ".concat(t6[e.role]),children:e.role.charAt(0).toUpperCase()+e.role.slice(1)}),I&&"owner"!==e.role&&e.userId!==a&&(0,s.jsx)("button",{onClick:()=>B(e),className:"p-1.5 text-text-muted hover:text-error rounded transition-colors",title:"Remove member",children:(0,s.jsx)(rt,{})})]})]},e.id)})}),(x.length>0||p)&&(0,s.jsxs)("div",{className:"mt-8",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide",children:"Repo Collaborators"}),(0,s.jsx)("span",{className:"px-2 py-0.5 bg-accent-purple/10 text-accent-purple text-[10px] rounded-full",children:"GitHub Access"})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-4",children:"These users have access via GitHub repo permissions. They can access this workspace without an explicit invite."}),p?(0,s.jsxs)("div",{className:"flex items-center gap-2 py-4",children:[(0,s.jsx)(t7,{}),(0,s.jsx)("span",{className:"text-sm text-text-muted",children:"Loading collaborators..."})]}):(0,s.jsx)("div",{className:"space-y-2",children:x.map(e=>{var t;return(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 p-3 md:p-4 bg-bg-tertiary rounded-lg border border-accent-purple/20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.login,className:"w-9 h-9 md:w-10 md:h-10 rounded-full"}):(0,s.jsx)("div",{className:"w-9 h-9 md:w-10 md:h-10 rounded-full bg-accent-purple/20 flex items-center justify-center text-accent-purple font-bold text-xs md:text-sm",children:(null===(t=e.login[0])||void 0===t?void 0:t.toUpperCase())||"?"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary truncate",children:e.login}),(0,s.jsx)("span",{className:"text-[10px] px-2 py-0.5 bg-accent-purple/10 text-accent-purple rounded-full",children:"via GitHub"})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted truncate",children:1===e.repos.length?"Access via ".concat(e.repos[0]):"Access via ".concat(e.repos.length," repos")})]})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 sm:gap-3 ml-12 sm:ml-0",children:(0,s.jsx)("span",{className:"px-2 md:px-3 py-1 md:py-1.5 rounded-full text-[10px] md:text-xs font-medium ".concat("admin"===e.permission?"bg-accent-cyan/20 text-accent-cyan":"write"===e.permission?"bg-success/20 text-success":"bg-bg-hover text-text-muted"),children:"admin"===e.permission?"Admin":"write"===e.permission?"Write":"Read"})})]},e.id)})})]}),i.length>0&&(0,s.jsxs)("div",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide mb-4",children:"Your Pending Invitations"}),(0,s.jsx)("div",{className:"space-y-2",children:i.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 bg-bg-tertiary rounded-lg border border-accent-cyan/30",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary",children:e.workspaceName}),(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Invited by ",e.invitedBy," as ",e.role]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{onClick:async()=>{(await c.xv.acceptInvite(e.id)).success&&(d(t=>t.filter(t=>t.id!==e.id)),j("Invitation accepted!"),setTimeout(()=>j(null),3e3))},className:"px-3 py-1.5 bg-success/20 text-success rounded text-xs font-medium hover:bg-success/30 transition-colors",children:"Accept"}),(0,s.jsx)("button",{onClick:async()=>{(await c.xv.declineInvite(e.id)).success&&d(t=>t.filter(t=>t.id!==e.id))},className:"px-3 py-1.5 bg-bg-hover text-text-muted rounded text-xs font-medium hover:text-text-primary transition-colors",children:"Decline"})]})]},e.id))})]}),(0,s.jsxs)("div",{className:"mt-8 p-4 bg-bg-tertiary/50 rounded-lg",children:[(0,s.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-3",children:"Role Permissions"}),(0,s.jsx)("div",{className:"space-y-2",children:Object.entries(t8).map(e=>{let[t,r]=e;return(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium ".concat(t6[t]," shrink-0"),children:t.charAt(0).toUpperCase()+t.slice(1)}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:r})]},t)})})]})]})}function t7(){return(0,s.jsx)("svg",{className:"animate-spin h-5 w-5 text-accent-cyan",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function re(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function rt(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,s.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"})]})}let rr={free:"bg-bg-tertiary border-border-subtle text-text-muted",pro:"bg-accent-cyan/10 border-accent-cyan/30 text-accent-cyan",team:"bg-blue-900/30 border-blue-500/40 text-blue-400",enterprise:"bg-amber-400/10 border-amber-400/30 text-amber-400"},rs={free:"Free tier - upgrade to unlock more features",pro:"Professional plan with enhanced features",team:"Team plan with collaboration features",enterprise:"Enterprise plan with dedicated support"},rn={free:0,pro:1,team:2,enterprise:3};function ra(e){let{onUpgrade:t}=e,[r,a]=(0,n.useState)([]),[o,l]=(0,n.useState)("free"),[i,d]=(0,n.useState)(null),[x,u]=(0,n.useState)([]),[m,h]=(0,n.useState)(!0),[p,g]=(0,n.useState)(null),[b,f]=(0,n.useState)(null),[y,j]=(0,n.useState)("month"),[v,w]=(0,n.useState)(null),[N,k]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),[L,M]=(0,n.useState)(!1);(0,n.useEffect)(()=>{!async function(){h(!0),g(null);let[e,t,r]=await Promise.all([c.xv.getBillingPlans(),c.xv.getSubscription(),c.xv.getInvoices()]);if(e.success&&a(e.data.plans),t.success){var s;l(t.data.tier),d(t.data.subscription),(null===(s=t.data.subscription)||void 0===s?void 0:s.interval)&&j(t.data.subscription.interval)}r.success&&u(r.data.invoices),e.success||g(e.error),h(!1)}()},[]);let D=(0,n.useCallback)(async e=>{w(e);let t=await c.xv.createCheckoutSession(e,y);t.success&&t.data.checkoutUrl?window.location.href=t.data.checkoutUrl:t.success||(g(t.error),w(null))},[y]),A=(0,n.useCallback)(async()=>{k(!0);let e=await c.xv.createBillingPortal();e.success&&e.data.portalUrl?window.location.href=e.data.portalUrl:e.success||g(e.error),k(!1)},[]),E=(0,n.useCallback)(async()=>{if(!window.confirm("Are you sure you want to cancel your subscription? You will retain access until the end of your billing period."))return;S(!0);let e=await c.xv.cancelSubscription();e.success?(d(e=>e?{...e,cancelAtPeriodEnd:!0}:null),f(e.data.message),setTimeout(()=>f(null),5e3)):g(e.error),S(!1)},[]),W=(0,n.useCallback)(async()=>{M(!0);let e=await c.xv.resumeSubscription();e.success?(d(e=>e?{...e,cancelAtPeriodEnd:!1}:null),f(e.data.message),setTimeout(()=>f(null),3e3)):g(e.error),M(!1)},[]);return m?(0,s.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,s.jsx)(ro,{}),(0,s.jsx)("span",{className:"ml-3 text-text-muted",children:"Loading billing information..."})]}):(0,s.jsxs)("div",{className:"space-y-8",children:[p&&(0,s.jsxs)("div",{className:"p-3 bg-error/10 border border-error/30 rounded-lg text-error text-sm",children:[p,(0,s.jsx)("button",{onClick:()=>g(null),className:"ml-2 text-error/70 hover:text-error",children:"\xd7"})]}),b&&(0,s.jsx)("div",{className:"p-3 bg-success/10 border border-success/30 rounded-lg text-success text-sm",children:b}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide mb-4",children:"Current Plan"}),(0,s.jsx)("div",{className:"p-4 md:p-6 rounded-lg border-2 ".concat(rr[o]),children:(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"text-lg md:text-xl font-bold text-text-primary capitalize",children:[o," Plan"]}),i?(0,s.jsx)("p",{className:"text-xs md:text-sm text-text-secondary mt-1",children:i.cancelAtPeriodEnd?(0,s.jsxs)("span",{className:"text-amber-400",children:["Cancels on ",new Date(i.currentPeriodEnd).toLocaleDateString()]}):(0,s.jsxs)(s.Fragment,{children:["Renews on ",new Date(i.currentPeriodEnd).toLocaleDateString(),(0,s.jsxs)("span",{className:"text-text-muted ml-2",children:["(","year"===i.interval?"Yearly":"Monthly",")"]})]})}):(0,s.jsx)("p",{className:"text-xs md:text-sm text-text-muted mt-1",children:rs[o]||rs.free})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[i&&!i.cancelAtPeriodEnd&&(0,s.jsx)("button",{onClick:E,disabled:C,className:"px-3 md:px-4 py-2 bg-bg-hover text-text-secondary rounded-lg text-xs md:text-sm font-medium hover:text-text-primary disabled:opacity-50 transition-colors",children:C?"Canceling...":"Cancel Plan"}),(null==i?void 0:i.cancelAtPeriodEnd)&&(0,s.jsx)("button",{onClick:W,disabled:L,className:"px-3 md:px-4 py-2 bg-success/20 text-success rounded-lg text-xs md:text-sm font-medium hover:bg-success/30 disabled:opacity-50 transition-colors",children:L?"Resuming...":"Resume Plan"}),i&&(0,s.jsx)("button",{onClick:A,disabled:N,className:"px-3 md:px-4 py-2 bg-accent-cyan text-bg-deep rounded-lg text-xs md:text-sm font-medium hover:bg-accent-cyan/90 disabled:opacity-50 transition-colors",children:N?"Opening...":"Manage Billing"})]})]})})]}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-4",children:[(0,s.jsx)("span",{className:"text-sm font-medium ".concat("month"===y?"text-text-primary":"text-text-muted"),children:"Monthly"}),(0,s.jsx)("button",{onClick:()=>j(e=>"month"===e?"year":"month"),className:"relative w-14 h-7 bg-bg-tertiary rounded-full transition-colors",children:(0,s.jsx)("span",{className:"absolute top-1 w-5 h-5 bg-accent-cyan rounded-full transition-transform ".concat("year"===y?"translate-x-8":"translate-x-1")})}),(0,s.jsxs)("span",{className:"text-sm font-medium ".concat("year"===y?"text-text-primary":"text-text-muted"),children:["Yearly",(0,s.jsx)("span",{className:"ml-1 text-xs text-success",children:"(Save 20%)"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide mb-4",children:"Available Plans"}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:r.filter(e=>"free"!==e.tier).map(e=>{let t=(rn[e.tier]||0)>(rn[o]||0),r=e.recommended&&t,n=(rn[e.tier]||0)<(rn[o]||0);return(0,s.jsxs)("div",{className:"relative p-6 rounded-lg border ".concat(r?"border-accent-cyan shadow-glow-cyan":"border-border-subtle"," bg-bg-tertiary"),children:[r&&(0,s.jsx)("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2 px-3 py-1 bg-accent-cyan text-bg-deep text-xs font-bold rounded-full",children:"Most Popular"}),(0,s.jsx)("h4",{className:"text-lg font-bold text-text-primary",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1 mb-4",children:e.description}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("span",{className:"text-3xl font-bold text-text-primary",children:["$","year"===y?e.price.yearly:e.price.monthly]}),(0,s.jsxs)("span",{className:"text-text-muted",children:["/","year"===y?"year":"month"]})]}),(0,s.jsx)("ul",{className:"space-y-2 mb-6",children:e.features.slice(0,5).map((e,t)=>(0,s.jsxs)("li",{className:"flex items-start gap-2 text-sm text-text-secondary",children:[(0,s.jsx)(rl,{className:"text-success shrink-0 mt-0.5"}),e]},t))}),o===e.tier?(0,s.jsx)("button",{disabled:!0,className:"w-full py-2.5 bg-bg-hover text-text-muted rounded-lg text-sm font-medium cursor-default",children:"Current Plan"}):(0,s.jsx)("button",{onClick:()=>D(e.tier),disabled:null!==v,className:"w-full py-2.5 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 ".concat(r?"bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90":"bg-bg-hover text-text-primary hover:bg-bg-active"),children:v===e.tier?"Loading...":n?"Downgrade":"Upgrade"})]},e.tier)})})]}),(0,s.jsx)("div",{className:"p-4 md:p-6 bg-gradient-to-r from-amber-400/10 to-accent-purple/10 border border-amber-400/20 rounded-lg",children:(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-base md:text-lg font-bold text-text-primary",children:"Enterprise"}),(0,s.jsx)("p",{className:"text-xs md:text-sm text-text-secondary mt-1",children:"Custom solutions for large teams with dedicated support, SLA, and custom integrations."})]}),(0,s.jsx)("a",{href:"mailto:enterprise@agent-relay.com",className:"px-4 md:px-6 py-2 md:py-2.5 bg-amber-400 text-bg-deep rounded-lg text-xs md:text-sm font-bold hover:bg-amber-300 transition-colors text-center shrink-0",children:"Contact Sales"})]})}),x.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide mb-4",children:"Billing History"}),(0,s.jsx)("div",{className:"hidden md:block bg-bg-tertiary rounded-lg overflow-hidden",children:(0,s.jsxs)("table",{className:"w-full",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-border-subtle",children:[(0,s.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-text-muted uppercase",children:"Invoice"}),(0,s.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-text-muted uppercase",children:"Date"}),(0,s.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-text-muted uppercase",children:"Amount"}),(0,s.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-text-muted uppercase",children:"Status"}),(0,s.jsx)("th",{className:"text-right px-4 py-3 text-xs font-semibold text-text-muted uppercase"})]})}),(0,s.jsx)("tbody",{children:x.map(e=>(0,s.jsxs)("tr",{className:"border-b border-border-subtle last:border-0",children:[(0,s.jsx)("td",{className:"px-4 py-3 text-sm text-text-primary font-medium",children:e.number}),(0,s.jsx)("td",{className:"px-4 py-3 text-sm text-text-secondary",children:new Date(e.date).toLocaleDateString()}),(0,s.jsxs)("td",{className:"px-4 py-3 text-sm text-text-primary",children:["$",(e.amount/100).toFixed(2)]}),(0,s.jsx)("td",{className:"px-4 py-3",children:(0,s.jsx)("span",{className:"text-xs px-2 py-1 rounded-full ".concat("paid"===e.status?"bg-success/20 text-success":"open"===e.status?"bg-amber-400/20 text-amber-400":"bg-error/20 text-error"),children:e.status})}),(0,s.jsx)("td",{className:"px-4 py-3 text-right",children:e.pdfUrl&&(0,s.jsx)("a",{href:e.pdfUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-accent-cyan hover:underline",children:"Download"})})]},e.id))})]})}),(0,s.jsx)("div",{className:"md:hidden space-y-3",children:x.map(e=>(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.number}),(0,s.jsx)("span",{className:"text-xs px-2 py-1 rounded-full ".concat("paid"===e.status?"bg-success/20 text-success":"open"===e.status?"bg-amber-400/20 text-amber-400":"bg-error/20 text-error"),children:e.status})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,s.jsx)("span",{className:"text-text-muted",children:new Date(e.date).toLocaleDateString()}),(0,s.jsxs)("span",{className:"text-text-primary font-medium",children:["$",(e.amount/100).toFixed(2)]})]}),e.pdfUrl&&(0,s.jsx)("a",{href:e.pdfUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-3 block text-center text-xs text-accent-cyan py-2 border border-accent-cyan/30 rounded-lg hover:bg-accent-cyan/10 transition-colors",children:"Download PDF"})]},e.id))})]})]})}function ro(){return(0,s.jsx)("svg",{className:"animate-spin h-5 w-5 text-accent-cyan",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function rl(e){let{className:t=""}=e;return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function ri(e){var t,r;let{currentUserId:a,initialTab:o="dashboard",onClose:l,settings:i,onUpdateSettings:d,activeWorkspaceId:x}=e,[u,m]=(0,n.useState)(o),[h,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null!=x?x:null),[f,y]=(0,n.useState)(!0);(0,n.useEffect)(()=>{x&&b(x)},[x]),(0,n.useEffect)(()=>{(async function(){y(!0);let e=await c.xv.getWorkspaceSummary();e.success&&e.data.workspaces.length>0&&(p(e.data.workspaces),g||b(e.data.workspaces[0].id)),y(!1)})()},[g]);let j=(0,n.useCallback)(e=>{d(e)},[d]),v=(0,n.useCallback)(e=>{j(t=>{let r={...t.notifications,...e};return{...t,notifications:{...r,enabled:r.sound||r.desktop||r.mentionsOnly}}})},[j]),w=[{id:"dashboard",label:"Dashboard",icon:(0,s.jsx)(rp,{})},{id:"workspace",label:"Workspace",icon:(0,s.jsx)(rg,{})},{id:"team",label:"Team",icon:(0,s.jsx)(rb,{})},{id:"billing",label:"Billing",icon:(0,s.jsx)(rf,{})}];return(0,s.jsxs)("div",{className:"fixed inset-0 z-50 bg-bg-deep",children:[(0,s.jsxs)("div",{className:"absolute inset-0 opacity-30",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,_rgba(0,217,255,0.08)_0%,_transparent_50%)]"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom_left,_rgba(168,85,247,0.06)_0%,_transparent_50%)]"})]}),(0,s.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,s.jsxs)("header",{className:"h-14 md:h-16 px-4 md:px-6 flex items-center justify-between border-b border-border-subtle bg-bg-secondary/80 backdrop-blur-sm",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 md:gap-4",children:[(0,s.jsx)("div",{className:"w-8 h-8 md:w-10 md:h-10 rounded-xl bg-gradient-to-br from-accent-cyan to-accent-purple flex items-center justify-center shadow-lg shadow-accent-cyan/20",children:(0,s.jsx)(rh,{className:"text-white w-4 h-4 md:w-[18px] md:h-[18px]"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-base md:text-lg font-bold text-text-primary tracking-tight",children:"Settings"}),(0,s.jsx)("p",{className:"text-[10px] md:text-xs text-text-muted hidden sm:block",children:"Manage your workspace and preferences"})]})]}),(0,s.jsx)("button",{onClick:l,className:"w-9 h-9 md:w-10 md:h-10 rounded-lg bg-bg-tertiary border border-border-subtle flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",children:(0,s.jsx)(ry,{})})]}),(0,s.jsx)("div",{className:"border-b border-border-subtle bg-bg-secondary/50",children:(0,s.jsx)("div",{className:"flex sm:justify-center overflow-x-auto scrollbar-hide scroll-smooth snap-x snap-mandatory touch-pan-x",style:{WebkitOverflowScrolling:"touch"},children:w.map(e=>(0,s.jsxs)("button",{onClick:()=>m(e.id),className:"flex items-center gap-2 px-4 sm:px-6 py-3 text-sm font-medium transition-all whitespace-nowrap shrink-0 snap-start ".concat(u===e.id?"text-accent-cyan border-b-2 border-accent-cyan bg-accent-cyan/5":"text-text-muted border-b-2 border-transparent hover:text-text-secondary"),children:[(0,s.jsx)("span",{className:u===e.id?"text-accent-cyan":"text-text-muted",children:e.icon}),e.label]},e.id))})}),("workspace"===u||"team"===u)&&h.length>0&&(0,s.jsx)("div",{className:"px-4 py-2 border-b border-border-subtle bg-bg-tertiary/50",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full shrink-0 ".concat((null===(t=h.find(e=>e.id===g))||void 0===t?void 0:t.status)==="running"?"bg-success":(null===(r=h.find(e=>e.id===g))||void 0===r?void 0:r.status)==="stopped"?"bg-amber-400":"bg-text-muted")}),1===h.length?(0,s.jsx)("span",{className:"text-sm text-text-primary",children:h[0].name}):(0,s.jsx)("select",{value:g||"",onChange:e=>b(e.target.value),className:"flex-1 px-3 py-2 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:h.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))})]})}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,s.jsx)("main",{className:"h-full w-full overflow-y-auto",children:(0,s.jsxs)("div",{className:"w-full max-w-4xl mx-auto p-4 md:p-8",children:["dashboard"===u&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(rc,{title:"Dashboard Settings",subtitle:"Customize your dashboard experience"}),(0,s.jsxs)(rd,{title:"Appearance",icon:(0,s.jsx)(rj,{}),children:[(0,s.jsx)(rx,{label:"Theme",description:"Choose your preferred color scheme",children:(0,s.jsxs)("select",{value:i.theme,onChange:e=>j(t=>({...t,theme:e.target.value})),className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:[(0,s.jsx)("option",{value:"dark",children:"Dark"}),(0,s.jsx)("option",{value:"light",children:"Light"}),(0,s.jsx)("option",{value:"system",children:"System"})]})}),(0,s.jsx)(rx,{label:"Compact Mode",description:"Reduce spacing and show more content",children:(0,s.jsx)(ru,{checked:i.display.compactMode,onChange:e=>j(t=>({...t,display:{...t.display,compactMode:e}}))})}),(0,s.jsx)(rx,{label:"Show Timestamps",description:"Display timestamps on messages",children:(0,s.jsx)(ru,{checked:i.display.showTimestamps,onChange:e=>j(t=>({...t,display:{...t.display,showTimestamps:e}}))})})]}),(0,s.jsxs)(rd,{title:"Notifications",icon:(0,s.jsx)(rv,{}),children:[(0,s.jsx)(rx,{label:"Sound Effects",description:"Play sounds for new messages",children:(0,s.jsx)(ru,{checked:i.notifications.sound,onChange:e=>v({sound:e})})}),(0,s.jsx)(rx,{label:"Browser Notifications",description:"Show desktop notifications",children:(0,s.jsx)(ru,{checked:i.notifications.desktop,onChange:e=>v({desktop:e})})})]}),(0,s.jsx)(rd,{title:"Behavior",icon:(0,s.jsx)(rh,{}),children:(0,s.jsx)(rx,{label:"Auto-scroll Messages",description:"Automatically scroll to new messages",children:(0,s.jsx)(ru,{checked:i.messages.autoScroll,onChange:e=>j(t=>({...t,messages:{...t.messages,autoScroll:e}}))})})})]}),"workspace"===u&&(0,s.jsx)(s.Fragment,{children:f?(0,s.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,s.jsx)("div",{className:"relative",children:(0,s.jsx)("div",{className:"w-12 h-12 rounded-full border-2 border-accent-cyan/20 border-t-accent-cyan animate-spin"})}),(0,s.jsx)("span",{className:"ml-4 text-text-muted",children:"Loading workspaces..."})]}):g?(0,s.jsx)(tF,{workspaceId:g,csrfToken:(0,c._V)()||void 0,onClose:l}):(0,s.jsx)(rm,{icon:(0,s.jsx)(rg,{}),title:"No Workspace",description:"Create a workspace to get started with Agent Relay.",action:(0,s.jsx)("button",{className:"px-6 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-lg hover:bg-accent-cyan/90 transition-colors",children:"Create Workspace"})})}),"team"===u&&(0,s.jsx)(s.Fragment,{children:g?(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(rc,{title:"Team Settings",subtitle:"Manage workspace members and permissions"}),(0,s.jsx)(t9,{workspaceId:g,currentUserId:a})]}):(0,s.jsx)(rm,{icon:(0,s.jsx)(rb,{}),title:"No Workspace Selected",description:"Select a workspace to manage team members."})}),"billing"===u&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(rc,{title:"Billing & Subscription",subtitle:"Manage your plan and payment methods"}),(0,s.jsx)(ra,{})]})]})})})]})]})}function rc(e){let{title:t,subtitle:r}=e;return(0,s.jsxs)("div",{className:"mb-6 sm:mb-8",children:[(0,s.jsx)("h2",{className:"text-xl sm:text-2xl font-bold text-text-primary",children:t}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:r})]})}function rd(e){let{title:t,icon:r,children:n}=e;return(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-xl border border-border-subtle overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-4 sm:px-6 py-3 sm:py-4 border-b border-border-subtle bg-bg-secondary/50 flex items-center gap-3",children:[(0,s.jsx)("span",{className:"text-accent-cyan",children:r}),(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-primary uppercase tracking-wide",children:t})]}),(0,s.jsx)("div",{className:"divide-y divide-border-subtle",children:n})]})}function rx(e){let{label:t,description:r,children:n}=e;return(0,s.jsxs)("div",{className:"px-4 sm:px-6 py-3 sm:py-4 flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary",children:t}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:r})]}),n]})}function ru(e){let{checked:t,onChange:r}=e;return(0,s.jsx)("button",{onClick:()=>r(!t),className:"relative w-12 h-6 rounded-full transition-colors ".concat(t?"bg-accent-cyan":"bg-bg-hover"),children:(0,s.jsx)("span",{className:"absolute top-1 w-4 h-4 bg-white rounded-full shadow transition-transform ".concat(t?"translate-x-7":"translate-x-1")})})}function rm(e){let{icon:t,title:r,description:n,action:a}=e;return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-tertiary flex items-center justify-center text-text-muted mb-4",children:t}),(0,s.jsx)("h3",{className:"text-lg font-semibold text-text-primary mb-2",children:r}),(0,s.jsx)("p",{className:"text-sm text-text-muted max-w-sm mb-6",children:n}),a]})}function rh(e){let{className:t=""}=e;return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.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 rp(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"7",height:"9"}),(0,s.jsx)("rect",{x:"14",y:"3",width:"7",height:"5"}),(0,s.jsx)("rect",{x:"14",y:"12",width:"7",height:"9"}),(0,s.jsx)("rect",{x:"3",y:"16",width:"7",height:"5"})]})}function rg(){return(0,s.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.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 rb(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,s.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,s.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function rf(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"1",y1:"10",x2:"23",y2:"10"})]})}function ry(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function rj(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"13.5",cy:"6.5",r:"2.5"}),(0,s.jsx)("circle",{cx:"19",cy:"13.5",r:"2.5"}),(0,s.jsx)("circle",{cx:"6",cy:"12",r:"2.5"}),(0,s.jsx)("circle",{cx:"11",cy:"19",r:"2.5"}),(0,s.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 rv(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,s.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}let rw={theme:"system",notifications:{enabled:!0,sound:!0,desktop:!1,mentionsOnly:!1},display:{compactMode:!1,showTimestamps:!0,showAvatars:!0,animationsEnabled:!0},messages:{autoScroll:!0},connection:{autoReconnect:!0,reconnectDelay:3e3,keepAliveInterval:3e4}};var rN=r(9116);function rk(e){let{isOpen:t,onClose:r}=e,[a,o]=(0,n.useState)("conversations"),[l,i]=(0,n.useState)([]),[c,d]=(0,n.useState)([]),[x,u]=(0,n.useState)([]),[m,h]=(0,n.useState)(null),[p,g]=(0,n.useState)(!1),[b,f]=(0,n.useState)(null),[y,j]=(0,n.useState)(""),[v,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&(async()=>{let e=await rN.hi.getHistoryStats();e.success&&e.data&&h(e.data)})()},[t]),(0,n.useEffect)(()=>{t&&(async()=>{g(!0),f(null);try{if("conversations"===a){let e=await rN.hi.getHistoryConversations();e.success&&e.data?i(e.data.conversations):f(e.error||"Failed to fetch conversations")}else if("sessions"===a){let e=await rN.hi.getHistorySessions({agent:v||void 0,limit:50});e.success&&e.data?d(e.data.sessions):f(e.error||"Failed to fetch sessions")}else if("messages"===a){let r={limit:100,order:"desc"};if(y&&(r.search=y),N){let[s,n]=N.participants,a=await rN.hi.getHistoryMessages({...r,from:s,to:n}),o=await rN.hi.getHistoryMessages({...r,from:n,to:s});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 rN.hi.getHistoryMessages(r);e.success&&e.data?u(e.data.messages):f(e.error||"Failed to fetch messages")}}}catch(e){f("Failed to load data")}finally{g(!1)}})()},[t,a,v,y,N]);let C=(0,n.useCallback)(e=>{k(e),o("messages")},[]),S=(0,n.useCallback)(()=>{k(null),o("conversations")},[]);return t?(0,s.jsx)("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50",children:(0,s.jsxs)("div",{className:"bg-bg-primary rounded-lg shadow-xl w-[90vw] max-w-4xl h-[80vh] flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-primary",children:"Conversation History"}),m&&(0,s.jsxs)("div",{className:"flex gap-4 text-sm text-text-muted",children:[(0,s.jsxs)("span",{children:[m.messageCount," messages"]}),(0,s.jsxs)("span",{children:[m.sessionCount," sessions"]}),(0,s.jsxs)("span",{children:[m.uniqueAgents," agents"]})]})]}),(0,s.jsx)("button",{onClick:r,className:"p-2 text-text-muted hover:text-text-primary rounded transition-colors","aria-label":"Close",children:(0,s.jsx)(rE,{})})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 p-4 border-b border-border",children:[(0,s.jsxs)("div",{className:"flex gap-1 bg-bg-secondary rounded-md p-1",children:[(0,s.jsx)(rC,{active:"conversations"===a,onClick:()=>{k(null),o("conversations")},children:"Conversations"}),(0,s.jsx)(rC,{active:"sessions"===a,onClick:()=>o("sessions"),children:"Sessions"}),(0,s.jsx)(rC,{active:"messages"===a,onClick:()=>o("messages"),children:"Messages"})]}),"messages"===a&&(0,s.jsx)("div",{className:"flex-1 max-w-xs",children:(0,s.jsx)("input",{type:"text",placeholder:"Search messages...",value:y,onChange:e=>j(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,s.jsx)("div",{className:"flex-1 max-w-xs",children:(0,s.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,s.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,s.jsx)(rW,{})," Back to conversations"]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,s.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,s.jsx)(rT,{})}):b?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-error",children:b}):"conversations"===a?(0,s.jsx)(rS,{conversations:l,onConversationClick:C}):"sessions"===a?(0,s.jsx)(rL,{sessions:c}):(0,s.jsx)(rD,{messages:x,conversationTitle:N?"".concat(N.participants[0]," & ").concat(N.participants[1]):void 0})})]})}):null}function rC(e){let{active:t,onClick:r,children:n}=e;return(0,s.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:n})}function rS(e){let{conversations:t,onConversationClick:r}=e;return 0===t.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No conversations found"}):(0,s.jsx)("div",{className:"space-y-2",children:t.map((e,t)=>(0,s.jsxs)("div",{onClick:()=>r(e),className:"p-4 bg-bg-secondary rounded-lg cursor-pointer hover:bg-bg-tertiary transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium text-text-primary",children:e.participants.join(" & ")}),(0,s.jsxs)("span",{className:"text-xs px-2 py-0.5 bg-accent/10 text-accent rounded-full",children:[e.messageCount," messages"]})]}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:rA(e.lastTimestamp)})]}),(0,s.jsx)("p",{className:"text-sm text-text-muted truncate",children:e.lastMessage})]},t))})}function rL(e){let{sessions:t}=e;return 0===t.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No sessions found"}):(0,s.jsx)("div",{className:"space-y-2",children:t.map(e=>(0,s.jsxs)("div",{className:"p-4 bg-bg-secondary rounded-lg",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium text-text-primary",children:e.agentName}),e.cli&&(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 bg-bg-tertiary text-text-muted rounded",children:e.cli}),(0,s.jsx)(rM,{isActive:e.isActive,closedBy:e.closedBy})]}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:e.duration})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 text-sm text-text-muted",children:[(0,s.jsx)("span",{children:new Date(e.startedAt).toLocaleString()}),(0,s.jsxs)("span",{children:[e.messageCount," messages"]})]}),e.summary&&(0,s.jsx)("p",{className:"mt-2 text-sm text-text-muted truncate",children:e.summary})]},e.id))})}function rM(e){let{isActive:t,closedBy:r}=e;if(t)return(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 bg-success/10 text-success rounded-full",children:"Active"});let n={agent:"bg-text-muted/10 text-text-muted",disconnect:"bg-warning/10 text-warning",error:"bg-error/10 text-error"},a=r?n[r]:n.agent;return(0,s.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 rD(e){let{messages:t,conversationTitle:r}=e;return 0===t.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No messages found"}):(0,s.jsxs)("div",{className:"space-y-4",children:[r&&(0,s.jsx)("h3",{className:"text-lg font-medium text-text-primary mb-4",children:r}),t.map(e=>(0,s.jsxs)("div",{className:"p-4 bg-bg-secondary rounded-lg",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium text-accent",children:e.from}),(0,s.jsx)("span",{className:"text-text-muted",children:"to"}),(0,s.jsx)("span",{className:"font-medium text-text-primary",children:"*"===e.to?"Everyone":e.to}),e.isBroadcast&&(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 bg-accent/10 text-accent rounded-full",children:"Broadcast"}),e.isUrgent&&(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 bg-error/10 text-error rounded-full",children:"Urgent"})]}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:rA(e.timestamp)})]}),(0,s.jsx)("p",{className:"text-sm text-text-primary whitespace-pre-wrap",children:e.content}),e.thread&&(0,s.jsxs)("div",{className:"mt-2 text-xs text-text-muted",children:["Thread: ",e.thread.slice(0,8),"..."]})]},e.id))]})}function rA(e){let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/6e4),n=Math.floor(r/36e5),a=Math.floor(r/864e5);return s<1?"just now":s<60?"".concat(s,"m ago"):n<24?"".concat(n,"h ago"):a<7?"".concat(a,"d ago"):t.toLocaleDateString()}function rE(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function rW(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"15 18 9 12 15 6"})})}function rT(){return(0,s.jsx)("svg",{className:"animate-spin text-accent",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function rP(e){let{toasts:t,onDismiss:r,position:n="top-right",maxVisible:a=5}=e,o=t.slice(0,a);return(0,s.jsx)("div",{className:"toast-container toast-".concat(n),children:o.map(e=>(0,s.jsx)(rB,{toast:e,onDismiss:r},e.id))})}function rB(e){let{toast:t,onDismiss:r}=e,[a,o]=(0,n.useState)(!1),l=(0,n.useCallback)(()=>{o(!0),setTimeout(()=>r(t.id),200)},[t.id,r]);(0,n.useEffect)(()=>{if(0===t.duration)return;let e=setTimeout(l,t.duration||5e3);return()=>clearTimeout(e)},[t.duration,l]);let i=t.agentName?(0,u.GW)(t.agentName):null,c=function(e){switch(e){case"success":return rI;case"warning":return rR;case"error":return rU;case"message":return rF;default:return r_}}(t.type);return(0,s.jsxs)("div",{className:"toast toast-".concat(t.type," ").concat(a?"toast-exit":""),role:"alert",children:[(0,s.jsx)("div",{className:"toast-icon-wrapper",children:t.agentName?(0,s.jsx)("div",{className:"toast-agent-avatar",style:{backgroundColor:null==i?void 0:i.primary,color:null==i?void 0:i.text},children:(0,u.hP)(t.agentName)}):(0,s.jsx)("div",{className:"toast-icon toast-icon-".concat(t.type),children:(0,s.jsx)(c,{})})}),(0,s.jsxs)("div",{className:"toast-content",children:[(0,s.jsxs)("div",{className:"toast-header",children:[(0,s.jsx)("span",{className:"toast-title",children:t.title}),t.agentName&&(0,s.jsxs)("span",{className:"toast-agent",children:["@",t.agentName]})]}),t.message&&(0,s.jsx)("p",{className:"toast-message",children:t.message}),t.action&&(0,s.jsx)("button",{className:"toast-action",onClick:()=>{var e;null===(e=t.action)||void 0===e||e.onClick(),l()},children:t.action.label})]}),(0,s.jsx)("button",{className:"toast-close",onClick:l,"aria-label":"Dismiss",children:(0,s.jsx)(rO,{})}),0!==t.duration&&(0,s.jsx)("div",{className:"toast-progress",style:{animationDuration:"".concat(t.duration||5e3,"ms")}})]})}function r_(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function rI(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function rR(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,s.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function rU(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,s.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}function rF(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.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 rO(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function rH(e){let{workspaces:t,activeWorkspaceId:r,onSelect:a,onAddWorkspace:o,onWorkspaceSettings:l,isLoading:i=!1}=e,[c,d]=(0,n.useState)(!1),x=(0,n.useRef)(null),u=t.find(e=>e.id===r);return(0,n.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&d(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,s.jsxs)("div",{className:"relative w-full",ref:x,children:[(0,s.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:()=>d(!c),disabled:i,children:[i?(0,s.jsx)("span",{className:"flex-1 text-left text-[#666]",children:"Loading..."}):u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(rz,{provider:u.provider}),(0,s.jsx)("span",{className:"flex-1 text-left font-medium",children:u.name}),u.gitBranch&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs text-[#888] bg-white/5 px-1.5 py-0.5 rounded",children:[(0,s.jsx)(rZ,{}),u.gitBranch]})]}):(0,s.jsx)("span",{className:"flex-1 text-left text-[#666]",children:"Select workspace..."}),(0,s.jsx)(rV,{isOpen:c})]}),c&&(0,s.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,s.jsx)("div",{className:"max-h-[300px] overflow-y-auto",children:0===t.length?(0,s.jsxs)("div",{className:"py-6 px-4 text-center text-[#666] text-[13px] leading-relaxed",children:["No workspaces added yet.",(0,s.jsx)("br",{}),"Add a repository to get started."]}):t.map(e=>(0,s.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),d(!1)},children:[(0,s.jsx)(rz,{provider:e.provider}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col gap-0.5 min-w-0",children:[(0,s.jsx)("span",{className:"font-medium",children:e.name}),(0,s.jsx)("span",{className:"text-[11px] text-[#666] overflow-hidden text-ellipsis whitespace-nowrap",children:e.path})]}),(0,s.jsx)(rG,{status:e.status})]},e.id))}),(0,s.jsxs)("div",{className:"p-2 border-t border-[#3a3a4e] space-y-1.5",children:[l&&u&&(0,s.jsxs)("button",{className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-transparent border border-[#3a3a4e] rounded-md text-[#888] text-[13px] cursor-pointer transition-all hover:bg-white/5 hover:border-[#4a4a5e] hover:text-[#e8e8e8]",onClick:()=>{l(),d(!1)},children:[(0,s.jsx)(rJ,{}),"Workspace Settings"]}),(0,s.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,s.jsx)(rK,{}),"Add Workspace"]})]})]})]})}function rz(e){let{provider:t}=e,r={claude:"\uD83E\uDD16",codex:"\uD83E\uDDE0",gemini:"✨",generic:"\uD83D\uDCC1"};return(0,s.jsx)("span",{className:"text-base",title:t,children:r[t]||r.generic})}function rG(e){let{status:t}=e,r={active:"bg-green-500",inactive:"bg-gray-500",error:"bg-red-500"};return(0,s.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat(r[t]||r.inactive),title:t})}function rV(e){let{isOpen:t}=e;return(0,s.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,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function rZ(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,s.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,s.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,s.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]})}function rK(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function rJ(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.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 rq(e){let{isOpen:t,onClose:r,onAdd:a,isAdding:o=!1,error:l}=e,[i,c]=(0,n.useState)(""),[d,x]=(0,n.useState)(""),[u,m]=(0,n.useState)(null),h=(0,n.useRef)(null);(0,n.useEffect)(()=>{t&&h.current&&h.current.focus()},[t]),(0,n.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,s.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,s.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,s.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-[#e8e8e8]",children:"Add Workspace"}),(0,s.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,s.jsx)(r$,{})})]}),(0,s.jsxs)("form",{onSubmit:p,children:[(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{htmlFor:"workspace-path",className:"block mb-2 text-[13px] font-medium text-[#e8e8e8]",children:"Repository Path"}),(0,s.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,s.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,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{htmlFor:"workspace-name",className:"block mb-2 text-[13px] font-medium text-[#e8e8e8]",children:"Display Name (optional)"}),(0,s.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,s.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,s.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,s.jsxs)("div",{className:"flex gap-3 justify-end mt-6",children:[(0,s.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,s.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 r$(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}let rY=0;function rX(){return"log-".concat(Date.now(),"-").concat(++rY)}var rQ=r(9540),r0=r(1561),r1=r(7418);let r2=(0,n.createContext)({wsBaseUrl:null,isCloudMode:!1});function r5(e){let{children:t,wsUrl:r}=e,a=(0,n.useMemo)(()=>{if(!r)return{wsBaseUrl:null,isCloudMode:!1};let e=function(e){try{let t=new URL(e);return"".concat(t.protocol,"//").concat(t.host)}catch(t){return e}}(r),t=!1;try{t=new URL(r).host!==window.location.host}catch(e){}return{wsBaseUrl:e,isCloudMode:t}},[r]);return(0,s.jsx)(r2.Provider,{value:a,children:t})}let r4={background:"#0d0f14",foreground:"#c9d1d9",cursor:"#58a6ff",cursorAccent:"#0d0f14",selectionBackground:"#264f78",selectionForeground:"#ffffff",black:"#484f58",red:"#f85149",green:"#3fb950",yellow:"#d29922",blue:"#58a6ff",magenta:"#bc8cff",cyan:"#39c5cf",white:"#b1bac4",brightBlack:"#6e7681",brightRed:"#ff7b72",brightGreen:"#56d364",brightYellow:"#e3b341",brightBlue:"#79c0ff",brightMagenta:"#d2a8ff",brightCyan:"#56d4dd",brightWhite:"#ffffff"};function r3(e){let{agentName:t,maxHeight:r="500px",showHeader:a=!0,onClose:o,className:l=""}=e,i=(0,n.useRef)(null),c=(0,n.useRef)(null),d=(0,n.useRef)(null),x=(0,n.useRef)(null),m=(0,n.useRef)(null),h=(0,n.useRef)(null),p=(0,n.useRef)(0),[g,b]=(0,n.useState)(!1),[f,y]=(0,n.useState)(!1),[j,v]=(0,n.useState)(null),[w,N]=(0,n.useState)(!1),[k,C]=(0,n.useState)(""),[S,L]=(0,n.useState)(0),[M,D]=(0,n.useState)(!1),A=(0,n.useRef)(null),E=(0,u.GW)(t),W=function(e){let{wsBaseUrl:t}=(0,n.useContext)(r2);return(0,n.useMemo)(()=>{if(t)return"".concat(t).concat(e);let r="https:"===window.location.protocol?"wss:":"ws:",{hostname:s,port:n}=window.location;return"".concat(r,"//").concat(window.location.host).concat(e)},[t,e])}("/ws/logs/".concat(encodeURIComponent(t)));(0,n.useEffect)(()=>{if(!i.current)return;let e=new rQ.o({theme:r4,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:12,lineHeight:1.4,convertEol:!0,scrollback:1e4,cursorBlink:!1,cursorStyle:"bar",disableStdin:!0,allowProposedApi:!0}),t=new r0.X,r=new r1.Z;e.loadAddon(t),e.loadAddon(r),e.open(i.current),t.fit(),c.current=e,d.current=t,x.current=r,D(!0);let s=new ResizeObserver(()=>{t.fit()});return s.observe(i.current),()=>{s.disconnect(),e.dispose(),c.current=null,d.current=null,x.current=null,D(!1)}},[]),(0,n.useEffect)(()=>{if(!i.current||!M||!c.current||!window.matchMedia("(pointer: coarse)").matches)return;let e=i.current,t=c.current,r=12*1.4,s=0,n=0,a=0,o=!1,l=e=>{1===e.touches.length&&(n=s=e.touches[0].clientY,a=0,o=!1)},d=e=>{if(1!==e.touches.length)return;let l=e.touches[0].clientY,i=n-l;if(n=l,!o&&Math.abs(l-s)>10&&(o=!0),!o)return;let c=Math.trunc((a+=i)/r);0!==c&&(t.scrollLines(c),a-=c*r),e.preventDefault()},x=()=>{o=!1,a=0};return e.addEventListener("touchstart",l,{passive:!0}),e.addEventListener("touchmove",d,{passive:!1}),e.addEventListener("touchend",x,{passive:!0}),e.addEventListener("touchcancel",x,{passive:!0}),()=>{e.removeEventListener("touchstart",l),e.removeEventListener("touchmove",d),e.removeEventListener("touchend",x),e.removeEventListener("touchcancel",x)}},[M]);let T=(0,n.useCallback)(()=>{var e,r;if((null===(e=m.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN||(null===(r=m.current)||void 0===r?void 0:r.readyState)===WebSocket.CONNECTING)return;y(!0),v(null);let s=new WebSocket(W);m.current=s,s.onopen=()=>{var e;b(!0),y(!1),v(null),p.current=0,null===(e=c.current)||void 0===e||e.writeln("\x1b[90m[Connected to ".concat(t," log stream]\x1b[0m"))},s.onclose=e=>{var t,r;if(b(!1),y(!1),m.current=null,h.current&&(clearTimeout(h.current),h.current=null),4404===e.code){null===(r=c.current)||void 0===r||r.writeln("\x1b[31m[Agent not found]\x1b[0m");return}let s=Math.min(1e3*Math.pow(2,p.current),3e4);p.current++,null===(t=c.current)||void 0===t||t.writeln("\x1b[90m[Disconnected. Reconnecting in ".concat(s/1e3,"s...]\x1b[0m")),h.current=setTimeout(()=>{T()},s)},s.onerror=()=>{v(Error("WebSocket connection error")),y(!1)},s.onmessage=e=>{var t,r,s;try{let s=JSON.parse(e.data);if("error"===s.type){null===(t=c.current)||void 0===t||t.writeln("\x1b[31mError: ".concat(s.error,"\x1b[0m"));return}if("subscribed"===s.type)return;if("history"===s.type&&Array.isArray(s.lines)){s.lines.forEach(e=>{var t;null===(t=c.current)||void 0===t||t.writeln(e),L(e=>e+1)});return}if("log"===s.type||"output"===s.type){let e=s.content||s.data||s.message||"";if(e){null===(r=c.current)||void 0===r||r.write(e);let t=(e.match(/\n/g)||[]).length;t>0&&L(e=>e+t)}return}s.lines&&Array.isArray(s.lines)&&s.lines.forEach(e=>{var t;let r="string"==typeof e?e:e.content;null===(t=c.current)||void 0===t||t.writeln(r),L(e=>e+1)})}catch(t){if("string"==typeof e.data){null===(s=c.current)||void 0===s||s.write(e.data);let t=(e.data.match(/\n/g)||[]).length;t>0&&L(e=>e+t)}}}},[W,t]),P=(0,n.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null),m.current&&(m.current.close(),m.current=null),b(!1),y(!1)},[]),B=(0,n.useCallback)(()=>{var e;null===(e=c.current)||void 0===e||e.clear(),L(0)},[]),_=(0,n.useCallback)(e=>{C(e),e&&x.current&&x.current.findNext(e,{caseSensitive:!1})},[]),I=(0,n.useCallback)(()=>{k&&x.current&&x.current.findNext(k,{caseSensitive:!1})},[k]),R=(0,n.useCallback)(()=>{k&&x.current&&x.current.findPrevious(k,{caseSensitive:!1})},[k]);return(0,n.useEffect)(()=>(T(),()=>{P()}),[T,P]),(0,n.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),N(!0),setTimeout(()=>{var e;return null===(e=A.current)||void 0===e?void 0:e.focus()},0)),"Escape"===e.key&&w&&(N(!1),C("")),"Enter"===e.key&&w&&(e.preventDefault(),e.shiftKey?R():I())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,I,R]),(0,s.jsxs)("div",{className:"xterm-log-viewer flex flex-col min-h-0 rounded-xl overflow-hidden border border-[#2a2d35] shadow-2xl ".concat(l),style:{background:"linear-gradient(180deg, #0d0f14 0%, #0a0c10 100%)",boxShadow:"0 0 60px -15px ".concat(E.primary,"25, 0 25px 50px -12px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255,255,255,0.02)")},children:[(0,s.jsx)("style",{children:"\n .xterm-log-viewer .xterm {\n height: 100%;\n }\n .xterm-log-viewer .xterm-viewport {\n height: 100%;\n max-height: 100%;\n overscroll-behavior: contain;\n }\n /* On touch devices, disable browser touch handling so our JS handler works */\n @media (pointer: coarse) {\n .xterm-log-viewer .xterm,\n .xterm-log-viewer .xterm-viewport,\n .xterm-log-viewer .xterm-screen,\n .xterm-log-viewer .xterm-screen canvas {\n touch-action: none;\n }\n }\n "}),a&&(0,s.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,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsxs)("div",{className:"flex gap-1.5",children:[(0,s.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,s.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,s.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,s.jsx)("div",{className:"w-px h-4 bg-[#30363d]"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(r6,{}),(0,s.jsx)("span",{className:"text-sm font-semibold",style:{color:E.primary},children:t}),(0,s.jsx)(ss,{isConnected:g,isConnecting:f})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("button",{className:"p-1.5 rounded-lg transition-all duration-200 ".concat(w?"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:()=>{N(!w),w||setTimeout(()=>{var e;return null===(e=A.current)||void 0===e?void 0:e.focus()},0)},title:"Search (Cmd+F)",children:(0,s.jsx)(r8,{})}),(0,s.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9] transition-all duration-200",onClick:B,title:"Clear logs",children:(0,s.jsx)(r9,{})}),(0,s.jsx)("button",{className:"p-1.5 rounded-lg transition-all duration-200 ".concat(g?"hover:bg-[#f85149]/10 text-[#8b949e] hover:text-[#f85149]":"bg-[#3fb950]/20 text-[#3fb950] shadow-[0_0_12px_rgba(63,185,80,0.25)]"),onClick:g?P:T,title:g?"Disconnect":"Connect",children:g?(0,s.jsx)(st,{}):(0,s.jsx)(se,{})}),o&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-px h-4 bg-[#30363d] mx-1"}),(0,s.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#f85149]/10 text-[#8b949e] hover:text-[#f85149] transition-all duration-200",onClick:o,title:"Close",children:(0,s.jsx)(r7,{})})]})]})]}),w&&(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-[#21262d] bg-[#161b22]",children:[(0,s.jsx)(r8,{}),(0,s.jsx)("input",{ref:A,type:"text",className:"flex-1 bg-transparent border-none text-sm text-[#c9d1d9] placeholder:text-[#484f58] outline-none font-mono",placeholder:"Search logs... (Enter: next, Shift+Enter: prev)",value:k,onChange:e=>_(e.target.value)}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{className:"px-2 py-0.5 text-xs rounded bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9] transition-colors",onClick:R,title:"Previous (Shift+Enter)",children:"↑"}),(0,s.jsx)("button",{className:"px-2 py-0.5 text-xs rounded bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9] transition-colors",onClick:I,title:"Next (Enter)",children:"↓"})]})]}),j&&(0,s.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,s.jsx)(sr,{}),(0,s.jsx)("span",{children:j.message}),(0,s.jsx)("button",{className:"ml-auto text-xs px-2 py-0.5 rounded bg-[#f85149]/20 hover:bg-[#f85149]/30 transition-colors",onClick:T,children:"Retry"})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",style:{height:r,maxHeight:r,minHeight:"200px"},children:(0,s.jsx)("div",{ref:i,className:"h-full w-full"})}),(0,s.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,s.jsx)("div",{className:"flex items-center gap-3",children:(0,s.jsxs)("span",{className:"tabular-nums font-mono text-[#6e7681]",children:[S," lines"]})}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[#6e7681] font-mono uppercase tracking-wider text-[10px]",children:"PTY stream"}),(0,s.jsx)("div",{className:"w-2 h-2 rounded-full transition-all duration-300 ".concat(g?"bg-[#3fb950]":f?"bg-[#d29922] animate-pulse":"bg-[#484f58]"),style:{boxShadow:g?"0 0 8px rgba(63,185,80,0.6)":"none"}})]})]})]})}function r6(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#8b949e]",children:[(0,s.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,s.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function r8(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-[#8b949e]",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function r9(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,s.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 r7(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function se(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})}function st(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,s.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,s.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]})}function sr(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function ss(e){let{isConnected:t,isConnecting:r}=e;return r?(0,s.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,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#d29922] animate-pulse"}),"connecting"]}):t?(0,s.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,s.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,s.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,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58]"}),"offline"]})}function sn(e){let{agentName:t,mode:r="panel",maxHeight:a="500px",showHeader:o=!0,autoScrollDefault:l=!0,onClose:i,onExpand:c,className:d=""}=e,[x,m]=(0,n.useState)(l),h=(0,n.useRef)(null),{logs:p,isConnected:g,isConnecting:b}=function(e){let{agentName:t,maxLines:r=5e3,autoConnect:s=!0,reconnect:a=!0,maxReconnectAttempts:o=1/0}=e,[l,i]=(0,n.useState)([]),[c,d]=(0,n.useState)(!1),[x,u]=(0,n.useState)(!1),[m,h]=(0,n.useState)(null),p=(0,n.useRef)(null),g=(0,n.useRef)(0),b=(0,n.useRef)(null),f=(0,n.useRef)(t),y=(0,n.useRef)(!0),j=(0,n.useRef)(!1),v=(0,n.useRef)(new WeakMap),w=(0,n.useRef)(new WeakMap);f.current=t;let N=(0,n.useCallback)(()=>{var e,t;if(y.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||j.current)return;j.current=!0,u(!0),h(null);let s=function(e){let t="/ws/logs/".concat(encodeURIComponent(e)),r="https:"===window.location.protocol?"wss:":"ws:",{hostname:s,port:n}=window.location;return"".concat(r,"//").concat(window.location.host).concat(t)}(f.current);try{let e=new WebSocket(s);p.current=e,v.current.set(e,!1),w.current.set(e,!1),e.onopen=()=>{j.current=!1,d(!0),u(!1),h(null),g.current=0,i(e=>[...e,{id:rX(),timestamp:Date.now(),content:"Connected to ".concat(f.current," log stream"),type:"system",agentName:f.current}])},e.onclose=t=>{var r,s;let n=null!==(r=v.current.get(e))&&void 0!==r&&r,l=null!==(s=w.current.get(e))&&void 0!==s&&s;if(j.current=!1,d(!1),u(!1),p.current=null,b.current&&(clearTimeout(b.current),b.current=null),!n&&4404!==t.code){if(!t.wasClean&&l){let e=y.current&&a&&g.current<o;i(r=>[...r,{id:rX(),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:f.current}])}if(y.current&&a&&g.current<o){let e=Math.min(1e3*Math.pow(2,g.current),3e4);g.current++,b.current=setTimeout(()=>{N()},e)}}},e.onerror=()=>{j.current=!1,h(Error("WebSocket connection error")),u(!1)},e.onmessage=t=>{try{let s=JSON.parse(t.data);if("error"===s.type){h(Error(s.error||"Failed to stream logs for ".concat(s.agent||f.current))),i(e=>[...e,{id:rX(),timestamp:Date.now(),content:"Error: ".concat(s.error||"Unknown error"),type:"system",agentName:s.agent||f.current}]);return}if("subscribed"===s.type){console.log("[useAgentLogs] Subscribed to ".concat(s.agent));return}if("history"===s.type&&Array.isArray(s.lines)){s.lines.length>0&&w.current.set(e,!0),i(e=>{let t=s.lines.map(e=>({id:rX(),timestamp:Date.now(),content:e,type:"stdout",agentName:s.agent||f.current}));return[...e,...t].slice(-r)});return}"string"==typeof s?(w.current.set(e,!0),i(e=>[...e,{id:rX(),timestamp:Date.now(),content:s,type:"stdout",agentName:f.current}].slice(-r))):"log"===s.type||"output"===s.type?(w.current.set(e,!0),i(e=>{let t="stderr"===s.stream?"stderr":"stdout";return[...e,{id:rX(),timestamp:s.timestamp||Date.now(),content:s.content||s.data||s.message||"",type:t,agentName:s.agentName||f.current}].slice(-r)})):s.lines&&Array.isArray(s.lines)&&(w.current.set(e,!0),i(e=>{let t=s.lines.map(e=>{let t="object"==typeof e&&"stderr"===e.type?"stderr":"stdout";return{id:rX(),timestamp:Date.now(),content:"string"==typeof e?e:e.content,type:t,agentName:f.current}});return[...e,...t].slice(-r)}))}catch(s){"string"==typeof t.data&&(w.current.set(e,!0),i(e=>[...e,{id:rX(),timestamp:Date.now(),content:t.data,type:"stdout",agentName:f.current}].slice(-r)))}}}catch(e){j.current=!1,h(e instanceof Error?e:Error("Failed to create WebSocket")),u(!1)}},[r,a,o]),k=(0,n.useCallback)(()=>{y.current=!1,b.current&&(clearTimeout(b.current),b.current=null),p.current&&(v.current.set(p.current,!0),p.current.close(),p.current=null),j.current=!1,d(!1),u(!1)},[]),C=(0,n.useCallback)(()=>{i([])},[]);return(0,n.useEffect)(()=>(s&&t&&N(),()=>{k()}),[t,s,N,k]),{logs:l,isConnected:c,isConnecting:x,error:m,connect:N,disconnect:k,clear:C}}({agentName:t,autoConnect:!0}),f=(0,u.GW)(t),y=(0,n.useMemo)(()=>p.filter(e=>{let t=sl(e.content).trim();return 0!==t.length&&!(t.length<=2&&/^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⣾⣽⣻⢿⡿⣟⣯⣷◐◓◑◒●○◉◎|\\\/\-*.\u2800-\u28FF]+$/.test(t))}),[p]);(0,n.useEffect)(()=>{if(x&&h.current){let e=h.current;e.scrollTop=e.scrollHeight}},[p,x]);let j=(0,n.useCallback)(()=>{if(!h.current)return;let e=h.current,t=e.scrollHeight-e.scrollTop-e.clientHeight<50;t&&!x?m(!0):!t&&x&&m(!1)},[x]);return"inline"===r?(0,s.jsxs)("div",{className:"log-viewer-inline rounded-lg overflow-hidden border border-[#2a2d35] ".concat(d),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,s.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,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(si,{}),(0,s.jsx)("span",{className:"text-xs font-medium",style:{color:f.primary},children:"Live logs"}),(0,s.jsx)(so,{isConnected:g,isConnecting:b})]}),(0,s.jsx)("div",{className:"flex items-center gap-1",children:(0,s.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:c,title:"Expand",children:(0,s.jsx)(sc,{})})})]}),(0,s.jsxs)("div",{className:"font-mono text-xs leading-relaxed p-3 overflow-y-auto touch-pan-y",style:{maxHeight:"150px",WebkitOverflowScrolling:"touch",overscrollBehavior:"contain",touchAction:"pan-y"},ref:h,onScroll:j,children:[y.slice(-20).map(e=>(0,s.jsx)(sa,{log:e,compact:!0},e.id)),0===y.length&&(0,s.jsxs)("div",{className:"text-[#484f58] italic flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58] animate-pulse"}),"Waiting for output..."]})]})]}):(0,s.jsx)(r3,{agentName:t,maxHeight:a,showHeader:o,onClose:i,className:d})}function sa(e){let{log:t,compact:r=!1}=e,n=sl(t.content);return(0,s.jsx)("div",{className:"".concat((()=>{switch(t.type){case"stderr":return"text-[#f85149]";case"system":return"text-[#58a6ff] italic";case"input":return"text-[#d29922]";default:return"text-[#c9d1d9]"}})()," leading-5 whitespace-pre-wrap break-all min-w-0 overflow-hidden"),children:n})}function so(e){let{isConnected:t,isConnecting:r}=e;return r?(0,s.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,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#d29922] animate-pulse"}),"connecting"]}):t?(0,s.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,s.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,s.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,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58]"}),"offline"]})}function sl(e){if(!e)return"";let t=e;return(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(RegExp("\\x1b\\].*?(?:\\x07|\\x1b\\\\)","gs"),"")).replace(RegExp("\\x1bP.*?\\x1b\\\\","gs"),"")).replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g,"")).replace(/\x1b[@-Z\\-_]/g,"")).replace(/^\[\??\d+[hlKJHfABCDGPXsu]/gm,"")).replace(/\[\d+(?:;\d+)*m/g,"")).replace(/\r/g,"")).replace(/.\x08/g,"")).replace(/\x08+/g,"")).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function si(e){let{size:t=16}=e;return(0,s.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,s.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,s.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function sc(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,s.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,s.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,s.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}function sd(e){let{agent:t,position:r="right",isOpen:a,onClose:o,onAgentChange:l,availableAgents:i=[]}=e,c=(0,u.GW)(t.name),[d,x]=(0,n.useState)(!1),m=(0,n.useCallback)(async()=>{if(!d){x(!0);try{let e=await rN.hi.interruptAgent(t.name);e.success||console.error("Failed to interrupt agent:",e.error)}catch(e){console.error("Error interrupting agent:",e)}finally{setTimeout(()=>x(!1),500)}}},[t.name,d]);return((0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&a&&o()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,o]),(0,n.useEffect)(()=>{if(!a)return;let e=document.body.style.overflow,t=document.body.style.overscrollBehavior;return document.body.style.overflow="hidden",document.body.style.overscrollBehavior="none",()=>{document.body.style.overflow=e,document.body.style.overscrollBehavior=t}},[a]),a)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 z-[1099] animate-fade-in",onClick:o}),(0,s.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,s.jsxs)("div",{className:"flex flex-col gap-3 border-b border-[#21262d] px-4 py-3 sm:px-5 sm:py-4",style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"relative shrink-0 rounded-xl flex items-center justify-center font-bold overflow-hidden w-9 h-9 text-sm sm:w-11 sm:h-11",style:{backgroundColor:c.primary,color:c.text,boxShadow:"0 0 20px ".concat(c.primary,"50, inset 0 1px 0 rgba(255,255,255,0.2)")},children:[(0,s.jsx)("div",{className:"absolute inset-0 opacity-30",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.35) 0%, transparent 50%)"}}),(0,s.jsx)("span",{className:"relative z-10",children:(0,u.hP)(t.name)})]}),(0,s.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 flex-wrap",children:[(0,s.jsx)("h2",{className:"text-base sm:text-lg font-semibold m-0",style:{color:c.primary},title:t.name,children:t.name}),(0,s.jsx)("span",{className:"px-2 py-0.5 rounded-md text-[10px] uppercase tracking-wider font-medium shrink-0 ".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,s.jsx)("span",{className:"text-xs sm:text-sm text-[#8b949e] truncate mt-0.5",title:t.currentTask,children:t.currentTask})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[i.length>1&&l&&(0,s.jsx)(sx,{agents:i,currentAgent:t,onSelect:l}),(0,s.jsxs)("div",{className:"flex items-center gap-1 bg-[#21262d]/80 rounded-lg p-1 border border-[#30363d]/50",children:[(0,s.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,s.jsx)(sh,{})}),(0,s.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,s.jsx)(sp,{})}),(0,s.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,s.jsx)(sg,{})})]}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsx)("button",{className:"p-2 rounded-lg transition-all duration-200 ".concat(d?"bg-[#d29922]/20 text-[#d29922] animate-pulse":"text-[#8b949e] hover:text-[#d29922] hover:bg-[#d29922]/10 hover:shadow-[0_0_8px_rgba(210,153,34,0.2)]"),onClick:m,disabled:d,title:"Send ESC to agent - interrupt current operation",children:(0,s.jsx)(su,{})}),(0,s.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:o,children:(0,s.jsx)(sm,{})})]})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:(0,s.jsx)(sn,{agentName:t.name,mode:"panel",showHeader:!1,maxHeight:"100%",className:"h-full rounded-none border-none"})})]}),(0,s.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 sx(e){let{agents:t,currentAgent:r,onSelect:a}=e,[o,l]=n.useState(!1),i=n.useRef(null);return(0,n.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.jsxs)("div",{className:"relative",ref:i,children:[(0,s.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:()=>l(!o),children:[(0,s.jsx)("span",{children:"Switch agent"}),(0,s.jsx)(sb,{})]}),o&&(0,s.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,s.jsx)("div",{className:"max-h-64 overflow-y-auto",children:t.map(e=>{let t=(0,u.GW)(e.name),n=e.name===r.name;return(0,s.jsxs)("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left transition-colors ".concat(n?"bg-[#238636]/20":"hover:bg-[#21262d]"),onClick:()=>{a(e),l(!1)},children:[(0,s.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,u.hP)(e.name)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"text-sm text-[#c9d1d9] truncate",children:e.name}),(0,s.jsx)("div",{className:"text-xs text-[#8b949e]",children:e.status})]}),n&&(0,s.jsx)(sf,{})]},e.name)})})})]})}function su(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),(0,s.jsx)("text",{x:"12",y:"15",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"8",fontWeight:"600",fontFamily:"system-ui",children:"ESC"})]})}function sm(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function sh(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,s.jsx)("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}function sp(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,s.jsx)("line",{x1:"3",y1:"15",x2:"21",y2:"15"})]})}function sg(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,s.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,s.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,s.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}function sb(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function sf(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3fb950",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function sy(e){let{agentName:t,steps:r,history:a=[],selectedTrajectoryId:o,onSelectTrajectory:l,isLoading:i=!1,onStepClick:c,compact:d=!1}=e,[x,u]=(0,n.useState)(new Set),[m,h]=(0,n.useState)("all"),[p,g]=(0,n.useState)(""),b=null===o&&a.length>0;(0,n.useEffect)(()=>{h("all")},[o]);let f=(0,n.useMemo)(()=>"all"===m?r:r.filter(e=>e.type===m),[r,m]),y=(0,n.useMemo)(()=>{let e=p.trim().toLowerCase();return e?a.filter(t=>{var r,s,n,a,o;let l=null===(r=t.title)||void 0===r?void 0:r.toLowerCase().includes(e),i=null===(s=t.summary)||void 0===s?void 0:s.toLowerCase().includes(e),c=null===(n=t.agents)||void 0===n?void 0:n.some(t=>t.toLowerCase().includes(e)),d=null===(a=t.status)||void 0===a?void 0:a.toLowerCase().includes(e),x=null===(o=t.id)||void 0===o?void 0:o.toLowerCase().includes(e);return l||i||c||d||x}):a},[a,p]),j=e=>{u(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},v=[{value:"all",label:"All",icon:(0,s.jsx)(sN,{})},{value:"tool_call",label:"Tools",icon:(0,s.jsx)(sk,{})},{value:"decision",label:"Decisions",icon:(0,s.jsx)(sC,{})},{value:"message",label:"Messages",icon:(0,s.jsx)(sS,{})},{value:"state_change",label:"State",icon:(0,s.jsx)(sL,{})},{value:"phase_transition",label:"Phases",icon:(0,s.jsx)(sM,{})},{value:"error",label:"Errors",icon:(0,s.jsx)(sD,{})}],w=(0,n.useMemo)(()=>{let e=r.filter(e=>e.phase).reduce((e,t)=>(t.phase&&(e[t.phase]=(e[t.phase]||0)+1),e),{}),t=Object.values(e).reduce((e,t)=>e+t,0);return{phases:e,total:t}},[r]);return(0,s.jsxs)("div",{className:"h-full flex flex-col bg-gradient-to-b from-bg-card to-bg-tertiary rounded-xl border border-border/50 overflow-hidden shadow-lg backdrop-blur-sm",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-accent-cyan to-blue-500 opacity-60"}),(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border/30",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[o&&l&&(0,s.jsxs)("button",{onClick:()=>l(null),className:"flex items-center gap-1.5 px-2 py-1.5 text-[11px] font-medium text-text-muted hover:text-accent-cyan bg-bg-elevated/50 hover:bg-bg-elevated rounded-lg border border-border/30 hover:border-accent-cyan/30 transition-all duration-200",title:"Back to trajectory list",children:[(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,s.jsx)("path",{d:"M19 12H5M12 19l-7-7 7-7",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,s.jsx)("span",{children:"List"})]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-blue-500/20 to-accent-cyan/20 flex items-center justify-center border border-blue-500/30",children:(0,s.jsx)(sw,{})}),r.some(e=>"running"===e.status)&&(0,s.jsx)("span",{className:"absolute -top-1 -right-1 w-3 h-3 bg-accent-cyan rounded-full animate-pulse shadow-[0_0_8px_rgba(0,217,255,0.6)]"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary tracking-wide",children:"Trajectory"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-[11px] text-text-muted font-mono",children:[r.length," ",1===r.length?"step":"steps"]}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-dim",children:"|"}),(0,s.jsx)("span",{className:"text-[11px] text-accent-cyan/80 font-medium truncate max-w-[120px]",children:t})]})]})]})]}),w.total>0&&!d&&(0,s.jsx)("div",{className:"flex items-center gap-1.5",children:["plan","design","execute","review","observe"].map(e=>{let t=w.phases[e]||0,r=sv(e);return t>0?(0,s.jsx)("div",{className:"h-1.5 rounded-full transition-all duration-300",style:{width:"".concat(Math.max(8,t/w.total*48),"px"),backgroundColor:r||"var(--color-border)"},title:"".concat(e,": ").concat(t)},e):null})})]}),!d&&!b&&(0,s.jsx)("div",{className:"flex items-center gap-1 px-4 py-2 bg-bg-elevated/50 border-b border-border/20 overflow-x-auto scrollbar-thin",children:v.map(e=>(0,s.jsxs)("button",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-lg transition-all duration-200 whitespace-nowrap ".concat(m===e.value?"bg-blue-500/20 text-blue-500 border border-blue-500/30 shadow-[0_0_12px_rgba(59,130,246,0.15)]":"text-text-muted hover:text-text-secondary hover:bg-bg-hover/50"),onClick:()=>h(e.value),children:[(0,s.jsx)("span",{className:"opacity-70",children:e.icon}),e.label]},e.value))})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3 scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent",children:i?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-12 text-text-muted",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(sW,{}),(0,s.jsx)("div",{className:"absolute inset-0 bg-accent-cyan/10 rounded-full blur-xl"})]}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Loading trajectory..."})]}):b?(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 px-2",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-text-secondary uppercase tracking-wider",children:"All Trajectories"}),(0,s.jsx)("input",{type:"search",value:p,onChange:e=>g(e.target.value),placeholder:"Search trajectories...",className:"text-[11px] text-text-secondary bg-bg-elevated/60 border border-border/30 rounded-md px-2 py-1 w-40 focus:outline-none focus:border-accent-cyan/40"})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[y.map(e=>(0,s.jsxs)("button",{onClick:()=>null==l?void 0:l(e.id),className:"w-full text-left px-3 py-2.5 rounded-lg transition-all duration-200 border ".concat("active"===e.status?"bg-blue-500/10 border-blue-500/30 hover:bg-blue-500/20":"bg-bg-tertiary/50 border-transparent hover:bg-bg-elevated/60 hover:border-border/40"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"text-[13px] font-medium text-text-primary truncate flex-1",children:e.title}),(0,s.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0 ".concat("completed"===e.status?"bg-green-500/15 text-green-500":"active"===e.status?"bg-blue-500/15 text-blue-500":"bg-amber-500/15 text-amber-500"),children:e.status})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)("span",{className:"text-[10px] text-text-dim",children:function(e){let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/6e4),n=Math.floor(r/36e5),a=Math.floor(r/864e5);return s<1?"just now":s<60?"".concat(s,"m ago"):n<24?"".concat(n,"h ago"):a<7?"".concat(a,"d ago"):t.toLocaleDateString()}(e.startedAt)}),e.confidence&&(0,s.jsxs)("span",{className:"text-[10px] text-text-dim",children:["• ",Math.round(100*e.confidence),"% confidence"]})]}),e.summary&&(0,s.jsx)("p",{className:"text-[11px] text-text-muted mt-1 line-clamp-2",children:e.summary})]},e.id)),0===y.length&&(0,s.jsx)("div",{className:"px-3 py-4 text-[11px] text-text-muted",children:"No matching trajectories. Try a different search."})]})]}):0===f.length?(0,s.jsx)("div",{className:"flex flex-col gap-4 py-4 text-text-muted",children:0===r.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-8",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-elevated/50 flex items-center justify-center border border-border/30",children:(0,s.jsx)(sE,{})}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-secondary",children:"No steps recorded"}),(0,s.jsx)("p",{className:"text-xs text-text-dim mt-1",children:"Steps will appear here as the agent works"})]})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-8",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-elevated/50 flex items-center justify-center border border-border/30",children:(0,s.jsx)(sE,{})}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-secondary",children:"No matching steps"}),(0,s.jsx)("p",{className:"text-xs text-text-dim mt-1",children:'Try a different filter or select "All"'})]})]})}):(0,s.jsx)("div",{className:"flex flex-col gap-0.5",children:f.map((e,t)=>(0,s.jsx)(sj,{step:e,isExpanded:x.has(e.id),isLast:t===f.length-1,isFirst:0===t,compact:d,onToggle:()=>j(e.id),onClick:c?()=>c(e):void 0},e.id))})})]})}function sj(e){var t;let{step:r,isExpanded:n,isLast:a,isFirst:o=!1,compact:l=!1,onToggle:i,onClick:c}=e,d=new Date(r.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),x=function(e){switch(e){case"tool_call":return(0,s.jsx)(sk,{});case"decision":return(0,s.jsx)(sC,{});case"message":return(0,s.jsx)(sS,{});case"state_change":return(0,s.jsx)(sL,{});case"phase_transition":return(0,s.jsx)(sM,{});case"error":return(0,s.jsx)(sD,{});default:return null}}(r.type),u=function(e){switch(e){case"running":return"#ff6b35";case"success":return"#00ffc8";case"error":return"#ff4757";default:return null}}(r.status),m=sv(r.phase),h=function(e){switch(e){case"tool_call":return"#00d9ff";case"decision":case"message":return"#3b82f6";case"state_change":return"#10b981";case"phase_transition":return"#f59e0b";case"error":return"#ef4444";default:return"#6b7280"}}(r.type),p=r.metadata&&Object.keys(r.metadata).length>0,g=!!r.description||p||!!c;return(0,s.jsxs)("div",{className:"flex gap-3 group",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center w-7 relative",children:[!o&&(0,s.jsx)("div",{className:"absolute top-0 w-px h-2 transition-colors",style:{backgroundColor:m?"".concat(m,"40"):"var(--color-border)"}}),(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0 z-10 mt-2 transition-all duration-200 ".concat("running"===r.status?"animate-pulse shadow-[0_0_12px_rgba(0,217,255,0.4)]":"group-hover:scale-110"),style:{background:u?"linear-gradient(135deg, ".concat(u,"40, ").concat(u,"20)"):m?"linear-gradient(135deg, ".concat(m,"30, ").concat(m,"10)"):"linear-gradient(135deg, ".concat(h,"30, ").concat(h,"10)"),borderWidth:"1px",borderStyle:"solid",borderColor:u||m||h||"var(--color-border)",color:u||m||h||"var(--color-text-secondary)"},children:x}),!a&&(0,s.jsx)("div",{className:"w-px flex-1 mt-1 transition-colors",style:{background:"linear-gradient(to bottom, ".concat(m||h||"var(--color-border)","40, transparent)")}})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 pt-1 ".concat(a?"pb-1":"pb-3"),children:[(0,s.jsxs)("button",{className:"w-full flex items-center justify-between gap-3 px-3 py-2.5 rounded-lg transition-all duration-200 text-left border ".concat(n?"bg-bg-elevated/80 border-border/60 shadow-sm":"bg-bg-tertiary/50 border-transparent hover:bg-bg-elevated/60 hover:border-border/40"),onClick:i,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"text-[13px] font-medium text-text-primary truncate",children:r.title}),(0,s.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0",style:{backgroundColor:"".concat(h,"15"),color:h},children:{tool_call:"Tool",decision:"Decision",message:"Message",state_change:"State",phase_transition:"Phase",error:"Error"}[r.type]}),r.phase&&m&&(0,s.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0",style:{backgroundColor:"".concat(m,"15"),color:m},children:r.phase})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[void 0!==r.duration&&(0,s.jsx)("span",{className:"text-[10px] font-mono text-text-muted px-1.5 py-0.5 bg-bg-elevated/50 rounded",children:(t=r.duration)<1e3?"".concat(t,"ms"):t<6e4?"".concat((t/1e3).toFixed(1),"s"):"".concat((t/6e4).toFixed(1),"m")}),(0,s.jsx)("span",{className:"text-[10px] text-text-dim",children:d}),!l&&(0,s.jsx)(sA,{isExpanded:n})]})]}),n&&!l&&g&&(0,s.jsxs)("div",{className:"mt-2 ml-1 pl-3 border-l-2 border-border/30",children:[r.description&&(0,s.jsx)("p",{className:"text-[13px] text-text-secondary mb-3 leading-relaxed",children:r.description}),p&&(0,s.jsx)("div",{className:"bg-bg-elevated/50 rounded-lg p-3 mb-3 overflow-x-auto border border-border/20",children:(0,s.jsx)("pre",{className:"text-[11px] font-mono text-text-muted whitespace-pre-wrap break-words leading-relaxed",children:JSON.stringify(r.metadata,null,2)})}),c&&(0,s.jsxs)("button",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium text-accent-cyan bg-accent-cyan/10 border border-accent-cyan/20 rounded-md hover:bg-accent-cyan/20 hover:border-accent-cyan/30 transition-colors",onClick:e=>{e.stopPropagation(),c()},children:[(0,s.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,s.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,s.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,s.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"View Details"]})]})]})]})}function sv(e){switch(e){case"plan":return"#3b82f6";case"design":return"#00d9ff";case"execute":return"#ff6b35";case"review":return"#00ffc8";case"observe":return"#fbbf24";default:return null}}function sw(){return(0,s.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-blue-500",children:(0,s.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4",strokeLinecap:"round",strokeLinejoin:"round"})})}function sN(){return(0,s.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M12 2v4m0 12v4m-7.07-14.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83"})]})}function sk(){return(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})})}function sC(){return(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M12 2l2.4 7.4H22l-6 4.6 2.3 7-6.3-4.6L5.7 21l2.3-7-6-4.6h7.6z"})})}function sS(){return(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.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 sL(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,s.jsx)("path",{d:"M9 12h6m-3-3v6"})]})}function sM(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("path",{d:"M12 6v6l4 2"})]})}function sD(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("circle",{cx:"12",cy:"16",r:"0.5",fill:"currentColor"})]})}function sA(e){let{isExpanded:t}=e;return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-muted transition-transform duration-200 ".concat(t?"rotate-180":""),children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function sE(){return(0,s.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-text-dim",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function sW(){return(0,s.jsx)("svg",{className:"animate-spin",width:"20",height:"20",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round",className:"text-accent"})})}function sT(e){let{decisions:t,onApprove:r,onReject:a,onDismiss:o,isProcessing:l={}}=e,[i,c]=(0,n.useState)(null),[d,x]=(0,n.useState)({}),u=(0,n.useMemo)(()=>{let e={critical:0,high:1,medium:2,low:3};return[...t].sort((t,r)=>{let s=e[t.priority]-e[r.priority];return 0!==s?s:new Date(t.timestamp).getTime()-new Date(r.timestamp).getTime()})},[t]),m=(0,n.useMemo)(()=>t.reduce((e,t)=>(e[t.priority]=(e[t.priority]||0)+1,e),{}),[t]),h=async(e,t)=>{await (null==r?void 0:r(e.id,t))},p=async e=>{await (null==a?void 0:a(e.id,d[e.id])),x(t=>{let r={...t};return delete r[e.id],r})};return 0===t.length?(0,s.jsxs)("div",{className:"decision-queue decision-queue-empty",children:[(0,s.jsx)(sI,{}),(0,s.jsx)("span",{children:"No pending decisions"})]}):(0,s.jsxs)("div",{className:"decision-queue",children:[(0,s.jsxs)("div",{className:"decision-queue-header",children:[(0,s.jsxs)("div",{className:"decision-queue-title",children:[(0,s.jsx)(s_,{}),(0,s.jsx)("span",{children:"Pending Decisions"}),(0,s.jsx)("span",{className:"decision-queue-count",children:t.length})]}),(0,s.jsxs)("div",{className:"decision-queue-summary",children:[m.critical&&(0,s.jsxs)("span",{className:"decision-priority-badge critical",children:[m.critical," critical"]}),m.high&&(0,s.jsxs)("span",{className:"decision-priority-badge high",children:[m.high," high"]})]})]}),(0,s.jsx)("div",{className:"decision-queue-list",children:u.map(e=>(0,s.jsx)(sP,{decision:e,isExpanded:i===e.id,isProcessing:l[e.id]||!1,rejectReason:d[e.id]||"",onToggle:()=>c(t=>t===e.id?null:e.id),onApprove:t=>h(e,t),onReject:()=>p(e),onRejectReasonChange:t=>x(r=>({...r,[e.id]:t})),onDismiss:()=>null==o?void 0:o(e.id)},e.id))})]})}function sP(e){let{decision:t,isExpanded:r,isProcessing:n,rejectReason:a,onToggle:o,onApprove:l,onReject:i,onRejectReasonChange:c,onDismiss:d}=e,x=(0,u.GW)(t.agentName),m=function(e){let t=new Date(e),r=Math.floor((new Date().getTime()-t.getTime())/6e4);return r<1?"just now":r<60?"".concat(r,"m ago"):r<1440?"".concat(Math.floor(r/60),"h ago"):t.toLocaleDateString()}(t.timestamp),h=t.expiresAt?function(e){let t=new Date(e),r=new Date,s=t.getTime()-r.getTime();if(s<=0)return{text:"Expired",urgent:!0};let n=Math.floor(s/6e4);return n<5?{text:"".concat(n,"m left"),urgent:!0}:n<60?{text:"".concat(n,"m left"),urgent:!1}:{text:"".concat(Math.floor(n/60),"h left"),urgent:!1}}(t.expiresAt):null;return(0,s.jsxs)("div",{className:"decision-card ".concat(t.priority),children:[(0,s.jsxs)("div",{className:"decision-card-header",onClick:o,children:[(0,s.jsx)("div",{className:"decision-card-avatar",style:{backgroundColor:x.primary,color:x.text},children:(0,u.hP)(t.agentName)}),(0,s.jsxs)("div",{className:"decision-card-info",children:[(0,s.jsxs)("div",{className:"decision-card-title",children:[(0,s.jsx)("span",{className:"decision-card-agent",children:t.agentName}),(0,s.jsx)("span",{className:"decision-card-type",children:{approval:"Approval",choice:"Choice",confirmation:"Confirm",input:"Input"}[t.type]}),(0,s.jsx)(sB,{priority:t.priority})]}),(0,s.jsx)("div",{className:"decision-card-subtitle",children:t.title})]}),(0,s.jsxs)("div",{className:"decision-card-meta",children:[h&&(0,s.jsx)("span",{className:"decision-card-expires ".concat(h.urgent?"urgent":""),children:h.text}),(0,s.jsx)("span",{className:"decision-card-time",children:m}),(0,s.jsx)(sU,{isExpanded:r})]})]}),r&&(0,s.jsxs)("div",{className:"decision-card-body",children:[(0,s.jsx)("p",{className:"decision-card-desc",children:t.description}),t.context&&Object.keys(t.context).length>0&&(0,s.jsxs)("div",{className:"decision-card-context",children:[(0,s.jsx)("span",{className:"decision-card-context-label",children:"Context"}),(0,s.jsx)("pre",{children:JSON.stringify(t.context,null,2)})]}),"choice"===t.type&&t.options&&(0,s.jsx)("div",{className:"decision-card-options",children:t.options.map(e=>(0,s.jsxs)("button",{className:"decision-card-option",onClick:()=>l(e.id),disabled:n,children:[(0,s.jsx)("span",{className:"decision-option-label",children:e.label}),e.description&&(0,s.jsx)("span",{className:"decision-option-desc",children:e.description})]},e.id))}),"choice"!==t.type&&(0,s.jsxs)("div",{className:"decision-card-actions",children:[(0,s.jsxs)("button",{className:"decision-btn decision-btn-approve",onClick:()=>l(),disabled:n,children:[n?(0,s.jsx)(sF,{}):(0,s.jsx)(sI,{}),"confirmation"===t.type?"Confirm":"Approve"]}),(0,s.jsxs)("div",{className:"decision-reject-group",children:[(0,s.jsx)("input",{type:"text",className:"decision-reject-input",placeholder:"Reason (optional)",value:a,onChange:e=>c(e.target.value),disabled:n}),(0,s.jsxs)("button",{className:"decision-btn decision-btn-reject",onClick:i,disabled:n,children:[(0,s.jsx)(sR,{}),"Reject"]})]})]}),(0,s.jsx)("button",{className:"decision-card-dismiss",onClick:d,disabled:n,children:"Dismiss without action"})]})]})}function sB(e){let{priority:t}=e;return(0,s.jsx)("span",{className:"decision-priority-badge ".concat(t),children:t})}function s_(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function sI(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function sR(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function sU(e){let{isExpanded:t}=e;return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:t?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function sF(){return(0,s.jsx)("svg",{className:"decision-spinner",width:"14",height:"14",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function sO(e){var t;let{server:r,isSelected:n=!1,onClick:a,onReconnect:o,compact:l=!1}=e,i=function(e){switch(e){case"online":return"#10b981";case"offline":return"#ef4444";case"degraded":return"#f59e0b";case"connecting":return"#6366f1";default:return"#888888"}}(r.status),c=function(e){switch(e){case"online":return"Online";case"offline":return"Offline";case"degraded":return"Degraded";case"connecting":return"Connecting...";default:return"Unknown"}}(r.status);return l?(0,s.jsxs)("button",{className:"\n flex items-center gap-2 py-2 px-3 bg-bg-tertiary border border-border-subtle rounded-md cursor-pointer font-inherit transition-all duration-150\n hover:bg-bg-hover\n ".concat(n?"bg-bg-elevated border-accent-cyan":"","\n ").concat("offline"===r.status?"opacity-70":"","\n "),onClick:a,children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:i}}),(0,s.jsx)("span",{className:"flex-1 text-sm font-medium text-text-primary text-left",children:r.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded-full",children:r.agentCount})]}):(0,s.jsxs)("div",{className:"\n bg-bg-card border border-border-subtle rounded-lg p-4 cursor-pointer transition-all duration-150\n hover:border-border-hover hover:shadow-md\n ".concat(n?"border-accent-cyan bg-bg-elevated":"","\n ").concat("offline"===r.status?"opacity-70":"","\n ").concat("degraded"===r.status?"border-l-[3px] border-l-warning":"","\n "),onClick:a,role:a?"button":void 0,tabIndex:a?0:void 0,children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(sH,{}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:r.name}),r.region&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:r.region})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",style:{color:i},children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat("connecting"===r.status?"animate-pulse":""),style:{backgroundColor:i}}),(0,s.jsx)("span",{children:c})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(60px,1fr))] gap-3 mb-4",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,s.jsx)("span",{className:"text-lg font-semibold text-text-primary",children:r.agentCount}),(0,s.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Agents"})]}),void 0!==r.messageRate&&(0,s.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,s.jsxs)("span",{className:"text-lg font-semibold text-text-primary",children:[r.messageRate,"/s"]}),(0,s.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Messages"})]}),void 0!==r.latency&&(0,s.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,s.jsxs)("span",{className:"text-lg font-semibold text-text-primary",children:[r.latency,"ms"]}),(0,s.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Latency"})]}),void 0!==r.uptime&&(0,s.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,s.jsx)("span",{className:"text-lg font-semibold text-text-primary",children:(t=r.uptime)<60?"".concat(t,"s"):t<3600?"".concat(Math.floor(t/60),"m"):t<86400?"".concat(Math.floor(t/3600),"h"):"".concat(Math.floor(t/86400),"d")}),(0,s.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Uptime"})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-border-subtle",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted font-mono",children:r.url}),r.version&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:["v",r.version]})]}),"offline"===r.status&&o&&(0,s.jsxs)("button",{className:"flex items-center justify-center gap-1.5 w-full mt-3 py-2 px-3 bg-error/10 border border-error/30 rounded-md text-error text-xs font-medium cursor-pointer font-inherit transition-all duration-150 hover:bg-error/20 hover:border-error/50",onClick:e=>{e.stopPropagation(),o()},children:[(0,s.jsx)(sz,{}),"Reconnect"]})]})}function sH(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2",ry:"2"}),(0,s.jsx)("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"6.01",y2:"6"}),(0,s.jsx)("line",{x1:"6",y1:"18",x2:"6.01",y2:"18"})]})}function sz(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,s.jsx)("polyline",{points:"1 20 1 14 7 14"}),(0,s.jsx)("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function sG(e){let{servers:t,agents:r,selectedServerId:a,onServerSelect:o,onServerReconnect:l,isLoading:i=!1}=e,[c,d]=(0,n.useState)("grid"),x=(0,n.useMemo)(()=>{let e=t.filter(e=>"online"===e.status).length,r=t.reduce((e,t)=>e+t.agentCount,0),s=t.filter(e=>void 0!==e.latency).length>0?Math.round(t.reduce((e,t)=>e+(t.latency||0),0)/t.filter(e=>void 0!==e.latency).length):null,n=t.reduce((e,t)=>e+(t.messageRate||0),0);return{online:e,total:t.length,totalAgents:r,avgLatency:s,totalMessages:n}},[t]),m=(0,n.useMemo)(()=>{let e={};return t.forEach(t=>{e[t.id]=[]}),r.forEach((r,s)=>{let n=s%t.length;t[n]&&e[t[n].id].push(r)}),e},[t,r]);return i?(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden flex flex-col items-center justify-center p-12 text-text-muted text-center",children:[(0,s.jsx)(sq,{}),(0,s.jsx)("span",{className:"mt-3 text-sm",children:"Loading fleet data..."})]}):0===t.length?(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden flex flex-col items-center justify-center p-12 text-text-muted text-center",children:[(0,s.jsx)(sJ,{}),(0,s.jsx)("h3",{className:"mt-4 mb-2 text-base font-semibold text-text-primary",children:"No Fleet Servers"}),(0,s.jsx)("p",{className:"text-sm",children:"Connect to peer servers to enable fleet view"})]}):(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-6 p-4 border-b border-border-subtle bg-bg-secondary",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 font-semibold text-sm text-text-primary",children:[(0,s.jsx)(sV,{}),(0,s.jsx)("span",{children:"Fleet Overview"})]}),(0,s.jsxs)("div",{className:"flex gap-6 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center",children:[(0,s.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[x.online,"/",x.total]}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Servers"})]}),(0,s.jsxs)("div",{className:"flex flex-col items-center",children:[(0,s.jsx)("span",{className:"text-base font-semibold text-text-primary",children:x.totalAgents}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Agents"})]}),null!==x.avgLatency&&(0,s.jsxs)("div",{className:"flex flex-col items-center",children:[(0,s.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[x.avgLatency,"ms"]}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Avg Latency"})]}),(0,s.jsxs)("div",{className:"flex flex-col items-center",children:[(0,s.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[x.totalMessages,"/s"]}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Messages"})]})]}),(0,s.jsxs)("div",{className:"flex gap-1 bg-bg-tertiary rounded-md p-0.5",children:[(0,s.jsx)("button",{className:"flex items-center justify-center w-7 h-7 bg-transparent border-none rounded cursor-pointer transition-all duration-150 ".concat("grid"===c?"bg-bg-card text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary"),onClick:()=>d("grid"),title:"Grid view",children:(0,s.jsx)(sZ,{})}),(0,s.jsx)("button",{className:"flex items-center justify-center w-7 h-7 bg-transparent border-none rounded cursor-pointer transition-all duration-150 ".concat("list"===c?"bg-bg-card text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary"),onClick:()=>d("list"),title:"List view",children:(0,s.jsx)(sK,{})})]})]}),(0,s.jsx)("div",{className:"flex h-1 bg-bg-tertiary",children:t.map(e=>(0,s.jsx)("div",{className:"transition-all duration-300 ".concat({online:"bg-success",offline:"bg-error",degraded:"bg-warning",connecting:"bg-accent-purple"}[e.status]||"bg-text-dim"),style:{flex:e.agentCount||1},title:"".concat(e.name,": ").concat(e.agentCount," agents")},e.id))}),(0,s.jsx)("div",{className:"p-4 ".concat("grid"===c?"grid grid-cols-[repeat(auto-fill,minmax(280px,1fr))] gap-4":"flex flex-col gap-2"),children:t.map(e=>{var t;return(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)(sO,{server:e,isSelected:e.id===a,onClick:()=>null==o?void 0:o(e.id),onReconnect:()=>null==l?void 0:l(e.id),compact:"list"===c}),"grid"===c&&(null===(t=m[e.id])||void 0===t?void 0:t.length)>0&&(0,s.jsxs)("div",{className:"flex gap-1 px-2",children:[m[e.id].slice(0,5).map((e,t)=>{let r=(0,u.GW)(e.name);return(0,s.jsx)("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold border-2 border-bg-card",style:{backgroundColor:r.primary,color:r.text,marginLeft:t>0?"-4px":0},title:e.name,children:(0,u.hP)(e.name)},e.name)}),m[e.id].length>5&&(0,s.jsxs)("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold bg-bg-tertiary text-text-muted border-2 border-bg-card",style:{marginLeft:"-4px"},children:["+",m[e.id].length-5]})]})]},e.id)})})]})}function sV(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function sZ(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,s.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,s.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"}),(0,s.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"})]})}function sK(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),(0,s.jsx)("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),(0,s.jsx)("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),(0,s.jsx)("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),(0,s.jsx)("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),(0,s.jsx)("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]})}function sJ(){return(0,s.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2",ry:"2"}),(0,s.jsx)("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"6.01",y2:"6"}),(0,s.jsx)("line",{x1:"6",y1:"18",x2:"6.01",y2:"18"})]})}function sq(){return(0,s.jsx)("svg",{className:"animate-spin",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function s$(e){let{typingUsers:t}=e;return 0===t.length?null:(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-sm text-[#8d8d8e]",children:[(0,s.jsx)("div",{className:"flex -space-x-1.5",children:t.slice(0,3).map(e=>(0,s.jsx)("div",{className:"relative",title:e.username,children:e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-5 h-5 rounded-full border border-[#1a1d21]"}):(0,s.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,s.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,s.jsxs)("span",{className:"flex gap-0.5",children:[(0,s.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"0ms"}}),(0,s.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"150ms"}}),(0,s.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})]})]})}function sY(e,t){let r=e.substring(0,t).match(/(?:^|[\s(])@(\S*)$/);return r?r[1]:null}function sX(e,t,r){let s=e.substring(0,r),n=e.substring(r),a=s.match(/(?:^|[\s(])@(\S*)$/);if(a){let r=a.index||0,s=a[0].charAt(0),o=e.substring(0,"@"===s?r:r+1),l="@".concat(t," "),i=o.length+l.length;return{value:o+l+n,cursorPosition:i}}return{value:e,cursorPosition:r}}function sQ(e){let{agents:t,humanUsers:r=[],inputValue:a,cursorPosition:o,onSelect:l,onClose:i,isVisible:c}=e,[d,x]=(0,n.useState)(0),m=(0,n.useRef)(null),h=(0,n.useMemo)(()=>sY(a,o),[a,o]),p=(0,n.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,n.useMemo)(()=>{if(null===h)return[];let e=h.toLowerCase(),s=[];("*".includes(e)||"everyone".includes(e)||"all".includes(e)||"broadcast".includes(e)||""===e)&&s.push({name:"*",displayName:"@everyone",description:"Broadcast to all agents",isBroadcast:!0});let n=e.startsWith("team:")||e.startsWith("team"),a=e.startsWith("team:")?e.substring(5):e.replace(/^team/,"");(n||""===e)&&p.forEach((t,r)=>{let n=r.toLowerCase();(""===a||n.includes(a)||"team:".concat(n).includes(e))&&s.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=>{s.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=>{s.push({name:e.name,displayName:"@".concat(e.name),description:e.team?"".concat(e.status||"Agent"," \xb7 ").concat(e.team):e.status||"Agent"})}),s},[h,t,r,p]);(0,n.useEffect)(()=>{x(0)},[g.length]),(0,n.useEffect)(()=>{if(!m.current)return;let e=m.current.querySelector('[data-selected="true"]');e&&e.scrollIntoView({block:"nearest"})},[d]);let b=(0,n.useCallback)(e=>{if(c&&0!==g.length)switch(e.key){case"ArrowDown":e.preventDefault(),x(e=>(e+1)%g.length);break;case"ArrowUp":e.preventDefault(),x(e=>(e-1+g.length)%g.length);break;case"Enter":case"Tab":e.preventDefault();let t=g[d];if(t){let e=sX(a,t.name,o);l(t.name,e.value)}break;case"Escape":e.preventDefault(),i()}},[c,g,d,a,o,l,i]);(0,n.useEffect)(()=>{if(c)return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[c,b]);let f=(0,n.useCallback)(e=>{let t=sX(a,e.name,o);l(e.name,t.value)},[a,o,l]);return c&&0!==g.length?(0,s.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,s.jsxs)("div",{"data-selected":t===d,className:"flex items-center gap-2.5 py-2 px-3 cursor-pointer transition-colors duration-150 ".concat(t===d?"bg-white/[0.08]":"hover:bg-white/[0.08]"),onClick:()=>f(e),onMouseEnter:()=>x(t),children:[e.isHuman&&e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-7 h-7 rounded-md object-cover"}):(0,s.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,u.GW)(e.name).primary},children:e.isBroadcast?"*":e.isTeam?(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,s.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,s.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}):e.isHuman?(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"12",cy:"7",r:"4"})]}):(0,u.hP)(e.name)}),(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-[#d1d2d3]",children:e.displayName}),(0,s.jsx)("span",{className:"text-xs text-[#8d8d8e] truncate",children:e.description})]})]},e.name))}):null}function s0(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 s1(e,t,r){let s=e.substring(0,r),n=e.substring(r),a=s.match(/(?:^|[\s(])@(\S*)$/);if(a){let r=a.index||0,s=a[0].charAt(0);return e.substring(0,"@"===s?r:r+1)+"@".concat(t," ")+n}return e}let s2=new Map;function s5(e){let{inputValue:t,cursorPosition:r,onSelect:a,onClose:o,isVisible:l,apiBase:i=""}=e,[c,d]=(0,n.useState)(0),[x,u]=(0,n.useState)([]),[m,h]=(0,n.useState)(!1),[p,g]=(0,n.useState)(null),b=(0,n.useRef)(null),f=(0,n.useRef)(null),y=(0,n.useMemo)(()=>s0(t,r),[t,r]);(0,n.useEffect)(()=>{if(!l||null===y){u([]);return}let e=y||"__root__",t=s2.get(e);if(t&&Date.now()-t.timestamp<3e4){u(t.files),g(null);return}f.current&&f.current.abort();let r=new AbortController;f.current=r;let s=setTimeout(async()=>{h(!0),g(null);try{let t=y||"",s=i?"".concat(i,"/api/files?q=").concat(encodeURIComponent(t),"&limit=15"):(0,rN.kG)("/api/files?q=".concat(encodeURIComponent(t),"&limit=15")),n=await fetch(s,{signal:r.signal});if(!n.ok)throw Error("Failed to fetch files");let a=((await n.json()).files||[]).map(e=>({path:e.path,name:e.name,isDirectory:e.isDirectory||!1}));s2.set(e,{files:a,timestamp:Date.now()}),u(a)}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;g("Failed to load files"),u([])}finally{h(!1)}},150);return()=>{clearTimeout(s),r.abort()}},[l,y,i]),(0,n.useEffect)(()=>{d(0)},[x.length]),(0,n.useEffect)(()=>{if(!b.current)return;let e=b.current.querySelector('[data-selected="true"]');e&&e.scrollIntoView({block:"nearest"})},[c]);let j=(0,n.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 s=x[c];if(s){let e=s1(t,s.path,r);a(s.path,e)}break;case"Escape":e.preventDefault(),o()}},[l,x,c,t,r,a,o]);(0,n.useEffect)(()=>{if(l)return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[l,j]);let v=(0,n.useCallback)(e=>{let s=s1(t,e.path,r);a(e.path,s)},[t,r,a]);return l&&(0!==x.length||m||p)?(0,s.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:b,children:[(0,s.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,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,s.jsx)("polyline",{points:"13 2 13 9 20 9"})]}),"Files ",y&&(0,s.jsxs)("span",{className:"text-[#6b6b6c]",children:['matching "',y,'"']})]}),m&&0===x.length&&(0,s.jsxs)("div",{className:"px-3 py-4 text-sm text-[#8d8d8e] text-center",children:[(0,s.jsx)("svg",{className:"animate-spin mx-auto mb-2",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})}),"Searching files..."]}),p&&(0,s.jsx)("div",{className:"px-3 py-4 text-sm text-red-400 text-center",children:p}),x.map((e,t)=>(0,s.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,s.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,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#fbbf24",strokeWidth:"2",children:(0,s.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,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#60a5fa",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,s.jsx)("polyline",{points:"13 2 13 9 20 9"})]})}),(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-[#d1d2d3] truncate",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-[#6b6b6c] truncate",children:e.path})]})]},e.path)),!m&&!p&&0===x.length&&y&&(0,s.jsxs)("div",{className:"px-3 py-4 text-sm text-[#8d8d8e] text-center",children:['No files found matching "',y,'"']})]}):null}function s4(e){let{onSend:t,onTyping:r,isSending:a=!1,disabled:o=!1,placeholder:l="Type a message...",error:i,agents:c=[],humanUsers:d=[],enableFileAutocomplete:x=!1,insertMention:u,onMentionInserted:m,className:h=""}=e,[p,g]=(0,n.useState)(""),[b,f]=(0,n.useState)(0),[y,j]=(0,n.useState)(!1),[v,w]=(0,n.useState)(!1),[N,k]=(0,n.useState)([]),C=(0,n.useRef)(null),S=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(u&&m){let e="@".concat(u," "),t=C.current;if(t){let r=t.selectionStart||p.length;g(p.slice(0,r)+e+p.slice(r)),setTimeout(()=>{t.focus();let s=r+e.length;t.setSelectionRange(s,s)},0)}else g(t=>t+e);m()}},[u,m,p]);let L=(0,n.useCallback)(async e=>{for(let t of e){let e=crypto.randomUUID(),r=URL.createObjectURL(t);k(s=>[...s,{id:e,file:t,preview:r,isUploading:!0}]);try{let r=await rN.hi.uploadAttachment(t);r.success&&r.data?k(t=>t.map(t=>t.id===e?{...t,isUploading:!1,uploadedId:r.data.attachment.id}:t)):k(t=>t.map(t=>t.id===e?{...t,isUploading:!1,error:r.error||"Upload failed"}:t))}catch(t){k(t=>t.map(t=>t.id===e?{...t,isUploading:!1,error:"Upload failed"}:t))}}},[]),M=(0,n.useCallback)(e=>{if(!e||0===e.length)return;let t=Array.from(e).filter(e=>e.type.startsWith("image/"));t.length>0&&L(t)},[L]),D=(0,n.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(),L(r))},[L]),A=(0,n.useCallback)(e=>{k(t=>{let r=t.find(t=>t.id===e);return r&&URL.revokeObjectURL(r.preview),t.filter(t=>t.id!==e)})},[]),E=async e=>{e.preventDefault();let r=p.trim().length>0,s=N.length>0;if(!r&&!s||a||o||N.some(e=>e.isUploading))return;let n=N.filter(e=>e.uploadedId).map(e=>e.uploadedId),l=p.trim();!l&&n.length>0&&(l="[Screenshot attached]"),await t(l,n.length>0?n:void 0)&&(N.forEach(e=>URL.revokeObjectURL(e.preview)),g(""),k([]),j(!1),w(!1))},W=(p.trim()||N.length>0)&&!a&&!o&&!N.some(e=>e.isUploading);return(0,s.jsxs)("form",{className:"flex flex-col gap-1.5 sm:gap-2 ".concat(h),onSubmit:E,children:[N.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 sm:gap-2 p-1.5 sm:p-2 bg-bg-card rounded-lg border border-border-subtle",children:N.map(e=>(0,s.jsxs)("div",{className:"relative group",children:[(0,s.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,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,s.jsx)("svg",{className:"animate-spin h-5 w-5 text-accent-cyan",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}),e.error&&(0,s.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,s.jsx)("button",{type:"button",onClick:()=>A(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,s.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e.id))}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-3",children:[(0,s.jsx)("input",{ref:S,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>M(e.target.files)}),(0,s.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=S.current)||void 0===e?void 0:e.click()},disabled:o,className:"p-2 sm:p-2.5 bg-bg-card border border-border-subtle rounded-lg sm:rounded-xl text-text-muted hover:text-accent-cyan hover:border-accent-cyan/50 transition-colors flex-shrink-0 disabled:opacity-50 disabled:cursor-not-allowed",title:"Attach screenshot (or paste from clipboard)",children:(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"sm:w-[18px] sm:h-[18px]",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,s.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,s.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}),(0,s.jsxs)("div",{className:"flex-1 relative min-w-0",children:[(c.length>0||d.length>0)&&(0,s.jsx)(sQ,{agents:c,humanUsers:d,inputValue:p,cursorPosition:b,onSelect:(e,t)=>{g(t),j(!1),w(!1),setTimeout(()=>{if(C.current){C.current.focus();let e=t.indexOf(" ")+1;C.current.setSelectionRange(e,e)}},0)},onClose:()=>j(!1),isVisible:y}),x&&(0,s.jsx)(s5,{inputValue:p,cursorPosition:b,onSelect:(e,t)=>{g(t),w(!1),j(!1),setTimeout(()=>{if(C.current){C.current.focus();let e=t.indexOf(" ",1)+1;C.current.setSelectionRange(e,e)}},0)},onClose:()=>w(!1),isVisible:v}),(0,s.jsx)("textarea",{ref:C,className:"w-full py-2 sm:py-3 px-3 sm:px-4 bg-bg-card border border-border-subtle rounded-lg sm:rounded-xl text-sm font-sans text-text-primary outline-none transition-all duration-200 resize-none min-h-[40px] sm:min-h-[44px] max-h-[100px] sm: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 disabled:opacity-50 disabled:cursor-not-allowed",placeholder:l,value:p,onChange:e=>{let t=e.target.value,s=e.target.selectionStart||0;if(g(t),f(s),null==r||r(t.trim().length>0),x&&null!==s0(t,s)){w(!0),j(!1);return}if((c.length>0||d.length>0)&&null!==sY(t,s)){j(!0),w(!1);return}j(!1),w(!1)},onKeyDown:e=>{(!y&&!v||"ArrowDown"!==e.key&&"ArrowUp"!==e.key&&"Tab"!==e.key)&&("Enter"!==e.key||e.shiftKey||y||v||(e.preventDefault(),(p.trim()||N.length>0)&&!a&&!o&&E(e)))},onPaste:D,onSelect:e=>f(e.target.selectionStart||0),disabled:o||a,rows:1})]}),(0,s.jsx)("button",{type:"submit",className:"py-2 sm:py-3 px-3 sm:px-5 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-lg sm:rounded-xl text-xs sm: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 flex-shrink-0",disabled:!W,title:a?"Sending...":N.some(e=>e.isUploading)?"Uploading...":"Send message",children:a?(0,s.jsx)("span",{className:"hidden sm:inline",children:"Sending..."}):N.some(e=>e.isUploading)?(0,s.jsx)("span",{className:"hidden sm:inline",children:"Uploading..."}):(0,s.jsxs)("span",{className:"flex items-center gap-1 sm:gap-2",children:[(0,s.jsx)("span",{className:"hidden sm:inline",children:"Send"}),(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,s.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})]})}),i&&(0,s.jsx)("span",{className:"text-error text-xs ml-2",children:i})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted px-1",children:[(0,s.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"Enter"})," to send,"," ",(0,s.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"Shift+Enter"})," for new line",(c.length>0||d.length>0)&&(0,s.jsxs)(s.Fragment,{children:[", ",(0,s.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"@"})," to mention"]})]})]})}function s3(e){let{onlineUsers:t,onUserClick:r,maxAvatars:a=4}=e,[o,l]=(0,n.useState)(!1),i=(0,n.useRef)(null);if((0,n.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,s.jsxs)("div",{className:"relative",ref:i,children:[(0,s.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,s.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),(0,s.jsxs)("div",{className:"flex -space-x-1.5",children:[c.map(e=>(0,s.jsx)("div",{className:"relative ring-2 ring-[#1a1d21] rounded-full",title:e.username,children:e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-6 h-6 rounded-full object-cover"}):(0,s.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,s.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,s.jsxs)("span",{className:"text-xs text-[#8d8d8e]",children:[t.length," online"]})]}),o&&(0,s.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,s.jsx)("div",{className:"p-2 border-b border-white/10",children:(0,s.jsx)("h3",{className:"text-sm font-medium text-[#d1d2d3]",children:"Online Users"})}),(0,s.jsx)("div",{className:"py-1",children:t.map(e=>(0,s.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,s.jsxs)("div",{className:"relative",children:[e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-8 h-8 rounded-full object-cover"}):(0,s.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,s.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-green-500 rounded-full border-2 border-[#1a1d21]"})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-[#d1d2d3] truncate",children:e.username}),(0,s.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 s6(e){let{user:t,onClose:r,onMention:a,onSendMessage:o}=e,l=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return t&&window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,r]);let i=(0,n.useRef)(!1);if((0,n.useEffect)(()=>{t&&(i.current=!0)},[t]),(0,n.useEffect)(()=>{let e=e=>{if(i.current){i.current=!1;return}l.current&&!l.current.contains(e.target)&&r()};if(t)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[t,r]),!t)return null;let c="https://github.com/".concat(t.username);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40"}),(0,s.jsxs)("div",{ref:l,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,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-[#d1d2d3]",children:"Profile"}),(0,s.jsx)("button",{onClick:r,className:"p-1 hover:bg-white/10 rounded-md transition-colors",title:"Close",children:(0,s.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,s.jsxs)("div",{className:"flex flex-col items-center p-6 border-b border-white/10",children:[(0,s.jsxs)("div",{className:"relative mb-4",children:[t.avatarUrl?(0,s.jsx)("img",{src:t.avatarUrl,alt:t.username,className:"w-24 h-24 rounded-full object-cover border-4 border-[#a855f7]/30"}):(0,s.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,s.jsx)("div",{className:"absolute bottom-1 right-1 w-5 h-5 bg-green-500 rounded-full border-4 border-[#1a1d21]"})]}),(0,s.jsx)("h3",{className:"text-xl font-semibold text-[#d1d2d3] mb-1",children:t.username}),(0,s.jsxs)("span",{className:"text-sm text-green-400 flex items-center gap-1.5",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),"Online"]})]}),(0,s.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Online Since"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:s8(t.connectedAt)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Last Active"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:s8(t.lastSeen)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"GitHub"}),(0,s.jsxs)("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 mt-1 text-sm text-[#a855f7] hover:text-[#c084fc] transition-colors",children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.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,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3"})})]})]})]})}),(0,s.jsxs)("div",{className:"p-4 border-t border-white/10 space-y-2",children:[(0,s.jsxs)("button",{onClick:()=>{null==o||o(t),r()},className:"w-full flex items-center justify-center gap-2 py-2.5 bg-[#00d4aa] hover:bg-[#00bfa0] text-[#0a0e14] font-medium rounded-lg transition-colors",children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.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"})}),"Send Message"]}),(0,s.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,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,s.jsx)("path",{d:"M16 8v5a3 3 0 006 0v-1a10 10 0 10-3.92 7.94"})]}),"Mention @",t.username]}),(0,s.jsxs)("a",{href:c,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,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.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 s8(e){return new Date(e).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}let s9={claude:{label:"Claude",color:"#00d9ff",icon:"\uD83E\uDD16"},codex:{label:"Codex",color:"#10a37f",icon:"\uD83E\uDDE0"},gemini:{label:"Gemini",color:"#4285f4",icon:"✨"},droid:{label:"Droid",color:"#ff6b35",icon:"\uD83E\uDD16"},opencode:{label:"OpenCode",color:"#a855f7",icon:"\uD83D\uDCBB"},cursor:{label:"Cursor",color:"#00b4d8",icon:"\uD83D\uDDB1️"},other:{label:"AI Agent",color:"#8d8d8e",icon:"\uD83E\uDD16"}},s7={agent:"cursor"};function ne(e){var t;let{agent:r,onClose:a,onMessage:o,onLogs:l,onRelease:i,summary:c}=e,d=(0,n.useRef)(null),[x,m]=(0,n.useState)(!1),[g,b]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&a()};return r&&window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,a]);let f=(0,n.useRef)(!1);if((0,n.useEffect)(()=>{r&&(f.current=!0,m(!1),b(!1))},[r]),(0,n.useEffect)(()=>{let e=e=>{if(f.current){f.current=!1;return}d.current&&!d.current.contains(e.target)&&a()};if(r)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[r,a]),!r)return null;let y=(0,u.GW)(r.name),j=(0,u.hP)(r.name),v=h(r.name),w=p(r.name),N=u.yh[r.status]||u.yh.offline,k="online"===r.status,C=r.profile;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40"}),(0,s.jsxs)("div",{ref:d,className:"fixed right-0 top-0 h-full w-96 bg-[#1a1d21] border-l border-white/10 shadow-2xl z-50 flex flex-col animate-slide-in-right",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-[#d1d2d3]",children:"Agent Profile"}),(0,s.jsx)("button",{onClick:a,className:"p-1 hover:bg-white/10 rounded-md transition-colors text-[#d1d2d3]",title:"Close",children:(0,s.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,s.jsxs)("div",{className:"flex flex-col items-center p-6 border-b border-white/10",children:[(0,s.jsxs)("div",{className:"relative mb-4",children:[(0,s.jsx)("div",{className:"w-24 h-24 rounded-2xl flex items-center justify-center text-3xl font-bold shadow-lg",style:{background:"linear-gradient(135deg, ".concat(y.primary,", ").concat(y.primary,"99)"),boxShadow:k?"0 4px 20px ".concat(y.primary,"50"):"none"},children:(0,s.jsx)("span",{style:{color:y.text},children:j})}),(0,s.jsx)("div",{className:"absolute bottom-1 right-1 w-5 h-5 rounded-full border-4 border-[#1a1d21] ".concat(k?"animate-pulse":""),style:{backgroundColor:N,boxShadow:k?"0 0 8px ".concat(N):"none"}})]}),(0,s.jsx)("h3",{className:"text-xl font-semibold text-[#d1d2d3] mb-1",children:v}),w&&(0,s.jsx)("span",{className:"text-sm text-[#8d8d8e] font-mono mb-2",children:w}),(null==C?void 0:C.title)&&(0,s.jsx)("span",{className:"text-sm text-[#a855f7] font-medium mb-2",children:C.title}),(0,s.jsxs)("span",{className:"text-sm flex items-center gap-1.5",style:{color:N},children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(k?"animate-pulse":""),style:{backgroundColor:N}}),r.status.charAt(0).toUpperCase()+r.status.slice(1),r.isProcessing&&" - Thinking..."]}),r.cli&&(()=>{let e=r.cli.toLowerCase(),t=s9[s7[e]||e]||s9.other;return(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-3 px-3 py-2 rounded-lg border",style:{borderColor:"".concat(t.color,"40"),backgroundColor:"".concat(t.color,"10")},children:[(0,s.jsx)("span",{className:"text-lg",children:t.icon}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Provider"}),(0,s.jsx)("span",{className:"text-sm font-medium",style:{color:t.color},children:t.label})]}),(null==C?void 0:C.model)&&(0,s.jsx)("span",{className:"ml-auto text-xs text-[#8d8d8e] font-mono",children:C.model})]})})(),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 mt-3",children:[r.isSpawned&&(0,s.jsx)("span",{className:"text-xs bg-[#a855f7]/20 text-[#a855f7] px-2 py-1 rounded uppercase font-medium",children:"Spawned"}),r.team&&(0,s.jsx)("span",{className:"text-xs bg-[#00d9ff]/20 text-[#00d9ff] px-2 py-1 rounded",children:r.team}),(null==C?void 0:C.personaName)&&(0,s.jsx)("span",{className:"text-xs bg-[#10b981]/20 text-[#10b981] px-2 py-1 rounded",children:C.personaName})]})]}),(0,s.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:(0,s.jsxs)("div",{className:"space-y-4",children:[c&&((null===(t=c.completedTasks)||void 0===t?void 0:t.length)||c.currentTask||c.context)&&(0,s.jsxs)("div",{className:"bg-[#1e2024] border border-[#00d9ff]/20 rounded-lg p-3",children:[(0,s.jsxs)("label",{className:"text-xs text-[#00d9ff] uppercase tracking-wide font-medium flex items-center gap-1.5 mb-2",children:[(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4"})}),"Recent Work"]}),c.currentTask&&(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.jsx)("span",{className:"text-xs text-[#8d8d8e]",children:"Working on:"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-0.5 bg-[#2a2d31] p-2 rounded",children:c.currentTask})]}),c.completedTasks&&c.completedTasks.length>0&&(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.jsx)("span",{className:"text-xs text-[#8d8d8e]",children:"Completed:"}),(0,s.jsxs)("ul",{className:"mt-1 space-y-1",children:[c.completedTasks.slice(0,5).map((e,t)=>(0,s.jsxs)("li",{className:"text-xs text-[#d1d2d3] flex items-start gap-1.5",children:[(0,s.jsx)("span",{className:"text-[#10b981] mt-0.5",children:"✓"}),(0,s.jsx)("span",{children:e})]},t)),c.completedTasks.length>5&&(0,s.jsxs)("li",{className:"text-xs text-[#8d8d8e]",children:["+",c.completedTasks.length-5," more..."]})]})]}),c.context&&(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.jsx)("span",{className:"text-xs text-[#8d8d8e]",children:"Context:"}),(0,s.jsx)("p",{className:"text-xs text-[#a0a0b0] mt-0.5 italic",children:c.context})]}),c.files&&c.files.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-xs text-[#8d8d8e]",children:"Files:"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1 mt-1",children:[c.files.slice(0,6).map((e,t)=>(0,s.jsx)("span",{className:"text-[10px] font-mono bg-[#2a2d31] text-[#a855f7] px-1.5 py-0.5 rounded",title:e,children:e.split("/").pop()},t)),c.files.length>6&&(0,s.jsxs)("span",{className:"text-[10px] text-[#8d8d8e]",children:["+",c.files.length-6]})]})]}),c.lastUpdated&&(0,s.jsx)("div",{className:"mt-2 pt-2 border-t border-[#2a2d31]",children:(0,s.jsxs)("span",{className:"text-[10px] text-[#606070]",children:["Updated ",function(e){let t=new Date(e),r=Math.floor((new Date().getTime()-t.getTime())/1e3),s=Math.floor(r/60),n=Math.floor(s/60),a=Math.floor(n/24);return r<60?"just now":s<60?"".concat(s," min ago"):n<24?"".concat(n," hr ago"):a<7?"".concat(a," day").concat(a>1?"s":""," ago"):nt(e)}(c.lastUpdated)]})})]}),(null==C?void 0:C.description)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Description"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:C.description})]}),r.currentTask&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Current Task"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1 bg-[#2a2d31] p-2 rounded",children:r.currentTask})]}),(null==C?void 0:C.spawnPrompt)&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide flex items-center justify-between",children:[(0,s.jsx)("span",{children:"Spawn Prompt"}),C.spawnPrompt.length>200&&(0,s.jsx)("button",{onClick:()=>m(!x),className:"text-[#a855f7] hover:text-[#c084fc] text-xs font-normal",children:x?"Show less":"Show more"})]}),(0,s.jsx)("pre",{className:"text-sm text-[#d1d2d3] mt-1 bg-[#2a2d31] p-3 rounded font-mono whitespace-pre-wrap ".concat(!x&&C.spawnPrompt.length>200?"line-clamp-4":""),children:C.spawnPrompt})]}),(null==C?void 0:C.personaPrompt)&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide flex items-center justify-between",children:[(0,s.jsx)("span",{children:"Agent Persona"}),C.personaPrompt.length>200&&(0,s.jsx)("button",{onClick:()=>b(!g),className:"text-[#a855f7] hover:text-[#c084fc] text-xs font-normal",children:g?"Show less":"Show more"})]}),(0,s.jsx)("pre",{className:"text-sm text-[#d1d2d3] mt-1 bg-[#2a2d31] p-3 rounded font-mono whitespace-pre-wrap ".concat(!g&&C.personaPrompt.length>200?"line-clamp-4":""),children:C.personaPrompt})]}),(null==C?void 0:C.model)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Model"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1 font-mono",children:C.model})]}),(null==C?void 0:C.workingDirectory)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Working Directory"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1 font-mono bg-[#2a2d31] p-2 rounded truncate",title:C.workingDirectory,children:C.workingDirectory})]}),r.agentId&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Agent ID"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1 font-mono bg-[#2a2d31] p-2 rounded",children:r.agentId})]}),(null==C?void 0:C.capabilities)&&C.capabilities.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Capabilities"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1",children:C.capabilities.map((e,t)=>(0,s.jsx)("span",{className:"text-xs bg-[#2a2d31] text-[#d1d2d3] px-2 py-1 rounded",children:e},t))})]}),r.lastSeen&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Last Seen"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:nt(r.lastSeen)})]}),(null==C?void 0:C.firstSeen)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"First Seen"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:nt(C.firstSeen)})]}),void 0!==r.messageCount&&r.messageCount>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Messages"}),(0,s.jsxs)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:[r.messageCount," messages sent"]})]})]})}),(0,s.jsxs)("div",{className:"p-4 border-t border-white/10 space-y-2",children:[o&&(0,s.jsxs)("button",{onClick:()=>{o(r),a()},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,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.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"})}),"Send Message"]}),r.isSpawned&&l&&(0,s.jsxs)("button",{onClick:()=>{l(r),a()},className:"w-full flex items-center justify-center gap-2 py-2.5 border border-[#00d9ff]/30 text-[#00d9ff] hover:bg-[#00d9ff]/10 font-medium rounded-lg transition-colors",children:[(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,s.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}),"View Logs"]}),r.isSpawned&&i&&(0,s.jsxs)("button",{onClick:()=>{confirm("Are you sure you want to release ".concat(v,"?"))&&(i(r),a())},className:"w-full flex items-center justify-center gap-2 py-2.5 border border-[#ff6b6b]/30 text-[#ff6b6b] hover:bg-[#ff6b6b]/10 font-medium rounded-lg transition-colors",children:[(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,s.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),"Release Agent"]})]})]})]})}function nt(e){return new Date(e).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function nr(e){let{isOpen:t,onClose:r,projects:a,isCloudMode:o=!1,hasArchitect:l=!1,onArchitectSpawned:i}=e,[c,d]=(0,n.useState)([]),[x,u]=(0,n.useState)([]),[m,h]=(0,n.useState)(!1),[p,g]=(0,n.useState)(null),[b,f]=(0,n.useState)(!1),[y,j]=(0,n.useState)(""),[v,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(new Set),[C,S]=(0,n.useState)(!1),[L,M]=(0,n.useState)("claude"),[D,A]=(0,n.useState)(null),[E,W]=(0,n.useState)(null),[T,P]=(0,n.useState)(new Set);(0,n.useEffect)(()=>{t&&o&&B()},[t,o]);let B=async()=>{h(!0),g(null);try{let e=await fetch("/api/project-groups");if(e.ok){let t=await e.json();d(t.groups||[]),u(t.ungroupedRepositories||[])}else{let t=await e.json().catch(()=>({}));g(t.error||"Failed to load project groups")}}catch(e){g("Failed to load project groups")}finally{h(!1)}},_=async()=>{if(y.trim()&&0!==N.size){h(!0),g(null);try{let e=await fetch("/api/project-groups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y.trim(),description:v.trim()||void 0,repositoryIds:Array.from(N)})});if(e.ok){let t=await e.json();t.group&&(d(e=>[...e,t.group]),u(e=>e.filter(e=>!N.has(e.id))),f(!1),j(""),w(""),k(new Set))}else{let t=await e.json().catch(()=>({}));g(t.error||"Failed to create project group")}}catch(e){g("Failed to create project group")}finally{h(!1)}}},I=async(e,t)=>{g(null);try{let r=await fetch("/api/project-groups/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(r.ok){let t=await r.json();t.group&&(d(r=>r.map(r=>r.id===e?{...r,...t.group}:r)),A(null))}else{let e=await r.json().catch(()=>({}));g(e.error||"Failed to update project group")}}catch(e){g("Failed to update project group")}},R=async(e,t)=>{g(null);try{let r="/api/project-groups/".concat(e,"/coordinator/").concat(t?"enable":"disable"),s=await fetch(r,{method:"POST"});if(s.ok){let r=await s.json();d(s=>s.map(s=>{var n,a;return s.id===e?{...s,coordinatorAgent:{...s.coordinatorAgent,enabled:t,name:(null===(n=r.coordinator)||void 0===n?void 0:n.name)||(null===(a=s.coordinatorAgent)||void 0===a?void 0:a.name)}}:s}))}else{let e=await s.json().catch(()=>({}));g(e.error||"Failed to ".concat(t?"enable":"disable"," coordinator"))}}catch(e){g("Failed to ".concat(t?"enable":"disable"," coordinator"))}},U=async e=>{if(window.confirm("Delete this project group? The coordinator will be stopped and repositories will be ungrouped."))try{let t=c.find(t=>t.id===e),r=await fetch("/api/project-groups/".concat(e),{method:"DELETE"});if(r.ok)d(t=>t.filter(t=>t.id!==e)),(null==t?void 0:t.repositories)&&u(e=>[...e,...t.repositories]);else{let e=await r.json().catch(()=>({}));g(e.error||"Failed to delete project group")}}catch(e){g("Failed to delete project group")}},F=async(e,t)=>{try{let r=await fetch("/api/project-groups/".concat(e,"/repositories/").concat(t),{method:"DELETE"});if(r.ok){let r=c.find(t=>t.id===e),s=null==r?void 0:r.repositories.find(e=>e.id===t);d(r=>r.map(r=>r.id===e?{...r,repositories:r.repositories.filter(e=>e.id!==t),repositoryCount:r.repositoryCount-1}:r)),s&&u(e=>[...e,s])}else{let e=await r.json().catch(()=>({}));g(e.error||"Failed to remove repository from group")}}catch(e){g("Failed to remove repository from group")}},O=async(e,t)=>{if(0!==t.length)try{let r=await fetch("/api/project-groups/".concat(e,"/repositories"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repositoryIds:t})});if(r.ok)await B(),W(null),P(new Set);else{let e=await r.json().catch(()=>({}));g(e.error||"Failed to add repositories to group")}}catch(e){g("Failed to add repositories to group")}},H=e=>{P(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},z=e=>{k(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};if(!t)return null;let G=async()=>{S(!0),g(null);try{let e=await fetch("/api/spawn/architect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:L})}),t=await e.json();e.ok&&t.success?(null==i||i(),r()):g(t.error||"Failed to spawn Architect")}catch(e){g("Failed to spawn Architect")}finally{S(!1)}};if(!o){let e=a.length>1;return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,s.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,s.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(na,{}),(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Coordinator Agent"})]}),(0,s.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,s.jsx)(no,{})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[p&&(0,s.jsx)("div",{className:"bg-error/10 border border-error/30 rounded-lg p-3 mb-4 text-error text-sm",children:p}),e&&(0,s.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,s.jsxs)("h3",{className:"text-sm font-semibold text-text-primary mb-3 flex items-center gap-2",children:[(0,s.jsx)(na,{}),"Spawn Architect"]}),l?(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-success",children:[(0,s.jsx)(nx,{}),"Architect is running"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-sm text-text-secondary mb-4",children:["Spawn an Architect agent to coordinate across your ",a.length," connected projects."]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.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:L,onChange:e=>M(e.target.value),children:[(0,s.jsx)("option",{value:"claude",children:"Claude (default)"}),(0,s.jsx)("option",{value:"claude:opus",children:"Claude Opus"}),(0,s.jsx)("option",{value:"claude:sonnet",children:"Claude Sonnet"}),(0,s.jsx)("option",{value:"codex",children:"Codex"})]}),(0,s.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:G,disabled:C,children:C?"Spawning...":"Spawn"})]})]})]}),!e&&(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 mb-4 border border-border-subtle",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Not in Bridge Mode"}),(0,s.jsx)("p",{className:"text-sm text-text-secondary",children:"The Architect coordinates multiple projects. Start bridge mode to enable:"}),(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg p-3 font-mono text-sm mt-3",children:[(0,s.jsx)("span",{className:"text-text-muted",children:"$"})," ",(0,s.jsx)("span",{className:"text-accent-cyan",children:"relay bridge"})," ",(0,s.jsx)("span",{className:"text-accent-orange",children:"~/project1 ~/project2"})]})]}),(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 mb-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"CLI Alternative"}),(0,s.jsxs)("p",{className:"text-sm text-text-secondary mb-3",children:["You can also spawn the Architect via CLI with the ",(0,s.jsx)("code",{className:"bg-bg-card px-1.5 py-0.5 rounded text-accent-cyan",children:"--architect"})," flag:"]}),(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg p-3 font-mono text-sm",children:[(0,s.jsx)("span",{className:"text-text-muted",children:"$"})," ",(0,s.jsx)("span",{className:"text-accent-cyan",children:"relay bridge"})," ",(0,s.jsx)("span",{className:"text-accent-orange",children:"~/project1 ~/project2"})," ",(0,s.jsx)("span",{className:"text-accent-purple",children:"--architect"})]})]})]}),(0,s.jsx)("div",{className:"flex justify-end py-4 px-6 border-t border-border-subtle",children:(0,s.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,s.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,s.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,s.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(na,{}),(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Coordinator Agents"})]}),(0,s.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,s.jsx)(no,{})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[p&&(0,s.jsx)("div",{className:"bg-error/10 border border-error/30 rounded-lg p-3 mb-4 text-error text-sm",children:p}),m&&0===c.length?(0,s.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,s.jsx)(nn,{})}):(0,s.jsxs)(s.Fragment,{children:[c.length>0&&(0,s.jsxs)("div",{className:"space-y-3 mb-6",children:[(0,s.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Project Groups"}),c.map(e=>{var t,r,n,a;return(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-semibold text-text-primary",children:e.name}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[e.repositoryCount," ",1===e.repositoryCount?"repo":"repos"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{className:"text-text-muted hover:text-accent-cyan transition-colors p-1",onClick:()=>A(e),title:"Edit group",children:(0,s.jsx)(nl,{})}),(0,s.jsx)("button",{className:"text-text-muted hover:text-error transition-colors p-1",onClick:()=>U(e.id),title:"Delete group",children:(0,s.jsx)(nc,{})})]})]}),e.repositories.length>0&&(0,s.jsx)("div",{className:"mb-3 space-y-1",children:e.repositories.map(t=>(0,s.jsxs)("div",{className:"flex items-center justify-between py-1 px-2 bg-bg-card/50 rounded text-xs",children:[(0,s.jsx)("span",{className:"text-text-secondary font-mono",children:t.githubFullName}),(0,s.jsx)("button",{className:"text-text-muted hover:text-error transition-colors p-0.5",onClick:()=>F(e.id,t.id),title:"Remove from group",children:(0,s.jsx)(no,{size:12})})]},t.id))}),e.description&&(0,s.jsx)("p",{className:"text-xs text-text-muted mb-3",children:e.description}),E===e.id?(0,s.jsxs)("div",{className:"mb-3 p-3 bg-bg-card rounded-lg border border-border-subtle",children:[(0,s.jsx)("div",{className:"text-xs font-medium text-text-muted mb-2",children:"Select repositories to add:"}),(0,s.jsx)("div",{className:"space-y-1 max-h-[150px] overflow-y-auto mb-3",children:x.length>0?x.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 p-1.5 rounded cursor-pointer hover:bg-bg-hover",children:[(0,s.jsx)("input",{type:"checkbox",className:"accent-accent-cyan",checked:T.has(e.id),onChange:()=>H(e.id)}),(0,s.jsx)("span",{className:"text-xs text-text-primary font-mono",children:e.githubFullName})]},e.id)):(0,s.jsx)("p",{className:"text-xs text-text-muted py-2 text-center",children:"No ungrouped repositories available"})}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("button",{className:"py-1 px-3 text-xs bg-transparent border border-border-subtle rounded text-text-secondary hover:bg-bg-hover",onClick:()=>{W(null),P(new Set)},children:"Cancel"}),(0,s.jsx)("button",{className:"py-1 px-3 text-xs bg-accent-cyan text-bg-deep rounded font-medium hover:bg-accent-cyan/90 disabled:opacity-50",onClick:()=>O(e.id,Array.from(T)),disabled:0===T.size,children:"Add Selected"})]})]}):x.length>0?(0,s.jsxs)("button",{className:"mb-3 w-full py-1.5 text-xs border border-dashed border-border-subtle rounded text-text-muted hover:border-accent-cyan/50 hover:text-accent-cyan transition-colors flex items-center justify-center gap-1",onClick:()=>{W(e.id),P(new Set)},children:[(0,s.jsx)(ni,{}),"Add repositories"]}):null,(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ns,{status:(null===(t=e.coordinatorAgent)||void 0===t?void 0:t.enabled)?"running":"stopped"}),(null===(r=e.coordinatorAgent)||void 0===r?void 0:r.name)&&(0,s.jsx)("span",{className:"text-sm text-text-secondary",children:e.coordinatorAgent.name})]}),(0,s.jsxs)("button",{className:"py-1.5 px-3 rounded-md text-xs font-medium transition-colors ".concat((null===(n=e.coordinatorAgent)||void 0===n?void 0:n.enabled)?"bg-error/20 text-error hover:bg-error/30":"bg-accent-cyan/20 text-accent-cyan hover:bg-accent-cyan/30"," ").concat(0===e.repositoryCount?"opacity-50 cursor-not-allowed":""),onClick:()=>{var t;return e.repositoryCount>0&&R(e.id,!(null===(t=e.coordinatorAgent)||void 0===t?void 0:t.enabled))},disabled:0===e.repositoryCount,title:0===e.repositoryCount?"Add repositories first":void 0,children:[(null===(a=e.coordinatorAgent)||void 0===a?void 0:a.enabled)?"Stop":"Start"," Coordinator"]})]})]},e.id)})]}),D&&(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-accent-cyan/30 mb-4",children:[(0,s.jsx)("h4",{className:"text-sm font-semibold text-text-primary mb-4",children:"Edit Project Group"}),(0,s.jsx)(nu,{group:D,onSave:e=>I(D.id,e),onCancel:()=>A(null)})]}),b?(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-accent-cyan/30",children:[(0,s.jsx)("h4",{className:"text-sm font-semibold text-text-primary mb-4",children:"Create Project Group"}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Group Name"}),(0,s.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:y,onChange:e=>j(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Description (optional)"}),(0,s.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., All frontend repositories",value:v,onChange:e=>w(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Select Repositories"}),(0,s.jsxs)("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:[x.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 p-2 bg-bg-card rounded-md cursor-pointer hover:bg-bg-hover",children:[(0,s.jsx)("input",{type:"checkbox",className:"accent-accent-cyan",checked:N.has(e.id),onChange:()=>z(e.id)}),(0,s.jsx)("span",{className:"text-sm text-text-primary font-mono",children:e.githubFullName}),e.isPrivate&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"\uD83D\uDD12"})]},e.id)),0===x.length&&(0,s.jsx)("p",{className:"text-sm text-text-muted py-4 text-center",children:"No ungrouped repositories. Add repositories in Settings or ungroup existing ones."})]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.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:()=>{f(!1),j(""),w(""),k(new Set)},children:"Cancel"}),(0,s.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:_,disabled:!y.trim()||0===N.size||m,children:m?"Creating...":"Create Group"})]})]})]}):(0,s.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:()=>f(!0),disabled:!!D,children:[(0,s.jsx)(ni,{}),"Create Project Group"]}),(0,s.jsxs)("div",{className:"mt-6 p-4 bg-bg-tertiary/50 rounded-lg border border-border-subtle",children:[(0,s.jsxs)("h4",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center gap-2",children:[(0,s.jsx)(nd,{}),"What is a Coordinator?"]}),(0,s.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 ns(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,s.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium ".concat(r[t]||r.stopped),children:t})}function nn(){return(0,s.jsx)("svg",{className:"animate-spin h-6 w-6 text-accent-cyan",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function na(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,s.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function no(e){let{size:t=20}=e;return(0,s.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function nl(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,s.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}function ni(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function nc(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,s.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 nd(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function nx(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"text-success",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function nu(e){let{group:t,onSave:r,onCancel:a}=e,[o,l]=(0,n.useState)(t.name),[i,c]=(0,n.useState)(t.description||"");return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Group Name"}),(0,s.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",value:o,onChange:e=>l(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Description"}),(0,s.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:"Optional description",value:i,onChange:e=>c(e.target.value)})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.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:a,children:"Cancel"}),(0,s.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:()=>{let e={};o.trim()!==t.name&&(e.name=o.trim()),i.trim()!==(t.description||"")&&(e.description=i.trim()),Object.keys(e).length>0?r(e):a()},disabled:!o.trim(),children:"Save Changes"})]})]})}function nm(){let e=(0,n.useMemo)(()=>Array.from({length:50},(e,t)=>({id:t,x:100*Math.random(),delay:.5*Math.random(),duration:2+2*Math.random(),size:4+8*Math.random(),color:["#00d9ff","#00b8d9","#4ade80","#facc15","#f472b6","#a78bfa"][Math.floor(6*Math.random())],rotation:360*Math.random()})),[]);return(0,s.jsxs)("div",{className:"fixed inset-0 pointer-events-none overflow-hidden z-50",children:[e.map(e=>(0,s.jsx)("div",{className:"absolute animate-confetti-fall",style:{left:"".concat(e.x,"%"),top:"-20px",width:e.size,height:.6*e.size,backgroundColor:e.color,transform:"rotate(".concat(e.rotation,"deg)"),animationDelay:"".concat(e.delay,"s"),animationDuration:"".concat(e.duration,"s"),borderRadius:"2px"}},e.id)),(0,s.jsx)("style",{children:"\n @keyframes confetti-fall {\n 0% {\n transform: translateY(0) rotate(0deg) scale(1);\n opacity: 1;\n }\n 100% {\n transform: translateY(100vh) rotate(720deg) scale(0.5);\n opacity: 0;\n }\n }\n .animate-confetti-fall {\n animation: confetti-fall linear forwards;\n }\n "})]})}function nh(){return(0,s.jsxs)("div",{className:"relative w-20 h-20",children:[(0,s.jsx)("div",{className:"absolute inset-0 rounded-full bg-gradient-to-r from-emerald-400 to-cyan-400 opacity-20 animate-pulse-slow"}),(0,s.jsx)("div",{className:"absolute inset-1 rounded-full bg-gradient-to-br from-emerald-400 via-emerald-500 to-cyan-500 p-0.5 animate-scale-in",children:(0,s.jsx)("div",{className:"w-full h-full rounded-full bg-bg-primary flex items-center justify-center",children:(0,s.jsxs)("svg",{className:"w-10 h-10",viewBox:"0 0 24 24",fill:"none",children:[(0,s.jsx)("path",{d:"M5 12l5 5L19 7",stroke:"url(#check-gradient)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-draw-check",style:{strokeDasharray:30,strokeDashoffset:30}}),(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:"check-gradient",x1:"5",y1:"12",x2:"19",y2:"7",children:[(0,s.jsx)("stop",{stopColor:"#34d399"}),(0,s.jsx)("stop",{offset:"1",stopColor:"#22d3ee"})]})})]})})}),(0,s.jsx)("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-yellow-400 rounded-full animate-sparkle",style:{animationDelay:"0.5s"}}),(0,s.jsx)("div",{className:"absolute top-0 -left-2 w-2 h-2 bg-cyan-400 rounded-full animate-sparkle",style:{animationDelay:"0.7s"}}),(0,s.jsx)("div",{className:"absolute -bottom-1 right-2 w-2 h-2 bg-emerald-400 rounded-full animate-sparkle",style:{animationDelay:"0.9s"}}),(0,s.jsx)("style",{children:"\n @keyframes scale-in {\n 0% { transform: scale(0); opacity: 0; }\n 50% { transform: scale(1.1); }\n 100% { transform: scale(1); opacity: 1; }\n }\n @keyframes draw-check {\n to { stroke-dashoffset: 0; }\n }\n @keyframes sparkle {\n 0%, 100% { transform: scale(0); opacity: 0; }\n 50% { transform: scale(1); opacity: 1; }\n }\n @keyframes pulse-slow {\n 0%, 100% { transform: scale(1); opacity: 0.2; }\n 50% { transform: scale(1.2); opacity: 0.4; }\n }\n .animate-scale-in {\n animation: scale-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n .animate-draw-check {\n animation: draw-check 0.4s ease-out 0.4s forwards;\n }\n .animate-sparkle {\n animation: sparkle 1s ease-in-out infinite;\n }\n .animate-pulse-slow {\n animation: pulse-slow 2s ease-in-out infinite;\n }\n "})]})}function np(){return(0,s.jsxs)("div",{className:"relative w-20 h-20",children:[(0,s.jsx)("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent-cyan border-r-accent-cyan/50 animate-spin"}),(0,s.jsx)("div",{className:"absolute inset-3 rounded-full bg-gradient-to-br from-accent-cyan/20 to-transparent animate-pulse"}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-accent-cyan animate-ping"})}),(0,s.jsx)("div",{className:"absolute inset-0 animate-spin",style:{animationDuration:"3s"},children:(0,s.jsx)("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-2 h-2 rounded-full bg-accent-cyan/80"})}),(0,s.jsx)("div",{className:"absolute inset-0 animate-spin",style:{animationDuration:"4s",animationDirection:"reverse"},children:(0,s.jsx)("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 w-1.5 h-1.5 rounded-full bg-cyan-300/60"})})]})}function ng(e){let{children:t,delay:r}=e;return(0,s.jsxs)("li",{className:"flex items-center gap-3 opacity-0 animate-slide-in-left",style:{animationDelay:"".concat(r,"s"),animationFillMode:"forwards"},children:[(0,s.jsx)("div",{className:"w-5 h-5 rounded-full bg-gradient-to-br from-emerald-400 to-cyan-400 flex items-center justify-center flex-shrink-0",children:(0,s.jsx)("svg",{className:"w-3 h-3 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:(0,s.jsx)("path",{d:"M20 6L9 17l-5-5",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,s.jsx)("span",{className:"text-text-secondary",children:t}),(0,s.jsx)("style",{children:"\n @keyframes slide-in-left {\n from {\n opacity: 0;\n transform: translateX(-20px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n }\n .animate-slide-in-left {\n animation: slide-in-left 0.4s ease-out forwards;\n }\n "})]})}function nb(e){let{type:t,sessionId:r,onClose:a}=e,[o,l]=(0,n.useState)(null),[i,d]=(0,n.useState)("success"===t),[x,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{"success"===t&&(async()=>{try{await new Promise(e=>setTimeout(e,1500));let r=await c.xv.getSubscription();if(r.success&&r.data){var e,t;l({plan:(null===(e=r.data.subscription)||void 0===e?void 0:e.tier)||"pro",status:(null===(t=r.data.subscription)||void 0===t?void 0:t.status)||"active"}),setTimeout(()=>h(!0),200)}}catch(e){u("Could not verify subscription. Please check your billing settings.")}finally{d(!1)}})()},[t,r]);let p=(null==o?void 0:o.plan)==="pro"?"Pro":(null==o?void 0:o.plan)==="team"?"Team":(null==o?void 0:o.plan)==="enterprise"?"Enterprise":"Premium";return"success"===t?(0,s.jsxs)("div",{className:"min-h-screen bg-bg-deep flex items-center justify-center p-4 overflow-hidden",children:[(0,s.jsxs)("div",{className:"fixed inset-0 overflow-hidden pointer-events-none",children:[(0,s.jsx)("div",{className:"absolute top-1/4 -left-32 w-96 h-96 bg-accent-cyan/10 rounded-full blur-3xl animate-float"}),(0,s.jsx)("div",{className:"absolute bottom-1/4 -right-32 w-96 h-96 bg-emerald-500/10 rounded-full blur-3xl animate-float",style:{animationDelay:"1s"}})]}),m&&(0,s.jsx)(nm,{}),(0,s.jsxs)("div",{className:"relative max-w-md w-full bg-bg-primary/95 backdrop-blur-xl rounded-3xl border border-border-subtle p-10 text-center shadow-2xl opacity-0 animate-fade-scale-in",style:{animationFillMode:"forwards"},children:[(0,s.jsx)("div",{className:"absolute top-0 left-8 right-8 h-1 rounded-full bg-gradient-to-r from-transparent via-accent-cyan to-transparent"}),i?(0,s.jsxs)("div",{className:"py-8",children:[(0,s.jsx)("div",{className:"flex justify-center mb-8",children:(0,s.jsx)(np,{})}),(0,s.jsx)("h1",{className:"text-2xl font-bold text-text-primary mb-3 tracking-tight",children:"Processing your upgrade"}),(0,s.jsx)("p",{className:"text-text-muted",children:"Confirming your subscription..."})]}):x?(0,s.jsxs)("div",{className:"py-4",children:[(0,s.jsx)("div",{className:"w-16 h-16 mx-auto mb-6 rounded-full bg-amber-500/20 flex items-center justify-center",children:(0,s.jsxs)("svg",{className:"w-8 h-8 text-amber-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),(0,s.jsx)("h1",{className:"text-2xl font-bold text-text-primary mb-3",children:"Almost there!"}),(0,s.jsx)("p",{className:"text-text-muted mb-8",children:x}),(0,s.jsx)("button",{onClick:a,className:"group w-full py-4 px-6 bg-gradient-to-r from-accent-cyan to-cyan-400 text-bg-deep font-bold rounded-2xl transition-all duration-300 hover:shadow-[0_0_30px_rgba(0,217,255,0.4)] hover:scale-[1.02] active:scale-[0.98]",children:"Go to Billing Settings"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex justify-center mb-6",children:(0,s.jsx)(nh,{})}),(0,s.jsxs)("h1",{className:"text-3xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-text-primary via-accent-cyan to-emerald-400 mb-3 tracking-tight opacity-0 animate-fade-in",style:{animationDelay:"0.3s",animationFillMode:"forwards"},children:["Welcome to ",p,"!"]}),(0,s.jsx)("p",{className:"text-text-muted mb-8 opacity-0 animate-fade-in",style:{animationDelay:"0.5s",animationFillMode:"forwards"},children:"Your subscription is active. Time to supercharge your workflow."}),(0,s.jsxs)("div",{className:"bg-gradient-to-br from-bg-secondary to-bg-deep rounded-2xl p-5 mb-8 text-left border border-border-subtle/50 opacity-0 animate-fade-in",style:{animationDelay:"0.6s",animationFillMode:"forwards"},children:[(0,s.jsx)("h3",{className:"text-xs font-bold text-accent-cyan uppercase tracking-wider mb-4",children:"Your new powers"}),(0,s.jsxs)("ul",{className:"space-y-3 text-sm",children:[(0,s.jsx)(ng,{delay:.8,children:"Expanded workspace & repository limits"}),(0,s.jsx)(ng,{delay:.9,children:"More compute hours for your agents"}),(0,s.jsx)(ng,{delay:1,children:"Increased concurrent agent capacity"}),(0,s.jsx)(ng,{delay:1.1,children:"Priority support & faster responses"})]})]}),(0,s.jsx)("button",{onClick:a,className:"group w-full py-4 px-6 bg-gradient-to-r from-accent-cyan via-cyan-400 to-emerald-400 text-bg-deep font-bold rounded-2xl transition-all duration-300 hover:shadow-[0_0_40px_rgba(0,217,255,0.5)] hover:scale-[1.02] active:scale-[0.98] opacity-0 animate-fade-in",style:{animationDelay:"1.2s",animationFillMode:"forwards"},children:(0,s.jsxs)("span",{className:"flex items-center justify-center gap-2",children:["Launch Dashboard",(0,s.jsx)("svg",{className:"w-5 h-5 transition-transform group-hover:translate-x-1",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,s.jsx)("path",{d:"M5 12h14M12 5l7 7-7 7",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]})]}),(0,s.jsx)("style",{children:"\n @keyframes fade-scale-in {\n from {\n opacity: 0;\n transform: scale(0.95) translateY(10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n }\n @keyframes fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes float {\n 0%, 100% { transform: translateY(0) scale(1); }\n 50% { transform: translateY(-20px) scale(1.05); }\n }\n .animate-fade-scale-in {\n animation: fade-scale-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n .animate-fade-in {\n animation: fade-in 0.5s ease-out forwards;\n }\n .animate-float {\n animation: float 6s ease-in-out infinite;\n }\n "})]}):(0,s.jsxs)("div",{className:"min-h-screen bg-bg-deep flex items-center justify-center p-4",children:[(0,s.jsx)("div",{className:"fixed inset-0 overflow-hidden pointer-events-none",children:(0,s.jsx)("div",{className:"absolute top-1/3 left-1/4 w-64 h-64 bg-text-muted/5 rounded-full blur-3xl"})}),(0,s.jsxs)("div",{className:"relative max-w-md w-full bg-bg-primary/95 backdrop-blur-xl rounded-3xl border border-border-subtle p-10 text-center shadow-xl opacity-0 animate-fade-scale-in",style:{animationFillMode:"forwards"},children:[(0,s.jsx)("div",{className:"w-16 h-16 mx-auto mb-6 rounded-full bg-bg-secondary border border-border-subtle flex items-center justify-center",children:(0,s.jsx)("svg",{className:"w-7 h-7 text-text-muted",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,s.jsx)("h1",{className:"text-2xl font-bold text-text-primary mb-3",children:"No problem!"}),(0,s.jsx)("p",{className:"text-text-muted mb-8 leading-relaxed",children:"Checkout was canceled and you haven't been charged. You can upgrade anytime when you're ready."}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("button",{onClick:a,className:"group w-full py-4 px-6 bg-gradient-to-r from-accent-cyan to-cyan-400 text-bg-deep font-bold rounded-2xl transition-all duration-300 hover:shadow-[0_0_30px_rgba(0,217,255,0.4)] hover:scale-[1.02] active:scale-[0.98]",children:(0,s.jsxs)("span",{className:"flex items-center justify-center gap-2",children:["Return to Dashboard",(0,s.jsx)("svg",{className:"w-5 h-5 transition-transform group-hover:translate-x-1",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,s.jsx)("path",{d:"M5 12h14M12 5l7 7-7 7",strokeLinecap:"round",strokeLinejoin:"round"})})]})}),(0,s.jsx)("button",{onClick:()=>{window.location.href="/?settings=billing"},className:"w-full py-4 px-6 bg-bg-secondary text-text-primary font-semibold rounded-2xl border border-border-subtle transition-all duration-300 hover:border-accent-cyan/50 hover:bg-bg-secondary/80",children:"View Plans"})]})]}),(0,s.jsx)("style",{children:"\n @keyframes fade-scale-in {\n from {\n opacity: 0;\n transform: scale(0.95) translateY(10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n }\n .animate-fade-scale-in {\n animation: fade-scale-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\n }\n "})]})}function nf(e){let{apiBaseUrl:t="",onUpgradeClick:r}=e,[a,o]=(0,n.useState)(null),[l,i]=(0,n.useState)(!0),[c,d]=(0,n.useState)(null),[x,u]=(0,n.useState)(!1);if((0,n.useEffect)(()=>{async function e(){try{let e=await fetch("".concat(t,"/api/usage"),{credentials:"include"});if(!e.ok){if(401===e.status){i(!1);return}throw Error("Failed to fetch usage")}let r=await e.json();o(r)}catch(e){d(e instanceof Error?e.message:"Unknown error")}finally{i(!1)}}e();let r=setInterval(e,3e5);return()=>clearInterval(r)},[t]),l||c||!a||"free"!==a.plan||x)return null;let{computeHoursThisMonth:m}=a.usage,{computeHoursPerMonth:h}=a.limits,p=a.percentUsed.computeHours,g=Math.max(0,h-m),b=g<=0,f=p>=80&&!b,y=a.introBonus,j=(null==y?void 0:y.isActive)&&y.daysRemaining>0,v=new Date().toLocaleDateString("en-US",{month:"long"}),w="bg-bg-tertiary border-border-subtle",N="text-text-secondary",k="text-accent-cyan";return b?(w="bg-error/10 border-error/30",N="text-error",k="text-error"):f?(w="bg-warning/10 border-warning/30",N="text-warning",k="text-warning"):j&&(w="bg-accent-cyan/10 border-accent-cyan/30",N="text-accent-cyan",k="text-accent-cyan"),(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b ".concat(w),children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[j?(0,s.jsx)(nv,{className:k}):(0,s.jsx)(ny,{className:k}),(0,s.jsx)("span",{className:"text-sm ".concat(N),children:b?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"Compute limit reached"})," — Your free tier compute hours for ",v," have been used. Workspaces are paused until next month."]}):f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("strong",{children:[g.toFixed(1),"h remaining"]})," — You've used ",p,"% of your free tier compute hours for ",v,"."]}):j?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"Intro Bonus Active"})," — ",y.resources.cpus," CPU / ",y.resources.memoryGb,"GB RAM."," ",(0,s.jsxs)("span",{className:"text-text-secondary",children:[y.daysRemaining," day",1!==y.daysRemaining?"s":""," remaining before auto-resize to 1 CPU / 2GB."]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("strong",{children:[g.toFixed(1)," of ",h,"h"]})," compute hours remaining this month"]})})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(b||f||j)&&(0,s.jsx)("button",{onClick:r||(()=>window.location.href="/pricing"),className:"px-3 py-1.5 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-md text-xs cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",children:j?"Keep Pro Resources":"Upgrade Plan"}),!b&&(0,s.jsx)("button",{onClick:()=>u(!0),className:"p-1 text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:(0,s.jsx)(nj,{})})]})]})}function ny(e){let{className:t}=e;return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function nj(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function nv(e){let{className:t}=e;return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,s.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,s.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,s.jsx)("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),(0,s.jsx)("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}let nw={url:"",autoConnect:!0,reconnect:!0,maxReconnectAttempts:10,reconnectDelay:1e3},nN="relay:recentRepos";function nk(e){try{localStorage.setItem(nN,JSON.stringify(e))}catch(e){}}var nC=r(8145),nS=r(5372);let nL="dashboard-settings",nM="__activity__";function nD(e){var t,a,o,i,d,x;let{wsUrl:h,orchestratorUrl:p}=e,{data:b,isConnected:y,error:j}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={...nw,...e},[r,s]=(0,n.useState)(null),[a,o]=(0,n.useState)(!1),[l,i]=(0,n.useState)(null),c=(0,n.useRef)(null),d=(0,n.useRef)(0),x=(0,n.useRef)(null),u=(0,n.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);s(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,n.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null),c.current&&(c.current.close(),c.current=null),o(!1)},[]);return(0,n.useEffect)(()=>(t.autoConnect&&u(),()=>{m()}),[t.autoConnect,u,m]),{data:r,isConnected:a,error:l,connect:u,disconnect:m}}({url:h}),{workspaces:v,activeWorkspaceId:w,agents:N,isConnected:k,isLoading:C,error:S,switchWorkspace:L,addWorkspace:M,removeWorkspace:D,spawnAgent:A,stopAgent:E}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{apiUrl:t="http://localhost:3456",enabled:r=!1}=e,[s,a]=(0,n.useState)([]),[o,l]=(0,n.useState)(),[i,c]=(0,n.useState)([]),[d,x]=(0,n.useState)(!1),[u,m]=(0,n.useState)(r),[h,p]=(0,n.useState)(null),g=(0,n.useRef)(null),b=(0,n.useRef)(),f=t.replace(/^http/,"ws"),y=(0,n.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,n.useEffect)(()=>{if(!r)return;let e=()=>{try{let t=new WebSocket(f);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&&j(r.data)}catch(e){console.error("Failed to parse WebSocket message:",e)}},t.onclose=()=>{x(!1),g.current=null,b.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))),b.current=setTimeout(e,3e3)}};return y().then(e),()=>{b.current&&clearTimeout(b.current),g.current&&g.current.close()}},[f,y,r]);let j=(0,n.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,n.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 s=await fetch("".concat(t,"/workspaces/").concat(e,"/agents"));s.ok&&c((await s.json()).agents.map(e=>({...e,spawnedAt:new Date(e.spawnedAt)})))},[t]),w=(0,n.useCallback)(async(e,r)=>{let s=await fetch("".concat(t,"/workspaces"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,name:r})});if(!s.ok)throw Error((await s.json()).error||"Failed to add workspace");return s.json()},[t]),N=(0,n.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,n.useCallback)(async(e,r,s)=>{if(!o)throw Error("No active workspace");let n=await fetch("".concat(t,"/workspaces/").concat(o,"/agents"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,task:r,provider:s})});if(!n.ok)throw Error((await n.json()).error||"Failed to spawn agent");return n.json()},[t,o]),C=(0,n.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:s,activeWorkspaceId:o,agents:i,isConnected:d,isLoading:u,error:h,switchWorkspace:v,addWorkspace:w,removeWorkspace:N,spawnAgent:k,stopAgent:C,refresh:y}}({apiUrl:p}),W=(0,nS.uo)(),T=(null==W?void 0:W.user)?{displayName:W.user.githubUsername||W.user.displayName||"",avatarUrl:W.user.avatarUrl}:void 0,[P,B]=(0,n.useState)([]),[_,I]=(0,n.useState)(()=>(0,rN.J$)()),[R,U]=(0,n.useState)(!1),[F,O]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(!(null==W?void 0:W.user))return;let e=async()=>{U(!0);try{let e=await c.xv.getAccessibleWorkspaces();if(e.success&&e.data.workspaces){B(e.data.workspaces);let t=new Set(e.data.workspaces.map(e=>e.id));if(_&&!t.has(_)){if(e.data.workspaces.length>0){let t=e.data.workspaces[0].id;I(t),(0,rN.hc)(t)}else I(null),(0,rN.hc)(null)}else if(!_&&e.data.workspaces.length>0){let t=e.data.workspaces[0].id;I(t),(0,rN.hc)(t)}}}catch(e){console.error("Failed to fetch cloud workspaces:",e)}finally{U(!1)}};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[null==W?void 0:W.user,_]),(0,n.useEffect)(()=>{if(!(null==W?void 0:W.user)||!_){O([]);return}let e=async()=>{try{let e=await rN.hi.get("/api/daemons/workspace/".concat(_,"/agents"));if(e.agents){let t=e.agents.map(e=>({name:e.name,status:"online"===e.daemonStatus?"online":"offline",isLocal:!e.isHuman,isHuman:e.isHuman,avatarUrl:e.avatarUrl,daemonName:e.isHuman?void 0:e.daemonName,machineId:e.isHuman?void 0:e.machineId,lastSeen:e.lastSeenAt||void 0}));O(t)}}catch(e){console.error("Failed to fetch local agents:",e),O([])}};e();let t=setInterval(e,15e3);return()=>clearInterval(t)},[null==W?void 0:W.user,_]);let H=!!(null==W?void 0:W.user),z=(0,n.useMemo)(()=>H&&P.length>0?P.map(e=>({id:e.id,name:e.name,path:e.publicUrl||"/workspace/".concat(e.name),status:"running"===e.status?"active":"inactive",provider:"claude",lastActiveAt:new Date})):v,[H,P,v]),G=H?_:w,V=H?R:C;(0,n.useEffect)(()=>{H&&_?(0,rN.hc)(_):H&&!_?(0,rN.hc)(null):H||(0,rN.hc)(null)},[H,_]);let Z=(0,n.useCallback)(async e=>{H?(I(e.id),(0,rN.hc)(e.id)):await L(e.id)},[H,L]),K=(0,n.useMemo)(()=>T?{username:T.displayName,avatarUrl:T.avatarUrl}:void 0,[null==T?void 0:T.displayName,null==T?void 0:T.avatarUrl]),[J,q]=(0,n.useState)(nM),[$,Y]=(0,n.useState)([]),X=(0,n.useCallback)(e=>{let t={...e,id:"activity-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9)),timestamp:new Date().toISOString()};Y(e=>[t,...e].slice(0,200))},[]),[Q,et]=(0,n.useState)(!1),[er,es]=(0,n.useState)([]),en=(0,n.useCallback)((e,t,r)=>{var s;let n=null===(s=null==r?void 0:r.incrementUnread)||void 0===s||s;eL(r=>{var s;let n=null!==(s=r[e])&&void 0!==s?s:[];return n.some(e=>e.id===t.id||e.from===t.from&&e.content===t.content&&e.threadId===t.threadId&&2e3>Math.abs(new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()))?r:{...r,[e]:[...n,t]}}),J===e?(eC(e=>[...e,t]),eB(void 0)):n&&ev(t=>t.find(t=>t.id===e)?t.map(t=>{var r;return t.id===e?{...t,unreadCount:(null!==(r=t.unreadCount)&&void 0!==r?r:0)+1}:t}):[...t,{id:e,name:e.startsWith("#")?e.slice(1):e,visibility:"public",status:"active",createdAt:new Date().toISOString(),createdBy:(null==T?void 0:T.displayName)||"Dashboard",memberCount:1,unreadCount:1,hasMentions:!1,isDm:e.startsWith("dm:")}])},[null==T?void 0:T.displayName,J]),{onlineUsers:ea,typingUsers:eo,sendTyping:el,isConnected:ei}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{currentUser:t,wsUrl:r,autoConnect:s=!0,onEvent:a,workspaceId:o}=e,[l,i]=(0,n.useState)([]),[c,d]=(0,n.useState)([]),[x,u]=(0,n.useState)(!1),m=(0,n.useRef)(null),h=(0,n.useRef)(null),p=(0,n.useRef)(null),g=(0,n.useRef)(!1),b=(0,n.useRef)(t);b.current=t;let f=(0,n.useRef)(o);f.current=o;let y=(0,n.useRef)(a);y.current=a,(0,n.useEffect)(()=>{let e=setInterval(()=>{let e=Date.now();d(t=>t.filter(t=>e-t.startedAt<3e3))},1e3);return()=>clearInterval(e)},[]);let j=(0,n.useCallback)(()=>{var e;if(!b.current||(null===(e=m.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN||g.current)return;g.current=!0;let t=r||function(){let e="https:"===window.location.protocol?"wss:":"ws:";return"".concat(e,"//").concat(window.location.host,"/ws/presence")}();try{let e=new WebSocket(t);e.onopen=()=>{g.current=!1,u(!0);let t=b.current;if(t){e.send(JSON.stringify({type:"presence",action:"join",user:{username:t.username,avatarUrl:t.avatarUrl}}));let r=f.current;r&&e.send(JSON.stringify({type:"subscribe_channels",workspaceId:r}))}},e.onclose=()=>{g.current=!1,u(!1),m.current=null,b.current&&(h.current=setTimeout(()=>{j()},2e3))},e.onerror=e=>{console.error("[usePresence] Error:",e)},e.onmessage=e=>{try{var t,r,s,n;let a=JSON.parse(e.data);switch(a.type){case"presence_list":i(a.users||[]);break;case"presence_join":i(e=>[...e.filter(e=>e.username!==a.user.username),a.user]),null===(t=y.current)||void 0===t||t.call(y,a);break;case"presence_leave":i(e=>e.filter(e=>e.username!==a.username)),d(e=>e.filter(e=>e.username!==a.username)),null===(r=y.current)||void 0===r||r.call(y,a);break;case"typing":if(a.username===(null===(s=b.current)||void 0===s?void 0:s.username))break;a.isTyping?d(e=>[...e.filter(e=>e.username!==a.username),{username:a.username,avatarUrl:a.avatarUrl,startedAt:Date.now()}]):d(e=>e.filter(e=>e.username!==a.username));break;default:null===(n=y.current)||void 0===n||n.call(y,a)}}catch(e){console.error("[usePresence] Failed to parse message:",e)}},m.current=e}catch(e){console.error("[usePresence] Failed to create WebSocket:",e)}},[r]),v=(0,n.useCallback)(()=>{if(h.current&&(clearTimeout(h.current),h.current=null),g.current=!1,m.current){let e=m.current;e.onclose=null,e.onerror=null;let t=b.current;e.readyState===WebSocket.OPEN&&t&&e.send(JSON.stringify({type:"presence",action:"leave",username:t.username})),e.close(),m.current=null}u(!1)},[]),w=(0,n.useCallback)(e=>{if(!m.current||m.current.readyState!==WebSocket.OPEN)return;let t=b.current;t&&(p.current&&(clearTimeout(p.current),p.current=null),m.current.send(JSON.stringify({type:"typing",isTyping:e,username:t.username,avatarUrl:t.avatarUrl})),e&&(p.current=setTimeout(()=>{p.current=null,w(!1)},3e3)))},[]);return(0,n.useEffect)(()=>{if(s&&b.current&&(!m.current||m.current.readyState===WebSocket.CLOSED))return j(),()=>{v()}},[s,null==t?void 0:t.username,j,v]),(0,n.useEffect)(()=>{let e=()=>{var e;let t=b.current;(null===(e=m.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN&&t&&m.current.send(JSON.stringify({type:"presence",action:"leave",username:t.username}))};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),{onlineUsers:l,typingUsers:c,sendTyping:w,isConnected:x}}({currentUser:K,onEvent:(0,n.useCallback)(e=>{var t,r,s,n;if((null==e?void 0:e.type)==="presence_join"&&e.user){let t=e.user;t.username!==(null==T?void 0:T.displayName)&&X({type:"user_joined",actor:t.username,actorAvatarUrl:t.avatarUrl,actorType:"user",title:"came online"})}else if((null==e?void 0:e.type)==="presence_leave"&&e.username)e.username!==(null==T?void 0:T.displayName)&&X({type:"user_left",actor:e.username,actorType:"user",title:"went offline"});else if((null==e?void 0:e.type)==="agent_spawned"&&e.agent)X({type:"agent_spawned",actor:e.agent.name||e.agent,actorType:"agent",title:"was spawned",description:e.task,metadata:{cli:e.cli,task:e.task,spawnedBy:e.spawnedBy}});else if((null==e?void 0:e.type)==="agent_released"&&e.agent)X({type:"agent_released",actor:e.agent.name||e.agent,actorType:"agent",title:"was released",metadata:{releasedBy:e.releasedBy}});else if((null==e?void 0:e.type)==="channel_created"){let t=e.channel;if(!t||!t.id)return;ev(e=>{if(e.some(e=>e.id===t.id))return e;let r={id:t.id,name:t.name||t.id,description:t.description,visibility:t.visibility||"public",status:t.status||"active",createdAt:t.createdAt||new Date().toISOString(),createdBy:t.createdBy||"unknown",memberCount:t.memberCount||1,unreadCount:t.unreadCount||0,hasMentions:t.hasMentions||!1,isDm:t.isDm||!1};return console.log("[App] Channel created via WebSocket:",r.id),[...e,r]})}else if((null==e?void 0:e.type)==="channel_message"){let s=e.channel;if(!s)return;let n=e.from||"unknown",a=e.fromEntityType||((null==T?void 0:T.displayName)&&n===T.displayName?"user":"agent"),o={id:null!==(t=e.id)&&void 0!==t?t:"ws-".concat(Date.now()),channelId:s,from:n,fromEntityType:a,fromAvatarUrl:e.fromAvatarUrl,content:null!==(r=e.body)&&void 0!==r?r:"",timestamp:e.timestamp||new Date().toISOString(),threadId:e.thread,isRead:J===s};en(s,o,{incrementUnread:J!==s})}else if((null==e?void 0:e.type)==="direct_message"){let t=e.from||"unknown",r=null==T?void 0:T.displayName;if(!r)return;let a=[t,r].sort(),o="dm:".concat(a.join(":")),l=e.fromEntityType||"agent",i={id:null!==(s=e.id)&&void 0!==s?s:"dm-".concat(Date.now()),channelId:o,from:t,fromEntityType:l,fromAvatarUrl:e.fromAvatarUrl,content:null!==(n=e.body)&&void 0!==n?n:"",timestamp:e.timestamp||new Date().toISOString(),threadId:e.thread,isRead:J===o};en(o,i,{incrementUnread:J!==o})}},[X,en,null==T?void 0:T.displayName,J]),workspaceId:null!=G?G:void 0});(0,n.useEffect)(()=>{(null==T?void 0:T.displayName)&&localStorage.setItem("relay_username",T.displayName)},[null==T?void 0:T.displayName]);let{memberUsernames:ec}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{workspaceId:t,enabled:r=!0}=e,[s,a]=(0,n.useState)([]),[o,l]=(0,n.useState)(!1),[i,d]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{if(!t||!r){a([]);return}l(!0),d(null);try{let e=await c.xv.getWorkspaceMembers(t);e.success?a(e.data.members):(d(e.error),a([]))}catch(e){d(e instanceof Error?e.message:"Failed to fetch members"),a([])}finally{l(!1)}},[t,r]);return(0,n.useEffect)(()=>{x()},[x]),{memberUsernames:(0,n.useMemo)(()=>{let e=new Set;for(let r of s){var t;(null===(t=r.user)||void 0===t?void 0:t.githubUsername)&&e.add(r.user.githubUsername.toLowerCase())}return e},[s]),isLoading:o,error:i,refetch:x}}({workspaceId:null!=G?G:void 0,enabled:H&&!!G}),ed=(0,n.useMemo)(()=>0===ec.size?ea:ea.filter(e=>ec.has(e.username.toLowerCase())),[ea,ec]),[ex,eu]=(0,n.useState)(null),[em,eh]=(0,n.useState)(),[ep,eg]=(0,n.useState)(null),eb=(0,n.useMemo)(()=>{var e;let t=new Map;for(let r of null!==(e=null==b?void 0:b.summaries)&&void 0!==e?e:[])t.set(r.agentName.toLowerCase(),r);return t},[null==b?void 0:b.summaries]),[ef,ey]=(0,n.useState)("local"),[ej,ev]=(0,n.useState)([]),[ew,eN]=(0,n.useState)([]),[ek,eC]=(0,n.useState)([]),[eS,eL]=(0,n.useState)({}),eM=(0,n.useRef)(new Set),[eD,eA]=(0,n.useState)(!1),[eE,eW]=(0,n.useState)(!1),[eT,eB]=(0,n.useState)(),e_=["#general","#engineering"],eI=(0,n.useCallback)(e=>{let t=[...e.archivedChannels||[],...e.channels.filter(e=>"archived"===e.status)],r=e.channels.filter(e=>"archived"!==e.status),s=new Set(r.map(e=>e.id));ev([...e_.filter(e=>!s.has(e)).map(e=>({id:e,name:e.replace("#",""),description:"#general"===e?"General discussion for all agents":"Engineering discussion",visibility:"public",memberCount:0,unreadCount:0,hasMentions:!1,createdAt:new Date().toISOString(),status:"active",createdBy:"system",isDm:!1})),...r]),eN(t)},[]),eR=(0,n.useMemo)(()=>{if(J)return ej.find(e=>e.id===J)||ew.find(e=>e.id===J)},[J,ej,ew]),[eU,eF]=(0,n.useState)([]),[eO,eH]=(0,n.useState)(),[ez,eG]=(0,n.useState)(!1),[eV,eZ]=(0,n.useState)(!1),[eK,eJ]=(0,n.useState)(null),[eq,e$]=(0,n.useState)(!1),[eY,eQ]=(0,n.useState)(!1),[e0,e1]=(0,n.useState)(null),[e2,e4]=(0,n.useState)(!1),[e3,e6]=(0,n.useState)(!1),[e8,e9]=(0,n.useState)(!1),[tt,tr]=(0,n.useState)(null),[ts,tn]=(0,n.useState)(!1),[ta,to]=(0,n.useState)(!1),[tl,ti]=(0,n.useState)(()=>(function(){try{let e=localStorage.getItem(nL);if(!e)return rw;let t=JSON.parse(e);if(!t||"object"!=typeof t)return rw;if("notifications"in t&&"display"in t){let e={...rw,...t,notifications:{...rw.notifications,...t.notifications},display:{...rw.display,...t.display},messages:{...rw.messages,...t.messages},connection:{...rw.connection,...t.connection}};return e.notifications.enabled=e.notifications.sound||e.notifications.desktop||e.notifications.mentionsOnly,e}if("notificationsEnabled"in t||"soundEnabled"in t||"autoScrollMessages"in t)return function(e){var t,r,s,n,a;let o=e.theme&&["dark","light","system"].includes(e.theme)?e.theme:rw.theme,l=null!==(t=e.soundEnabled)&&void 0!==t?t:rw.notifications.sound,i=null!==(r=e.notificationsEnabled)&&void 0!==r?r:rw.notifications.desktop;return{...rw,theme:o,display:{...rw.display,compactMode:null!==(s=e.compactMode)&&void 0!==s?s:rw.display.compactMode,showTimestamps:null!==(n=e.showTimestamps)&&void 0!==n?n:rw.display.showTimestamps},notifications:{...rw.notifications,sound:l,desktop:i,enabled:l||i||rw.notifications.mentionsOnly},messages:{...rw.messages,autoScroll:null!==(a=e.autoScrollMessages)&&void 0!==a?a:rw.messages.autoScroll}}}(t)}catch(e){}return rw})()),tc=(0,n.useCallback)(e=>{ti(t=>e(t))},[]),[td,tx]=(0,n.useState)(!1),[tu,tm]=(0,n.useState)("dashboard"),[th,tp]=(0,n.useState)(!1),[tg,tf]=(0,n.useState)(!1),[ty,tj]=(0,n.useState)({}),[tv,tw]=(0,n.useState)({}),[tk,tC]=(0,n.useState)(null),[tS,tL]=(0,n.useState)(!1),{steps:tM,status:tD,history:tA,isLoading:tE,selectTrajectory:tW,selectedTrajectoryId:tT}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{pollInterval:t=2e3,autoPoll:r=!0,trajectoryId:s,apiBaseUrl:a=""}=e,[o,l]=(0,n.useState)([]),[i,c]=(0,n.useState)(null),[d,x]=(0,n.useState)([]),[u,m]=(0,n.useState)(!0),[h,p]=(0,n.useState)(null),[g,b]=(0,n.useState)(s||null),f=(0,n.useRef)(null),y=(0,n.useRef)(!1),j=(0,n.useRef)(!1),v=(0,n.useRef)(g),w=(0,n.useRef)(0),N=(0,n.useCallback)(async()=>{try{let e=a?"".concat(a,"/api/trajectory"):(0,rN.kG)("/api/trajectory"),t=await fetch(e,{credentials:"include"}),r=await t.json();!1!==r.success&&c({active:r.active,trajectoryId:r.trajectoryId,phase:r.phase,task:r.task})}catch(e){console.error("[useTrajectory] Status fetch error:",e)}},[a]),k=(0,n.useCallback)(async()=>{try{let e=a?"".concat(a,"/api/trajectory/history"):(0,rN.kG)("/api/trajectory/history"),t=await fetch(e,{credentials:"include"}),r=await t.json();r.success&&x(r.trajectories||[])}catch(e){console.error("[useTrajectory] History fetch error:",e)}},[a]),C=(0,n.useCallback)(async()=>{let e=++w.current;try{let t=g?"/api/trajectory/steps?trajectoryId=".concat(encodeURIComponent(g)):"/api/trajectory/steps",r=a?"".concat(a).concat(t):(0,rN.kG)(t),s=await fetch(r,{credentials:"include"}),n=await s.json();if(e!==w.current){console.log("[useTrajectory] Ignoring superseded fetch (request",e,"current",w.current,")");return}if(g!==v.current){console.log("[useTrajectory] Ignoring stale fetch for",g,"current is",v.current);return}n.success?(l(n.steps||[]),p(null)):p(n.error||"Failed to fetch trajectory steps")}catch(t){e===w.current&&g===v.current&&(console.error("[useTrajectory] Steps fetch error:",t),p(t.message))}},[a,g]),S=(0,n.useCallback)(e=>{let t=""===e?null:e;t!==g&&(w.current++,v.current=t,l([]),null!==t&&m(!0),b(t))},[g]),L=(0,n.useCallback)(async()=>{m(!0),await Promise.all([N(),C(),k()]),m(!1)},[N,C,k]);return(0,n.useEffect)(()=>{v.current=g},[g]),(0,n.useEffect)(()=>{j.current||(j.current=!0,L())},[L]),(0,n.useEffect)(()=>{if(!y.current){y.current=!0;return}let e=!1;return m(!0),C().finally(()=>{e||m(!1)}),()=>{e=!0}},[g,C]),(0,n.useEffect)(()=>{if(!r)return;f.current=setInterval(()=>{C(),N()},t);let e=setInterval(k,1e4);return()=>{f.current&&clearInterval(f.current),clearInterval(e)}},[r,t,C,N,k]),{steps:o,status:i,history:d,isLoading:u,error:h,refresh:L,selectTrajectory:S,selectedTrajectoryId:g}}({autoPoll:tS}),tP=(0,n.useMemo)(()=>{var e,t;return tT&&null!==(t=null===(e=tA.find(e=>e.id===tT))||void 0===e?void 0:e.title)&&void 0!==t?t:null},[tT,tA]),{recentRepos:tB,addRecentRepo:t_,getRecentProjects:tI}=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=null!==(e=t.maxRecent)&&void 0!==e?e:5,[s,a]=(0,n.useState)([]);(0,n.useEffect)(()=>{a(function(){try{let e=localStorage.getItem(nN);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];return t}catch(e){return[]}}())},[]);let o=(0,n.useCallback)(e=>{a(t=>{let s=t.filter(t=>t.id!==e.id),n=[{id:e.id,path:e.path,name:e.name,lastAccessed:Date.now()},...s].slice(0,r);return nk(n),n})},[r]),l=(0,n.useCallback)(e=>{a(t=>{let r=t.filter(t=>t.id!==e);return nk(r),r})},[]),i=(0,n.useCallback)(()=>{a([]),nk([])},[]),c=(0,n.useCallback)(e=>{let t=new Map(e.map(e=>[e.id,e]));return s.map(e=>t.get(e.id)).filter(e=>void 0!==e)},[s]);return{recentRepos:s,addRecentRepo:o,removeRecentRepo:l,clearRecentRepos:i,getRecentProjects:c}}(),{repos:tR,refetch:tU}=function(e){let{workspaceId:t,apiBaseUrl:r="/api",enabled:s=!0}=e,[a,o]=(0,n.useState)([]),[l,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{if(t&&s){i(!0),d(null);try{let e=await fetch("".concat(r,"/workspaces/").concat(t,"/repos"),{credentials:"include"});if(!e.ok)throw Error("Failed to fetch workspace repos");let s=await e.json();o(s.repositories||[])}catch(e){d(e instanceof Error?e.message:"Failed to fetch repos"),console.error("Error fetching workspace repos:",e)}finally{i(!1)}}},[t,r,s]);return(0,n.useEffect)(()=>{x()},[x]),{repos:a,isLoading:l,error:c,refetch:x}}({workspaceId:null!=G?G:void 0,apiBaseUrl:"/api",enabled:H&&!!G});(0,n.useEffect)(()=>{eL({}),eC([]),q(void 0)},[G]);let[tF,tO]=(0,n.useState)(!1),[tH,tz]=(0,n.useState)(!1),[tG,tV]=(0,n.useState)([]),[tZ,tK]=(0,n.useState)({}),[tJ,tq]=(0,n.useState)(!1),[t$,tY]=(0,n.useState)([]),{toasts:tX,addToast:tQ,dismissToast:t0}=function(){let[e,t]=(0,n.useState)([]),r=(0,n.useCallback)(e=>{let r=Math.random().toString(36).substring(2,9);return t(t=>[...t,{...e,id:r}]),r},[]),s=(0,n.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),a=(0,n.useCallback)(()=>{t([])},[]),o=(0,n.useCallback)((e,t)=>r({type:"info",title:e,message:t}),[r]),l=(0,n.useCallback)((e,t)=>r({type:"success",title:e,message:t}),[r]),i=(0,n.useCallback)((e,t)=>r({type:"warning",title:e,message:t}),[r]),c=(0,n.useCallback)((e,t)=>r({type:"error",title:e,message:t}),[r]),d=(0,n.useCallback)((e,t,s)=>r({type:"message",title:"New Message",message:t,agentName:e,action:s}),[r]);return{toasts:e,addToast:r,dismissToast:s,clearToasts:a,info:o,success:l,warning:i,error:c,message:d}}(),[t1,t2]=(0,n.useState)(new Set),[t5,t4]=(0,n.useState)(),[t3,t6]=(0,n.useState)(!1),[t8,t9]=(0,n.useState)(!1),[t7,re]=(0,n.useState)(!1),rt=(0,n.useRef)(0),rr=(0,n.useRef)(!0),[rs,rn]=(0,n.useState)(new Map),ra=(0,n.useRef)(null),ro=(0,n.useCallback)(()=>{window.innerWidth<=768&&t9(!1)},[]),rl=(0,n.useMemo)(()=>(function(e){let{agents:t=[],users:r=[],localAgents:s=[]}=e,n=[...t,...r,...s].filter(e=>"dashboard"!==e.name.toLowerCase()),a=new Map;for(let e of n){let t=e.name.toLowerCase(),r=a.get(t);if(r){let s=!r.isLocal&&e.isLocal;a.set(t,{...r,...e,isLocal:!s&&!!e.isLocal})}else a.set(t,e)}return Array.from(a.values())})({agents:null==b?void 0:b.agents,users:null==b?void 0:b.users,localAgents:F}),[null==b?void 0:b.agents,null==b?void 0:b.users,F]),rc=(0,n.useCallback)(e=>{rn(t=>{let r=new Map(t);return r.set(e.toLowerCase(),Date.now()),r})},[]),{agents:rd,groups:rx,selectedAgent:ru,selectAgent:rm,searchQuery:rh,setSearchQuery:rp,totalCount:rg,onlineCount:rb,needsAttentionCount:rf}=function(e){let{agents:t,initialSelected:r,initialSearchQuery:s=""}=e,[a,o]=(0,n.useState)(null!=r?r:null),[l,i]=(0,n.useState)(s),c=(0,n.useMemo)(()=>g(t,l),[t,l]),d=(0,n.useMemo)(()=>m(c),[c]),x=(0,n.useMemo)(()=>[...c].sort((e,t)=>e.name.localeCompare(t.name)),[c]),h=(0,n.useMemo)(()=>{var e;return null!==(e=t.find(e=>e.name===a))&&void 0!==e?e:null},[t,a]),p=(0,n.useMemo)(()=>{let e=f(t);return{totalCount:e.total,onlineCount:e.online,needsAttentionCount:e.needsAttention}},[t]),b=(0,n.useCallback)(e=>{o(e)},[]),y=(0,n.useCallback)(e=>t.find(t=>t.name===e),[t]),j=(0,n.useCallback)(e=>({...e,color:(0,u.GW)(e.name)}),[]);return{agents:c,groups:d,sortedAgents:x,selectedAgent:h,selectAgent:b,searchQuery:l,setSearchQuery:i,...p,getAgentByName:y,getAgentWithColor:j}}({agents:rl}),{messages:ry,threadMessages:rj,currentChannel:rv,setCurrentChannel:rC,currentThread:rS,setCurrentThread:rL,activeThreads:rM,totalUnreadThreadCount:rD,sendMessage:rA,isSending:rE,sendError:rW}=function(e){let{messages:t,currentChannel:r="general",senderName:s}=e,[a,o]=(0,n.useState)(r),[l,i]=(0,n.useState)(null),[c,d]=(0,n.useState)(!1),[x,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(new Map),p=s||"Dashboard",[g,b]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(0===g.length)return;let e=new Set(t.slice(-50).map(e=>"".concat(e.to,":").concat(e.content.slice(0,100))));b(t=>t.filter(t=>{let r="".concat(t.to,":").concat(t.content.slice(0,100));return!e.has(r)}))},[t,g.length]);let f=(0,n.useMemo)(()=>0===g.length?t:[...t,...g],[t,g]),y=(0,n.useMemo)(()=>{let e=new Set(f.map(e=>e.id)),t=f.filter(t=>!t.thread||!e.has(t.thread));return"general"===a?t:t.filter(e=>e.from===a||e.to===a)},[f,a]),j=(0,n.useCallback)(e=>f.filter(t=>t.thread===e),[f]),v=(0,n.useMemo)(()=>{let e=new Map,t=new Set(f.map(e=>e.id));for(let t of f)if(t.thread){let r=e.get(t.thread)||[];r.push(t),e.set(t.thread,r)}let r=[];for(let[s,n]of e.entries()){let e=[...n].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),a=[...new Set(n.flatMap(e=>[e.from,e.to]))].filter(e=>"*"!==e),o=m.get(s),l=n.filter(e=>e.from!==p&&!e.isRead&&(!o||new Date(e.timestamp).getTime()>o)).length,i=s;if(t.has(s)){let e=f.find(e=>e.id===s);if(e){let t=e.content.split("\n")[0];i=t.length>30?t.substring(0,30)+"...":t}}r.push({id:s,name:i,lastMessage:e[0],messageCount:n.length,unreadCount:l,participants:a})}return r.sort((e,t)=>new Date(t.lastMessage.timestamp).getTime()-new Date(e.lastMessage.timestamp).getTime())},[f,m]),w=(0,n.useCallback)(e=>{i(e),e&&h(t=>{let r=new Map(t);return r.set(e,Date.now()),r})},[]),N=(0,n.useMemo)(()=>v.filter(e=>e.unreadCount>0).length,[v]),k=(0,n.useMemo)(()=>{let e=f.filter(e=>!e.isRead).length;return{totalCount:f.length,unreadCount:e}},[f]);return{messages:y,threadMessages:j,currentChannel:a,setCurrentChannel:o,currentThread:l,setCurrentThread:w,activeThreads:v,totalUnreadThreadCount:N,sendMessage:(0,n.useCallback)(async(e,t,r,n)=>{d(!0),u(null);let a="optimistic-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9)),o={id:a,from:p,to:e,content:t,timestamp:new Date().toISOString(),status:"sending",thread:r,isRead:!0};b(e=>[...e,o]);try{let o={to:e,message:t,thread:r,attachments:n};s&&(o.from=s);let l=await rN.hi.sendMessage(o);if(l.success)return!0;return b(e=>e.filter(e=>e.id!==a)),u(l.error||"Failed to send message"),!1}catch(e){return b(e=>e.filter(e=>e.id!==a)),u("Network error"),!1}finally{d(!1)}},[p,s]),isSending:c,sendError:x,...k}}({messages:null!==(d=null==b?void 0:b.messages)&&void 0!==d?d:[],senderName:null==T?void 0:T.displayName}),rT=(0,n.useMemo)(()=>rv&&rl.find(e=>e.isHuman&&e.name.toLowerCase()===rv.toLowerCase())||null,[rl,rv]),rB=(0,n.useMemo)(()=>{var e;return rT&&null!==(e=ty[rT.name])&&void 0!==e?e:[]},[rT,ty]),r_=(0,n.useMemo)(()=>{var e;return rT&&null!==(e=tv[rT.name])&&void 0!==e?e:[]},[rT,tv]),{visibleMessages:rI,participantAgents:rR}=function(e){let{currentHuman:t,currentUserName:r,messages:s,agents:a,selectedDmAgents:o,removedDmAgents:l}=e,i=(0,n.useMemo)(()=>new Set(a.map(e=>e.name)),[a]),c=(0,n.useMemo)(()=>{if(!t)return[];let e=t.name,r=new Set;for(let t of s){let{from:s,to:n}=t;s&&n&&(s===e&&i.has(n)&&r.add(n),n===e&&i.has(s)&&r.add(s),o.includes(s)&&i.has(n)&&r.add(n),o.includes(n)&&i.has(s)&&r.add(s))}let n=new Set([...o,...r]);return l.forEach(e=>n.delete(e)),Array.from(n)},[i,t,s,l,o]),d=(0,n.useMemo)(()=>{if(!t)return s;let e=new Set([t.name,...c]),n=r||"Dashboard";e.add(n),console.log("[DM Filter] currentHuman:",t.name,"currentUser:",r,"agents:",c,"participants:",Array.from(e));let a=s.filter(t=>{var r,s;if(!t.from||!t.to)return!1;let n=e.has(t.from),a=e.has(t.to),o=n&&a;return((null===(r=t.from)||void 0===r?void 0:r.includes("Agent"))||(null===(s=t.to)||void 0===s?void 0:s.includes("Agent")))&&console.log("[DM Filter] msg:",t.from,"->",t.to,"hasFrom:",n,"hasTo:",a,"passes:",o),o});return console.log("[DM Filter] filtered count:",a.length),a},[t,r,c,s]);return{visibleMessages:(0,n.useMemo)(()=>{var e,r,s,n,a,o;if(!t)return d;let l=e=>(null!=e?e:"").trim().replace(/\s+/g," "),i=e=>"sending"===e.status?1:0,c=(e,t)=>{let r=i(e),s=i(t),n=new Date(e.timestamp).getTime(),a=new Date(t.timestamp).getTime();return s<r?t:s>r?e:a>=n?t:e},x=[...d].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime()),u=new Map,m=new Map;for(let t of x){if(t.id){let e=u.get(t.id);u.set(t.id,e?c(e,t):t);continue}let s=null!==(r=null===(e=t.from)||void 0===e?void 0:e.toLowerCase())&&void 0!==r?r:"",n=Math.floor(new Date(t.timestamp).getTime()/5e3),a="".concat(s,"|").concat(n,"|").concat(l(t.content)),o=m.get(a);m.set(a,o?c(o,t):t)}let h=[...u.values(),...m.values()],p=new Map;for(let e of h){let t=null!==(a=null===(s=e.from)||void 0===s?void 0:s.toLowerCase())&&void 0!==a?a:"",r=null!==(o=null===(n=e.to)||void 0===n?void 0:n.toLowerCase())&&void 0!==o?o:"",i="".concat(t,"|").concat(r,"|").concat(l(e.content)),d=p.get(i);p.set(i,d?c(d,e):e)}return Array.from(p.values()).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())},[t,d]),participantAgents:c}}({currentHuman:rT,currentUserName:null!==(x=null==T?void 0:T.displayName)&&void 0!==x?x:null,messages:ry,agents:rd,selectedDmAgents:rB,removedDmAgents:r_}),rU=(0,n.useMemo)(()=>G||!J?[]:ry.filter(e=>J===nM?"*"===e.to||e.isBroadcast:e.to===J||e.channel===J||e.thread===J).map(e=>{var t;return{id:e.id,channelId:J,from:e.from,fromEntityType:"Dashboard"===e.from||e.from===(null==T?void 0:T.displayName)?"user":"agent",content:e.content,timestamp:e.timestamp,isRead:null===(t=e.isRead)||void 0===t||t,threadId:e.thread!==J?e.thread:void 0}}),[ry,J,G,null==T?void 0:T.displayName]),rF=G?ek:rU,rO=(0,n.useMemo)(()=>{var e;let t=new Set(rd.map(e=>e.name.toLowerCase())),r=new Map;for(let s of(T&&r.set(T.displayName.toLowerCase(),{username:T.displayName,avatarUrl:T.avatarUrl}),null!==(e=null==b?void 0:b.messages)&&void 0!==e?e:[])){let e=s.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==b?void 0:b.messages,rd,T]),rz=(0,n.useMemo)(()=>{var e,t;if(!T)return{};let r={},s=new Set(rl.filter(e=>e.isHuman).map(e=>e.name.toLowerCase()));for(let n of null!==(e=null==b?void 0:b.messages)&&void 0!==e?e:[]){let e=n.from,a=n.to;if(!e||!a)continue;let o=a===T.displayName,l=s.has(e.toLowerCase());if(!o||!l)continue;let i=null!==(t=rs.get(e.toLowerCase()))&&void 0!==t?t:0;new Date(n.timestamp).getTime()>i&&(r[e]=(r[e]||0)+1)}return r},[rl,T,null==b?void 0:b.messages,rs]);(0,n.useEffect)(()=>{T&&rv&&new Set(rl.filter(e=>e.isHuman).map(e=>e.name.toLowerCase())).has(rv.toLowerCase())&&rc(rv)},[rl,rv,T,rc]),(0,n.useEffect)(()=>{if(!(window.innerWidth<=768)){re(!1);return}let e=ry.length;!t8&&e>rt.current&&re(!0),rr.current=!t8},[ry.length,t8]),(0,n.useEffect)(()=>{t8&&(re(!1),rt.current=ry.length)},[t8,ry.length]),(0,n.useEffect)(()=>{rt.current=ry.length},[]),(0,n.useEffect)(()=>{if(null==b?void 0:b.messages)for(let n of b.messages){var e,t,r,s;if((null===(e=n.content)||void 0===e?void 0:e.includes("auth_revoked"))||(null===(t=n.content)||void 0===t?void 0:t.includes("authentication_error")))try{let e=JSON.parse(n.content);if("auth_revoked"===e.type&&e.agent){let t=e.agent;t1.has(t)||(t2(e=>new Set([...e,t])),tQ({type:"error",title:"Authentication Expired",message:"".concat(t,"'s API credentials have expired. Please reconnect."),agentName:t,duration:0,action:{label:"Reconnect",onClick:()=>{window.location.href="/providers"}}}))}}catch(e){if((null===(r=n.content)||void 0===r?void 0:r.includes("OAuth token"))&&(null===(s=n.content)||void 0===s?void 0:s.includes("expired"))){let e=n.from;e&&!t1.has(e)&&(t2(t=>new Set([...t,e])),tQ({type:"error",title:"Authentication Expired",message:"".concat(e,"'s API credentials have expired. Please reconnect."),agentName:e,duration:0,action:{label:"Reconnect",onClick:()=>{window.location.href="/providers"}}}))}}}},[null==b?void 0:b.messages,t1,tQ]);let rG=!!(null==b?void 0:null===(a=b.fleet)||void 0===a?void 0:null===(t=a.servers)||void 0===t?void 0:t.length)||v.length>0;(0,n.useEffect)(()=>{if(v.length>0){if(tR.length>1&&G){let t=tR.map(e=>({id:e.id,path:e.githubFullName,name:e.githubFullName.split("/").pop()||e.githubFullName,agents:N.filter(e=>e.workspaceId===G).map(e=>({name:e.name,status:"running"===e.status?"online":"offline",isSpawned:!0,cli:e.provider})),lead:void 0}));if(eF(t),!eO||!t.find(e=>e.id===eO)){var e;eH(null===(e=t[0])||void 0===e?void 0:e.id)}}else eF(v.map(e=>({id:e.id,path:e.path,name:e.name,agents:N.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}))),eH(w)}},[v,N,w,tR,G,eO]),(0,n.useEffect)(()=>{if(v.length>0)return;let e=async()=>{let e=await rN.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}));eF(e),!eO&&e.length>0&&eH(e[0].id)}}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[v.length,eO]);let rV=["architect"],{bridgeAgents:rZ,projectAgents:rK}=(0,n.useMemo)(()=>{let e=[],t=[];for(let r of rd)rV.includes(r.name.toLowerCase())?e.push(r):t.push(r);return{bridgeAgents:e,projectAgents:t}},[rd]),rJ=(0,n.useMemo)(()=>0===eU.length||0===new Set(rK.map(e=>e.name.toLowerCase())).size?eU:eU.map((e,t)=>{if(0===t||e.id===eO){let t=new Set(e.agents.map(e=>e.name.toLowerCase())),r=rK.filter(e=>!t.has(e.name.toLowerCase()));return{...e,agents:[...e.agents,...r]}}return e}),[eU,rK,eO]),r$=(0,n.useMemo)(()=>{let e=rK.filter(e=>e.isHuman);return rJ.length>0?e:rK},[rJ,rK]);(0,n.useCallback)(async e=>{try{await L(e.id)}catch(e){console.error("Failed to switch workspace:",e)}},[L]);let rY=(0,n.useCallback)(async(e,t)=>{eQ(!0),e1(null);try{await M(e,t),e$(!1)}catch(e){throw e1(e instanceof Error?e.message:"Failed to add workspace"),e}finally{eQ(!1)}},[M]),rX=(0,n.useCallback)(e=>{eH(e.id),ey("local"),q(void 0),t_(e),v.length>0&&L(e.id).catch(e=>{console.error("Failed to switch workspace:",e)}),e.agents.length>0&&(rm(e.agents[0].name),rC(e.agents[0].name)),ro()},[rm,rC,ro,v.length,L,t_]),rQ=(0,n.useCallback)(e=>{ey("local"),q(void 0),rm(e.name),rC(e.name),ro()},[rm,rC,ro]),r0=(0,n.useCallback)(()=>{eJ(null),eG(!0)},[]),r1=(0,n.useCallback)(()=>{tm("dashboard"),tx(!0)},[]),r2=(0,n.useCallback)(()=>{tm("workspace"),tx(!0)},[]),r4=(0,n.useCallback)(()=>{tm("billing"),tx(!0)},[]),r3=(0,n.useCallback)(()=>{tp(!0)},[]),r6=(0,n.useCallback)(()=>{tf(!0)},[]),r8=(0,n.useCallback)(()=>{tO(!0)},[]),r9=(0,n.useCallback)(e=>{ey("local"),q(void 0),rC(e.name),rc(e.name),ro()},[ro,rc,rC]),r7=(0,n.useCallback)((e,t)=>{e!==(null==T?void 0:T.displayName)&&(ey("local"),q(void 0),"agent"===t&&rm(e),rC(e),ro())},[null==T?void 0:T.displayName,rm,rC,ro]),se=(0,n.useMemo)(()=>[{id:"#general",name:"general",description:"General discussion for all agents",visibility:"public",memberCount:0,unreadCount:0,hasMentions:!1,createdAt:"2024-01-01T00:00:00.000Z",status:"active",createdBy:"system",isDm:!1},{id:"#engineering",name:"engineering",description:"Engineering discussion",visibility:"public",memberCount:0,unreadCount:0,hasMentions:!1,createdAt:"2024-01-01T00:00:00.000Z",status:"active",createdBy:"system",isDm:!1}],[]);(0,n.useEffect)(()=>{if(!H||!G){ev(se),eN([]);return}ev(se),eN([]),eA(!0),(async()=>{try{let e=await (0,nC.Gn)(G);eI(e)}catch(e){console.error("Failed to fetch channels:",e)}finally{eA(!1)}})()},[G,H,se,eI]),(0,n.useEffect)(()=>{var e;if(!J||"channels"!==ef)return;let t=null!==(e=eS[J])&&void 0!==e?e:[];t.length>0?(eC(t),eW(!1)):eM.current.has(J)?(eC([]),eW(!1)):(eM.current.add(J),(async()=>{try{let e=await (0,nC._U)(G||"local",J,{limit:200});eL(t=>({...t,[J]:e.messages})),eC(e.messages),eW(e.hasMore)}catch(e){console.error("Failed to fetch channel messages:",e),eC([]),eW(!1)}})()),eB(void 0),ev(e=>e.map(e=>e.id===J?{...e,unreadCount:0,hasMentions:!1}:e))},[J,ef,G]);let st=(0,n.useCallback)(async e=>{q(e.id),ro();try{let{joinChannel:t}=await Promise.resolve().then(r.bind(r,8145));await t(G||"local",e.id)}catch(e){console.error("Failed to join channel:",e)}},[ro,G]),sr=(0,n.useCallback)(()=>{e4(!0)},[]),ss=(0,n.useCallback)(async e=>{if(G){e6(!0);try{var t;let r=await (0,nC.mi)(G,e),s=await (0,nC.Gn)(G);eI(s),(null===(t=r.channel)||void 0===t?void 0:t.id)&&q(r.channel.id),e4(!1)}catch(e){console.error("Failed to create channel:",e)}finally{e6(!1)}}},[G]),sn=(0,n.useCallback)(e=>{tr(e),e9(!0)},[]),sa=(0,n.useCallback)(async e=>{if(tt){tn(!0);try{let t=(0,rN._V)(),r={"Content-Type":"application/json"};t&&(r["X-CSRF-Token"]=t);let s=e.map(e=>({id:e,type:"agent"}));if(!(await fetch("/api/channels/invite",{method:"POST",headers:r,credentials:"include",body:JSON.stringify({channel:tt.name,invites:s,workspaceId:G})})).ok)throw Error("Failed to invite members");e9(!1),tr(null)}catch(e){console.error("Failed to invite to channel:",e)}finally{tn(!1)}}},[tt,G]);(0,n.useCallback)(async e=>{if(G)try{let{joinChannel:t}=await Promise.resolve().then(r.bind(r,8145));await t(G,e);let s=await (0,nC.Gn)(G);eI(s)}catch(e){console.error("Failed to join channel:",e)}},[G,eI]),(0,n.useCallback)(async e=>{if(G)try{let{leaveChannel:t}=await Promise.resolve().then(r.bind(r,8145));await t(G,e.id),J===e.id&&q(void 0);let s=await (0,nC.Gn)(G);eI(s)}catch(e){console.error("Failed to leave channel:",e)}},[G,J,eI]);let so=(0,n.useCallback)(async()=>{if(eR&&G)try{let e=await (0,nC.Fk)(G,eR.id);es(e),et(!0)}catch(e){console.error("Failed to load channel members:",e)}},[eR,G]),sl=(0,n.useCallback)(async(e,t)=>{if(eR&&G)try{await (0,nC.Ah)(G,eR.id,e,t);let r=await (0,nC.Fk)(G,eR.id);es(r)}catch(e){console.error("Failed to remove member:",e)}},[eR,G]),si=(0,n.useCallback)(async(e,t,r)=>{if(eR&&G)try{let r=(0,rN._V)(),s={"Content-Type":"application/json"};if(r&&(s["X-CSRF-Token"]=r),!(await fetch("/api/channels/invite",{method:"POST",headers:s,credentials:"include",body:JSON.stringify({channel:eR.name,invites:[{id:e,type:t}],workspaceId:G})})).ok)throw Error("Failed to add member");let n=await (0,nC.Fk)(G,eR.id);es(n)}catch(e){console.error("Failed to add member:",e)}},[eR,G]),sc=(0,n.useCallback)(async e=>{if(G)try{let{archiveChannel:t}=await Promise.resolve().then(r.bind(r,8145));await t(G,e.id),J===e.id&&q(void 0);let s=await (0,nC.Gn)(G);eI(s)}catch(e){console.error("Failed to archive channel:",e)}},[G,J,eI]),sx=(0,n.useCallback)(async e=>{if(G)try{let{unarchiveChannel:t}=await Promise.resolve().then(r.bind(r,8145));await t(G,e.id);let s=await (0,nC.Gn)(G);eI(s)}catch(e){console.error("Failed to unarchive channel:",e)}},[G,eI]),su=(0,n.useCallback)(async(e,t)=>{if(!J)return;let r=(null==T?void 0:T.displayName)||"Dashboard",s={id:"local-".concat(Date.now()),channelId:J,from:r,fromEntityType:"user",content:e,timestamp:new Date().toISOString(),threadId:t,isRead:!0};en(J,s,{incrementUnread:!1});try{await (0,nC.bG)(G||"local",J,{content:e,threadId:t})}catch(e){console.error("Failed to send channel message:",e)}},[G,J,null==T?void 0:T.displayName,en]),sm=(0,n.useCallback)(async()=>{},[]),sh=(0,n.useRef)(null),sp=(0,n.useCallback)(e=>{G&&(sh.current&&clearTimeout(sh.current),sh.current=setTimeout(async()=>{try{await (0,nC.Qh)(G,e),eB(void 0),ev(t=>t.map(t=>t.id===e?{...t,unreadCount:0,hasMentions:!1}:t))}catch(e){console.error("Failed to mark channel as read:",e)}},500))},[G]);(0,n.useEffect)(()=>{J&&eT&&0!==eT.count&&"channels"===ef&&sp(J)},[J,eT,ef,sp]),(0,n.useEffect)(()=>()=>{sh.current&&clearTimeout(sh.current)},[]);let sg=(0,n.useCallback)(e=>{var t;if(!rT)return;let r=rT.name,s=(null!==(t=ty[r])&&void 0!==t?t:[]).includes(e);tj(t=>{var n;let a=null!==(n=t[r])&&void 0!==n?n:[],o=s?a.filter(t=>t!==e):[...a,e];return{...t,[r]:o}}),tw(t=>{var n;let a=null!==(n=t[r])&&void 0!==n?n:[];return s?a.includes(e)?t:{...t,[r]:[...a,e]}:{...t,[r]:a.filter(t=>t!==e)}})},[rT,ty]),sb=(0,n.useCallback)(async(e,t)=>{if(!rT)return!1;let r=rT.name;if(await rA(r,e,void 0,t),rB.length>0)for(let r of rB)await rA(r,e,void 0,t);return!0},[rT,rB,rA]),sf=(0,n.useCallback)(async(e,t)=>{let r="general"===rv?"*":rv;return rT?sb(e,t):rA(r,e,void 0,t)},[rv,rT,sb,rA]),sj=(0,n.useMemo)(()=>rT?rd.filter(e=>!e.isHuman).map(e=>{var t;let r=(null!==(t=ty[rT.name])&&void 0!==t?t:[]).includes(e.name);return{id:"dm-toggle-".concat(rT.name,"-").concat(e.name),label:"".concat(r?"Remove":"Invite"," ").concat(e.name," in DM"),description:"DM with ".concat(rT.name),category:"actions",action:()=>sg(e.name)}}):[],[rd,rT,ty,sg]),sv=(0,n.useMemo)(()=>{let e=[];return e.push({id:"channels-view",label:"Go to Channels",description:"Switch to channel messaging view",category:"channels",shortcut:"⌘⇧C",action:()=>{ey("channels")}}),e.push({id:"channels-create",label:"Create Channel",description:"Create a new messaging channel",category:"channels",action:()=>{ey("channels"),sr()}}),ej.forEach(t=>{let r=t.unreadCount>0?" (".concat(t.unreadCount," unread)"):"";e.push({id:"channel-switch-".concat(t.id),label:t.isDm?"@".concat(t.name):"#".concat(t.name),description:t.description||"Switch to ".concat(t.isDm?"DM":"channel").concat(r),category:"channels",action:()=>{ey("channels"),q(t.id)}})}),e},[ej,sr]),sw=(0,n.useCallback)(async(e,t)=>{let r=await rA(e,t);if(r){if("*"===e)rm(null),q(nM),ey("channels");else{let t=rd.find(t=>t.name===e);t?(rm(t.name),rC(t.name)):rC(e)}}return r},[rA,rm,rC,rd]),sN=(0,n.useCallback)(async e=>{if(H)try{let t=await c.xv.restartWorkspace(e);t.success?(tY(t=>t.map(t=>t.id===e?{...t,status:"connecting"}:t)),setTimeout(async()=>{try{let e=await c.xv.getWorkspaceSummary();e.success&&e.data.workspaces&&B(e.data.workspaces)}catch(e){console.error("Failed to refresh workspaces after reconnect:",e)}},2e3)):console.error("Failed to restart workspace:",t.error)}catch(e){console.error("Failed to reconnect to server:",e)}else console.warn("Server reconnect not fully supported in orchestrator mode")},[H]),sk=(0,n.useCallback)(async e=>{eZ(!0),eJ(null);try{if(v.length>0&&w)return await A(e.name,void 0,e.command),!0;let t=await rN.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 eJ(t.error||"Failed to spawn agent"),!1;return!0}catch(e){return eJ(e instanceof Error?e.message:"Failed to spawn agent"),!1}finally{eZ(!1)}},[v.length,w,A]),sC=(0,n.useCallback)(async e=>{if(e.isSpawned&&window.confirm('Are you sure you want to release agent "'.concat(e.name,'"?')))try{if(v.length>0&&w){await E(e.name);return}let t=await rN.hi.releaseAgent(e.name);t.success||console.error("Failed to release agent:",t.error)}catch(e){console.error("Failed to release agent:",e)}},[v.length,w,E]),sS=(0,n.useCallback)(e=>{tC(e)},[]);(0,n.useEffect)(()=>{if(!tJ)return;let e=async()=>{let e=await rN.hi.getFleetServers();e.success&&e.data&&tY(e.data.servers.map(e=>({id:e.id,name:e.name,url:"local"===e.id?window.location.origin:"http://".concat(e.id),status:"healthy"===e.status?"online":"degraded"===e.status?"degraded":"offline",agentCount:e.agents.length,uptime:e.uptime,lastSeen:e.lastHeartbeat})))};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[tJ]),(0,n.useEffect)(()=>{if(!tH)return;let e=async()=>{let e=await rN.hi.getDecisions();e.success&&e.data&&tV(e.data.decisions.map(rN.XP))};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[tH]);let sL=(0,n.useCallback)(async(e,t)=>{tK(t=>({...t,[e]:!0}));try{let r=await rN.hi.approveDecision(e,t);r.success?tV(t=>t.filter(t=>t.id!==e)):console.error("Failed to approve decision:",r.error)}catch(e){console.error("Failed to approve decision:",e)}finally{tK(t=>({...t,[e]:!1}))}},[]),sM=(0,n.useCallback)(async(e,t)=>{tK(t=>({...t,[e]:!0}));try{let r=await rN.hi.rejectDecision(e,t);r.success?tV(t=>t.filter(t=>t.id!==e)):console.error("Failed to reject decision:",r.error)}catch(e){console.error("Failed to reject decision:",e)}finally{tK(t=>({...t,[e]:!1}))}},[]),sD=(0,n.useCallback)(async e=>{(await rN.hi.dismissDecision(e)).success&&tV(t=>t.filter(t=>t.id!==e))},[]),sA=(0,n.useCallback)(async e=>{t6(!0);try{var t;let r=e7[e.priority].beadsPriority,s=await rN.hi.createBead({title:e.title,assignee:e.agentName,priority:r,type:"task"});if(s.success&&(null===(t=s.data)||void 0===t?void 0:t.bead))await rN.hi.sendRelayMessage({to:e.agentName,content:'\uD83D\uDCCB New task assigned: "'.concat(e.title,'" (P').concat(r,")\nCheck `bd ready` for details.")}),console.log("Task created:",s.data.bead.id);else throw console.error("Failed to create task bead:",s.error),Error(s.error||"Failed to create task")}catch(e){throw console.error("Failed to create task:",e),e}finally{t6(!1)}},[]),sE=(0,n.useCallback)(()=>{to(!0)},[]),sW=(0,n.useCallback)(()=>{to(!1)},[]);(0,n.useEffect)(()=>{!function(e){try{localStorage.setItem(nL,JSON.stringify(e))}catch(e){}}(tl)},[tl]),n.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(tl.theme),"system"===tl.theme){let t=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>e("system");return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}},[tl.theme]),(0,n.useEffect)(()=>{if(tl.notifications.desktop&&"Notification"in window&&"granted"!==Notification.permission){if("denied"===Notification.permission){tc(e=>({...e,notifications:{...e.notifications,desktop:!1,enabled:e.notifications.sound||e.notifications.mentionsOnly}}));return}Notification.requestPermission().then(e=>{"granted"!==e&&tc(e=>({...e,notifications:{...e.notifications,desktop:!1,enabled:e.notifications.sound||e.notifications.mentionsOnly}}))}).catch(()=>void 0)}},[tl.notifications.desktop,tl.notifications.sound,tl.notifications.mentionsOnly,tc]),(0,n.useEffect)(()=>{let e=null==b?void 0:b.messages;if(!e||0===e.length){ra.current=null;return}let t=e[e.length-1];if(!tl.notifications.enabled){var r;ra.current=null!==(r=null==t?void 0:t.id)&&void 0!==r?r:null;return}if(!ra.current){ra.current=t.id;return}let s=e.findIndex(e=>e.id===ra.current);if(-1===s){ra.current=t.id;return}let n=e.slice(s+1);if(0===n.length)return;ra.current=t.id;let a=e=>"Dashboard"===e.from||T&&e.from===T.displayName,o=e=>"general"===rv?"*"===e.to||e.isBroadcast||"general"===e.channel:e.from===rv||e.to===rv,l=e=>!(a(e)||tl.notifications.mentionsOnly&&(null==T?void 0:T.displayName)&&!e.content.includes("@".concat(T.displayName))||"undefined"!=typeof document&&!document.hidden&&o(e)),i=!1;for(let e of n)if(l(e)){if(tl.notifications.desktop&&"Notification"in window&&"granted"===Notification.permission){let t="*"===e.to?"Activity":e.to,r=e.content.split("\n")[0].slice(0,160),s=new Notification("".concat(e.from," → ").concat(t),{body:r});s.onclick=()=>{window.focus(),"*"===e.to?(q(nM),ey("channels")):rC(e.from),s.close()}}tl.notifications.sound&&(i=!0)}i&&function(){let e=window.AudioContext||window.webkitAudioContext;if(e)try{let t=new e,r=t.createOscillator(),s=t.createGain();r.type="sine",r.frequency.value=880,s.gain.value=.03,r.connect(s),s.connect(t.destination),r.start(),r.stop(t.currentTime+.12),r.onended=()=>{t.close().catch(()=>void 0)}}catch(e){}}()},[null==b?void 0:b.messages,tl.notifications,rv,T,rC]),n.useEffect(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),to(!0)),(e.metaKey||e.ctrlKey)&&e.shiftKey&&"s"===e.key&&(e.preventDefault(),r0()),(e.metaKey||e.ctrlKey)&&e.shiftKey&&"c"===e.key&&(e.preventDefault(),ey("channels")),(e.metaKey||e.ctrlKey)&&"n"===e.key&&(e.preventDefault(),r6()),"Escape"===e.key&&(to(!1),eG(!1),tf(!1),tL(!1),tx(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r0,r6]);let sP=window.location.pathname,sB=new URLSearchParams(window.location.search);return"/billing/success"===sP?(0,s.jsx)(nb,{type:"success",sessionId:sB.get("session_id")||void 0,onClose:()=>{window.location.href="/"}}):"/billing/canceled"===sP?(0,s.jsx)(nb,{type:"canceled",onClose:()=>{window.location.href="/"}}):(0,s.jsx)(r5,{wsUrl:h,children:(0,s.jsxs)("div",{className:"flex h-screen bg-bg-deep font-sans text-text-primary",children:[(0,s.jsx)("div",{className:"\n fixed inset-0 bg-black/60 backdrop-blur-sm z-[999] transition-opacity duration-200\n md:hidden\n ".concat(t8?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none","\n "),onClick:()=>t9(!1)}),(0,s.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(t8?"translate-x-0":"-translate-x-full","\n "),children:[(0,s.jsx)("div",{className:"p-3 border-b border-sidebar-border",children:(0,s.jsx)(rH,{workspaces:z,activeWorkspaceId:null!=G?G:void 0,onSelect:Z,onAddWorkspace:()=>e$(!0),onWorkspaceSettings:r2,isLoading:V})}),(0,s.jsx)(ee,{agents:r$,bridgeAgents:rZ,projects:rJ,currentUserName:null==T?void 0:T.displayName,humanUnreadCounts:rz,currentProject:eO,selectedAgent:null==ru?void 0:ru.name,viewMode:ef,isFleetAvailable:rG,isConnected:y||k,isOpen:t8,activeThreads:rM,currentThread:rS,totalUnreadThreadCount:rD,channels:ej.filter(e=>!e.isDm&&!e.id.startsWith("dm:")).map(e=>({id:e.id,name:e.name,unreadCount:e.unreadCount,hasMentions:e.hasMentions})),archivedChannels:ew.filter(e=>!e.isDm&&!e.id.startsWith("dm:")).map(e=>{var t;return{id:e.id,name:e.name,unreadCount:null!==(t=e.unreadCount)&&void 0!==t?t:0,hasMentions:e.hasMentions}}),selectedChannelId:J,isActivitySelected:J===nM,activityUnreadCount:0,onActivitySelect:()=>{q(nM),rm(null),ey("channels")},onChannelSelect:e=>{let t=ej.find(t=>t.id===e.id)||ew.find(t=>t.id===e.id);t&&(st(t),ey("channels"))},onCreateChannel:sr,onInviteToChannel:e=>{let t=ej.find(t=>t.id===e.id);t&&sn(t)},onArchiveChannel:e=>{let t=ej.find(t=>t.id===e.id);t&&sc(t)},onUnarchiveChannel:e=>{let t=ew.find(t=>t.id===e.id)||ej.find(t=>t.id===e.id);t&&sx(t)},onAgentSelect:rQ,onHumanSelect:r9,onProjectSelect:rX,onViewModeChange:ey,onSpawnClick:r0,onReleaseClick:sC,onLogsClick:sS,onProfileClick:eg,onThreadSelect:rL,onClose:()=>t9(!1),onSettingsClick:r1,onTrajectoryClick:()=>tL(!0),hasActiveTrajectory:null==tD?void 0:tD.active,onFleetClick:()=>tq(!tJ),isFleetViewActive:tJ,onCoordinatorClick:r8,hasMultipleProjects:rJ.length>1})]}),(0,s.jsxs)("main",{className:"flex-1 flex flex-col min-w-0 bg-bg-secondary/50 overflow-hidden",children:[(0,s.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-50 md:sticky md:top-0 md:left-auto md:right-auto bg-bg-secondary",children:[(0,s.jsx)(eP,{currentChannel:rv,selectedAgent:ru,projects:rJ,currentProject:rJ.find(e=>e.id===eO)||null,recentProjects:tI(rJ),viewMode:ef,selectedChannelName:null==eR?void 0:eR.name,onProjectChange:rX,onCommandPaletteOpen:sE,onSettingsClick:r1,onHistoryClick:r3,onNewConversationClick:r6,onCoordinatorClick:r8,onFleetClick:()=>tq(!tJ),isFleetViewActive:tJ,onTrajectoryClick:()=>tL(!0),hasActiveTrajectory:null==tD?void 0:tD.active,onMenuClick:()=>t9(!0),hasUnreadNotifications:t7}),(0,s.jsx)(nf,{onUpgradeClick:r4})]}),(0,s.jsx)("div",{className:"h-[52px] flex-shrink-0 md:hidden"}),T&&ed.length>0&&(0,s.jsx)("div",{className:"flex items-center justify-end px-4 py-1 bg-bg-tertiary/80 border-b border-border-subtle flex-shrink-0",children:(0,s.jsx)(s3,{onlineUsers:ed,onUserClick:eu})}),(0,s.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,s.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto ".concat(rS?"hidden md:block md:flex-[2]":""),children:[rT&&(0,s.jsxs)("div",{className:"px-4 py-2 border-b border-border-subtle bg-bg-secondary flex flex-col gap-2 sticky top-0 z-10",children:[(0,s.jsxs)("div",{className:"text-xs text-text-muted",children:["DM with ",(0,s.jsx)("span",{className:"font-semibold text-text-primary",children:rT.name}),". Invite agents:"]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[rd.filter(e=>!e.isHuman).map(e=>{var t;let r=(null!==(t=ty[rT.name])&&void 0!==t?t:[]).includes(e.name);return(0,s.jsxs)("button",{onClick:()=>sg(e.name),className:"px-3 py-1.5 text-xs font-medium rounded-lg transition-colors ".concat(r?"bg-accent-cyan text-bg-deep":"bg-bg-tertiary text-text-secondary hover:bg-bg-tertiary/80"),title:e.name,children:[r?"✓ ":"",e.name]},e.name)}),0===rd.filter(e=>!e.isHuman).length&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"No agents available"})]})]}),j?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center px-4",children:[(0,s.jsx)(nE,{}),(0,s.jsx)("h2",{className:"m-0 mb-2 font-display text-text-primary",children:"Connection Error"}),(0,s.jsx)("p",{className:"text-text-secondary",children:j.message}),(0,s.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"})]}):b?tJ?(0,s.jsx)("div",{className:"p-4 h-full overflow-y-auto",children:(0,s.jsx)(sG,{servers:t$,agents:rd,selectedServerId:t5,onServerSelect:t4,onServerReconnect:sN,isLoading:!b})}):J===nM?(0,s.jsx)(l,{events:$,maxEvents:100}):"channels"===ef&&eR?(0,s.jsx)(nC.F,{channel:eR,messages:rF,currentUser:(null==T?void 0:T.displayName)||"Anonymous",isLoadingMore:!1,hasMoreMessages:eE&&!!G,mentionSuggestions:rd.map(e=>e.name),unreadState:eT,onSendMessage:su,onLoadMore:sm,onThreadClick:e=>rL(e),onShowMembers:so,onMemberClick:r7}):"channels"===ef?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center px-4",children:[(0,s.jsx)(nW,{}),(0,s.jsx)("h2",{className:"m-0 mb-2 font-display text-text-primary",children:"Select a channel"}),(0,s.jsx)("p",{className:"text-text-secondary",children:"Choose a channel from the sidebar to start messaging"})]}):(0,s.jsx)(eX,{messages:rI,currentChannel:rv,currentThread:rS,onThreadClick:e=>rL(e),highlightedMessageId:null!=rS?rS:void 0,agents:rl,currentUser:T,skipChannelFilter:null!==rT,showTimestamps:tl.display.showTimestamps,autoScrollDefault:tl.messages.autoScroll,compactMode:tl.display.compactMode,onAgentClick:eg,onUserClick:eu,onlineUsers:ed}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center",children:[(0,s.jsx)(nA,{}),(0,s.jsx)("p",{className:"font-display text-text-secondary",children:"Connecting to dashboard..."})]})]}),rS&&(()=>{let e="channels"===ef,t=e=>{var t;return{id:e.id,from:e.from,to:e.channelId,content:e.content,timestamp:e.timestamp,thread:e.threadId,isRead:e.isRead,replyCount:null===(t=e.threadSummary)||void 0===t?void 0:t.replyCount,threadSummary:e.threadSummary}},r=null,n=!1;if(e){let e=rF.find(e=>e.id===rS);if(e)r=t(e);else{n=!0;let e=rF.filter(e=>e.threadId===rS).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime());e[0]&&(r=t(e[0]))}}else{var a,o;n=!(r=null!==(a=ry.find(e=>e.id===rS))&&void 0!==a?a:null),r||(r=null!==(o=ry.filter(e=>e.thread===rS).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())[0])&&void 0!==o?o:null)}let l=e?rF.filter(e=>e.threadId===rS).map(t):rj(rS);return(0,s.jsx)("div",{className:"w-full md:w-[400px] md:min-w-[320px] md:max-w-[500px] flex-shrink-0",children:(0,s.jsx)(e5,{originalMessage:r,replies:l,onClose:()=>rL(null),showTimestamps:tl.display.showTimestamps,onReply:async t=>{if(e&&eR)return await su(t,rS),!0;let s="*";return!n&&r&&(s="Dashboard"===r.from||T&&r.from===T.displayName?r.to:r.from),rA(s,t,rS)},isSending:rE,currentUser:T})})})()]}),eo.length>0&&(0,s.jsx)("div",{className:"px-4 bg-bg-tertiary border-t border-border-subtle",children:(0,s.jsx)(s$,{typingUsers:eo})}),"channels"!==ef&&(0,s.jsx)("div",{className:"p-2 sm:p-4 bg-bg-tertiary border-t border-border-subtle",children:(0,s.jsx)(s4,{agents:rd,humanUsers:rO,onSend:sf,onTyping:el,isSending:rE,error:rW,insertMention:em,onMentionInserted:()=>eh(void 0),enableFileAutocomplete:!0,placeholder:"Message ".concat("general"===rv?"everyone":"@"+rv,"...")})})]}),(0,s.jsx)(te,{isOpen:ta,onClose:sW,agents:rd,projects:eU,currentProject:eO,onAgentSelect:rQ,onProjectSelect:rX,onSpawnClick:r0,onTaskCreate:sA,onGeneralClick:()=>{rm(null),rC("general")},customCommands:[...sj,...sv]}),(0,s.jsx)(tb,{isOpen:ez,onClose:()=>eG(!1),onSpawn:sk,existingAgents:rd.map(e=>e.name),isSpawning:eV,error:eK,isCloudMode:H,workspaceId:null!=G?G:void 0}),(0,s.jsx)(rq,{isOpen:eq,onClose:()=>{e$(!1),e1(null)},onAdd:rY,isAdding:eY,error:e0}),(0,s.jsx)(nC.hG,{isOpen:e2,onClose:()=>e4(!1),onCreate:ss,isLoading:e3,existingChannels:ej.map(e=>e.name),availableMembers:rd.map(e=>e.name)}),(0,s.jsx)(nC.PC,{isOpen:e8,channelName:(null==tt?void 0:tt.name)||"",onClose:()=>{e9(!1),tr(null)},onInvite:sa,isLoading:ts,availableMembers:rd.map(e=>e.name)}),eR&&(0,s.jsx)(nC.pw,{channel:eR,members:er,isOpen:Q,onClose:()=>et(!1),onAddMember:si,onRemoveMember:sl,onUpdateRole:()=>{},currentUserId:null==T?void 0:T.displayName,availableAgents:rd.map(e=>({name:e.name})),workspaceId:null!=G?G:void 0}),(0,s.jsx)(rk,{isOpen:th,onClose:()=>tp(!1)}),(0,s.jsx)(tN,{isOpen:tg,onClose:()=>tf(!1),onSend:sw,agents:rd,isSending:rE,error:rW}),tk&&(0,s.jsx)(sd,{agent:tk,isOpen:!0,onClose:()=>tC(null),availableAgents:rd,onAgentChange:tC}),tS&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex bg-black/50 backdrop-blur-sm",onClick:()=>tL(!1),children:(0,s.jsxs)("div",{className:"ml-auto w-full max-w-3xl h-full bg-bg-primary shadow-2xl animate-in slide-in-from-right duration-300 flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-bg-secondary",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-blue-500/20 to-accent-cyan/20 flex items-center justify-center border border-blue-500/30",children:(0,s.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-blue-500",children:(0,s.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-primary m-0",children:"Trajectory Viewer"}),(0,s.jsx)("p",{className:"text-xs text-text-muted m-0",children:(null==tD?void 0:tD.active)?"Active: ".concat(tD.task||"Working..."):"Browse past trajectories"})]})]}),(0,s.jsx)("button",{onClick:()=>tL(!1),className:"w-10 h-10 rounded-lg bg-bg-tertiary border border-border-subtle flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover hover:border-blue-500/50 transition-all",title:"Close (Esc)",children:(0,s.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden p-6",children:(0,s.jsx)(sy,{agentName:(null==tP?void 0:tP.slice(0,30))||(null==tD?void 0:null===(o=tD.task)||void 0===o?void 0:o.slice(0,30))||"Trajectories",steps:tM,history:tA,selectedTrajectoryId:tT,onSelectTrajectory:tW,isLoading:tE})})]})}),tH&&(0,s.jsx)("div",{className:"fixed left-4 bottom-4 w-[400px] max-h-[500px] z-50 shadow-modal",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{onClick:()=>tz(!1),className:"absolute -top-2 -right-2 w-6 h-6 bg-bg-elevated border border-border rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover z-10",title:"Close decisions",children:(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})}),(0,s.jsx)(sT,{decisions:tG,onApprove:sL,onReject:sM,onDismiss:sD,isProcessing:tZ})]})}),!tH&&tG.length>0&&(0,s.jsxs)("button",{onClick:()=>tz(!0),className:"fixed left-4 bottom-4 w-12 h-12 bg-warning text-bg-deep rounded-full shadow-[0_0_20px_rgba(255,107,53,0.4)] flex items-center justify-center hover:scale-105 transition-transform z-50",title:"".concat(tG.length," pending decision").concat(tG.length>1?"s":""),children:[(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),tG.length>0&&(0,s.jsx)("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-error text-white text-[10px] font-bold rounded-full flex items-center justify-center",children:tG.length})]}),(0,s.jsx)(s6,{user:ex,onClose:()=>eu(null),onMention:e=>{eh(e),eu(null)},onSendMessage:e=>{rC(e.username),rc(e.username),eu(null)}}),(0,s.jsx)(ne,{agent:ep,onClose:()=>eg(null),onMessage:e=>{rm(e.name),rC(e.name),eg(null)},onLogs:sS,onRelease:sC,summary:ep?eb.get(ep.name.toLowerCase()):null}),(0,s.jsx)(nr,{isOpen:tF,onClose:()=>tO(!1),projects:rJ,isCloudMode:!!T,hasArchitect:rZ.some(e=>"architect"===e.name.toLowerCase()),onArchitectSpawned:()=>{tO(!1)}}),td&&(0,s.jsx)(ri,{currentUserId:null==W?void 0:null===(i=W.user)||void 0===i?void 0:i.id,initialTab:tu,onClose:()=>tx(!1),settings:tl,onUpdateSettings:tc,activeWorkspaceId:G}),(0,s.jsx)(rP,{toasts:tX,onDismiss:t0,position:"top-right"})]})})}function nA(){return(0,s.jsx)("svg",{className:"animate-spin mb-4 text-accent-cyan",width:"28",height:"28",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function nE(){return(0,s.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,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function nW(){return(0,s.jsxs)("svg",{className:"text-text-muted mb-4",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,s.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,s.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,s.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}},5372:function(e,t,r){r.d(t,{TI:function(){return c},uo:function(){return d}});var s=r(7437),n=r(2265),a=r(9165);let o={checkOnMount:!0,checkInterval:6e4,onExpired:()=>{}};function l(e){let{isOpen:t,error:r,onLogin:n,onDismiss:a}=e;return t?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[9998]",onClick:a,"aria-hidden":"true"}),(0,s.jsx)("div",{className:"fixed inset-0 flex items-center justify-center z-[9999] p-4",role:"dialog","aria-modal":"true","aria-labelledby":"session-expired-title",children:(0,s.jsxs)("div",{className:"bg-bg-primary rounded-lg shadow-xl max-w-md w-full p-6 animate-in fade-in zoom-in-95 duration-200",children:[(0,s.jsx)("div",{className:"flex justify-center mb-4",children:(0,s.jsx)("div",{className:"w-16 h-16 rounded-full bg-warning/10 flex items-center justify-center",children:(0,s.jsx)("svg",{className:"w-8 h-8 text-warning",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})})}),(0,s.jsx)("h2",{id:"session-expired-title",className:"text-xl font-semibold text-text-primary text-center mb-2",children:"Session Expired"}),(0,s.jsx)("p",{className:"text-text-muted text-center mb-6",children:(()=>{if(!r)return"Your session has expired. Please log in again to continue.";switch(r.code){case"SESSION_EXPIRED":return"Your session has expired. Please log in again to continue.";case"USER_NOT_FOUND":return"Your account was not found. Please log in again.";case"SESSION_ERROR":return"There was a problem with your session. Please log in again.";default:return r.message||"Your session has expired. Please log in again."}})()}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("button",{onClick:n,className:"w-full py-3 px-4 bg-accent text-white font-medium rounded-lg hover:bg-accent-hover transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-accent focus:ring-offset-2 focus:ring-offset-bg-primary",children:"Log In Again"}),a&&(0,s.jsx)("button",{onClick:a,className:"w-full py-3 px-4 text-text-muted hover:text-text-primary font-medium rounded-lg transition-colors duration-200 hover:bg-bg-secondary",children:"Dismiss"})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted text-center mt-4",children:"You'll be redirected to the login page where you can sign in with GitHub."})]})})]}):null}let i=(0,n.createContext)(void 0);function c(e){let{children:t,cloudMode:r,checkInterval:c=6e4,onSessionExpired:d}=e,x=null!=r?r:function(){let e=window.location.hostname;if(e.includes("agent-relay.com")||e.includes("agentrelay.cloud"))return!0;let t=document.querySelector('meta[name="agent-relay-cloud"]');return(null==t?void 0:t.getAttribute("content"))==="true"||"true"===localStorage.getItem("agent-relay-cloud-mode")}(),u=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={...o,...e},[r,s]=(0,n.useState)(null),[l,i]=(0,n.useState)(!0),[c,d]=(0,n.useState)(!1),[x,u]=(0,n.useState)(null),m=(0,n.useRef)(null),h=(0,n.useRef)(!0),p=(0,n.useCallback)(async()=>{try{let e=await a.xv.checkSession();if(!h.current)return e;if(!e.authenticated&&(s(null),e.code)){let r={error:"Session expired",code:e.code,message:e.message||"Your session has expired. Please log in again."};u(r),d(!0),t.onExpired(r)}return e}catch(e){return{authenticated:!1,code:"SESSION_ERROR",message:"Failed to check session"}}},[t]),g=(0,n.useCallback)(async()=>{i(!0);try{let e=await a.xv.getMe();if(!h.current)return;e.success?(s(e.data),d(!1),u(null)):e.sessionExpired?(s(null),d(!0)):u({error:e.error,code:"SESSION_ERROR",message:e.error})}finally{h.current&&i(!1)}},[]);(0,n.useEffect)(()=>(0,a.Zk)(e=>{h.current&&(s(null),d(!0),u(e),t.onExpired(e))}),[t]),(0,n.useEffect)(()=>(h.current=!0,t.checkOnMount&&g(),()=>{h.current=!1}),[t.checkOnMount,g]),(0,n.useEffect)(()=>{if(!(t.checkInterval<=0))return m.current=setInterval(()=>{r&&p()},t.checkInterval),()=>{m.current&&(clearInterval(m.current),m.current=null)}},[t.checkInterval,r,p]);let b=(0,n.useCallback)(()=>{d(!1),u(null)},[]),f=(0,n.useCallback)(()=>{let e=encodeURIComponent(window.location.pathname+window.location.search);window.location.href="/login?returnTo=".concat(e)},[]),y=(0,n.useCallback)(async()=>{await a.xv.logout(),s(null),d(!1),u(null),window.location.href="/login"},[]);return{user:r,isLoading:l,isAuthenticated:null!==r,isExpired:c,error:x,csrfToken:(0,a._V)(),checkSession:p,clearExpired:b,redirectToLogin:f,logout:y}}({checkOnMount:x,checkInterval:x?c:0,onExpired:d}),m=(0,n.useCallback)(()=>{u.redirectToLogin()},[u]),h=(0,n.useCallback)(()=>{u.clearExpired()},[u]),p={...u,isCloudMode:x};return(0,s.jsxs)(i.Provider,{value:p,children:[t,x&&(0,s.jsx)(l,{isOpen:u.isExpired,error:u.error,onLogin:m,onDismiss:h})]})}function d(){return(0,n.useContext)(i)}},8145:function(e,t,r){r.d(t,{F:function(){return V},hG:function(){return Z},PC:function(){return K},pw:function(){return et},archiveChannel:function(){return u},mi:function(){return i},Fk:function(){return b},_U:function(){return l},joinChannel:function(){return d},leaveChannel:function(){return x},Gn:function(){return o},Qh:function(){return h},Ah:function(){return g},bG:function(){return c},unarchiveChannel:function(){return m}}),new Date().toISOString(),new Date(Date.now()-3e5).toISOString(),new Date(Date.now()-36e5).toISOString(),new Date(Date.now()-18e5).toISOString(),new Date(Date.now()-72e5).toISOString(),new Date(Date.now()-6e6).toISOString(),Date.now(),new Date(Date.now()-36e5).toISOString(),new Date(Date.now()-18e5).toISOString(),new Date(Date.now()-3e5).toISOString();var s=r(9116);function n(){return localStorage.getItem("relay_username")||"Dashboard"}class a extends Error{constructor(e,t,r){super(e),this.status=t,this.body=r,this.name="ApiError"}}async function o(e){(0,s.$3)();let t=new URLSearchParams;e&&t.set("workspaceId",e);let r=(0,s.kG)("/api/channels?".concat(t.toString()));try{var n,o;let e=await fetch(r,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!e.ok)throw new a("Failed to fetch channels",e.status);let t=await e.json();return{channels:null!==(n=t.channels)&&void 0!==n?n:[],archivedChannels:null!==(o=t.archivedChannels)&&void 0!==o?o:[]}}catch(e){if(e instanceof a)throw e;throw new a("Network error fetching channels",0)}}async function l(e,t,r){var n;(0,s.$3)();let o=new URLSearchParams;if((null==r?void 0:r.limit)&&o.set("limit",String(r.limit)),null==r?void 0:r.before){let e=Date.parse(r.before);Number.isNaN(e)||o.set("before",String(e))}e&&o.set("workspaceId",e);let l="/api/channels/".concat(encodeURIComponent(t),"/messages").concat(o.toString()?"?".concat(o.toString()):""),i=await fetch((0,s.kG)(l),{method:"GET",headers:{"Content-Type":"application/json"}});if(!i.ok)throw new a("Failed to fetch channel messages",i.status);let c=await i.json();return{messages:null!==(n=c.messages)&&void 0!==n?n:[],hasMore:!!c.hasMore,unread:{count:0}}}async function i(e,t){(0,s.$3)();try{let r=(0,s._V)(),n={"Content-Type":"application/json"};r&&(n["X-CSRF-Token"]=r);let o=await fetch((0,s.kG)("/api/channels"),{method:"POST",headers:n,credentials:"include",body:JSON.stringify({name:t.name,description:t.description,isPrivate:"private"===t.visibility,invites:t.members,workspaceId:e})});if(!o.ok){let e=await o.json().catch(()=>({error:"Unknown error"}));throw new a(e.error||"Failed to create channel",o.status)}let l=await o.json();return{channel:{id:l.channel.id,name:l.channel.name,description:l.channel.description,visibility:l.channel.visibility,status:l.channel.status,createdAt:l.channel.createdAt,createdBy:l.channel.createdBy,memberCount:1,unreadCount:0,hasMentions:!1,isDm:!1}}}catch(e){if(e instanceof a)throw e;throw new a("Network error creating channel",0)}}async function c(e,t,r){(0,s.$3)();let o=n();try{let n=await fetch((0,s.kG)("/api/channels/message"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:o,channel:t,body:r.content,thread:r.threadId,workspaceId:e})});if(!n.ok){let e=await n.json().catch(()=>({error:"Unknown error"}));throw new a(e.error||"Failed to send message",n.status)}return{message:{id:"pending-".concat(Date.now()),channelId:t,from:o,fromEntityType:"user",content:r.content,timestamp:new Date().toISOString(),threadId:r.threadId,isRead:!0}}}catch(e){if(e instanceof a)throw e;throw new a("Network error sending message",0)}}async function d(e,t){(0,s.$3)();let r=n();try{let n=await fetch((0,s.kG)("/api/channels/join"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,channel:t,workspaceId:e})});if(!n.ok){let e=await n.json().catch(()=>({error:"Unknown error"}));throw new a(e.error||"Failed to join channel",n.status)}return{id:t,name:t.startsWith("#")?t.slice(1):t,visibility:"public",status:"active",createdAt:new Date().toISOString(),createdBy:r,memberCount:1,unreadCount:0,hasMentions:!1,isDm:t.startsWith("dm:")}}catch(e){if(e instanceof a)throw e;throw new a("Network error joining channel",0)}}async function x(e,t){(0,s.$3)();let r=n();try{let n=await fetch((0,s.kG)("/api/channels/leave"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,channel:t,workspaceId:e})});if(!n.ok){let e=await n.json().catch(()=>({error:"Unknown error"}));throw new a(e.error||"Failed to leave channel",n.status)}}catch(e){if(e instanceof a)throw e;throw new a("Network error leaving channel",0)}}async function u(e,t){(0,s.$3)();let r=await fetch((0,s.kG)("/api/channels/archive"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:t,workspaceId:e})});if(!r.ok)throw new a("Failed to archive channel",r.status);return{id:t,name:t.startsWith("#")?t.slice(1):t,visibility:"public",status:"archived",createdAt:new Date().toISOString(),createdBy:n(),memberCount:0,unreadCount:0,hasMentions:!1,isDm:t.startsWith("dm:")}}async function m(e,t){(0,s.$3)();let r=await fetch((0,s.kG)("/api/channels/unarchive"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:t,workspaceId:e})});if(!r.ok)throw new a("Failed to unarchive channel",r.status);return{id:t,name:t.startsWith("#")?t.slice(1):t,visibility:"public",status:"active",createdAt:new Date().toISOString(),createdBy:n(),memberCount:0,unreadCount:0,hasMentions:!1,isDm:t.startsWith("dm:")}}async function h(e,t,r){}async function p(e){(0,s.$3)();let t=new URLSearchParams;e&&t.set("workspaceId",e);try{var r,n;let e=(0,s.kG)("/api/channels/available-members?".concat(t.toString())),a=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(!a.ok)return console.error("[ChannelsAPI] Failed to fetch available members:",a.status),{members:[],agents:[]};let o=await a.json();return{members:null!==(r=o.members)&&void 0!==r?r:[],agents:null!==(n=o.agents)&&void 0!==n?n:[]}}catch(e){return console.error("[ChannelsAPI] Error fetching available members:",e),{members:[],agents:[]}}}async function g(e,t,r,n){let o=(0,s.kG)("/api/channels/admin-remove"),l=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:t.startsWith("#")?t:"#".concat(t),member:r})});if(!l.ok)throw new a((await l.json().catch(()=>({}))).error||"Failed to remove member",l.status)}async function b(e,t){try{let e=(0,s.kG)("/api/channels/".concat(encodeURIComponent(t),"/members")),r=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)return console.warn("[ChannelsAPI] Failed to get channel members:",r.statusText),[{id:n(),displayName:n(),entityType:"user",role:"owner",status:"online",joinedAt:new Date().toISOString()}];return(await r.json()).members||[]}catch(e){return console.error("[ChannelsAPI] Error getting channel members:",e),[{id:n(),displayName:n(),entityType:"user",role:"owner",status:"online",joinedAt:new Date().toISOString()}]}}var f=r(7437),y=r(2265);function j(e){let{channel:t,members:r=[],canEdit:s=!1,onEditChannel:n,onShowMembers:a,onShowPinned:o,onSearch:l}=e,[i,c]=(0,y.useState)(!1),d=t.isDm,x=d?t.name:"".concat(t.name),u=r.filter(e=>"online"===e.status).length;return(0,f.jsxs)("div",{className:"flex-shrink-0 border-b border-border-subtle bg-bg-primary",children:[(0,f.jsxs)("div",{className:"flex items-center justify-between px-4 py-3",children:[(0,f.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,f.jsx)("div",{className:"\n flex-shrink-0 w-8 h-8 rounded-lg flex items-center justify-center\n ".concat(d?"bg-purple-500/10":"bg-accent-cyan/10","\n "),children:d?(0,f.jsx)(N,{className:"w-4 h-4 text-purple-400"}):(0,f.jsx)(w,{className:"w-4 h-4 text-accent-cyan"})}),(0,f.jsxs)("div",{className:"min-w-0",children:[(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[(0,f.jsx)("h1",{className:"text-base font-semibold text-text-primary truncate",children:x}),"archived"===t.status&&(0,f.jsx)("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-warning/20 text-warning rounded",children:"Archived"}),"private"===t.visibility&&!d&&(0,f.jsx)(k,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"})]}),t.topic&&(0,f.jsx)("p",{className:"text-xs text-text-muted truncate mt-0.5",children:t.topic})]})]}),(0,f.jsxs)("div",{className:"flex items-center gap-1",children:[(0,f.jsxs)("button",{onClick:a,className:"flex items-center gap-1.5 px-2 py-1.5 rounded-md text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",title:"View members",children:[(0,f.jsx)(C,{className:"w-4 h-4"}),(0,f.jsxs)("span",{className:"text-xs",children:[t.memberCount,u>0&&(0,f.jsxs)("span",{className:"text-success ml-1",children:["(",u," online)"]})]})]}),(0,f.jsx)("div",{className:"w-px h-5 bg-border-subtle mx-1"}),l&&(0,f.jsx)("button",{onClick:l,className:"p-2 rounded-md text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",title:"Search in channel",children:(0,f.jsx)(S,{className:"w-4 h-4"})}),o&&(0,f.jsx)("button",{onClick:o,className:"p-2 rounded-md text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",title:"Pinned messages",children:(0,f.jsx)(L,{className:"w-4 h-4"})}),(0,f.jsx)("button",{onClick:()=>c(!i),className:"p-2 rounded-md transition-colors ".concat(i?"text-accent-cyan bg-accent-cyan/10":"text-text-muted hover:text-text-primary hover:bg-bg-hover"),title:"Channel details",children:(0,f.jsx)(M,{className:"w-4 h-4"})}),s&&n&&(0,f.jsx)("button",{onClick:n,className:"p-2 rounded-md text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",title:"Channel settings",children:(0,f.jsx)(D,{className:"w-4 h-4"})})]})]}),i&&(0,f.jsx)("div",{className:"px-4 pb-3 border-t border-border-subtle pt-3 bg-bg-secondary/50",children:(0,f.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.description&&(0,f.jsxs)("div",{children:[(0,f.jsx)("h3",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-1",children:"Description"}),(0,f.jsx)("p",{className:"text-sm text-text-secondary",children:t.description})]}),(0,f.jsxs)("div",{children:[(0,f.jsx)("h3",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-1",children:"Created"}),(0,f.jsxs)("p",{className:"text-sm text-text-secondary",children:[new Date(t.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})," by ",t.createdBy]})]}),r.length>0&&(0,f.jsxs)("div",{className:"sm:col-span-2",children:[(0,f.jsxs)("h3",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-2",children:["Members (",t.memberCount,")"]}),(0,f.jsxs)("div",{className:"flex flex-wrap gap-2",children:[r.slice(0,10).map(e=>(0,f.jsx)(v,{member:e},e.id)),t.memberCount>10&&(0,f.jsxs)("button",{onClick:a,className:"text-xs text-accent-cyan hover:underline",children:["+",t.memberCount-10," more"]})]})]})]})})]})}function v(e){let{member:t}=e;return(0,f.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-bg-tertiary rounded-full text-sm",children:[t.avatarUrl?(0,f.jsx)("img",{src:t.avatarUrl,alt:t.displayName||t.id,className:"w-4 h-4 rounded-full object-cover"}):(0,f.jsx)("div",{className:"\n w-4 h-4 rounded-full flex items-center justify-center text-[9px] font-medium\n ".concat("user"===t.entityType?"bg-purple-500/30 text-purple-300":"bg-accent-cyan/30 text-accent-cyan","\n "),children:(t.displayName||t.id).charAt(0).toUpperCase()}),(0,f.jsx)("span",{className:"text-text-secondary truncate max-w-[100px]",children:t.displayName||t.id}),(0,f.jsx)("span",{className:"w-1.5 h-1.5 rounded-full ".concat("online"===t.status?"bg-success":"away"===t.status?"bg-warning":"bg-text-dim")})]})}function w(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,f.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,f.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,f.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function N(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,f.jsx)("path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"})]})}function k(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,f.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function C(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,f.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,f.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,f.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function S(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,f.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function L(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),(0,f.jsx)("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"})]})}function M(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,f.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,f.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function D(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,f.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"})]})}var A=r(6270);function E(e){let{messages:t,unreadState:r,currentUser:s,isLoadingMore:n=!1,hasMore:a=!1,onLoadMore:o,onThreadClick:l,onMemberClick:i}=e,c=(0,y.useRef)(null),d=(0,y.useRef)(null),[x,u]=(0,y.useState)(!0),[m,h]=(0,y.useState)(!1),p=(0,y.useMemo)(()=>{let e=[],r="";return t.forEach(t=>{let s=new Date(t.timestamp).toDateString();s!==r?(r=s,e.push({date:s,messages:[t]})):e[e.length-1].messages.push(t)}),e},[t]),g=(0,y.useCallback)(()=>{let e=c.current;if(!e)return;let{scrollTop:t,scrollHeight:r,clientHeight:s}=e,l=r-t-s,i=l<100;u(i),h(!i&&l>500),t<100&&a&&!n&&o&&o()},[a,n,o]);(0,y.useEffect)(()=>{x&&d.current&&d.current.scrollIntoView({behavior:"smooth"})},[t.length,x]),(0,y.useEffect)(()=>{d.current&&d.current.scrollIntoView()},[]);let b=(0,y.useCallback)(()=>{var e;null===(e=d.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[]);return(0,f.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[(0,f.jsxs)("div",{ref:c,onScroll:g,className:"h-full overflow-y-auto px-4 py-2",children:[n&&(0,f.jsx)("div",{className:"flex justify-center py-4",children:(0,f.jsx)(I,{})}),a&&!n&&(0,f.jsx)("div",{className:"flex justify-center py-4",children:(0,f.jsx)("button",{onClick:o,className:"text-sm text-accent-cyan hover:underline",children:"Load earlier messages"})}),0===t.length&&!n&&(0,f.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center py-12",children:[(0,f.jsx)("div",{className:"text-4xl mb-3",children:(0,f.jsx)(R,{className:"w-12 h-12 text-text-muted"})}),(0,f.jsx)("h3",{className:"text-lg font-medium text-text-primary mb-1",children:"No messages yet"}),(0,f.jsx)("p",{className:"text-sm text-text-muted",children:"Be the first to send a message in this channel"})]}),p.map(e=>{let{date:t,messages:n}=e;return(0,f.jsxs)("div",{children:[(0,f.jsx)(B,{date:t}),n.map((e,t)=>{let a=(null==r?void 0:r.firstUnreadMessageId)===e.id&&r&&r.count>0;return(0,f.jsxs)(y.Fragment,{children:[a&&(0,f.jsx)(_,{count:r.count}),(0,f.jsx)(W,{message:e,isOwn:e.from===s,onThreadClick:l,onMemberClick:i,showAvatar:function(e,t){if(0===t)return!0;let r=e[t],s=e[t-1];return r.from!==s.from||new Date(r.timestamp).getTime()-new Date(s.timestamp).getTime()>3e5}(n,t)})]},e.id)})]},t)}),(0,f.jsx)("div",{ref:d})]}),m&&(0,f.jsx)("button",{onClick:b,className:"absolute bottom-4 right-4 p-3 bg-bg-elevated border border-border-subtle rounded-full shadow-lg hover:bg-bg-hover transition-colors",title:"Scroll to bottom",children:(0,f.jsx)(F,{className:"w-5 h-5 text-text-primary"})})]})}function W(e){let{message:t,isOwn:r,onThreadClick:s,onMemberClick:n,showAvatar:a}=e,o=t.threadSummary&&t.threadSummary.replyCount>0;return(0,f.jsx)("div",{className:"group relative py-1 ".concat(a?"mt-3":""),children:(0,f.jsxs)("div",{className:"flex gap-3",children:[(0,f.jsx)("div",{className:"w-9 flex-shrink-0",children:a&&(0,f.jsx)(T,{name:t.from,avatarUrl:t.fromAvatarUrl,entityType:t.fromEntityType})}),(0,f.jsxs)("div",{className:"flex-1 min-w-0",children:[a&&(0,f.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,f.jsx)("button",{type:"button",onClick:()=>{!r&&n&&n(t.from,t.fromEntityType||"agent")},disabled:r||!n,className:"text-sm font-semibold ".concat(r?"text-accent-cyan cursor-default":"text-text-primary hover:underline cursor-pointer"," disabled:cursor-default disabled:hover:no-underline"),children:t.from}),(0,f.jsx)("span",{className:"text-xs text-text-muted",children:new Date(t.timestamp).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}),t.editedAt&&(0,f.jsx)("span",{className:"text-xs text-text-muted",children:"(edited)"}),(0,f.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(o||t.threadId?"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==s?void 0:s(t.threadId||t.id),title:t.threadId?"View thread":o?"".concat(t.threadSummary.replyCount," ").concat(1===t.threadSummary.replyCount?"reply":"replies"):"Reply in thread",children:[(0,f.jsx)(U,{className:"w-3.5 h-3.5"}),o&&(0,f.jsx)("span",{className:"text-xs font-medium",children:t.threadSummary.replyCount})]})]}),(0,f.jsx)("div",{className:"text-sm text-text-primary whitespace-pre-wrap break-words",children:(0,A.y)(t.content,{mentions:t.mentions})}),t.attachments&&t.attachments.length>0&&(0,f.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:t.attachments.map(e=>(0,f.jsx)(P,{attachment:e},e.id))})]})]})})}function T(e){let{name:t,avatarUrl:r,entityType:s}=e;return r?(0,f.jsx)("img",{src:r,alt:t,className:"w-9 h-9 rounded-full object-cover"}):(0,f.jsx)("div",{className:"\n w-9 h-9 rounded-full flex items-center justify-center text-sm font-medium\n ".concat("user"===s?"bg-purple-500/30 text-purple-300":"bg-accent-cyan/30 text-accent-cyan","\n "),children:t.charAt(0).toUpperCase()})}function P(e){var t;let{attachment:r}=e;return r.mimeType.startsWith("image/")?(0,f.jsx)("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"block max-w-xs rounded-lg overflow-hidden border border-border-subtle hover:border-accent-cyan/30 transition-colors",children:(0,f.jsx)("img",{src:r.thumbnailUrl||r.url,alt:r.filename,className:"max-w-full max-h-48 object-cover"})}):(0,f.jsxs)("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-2 bg-bg-tertiary rounded-lg border border-border-subtle hover:border-accent-cyan/30 transition-colors",children:[(0,f.jsx)(O,{className:"w-5 h-5 text-text-muted"}),(0,f.jsxs)("div",{className:"min-w-0",children:[(0,f.jsx)("p",{className:"text-sm text-text-primary truncate",children:r.filename}),(0,f.jsx)("p",{className:"text-xs text-text-muted",children:(t=r.size)<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB")})]})]})}function B(e){let{date:t}=e;return(0,f.jsxs)("div",{className:"flex items-center gap-3 py-3",children:[(0,f.jsx)("div",{className:"flex-1 h-px bg-border-subtle"}),(0,f.jsx)("span",{className:"text-xs font-medium text-text-muted px-2",children:function(e){let t=new Date(e),r=new Date,s=new Date(r);return(s.setDate(s.getDate()-1),t.toDateString()===r.toDateString())?"Today":t.toDateString()===s.toDateString()?"Yesterday":t.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}(t)}),(0,f.jsx)("div",{className:"flex-1 h-px bg-border-subtle"})]})}function _(e){let{count:t}=e;return(0,f.jsxs)("div",{className:"flex items-center gap-3 py-2 my-2",children:[(0,f.jsx)("div",{className:"flex-1 h-px bg-red-500/50"}),(0,f.jsxs)("span",{className:"text-xs font-semibold text-red-400 px-2 flex items-center gap-1",children:[(0,f.jsx)("span",{className:"w-2 h-2 bg-red-500 rounded-full"}),t," new ",1===t?"message":"messages"]}),(0,f.jsx)("div",{className:"flex-1 h-px bg-red-500/50"})]})}function I(){return(0,f.jsx)("div",{className:"w-5 h-5 border-2 border-accent-cyan/30 border-t-accent-cyan rounded-full animate-spin"})}function R(e){let{className:t}=e;return(0,f.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,f.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 U(e){let{className:t}=e;return(0,f.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,f.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 F(e){let{className:t}=e;return(0,f.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,f.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function O(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,f.jsx)("polyline",{points:"14 2 14 8 20 8"})]})}function H(e){let{channelId:t,placeholder:r="Send a message...",disabled:s=!1,onSend:n,onTyping:a,mentionSuggestions:o=[]}=e,[l,i]=(0,y.useState)(""),[c,d]=(0,y.useState)(!1),[x,u]=(0,y.useState)(""),[m,h]=(0,y.useState)(0),[p,g]=(0,y.useState)(0),b=(0,y.useRef)(null),j=(0,y.useRef)(null),v=(0,y.useRef)(!1),w=(0,y.useMemo)(()=>{if(!x)return o.slice(0,5);let e=x.toLowerCase();return o.filter(t=>t.toLowerCase().includes(e)).slice(0,5)},[o,x]),N=(0,y.useCallback)(e=>{a&&(e&&!v.current&&(v.current=!0,a(!0)),j.current&&clearTimeout(j.current),e?j.current=setTimeout(()=>{v.current=!1,a(!1)},1e3):(v.current=!1,a(!1)))},[a]);(0,y.useEffect)(()=>()=>{j.current&&clearTimeout(j.current),v.current&&a&&a(!1)},[a]);let k=(0,y.useCallback)(e=>{let t=e.target.value,r=e.target.selectionStart;i(t),g(r),N(t.length>0);let s=t.slice(0,r).match(/@(\w*)$/);s?(u(s[1]),d(!0),h(0)):(d(!1),u(""));let n=b.current;n&&(n.style.height="auto",n.style.height="".concat(Math.min(n.scrollHeight,200),"px"))},[N]),C=(0,y.useCallback)(e=>{let t=l.slice(0,p),r=l.slice(p),s=t.match(/@(\w*)$/);if(!s)return;let n=t.slice(0,-s[0].length);i("".concat(n,"@").concat(e," ").concat(r)),d(!1),u(""),setTimeout(()=>{if(b.current){b.current.focus();let t=n.length+e.length+2;b.current.setSelectionRange(t,t),g(t)}},0)},[l,p]),S=(0,y.useCallback)(e=>{if(c&&w.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),h(e=>e<w.length-1?e+1:0);return;case"ArrowUp":e.preventDefault(),h(e=>e>0?e-1:w.length-1);return;case"Tab":case"Enter":e.preventDefault(),C(w[m]);return;case"Escape":e.preventDefault(),d(!1);return}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),L())},[c,w,m,C]),L=(0,y.useCallback)(()=>{let e=l.trim();e&&!s&&(n(e),i(""),N(!1),b.current&&(b.current.style.height="auto"))},[l,s,n,N]);return(0,f.jsxs)("div",{className:"relative flex-shrink-0 border-t border-border-subtle bg-bg-primary",children:[c&&w.length>0&&(0,f.jsx)("div",{className:"absolute bottom-full left-4 mb-1 bg-bg-elevated border border-border-subtle rounded-lg shadow-lg py-1 min-w-[200px] max-h-[200px] overflow-y-auto",children:w.map((e,t)=>(0,f.jsxs)("button",{onClick:()=>C(e),className:"\n w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left transition-colors\n ".concat(t===m?"bg-accent-cyan/10 text-text-primary":"text-text-secondary hover:bg-bg-hover","\n "),children:[(0,f.jsx)("div",{className:"w-6 h-6 rounded-full bg-accent-cyan/20 flex items-center justify-center text-xs font-medium text-accent-cyan",children:e.charAt(0).toUpperCase()}),(0,f.jsx)("span",{children:e})]},e))}),(0,f.jsxs)("div",{className:"p-4",children:[(0,f.jsxs)("div",{className:"flex items-end gap-3",children:[(0,f.jsx)("button",{type:"button",disabled:s,className:"p-2 rounded-lg text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex-shrink-0",title:"Attach file",children:(0,f.jsx)(z,{className:"w-5 h-5"})}),(0,f.jsx)("div",{className:"flex-1 relative",children:(0,f.jsx)("textarea",{ref:b,value:l,onChange:k,onKeyDown:S,placeholder:r,disabled:s,rows:1,className:"w-full px-4 py-2.5 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm resize-none focus:outline-none focus:border-accent-cyan/50 disabled:opacity-50 disabled:cursor-not-allowed placeholder:text-text-muted",style:{maxHeight:"200px"}})}),(0,f.jsx)("button",{type:"button",onClick:L,disabled:!l.trim()||s,className:"\n p-2.5 rounded-lg transition-colors flex-shrink-0\n ".concat(l.trim()&&!s?"bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90":"bg-bg-tertiary text-text-muted cursor-not-allowed","\n "),title:"Send message",children:(0,f.jsx)(G,{className:"w-5 h-5"})})]}),(0,f.jsxs)("p",{className:"mt-2 text-xs text-text-muted",children:[(0,f.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"Enter"})," to send,"," ",(0,f.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"Shift+Enter"})," for new line,"," ",(0,f.jsx)("kbd",{className:"px-1 py-0.5 bg-bg-tertiary rounded text-[10px]",children:"@"})," to mention"]})]})]})}function z(e){let{className:t}=e;return(0,f.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,f.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}function G(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,f.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function V(e){let{channel:t,members:r=[],messages:s,unreadState:n,currentUser:a,canEditChannel:o=!1,isLoadingMore:l=!1,hasMoreMessages:i=!1,mentionSuggestions:c=[],onLoadMore:d,onSendMessage:x,onEditChannel:u,onShowMembers:m,onShowPinned:h,onSearch:p,onThreadClick:g,onTyping:b,onMarkRead:v,onMemberClick:w}=e,N=(0,y.useCallback)(e=>{x(e)},[x]),k=(0,y.useMemo)(()=>t.isDm?"Message ".concat(t.name):"Message #".concat(t.name),[t]),C="archived"===t.status;return(0,f.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary",children:[(0,f.jsx)(j,{channel:t,members:r,canEdit:o,onEditChannel:u,onShowMembers:m,onShowPinned:h,onSearch:p}),(0,f.jsx)(E,{messages:s,unreadState:n,currentUser:a,isLoadingMore:l,hasMore:i,onLoadMore:d,onThreadClick:g,onMemberClick:w}),C?(0,f.jsx)("div",{className:"px-4 py-3 bg-bg-secondary border-t border-border-subtle text-center",children:(0,f.jsx)("p",{className:"text-sm text-text-muted",children:"This channel is archived. Unarchive it to send messages."})}):(0,f.jsx)(H,{channelId:t.id,placeholder:k,onSend:N,onTyping:b,mentionSuggestions:c})]})}function Z(e){let{isOpen:t,onClose:r,onCreate:s,isLoading:n=!1,existingChannels:a=[],availableMembers:o=[],workspaceId:l}=e,[i,c]=(0,y.useState)(""),[d,x]=(0,y.useState)(""),[u,m]=(0,y.useState)("public"),[h,g]=(0,y.useState)(""),[b,j]=(0,y.useState)([]),[v,w]=(0,y.useState)([]),[N,k]=(0,y.useState)([]),[C,S]=(0,y.useState)(!1);(0,y.useEffect)(()=>{t&&(S(!0),p(l).then(e=>{let{members:t,agents:r}=e;w(t),k(r)}).catch(e=>{console.error("[CreateChannelModal] Failed to fetch available members:",e)}).finally(()=>{S(!1)}))},[t,l]);let L=[...v,...N,...o.filter(e=>!N.some(t=>t.id===e)&&!v.some(t=>t.id===e)).map(e=>({id:e,displayName:e,type:"agent"}))],M=(0,y.useCallback)(()=>{c(""),x(""),m("public"),g(""),j([]),r()},[r]),D=(0,y.useCallback)(e=>{b.some(t=>t.id===e.id)||(j(t=>[...t,{id:e.id,type:e.type}]),g(""))},[b]),A=(0,y.useCallback)(e=>{j(t=>t.filter(t=>t.id!==e))},[]),E=(0,y.useCallback)(e=>{e.preventDefault(),i.trim()&&s({name:i.trim().toLowerCase().replace(/\s+/g,"-"),description:d.trim()||void 0,visibility:u,members:b.length>0?b:void 0})},[i,d,u,b,s]),W=L.filter(e=>{var t;return((null===(t=e.displayName)||void 0===t?void 0:t.toLowerCase().includes(h.toLowerCase()))||e.id.toLowerCase().includes(h.toLowerCase()))&&!b.some(t=>t.id===e.id)}).slice(0,8);if(!t)return null;let T=i.trim().toLowerCase().replace(/\s+/g,"-"),P=a.includes("#".concat(T)),B=T.length>=2&&T.length<=80&&/^[a-z0-9-]+$/.test(T),_=i.trim()&&B&&!P;return(0,f.jsx)(J,{onClose:M,children:(0,f.jsxs)("form",{onSubmit:E,className:"p-6 w-[400px] max-w-full",children:[(0,f.jsx)("h2",{className:"text-lg font-semibold text-text-primary mb-6",children:"Create a channel"}),(0,f.jsxs)("div",{className:"mb-4",children:[(0,f.jsx)("label",{className:"block text-sm font-medium text-text-primary mb-1.5",children:"Channel name"}),(0,f.jsxs)("div",{className:"relative",children:[(0,f.jsx)("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted",children:"#"}),(0,f.jsx)("input",{type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"e.g., engineering",className:"w-full pl-7 pr-3 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50",autoFocus:!0})]}),i&&!B&&(0,f.jsx)("p",{className:"mt-1 text-xs text-red-400",children:"Channel names must be 2-80 characters, lowercase letters, numbers, and hyphens only"}),P&&(0,f.jsx)("p",{className:"mt-1 text-xs text-red-400",children:"A channel with this name already exists"})]}),(0,f.jsxs)("div",{className:"mb-4",children:[(0,f.jsxs)("label",{className:"block text-sm font-medium text-text-primary mb-1.5",children:["Description ",(0,f.jsx)("span",{className:"text-text-muted font-normal",children:"(optional)"})]}),(0,f.jsx)("textarea",{value:d,onChange:e=>x(e.target.value),placeholder:"What's this channel about?",rows:2,className:"w-full px-3 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50 resize-none"})]}),(0,f.jsxs)("div",{className:"mb-4",children:[(0,f.jsxs)("label",{className:"block text-sm font-medium text-text-primary mb-1.5",children:["Invite members ",(0,f.jsx)("span",{className:"text-text-muted font-normal",children:"(optional)"}),C&&(0,f.jsx)("span",{className:"ml-2 text-text-muted text-xs",children:"Loading..."})]}),(0,f.jsxs)("div",{className:"relative",children:[(0,f.jsx)("input",{type:"text",value:h,onChange:e=>g(e.target.value),placeholder:L.length>0?"Type agent or user name...":"No members available",className:"w-full px-3 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50"}),h&&W.length>0&&(0,f.jsx)("div",{className:"absolute z-10 w-full mt-1 bg-bg-secondary border border-border-subtle rounded-lg shadow-lg max-h-48 overflow-y-auto",children:W.map(e=>(0,f.jsxs)("button",{type:"button",onClick:()=>D(e),className:"w-full px-3 py-2 text-left text-sm text-text-primary hover:bg-bg-hover transition-colors flex items-center justify-between",children:[(0,f.jsx)("span",{children:e.displayName||e.id}),(0,f.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded ".concat("agent"===e.type?"bg-purple-500/20 text-purple-400":"bg-accent-cyan/20 text-accent-cyan"),children:"agent"===e.type?"Agent":"User"})]},e.id))}),!h&&L.length>0&&(0,f.jsxs)("div",{className:"mt-2 text-xs text-text-muted",children:[v.length>0&&(0,f.jsxs)("span",{children:[v.length," user",1!==v.length?"s":""]}),v.length>0&&N.length>0&&(0,f.jsx)("span",{children:", "}),N.length>0&&(0,f.jsxs)("span",{children:[N.length," agent",1!==N.length?"s":""]}),(0,f.jsx)("span",{children:" available"})]})]}),b.length>0&&(0,f.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:b.map(e=>(0,f.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full ".concat("agent"===e.type?"bg-purple-500/10 text-purple-400":"bg-accent-cyan/10 text-accent-cyan"),children:[e.id,(0,f.jsxs)("span",{className:"text-[10px] opacity-70",children:["(","agent"===e.type?"Agent":"User",")"]}),(0,f.jsx)("button",{type:"button",onClick:()=>A(e.id),className:"hover:text-red-400 transition-colors",children:(0,f.jsx)(ee,{className:"w-3 h-3"})})]},e.id))})]}),(0,f.jsxs)("div",{className:"mb-6",children:[(0,f.jsx)("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Visibility"}),(0,f.jsxs)("div",{className:"space-y-2",children:[(0,f.jsxs)("label",{className:"\n flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors\n ".concat("public"===u?"border-accent-cyan/30 bg-accent-cyan/5":"border-border-subtle hover:bg-bg-hover","\n "),children:[(0,f.jsx)("input",{type:"radio",name:"visibility",value:"public",checked:"public"===u,onChange:()=>m("public"),className:"mt-1"}),(0,f.jsxs)("div",{children:[(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[(0,f.jsx)($,{className:"w-4 h-4 text-text-primary"}),(0,f.jsx)("span",{className:"text-sm font-medium text-text-primary",children:"Public"})]}),(0,f.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Anyone can join and view messages"})]})]}),(0,f.jsxs)("label",{className:"\n flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors\n ".concat("private"===u?"border-accent-cyan/30 bg-accent-cyan/5":"border-border-subtle hover:bg-bg-hover","\n "),children:[(0,f.jsx)("input",{type:"radio",name:"visibility",value:"private",checked:"private"===u,onChange:()=>m("private"),className:"mt-1"}),(0,f.jsxs)("div",{children:[(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[(0,f.jsx)(Y,{className:"w-4 h-4 text-text-primary"}),(0,f.jsx)("span",{className:"text-sm font-medium text-text-primary",children:"Private"})]}),(0,f.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:"Only invited members can join"})]})]})]})]}),(0,f.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,f.jsx)("button",{type:"button",onClick:M,disabled:n,className:"px-4 py-2 text-sm font-medium text-text-secondary bg-bg-tertiary hover:bg-bg-hover rounded-lg transition-colors disabled:opacity-50",children:"Cancel"}),(0,f.jsxs)("button",{type:"submit",disabled:!_||n,className:"px-4 py-2 text-sm font-medium bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[n&&(0,f.jsx)(q,{className:"w-4 h-4"}),"Create Channel"]})]})]})})}function K(e){let{isOpen:t,channelName:r,onClose:s,onInvite:n,isLoading:a=!1,availableMembers:o=[]}=e,[l,i]=(0,y.useState)(""),[c,d]=(0,y.useState)([]),x=(0,y.useCallback)(()=>{i(""),d([]),s()},[s]),u=(0,y.useCallback)(e=>{let t=e.trim();t&&!c.includes(t)&&(d(e=>[...e,t]),i(""))},[c]),m=(0,y.useCallback)(e=>{d(t=>t.filter(t=>t!==e))},[]),h=(0,y.useCallback)(e=>{e.preventDefault(),0!==c.length&&n(c)},[c,n]),p=o.filter(e=>e.toLowerCase().includes(l.toLowerCase())&&!c.includes(e)).slice(0,5);return t?(0,f.jsx)(J,{onClose:x,children:(0,f.jsxs)("form",{onSubmit:h,className:"p-6 w-[400px] max-w-full",children:[(0,f.jsxs)("h2",{className:"text-lg font-semibold text-text-primary mb-2",children:["Invite to #",r]}),(0,f.jsx)("p",{className:"text-sm text-text-muted mb-6",children:"Add agents or users to this channel"}),(0,f.jsxs)("div",{className:"mb-4",children:[(0,f.jsx)("label",{className:"block text-sm font-medium text-text-primary mb-1.5",children:"Members to invite"}),(0,f.jsxs)("div",{className:"relative",children:[(0,f.jsx)("input",{type:"text",value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&l.trim()&&(e.preventDefault(),u(l))},placeholder:"Type agent or user name...",className:"w-full px-3 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50",autoFocus:!0}),l&&p.length>0&&(0,f.jsx)("div",{className:"absolute z-10 w-full mt-1 bg-bg-secondary border border-border-subtle rounded-lg shadow-lg max-h-40 overflow-y-auto",children:p.map(e=>(0,f.jsx)("button",{type:"button",onClick:()=>u(e),className:"w-full px-3 py-2 text-left text-sm text-text-primary hover:bg-bg-hover transition-colors",children:e},e))})]}),c.length>0&&(0,f.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:c.map(e=>(0,f.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-accent-cyan/10 text-accent-cyan text-xs rounded-full",children:[e,(0,f.jsx)("button",{type:"button",onClick:()=>m(e),className:"hover:text-red-400 transition-colors",children:(0,f.jsx)(ee,{className:"w-3 h-3"})})]},e))})]}),(0,f.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,f.jsx)("button",{type:"button",onClick:x,disabled:a,className:"px-4 py-2 text-sm font-medium text-text-secondary bg-bg-tertiary hover:bg-bg-hover rounded-lg transition-colors disabled:opacity-50",children:"Cancel"}),(0,f.jsxs)("button",{type:"submit",disabled:0===c.length||a,className:"px-4 py-2 text-sm font-medium bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[a&&(0,f.jsx)(q,{className:"w-4 h-4"}),"Invite ",c.length>0?"(".concat(c.length,")"):""]})]})]})}):null}function J(e){let{children:t,onClose:r}=e;return(0,f.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:r,children:[(0,f.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),(0,f.jsx)("div",{className:"relative bg-bg-elevated border border-border-subtle rounded-xl shadow-2xl animate-in fade-in zoom-in-95 duration-150",onClick:e=>e.stopPropagation(),children:t})]})}function q(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:"animate-spin ".concat(t),viewBox:"0 0 24 24",fill:"none",children:[(0,f.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,f.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function $(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,f.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,f.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,f.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function Y(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,f.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function X(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,f.jsx)("circle",{cx:"8.5",cy:"7",r:"4"}),(0,f.jsx)("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),(0,f.jsx)("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]})}function Q(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,f.jsx)("circle",{cx:"8.5",cy:"7",r:"4"}),(0,f.jsx)("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]})}function ee(e){let{className:t}=e;return(0,f.jsxs)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,f.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,f.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function et(e){let{channel:t,members:r,isOpen:s,onClose:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,currentUserId:i,isLoading:c=!1,availableUsers:d=[],availableAgents:x=[],workspaceId:u}=e,[m,h]=(0,y.useState)(!1),[g,b]=(0,y.useState)("user"),[j,v]=(0,y.useState)(""),[w,N]=(0,y.useState)("member"),[k,C]=(0,y.useState)([]),[S,L]=(0,y.useState)([]),[M,D]=(0,y.useState)(!1);(0,y.useEffect)(()=>{s&&(D(!0),p(u).then(e=>{let{members:t,agents:r}=e;C(t),L(r)}).catch(e=>{console.error("[MemberManagementPanel] Failed to fetch available members:",e)}).finally(()=>{D(!1)}))},[s,u]);let A=k.length>0?k.map(e=>({id:e.id,name:e.displayName||e.id})):d,E=S.length>0?S.map(e=>({name:e.displayName||e.id})):x;if(!s)return null;let W=r.filter(e=>"user"===e.entityType),T=r.filter(e=>"agent"===e.entityType),P=r.find(e=>e.id===i),B=(null==P?void 0:P.role)==="owner"||(null==P?void 0:P.role)==="admin",_=r.filter(e=>"owner"===e.role||"admin"===e.role).length,I=new Set(r.map(e=>e.id)),R=A.filter(e=>!I.has(e.id)),U=E.filter(e=>!r.some(t=>t.displayName===e.name&&"agent"===t.entityType)),F=e=>"owner"!==e.role&&("admin"!==e.role||!(_<=1))&&e.id!==i&&B,O=e=>"owner"!==e.role&&("admin"!==e.role||!(_<=1))&&B;return(0,f.jsx)(J,{onClose:n,children:(0,f.jsxs)("div",{className:"p-6 w-[500px] max-w-full max-h-[80vh] overflow-hidden flex flex-col",children:[(0,f.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,f.jsxs)("div",{className:"flex items-center gap-3",children:[(0,f.jsx)("div",{className:"w-10 h-10 rounded-full bg-accent-cyan/10 flex items-center justify-center",children:(0,f.jsx)(X,{className:"w-5 h-5 text-accent-cyan"})}),(0,f.jsxs)("div",{children:[(0,f.jsx)("h2",{className:"text-lg font-semibold text-text-primary",children:"Members"}),(0,f.jsxs)("p",{className:"text-sm text-text-muted",children:["#",t.name," \xb7 ",r.length," ",1===r.length?"member":"members"]})]})]}),B&&(0,f.jsx)("button",{onClick:()=>h(!m),className:"px-3 py-1.5 text-sm font-medium bg-accent-cyan/20 text-accent-cyan hover:bg-accent-cyan/30 rounded-lg transition-colors",children:m?"Cancel":"Add Member"})]}),m&&B&&(0,f.jsxs)("div",{className:"mb-4 p-4 bg-bg-tertiary rounded-lg border border-border-subtle",children:[(0,f.jsxs)("div",{className:"flex gap-2 mb-3",children:[(0,f.jsx)("button",{onClick:()=>b("user"),className:"px-3 py-1.5 text-sm rounded-lg transition-colors ".concat("user"===g?"bg-accent-cyan text-bg-deep":"bg-bg-hover text-text-secondary hover:text-text-primary"),children:"User"}),(0,f.jsx)("button",{onClick:()=>b("agent"),className:"px-3 py-1.5 text-sm rounded-lg transition-colors ".concat("agent"===g?"bg-accent-cyan text-bg-deep":"bg-bg-hover text-text-secondary hover:text-text-primary"),children:"Agent"})]}),(0,f.jsxs)("div",{className:"flex gap-2 mb-3",children:[(0,f.jsxs)("select",{value:j,onChange:e=>v(e.target.value),className:"flex-1 px-3 py-2 bg-bg-deep border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50",disabled:M,children:[(0,f.jsx)("option",{value:"",children:M?"Loading...":"Select ".concat(g,"...")}),"user"===g?R.map(e=>(0,f.jsx)("option",{value:e.id,children:e.name},e.id)):U.map(e=>(0,f.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,f.jsxs)("select",{value:w,onChange:e=>N(e.target.value),className:"px-3 py-2 bg-bg-deep border border-border-subtle rounded-lg text-text-primary text-sm focus:outline-none focus:border-accent-cyan/50",children:[(0,f.jsx)("option",{value:"member",children:"Member"}),(0,f.jsx)("option",{value:"admin",children:"Admin"}),(0,f.jsx)("option",{value:"read_only",children:"Read Only"})]})]}),(0,f.jsxs)("button",{onClick:()=>{j&&(a(j,g,w),v(""),h(!1))},disabled:!j||c,className:"w-full px-3 py-2 text-sm font-medium bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:["Add ","user"===g?"User":"Agent"]})]}),(0,f.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-4",children:[W.length>0&&(0,f.jsxs)("div",{children:[(0,f.jsxs)("h3",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:["Users (",W.length,")"]}),(0,f.jsx)("div",{className:"space-y-1",children:W.map(e=>(0,f.jsx)(er,{member:e,canChangeRole:O(e),canRemove:F(e),onChangeRole:t=>l(e.id,"user",t),onRemove:()=>o(e.id,"user"),isCurrentUser:e.id===i},e.id))})]}),T.length>0&&(0,f.jsxs)("div",{children:[(0,f.jsxs)("h3",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:["Agents (",T.length,")"]}),(0,f.jsx)("div",{className:"space-y-1",children:T.map(e=>(0,f.jsx)(er,{member:e,canChangeRole:O(e),canRemove:F(e),onChangeRole:t=>l(e.id,"agent",t),onRemove:()=>o(e.id,"agent"),isAgent:!0},e.id))})]})]}),(0,f.jsx)("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:(0,f.jsx)("button",{onClick:n,className:"w-full px-4 py-2 text-sm font-medium text-text-secondary bg-bg-tertiary hover:bg-bg-hover rounded-lg transition-colors",children:"Done"})})]})})}function er(e){let{member:t,canChangeRole:r,canRemove:s,onChangeRole:n,onRemove:a,isCurrentUser:o,isAgent:l}=e;return(0,f.jsxs)("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-bg-tertiary group",children:[(0,f.jsxs)("div",{className:"flex items-center gap-3",children:[(0,f.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-xs font-medium ".concat(l?"bg-purple-500/20 text-purple-400":"bg-accent-cyan/20 text-accent-cyan"),children:(t.displayName||t.id)[0].toUpperCase()}),(0,f.jsxs)("div",{children:[(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[(0,f.jsx)("span",{className:"text-sm font-medium text-text-primary",children:t.displayName||t.id}),o&&(0,f.jsx)("span",{className:"text-xs text-text-muted",children:"(you)"}),l&&(0,f.jsx)("span",{className:"text-xs px-1.5 py-0.5 bg-purple-500/20 text-purple-400 rounded",children:"Agent"})]}),(0,f.jsx)("span",{className:"text-xs capitalize ".concat("owner"===t.role?"text-yellow-400":"admin"===t.role?"text-accent-cyan":"text-text-muted"),children:t.role})]})]}),(0,f.jsxs)("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[r&&(0,f.jsxs)("select",{value:"owner"===t.role?"admin":t.role,onChange:e=>n(e.target.value),className:"px-2 py-1 text-xs bg-bg-tertiary border border-border-subtle rounded text-text-primary focus:outline-none focus:border-accent-cyan/50",children:[(0,f.jsx)("option",{value:"admin",children:"Admin"}),(0,f.jsx)("option",{value:"member",children:"Member"}),(0,f.jsx)("option",{value:"read_only",children:"Read Only"})]}),s&&(0,f.jsx)("button",{onClick:a,className:"p-1.5 text-red-400 hover:bg-red-500/20 rounded transition-colors",title:"Remove member",children:(0,f.jsx)(Q,{className:"w-4 h-4"})})]})]})}},6270:function(e,t,r){r.d(t,{y:function(){return k}});var s=r(7437),n=r(2265),a=r(3225),o=r(9880),l=r(454),i=r(1999),c=r(290),d=r(4327),x=r(1202),u=r(3706),m=r(6011),h=r(1801),p=r(754),g=r(3871),b=r(5482),f=r(5210),y=r(963),j=r(7711);a.Z.registerLanguage("javascript",l.Z),a.Z.registerLanguage("typescript",i.Z),a.Z.registerLanguage("python",c.Z),a.Z.registerLanguage("bash",d.Z),a.Z.registerLanguage("shell",d.Z),a.Z.registerLanguage("json",x.Z),a.Z.registerLanguage("markdown",u.Z),a.Z.registerLanguage("yaml",m.Z),a.Z.registerLanguage("css",h.Z),a.Z.registerLanguage("go",p.Z),a.Z.registerLanguage("rust",g.Z),a.Z.registerLanguage("sql",b.Z),a.Z.registerLanguage("ruby",f.Z),a.Z.registerLanguage("java",y.Z),a.Z.registerLanguage("docker",j.Z),a.Z.registerLanguage("dockerfile",j.Z);let v={...o.Z,'pre[class*="language-"]':{...o.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-"]':{...o.Z['code[class*="language-"]'],background:"transparent",fontSize:"0.75rem"}};function w(e){let{code:t,language:r}=e,[o,l]=(0,n.useState)(!1),i=(0,n.useCallback)(async()=>{try{await navigator.clipboard.writeText(t),l(!0),setTimeout(()=>l(!1),2e3)}catch(e){console.error("Failed to copy:",e)}},[t]),c=r.toLowerCase().replace(/^(js|jsx)$/,"javascript").replace(/^(ts|tsx)$/,"typescript").replace(/^(py)$/,"python").replace(/^(rb)$/,"ruby").replace(/^(sh|shell|zsh)$/,"bash");return(0,s.jsxs)("div",{className:"relative group my-2",children:[(0,s.jsxs)("div",{className:"absolute top-2 right-2 flex items-center gap-2 z-10",children:[r&&"text"!==r&&(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-cyan/20 text-accent-cyan font-mono",children:r}),(0,s.jsx)("button",{onClick:i,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:o?"✓ Copied":"Copy"})]}),(0,s.jsx)(a.Z,{language:c,style:v,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 N(e){let t=e.split("\n"),r=[],s=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";s&&s.type===t?s.content+="\n"+e:(s&&r.push(s),s={type:t,content:e})}return s&&r.push(s),r}function k(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.replace(/\\n/g,"\n").replace(/\r\n/g,"\n").replace(/\r/g,"\n"),a=function(e){let t;let r=[],s=/```(\w*)\n([\s\S]*?)```/g,n=0;for(;null!==(t=s.exec(e));){if(t.index>n){let s=N(e.slice(n,t.index));r.push(...s)}r.push({type:"code",language:t[1]||"text",content:t[2]}),n=t.index+t[0].length}if(n<e.length){let t=N(e.slice(n));r.push(...t)}return 0===r.length?N(e):r}(r);return 1===a.length&&"text"===a[0].type?r.split("\n").map((e,r)=>(0,s.jsxs)(n.Fragment,{children:[r>0&&(0,s.jsx)("br",{}),C(e,t.mentions)]},r)):a.map((e,r)=>{if("code"===e.type)return(0,s.jsx)(w,{code:e.content,language:e.language||"text"},r);if("table"===e.type)return(0,s.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},r);let a=e.content.split("\n");return(0,s.jsx)("span",{children:a.map((e,r)=>(0,s.jsxs)(n.Fragment,{children:[r>0&&(0,s.jsx)("br",{}),C(e,t.mentions)]},r))},r)})}function C(e,t){return e.split(/(`[^`]+`|https?:\/\/[^\s]+)/g).map((e,r)=>{if(!e)return null;if(e.startsWith("`")&&e.endsWith("`")&&e.length>2){let t=e.slice(1,-1);return(0,s.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-bg-elevated/80 text-accent-cyan font-mono text-[0.85em] border border-border-subtle/50",children:t},"code-".concat(r))}return/^https?:\/\//.test(e)?(0,s.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan no-underline hover:underline",children:e},"url-".concat(r)):function(e,t,r){let n;if(!t||0===t.length)return e;let a=t.map(S).filter(Boolean);if(0===a.length)return e;let o=RegExp("@(".concat(a.join("|"),")\\b"),"g"),l=[],i=0;for(;null!==(n=o.exec(e));)n.index>i&&l.push(e.slice(i,n.index)),l.push((0,s.jsxs)("span",{className:"px-1 py-0.5 bg-accent-cyan/20 text-accent-cyan rounded",children:["@",n[1]]},"".concat(r,"-mention-").concat(n.index))),i=n.index+n[0].length;return i<e.length&&l.push(e.slice(i)),l.length>0?l:e}(e,t,"text-".concat(r))})}function S(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}}]);