@jacques-ai/server 0.0.7-alpha.1

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 (384) hide show
  1. package/dist/config/config.d.ts +34 -0
  2. package/dist/config/config.d.ts.map +1 -0
  3. package/dist/config/config.js +32 -0
  4. package/dist/config/config.js.map +1 -0
  5. package/dist/connection/applescript.d.ts +46 -0
  6. package/dist/connection/applescript.d.ts.map +1 -0
  7. package/dist/connection/applescript.js +62 -0
  8. package/dist/connection/applescript.js.map +1 -0
  9. package/dist/connection/applescript.test.d.ts +5 -0
  10. package/dist/connection/applescript.test.d.ts.map +1 -0
  11. package/dist/connection/applescript.test.js +64 -0
  12. package/dist/connection/applescript.test.js.map +1 -0
  13. package/dist/connection/constants.d.ts +88 -0
  14. package/dist/connection/constants.d.ts.map +1 -0
  15. package/dist/connection/constants.js +110 -0
  16. package/dist/connection/constants.js.map +1 -0
  17. package/dist/connection/git-info.d.ts +30 -0
  18. package/dist/connection/git-info.d.ts.map +1 -0
  19. package/dist/connection/git-info.js +52 -0
  20. package/dist/connection/git-info.js.map +1 -0
  21. package/dist/connection/git-info.test.d.ts +5 -0
  22. package/dist/connection/git-info.test.d.ts.map +1 -0
  23. package/dist/connection/git-info.test.js +35 -0
  24. package/dist/connection/git-info.test.js.map +1 -0
  25. package/dist/connection/index.d.ts +19 -0
  26. package/dist/connection/index.d.ts.map +1 -0
  27. package/dist/connection/index.js +36 -0
  28. package/dist/connection/index.js.map +1 -0
  29. package/dist/connection/process-detection.d.ts +58 -0
  30. package/dist/connection/process-detection.d.ts.map +1 -0
  31. package/dist/connection/process-detection.js +239 -0
  32. package/dist/connection/process-detection.js.map +1 -0
  33. package/dist/connection/process-detection.test.d.ts +5 -0
  34. package/dist/connection/process-detection.test.d.ts.map +1 -0
  35. package/dist/connection/process-detection.test.js +43 -0
  36. package/dist/connection/process-detection.test.js.map +1 -0
  37. package/dist/connection/session-discovery.d.ts +55 -0
  38. package/dist/connection/session-discovery.d.ts.map +1 -0
  39. package/dist/connection/session-discovery.js +311 -0
  40. package/dist/connection/session-discovery.js.map +1 -0
  41. package/dist/connection/terminal-key.d.ts +126 -0
  42. package/dist/connection/terminal-key.d.ts.map +1 -0
  43. package/dist/connection/terminal-key.js +271 -0
  44. package/dist/connection/terminal-key.js.map +1 -0
  45. package/dist/connection/terminal-key.test.d.ts +5 -0
  46. package/dist/connection/terminal-key.test.d.ts.map +1 -0
  47. package/dist/connection/terminal-key.test.js +221 -0
  48. package/dist/connection/terminal-key.test.js.map +1 -0
  49. package/dist/connection/worktree.d.ts +114 -0
  50. package/dist/connection/worktree.d.ts.map +1 -0
  51. package/dist/connection/worktree.js +320 -0
  52. package/dist/connection/worktree.js.map +1 -0
  53. package/dist/connection/worktree.test.d.ts +5 -0
  54. package/dist/connection/worktree.test.d.ts.map +1 -0
  55. package/dist/connection/worktree.test.js +113 -0
  56. package/dist/connection/worktree.test.js.map +1 -0
  57. package/dist/focus-watcher.d.ts +51 -0
  58. package/dist/focus-watcher.d.ts.map +1 -0
  59. package/dist/focus-watcher.js +169 -0
  60. package/dist/focus-watcher.js.map +1 -0
  61. package/dist/handlers/event-handler.d.ts +93 -0
  62. package/dist/handlers/event-handler.d.ts.map +1 -0
  63. package/dist/handlers/event-handler.js +196 -0
  64. package/dist/handlers/event-handler.js.map +1 -0
  65. package/dist/handlers/event-handler.test.d.ts +5 -0
  66. package/dist/handlers/event-handler.test.d.ts.map +1 -0
  67. package/dist/handlers/event-handler.test.js +305 -0
  68. package/dist/handlers/event-handler.test.js.map +1 -0
  69. package/dist/handlers/session-handler.d.ts +23 -0
  70. package/dist/handlers/session-handler.d.ts.map +1 -0
  71. package/dist/handlers/session-handler.js +104 -0
  72. package/dist/handlers/session-handler.js.map +1 -0
  73. package/dist/handlers/session-handler.test.d.ts +5 -0
  74. package/dist/handlers/session-handler.test.d.ts.map +1 -0
  75. package/dist/handlers/session-handler.test.js +89 -0
  76. package/dist/handlers/session-handler.test.js.map +1 -0
  77. package/dist/handlers/settings-handler.d.ts +32 -0
  78. package/dist/handlers/settings-handler.d.ts.map +1 -0
  79. package/dist/handlers/settings-handler.js +127 -0
  80. package/dist/handlers/settings-handler.js.map +1 -0
  81. package/dist/handlers/settings-handler.test.d.ts +5 -0
  82. package/dist/handlers/settings-handler.test.d.ts.map +1 -0
  83. package/dist/handlers/settings-handler.test.js +105 -0
  84. package/dist/handlers/settings-handler.test.js.map +1 -0
  85. package/dist/handlers/window-handler.d.ts +30 -0
  86. package/dist/handlers/window-handler.d.ts.map +1 -0
  87. package/dist/handlers/window-handler.js +486 -0
  88. package/dist/handlers/window-handler.js.map +1 -0
  89. package/dist/handlers/window-handler.test.d.ts +8 -0
  90. package/dist/handlers/window-handler.test.d.ts.map +1 -0
  91. package/dist/handlers/window-handler.test.js +167 -0
  92. package/dist/handlers/window-handler.test.js.map +1 -0
  93. package/dist/handlers/worktree-handler.d.ts +28 -0
  94. package/dist/handlers/worktree-handler.d.ts.map +1 -0
  95. package/dist/handlers/worktree-handler.js +268 -0
  96. package/dist/handlers/worktree-handler.js.map +1 -0
  97. package/dist/handlers/worktree-handler.test.d.ts +8 -0
  98. package/dist/handlers/worktree-handler.test.d.ts.map +1 -0
  99. package/dist/handlers/worktree-handler.test.js +118 -0
  100. package/dist/handlers/worktree-handler.test.js.map +1 -0
  101. package/dist/handlers/ws-utils.d.ts +12 -0
  102. package/dist/handlers/ws-utils.d.ts.map +1 -0
  103. package/dist/handlers/ws-utils.js +16 -0
  104. package/dist/handlers/ws-utils.js.map +1 -0
  105. package/dist/http-api.d.ts +26 -0
  106. package/dist/http-api.d.ts.map +1 -0
  107. package/dist/http-api.js +148 -0
  108. package/dist/http-api.js.map +1 -0
  109. package/dist/logger.d.ts +42 -0
  110. package/dist/logger.d.ts.map +1 -0
  111. package/dist/logger.js +147 -0
  112. package/dist/logger.js.map +1 -0
  113. package/dist/logging/logger-factory.d.ts +51 -0
  114. package/dist/logging/logger-factory.d.ts.map +1 -0
  115. package/dist/logging/logger-factory.js +59 -0
  116. package/dist/logging/logger-factory.js.map +1 -0
  117. package/dist/mcp/search-tool.d.ts +65 -0
  118. package/dist/mcp/search-tool.d.ts.map +1 -0
  119. package/dist/mcp/search-tool.js +176 -0
  120. package/dist/mcp/search-tool.js.map +1 -0
  121. package/dist/mcp/server.d.ts +9 -0
  122. package/dist/mcp/server.d.ts.map +1 -0
  123. package/dist/mcp/server.js +152 -0
  124. package/dist/mcp/server.js.map +1 -0
  125. package/dist/process-scanner.d.ts +96 -0
  126. package/dist/process-scanner.d.ts.map +1 -0
  127. package/dist/process-scanner.js +194 -0
  128. package/dist/process-scanner.js.map +1 -0
  129. package/dist/routes/__tests__/archive-routes.test.d.ts +5 -0
  130. package/dist/routes/__tests__/archive-routes.test.d.ts.map +1 -0
  131. package/dist/routes/__tests__/archive-routes.test.js +158 -0
  132. package/dist/routes/__tests__/archive-routes.test.js.map +1 -0
  133. package/dist/routes/__tests__/config-routes.test.d.ts +5 -0
  134. package/dist/routes/__tests__/config-routes.test.d.ts.map +1 -0
  135. package/dist/routes/__tests__/config-routes.test.js +112 -0
  136. package/dist/routes/__tests__/config-routes.test.js.map +1 -0
  137. package/dist/routes/__tests__/http-utils.test.d.ts +5 -0
  138. package/dist/routes/__tests__/http-utils.test.d.ts.map +1 -0
  139. package/dist/routes/__tests__/http-utils.test.js +102 -0
  140. package/dist/routes/__tests__/http-utils.test.js.map +1 -0
  141. package/dist/routes/__tests__/notification-routes.test.d.ts +5 -0
  142. package/dist/routes/__tests__/notification-routes.test.d.ts.map +1 -0
  143. package/dist/routes/__tests__/notification-routes.test.js +91 -0
  144. package/dist/routes/__tests__/notification-routes.test.js.map +1 -0
  145. package/dist/routes/__tests__/project-routes.test.d.ts +5 -0
  146. package/dist/routes/__tests__/project-routes.test.d.ts.map +1 -0
  147. package/dist/routes/__tests__/project-routes.test.js +168 -0
  148. package/dist/routes/__tests__/project-routes.test.js.map +1 -0
  149. package/dist/routes/__tests__/session-routes.test.d.ts +5 -0
  150. package/dist/routes/__tests__/session-routes.test.d.ts.map +1 -0
  151. package/dist/routes/__tests__/session-routes.test.js +198 -0
  152. package/dist/routes/__tests__/session-routes.test.js.map +1 -0
  153. package/dist/routes/__tests__/source-routes.test.d.ts +5 -0
  154. package/dist/routes/__tests__/source-routes.test.d.ts.map +1 -0
  155. package/dist/routes/__tests__/source-routes.test.js +142 -0
  156. package/dist/routes/__tests__/source-routes.test.js.map +1 -0
  157. package/dist/routes/__tests__/sync-routes.test.d.ts +5 -0
  158. package/dist/routes/__tests__/sync-routes.test.d.ts.map +1 -0
  159. package/dist/routes/__tests__/sync-routes.test.js +77 -0
  160. package/dist/routes/__tests__/sync-routes.test.js.map +1 -0
  161. package/dist/routes/__tests__/test-helpers.d.ts +47 -0
  162. package/dist/routes/__tests__/test-helpers.d.ts.map +1 -0
  163. package/dist/routes/__tests__/test-helpers.js +97 -0
  164. package/dist/routes/__tests__/test-helpers.js.map +1 -0
  165. package/dist/routes/archive-routes.d.ts +15 -0
  166. package/dist/routes/archive-routes.d.ts.map +1 -0
  167. package/dist/routes/archive-routes.js +181 -0
  168. package/dist/routes/archive-routes.js.map +1 -0
  169. package/dist/routes/claude-routes.d.ts +9 -0
  170. package/dist/routes/claude-routes.d.ts.map +1 -0
  171. package/dist/routes/claude-routes.js +47 -0
  172. package/dist/routes/claude-routes.js.map +1 -0
  173. package/dist/routes/config-routes.d.ts +9 -0
  174. package/dist/routes/config-routes.d.ts.map +1 -0
  175. package/dist/routes/config-routes.js +56 -0
  176. package/dist/routes/config-routes.js.map +1 -0
  177. package/dist/routes/config-store.d.ts +41 -0
  178. package/dist/routes/config-store.d.ts.map +1 -0
  179. package/dist/routes/config-store.js +52 -0
  180. package/dist/routes/config-store.js.map +1 -0
  181. package/dist/routes/http-utils.d.ts +32 -0
  182. package/dist/routes/http-utils.d.ts.map +1 -0
  183. package/dist/routes/http-utils.js +123 -0
  184. package/dist/routes/http-utils.js.map +1 -0
  185. package/dist/routes/index.d.ts +19 -0
  186. package/dist/routes/index.d.ts.map +1 -0
  187. package/dist/routes/index.js +17 -0
  188. package/dist/routes/index.js.map +1 -0
  189. package/dist/routes/notification-routes.d.ts +10 -0
  190. package/dist/routes/notification-routes.d.ts.map +1 -0
  191. package/dist/routes/notification-routes.js +64 -0
  192. package/dist/routes/notification-routes.js.map +1 -0
  193. package/dist/routes/project-routes.d.ts +22 -0
  194. package/dist/routes/project-routes.d.ts.map +1 -0
  195. package/dist/routes/project-routes.js +415 -0
  196. package/dist/routes/project-routes.js.map +1 -0
  197. package/dist/routes/session-routes.d.ts +18 -0
  198. package/dist/routes/session-routes.d.ts.map +1 -0
  199. package/dist/routes/session-routes.js +609 -0
  200. package/dist/routes/session-routes.js.map +1 -0
  201. package/dist/routes/source-routes.d.ts +12 -0
  202. package/dist/routes/source-routes.d.ts.map +1 -0
  203. package/dist/routes/source-routes.js +119 -0
  204. package/dist/routes/source-routes.js.map +1 -0
  205. package/dist/routes/static-routes.d.ts +12 -0
  206. package/dist/routes/static-routes.d.ts.map +1 -0
  207. package/dist/routes/static-routes.js +52 -0
  208. package/dist/routes/static-routes.js.map +1 -0
  209. package/dist/routes/sync-routes.d.ts +9 -0
  210. package/dist/routes/sync-routes.d.ts.map +1 -0
  211. package/dist/routes/sync-routes.js +78 -0
  212. package/dist/routes/sync-routes.js.map +1 -0
  213. package/dist/routes/tile-routes.d.ts +10 -0
  214. package/dist/routes/tile-routes.d.ts.map +1 -0
  215. package/dist/routes/tile-routes.js +108 -0
  216. package/dist/routes/tile-routes.js.map +1 -0
  217. package/dist/routes/types.d.ts +17 -0
  218. package/dist/routes/types.d.ts.map +1 -0
  219. package/dist/routes/types.js +5 -0
  220. package/dist/routes/types.js.map +1 -0
  221. package/dist/routes/usage-routes.d.ts +8 -0
  222. package/dist/routes/usage-routes.d.ts.map +1 -0
  223. package/dist/routes/usage-routes.js +18 -0
  224. package/dist/routes/usage-routes.js.map +1 -0
  225. package/dist/server.d.ts +8 -0
  226. package/dist/server.d.ts.map +1 -0
  227. package/dist/server.js +173 -0
  228. package/dist/server.js.map +1 -0
  229. package/dist/services/branch-divergence-service.d.ts +48 -0
  230. package/dist/services/branch-divergence-service.d.ts.map +1 -0
  231. package/dist/services/branch-divergence-service.js +156 -0
  232. package/dist/services/branch-divergence-service.js.map +1 -0
  233. package/dist/services/broadcast-service.d.ts +68 -0
  234. package/dist/services/broadcast-service.d.ts.map +1 -0
  235. package/dist/services/broadcast-service.js +78 -0
  236. package/dist/services/broadcast-service.js.map +1 -0
  237. package/dist/services/broadcast-service.test.d.ts +5 -0
  238. package/dist/services/broadcast-service.test.d.ts.map +1 -0
  239. package/dist/services/broadcast-service.test.js +130 -0
  240. package/dist/services/broadcast-service.test.js.map +1 -0
  241. package/dist/services/chat-service.d.ts +72 -0
  242. package/dist/services/chat-service.d.ts.map +1 -0
  243. package/dist/services/chat-service.js +342 -0
  244. package/dist/services/chat-service.js.map +1 -0
  245. package/dist/services/chat-system-prompt.d.ts +14 -0
  246. package/dist/services/chat-system-prompt.d.ts.map +1 -0
  247. package/dist/services/chat-system-prompt.js +68 -0
  248. package/dist/services/chat-system-prompt.js.map +1 -0
  249. package/dist/services/notification-service.d.ts +115 -0
  250. package/dist/services/notification-service.d.ts.map +1 -0
  251. package/dist/services/notification-service.js +424 -0
  252. package/dist/services/notification-service.js.map +1 -0
  253. package/dist/services/notification-service.test.d.ts +5 -0
  254. package/dist/services/notification-service.test.d.ts.map +1 -0
  255. package/dist/services/notification-service.test.js +918 -0
  256. package/dist/services/notification-service.test.js.map +1 -0
  257. package/dist/session/cleanup-service.d.ts +51 -0
  258. package/dist/session/cleanup-service.d.ts.map +1 -0
  259. package/dist/session/cleanup-service.js +98 -0
  260. package/dist/session/cleanup-service.js.map +1 -0
  261. package/dist/session/cleanup-service.test.d.ts +5 -0
  262. package/dist/session/cleanup-service.test.d.ts.map +1 -0
  263. package/dist/session/cleanup-service.test.js +121 -0
  264. package/dist/session/cleanup-service.test.js.map +1 -0
  265. package/dist/session/process-monitor.d.ts +79 -0
  266. package/dist/session/process-monitor.d.ts.map +1 -0
  267. package/dist/session/process-monitor.js +270 -0
  268. package/dist/session/process-monitor.js.map +1 -0
  269. package/dist/session/process-monitor.test.d.ts +5 -0
  270. package/dist/session/process-monitor.test.d.ts.map +1 -0
  271. package/dist/session/process-monitor.test.js +367 -0
  272. package/dist/session/process-monitor.test.js.map +1 -0
  273. package/dist/session/session-factory.d.ts +29 -0
  274. package/dist/session/session-factory.d.ts.map +1 -0
  275. package/dist/session/session-factory.js +123 -0
  276. package/dist/session/session-factory.js.map +1 -0
  277. package/dist/session/session-factory.test.d.ts +5 -0
  278. package/dist/session/session-factory.test.d.ts.map +1 -0
  279. package/dist/session/session-factory.test.js +299 -0
  280. package/dist/session/session-factory.test.js.map +1 -0
  281. package/dist/session-registry.d.ts +168 -0
  282. package/dist/session-registry.d.ts.map +1 -0
  283. package/dist/session-registry.js +626 -0
  284. package/dist/session-registry.js.map +1 -0
  285. package/dist/session-registry.test.d.ts +5 -0
  286. package/dist/session-registry.test.d.ts.map +1 -0
  287. package/dist/session-registry.test.js +582 -0
  288. package/dist/session-registry.test.js.map +1 -0
  289. package/dist/start-server.d.ts +31 -0
  290. package/dist/start-server.d.ts.map +1 -0
  291. package/dist/start-server.js +408 -0
  292. package/dist/start-server.js.map +1 -0
  293. package/dist/terminal-activator.d.ts +29 -0
  294. package/dist/terminal-activator.d.ts.map +1 -0
  295. package/dist/terminal-activator.js +264 -0
  296. package/dist/terminal-activator.js.map +1 -0
  297. package/dist/terminal-activator.test.d.ts +9 -0
  298. package/dist/terminal-activator.test.d.ts.map +1 -0
  299. package/dist/terminal-activator.test.js +95 -0
  300. package/dist/terminal-activator.test.js.map +1 -0
  301. package/dist/terminal-launcher.d.ts +51 -0
  302. package/dist/terminal-launcher.d.ts.map +1 -0
  303. package/dist/terminal-launcher.js +298 -0
  304. package/dist/terminal-launcher.js.map +1 -0
  305. package/dist/terminal-launcher.test.d.ts +8 -0
  306. package/dist/terminal-launcher.test.d.ts.map +1 -0
  307. package/dist/terminal-launcher.test.js +222 -0
  308. package/dist/terminal-launcher.test.js.map +1 -0
  309. package/dist/types.d.ts +796 -0
  310. package/dist/types.d.ts.map +1 -0
  311. package/dist/types.js +15 -0
  312. package/dist/types.js.map +1 -0
  313. package/dist/unix-socket.d.ts +68 -0
  314. package/dist/unix-socket.d.ts.map +1 -0
  315. package/dist/unix-socket.js +180 -0
  316. package/dist/unix-socket.js.map +1 -0
  317. package/dist/usage-limits.d.ts +13 -0
  318. package/dist/usage-limits.d.ts.map +1 -0
  319. package/dist/usage-limits.js +112 -0
  320. package/dist/usage-limits.js.map +1 -0
  321. package/dist/watchers/handoff-watcher.d.ts +74 -0
  322. package/dist/watchers/handoff-watcher.d.ts.map +1 -0
  323. package/dist/watchers/handoff-watcher.js +124 -0
  324. package/dist/watchers/handoff-watcher.js.map +1 -0
  325. package/dist/watchers/handoff-watcher.test.d.ts +8 -0
  326. package/dist/watchers/handoff-watcher.test.d.ts.map +1 -0
  327. package/dist/watchers/handoff-watcher.test.js +142 -0
  328. package/dist/watchers/handoff-watcher.test.js.map +1 -0
  329. package/dist/websocket.d.ts +107 -0
  330. package/dist/websocket.d.ts.map +1 -0
  331. package/dist/websocket.js +268 -0
  332. package/dist/websocket.js.map +1 -0
  333. package/dist/window-manager/index.d.ts +28 -0
  334. package/dist/window-manager/index.d.ts.map +1 -0
  335. package/dist/window-manager/index.js +56 -0
  336. package/dist/window-manager/index.js.map +1 -0
  337. package/dist/window-manager/layouts.d.ts +42 -0
  338. package/dist/window-manager/layouts.d.ts.map +1 -0
  339. package/dist/window-manager/layouts.js +133 -0
  340. package/dist/window-manager/layouts.js.map +1 -0
  341. package/dist/window-manager/linux-manager.d.ts +45 -0
  342. package/dist/window-manager/linux-manager.d.ts.map +1 -0
  343. package/dist/window-manager/linux-manager.js +299 -0
  344. package/dist/window-manager/linux-manager.js.map +1 -0
  345. package/dist/window-manager/macos-manager.d.ts +103 -0
  346. package/dist/window-manager/macos-manager.d.ts.map +1 -0
  347. package/dist/window-manager/macos-manager.js +637 -0
  348. package/dist/window-manager/macos-manager.js.map +1 -0
  349. package/dist/window-manager/smart-layouts.d.ts +116 -0
  350. package/dist/window-manager/smart-layouts.d.ts.map +1 -0
  351. package/dist/window-manager/smart-layouts.js +188 -0
  352. package/dist/window-manager/smart-layouts.js.map +1 -0
  353. package/dist/window-manager/smart-layouts.test.d.ts +8 -0
  354. package/dist/window-manager/smart-layouts.test.d.ts.map +1 -0
  355. package/dist/window-manager/smart-layouts.test.js +311 -0
  356. package/dist/window-manager/smart-layouts.test.js.map +1 -0
  357. package/dist/window-manager/tile-state.d.ts +87 -0
  358. package/dist/window-manager/tile-state.d.ts.map +1 -0
  359. package/dist/window-manager/tile-state.js +136 -0
  360. package/dist/window-manager/tile-state.js.map +1 -0
  361. package/dist/window-manager/tile-state.test.d.ts +8 -0
  362. package/dist/window-manager/tile-state.test.d.ts.map +1 -0
  363. package/dist/window-manager/tile-state.test.js +179 -0
  364. package/dist/window-manager/tile-state.test.js.map +1 -0
  365. package/dist/window-manager/types.d.ts +104 -0
  366. package/dist/window-manager/types.d.ts.map +1 -0
  367. package/dist/window-manager/types.js +8 -0
  368. package/dist/window-manager/types.js.map +1 -0
  369. package/dist/window-manager/windows-manager.d.ts +44 -0
  370. package/dist/window-manager/windows-manager.d.ts.map +1 -0
  371. package/dist/window-manager/windows-manager.js +281 -0
  372. package/dist/window-manager/windows-manager.js.map +1 -0
  373. package/dist/window-manager/windows-manager.test.d.ts +8 -0
  374. package/dist/window-manager/windows-manager.test.d.ts.map +1 -0
  375. package/dist/window-manager/windows-manager.test.js +183 -0
  376. package/dist/window-manager/windows-manager.test.js.map +1 -0
  377. package/gui-dist/assets/index-BmYIHRYe.js +142 -0
  378. package/gui-dist/assets/index-D_N5RH8O.css +1 -0
  379. package/gui-dist/assets/vendor-icons-ByXNrcwf.js +336 -0
  380. package/gui-dist/assets/vendor-markdown-DWPYwU1x.js +22 -0
  381. package/gui-dist/assets/vendor-react-CpILBTDM.js +59 -0
  382. package/gui-dist/index.html +17 -0
  383. package/gui-dist/jacsub.png +0 -0
  384. package/package.json +67 -0
@@ -0,0 +1,142 @@
1
+ var vs=Object.defineProperty;var ws=(n,o,s)=>o in n?vs(n,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[o]=s;var xe=(n,o,s)=>ws(n,typeof o!="symbol"?o+"":o,s);import{j as e,M as ks}from"./vendor-markdown-DWPYwU1x.js";import{a as Cs,r as a,R as mn,u as mt,b as hn,d as Is,N as zn,L as qn,O as Ts,e as Lo,f as Po,h as zs,i as _e,j as Rs,B as Es}from"./vendor-react-CpILBTDM.js";import{S as yt,a as Yn,P as $s,G as ht,Z as yn,b as qt,c as bn,B as et,F as Re,X as st,L as Oe,d as Ao,C as Dt,T as _o,e as Fe,f as Wt,g as Bs,h as Ms,i as Ls,j as Fo,k as Ps,l as ao,m as ft,M as Do,W as Zt,n as Xn,o as Wo,p as No,q as Yt,r as vt,s as tt,t as Zn,u as Qn,v as At,w as As,x as _s,y as Ho,z as Fs,A as Ds,D as Ws,E as Ns,R as Nt,H as Oo,I as eo,J as Hs,K as Os,N as lo,O as co,Q as qs,U as Us,V as Un,Y as Js,_ as Gs,$ as Vs,a0 as Ks,a1 as Ys,a2 as Xs,a3 as to,a4 as Zs,a5 as Qs,a6 as er,a7 as tr,a8 as nr}from"./vendor-icons-ByXNrcwf.js";(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function s(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(i){if(i.ep)return;i.ep=!0;const l=s(i);fetch(i.href,l)}})();var Jn={},po=Cs;Jn.createRoot=po.createRoot,Jn.hydrateRoot=po.hydrateRoot;const t={bgPrimary:"#0d0d0d",bgSecondary:"#1a1a1a",bgElevated:"#252525",bgInput:"#2a2a2a",accent:"#E67E52",accentOrange:"#FF6600",textPrimary:"#ffffff",textSecondary:"#8B9296",textMuted:"#6B7075",success:"#4ADE80",warning:"#FBBF24",danger:"#EF4444",borderSubtle:"#3a3a3a",dotRed:"#FF5F56",dotYellow:"#FFBD2E",dotGreen:"#27C93F"},ke={fontFamily:{mono:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",sans:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"}};function xn({title:n,status:o,showDots:s=!0,children:r,headerRight:i,noPadding:l=!1,onClick:c}){return e.jsxs("div",{style:{...nt.container,cursor:c?"pointer":"default"},onClick:c,children:[e.jsxs("div",{style:nt.chrome,children:[e.jsxs("div",{style:nt.chromeLeft,children:[s&&e.jsxs("div",{style:nt.dots,children:[e.jsx("span",{style:{...nt.dot,backgroundColor:t.dotRed}}),e.jsx("span",{style:{...nt.dot,backgroundColor:t.dotYellow}}),e.jsx("span",{style:{...nt.dot,backgroundColor:t.dotGreen}})]}),n&&e.jsx("span",{style:nt.title,children:n})]}),e.jsxs("div",{style:nt.chromeRight,children:[o,i]})]}),e.jsx("div",{style:l?nt.contentNoPadding:nt.content,children:r})]})}const nt={container:{backgroundColor:t.bgPrimary,border:`1px solid ${t.borderSubtle}`,borderRadius:"8px",overflow:"hidden",transition:"border-color 200ms ease"},chrome:{display:"flex",alignItems:"center",justifyContent:"space-between",height:"32px",padding:"0 12px",backgroundColor:t.bgSecondary,borderBottom:`1px solid ${t.borderSubtle}`},chromeLeft:{display:"flex",alignItems:"center",gap:"10px",minWidth:0},chromeRight:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},dots:{display:"flex",gap:"6px",flexShrink:0},dot:{width:"6px",height:"6px",borderRadius:"50%",opacity:.7},title:{fontSize:"11px",color:t.textMuted,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},content:{padding:"16px"},contentNoPadding:{padding:0}};function or({value:n,onChange:o,placeholder:s="Search...",resultCount:r}){return e.jsxs("div",{style:nn.container,children:[e.jsx(yt,{size:14,color:t.textMuted,style:nn.icon}),e.jsx("input",{type:"text",value:n,onChange:i=>o(i.target.value),placeholder:s,style:nn.input}),r!==void 0&&n.length>0&&e.jsxs("span",{style:nn.count,children:[r," result",r!==1?"s":""]})]})}const nn={container:{position:"relative",display:"flex",alignItems:"center",flex:1,maxWidth:"400px"},icon:{position:"absolute",left:"12px",pointerEvents:"none",flexShrink:0},input:{width:"100%",padding:"10px 14px 10px 36px",fontSize:"14px",fontFamily:"inherit",backgroundColor:t.bgInput,border:`1px solid ${t.borderSubtle}`,borderRadius:"8px",color:t.textPrimary,outline:"none",transition:"border-color 200ms ease, box-shadow 200ms ease"},count:{position:"absolute",right:"12px",fontSize:"11px",color:t.textMuted,pointerEvents:"none",fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"}},sr={plan:{color:"#A78BFA",bg:"rgba(167, 139, 250, 0.15)",border:"rgba(167, 139, 250, 0.3)",Icon:Re},agent:{color:"#FF6600",bg:"rgba(255, 102, 0, 0.15)",border:"rgba(255, 102, 0, 0.3)",Icon:et},mcp:{color:t.textSecondary,bg:"rgba(139, 146, 150, 0.15)",Icon:bn},web:{color:"#60A5FA",bg:"rgba(96, 165, 250, 0.15)",Icon:qt},compacted:{color:t.textMuted,bg:"rgba(107, 112, 117, 0.15)",Icon:yn},planning:{color:"#34D399",bg:"rgba(52, 211, 153, 0.15)",Icon:ht},execution:{color:"#60A5FA",bg:"rgba(96, 165, 250, 0.15)",Icon:$s},"p-less":{color:"#EF4444",bg:"rgba(239, 68, 68, 0.15)",Icon:Yn},focused:{color:t.bgPrimary,bg:t.accent},live:{color:t.success,bg:"rgba(74, 222, 128, 0.15)",dot:!0,pulse:!0},idle:{color:t.textMuted,bg:"rgba(107, 112, 117, 0.15)",dot:!0},working:{color:t.accent,bg:"rgba(230, 126, 82, 0.15)",dot:!0,pulse:!0},default:{color:t.textSecondary,bg:"rgba(139, 146, 150, 0.15)"}};function $e({label:n,variant:o="default",icon:s,size:r="sm",onClick:i}){const l=sr[o],c=r==="sm";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:c?"4px":"6px",padding:c?"2px 8px":"4px 10px",fontSize:c?"11px":"12px",fontWeight:500,color:l.color,backgroundColor:l.bg,border:l.border?`1px solid ${l.border}`:"none",borderRadius:"6px",cursor:i?"pointer":"default",transition:"all 150ms ease",whiteSpace:"nowrap",lineHeight:1.4},onClick:i,children:[l.dot&&e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:l.color,animation:l.pulse?"pulse-glow 2s ease-in-out infinite":"none",flexShrink:0}}),!l.dot&&(s||l.Icon)&&e.jsx(e.Fragment,{children:s||l.Icon&&e.jsx(l.Icon,{size:c?12:14})}),n]})}function Ut({title:n,accentColor:o=t.accent,action:s}){return e.jsxs("div",{style:on.container,children:[e.jsxs("div",{style:on.left,children:[e.jsx("span",{style:{color:o,marginRight:"8px",fontSize:"10px",opacity:.8},children:"▸"}),e.jsx("span",{style:on.label,children:n})]}),s&&e.jsx("div",{style:on.action,children:s})]})}const on={container:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},left:{display:"flex",alignItems:"center"},label:{fontSize:"11px",fontWeight:600,color:t.textMuted,letterSpacing:"0.15em",textTransform:"uppercase"},action:{flexShrink:0}};function rr({icon:n,title:o,description:s,action:r}){return e.jsxs("div",{style:sn.container,children:[e.jsx(n,{size:48,color:t.textMuted,style:{opacity:.4,marginBottom:"16px"}}),e.jsx("p",{style:sn.title,children:o}),s&&e.jsx("p",{style:sn.description,children:s}),r&&e.jsx("div",{style:sn.action,children:r})]})}const sn={container:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"64px 32px",textAlign:"center"},title:{fontSize:"16px",fontWeight:500,color:t.textPrimary,margin:"0 0 8px 0"},description:{fontSize:"13px",color:t.textMuted,margin:0,maxWidth:"320px",lineHeight:1.5},action:{marginTop:"20px"}},ir={low:t.textMuted,medium:t.accent,high:t.warning,critical:t.danger},ar={low:"none",medium:`0 0 20px ${t.accent}15, 0 8px 24px rgba(0,0,0,0.5)`,high:`0 0 20px ${t.warning}20, 0 8px 24px rgba(0,0,0,0.5)`,critical:`0 0 24px ${t.danger}25, 0 8px 24px rgba(0,0,0,0.5)`};let uo=!1;function lr(){if(uo)return;uo=!0;const n=document.createElement("style");n.textContent=`
2
+ @keyframes jacques-toast-in {
3
+ 0% {
4
+ opacity: 0;
5
+ transform: translateX(100%) scale(0.95);
6
+ }
7
+ 60% {
8
+ opacity: 1;
9
+ transform: translateX(-4px) scale(1.005);
10
+ }
11
+ 100% {
12
+ opacity: 1;
13
+ transform: translateX(0) scale(1);
14
+ }
15
+ }
16
+ @keyframes jacques-toast-out {
17
+ 0% {
18
+ opacity: 1;
19
+ transform: translateX(0) scale(1);
20
+ }
21
+ 100% {
22
+ opacity: 0;
23
+ transform: translateX(40%) scale(0.96);
24
+ }
25
+ }
26
+ @keyframes jacques-progress-shrink {
27
+ from { transform: scaleX(1); }
28
+ to { transform: scaleX(0); }
29
+ }
30
+ @keyframes jacques-toast-flash {
31
+ 0%, 100% { opacity: 1; }
32
+ 50% { opacity: 0.7; }
33
+ }
34
+ `,document.head.appendChild(n)}function cr({toast:n,onDismiss:o,onClick:s,duration:r=6e3,index:i=0}){const[l,c]=a.useState(!1),p=a.useRef(),g=ir[n.priority],d=!!s;a.useEffect(()=>{lr()},[]),a.useEffect(()=>{if(!(r<=0))return p.current=setTimeout(()=>{c(!0)},r),()=>clearTimeout(p.current)},[r]),a.useEffect(()=>{if(!l)return;const u=setTimeout(()=>o(n.id),220);return()=>clearTimeout(u)},[l,o,n.id]);const h=()=>{clearTimeout(p.current),c(!0)},y=u=>{u.target.closest('[aria-label="Dismiss notification"]')||s&&(s(n),h())},m=`${i*80}ms`,x=!!n.projectName,b=x?n.projectName:n.title,f=x?n.branchName?`${n.branchName} · ${n.title}`:n.title:n.body;return e.jsxs("div",{style:{...Ue.container,borderLeftColor:g,boxShadow:ar[n.priority],cursor:d?"pointer":"default",animation:l?"jacques-toast-out 200ms ease-in forwards":`jacques-toast-in 350ms cubic-bezier(0.16, 1, 0.3, 1) ${m} both`},onClick:y,onMouseEnter:()=>clearTimeout(p.current),onMouseLeave:()=>{r>0&&!l&&(p.current=setTimeout(()=>c(!0),2e3))},children:[e.jsxs("div",{style:Ue.chrome,children:[e.jsxs("div",{style:Ue.chromeLeft,children:[e.jsx("span",{style:{...Ue.priorityDot,backgroundColor:g,animation:n.priority==="critical"?"jacques-toast-flash 1.2s ease-in-out infinite":"none"}}),e.jsx("span",{style:Ue.chromeTitle,children:n.category||"notification"})]}),e.jsx("button",{style:Ue.dismissBtn,onClick:h,"aria-label":"Dismiss notification",children:e.jsx(st,{size:11})})]}),e.jsxs("div",{style:Ue.content,children:[e.jsx("img",{src:"/jacsub.png",alt:"",style:Ue.mascot,draggable:!1}),e.jsxs("div",{style:Ue.textBlock,children:[e.jsx("div",{style:Ue.title,children:b}),e.jsx("div",{style:Ue.body,children:f})]})]}),r>0&&!l&&e.jsx("div",{style:Ue.progressTrack,children:e.jsx("div",{style:{...Ue.progressFill,backgroundColor:g,animation:`jacques-progress-shrink ${r}ms linear forwards`,animationDelay:m}})})]})}const Ue={container:{width:"340px",maxWidth:"calc(100vw - 32px)",backgroundColor:t.bgSecondary,border:`1px solid ${t.borderSubtle}`,borderLeft:"3px solid",borderRadius:"8px",overflow:"hidden",pointerEvents:"auto",backdropFilter:"blur(12px)",willChange:"transform, opacity"},chrome:{display:"flex",alignItems:"center",justifyContent:"space-between",height:"26px",padding:"0 8px 0 10px",backgroundColor:t.bgElevated,borderBottom:`1px solid ${t.borderSubtle}`},chromeLeft:{display:"flex",alignItems:"center",gap:"6px",minWidth:0},priorityDot:{width:"6px",height:"6px",borderRadius:"50%",flexShrink:0},chromeTitle:{fontSize:"10px",fontFamily:ke.fontFamily.mono,color:t.textMuted,letterSpacing:"0.3px",textTransform:"lowercase",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},dismissBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",padding:0,border:"none",borderRadius:"4px",backgroundColor:"transparent",color:t.textMuted,cursor:"pointer",transition:"all 120ms ease",flexShrink:0},content:{display:"flex",alignItems:"flex-start",gap:"10px",padding:"10px 12px"},mascot:{width:"26px",height:"26px",borderRadius:"6px",objectFit:"contain",flexShrink:0,marginTop:"1px",filter:"drop-shadow(0 1px 2px rgba(0,0,0,0.4))"},textBlock:{flex:1,minWidth:0},title:{fontSize:"12px",fontWeight:600,color:t.textPrimary,lineHeight:1.3,marginBottom:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},body:{fontSize:"11px",color:t.textSecondary,lineHeight:1.4,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},progressTrack:{height:"2px",backgroundColor:t.bgPrimary},progressFill:{height:"100%",transformOrigin:"left",willChange:"transform"}},dr=3;let Ht=[];const Gn=new Set;function no(){Gn.forEach(n=>n())}function qo(n){return Gn.add(n),()=>{Gn.delete(n)}}function Uo(){return Ht}function pr(n){const o=`toast-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return Ht=[{id:o,title:n.title,body:n.body,priority:n.priority??"medium",category:n.category,timestamp:Date.now(),sessionId:n.sessionId,projectName:n.projectName,branchName:n.branchName},...Ht].slice(0,dr),no(),o}function Jo(n){Ht=Ht.filter(o=>o.id!==n),no()}function ur(){Ht=[],no()}const xt={push:pr,remove:Jo,clear:ur,subscribe:qo,getSnapshot:Uo};try{globalThis.__toastStore=xt}catch{}const xr={low:5e3,medium:6e3,high:8e3,critical:1e4};function gr({onFocusTerminal:n}={}){const o=a.useSyncExternalStore(qo,Uo),s=a.useRef(null),r=a.useCallback(l=>{Jo(l)},[]),i=a.useCallback(l=>{l.sessionId&&n&&n(l.sessionId)},[n]);return o.length===0?null:e.jsx("div",{ref:s,style:hr.container,children:o.map((l,c)=>e.jsx(cr,{toast:l,onDismiss:r,onClick:i,duration:xr[l.priority],index:c},l.id))})}const hr={container:{position:"fixed",top:"16px",right:"16px",zIndex:9999,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"}};function pt({content:n,className:o}){return e.jsx("div",{className:o,style:Ce.container,children:e.jsx(ks,{components:{h1:({children:s})=>e.jsx("h1",{style:Ce.h1,children:s}),h2:({children:s})=>e.jsx("h2",{style:Ce.h2,children:s}),h3:({children:s})=>e.jsx("h3",{style:Ce.h3,children:s}),h4:({children:s})=>e.jsx("h4",{style:Ce.h4,children:s}),p:({children:s})=>e.jsx("p",{style:Ce.p,children:s}),ul:({children:s})=>e.jsx("ul",{style:Ce.ul,children:s}),ol:({children:s})=>e.jsx("ol",{style:Ce.ol,children:s}),li:({children:s})=>e.jsx("li",{style:Ce.li,children:s}),code:({children:s,className:r})=>!r?e.jsx("code",{style:Ce.inlineCode,children:s}):e.jsx("code",{style:Ce.blockCode,children:s}),pre:({children:s})=>e.jsx("pre",{style:Ce.pre,children:s}),blockquote:({children:s})=>e.jsx("blockquote",{style:Ce.blockquote,children:s}),table:({children:s})=>e.jsx("table",{style:Ce.table,children:s}),thead:({children:s})=>e.jsx("thead",{style:Ce.thead,children:s}),tbody:({children:s})=>e.jsx("tbody",{children:s}),tr:({children:s})=>e.jsx("tr",{style:Ce.tr,children:s}),th:({children:s})=>e.jsx("th",{style:Ce.th,children:s}),td:({children:s})=>e.jsx("td",{style:Ce.td,children:s}),a:({children:s,href:r})=>e.jsx("a",{href:r,style:Ce.a,target:"_blank",rel:"noopener noreferrer",children:s}),strong:({children:s})=>e.jsx("strong",{style:Ce.strong,children:s}),em:({children:s})=>e.jsx("em",{style:Ce.em,children:s}),hr:()=>e.jsx("hr",{style:Ce.hr})},children:n})})}const Ce={container:{fontSize:"14px",lineHeight:1.6,color:t.textPrimary},h1:{fontSize:"24px",fontWeight:700,color:t.textPrimary,margin:"0 0 16px 0",paddingBottom:"8px",borderBottom:`1px solid ${t.borderSubtle}`},h2:{fontSize:"20px",fontWeight:600,color:t.textPrimary,margin:"24px 0 12px 0"},h3:{fontSize:"16px",fontWeight:600,color:t.textPrimary,margin:"20px 0 8px 0"},h4:{fontSize:"14px",fontWeight:600,color:t.textSecondary,margin:"16px 0 8px 0"},p:{margin:"0 0 12px 0"},ul:{margin:"0 0 12px 0",paddingLeft:"24px"},ol:{margin:"0 0 12px 0",paddingLeft:"24px"},li:{margin:"4px 0"},inlineCode:{backgroundColor:t.bgElevated,padding:"2px 6px",borderRadius:"4px",fontSize:"13px",fontFamily:"monospace",color:t.accent},blockCode:{display:"block",backgroundColor:t.bgPrimary,padding:"12px",borderRadius:"6px",fontSize:"13px",fontFamily:"monospace",color:t.textSecondary,overflow:"auto"},pre:{margin:"0 0 12px 0",backgroundColor:t.bgPrimary,borderRadius:"6px",overflow:"auto"},blockquote:{margin:"0 0 12px 0",paddingLeft:"16px",borderLeft:`3px solid ${t.accent}`,color:t.textSecondary,fontStyle:"italic"},table:{width:"100%",borderCollapse:"collapse",margin:"0 0 12px 0",fontSize:"13px"},thead:{backgroundColor:t.bgElevated},tr:{borderBottom:`1px solid ${t.borderSubtle}`},th:{padding:"8px 12px",textAlign:"left",fontWeight:600,color:t.textPrimary},td:{padding:"8px 12px",color:t.textSecondary},a:{color:t.accent,textDecoration:"none"},strong:{fontWeight:600,color:t.textPrimary},em:{fontStyle:"italic"},hr:{border:"none",borderTop:`1px solid ${t.borderSubtle}`,margin:"16px 0"}};function fr(){const[n,o]=a.useState(null),s=a.useCallback(c=>{o(c)},[]),r=a.useCallback(()=>{o(null)},[]),i=a.useCallback(c=>{o(p=>p?{...p,...c}:null)},[]),l=n?{...n,isOpen:!0,onClose:r}:null;return{openModal:s,closeModal:r,updateModal:i,modalProps:l}}const xo={plan:{bg:"rgba(52, 211, 153, 0.15)",fg:"#34D399"},agent:{bg:"rgba(255, 102, 0, 0.15)",fg:"#FF6600"},web:{bg:"rgba(96, 165, 250, 0.15)",fg:"#60A5FA"}};function mr({isOpen:n,onClose:o,title:s,badge:r,icon:i,subtitle:l,content:c,footerInfo:p,size:g="lg",loading:d=!1}){if(a.useEffect(()=>{if(!n)return;const m=x=>{x.key==="Escape"&&o()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n,o]),a.useEffect(()=>{if(!n)return;const m=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=m}},[n]),!n)return null;const h=r?xo[r.variant]||xo.agent:null,y=g==="lg"?"820px":"640px";return e.jsx("div",{style:qe.overlay,onClick:o,children:e.jsxs("div",{style:{...qe.modal,maxWidth:y},onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{style:qe.chromeBar,children:[e.jsxs("div",{style:qe.chromeLeft,children:[i&&e.jsx("span",{style:qe.chromeIcon,children:i}),e.jsx("span",{style:qe.chromeTitle,children:s}),r&&h&&e.jsx("span",{style:{...qe.chromeBadge,backgroundColor:h.bg,color:h.fg},children:r.label})]}),e.jsx("button",{type:"button",style:qe.closeButton,onClick:o,title:"Close (Esc)",children:e.jsx(st,{size:16})})]}),l&&e.jsx("div",{style:qe.subtitle,children:l}),e.jsx("div",{style:qe.contentArea,children:d?e.jsxs("div",{style:qe.loadingContainer,children:[e.jsx(Oe,{size:20,style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"Loading..."})]}):e.jsx(pt,{content:c})}),e.jsxs("div",{style:qe.footer,children:[p&&e.jsx("span",{style:qe.footerInfo,children:p}),e.jsx("span",{style:qe.footerHint,children:"Esc to close"})]})]})})}const qe={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"24px",backdropFilter:"blur(4px)",transition:"opacity 150ms ease"},modal:{width:"100%",maxHeight:"85vh",display:"flex",flexDirection:"column",backgroundColor:t.bgSecondary,borderRadius:"10px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden",boxShadow:"0 24px 48px rgba(0, 0, 0, 0.4)"},chromeBar:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:t.bgElevated,borderBottom:`1px solid ${t.borderSubtle}`,flexShrink:0},chromeLeft:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},chromeIcon:{display:"inline-flex",alignItems:"center",color:t.textMuted,flexShrink:0},chromeTitle:{fontSize:"14px",fontWeight:600,color:t.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},chromeBadge:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,flexShrink:0},closeButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"4px",backgroundColor:"transparent",border:"none",borderRadius:"4px",color:t.textMuted,cursor:"pointer",flexShrink:0,transition:"color 150ms ease"},subtitle:{padding:"8px 16px",fontSize:"12px",color:t.textSecondary,borderBottom:`1px solid ${t.borderSubtle}`,flexShrink:0},contentArea:{flex:1,overflow:"auto",padding:"20px 24px",minHeight:0},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"48px 0",color:t.textMuted,fontSize:"13px"},footer:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderTop:`1px solid ${t.borderSubtle}`,flexShrink:0},footerInfo:{fontSize:"11px",color:t.textMuted,fontFamily:"monospace"},footerHint:{fontSize:"11px",color:t.textMuted,marginLeft:"auto"}},Go="jacques-notification-history",Vo=50;let Ye=yr();const Vn=new Set;function Qt(){Vn.forEach(n=>n())}function en(){try{localStorage.setItem(Go,JSON.stringify(Ye))}catch{}}function yr(){try{const n=localStorage.getItem(Go);if(n){const o=JSON.parse(n);if(Array.isArray(o))return o.slice(0,Vo)}}catch{}return[]}function br(n){return Vn.add(n),()=>{Vn.delete(n)}}function jr(){return Ye}function Sr(n){const o={...n,read:n.read??!1};return Ye.some(s=>s.id===o.id)||(Ye=[o,...Ye].slice(0,Vo),en(),Qt()),o.id}function vr(n){Ye=Ye.map(o=>o.id===n?{...o,read:!0}:o),en(),Qt()}function wr(){Ye=Ye.map(n=>({...n,read:!0})),en(),Qt()}function kr(){Ye=[],en(),Qt()}function Cr(){return Ye.filter(n=>!n.read).length}function Ir(n){Ye=Ye.filter(o=>o.id!==n),en(),Qt()}const Pt={push:Sr,markRead:vr,markAllRead:wr,clear:kr,remove:Ir,getUnreadCount:Cr,subscribe:br,getSnapshot:jr},Tr={enabled:!1,categories:{context:!0,operation:!1,plan:!0,"auto-compact":!0,handoff:!0,"bug-alert":!1},largeOperationThreshold:5e4,contextThresholds:[50,70],bugAlertThreshold:5},zr={context:"Context",operation:"Operation",plan:"Plan","auto-compact":"Compact",handoff:"Handoff","bug-alert":"Bug Alert"},Rr={low:t.textMuted,medium:t.accent,high:t.warning,critical:t.danger};function Er({onFocusTerminal:n}={}){const[o,s]=a.useState(!1),r=a.useRef(null),i=a.useRef(null),l=a.useSyncExternalStore(Pt.subscribe,Pt.getSnapshot),c=l.filter(p=>!p.read).length;return a.useEffect(()=>{if(!o)return;function p(g){r.current&&!r.current.contains(g.target)&&i.current&&!i.current.contains(g.target)&&s(!1)}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[o]),e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{ref:i,onClick:()=>s(p=>!p),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"none",borderRadius:"6px",cursor:"pointer",transition:"all 150ms ease",flexShrink:0,backgroundColor:o?t.bgElevated:"transparent",color:o?t.accent:t.textMuted,position:"relative"},title:"Notification center",children:[e.jsx(Ao,{size:16}),c>0&&e.jsx("span",{style:He.badge,children:c>9?"9+":c})]}),o&&e.jsxs("div",{ref:r,style:He.panel,children:[e.jsxs("div",{style:He.panelHeader,children:[e.jsx("span",{style:He.panelTitle,children:"Notifications"}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[c>0&&e.jsx("button",{style:He.headerAction,onClick:()=>Pt.markAllRead(),title:"Mark all read",children:e.jsx(Dt,{size:12})}),l.length>0&&e.jsx("button",{style:He.headerAction,onClick:()=>Pt.clear(),title:"Clear all",children:e.jsx(_o,{size:12})}),e.jsx("button",{style:He.headerAction,onClick:()=>s(!1),title:"Close",children:e.jsx(st,{size:12})})]})]}),e.jsx("div",{style:He.list,children:l.length===0?e.jsx("div",{style:He.empty,children:"No notifications"}):l.map(p=>e.jsx($r,{notification:p,onClick:()=>{Pt.markRead(p.id),p.sessionId&&n&&n(p.sessionId)}},p.id))})]})]})}function $r({notification:n,onClick:o}){const s=Br(n.timestamp),r=!!n.projectName,i=r?n.projectName:n.title,l=r?n.branchName?`${n.branchName} · ${n.title}`:n.title:n.body;return e.jsxs("div",{style:{...He.row,opacity:n.read?.6:1,backgroundColor:n.read?"transparent":`${t.bgElevated}80`},onClick:o,children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",backgroundColor:Rr[n.priority],flexShrink:0,marginTop:5}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:He.rowHeader,children:[e.jsx("span",{style:He.rowTitle,children:i}),e.jsx("span",{style:He.rowCategory,children:zr[n.category]??n.category})]}),e.jsx("div",{style:He.rowBody,children:l}),e.jsx("div",{style:He.rowTime,children:s})]}),n.sessionId&&e.jsx("span",{style:{fontSize:10,color:t.textMuted,flexShrink:0,marginTop:4},title:"Click to focus terminal",children:"->"}),!n.read&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",backgroundColor:t.accent,flexShrink:0,marginTop:5}})]})}function Br(n){const o=Math.floor((Date.now()-n)/1e3);if(o<60)return"just now";const s=Math.floor(o/60);if(s<60)return`${s}m ago`;const r=Math.floor(s/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}const He={badge:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,borderRadius:7,backgroundColor:t.danger,color:"#fff",fontSize:9,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",padding:"0 3px",lineHeight:1},panel:{position:"absolute",bottom:40,left:0,width:320,maxHeight:400,backgroundColor:t.bgSecondary,border:`1px solid ${t.borderSubtle}`,borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",zIndex:100,display:"flex",flexDirection:"column",overflow:"hidden"},panelHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderBottom:`1px solid ${t.borderSubtle}`},panelTitle:{fontSize:13,fontWeight:600,color:t.textPrimary},headerAction:{display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,border:"none",borderRadius:4,cursor:"pointer",backgroundColor:"transparent",color:t.textMuted,transition:"all 150ms ease"},list:{flex:1,overflowY:"auto",maxHeight:350},empty:{padding:24,textAlign:"center",color:t.textMuted,fontSize:13},row:{display:"flex",gap:8,padding:"8px 12px",cursor:"pointer",borderBottom:`1px solid ${t.borderSubtle}20`,transition:"background-color 150ms ease"},rowHeader:{display:"flex",alignItems:"center",gap:6,marginBottom:2},rowTitle:{fontSize:12,fontWeight:600,color:t.textPrimary},rowCategory:{fontSize:10,color:t.textMuted,backgroundColor:t.bgElevated,padding:"1px 5px",borderRadius:3},rowBody:{fontSize:12,color:t.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},rowTime:{fontSize:10,color:t.textMuted,marginTop:2}};function Rn({checked:n,onChange:o,disabled:s=!1,size:r="md",label:i,description:l}){const c=r==="sm"?{track:{width:28,height:16},thumb:12}:{track:{width:36,height:20},thumb:16},p=()=>{s||o(!n)},g=d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),s||o(!n))};return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},onClick:p,children:[(i||l)&&e.jsxs("div",{style:{flex:1,minWidth:0},children:[i&&e.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:t.textPrimary},children:i}),l&&e.jsx("div",{style:{fontSize:"12px",color:t.textMuted,marginTop:"2px"},children:l})]}),e.jsx("div",{role:"switch","aria-checked":n,"aria-disabled":s,tabIndex:s?-1:0,onKeyDown:g,onClick:p,style:{position:"relative",width:c.track.width,height:c.track.height,borderRadius:c.track.height/2,backgroundColor:n?t.accent:t.bgInput,border:`1px solid ${n?t.accent:t.borderSubtle}`,cursor:s?"not-allowed":"pointer",transition:"background-color 150ms ease, border-color 150ms ease",flexShrink:0},children:e.jsx("div",{style:{position:"absolute",top:(c.track.height-c.thumb)/2-1,left:n?c.track.width-c.thumb-(c.track.height-c.thumb)/2-1:(c.track.height-c.thumb)/2-1,width:c.thumb,height:c.thumb,borderRadius:"50%",backgroundColor:"#ffffff",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",transition:"left 150ms ease"}})})]})}function zt({title:n,icon:o,description:s,badge:r,defaultExpanded:i=!1,children:l}){const[c,p]=a.useState(i);return e.jsxs("div",{style:it.container,children:[e.jsxs("button",{type:"button",style:it.header,onClick:()=>p(!c),children:[e.jsx("span",{style:{...it.chevron,transform:c?"rotate(90deg)":"none"},children:e.jsx(Fe,{size:16})}),e.jsxs("div",{style:it.headerContent,children:[e.jsxs("div",{style:it.titleRow,children:[o&&e.jsx("span",{style:it.icon,children:o}),e.jsx("span",{style:it.title,children:n}),r&&e.jsx("span",{style:it.badge,children:r})]}),s&&!c&&e.jsx("div",{style:it.description,children:s})]})]}),c&&e.jsx("div",{style:it.content,children:l})]})}const it={container:{backgroundColor:t.bgPrimary,border:`1px solid ${t.borderSubtle}`,borderRadius:"8px",overflow:"hidden"},header:{display:"flex",alignItems:"flex-start",gap:"10px",width:"100%",padding:"14px 16px",backgroundColor:t.bgSecondary,border:"none",cursor:"pointer",textAlign:"left",transition:"background-color 150ms ease"},chevron:{display:"inline-flex",alignItems:"center",justifyContent:"center",color:t.textMuted,transition:"transform 150ms ease",flexShrink:0,marginTop:"2px"},headerContent:{flex:1,minWidth:0},titleRow:{display:"flex",alignItems:"center",gap:"8px"},icon:{display:"inline-flex",alignItems:"center",justifyContent:"center",color:t.accent},title:{fontSize:"14px",fontWeight:600,color:t.textPrimary},badge:{marginLeft:"auto"},description:{fontSize:"12px",color:t.textMuted,marginTop:"4px"},content:{padding:"16px",borderTop:`1px solid ${t.borderSubtle}`,display:"flex",flexDirection:"column",gap:"16px"}};class Ko extends mn.Component{constructor(s){super(s);xe(this,"handleRetry",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){console.error("[Jacques] Render error caught by ErrorBoundary:",s,r)}render(){var s;return this.state.hasError?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",gap:"16px",color:t.textSecondary,fontFamily:"'JetBrains Mono', monospace",minHeight:this.props.level==="app"?"100vh":"200px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:600,color:t.danger},children:"Something went wrong"}),e.jsx("span",{style:{fontSize:"12px",color:t.textMuted,maxWidth:"400px",textAlign:"center",lineHeight:1.5},children:((s=this.state.error)==null?void 0:s.message)||"An unexpected error occurred"}),e.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 16px",borderRadius:"6px",border:`1px solid ${t.accent}`,backgroundColor:"transparent",color:t.accent,cursor:"pointer",fontSize:"12px",fontWeight:500,marginTop:"8px",fontFamily:"inherit"},children:"Try Again"}),this.props.level==="app"&&e.jsx("a",{href:"/",style:{fontSize:"11px",color:t.textMuted,textDecoration:"underline",marginTop:"4px"},children:"Return to Home"})]}):this.props.children}}function kt(n){return n.git_repo_root&&n.git_repo_root.split(/[\\/]/).pop()||n.project}function Mr({sessions:n,archivedProjects:o=[],discoveredProjects:s=[],selectedProject:r,onSelectProject:i,onLaunchSession:l,onHideProject:c}){const[p,g]=a.useState(!1),d=a.useMemo(()=>{const f=new Map;if(s.length>0)for(const u of s){const v=n.filter(z=>kt(z)===u.name);f.set(u.name,{name:u.name,sessionCount:v.length>0?v.length:u.sessionCount,isActive:v.length>0,lastActivity:v.length>0?Math.max(...v.map(z=>z.last_activity)):u.lastActivity?new Date(u.lastActivity).getTime():void 0,isGitProject:u.isGitProject,gitRepoRoot:u.gitRepoRoot,projectPaths:u.projectPaths})}else n.forEach(u=>{const v=kt(u)||"unknown",z=f.get(v);z?(z.sessionCount++,z.lastActivity=Math.max(z.lastActivity||0,u.last_activity)):f.set(v,{name:v,sessionCount:1,isActive:!0,lastActivity:u.last_activity})}),o.forEach(u=>{f.has(u)||f.set(u,{name:u,sessionCount:0,isActive:!1})});return Array.from(f.values()).sort((u,v)=>u.isActive&&!v.isActive?-1:!u.isActive&&v.isActive?1:u.lastActivity&&v.lastActivity?(v.lastActivity||0)-(u.lastActivity||0):u.lastActivity&&!v.lastActivity?-1:!u.lastActivity&&v.lastActivity?1:u.name.localeCompare(v.name))},[n,o,s]),h=d.filter(f=>f.isActive).length,y=r||"Select Project",m=f=>{i(f),g(!1)},x=(f,u)=>{f.stopPropagation(),c&&c(u.name)},b=(f,u)=>{var z;if(f.stopPropagation(),!l)return;const v=((z=u.projectPaths)==null?void 0:z[0])||u.gitRepoRoot;v&&l(v)};return e.jsxs("div",{style:we.container,children:[e.jsx("button",{type:"button",onClick:()=>g(!p),style:we.scopeButton,"aria-expanded":p,"aria-haspopup":"listbox",children:e.jsxs("div",{style:we.scopeContent,children:[e.jsx("span",{style:we.chevron,children:p?"▾":"▸"}),e.jsx("span",{style:we.scopeLabel,children:y})]})}),p&&e.jsxs("div",{style:we.dropdown,children:[h>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:we.sectionLabel,children:"ACTIVE"}),d.filter(f=>f.isActive).map(f=>e.jsxs("button",{type:"button",onClick:()=>m(f.name),style:{...we.projectItem,...r===f.name?we.projectItemSelected:{}},children:[e.jsx("span",{style:{...we.projectIndicator,color:t.success},children:r===f.name?"◉":"●"}),e.jsx("span",{style:we.projectName,children:f.name}),e.jsx("span",{style:we.sessionBadge,children:f.sessionCount}),l&&e.jsx("button",{type:"button",onClick:u=>b(u,f),style:we.launchButton,title:"Launch new session",children:e.jsx(Wt,{size:12})}),c&&e.jsx("button",{type:"button",onClick:u=>x(u,f),style:we.hideButton,title:"Hide project",children:e.jsx(st,{size:10})})]},f.name))]}),d.some(f=>!f.isActive)&&e.jsxs(e.Fragment,{children:[h>0&&e.jsx("div",{style:we.divider}),e.jsx("div",{style:{...we.sectionLabel,marginTop:h>0?"2px":"0"},children:"ARCHIVED"}),d.filter(f=>!f.isActive).map(f=>{var u;return e.jsxs("button",{type:"button",onClick:()=>m(f.name),style:{...we.projectItem,...r===f.name?we.projectItemSelected:{}},children:[e.jsx("span",{style:we.projectIndicator,children:r===f.name?"◉":"○"}),e.jsx("span",{style:{...we.projectName,color:t.textMuted},children:f.name}),e.jsx("span",{style:we.sessionBadge,children:f.sessionCount>0?f.sessionCount:"0"}),l&&(((u=f.projectPaths)==null?void 0:u[0])||f.gitRepoRoot)&&e.jsx("button",{type:"button",onClick:v=>b(v,f),style:we.launchButton,title:"Launch new session",children:e.jsx(Wt,{size:12})}),c&&e.jsx("button",{type:"button",onClick:v=>x(v,f),style:we.hideButton,title:"Hide project",children:e.jsx(st,{size:10})})]},f.name)})]}),d.length===0&&e.jsx("div",{style:we.emptyState,children:"No projects yet"})]})]})}const we={container:{position:"relative",padding:"0 8px",marginBottom:"8px"},scopeButton:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"10px 12px",backgroundColor:t.bgElevated,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",cursor:"pointer",transition:"all 150ms ease",textAlign:"left"},scopeContent:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:1},chevron:{color:t.textMuted,fontSize:"10px",width:"12px",flexShrink:0},scopeLabel:{fontSize:"13px",fontWeight:500,color:t.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},dropdown:{position:"absolute",top:"100%",left:"8px",right:"8px",marginTop:"4px",backgroundColor:t.bgSecondary,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",padding:"6px",zIndex:100,boxShadow:"0 8px 32px rgba(0, 0, 0, 0.4)",maxHeight:"300px",overflowY:"auto"},projectItem:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 10px",backgroundColor:"transparent",border:"none",borderRadius:"4px",cursor:"pointer",transition:"background-color 100ms ease",textAlign:"left"},projectItemSelected:{backgroundColor:t.bgElevated},projectIndicator:{fontSize:"8px",width:"16px",textAlign:"center",color:t.textMuted,flexShrink:0},projectName:{flex:1,fontSize:"13px",color:t.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sessionBadge:{fontSize:"11px",color:t.textMuted,flexShrink:0},launchButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",padding:0,backgroundColor:"transparent",border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",cursor:"pointer",color:t.textMuted,flexShrink:0,transition:"all 100ms ease"},hideButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",padding:0,backgroundColor:"transparent",border:"none",borderRadius:"3px",cursor:"pointer",color:t.textMuted,flexShrink:0,opacity:.5,transition:"all 100ms ease"},divider:{height:"1px",backgroundColor:t.borderSubtle,margin:"6px 0"},sectionLabel:{fontSize:"10px",fontWeight:600,color:t.textMuted,padding:"4px 10px",letterSpacing:"0.05em"},emptyState:{padding:"16px",textAlign:"center",fontSize:"13px",color:t.textMuted}},Lr="ws://localhost:4242";class Pr{constructor(){xe(this,"ws",null);xe(this,"reconnectAttempts",0);xe(this,"maxReconnectAttempts",10);xe(this,"reconnectTimeout",null);xe(this,"disposed",!1);xe(this,"onConnected");xe(this,"onDisconnected");xe(this,"onInitialState");xe(this,"onSessionUpdate");xe(this,"onSessionRemoved");xe(this,"onFocusChanged");xe(this,"onAutocompactToggled");xe(this,"onServerLog");xe(this,"onClaudeOperation");xe(this,"onApiLog");xe(this,"onHandoffReady");xe(this,"onChatDelta");xe(this,"onChatToolEvent");xe(this,"onChatComplete");xe(this,"onChatError");xe(this,"onCatalogUpdated");xe(this,"onNotificationFired");xe(this,"onSmartTileAddResult");xe(this,"onLaunchResult");xe(this,"onCreateWorktreeResult");xe(this,"onListWorktreesResult");xe(this,"onRemoveWorktreeResult")}connect(){if(!this.disposed){this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null);try{this.ws=new WebSocket(Lr),this.ws.onopen=()=>{var o;this.reconnectAttempts=0,(o=this.onConnected)==null||o.call(this)},this.ws.onclose=()=>{var o;(o=this.onDisconnected)==null||o.call(this),this.disposed||this.scheduleReconnect()},this.ws.onerror=()=>{},this.ws.onmessage=o=>{try{const s=JSON.parse(o.data);this.handleMessage(s)}catch{}}}catch{this.disposed||this.scheduleReconnect()}}}disconnect(){this.disposed=!0,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return;const o=Math.min(1e3*Math.pow(2,this.reconnectAttempts),3e4);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.connect()},o)}handleMessage(o){var s,r,i,l,c,p,g,d,h,y,m,x,b,f,u,v,z,I,P,k;switch(o.type){case"initial_state":(s=this.onInitialState)==null||s.call(this,o.sessions,o.focused_session_id);break;case"session_update":(r=this.onSessionUpdate)==null||r.call(this,o.session);break;case"session_removed":(i=this.onSessionRemoved)==null||i.call(this,o.session_id);break;case"focus_changed":(l=this.onFocusChanged)==null||l.call(this,o.session_id,o.session);break;case"autocompact_toggled":(c=this.onAutocompactToggled)==null||c.call(this,o.enabled);break;case"server_log":(p=this.onServerLog)==null||p.call(this,o);break;case"claude_operation":(g=this.onClaudeOperation)==null||g.call(this,o.operation);break;case"api_log":(d=this.onApiLog)==null||d.call(this,{method:o.method,path:o.path,status:o.status,durationMs:o.durationMs,timestamp:o.timestamp});break;case"handoff_ready":(h=this.onHandoffReady)==null||h.call(this,o.session_id,o.path);break;case"chat_delta":(y=this.onChatDelta)==null||y.call(this,o.projectPath,o.text);break;case"chat_tool_event":(m=this.onChatToolEvent)==null||m.call(this,o.projectPath,o.toolName);break;case"chat_complete":(x=this.onChatComplete)==null||x.call(this,o.projectPath,o.fullText,o.inputTokens,o.outputTokens);break;case"chat_error":(b=this.onChatError)==null||b.call(this,o.projectPath,o.reason,o.message);break;case"catalog_updated":(f=this.onCatalogUpdated)==null||f.call(this,o.projectPath,o.action,o.itemId);break;case"smart_tile_add_result":(u=this.onSmartTileAddResult)==null||u.call(this,o.success,o.repositioned,o.total_tiled,o.used_free_space,o.launch_method,o.error);break;case"launch_session_result":(v=this.onLaunchResult)==null||v.call(this,o.success,o.method,o.cwd,o.error);break;case"create_worktree_result":(z=this.onCreateWorktreeResult)==null||z.call(this,o.success,o.worktree_path,o.branch,o.session_launched,o.launch_method,o.error);break;case"list_worktrees_result":(I=this.onListWorktreesResult)==null||I.call(this,o.success,o.worktrees,o.error);break;case"remove_worktree_result":(P=this.onRemoveWorktreeResult)==null||P.call(this,o.success,o.worktree_path,o.branch_deleted,o.error);break;case"notification_fired":(k=this.onNotificationFired)==null||k.call(this,o.notification);break}}selectSession(o){this.send({type:"select_session",session_id:o})}triggerAction(o,s){this.send({type:"trigger_action",session_id:o,action:s})}toggleAutoCompact(){this.send({type:"toggle_autocompact"})}focusTerminal(o){this.send({type:"focus_terminal",session_id:o})}tileWindows(o,s){this.send({type:"tile_windows",session_ids:o,layout:s})}maximizeWindow(o){this.send({type:"maximize_window",session_id:o})}positionBrowserLayout(o,s){this.send({type:"position_browser_layout",session_ids:o,layout:s})}sendChatMessage(o,s){this.send({type:"chat_send",projectPath:o,message:s})}abortChat(o){this.send({type:"chat_abort",projectPath:o})}launchSession(o,s,r){this.send({type:"launch_session",cwd:o,preferred_terminal:s,dangerously_skip_permissions:r})}createWorktree(o,s,r,i){this.send({type:"create_worktree",repo_root:o,name:s,base_branch:r,dangerously_skip_permissions:i})}listWorktrees(o){this.send({type:"list_worktrees",repo_root:o})}removeWorktree(o,s,r,i){this.send({type:"remove_worktree",repo_root:o,worktree_path:s,force:r,delete_branch:i})}smartTileAdd(o,s,r){this.send({type:"smart_tile_add",launch_cwd:o,new_session_id:s,dangerously_skip_permissions:r})}send(o){var s;((s=this.ws)==null?void 0:s.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(o))}getIsConnected(){var o;return((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}}const go=100,ho=50,fo=100,Yo=a.createContext(null);function jn(){const n=a.useContext(Yo);if(!n)throw new Error("useJacquesClient must be used within JacquesClientProvider");return n}function Ar(){const[n,o]=a.useState([]),[s,r]=a.useState(null),[i,l]=a.useState(!1),[c,p]=a.useState(!1),[g,d]=a.useState(Date.now()),[h,y]=a.useState([]),[m,x]=a.useState([]),[b,f]=a.useState([]),[u,v]=a.useState(null),z=a.useRef({}),I=a.useRef(null),P=a.useRef(null),k=a.useRef(null),_=a.useRef(null);a.useEffect(()=>{if(_.current)return;const E=new Pr;return _.current=E,E.onConnected=()=>{l(!0),d(Date.now())},E.onDisconnected=()=>{l(!1),d(Date.now())},E.onInitialState=(j,R)=>{o(j),r(R),p(!0),d(Date.now())},E.onSessionUpdate=j=>{o(R=>{const H=R.findIndex(D=>D.session_id===j.session_id);let w;return H>=0?(w=[...R],w[H]=j):w=[...R,j],w.sort((D,Y)=>Y.last_activity-D.last_activity)}),d(Date.now())},E.onSessionRemoved=j=>{o(R=>R.filter(H=>H.session_id!==j)),r(R=>R===j?null:R),d(Date.now())},E.onFocusChanged=(j,R)=>{r(j),R&&o(H=>{const w=H.findIndex(D=>D.session_id===R.session_id);if(w>=0){const D=[...H];return D[w]=R,D.sort((Y,G)=>G.last_activity-Y.last_activity)}return[...H,R].sort((D,Y)=>Y.last_activity-D.last_activity)}),d(Date.now())},E.onAutocompactToggled=j=>{o(R=>R.map(H=>({...H,autocompact:H.autocompact?{...H.autocompact,enabled:j,bug_threshold:j?null:78}:{enabled:j,threshold:95,bug_threshold:j?null:78}}))),d(Date.now())},E.onServerLog=j=>{y(R=>{const H=[...R,j];return H.length>go?H.slice(-go):H})},E.onClaudeOperation=j=>{x(R=>{const H=[...R,j];return H.length>ho?H.slice(-ho):H})},E.onApiLog=j=>{f(R=>{const H=[...R,j];return H.length>fo?H.slice(-fo):H})},E.onHandoffReady=(j,R)=>{const H=R.split("/").pop()??"handoff";xt.push({title:"Handoff Ready",body:`Generated ${H}`,priority:"medium",category:"handoff"})},E.onNotificationFired=j=>{if(xt.push({title:j.title,body:j.body,priority:j.priority,category:j.category,sessionId:j.sessionId,projectName:j.projectName,branchName:j.branchName}),Pt.push({id:j.id,title:j.title,body:j.body,priority:j.priority,category:j.category,timestamp:j.timestamp,sessionId:j.sessionId,projectName:j.projectName,branchName:j.branchName}),typeof Notification<"u"&&Notification.permission==="granted"&&!document.hasFocus()){const R=j.projectName||j.title,H=j.projectName?j.branchName?`${j.branchName} · ${j.title}`:j.title:j.body;new Notification(R,{body:H,tag:`jacques-${j.category}-${j.id}`,icon:"/jacsub.png"})}},E.onChatDelta=(j,R)=>{var H,w;(w=(H=z.current).onChatDelta)==null||w.call(H,j,R)},E.onChatToolEvent=(j,R)=>{var H,w;(w=(H=z.current).onChatToolEvent)==null||w.call(H,j,R)},E.onChatComplete=(j,R,H,w)=>{var D,Y;(Y=(D=z.current).onChatComplete)==null||Y.call(D,j,R,H,w)},E.onChatError=(j,R,H)=>{var w,D;(D=(w=z.current).onChatError)==null||D.call(w,j,R,H)},E.onCatalogUpdated=(j,R,H)=>{var w,D;(D=(w=z.current).onCatalogUpdated)==null||D.call(w,j,R,H)},E.onSmartTileAddResult=(j,R,H,w,D,Y)=>{if(j){const G=w?"free-space":`grid (${H} tiled)`;xt.push({title:"Terminal Added",body:`${D||"terminal"} placed via ${G}${R>0?`, ${R} repositioned`:""}`,priority:"low",category:"handoff"})}else xt.push({title:"Smart Tile Failed",body:Y||"Could not add terminal to tile",priority:"high",category:"handoff"})},E.onLaunchResult=(j,R,H,w)=>{const D=H.split("/").pop()||H;j?xt.push({title:"Session Launched",body:`Opened ${R} in ${D}`,priority:"low",category:"handoff"}):xt.push({title:"Launch Failed",body:w||"Could not open terminal",priority:"high",category:"handoff"})},E.onCreateWorktreeResult=(j,R,H,w,D,Y)=>{var G;(G=I.current)==null||G.call(I,j,R,H,w,D,Y)},E.onListWorktreesResult=(j,R,H)=>{var w;(w=P.current)==null||w.call(P,j,R,H)},E.onRemoveWorktreeResult=(j,R,H,w)=>{var D;(D=k.current)==null||D.call(k,j,R,H,w)},E.connect(),v(E),()=>{E.disconnect(),_.current=null}},[]);const B=a.useCallback(E=>{u==null||u.selectSession(E)},[u]),W=a.useCallback((E,j)=>{u==null||u.triggerAction(E,j)},[u]),O=a.useCallback(()=>{u==null||u.toggleAutoCompact()},[u]),M=a.useCallback(E=>{u==null||u.focusTerminal(E)},[u]),$=a.useCallback((E,j)=>{u==null||u.tileWindows(E,j)},[u]),C=a.useCallback(E=>{u==null||u.maximizeWindow(E)},[u]),T=a.useCallback((E,j)=>{u==null||u.positionBrowserLayout(E,j)},[u]),S=a.useCallback((E,j)=>{u==null||u.sendChatMessage(E,j)},[u]),F=a.useCallback(E=>{u==null||u.abortChat(E)},[u]),J=a.useCallback((E,j,R)=>{u==null||u.smartTileAdd(E,j,R)},[u]),K=a.useCallback((E,j,R)=>{u==null||u.launchSession(E,j,R)},[u]),re=a.useCallback((E,j,R,H)=>{u==null||u.createWorktree(E,j,R,H)},[u]),U=a.useCallback(E=>{I.current=E},[]),Z=a.useCallback(E=>{u==null||u.listWorktrees(E)},[u]),q=a.useCallback((E,j,R,H)=>{u==null||u.removeWorktree(E,j,R,H)},[u]),X=a.useCallback(E=>{P.current=E},[]),Q=a.useCallback(E=>{k.current=E},[]),V=a.useCallback(E=>{z.current=E},[]);return{sessions:n,focusedSessionId:s,connected:i,initialStateReceived:c,lastUpdate:g,serverLogs:h,claudeOperations:m,apiLogs:b,selectSession:B,triggerAction:W,toggleAutoCompact:O,focusTerminal:M,tileWindows:$,maximizeWindow:C,positionBrowserLayout:T,smartTileAdd:J,launchSession:K,createWorktree:re,onCreateWorktreeResult:U,listWorktrees:Z,removeWorktree:q,onListWorktreesResult:X,onRemoveWorktreeResult:Q,sendChatMessage:S,abortChat:F,setChatCallbacks:V}}function _r({children:n}){const o=Ar();return mn.createElement(Yo.Provider,{value:o},n)}const me="/api";function Fr(n,o,s){let r=!1;const i=new URL(`${me}${n}`,window.location.origin);if(s!=null&&s.queryParams)for(const[c,p]of Object.entries(s.queryParams))i.searchParams.set(c,p);const l=s==null?void 0:s.errorPrefix;return fetch(i.toString(),{method:"POST"}).then(async c=>{var h,y,m,x,b,f;if(!c.ok){(h=o.onError)==null||h.call(o,`${l}: ${c.statusText}`);return}const p=(y=c.body)==null?void 0:y.getReader();if(!p){(m=o.onError)==null||m.call(o,"No response body");return}const g=new TextDecoder;let d="";for(;!r;){const{done:u,value:v}=await p.read();if(u)break;d+=g.decode(v,{stream:!0});const z=d.split(`
35
+ `);d=z.pop()||"";let I="";for(const P of z)if(P.startsWith("event: "))I=P.slice(7);else if(P.startsWith("data: ")){let k;try{k=JSON.parse(P.slice(6))}catch{console.warn("[Jacques SSE] Malformed data, skipping:",P.slice(6,100));continue}I==="progress"?(x=o.onProgress)==null||x.call(o,k):I==="complete"?(b=o.onComplete)==null||b.call(o,k):I==="error"&&((f=o.onError)==null||f.call(o,k.error))}}}).catch(c=>{var p;r||(p=o.onError)==null||p.call(o,c.message)}),{abort:()=>{r=!0}}}async function Xo(){const n=await fetch(`${me}/sources/status`);if(!n.ok)throw new Error(`Failed to get sources status: ${n.statusText}`);return n.json()}async function Dr(n){const o=await fetch(`${me}/sources/google`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){const s=await o.json();throw new Error(s.error||`Failed to configure Google Docs: ${o.statusText}`)}}async function Wr(n){const o=await fetch(`${me}/sources/notion`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){const s=await o.json();throw new Error(s.error||`Failed to configure Notion: ${o.statusText}`)}}async function mo(){const n=await fetch(`${me}/config/root-path`);if(!n.ok)throw new Error(`Failed to get root path: ${n.statusText}`);return n.json()}async function Nr(n){const o=await fetch(`${me}/config/root-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});if(!o.ok){const s=await o.json();throw new Error(s.error||`Failed to set root path: ${o.statusText}`)}}async function Hr(){const n=await fetch(`${me}/sessions/stats`);if(!n.ok)throw new Error(`Failed to get session stats: ${n.statusText}`);return n.json()}async function oo(){const n=await fetch(`${me}/sessions/by-project`);if(!n.ok)throw new Error(`Failed to list sessions: ${n.statusText}`);return n.json()}async function Or(){const n=await fetch(`${me}/projects`);if(!n.ok)throw new Error(`Failed to list projects: ${n.statusText}`);return n.json()}async function qr(n){const o=await fetch(`${me}/projects/${encodeURIComponent(n)}`,{method:"DELETE"});if(!o.ok)throw new Error(`Failed to hide project: ${o.statusText}`)}async function Zo(n){const o=await fetch(`${me}/sessions/${n}`);if(!o.ok)throw o.status===404?new Error("Session not found"):new Error(`Failed to get session: ${o.statusText}`);return o.json()}async function Sn(n,o){const s=await fetch(`${me}/sessions/${n}/subagents/${o}`);if(!s.ok)throw s.status===404?new Error("Subagent not found"):new Error(`Failed to get subagent: ${s.statusText}`);return s.json()}async function Qo(n,o){const s=await fetch(`${me}/sessions/${n}/plans/${o}`);if(!s.ok)throw s.status===404?new Error("Plan not found"):new Error(`Failed to get plan: ${s.statusText}`);return s.json()}async function Ur(n){const o=await fetch(`${me}/sessions/${n}/web-searches`);if(!o.ok)throw o.status===404?new Error("Session not found"):new Error(`Failed to get web searches: ${o.statusText}`);return o.json()}async function Jr(n){const o=await fetch(`${me}/sessions/${n}/badges`);if(!o.ok)throw o.status===404?new Error("Session not found"):new Error(`Failed to get session badges: ${o.statusText}`);return o.json()}async function gn(n){const o=await fetch(`${me}/sessions/${n}/tasks`);if(!o.ok)throw o.status===404?new Error("Session not found"):new Error(`Failed to get session tasks: ${o.statusText}`);return o.json()}async function Gr(n,o){const s=await fetch(`${me}/projects/${encodeURIComponent(n)}/plans/${encodeURIComponent(o)}/content`);if(!s.ok)throw s.status===404?new Error("Plan not found"):new Error(`Failed to get plan content: ${s.statusText}`);return s.json()}async function Vr(n){const o=await fetch(`${me}/projects/${encodeURIComponent(n)}/catalog`);if(!o.ok)throw new Error(`Failed to get catalog: ${o.statusText}`);return o.json()}async function Kr(n,o){const s=await fetch(`${me}/projects/${encodeURIComponent(n)}/context/${encodeURIComponent(o)}/content`);if(!s.ok)throw new Error(`Failed to get context file: ${s.statusText}`);return s.json()}function es(n,o={}){return Fr("/sync",n,{queryParams:o.force?{force:"true"}:void 0,errorPrefix:"Failed to sync"})}async function Yr(n){const o=await fetch(`${me}/projects/${encodeURIComponent(n)}/handoffs`);if(!o.ok)throw new Error(`Failed to list handoffs: ${o.statusText}`);return o.json()}async function Xr(n,o){const s=await fetch(`${me}/projects/${encodeURIComponent(n)}/handoffs/${encodeURIComponent(o)}/content`);if(!s.ok)throw s.status===404?new Error("Handoff not found"):new Error(`Failed to get handoff content: ${s.statusText}`);return s.json()}async function Zr(){try{const n=await fetch(`${me}/usage`);return n.ok?n.json():null}catch{return null}}async function Qr(){const n=await fetch(`${me}/notifications/settings`);if(!n.ok)throw new Error(`Failed to get notification settings: ${n.statusText}`);return n.json()}async function yo(n){const o=await fetch(`${me}/notifications/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok)throw new Error(`Failed to update notification settings: ${o.statusText}`);return o.json()}const ts=a.createContext(null);function ei({children:n}){const[o,s]=a.useState(null),[r,i]=a.useState([]),[l,c]=a.useState([]),p=a.useCallback(h=>o===null?h:h.filter(y=>kt(y)===o),[o]),g=a.useCallback(async()=>{try{const{projects:h}=await Or();c(h)}catch{}},[]);a.useEffect(()=>{g()},[g]);const d=a.useMemo(()=>({selectedProject:o,setSelectedProject:s,filterSessions:p,archivedProjects:r,setArchivedProjects:i,discoveredProjects:l,refreshProjects:g}),[o,p,r,l,g]);return e.jsx(ts.Provider,{value:d,children:n})}function wt(){const n=a.useContext(ts);if(!n)throw new Error("useProjectScope must be used within a ProjectScopeProvider");return n}const ti="jacques:";function ns(n){return`${ti}${n}`}function Kn(n,o){try{const s=localStorage.getItem(ns(n));return s===null?o:JSON.parse(s)}catch{return o}}function Xt(n,o){const s=ns(n),[r,i]=a.useState(()=>Kn(n,o)),l=a.useCallback(c=>{i(c),localStorage.setItem(s,JSON.stringify(c))},[s]);return a.useEffect(()=>{const c=p=>{if(p.key===s&&p.newValue!==null)try{i(JSON.parse(p.newValue))}catch{}};return window.addEventListener("storage",c),()=>window.removeEventListener("storage",c)},[s]),[r,l]}const En=250,$n=60,ni=600,oi=40;function rn({text:n,maxLength:o=200}){const[s,r]=a.useState(!1);return n.length>o?e.jsxs("span",{onClick:l=>{l.stopPropagation(),r(!s)},style:{cursor:"pointer",wordBreak:"break-word"},title:s?"Click to collapse":"Click to expand",children:[s?n:n.substring(0,o),e.jsx("span",{style:{color:t.accent,marginLeft:"4px",fontWeight:500},children:s?" ◂ less":"… more ▸"})]}):e.jsx("span",{children:n})}function Je(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}k`:n.toString()}function an(n){return n>=6e4?`${(n/6e4).toFixed(1)}m`:n>=1e3?`${(n/1e3).toFixed(1)}s`:`${n}ms`}function Rt(n){return(typeof n=="string"?new Date(n):new Date(n)).toLocaleTimeString("en-US",{hour12:!1})}function bo(n){return n>=500?t.danger:n>=400?t.warning:n>=200&&n<300?t.success:t.textMuted}function si({serverLogs:n,apiLogs:o,claudeOperations:s,maxLogs:r=100}){const[i,l]=a.useState("server"),[c,p]=a.useState(!0),g=a.useRef(null),[d,h]=a.useState(null),[y,m]=a.useState(null),[x,b]=Xt("logPanelHeight",En),[f,u]=a.useState(!1),v=a.useRef(0),z=a.useRef(0),I=x>oi+20,P=a.useCallback(w=>{if(!f)return;const D=v.current-w.clientY,Y=Math.min(ni,Math.max($n,z.current+D));b(Y)},[f]),k=a.useCallback(()=>{u(!1)},[]);a.useEffect(()=>(f&&(document.addEventListener("mousemove",P),document.addEventListener("mouseup",k),document.body.style.cursor="row-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",k),document.body.style.cursor="",document.body.style.userSelect=""}),[f,P,k]);const _=w=>{w.preventDefault(),v.current=w.clientY,z.current=x,u(!0)},B=()=>{b(I?$n:En)},W=async w=>{m(w);try{const D=await fetch(`${me}/claude/operations/${w}/debug`);if(D.ok){const Y=await D.json();h(Y)}else console.error("Failed to fetch debug data")}catch(D){console.error("Error fetching debug data:",D)}finally{m(null)}};a.useEffect(()=>{c&&g.current&&I&&(g.current.scrollTop=g.current.scrollHeight)},[n,o,s,c,I,i]);const O=()=>{if(g.current){const{scrollTop:w,scrollHeight:D,clientHeight:Y}=g.current,G=D-w-Y<10;p(G)}},M=n.slice(-r),$=o.slice(-r),C=s.slice(-50),T=M.filter(w=>w.level==="error").length,S=M.filter(w=>w.level==="warn").length,F=$.filter(w=>w.status>=400).length,J=C.filter(w=>!w.success).length,K=w=>{switch(w){case"error":return t.danger;case"warn":return t.warning;default:return t.textMuted}},re=w=>{switch(w){case"error":return"✕";case"warn":return"⚠";default:return"●"}},U=w=>{switch(w){case"all":return t.textPrimary;case"server":return t.textSecondary;case"api":return t.success;case"claude":return t.accent}},Z=w=>{switch(w){case"all":return M.length+$.length+C.length;case"server":return M.length;case"api":return $.length;case"claude":return C.length}},q=w=>{const D=T+F+J;switch(w){case"all":return D>0?{count:D,color:t.danger}:S>0?{count:S,color:t.warning}:null;case"server":return T>0?{count:T,color:t.danger}:S>0?{count:S,color:t.warning}:null;case"api":return F>0?{count:F,color:t.warning}:null;case"claude":return J>0?{count:J,color:t.danger}:null}},X=()=>e.jsx(e.Fragment,{children:M.length===0?e.jsx("div",{style:L.emptyState,children:"No server logs yet"}):M.map((w,D)=>e.jsxs("div",{style:L.logEntry,children:[e.jsx("span",{style:L.timestamp,children:Rt(w.timestamp)}),e.jsx("span",{style:{...L.levelIcon,color:K(w.level)},children:re(w.level)}),e.jsxs("span",{style:L.source,children:["[",w.source,"]"]}),e.jsx("span",{style:{...L.message,color:K(w.level)},children:e.jsx(rn,{text:w.message.replace(/^\[[^\]]+\]\s*/,""),maxLength:200})})]},D))}),Q=()=>e.jsx(e.Fragment,{children:$.length===0?e.jsx("div",{style:L.emptyState,children:"No API requests yet"}):$.map((w,D)=>e.jsxs("div",{style:L.logEntry,children:[e.jsx("span",{style:L.timestamp,children:Rt(w.timestamp)}),e.jsx("span",{style:{...L.method,color:t.success},children:w.method}),e.jsx("span",{style:L.path,children:w.path}),e.jsx("span",{style:{...L.status,color:bo(w.status)},children:w.status}),e.jsx("span",{style:L.duration,children:an(w.durationMs)})]},D))}),V=()=>e.jsx(e.Fragment,{children:C.length===0?e.jsx("div",{style:L.emptyState,children:"No Claude operations yet"}):C.map((w,D)=>{const Y=w.phase==="start",G=(w.userPromptTokensEst||0)+(w.systemPromptTokensEst||0),de=w.inputTokens>0?w.inputTokens-G:0;return e.jsxs("div",{style:L.claudeEntry,children:[e.jsxs("div",{style:L.logEntry,children:[e.jsx("span",{style:L.timestamp,children:Rt(w.timestamp)}),e.jsx("span",{style:{...L.tag,backgroundColor:Y?`${t.warning}30`:`${t.accent}30`,color:Y?t.warning:t.accent},children:Y?"start":"done"}),e.jsx("span",{style:{...L.operation,color:t.accent},children:w.operation}),Y?e.jsxs("span",{style:L.tokens,children:["est: ",Je(w.userPromptTokensEst||0)," user + ",Je(w.systemPromptTokensEst||0)," system = ",Je(G)]}):e.jsxs("span",{style:L.tokens,children:[Je(w.inputTokens)," in → ",Je(w.outputTokens)," out",de>1e3&&e.jsxs("span",{style:{color:t.warning,marginLeft:"8px"},children:["(overhead: ",Je(de),")"]})]}),!Y&&e.jsx("span",{style:L.duration,children:an(w.durationMs)}),e.jsx("span",{style:{...L.statusIndicator,color:w.success?t.success:t.danger},children:Y?"⋯":w.success?"✓":"✕"})]}),Y&&w.userPromptPreview&&e.jsxs("div",{style:L.detailRow,children:[e.jsx("span",{style:L.detailLabel,children:"prompt:"}),e.jsx("span",{style:L.detailValue,children:e.jsx(rn,{text:w.userPromptPreview,maxLength:150})})]}),!Y&&w.inputTokens>0&&e.jsxs("div",{style:L.detailRow,children:[e.jsx("span",{style:L.detailLabel,children:"breakdown:"}),e.jsxs("span",{style:L.detailValue,children:["user ~",Je(w.userPromptTokensEst||0)," + system ~",Je(w.systemPromptTokensEst||0)," +",e.jsxs("span",{style:{color:de>1e4?t.danger:t.warning},children:["claude overhead ~",Je(de)]})," ","= ",Je(w.inputTokens)," actual"]})]}),!Y&&w.toolsCalled&&w.toolsCalled.length>0&&e.jsxs("div",{style:L.detailRow,children:[e.jsx("span",{style:L.detailLabel,children:"tools:"}),e.jsxs("span",{style:L.detailValue,children:[w.toolsCalled.map((Le,kn)=>{const tn=Le!=="Write";return e.jsxs("span",{children:[kn>0&&" → ",e.jsx("span",{style:{color:tn?t.warning:t.success,fontWeight:tn?600:400},children:Le})]},Le)}),w.toolsCalled.some(Le=>Le!=="Write")&&e.jsx("span",{style:{color:t.warning,marginLeft:"8px"},title:"Non-Write tools indicate prompt needs optimization",children:"⚠ extra tools used"})]})]}),w.errorMessage&&e.jsxs("div",{style:L.detailRow,children:[e.jsx("span",{style:L.detailLabel,children:"error:"}),e.jsx("span",{style:{...L.detailValue,color:t.danger},children:e.jsx(rn,{text:w.errorMessage,maxLength:150})})]}),!Y&&e.jsx("div",{style:L.detailRow,children:e.jsx("button",{style:L.viewDetailsButton,onClick:()=>W(w.id),disabled:y===w.id,children:y===w.id?"Loading...":"View Full Details"})})]},`claude-${D}`)})}),E=()=>{if(!d)return null;const w=d.cliEvents||[],D=[];for(const Y of w){const G=Y;if(G.type==="stream_event"){const de=G.event;if((de==null?void 0:de.type)==="content_block_start"){const Le=de.content_block;(Le==null?void 0:Le.type)==="tool_use"&&Le.name&&D.push({name:Le.name,inputPreview:JSON.stringify(Le.input||{}).substring(0,100)})}}}return e.jsxs("div",{style:L.debugPanel,children:[e.jsxs("div",{style:L.debugHeader,children:[e.jsxs("span",{style:L.debugTitle,children:["Operation Details: ",d.operationId.substring(0,8),"..."]}),e.jsx("button",{style:L.closeButton,onClick:()=>h(null),children:"×"})]}),e.jsxs("div",{style:L.debugContent,children:[e.jsxs("div",{style:L.debugSection,children:[e.jsx("div",{style:L.debugSectionTitle,children:"Summary"}),e.jsxs("div",{style:L.debugText,children:["CLI args: ",d.cliArgs.join(" ").substring(0,100),"..."]}),e.jsxs("div",{style:L.debugText,children:["Events received: ",w.length]}),D.length>0&&e.jsxs("div",{style:L.debugText,children:["Tools used: ",D.map(Y=>Y.name).join(", ")]})]}),e.jsxs("div",{style:L.debugSection,children:[e.jsxs("div",{style:L.debugSectionTitle,children:["User Prompt (",d.userPrompt.length," chars, ~",Math.ceil(d.userPrompt.length/4)," tokens est)"]}),e.jsx("pre",{style:L.debugPre,children:d.userPrompt})]}),e.jsxs("div",{style:L.debugSection,children:[e.jsxs("div",{style:L.debugSectionTitle,children:["System Prompt (",d.systemPrompt.length," chars, ~",Math.ceil(d.systemPrompt.length/4)," tokens est)"]}),e.jsx("pre",{style:L.debugPre,children:d.systemPrompt})]}),d.response&&e.jsxs("div",{style:L.debugSection,children:[e.jsxs("div",{style:L.debugSectionTitle,children:["Response (",d.response.length," chars)"]}),e.jsx("pre",{style:L.debugPre,children:d.response})]}),e.jsxs("div",{style:L.debugSection,children:[e.jsxs("div",{style:L.debugSectionTitle,children:["Raw CLI Events (",w.length,")"]}),e.jsx("pre",{style:L.debugPre,children:JSON.stringify(w,null,2)})]})]})]})},j=()=>{const w=[...M.map(D=>({type:"server",timestamp:D.timestamp,data:D})),...$.map(D=>({type:"api",timestamp:D.timestamp,data:D})),...C.map(D=>({type:"claude",timestamp:new Date(D.timestamp).getTime(),data:D}))].sort((D,Y)=>D.timestamp-Y.timestamp);return w.length===0?e.jsx("div",{style:L.emptyState,children:"No logs yet"}):w.map((D,Y)=>{if(D.type==="server"){const G=D.data;return e.jsxs("div",{style:L.logEntry,children:[e.jsx("span",{style:L.timestamp,children:Rt(G.timestamp)}),e.jsx("span",{style:{...L.tag,backgroundColor:`${t.textSecondary}30`,color:t.textSecondary},children:"server"}),e.jsx("span",{style:{...L.levelIcon,color:K(G.level)},children:re(G.level)}),e.jsxs("span",{style:L.source,children:["[",G.source,"]"]}),e.jsx("span",{style:{...L.message,color:K(G.level)},children:e.jsx(rn,{text:G.message.replace(/^\[[^\]]+\]\s*/,""),maxLength:200})})]},`all-server-${Y}`)}else if(D.type==="api"){const G=D.data;return e.jsxs("div",{style:L.logEntry,children:[e.jsx("span",{style:L.timestamp,children:Rt(G.timestamp)}),e.jsx("span",{style:{...L.tag,backgroundColor:`${t.success}30`,color:t.success},children:"api"}),e.jsx("span",{style:{...L.method,color:t.success},children:G.method}),e.jsx("span",{style:L.path,children:G.path}),e.jsx("span",{style:{...L.status,color:bo(G.status)},children:G.status}),e.jsx("span",{style:L.duration,children:an(G.durationMs)})]},`all-api-${Y}`)}else{const G=D.data,de=G.phase==="start",Le=(G.userPromptTokensEst||0)+(G.systemPromptTokensEst||0);return e.jsxs("div",{style:L.logEntry,children:[e.jsx("span",{style:L.timestamp,children:Rt(G.timestamp)}),e.jsx("span",{style:{...L.tag,backgroundColor:de?`${t.warning}30`:`${t.accent}30`,color:de?t.warning:t.accent},children:de?"start":"done"}),e.jsx("span",{style:{...L.operation,color:t.accent},children:G.operation}),de?e.jsxs("span",{style:L.tokens,children:["est: ",Je(Le)]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:L.tokens,children:[Je(G.inputTokens)," in → ",Je(G.outputTokens)," out"]}),e.jsx("span",{style:L.duration,children:an(G.durationMs)})]}),e.jsx("span",{style:{...L.statusIndicator,color:G.success?t.success:t.danger},children:de?"⋯":G.success?"✓":"✕"})]},`all-claude-${Y}`)}})},R=()=>{switch(i){case"all":return j();case"server":return X();case"api":return Q();case"claude":return V()}},H=()=>{b(I?$n:En)};return e.jsxs("div",{style:{...L.container,height:x},children:[e.jsx("div",{style:{...L.resizeHandle,backgroundColor:f?`${t.accent}30`:void 0},onMouseDown:_,onDoubleClick:B,onMouseEnter:w=>{w.currentTarget.style.backgroundColor=`${t.accent}20`},onMouseLeave:w=>{f||(w.currentTarget.style.backgroundColor="transparent")},title:"Drag to resize, double-click to toggle",children:e.jsxs("div",{style:L.resizeGrip,children:[e.jsx("div",{style:L.resizeGripBar}),e.jsx("div",{style:L.resizeGripBar})]})}),e.jsxs("div",{style:L.header,onClick:H,children:[e.jsx("div",{style:L.tabs,onClick:w=>w.stopPropagation(),children:["all","server","api","claude"].map(w=>{const D=i===w,Y=q(w);return e.jsxs("button",{style:{...L.tab,...D&&{backgroundColor:t.bgElevated,color:U(w),borderBottom:`2px solid ${U(w)}`}},onClick:()=>l(w),children:[e.jsx("span",{style:{color:D?U(w):t.textSecondary,textTransform:"capitalize"},children:w}),!I&&e.jsxs("span",{style:L.tabCount,children:["(",Z(w),")"]}),Y&&e.jsx("span",{style:{...L.badge,backgroundColor:`${Y.color}30`,color:Y.color},children:Y.count})]},w)})}),e.jsx("div",{style:L.expandArea,children:e.jsx("span",{style:L.expandText,children:I?"▾ collapse":"▴ expand"})})]}),I&&e.jsx("div",{ref:g,style:L.logContainer,onScroll:O,children:R()}),I&&!c&&e.jsx("button",{style:L.scrollButton,onClick:()=>{p(!0),g.current&&(g.current.scrollTop=g.current.scrollHeight)},children:"↓ Scroll to bottom"}),d&&E()]})}const L={container:{position:"absolute",bottom:0,left:0,right:0,zIndex:100,backgroundColor:t.bgSecondary,borderTop:`2px solid ${t.borderSubtle}`,boxShadow:"0 -4px 12px rgba(0, 0, 0, 0.15)",display:"flex",flexDirection:"column",transition:"height 150ms ease"},resizeHandle:{position:"absolute",top:-8,left:0,right:0,height:"16px",cursor:"row-resize",backgroundColor:"transparent",zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 150ms ease"},resizeGrip:{display:"flex",flexDirection:"column",gap:"2px",padding:"4px 30px",backgroundColor:t.bgSecondary,borderRadius:"4px 4px 0 0",border:`1px solid ${t.borderSubtle}`,borderBottom:"none"},resizeGripBar:{width:"50px",height:"3px",backgroundColor:t.textMuted,borderRadius:"2px",opacity:.6},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 16px",borderBottom:`1px solid ${t.borderSubtle}`,cursor:"pointer",userSelect:"none"},tabs:{display:"flex",gap:"0"},tab:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 12px",background:"none",border:"none",borderBottom:"2px solid transparent",cursor:"pointer",fontSize:"12px",fontWeight:500,color:t.textSecondary,transition:"all 150ms ease"},tabCount:{fontSize:"11px",color:t.textMuted},badge:{fontSize:"10px",padding:"1px 6px",borderRadius:"8px",fontWeight:600},expandArea:{flex:1,display:"flex",justifyContent:"flex-end",padding:"8px 0"},expandText:{fontSize:"11px",color:t.textMuted},logContainer:{flex:1,overflowY:"auto",padding:"8px 16px",fontFamily:"monospace",fontSize:"12px",backgroundColor:t.bgPrimary,minHeight:0},tag:{fontSize:"10px",padding:"1px 6px",borderRadius:"4px",fontWeight:500,flexShrink:0},emptyState:{color:t.textMuted,textAlign:"center",padding:"16px"},logEntry:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"2px 0",lineHeight:1.4},timestamp:{color:t.textMuted,flexShrink:0,minWidth:"70px"},levelIcon:{flexShrink:0,width:"12px",textAlign:"center"},source:{color:t.textSecondary,flexShrink:0},message:{color:t.textPrimary,wordBreak:"break-word"},method:{flexShrink:0,fontWeight:600,minWidth:"48px"},path:{color:t.textPrimary,flexGrow:1,wordBreak:"break-word"},status:{flexShrink:0,fontWeight:500,minWidth:"32px",textAlign:"right"},duration:{color:t.textMuted,flexShrink:0,minWidth:"50px",textAlign:"right"},operation:{flexShrink:0,fontWeight:500,minWidth:"90px"},tokens:{color:t.textSecondary,flexShrink:0,minWidth:"140px"},statusIndicator:{flexShrink:0,fontWeight:600,width:"16px",textAlign:"center"},claudeEntry:{marginBottom:"4px",paddingBottom:"4px",borderBottom:`1px solid ${t.borderSubtle}`},detailRow:{display:"flex",alignItems:"flex-start",gap:"8px",paddingLeft:"78px",fontSize:"11px",marginTop:"2px"},detailLabel:{color:t.textMuted,flexShrink:0,minWidth:"70px"},detailValue:{color:t.textSecondary,wordBreak:"break-word",fontFamily:"monospace"},scrollButton:{position:"absolute",bottom:"60px",left:"50%",transform:"translateX(-50%)",padding:"4px 12px",fontSize:"11px",backgroundColor:t.accent,color:t.textPrimary,border:"none",borderRadius:"12px",cursor:"pointer",zIndex:11},viewDetailsButton:{padding:"4px 8px",fontSize:"11px",backgroundColor:t.bgElevated,color:t.accent,border:`1px solid ${t.accent}`,borderRadius:"4px",cursor:"pointer"},debugPanel:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:t.bgPrimary,display:"flex",flexDirection:"column",zIndex:1002},debugHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",backgroundColor:t.bgSecondary,borderBottom:`1px solid ${t.borderSubtle}`},debugTitle:{fontSize:"14px",fontWeight:600,color:t.accent},closeButton:{padding:"4px 8px",fontSize:"16px",backgroundColor:"transparent",color:t.textSecondary,border:"none",cursor:"pointer"},debugContent:{flex:1,overflowY:"auto",padding:"16px"},debugSection:{marginBottom:"16px"},debugSectionTitle:{fontSize:"12px",fontWeight:600,color:t.textSecondary,marginBottom:"8px",textTransform:"uppercase",letterSpacing:"0.05em"},debugText:{fontSize:"12px",color:t.textPrimary,marginBottom:"4px"},debugPre:{fontFamily:"monospace",fontSize:"11px",backgroundColor:t.bgSecondary,padding:"12px",borderRadius:"4px",color:t.textPrimary,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"300px",overflowY:"auto",margin:0}},jo="jacques-open-sessions";function os(n){return n?`${jo}:${n}`:jo}function So(n){try{const o=localStorage.getItem(os(n));if(o){const s=JSON.parse(o);if(Array.isArray(s))return s}}catch{}return[]}function ri(n,o){try{localStorage.setItem(os(n),JSON.stringify(o))}catch{}}function ii(n,o){switch(o.type){case"OPEN_SESSION":return n.sessions.find(r=>r.id===o.payload.id)?{...n,activeViewId:o.payload.id}:{sessions:[...n.sessions,o.payload],activeViewId:o.payload.id};case"CLOSE_SESSION":return{sessions:n.sessions.filter(r=>r.id!==o.payload),activeViewId:n.activeViewId===o.payload?null:n.activeViewId};case"VIEW_SESSION":return n.sessions.find(r=>r.id===o.payload)?{...n,activeViewId:o.payload}:n;case"VIEW_DASHBOARD":return{...n,activeViewId:null};case"UPDATE_TITLE":return{...n,sessions:n.sessions.map(s=>s.id===o.payload.id?{...s,title:o.payload.title}:s)};case"SWITCH_PROJECT":return{sessions:o.payload,activeViewId:null};default:return n}}const ss=a.createContext(null);function ai({children:n}){const{selectedProject:o}=wt(),s=a.useRef(o),[r,i]=a.useReducer(ii,{sessions:So(o),activeViewId:null});a.useEffect(()=>{o!==s.current&&(s.current=o,i({type:"SWITCH_PROJECT",payload:So(o)}))},[o]),a.useEffect(()=>{ri(s.current,r.sessions)},[r.sessions]);const l=a.useCallback(h=>{i({type:"OPEN_SESSION",payload:{...h,openedAt:Date.now()}})},[]),c=a.useCallback(h=>{i({type:"CLOSE_SESSION",payload:h})},[]),p=a.useCallback(h=>{i({type:"VIEW_SESSION",payload:h})},[]),g=a.useCallback(()=>{i({type:"VIEW_DASHBOARD"})},[]),d=a.useCallback((h,y)=>{i({type:"UPDATE_TITLE",payload:{id:h,title:y}})},[]);return e.jsx(ss.Provider,{value:{state:r,openSession:l,closeSession:c,viewSession:p,viewDashboard:g,updateTitle:d},children:n})}function Jt(){const n=a.useContext(ss);if(!n)throw new Error("useOpenSessions must be used within OpenSessionsProvider");return n}function Ot({size:n=16,color:o="currentColor",style:s}){return e.jsxs("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none",style:s,children:[e.jsx("path",{d:"M4 2h5l3 3v9a1 1 0 01-1 1H4a1 1 0 01-1-1V3a1 1 0 011-1z",stroke:o,strokeWidth:"1.5",fill:"none"}),e.jsx("path",{d:"M9 2v3h3",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("line",{x1:"5",y1:"8",x2:"10",y2:"8",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("line",{x1:"5",y1:"11",x2:"8",y2:"11",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"})]})}function rs({size:n=16,color:o="currentColor",style:s}){return e.jsxs("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"none",style:s,children:[e.jsx("rect",{x:"3",y:"4",width:"10",height:"9",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),e.jsx("circle",{cx:"6",cy:"8",r:"1",fill:o}),e.jsx("circle",{cx:"10",cy:"8",r:"1",fill:o}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"4",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("circle",{cx:"8",cy:"1.5",r:"0.75",fill:o})]})}function li({size:n=8,color:o="currentColor",filled:s=!0,style:r}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 8 8",style:r,children:s?e.jsx("circle",{cx:"4",cy:"4",r:"3",fill:o}):e.jsx("circle",{cx:"4",cy:"4",r:"2.5",stroke:o,strokeWidth:"1",fill:"none"})})}const ci=[/^implement the following plan[:\s]*/i,/^here is the plan[:\s]*/i,/^follow this plan[:\s]*/i];function di(n){for(const o of ci)if(o.test(n)){const s=n.replace(o,"").trim(),r=s.match(/^#\s+(.+)/m);return{isPlan:!0,display:(r?r[1].trim():s.split(`
36
+ `)[0].trim())||"Unnamed Plan"}}return{isPlan:!1,display:n}}function pi(){const{state:n,closeSession:o}=Jt(),s=mt(),{selectedProject:r}=wt(),[i,l]=a.useState(null),c=hn("/:projectSlug/sessions/:sessionId"),p=(c==null?void 0:c.params.sessionId)||null,g=hn("/:projectSlug/:tab"),d=(c==null?void 0:c.params.projectSlug)||(g==null?void 0:g.params.projectSlug)||r;if(n.sessions.length===0)return null;const h=m=>{d&&s(`/${d}/sessions/${m}`)},y=(m,x)=>{m.stopPropagation(),o(x),x===p&&d&&s(`/${d}/sessions`)};return e.jsx("div",{style:at.container,children:n.sessions.map((m,x)=>{const b=x===n.sessions.length-1,f=m.id===p,{isPlan:u,display:v}=di(m.title);return e.jsxs("div",{style:at.itemRow,onMouseEnter:()=>l(m.id),onMouseLeave:()=>l(null),children:[e.jsxs("div",{style:at.treeConnector,children:[e.jsx("div",{style:{...at.treeLine,height:b?"50%":"100%"}}),e.jsx("div",{style:at.treeBranch})]}),e.jsxs("button",{style:{...at.sessionButton,...f?at.sessionButtonActive:{}},onClick:()=>h(m.id),type:"button",title:m.title,children:[f&&e.jsx("span",{style:at.activeIndicator}),u&&e.jsx(Ot,{size:12,color:"#34D399",style:{flexShrink:0}}),e.jsx("span",{style:{...at.sessionTitle,color:f?t.accent:t.textSecondary},children:v}),e.jsx("button",{style:{...at.closeButton,opacity:i===m.id?1:0},onClick:z=>y(z,m.id),type:"button",title:"Close tab",children:e.jsx(st,{size:12})})]})]},m.id)})})}const at={container:{maxHeight:"240px",overflowY:"auto",marginLeft:"20px",marginRight:"8px"},itemRow:{display:"flex",alignItems:"stretch",position:"relative",minHeight:"28px"},treeConnector:{width:"16px",position:"relative",flexShrink:0},treeLine:{position:"absolute",left:"0px",top:0,width:"1px",backgroundColor:t.borderSubtle},treeBranch:{position:"absolute",left:"0px",top:"50%",width:"10px",height:"1px",backgroundColor:t.borderSubtle},sessionButton:{display:"flex",alignItems:"center",gap:"4px",flex:1,minWidth:0,padding:"4px 6px",borderRadius:"4px",border:"none",backgroundColor:"transparent",cursor:"pointer",transition:"background-color 150ms ease",position:"relative"},sessionButtonActive:{backgroundColor:t.bgElevated},activeIndicator:{position:"absolute",left:"-20px",top:"50%",transform:"translateY(-50%)",width:"2px",height:"12px",backgroundColor:t.accent,borderRadius:"0 2px 2px 0"},sessionTitle:{fontSize:"12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,textAlign:"left"},closeButton:{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",border:"none",borderRadius:"3px",backgroundColor:"transparent",color:t.textMuted,cursor:"pointer",padding:0,flexShrink:0,transition:"opacity 150ms ease"}},is=a.createContext(null);function ui(){return typeof Notification>"u"?"unsupported":Notification.permission}function xi({children:n}){const[o,s]=a.useState(Tr),[r,i]=a.useState(ui);a.useEffect(()=>{Qr().then(s).catch(()=>{})},[]);const l=a.useCallback(g=>{s(d=>{const h={...d,...g};return g.categories&&(h.categories={...d.categories,...g.categories}),h}),yo(g).catch(()=>{})},[]),c=a.useCallback(g=>{s(d=>{const h={...d.categories,[g]:!d.categories[g]};return yo({categories:h}).catch(()=>{}),{...d,categories:h}})},[]),p=a.useCallback(async()=>{if(typeof Notification>"u")return;const g=await Notification.requestPermission();i(g)},[]);return e.jsx(is.Provider,{value:{settings:o,updateSettings:l,toggleCategory:c,browserPermission:r,requestBrowserPermission:p},children:n})}function gi(){const n=a.useContext(is);if(!n)throw new Error("useNotifications must be used inside NotificationProvider");return n}const fn=[{id:"global.command-palette",keys:"Mod+k",category:"global",label:"Command palette",description:"Search all actions and shortcuts",zones:["*"]},{id:"global.help",keys:"?",category:"global",label:"Help overlay",description:"Show keyboard shortcut cheat sheet",zones:["*"]},{id:"global.escape",keys:"Escape",category:"global",label:"Close / Back / Deselect",description:"Close modal, go back, or clear selection",zones:["*"]},{id:"nav.sessions",keys:"1",category:"navigation",label:"Sessions",description:"Go to Sessions page",zones:["dashboard","sidebar"]},{id:"nav.artifacts",keys:"2",category:"navigation",label:"Artifacts",description:"Go to Artifacts page",zones:["dashboard","sidebar"]},{id:"nav.context",keys:"3",category:"navigation",label:"Context",description:"Go to Context page",zones:["dashboard","sidebar"]},{id:"nav.archive",keys:"4",category:"navigation",label:"Archive",description:"Go to Archive page",zones:["dashboard","sidebar"]},{id:"nav.settings",keys:"5",category:"navigation",label:"Settings",description:"Go to Settings page",zones:["dashboard","sidebar"]},{id:"nav.sidebar-toggle",keys:"[",category:"navigation",label:"Toggle sidebar",description:"Collapse or expand the sidebar",zones:["dashboard","sidebar"]},{id:"session.next",keys:"j",category:"selection",label:"Next item",description:"Move keyboard focus to next session (active or history)",zones:["dashboard"]},{id:"session.next-arrow",keys:"ArrowDown",category:"selection",label:"Next item",description:"Move keyboard focus to next session",zones:["dashboard"]},{id:"session.prev",keys:"k",category:"selection",label:"Previous item",description:"Move keyboard focus to previous session (active or history)",zones:["dashboard"]},{id:"session.prev-arrow",keys:"ArrowUp",category:"selection",label:"Previous item",description:"Move keyboard focus to previous session",zones:["dashboard"]},{id:"session.next-worktree",keys:"Shift+j",category:"selection",label:"Next worktree",description:"Jump to first session in next worktree group",zones:["dashboard"]},{id:"session.prev-worktree",keys:"Shift+k",category:"selection",label:"Previous worktree",description:"Jump to first session in previous worktree group",zones:["dashboard"]},{id:"session.toggle-select",keys:"Space",category:"selection",label:"Toggle select",description:"Toggle selection on focused session card (multi-select for tiling)",zones:["dashboard"]},{id:"session.select-all",keys:"Mod+a",category:"selection",label:"Select all",description:"Select all active sessions",zones:["dashboard"]},{id:"session.deselect-all",keys:"x",category:"selection",label:"Clear selection",description:"Deselect all sessions",zones:["dashboard"]},{id:"session.focus-terminal",keys:"Enter",category:"selection",label:"Focus terminal",description:"Bring the OS terminal window for this session to front",zones:["dashboard"]},{id:"session.open",keys:"o",category:"selection",label:"Open transcript",description:"Open session transcript viewer",zones:["dashboard"]},{id:"tile.fullscreen",keys:"f",category:"tiling",label:"Fullscreen",description:"Maximize the selected session terminal",zones:["dashboard"]},{id:"tile.tile-selected",keys:"t",category:"tiling",label:"Tile selected",description:"Arrange selected sessions in a tile layout",zones:["dashboard"]},{id:"tile.browser-layout",keys:"b",category:"tiling",label:"Browser + terminal(s)",description:"Browser with terminal(s) — auto-detects 1 or 2 based on selection",zones:["dashboard"]},{id:"terminal.launch",keys:"n",category:"terminal",label:"New session",description:"Launch a new session in the focused worktree",zones:["dashboard"]},{id:"terminal.create-worktree",keys:"Shift+w",category:"terminal",label:"Create worktree",description:"Create a new git worktree",zones:["dashboard"]},{id:"terminal.manage-worktrees",keys:"w",category:"terminal",label:"Manage worktrees",description:"Open worktree removal dialog",zones:["dashboard"]},{id:"viewer.prev-question",keys:"[",category:"viewer",label:"Previous question",description:"Jump to previous user question",zones:["session-viewer"]},{id:"viewer.next-question",keys:"]",category:"viewer",label:"Next question",description:"Jump to next user question",zones:["session-viewer"]},{id:"viewer.expand-all",keys:"e",category:"viewer",label:"Expand all",description:"Expand all collapsible blocks",zones:["session-viewer"]},{id:"viewer.collapse-all",keys:"c",category:"viewer",label:"Collapse all",description:"Collapse all collapsible blocks",zones:["session-viewer"]},{id:"viewer.scroll-end",keys:"Shift+g",category:"viewer",label:"Scroll to end",description:"Scroll to the bottom of the conversation",zones:["session-viewer"]},{id:"viewer.back",keys:"Backspace",category:"viewer",label:"Back",description:"Return to dashboard",zones:["session-viewer"]},{id:"history.toggle",keys:"h",category:"history",label:"Toggle history",description:"Expand or collapse session history section",zones:["dashboard"]}],as={global:"Global",navigation:"Navigation",selection:"Sessions",tiling:"Tiling",terminal:"Terminal",viewer:"Viewer",history:"History"};function ls(n,o){const s=o==="mac";return n.replace(/Mod\+/g,s?"⌘":"Ctrl+").replace(/Shift\+/g,s?"⇧":"Shift+").replace(/ArrowDown/g,"↓").replace(/ArrowUp/g,"↑").replace(/ArrowLeft/g,"←").replace(/ArrowRight/g,"→").replace(/Escape/g,"Esc").replace(/Backspace/g,"⌫").replace(/Enter/g,"↵").replace(/Space/g,"␣")}function hi(n){const o=n.split("+"),s={mod:!1,shift:!1,alt:!1,key:""};for(const r of o){const i=r.toLowerCase();i==="mod"?s.mod=!0:i==="shift"?s.shift=!0:i==="alt"?s.alt=!0:s.key=r}return s}function fi(n,o,s){const r=hi(o.keys);if(r.mod){if(!(s==="mac"?n.metaKey:n.ctrlKey))return!1}else if(s==="mac"&&n.metaKey||s!=="mac"&&n.ctrlKey)return!1;if(r.shift!==n.shiftKey||r.alt!==n.altKey)return!1;const i=r.key.toLowerCase(),l=mi(n.key);return i===l}function mi(n){return n===" "?"space":(n.length>1,n.toLowerCase())}function yi(n,o,s){for(const r of fn)if(!(!r.zones.includes(o)&&!r.zones.includes("*"))&&fi(n,r,s))return r}function bi(n){return{key:n.key,metaKey:n.metaKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,altKey:n.altKey}}function so(){if(typeof navigator<"u"){const n=navigator.userAgent.toLowerCase();return n.includes("mac")?"mac":n.includes("win")?"win":"linux"}return typeof process<"u"&&process.platform?process.platform==="darwin"?"mac":process.platform==="win32"?"win":"linux":"linux"}const cs=a.createContext(null);function ji({children:n}){const[o,s]=a.useState("dashboard"),[r,i]=a.useState(!1),[l,c]=a.useState([]),p=a.useRef(l);p.current=l,a.useEffect(()=>{function h(x){if(!x||!(x instanceof HTMLElement))return!1;const b=x.tagName.toLowerCase();return!!(b==="input"||b==="textarea"||x.isContentEditable)}function y(x){h(x.target)&&i(!0)}function m(x){h(x.target)&&i(!1)}return document.addEventListener("focusin",y),document.addEventListener("focusout",m),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",m)}},[]);const g=a.useCallback(h=>(c(y=>[...y,h]),()=>{c(y=>y.filter(m=>m!==h))}),[]),d={activeZone:l.length>0?"modal":r?"input":o,setActiveZone:s,isInputFocused:r,pushModal:g,hasModal:l.length>0};return e.jsx(cs.Provider,{value:d,children:n})}function vn(){const n=a.useContext(cs);if(!n)throw new Error("useFocusZone must be used within FocusZoneProvider");return n}const ds=a.createContext(null);function Si({children:n}){const o=a.useRef(new Map),s=a.useCallback((i,l)=>(o.current.set(i,l),()=>{o.current.get(i)===l&&o.current.delete(i)}),[]),r=a.useCallback(i=>{const l=o.current.get(i);return l?(l(),!0):!1},[]);return e.jsx(ds.Provider,{value:{registerAction:s,dispatch:r},children:n})}function wn(){const n=a.useContext(ds);if(!n)throw new Error("useShortcutActions must be used within ShortcutActionsProvider");return n}const vi=so();function wi(){const{activeZone:n}=vn(),{dispatch:o}=wn();a.useEffect(()=>{function s(r){const i=bi(r),l=yi(i,n,vi);l&&o(l.id)&&(r.preventDefault(),r.stopPropagation())}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n,o])}const ki=so();function Ci({onClose:n}){const[o,s]=a.useState(""),[r,i]=a.useState(0),l=a.useRef(null),c=a.useRef(null),{pushModal:p}=vn(),{dispatch:g}=wn(),d=mt();a.useEffect(()=>p("command-palette"),[p]),a.useEffect(()=>{var x;(x=l.current)==null||x.focus()},[]);const h=a.useMemo(()=>{if(!o.trim())return[...fn];const x=o.toLowerCase();return fn.filter(b=>{var f;return b.label.toLowerCase().includes(x)||((f=b.description)==null?void 0:f.toLowerCase().includes(x))||b.category.toLowerCase().includes(x)||b.id.toLowerCase().includes(x)})},[o]);a.useEffect(()=>{i(x=>Math.min(x,Math.max(0,h.length-1)))},[h.length]),a.useEffect(()=>{if(!c.current)return;const x=c.current.children[r];x==null||x.scrollIntoView({block:"nearest"})},[r]);const y=a.useCallback(x=>{if(n(),!g(x.id)&&x.id.startsWith("nav.")){const u={"nav.archive":"/archive","nav.settings":"/settings"}[x.id];u&&d(u)}},[g,d,n]),m=x=>{x.key==="Escape"?(x.preventDefault(),n()):x.key==="ArrowDown"?(x.preventDefault(),i(b=>Math.min(b+1,h.length-1))):x.key==="ArrowUp"?(x.preventDefault(),i(b=>Math.max(b-1,0))):x.key==="Enter"&&h.length>0&&(x.preventDefault(),y(h[r]))};return e.jsx("div",{style:Ge.backdrop,onClick:n,children:e.jsxs("div",{style:Ge.container,onClick:x=>x.stopPropagation(),onKeyDown:m,children:[e.jsxs("div",{style:Ge.inputRow,children:[e.jsx("span",{style:Ge.prompt,children:">"}),e.jsx("input",{ref:l,style:Ge.input,placeholder:"Type a command...",value:o,onChange:x=>{s(x.target.value),i(0)},autoFocus:!0}),e.jsx("kbd",{style:Ge.escHint,children:"Esc"})]}),e.jsx("div",{style:Ge.divider}),e.jsx("div",{ref:c,style:Ge.results,children:h.length===0?e.jsx("div",{style:Ge.emptyState,children:"No matching commands"}):h.map((x,b)=>e.jsxs("button",{style:{...Ge.item,backgroundColor:b===r?t.bgElevated:"transparent"},onClick:()=>y(x),onMouseEnter:()=>i(b),children:[e.jsx("span",{style:Ge.itemCategory,children:as[x.category]}),e.jsx("span",{style:Ge.itemLabel,children:x.label}),e.jsx("span",{style:Ge.itemKeys,children:ls(x.keys,ki)})]},x.id))})]})})}const Ge={backdrop:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",justifyContent:"center",alignItems:"flex-start",paddingTop:"15vh",zIndex:9999},container:{width:"560px",maxHeight:"420px",backgroundColor:t.bgSecondary,border:`1px solid ${t.borderSubtle}`,borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 25px 50px rgba(0, 0, 0, 0.5)"},inputRow:{display:"flex",alignItems:"center",padding:"12px 16px",gap:"8px"},prompt:{color:t.accent,fontFamily:ke.fontFamily.mono,fontSize:"16px",fontWeight:600,flexShrink:0},input:{flex:1,background:"none",border:"none",outline:"none",color:t.textPrimary,fontFamily:ke.fontFamily.mono,fontSize:"15px",padding:0},escHint:{color:t.textMuted,fontSize:"11px",fontFamily:ke.fontFamily.mono,padding:"2px 6px",borderRadius:"4px",border:`1px solid ${t.borderSubtle}`,flexShrink:0},divider:{height:"1px",background:t.borderSubtle},results:{flex:1,overflowY:"auto",padding:"4px"},item:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",borderRadius:"6px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",transition:"background-color 100ms ease"},itemCategory:{color:t.textMuted,fontSize:"11px",fontFamily:ke.fontFamily.mono,textTransform:"uppercase",letterSpacing:"0.5px",width:"72px",flexShrink:0},itemLabel:{flex:1,color:t.textPrimary,fontSize:"13px",fontFamily:ke.fontFamily.mono},itemKeys:{color:t.textMuted,fontSize:"12px",fontFamily:ke.fontFamily.mono,padding:"2px 6px",borderRadius:"4px",border:`1px solid ${t.borderSubtle}`,flexShrink:0},emptyState:{color:t.textMuted,fontFamily:ke.fontFamily.mono,fontSize:"13px",padding:"24px 16px",textAlign:"center"}},Ii=so();function Ti(n){const o=new Set,s=new Map;for(const r of n){if(r.id.endsWith("-arrow")||o.has(r.id))continue;o.add(r.id);const i=s.get(r.category)||[];i.push(r),s.set(r.category,i)}return s}function zi({onClose:n}){const{pushModal:o}=vn();a.useEffect(()=>o("help-overlay"),[o]),a.useEffect(()=>{function i(l){["Shift","Control","Alt","Meta"].includes(l.key)||(l.preventDefault(),n())}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]);const s=Ti([...fn]),r=["global","navigation","selection","tiling","terminal","viewer","history"];return e.jsx("div",{style:ot.backdrop,onClick:n,children:e.jsxs("div",{style:ot.container,onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{style:ot.header,children:[e.jsx("span",{style:ot.title,children:"Keyboard Shortcuts"}),e.jsx("span",{style:ot.hint,children:"Press any key to close"})]}),e.jsx("div",{style:ot.grid,children:r.map(i=>{const l=s.get(i);return l!=null&&l.length?e.jsxs("div",{style:ot.group,children:[e.jsx("div",{style:ot.groupTitle,children:as[i]}),l.map(c=>e.jsxs("div",{style:ot.row,children:[e.jsx("kbd",{style:ot.key,children:ls(c.keys,Ii)}),e.jsx("span",{style:ot.label,children:c.label})]},c.id))]},i):null})})]})})}const ot={backdrop:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.75)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:9999},container:{backgroundColor:t.bgSecondary,border:`1px solid ${t.borderSubtle}`,borderRadius:"12px",padding:"24px 32px",maxWidth:"720px",maxHeight:"80vh",overflow:"auto",boxShadow:"0 25px 50px rgba(0, 0, 0, 0.5)"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px",paddingBottom:"12px",borderBottom:`1px solid ${t.borderSubtle}`},title:{color:t.accent,fontFamily:ke.fontFamily.mono,fontSize:"16px",fontWeight:600,letterSpacing:"0.5px"},hint:{color:t.textMuted,fontFamily:ke.fontFamily.mono,fontSize:"11px"},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"24px"},group:{display:"flex",flexDirection:"column",gap:"4px"},groupTitle:{color:t.accent,fontFamily:ke.fontFamily.mono,fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"1px",marginBottom:"6px"},row:{display:"flex",alignItems:"center",gap:"12px",padding:"3px 0"},key:{color:t.textPrimary,fontFamily:ke.fontFamily.mono,fontSize:"12px",padding:"2px 8px",borderRadius:"4px",border:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgElevated,minWidth:"32px",textAlign:"center",flexShrink:0},label:{color:t.textSecondary,fontFamily:ke.fontFamily.mono,fontSize:"12px"}},Ri=["sessions","artifacts","context"],Ei=[{tab:"sessions",label:"Sessions",Icon:Ls},{tab:"artifacts",label:"Artifacts",Icon:Fo},{tab:"context",label:"Context",Icon:Ps}];function $i(){const n=Is(),o=mt(),{sessions:s,serverLogs:r,claudeOperations:i,apiLogs:l,launchSession:c,createWorktree:p,focusTerminal:g}=jn(),{selectedProject:d,setSelectedProject:h,archivedProjects:y,setArchivedProjects:m,discoveredProjects:x,refreshProjects:b}=wt(),[f,u]=a.useState({obsidian:{connected:!1},googleDocs:{connected:!1},notion:{connected:!1}}),v=hn("/:projectSlug/:tab"),z=hn("/:projectSlug/sessions/:sessionId"),I=(v==null?void 0:v.params.tab)&&Ri.includes(v.params.tab),P=(z==null?void 0:z.params.projectSlug)||(I?v.params.projectSlug:null),k=z?"sessions":I?v.params.tab:null;a.useEffect(()=>{P&&(h(P),localStorage.setItem("jacques:lastProjectSlug",P))},[P,h]);const _=P||d,[B,W]=Xt("sidebarCollapsed",!1),[O,M]=Xt("showLogs",!1),{viewDashboard:$}=Jt();wi();const{registerAction:C}=wn(),[T,S]=a.useState(!1),[F,J]=a.useState(!1);a.useEffect(()=>{const U=[C("global.command-palette",()=>S(Z=>!Z)),C("global.help",()=>J(Z=>!Z)),C("global.escape",()=>{T?S(!1):F&&J(!1)}),C("nav.sessions",()=>_&&o(`/${_}/sessions`)),C("nav.artifacts",()=>_&&o(`/${_}/artifacts`)),C("nav.context",()=>_&&o(`/${_}/context`)),C("nav.archive",()=>o("/archive")),C("nav.settings",()=>o("/settings")),C("nav.sidebar-toggle",()=>W(!B))];return()=>U.forEach(Z=>Z())},[C,o,_,T,F,B,W]),a.useEffect(()=>{async function U(){try{const Z=await Xo();u(Z)}catch(Z){console.error("Failed to load source status:",Z)}}U()},[n.pathname]),a.useEffect(()=>{if(x.length===0)return;const U=new Set(s.map(q=>kt(q))),Z=x.map(q=>q.name).filter(q=>!U.has(q));m(Z)},[x,s,m]);const K=async U=>{try{await qr(U),await b()}catch(Z){console.error("Failed to hide project:",Z)}},re=U=>{U&&o(`/${U}/${k||"sessions"}`)};return e.jsxs(xi,{children:[e.jsxs("div",{style:ye.container,children:[e.jsx(gr,{onFocusTerminal:g}),e.jsxs("aside",{style:{...ye.sidebar,width:B?"56px":"280px",transition:"width 200ms ease"},id:"sidebar",children:[e.jsx("div",{style:{...ye.logoSection,padding:B?"0 0 12px":"0 12px 12px 16px",flexDirection:B?"column":"row",justifyContent:B?"center":"space-between"},children:B?e.jsxs(e.Fragment,{children:[e.jsx("button",{style:ye.collapseButton,onClick:()=>W(!1),title:"Expand sidebar",children:e.jsx(Bs,{size:16})}),e.jsx("button",{style:ye.logoButton,onClick:()=>_&&o(`/${_}/sessions`),title:"Go to sessions",children:e.jsx("img",{src:"/jacsub.png",alt:"Jacques",style:ye.mascot})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{style:ye.logoButton,onClick:()=>_&&o(`/${_}/sessions`),title:"Go to sessions",children:[e.jsx("img",{src:"/jacsub.png",alt:"Jacques",style:ye.mascot}),e.jsx("span",{style:ye.logoText,children:"Jacques"})]}),e.jsx("button",{style:ye.collapseButton,onClick:()=>W(!0),title:"Collapse sidebar",children:e.jsx(Ms,{size:16})})]})}),!B&&e.jsx("div",{style:ye.blockSeparator,children:e.jsx("div",{style:{height:"1px",background:`linear-gradient(90deg, transparent, ${t.accent}40, transparent)`}})}),!B&&e.jsx(Mr,{sessions:s,archivedProjects:y,discoveredProjects:x,selectedProject:P,onSelectProject:re,onLaunchSession:c,onCreateWorktree:p,onHideProject:K}),e.jsx("nav",{style:{...ye.nav,padding:B?"0 4px":"0 8px"},children:Ei.map(U=>{const Z=k===U.tab,q=_?`/${_}/${U.tab}`:"/",X=U.tab==="sessions"?Q=>{$(),Z&&z&&(Q.preventDefault(),o(q))}:void 0;return e.jsxs(mn.Fragment,{children:[e.jsxs(zn,{to:q,onClick:X,style:{...ye.navLink,...Z?ye.navLinkActive:{},...B?{justifyContent:"center",padding:"8px",gap:"0"}:{}},title:B?U.label:void 0,children:[Z&&!B&&e.jsx("span",{style:ye.activeIndicator}),e.jsx(U.Icon,{size:16,style:{flexShrink:0,opacity:Z?1:.6}}),!B&&e.jsx("span",{children:U.label})]}),U.tab==="sessions"&&!B&&e.jsx(pi,{})]},U.tab)})}),!B&&e.jsxs("div",{style:ye.sourcesSection,children:[e.jsx(qn,{to:"/sources",style:ye.sectionHeaderLink,children:e.jsx(Ut,{title:"Sources",accentColor:t.accent})}),[{key:"obsidian",label:"Obsidian"},{key:"googleDocs",label:"Google Docs"},{key:"notion",label:"Notion"}].map(({key:U,label:Z})=>e.jsxs(qn,{to:"/sources",style:{...ye.sourceItem,color:f[U].connected?t.textSecondary:t.textMuted},children:[e.jsx("span",{children:Z}),e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:f[U].connected?t.success:t.textMuted,opacity:f[U].connected?1:.4,marginLeft:"auto",flexShrink:0}})]},U))]}),e.jsx("div",{style:{...ye.sidebarFooter,...B?{marginTop:"auto"}:{}},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",flexDirection:B?"column":"row"},children:[B?e.jsx(zn,{to:"/settings",style:{...ye.navLink,...n.pathname==="/settings"?ye.navLinkActive:{},justifyContent:"center",padding:"8px"},title:"Settings",children:e.jsx(ao,{size:16,style:{flexShrink:0,opacity:n.pathname==="/settings"?1:.6}})}):e.jsxs(zn,{to:"/settings",style:{...ye.navLink,...n.pathname==="/settings"?ye.navLinkActive:{},flex:1},children:[n.pathname==="/settings"&&e.jsx("span",{style:ye.activeIndicator}),e.jsx(ao,{size:16,style:{flexShrink:0,opacity:n.pathname==="/settings"?1:.6}}),e.jsx("span",{children:"Settings"})]}),e.jsx(Er,{onFocusTerminal:U=>g==null?void 0:g(U)}),e.jsx("button",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:"none",borderRadius:"6px",cursor:"pointer",transition:"all 150ms ease",flexShrink:0,backgroundColor:O?t.bgElevated:"transparent",color:O?t.accent:t.textMuted},onClick:()=>M(!O),title:O?"Hide logs":"Show logs",children:e.jsx(ft,{size:16})})]})})]}),e.jsxs("div",{style:ye.contentArea,children:[e.jsx("main",{style:ye.main,children:e.jsx(Ko,{level:"route",children:e.jsx(Ts,{})})}),O&&e.jsx(si,{serverLogs:r,apiLogs:l,claudeOperations:i})]})]}),T&&e.jsx(Ci,{onClose:()=>S(!1)}),F&&e.jsx(zi,{onClose:()=>J(!1)})]})}const ye={container:{display:"flex",height:"100vh",overflow:"hidden"},contentArea:{flex:1,display:"flex",flexDirection:"column",minWidth:0,overflow:"hidden",position:"relative"},sidebar:{backgroundColor:t.bgSecondary,borderRight:`1px solid ${t.borderSubtle}`,display:"flex",flexDirection:"column",padding:"16px 0",flexShrink:0,overflow:"hidden"},logoSection:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",padding:"0 12px 12px 16px",flexDirection:"row"},logoButton:{display:"flex",alignItems:"center",gap:"10px",background:"none",border:"none",cursor:"pointer",padding:"4px",borderRadius:"8px",transition:"opacity 150ms ease",textDecoration:"none"},mascot:{width:"36px",height:"36px",objectFit:"contain"},logoText:{fontSize:"20px",fontWeight:600,color:t.accent,letterSpacing:"0.5px",fontFamily:ke.fontFamily.sans},collapseButton:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",borderRadius:"6px",cursor:"pointer",transition:"all 150ms ease",flexShrink:0,backgroundColor:"transparent",color:t.textMuted},blockSeparator:{padding:"0 16px 16px"},nav:{display:"flex",flexDirection:"column",gap:"2px",padding:"0 8px"},navLink:{display:"flex",alignItems:"center",gap:"10px",padding:"8px 12px",borderRadius:"6px",color:t.textSecondary,textDecoration:"none",transition:"all 150ms ease",fontSize:"13px",position:"relative"},navLinkActive:{backgroundColor:t.bgElevated,color:t.accent},activeIndicator:{position:"absolute",left:"-8px",top:"50%",transform:"translateY(-50%)",width:"2px",height:"16px",backgroundColor:t.accent,borderRadius:"0 2px 2px 0"},sourcesSection:{marginTop:"auto",padding:"16px 8px 0",borderTop:`1px solid ${t.borderSubtle}`},sectionHeaderLink:{textDecoration:"none",display:"block",padding:"0 12px"},sourceItem:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",color:t.textSecondary,fontSize:"13px",textDecoration:"none",cursor:"pointer",borderRadius:"4px",transition:"background-color 150ms ease"},sidebarFooter:{padding:"12px 8px 0",borderTop:`1px solid ${t.borderSubtle}`,marginTop:"16px"},main:{flex:1,padding:0,overflow:"auto",minHeight:0}};function vo(){const n=mt(),{sessions:o,focusedSessionId:s,initialStateReceived:r}=jn();return a.useEffect(()=>{if(!r)return;if(s){const l=o.find(c=>c.session_id===s);if(l){const c=kt(l);n(`/${c}/sessions`,{replace:!0});return}}const i=localStorage.getItem("jacques:lastProjectSlug");if(o.length>0){if(i&&o.some(p=>kt(p)===i)){n(`/${i}/sessions`,{replace:!0});return}const l=[...o].sort((p,g)=>g.last_activity-p.last_activity),c=kt(l[0]);n(`/${c}/sessions`,{replace:!0});return}if(i){n(`/${i}/sessions`,{replace:!0});return}n("/archive",{replace:!0})},[o,s,r,n]),null}const Bi=30*1e3;function Mi(n){const[o,s]=a.useState(new Map),[r,i]=a.useState(!1),[l,c]=a.useState(null),p=a.useRef(new Map),g=a.useCallback(async(h,y=!1)=>{if(h.length===0)return;const m=Date.now(),x=[],b=new Map;for(const f of h){const u=p.current.get(f);u&&!y&&m-u.fetchedAt<Bi?b.set(f,u.badges):x.push(f)}if(x.length===0){s(b);return}i(!0),c(null);try{const f=await Promise.allSettled(x.map(async v=>{const z=await Jr(v);return{id:v,badges:z}})),u=new Map(b);for(const v of f)if(v.status==="fulfilled"){const{id:z,badges:I}=v.value;u.set(z,I),p.current.set(z,{badges:I,fetchedAt:m})}s(u)}catch(f){c(f instanceof Error?f.message:"Failed to fetch badges")}finally{i(!1)}},[]);a.useEffect(()=>{g(n)},[n.join(","),g]);const d=a.useCallback(()=>{g(n,!0)},[n,g]);return{badges:o,loading:r,error:l,refetch:d}}var ps={};function Li(n){if(typeof window>"u")return;const o=document.createElement("style");return o.setAttribute("type","text/css"),o.innerHTML=n,document.head.appendChild(o),n}Object.defineProperty(ps,"__esModule",{value:!0});var ze=a;function Pi(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var bt=Pi(ze);Li(`.rfm-marquee-container {
37
+ overflow-x: hidden;
38
+ display: flex;
39
+ flex-direction: row;
40
+ position: relative;
41
+ width: var(--width);
42
+ transform: var(--transform);
43
+ }
44
+ .rfm-marquee-container:hover div {
45
+ animation-play-state: var(--pause-on-hover);
46
+ }
47
+ .rfm-marquee-container:active div {
48
+ animation-play-state: var(--pause-on-click);
49
+ }
50
+
51
+ .rfm-overlay {
52
+ position: absolute;
53
+ width: 100%;
54
+ height: 100%;
55
+ }
56
+ .rfm-overlay::before, .rfm-overlay::after {
57
+ background: linear-gradient(to right, var(--gradient-color), rgba(255, 255, 255, 0));
58
+ content: "";
59
+ height: 100%;
60
+ position: absolute;
61
+ width: var(--gradient-width);
62
+ z-index: 2;
63
+ pointer-events: none;
64
+ touch-action: none;
65
+ }
66
+ .rfm-overlay::after {
67
+ right: 0;
68
+ top: 0;
69
+ transform: rotateZ(180deg);
70
+ }
71
+ .rfm-overlay::before {
72
+ left: 0;
73
+ top: 0;
74
+ }
75
+
76
+ .rfm-marquee {
77
+ flex: 0 0 auto;
78
+ min-width: var(--min-width);
79
+ z-index: 1;
80
+ display: flex;
81
+ flex-direction: row;
82
+ align-items: center;
83
+ animation: scroll var(--duration) linear var(--delay) var(--iteration-count);
84
+ animation-play-state: var(--play);
85
+ animation-delay: var(--delay);
86
+ animation-direction: var(--direction);
87
+ }
88
+ @keyframes scroll {
89
+ 0% {
90
+ transform: translateX(0%);
91
+ }
92
+ 100% {
93
+ transform: translateX(-100%);
94
+ }
95
+ }
96
+
97
+ .rfm-initial-child-container {
98
+ flex: 0 0 auto;
99
+ display: flex;
100
+ min-width: auto;
101
+ flex-direction: row;
102
+ align-items: center;
103
+ }
104
+
105
+ .rfm-child {
106
+ transform: var(--transform);
107
+ }`);const Ai=ze.forwardRef(function({style:o={},className:s="",autoFill:r=!1,play:i=!0,pauseOnHover:l=!1,pauseOnClick:c=!1,direction:p="left",speed:g=50,delay:d=0,loop:h=0,gradient:y=!1,gradientColor:m="white",gradientWidth:x=200,onFinish:b,onCycleComplete:f,onMount:u,children:v},z){const[I,P]=ze.useState(0),[k,_]=ze.useState(0),[B,W]=ze.useState(1),[O,M]=ze.useState(!1),$=ze.useRef(null),C=z||$,T=ze.useRef(null),S=ze.useCallback(()=>{if(T.current&&C.current){const q=C.current.getBoundingClientRect(),X=T.current.getBoundingClientRect();let Q=q.width,V=X.width;(p==="up"||p==="down")&&(Q=q.height,V=X.height),W(r&&Q&&V&&V<Q?Math.ceil(Q/V):1),P(Q),_(V)}},[r,C,p]);ze.useEffect(()=>{if(O&&(S(),T.current&&C.current)){const q=new ResizeObserver(()=>S());return q.observe(C.current),q.observe(T.current),()=>{q&&q.disconnect()}}},[S,C,O]),ze.useEffect(()=>{S()},[S,v]),ze.useEffect(()=>{M(!0)},[]),ze.useEffect(()=>{typeof u=="function"&&u()},[]);const F=ze.useMemo(()=>r?k*B/g:k<I?I/g:k/g,[r,I,k,B,g]),J=ze.useMemo(()=>Object.assign(Object.assign({},o),{"--pause-on-hover":!i||l?"paused":"running","--pause-on-click":!i||l&&!c||c?"paused":"running","--width":p==="up"||p==="down"?"100vh":"100%","--transform":p==="up"?"rotate(-90deg)":p==="down"?"rotate(90deg)":"none"}),[o,i,l,c,p]),K=ze.useMemo(()=>({"--gradient-color":m,"--gradient-width":typeof x=="number"?`${x}px`:x}),[m,x]),re=ze.useMemo(()=>({"--play":i?"running":"paused","--direction":p==="left"?"normal":"reverse","--duration":`${F}s`,"--delay":`${d}s`,"--iteration-count":h?`${h}`:"infinite","--min-width":r?"auto":"100%"}),[i,p,F,d,h,r]),U=ze.useMemo(()=>({"--transform":p==="up"?"rotate(90deg)":p==="down"?"rotate(-90deg)":"none"}),[p]),Z=ze.useCallback(q=>[...Array(Number.isFinite(q)&&q>=0?q:0)].map((X,Q)=>bt.default.createElement(ze.Fragment,{key:Q},ze.Children.map(v,V=>bt.default.createElement("div",{style:U,className:"rfm-child"},V)))),[U,v]);return O?bt.default.createElement("div",{ref:C,style:J,className:"rfm-marquee-container "+s},y&&bt.default.createElement("div",{style:K,className:"rfm-overlay"}),bt.default.createElement("div",{className:"rfm-marquee",style:re,onAnimationIteration:f,onAnimationEnd:b},bt.default.createElement("div",{className:"rfm-initial-child-container",ref:T},ze.Children.map(v,q=>bt.default.createElement("div",{style:U,className:"rfm-child"},q))),Z(B-1)),bt.default.createElement("div",{className:"rfm-marquee",style:re},Z(B))):null});var _i=ps.default=Ai;function Fi({session:n}){return n.git_branch?e.jsxs("div",{style:ln.gitRow,children:[e.jsx(ht,{size:11,color:t.textMuted,strokeWidth:2}),e.jsx("span",{style:ln.gitBranch,children:n.git_branch}),(n.git_ahead!=null&&n.git_ahead>0||n.git_behind!=null&&n.git_behind>0)&&e.jsxs("span",{style:ln.gitDivergence,children:[n.git_ahead!=null&&n.git_ahead>0?`↑${n.git_ahead}`:"",n.git_behind!=null&&n.git_behind>0?` ↓${n.git_behind}`:""]}),n.git_dirty&&e.jsx("span",{style:ln.gitDirty,children:"•"})]}):null}const ln={gitRow:{display:"flex",alignItems:"center",gap:"5px",marginTop:"1px"},gitBranch:{fontSize:"11px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace",letterSpacing:"-0.01em"},gitDivergence:{fontSize:"10px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace",opacity:.7},gitDirty:{fontSize:"11px",color:"#F59E0B",marginLeft:"2px"}},Di={Bash:{label:"Running command",icon:"terminal"},Read:{label:"Reading files",icon:"file-text"},Write:{label:"Writing code",icon:"pen-tool"},Edit:{label:"Editing code",icon:"pen-tool"},Task:{label:"Running subagent",icon:"bot"},Grep:{label:"Searching code",icon:"search"},Glob:{label:"Finding files",icon:"search"},WebSearch:{label:"Searching web",icon:"globe"},WebFetch:{label:"Fetching page",icon:"globe"},NotebookEdit:{label:"Editing notebook",icon:"pen-tool"}},Wi={Edit:{label:"Accepting edits",icon:"pen-tool"},Write:{label:"Accepting edits",icon:"pen-tool"},NotebookEdit:{label:"Accepting edits",icon:"pen-tool"},Bash:{label:"Approving command",icon:"terminal"},AskUserQuestion:{label:"Choosing option",icon:"message-square"},EnterPlanMode:{label:"Reviewing plan",icon:"git-branch"}},jt={working:"#E67E52",idle:"#4ADE80",active:"#4ADE80",awaiting:"#FBBF24",plan:"#34D399"};function Ni(n,o){if(n==="awaiting"){if(o==="ExitPlanMode")return{label:"Reviewing plan",color:jt.plan,needsAttention:!0,iconHint:"plan"};const s=o?Wi[o]:null;return{label:(s==null?void 0:s.label)||"Waiting for approval",color:jt.awaiting,needsAttention:!0,iconHint:(s==null?void 0:s.icon)||"shield-check"}}if(n==="idle")return{label:"Ready",color:jt.idle,needsAttention:!1,iconHint:"check-circle"};if(n==="active")return{label:"Starting...",color:jt.active,needsAttention:!1,iconHint:"loader"};if(n==="working"){if(!o)return{label:"Working...",color:jt.working,needsAttention:!1,iconHint:"loader"};const s=Di[o];return s?{label:s.label,color:jt.working,needsAttention:!1,iconHint:s.icon}:o.startsWith("mcp__")?{label:`MCP: ${o.split("__")[1]||"tool"}`,color:jt.working,needsAttention:!1,iconHint:"plug"}:{label:`Using ${o}`,color:jt.working,needsAttention:!1,iconHint:"wrench"}}return{label:n,color:"#6B7075",needsAttention:!1,iconHint:"circle"}}const Hi=[/^implement the following plan[:\s]*/i,/^here is the plan[:\s]*/i,/^follow this plan[:\s]*/i];function us(n,o){const s=(o==null?void 0:o.fallbackTitle)??"Untitled";if(!n)return{isPlan:!1,displayTitle:s};if(o!=null&&o.stripCommands){const r=n.trim();if(r.startsWith("<local-command")||r.startsWith("<command-"))return{isPlan:!1,displayTitle:"Active Session"}}for(const r of Hi)if(r.test(n)){const i=n.replace(r,"").trim(),l=i.match(/^#\s+(.+)/m);let c=l?l[1].trim():i.split(`
108
+ `)[0].trim();return o!=null&&o.stripArtifacts&&(c=c.replace(/\.{3}$/,"").replace(/-$/,"").trim()),o!=null&&o.maxLength&&c.length>o.maxLength&&(c=c.slice(0,o.maxLength-3)+"..."),{isPlan:!0,displayTitle:c||"Unnamed Plan"}}return{isPlan:!1,displayTitle:n}}function _t(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${Math.round(n/1e3)}k`:String(n)}function Oi(n){if(n<=50)return t.accent;const o=Math.min(1,(n-50)/50),s=Math.round(230+9*o),r=Math.round(126-58*o),i=Math.round(82-14*o);return`rgb(${s}, ${r}, ${i})`}function qi({hint:n,color:o,size:s=13}){const r={size:s,color:o,strokeWidth:2};switch(n){case"terminal":return e.jsx(ft,{...r});case"file-text":return e.jsx(Re,{...r});case"pen-tool":return e.jsx(Xn,{...r});case"search":return e.jsx(yt,{...r});case"bot":return e.jsx(et,{...r});case"globe":return e.jsx(qt,{...r});case"plug":return e.jsx(bn,{...r});case"wrench":return e.jsx(Zt,{...r});case"message-square":return e.jsx(Do,{...r});case"loader":return e.jsx(Oe,{...r,style:{animation:"spin 1.5s linear infinite"}});case"plan":return e.jsx(Ot,{size:s,color:o});default:return null}}function Ui({session:n,isFocused:o=!1,isKeyboardFocused:s=!1,badges:r,onClick:i,onFocusClick:l,onPlanClick:c,onAgentClick:p,isSelected:g=!1,onSelectionChange:d}){var D,Y;const h=a.useRef(null),y=a.useRef(null),[m,x]=a.useState(!1),[b,f]=a.useState(!1),[u,v]=a.useState(!1),[z,I]=a.useState(!1),[P,k]=a.useState(!1),[_,B]=a.useState(!1),[W,O]=a.useState(null),M=a.useRef(g);a.useEffect(()=>{if(g!==M.current){O(g?"selecting":"deselecting");const G=setTimeout(()=>O(null),g?300:200);return M.current=g,()=>clearTimeout(G)}},[g]),a.useEffect(()=>{const G=()=>{h.current&&y.current&&x(y.current.scrollWidth>h.current.offsetWidth)};return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[n.session_title]);const $=n.status,{isPlan:C,displayTitle:T}=us(n.session_title,{stripCommands:!0,stripArtifacts:!0,fallbackTitle:"Untitled session"}),S=Ni($,n.last_tool_name),J=(((D=n.model)==null?void 0:D.display_name)||((Y=n.model)==null?void 0:Y.id)||"").replace("claude-","").replace("-20251101","").replace("-20250218","").replace("-20250514",""),K=r&&r.planCount>0,re=r&&r.agentCount>0,U=n.context_metrics,Z=(U==null?void 0:U.used_percentage)??0,q=(U==null?void 0:U.context_window_size)??0,X=Math.round(q*(Z/100)),Q=Oi(Z),V=a.useCallback(G=>{G.stopPropagation(),l==null||l()},[l]),E=a.useCallback(G=>{G.stopPropagation(),d&&d(!g)},[d,g]),j=a.useCallback(G=>{G.stopPropagation(),i==null||i()},[i]),R=a.useCallback(G=>{G.stopPropagation(),c==null||c()},[c]),H=a.useCallback(G=>{G.stopPropagation(),p==null||p()},[p]),w=["jacques-compact-card",g&&"is-selected",o&&"is-focused",s&&"is-keyboard-focused",W==="selecting"&&"is-selecting",W==="deselecting"&&"is-deselecting"].filter(Boolean).join(" ");return e.jsxs("div",{className:w,"data-session-id":n.session_id,style:{...je.card,borderLeftWidth:"3px",borderLeftColor:o?t.accent:S.needsAttention?S.color:"#2e2e2e"},onClick:E,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),tabIndex:0,role:"button","aria-pressed":g,"aria-label":`Session: ${T}`,children:[e.jsxs("div",{style:je.chrome,children:[e.jsxs("div",{style:je.chromeLeft,children:[e.jsx("span",{style:{...je.dot,backgroundColor:S.color,boxShadow:`0 0 8px ${S.color}80`,animation:$==="working"?"status-pulse 1.8s ease-in-out infinite":$==="awaiting"||S.needsAttention?"attention-pulse 2s ease-in-out infinite":"none"}}),J&&e.jsx("span",{style:je.model,children:J}),e.jsx("span",{style:{...je.modePill,color:n.mode==="plan"||n.mode==="planning"?"#34D399":"#60A5FA",backgroundColor:n.mode==="plan"||n.mode==="planning"?"rgba(52, 211, 153, 0.12)":"rgba(96, 165, 250, 0.12)"},children:n.mode==="plan"||n.mode==="planning"?"plan":"exec"}),n.is_bypass&&e.jsx(Yn,{size:11,color:"#EF4444",style:{flexShrink:0,opacity:.85}})]}),e.jsxs("div",{style:je.chromeRight,children:[l&&e.jsx("button",{onClick:V,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{...je.focusBtn,opacity:b?u?1:.6:0},title:"Focus terminal",children:e.jsx(Wo,{size:12})}),U&&e.jsxs("span",{style:je.tokenInfo,children:[Z>=70?e.jsx("span",{style:{color:t.danger},children:"!! "}):Z>=50?e.jsx("span",{style:{color:t.accent},children:"! "}):null,_t(X),"/",_t(q)]})]})]}),e.jsx("div",{style:je.contextTrack,children:e.jsx("div",{style:{...je.contextFill,width:`${Math.min(100,Z)}%`,backgroundColor:Q,boxShadow:Z>=70?`0 0 10px ${Q}50`:"none"}})}),e.jsxs("div",{style:je.body,children:[e.jsxs("div",{style:je.titleSection,children:[e.jsxs("div",{ref:h,style:je.titleWrap,children:[C&&e.jsx(Ot,{size:15,color:"#34D399",style:{flexShrink:0,marginRight:6}}),m&&b?e.jsx(_i,{speed:40,delay:.3,gradient:!0,gradientColor:t.bgSecondary,gradientWidth:8,style:{overflow:"hidden"},children:e.jsx("span",{style:{...je.title,paddingRight:40},children:T})}):e.jsx("span",{ref:y,style:je.title,children:T})]}),e.jsx(Fi,{session:n})]}),e.jsxs("div",{style:je.footer,children:[e.jsx("div",{style:je.footerLeft,children:e.jsxs("span",{style:{...je.activityChip,color:S.color,animation:S.needsAttention?"attention-pulse 2s ease-in-out infinite":$==="working"?"activity-breathe 2.5s ease-in-out infinite":"none"},children:[e.jsx(qi,{hint:S.iconHint,color:S.color,size:13}),S.label]})}),e.jsxs("div",{style:je.footerRight,children:[K&&e.jsxs("button",{style:{...je.badgePill,backgroundColor:z?"rgba(52, 211, 153, 0.15)":"rgba(52, 211, 153, 0.08)",borderColor:z?"rgba(52, 211, 153, 0.35)":"rgba(52, 211, 153, 0.18)"},className:"jacques-indicator",onClick:R,onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),type:"button",title:`View ${r.planCount} plan${r.planCount>1?"s":""}`,children:[e.jsx(Ot,{size:12,color:"#34D399"}),e.jsx("span",{style:{...je.badgeLabel,color:"#34D399"},children:r.planCount})]}),re&&e.jsxs("button",{style:{...je.badgePill,backgroundColor:P?"rgba(255, 102, 0, 0.15)":"rgba(255, 102, 0, 0.08)",borderColor:P?"rgba(255, 102, 0, 0.35)":"rgba(255, 102, 0, 0.18)"},className:"jacques-indicator",onClick:H,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),type:"button",title:`View ${r.agentCount} agent${r.agentCount>1?"s":""}`,children:[e.jsx(rs,{size:12,color:"#FF6600"}),e.jsx("span",{style:{...je.badgeLabel,color:"#FF6600"},children:r.agentCount})]}),(r==null?void 0:r.hadAutoCompact)&&e.jsx(yn,{size:11,color:t.warning,style:{opacity:.6}}),e.jsx("button",{className:"jacques-card-hint",onClick:j,onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1),style:{...je.viewBtn,opacity:b?_?1:.7:0,transform:b?"translateX(0)":"translateX(-4px)"},type:"button",title:"Open session viewer",children:e.jsx(Fe,{size:14,color:_?t.textPrimary:t.textMuted})})]})]})]})]})}const je={card:{backgroundColor:t.bgSecondary,borderRadius:"10px",border:`1px solid ${t.borderSubtle}`,cursor:"pointer",transition:"all 200ms ease",minWidth:"240px",flex:"1 1 280px",maxWidth:"400px",display:"flex",flexDirection:"column",overflow:"hidden"},chrome:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",backgroundColor:t.bgElevated,gap:"10px",minHeight:"34px"},chromeLeft:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:1},chromeRight:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},dot:{width:"9px",height:"9px",borderRadius:"50%",flexShrink:0},model:{fontSize:"11px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace",letterSpacing:"-0.02em"},modePill:{display:"inline-flex",alignItems:"center",padding:"2px 7px",fontSize:"10px",fontWeight:600,borderRadius:"4px",lineHeight:1.4,letterSpacing:"0.03em",textTransform:"uppercase"},focusBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:"22px",height:"22px",padding:0,background:"transparent",border:"none",borderRadius:"4px",cursor:"pointer",color:t.textSecondary,transition:"opacity 150ms ease"},tokenInfo:{fontSize:"11px",color:t.textMuted,opacity:.7,fontVariantNumeric:"tabular-nums",fontFamily:"'JetBrains Mono', monospace",letterSpacing:"-0.02em"},contextTrack:{height:"3px",backgroundColor:`${t.borderSubtle}80`,position:"relative",overflow:"hidden"},contextFill:{position:"absolute",left:0,top:0,height:"100%",transition:"width 500ms ease, background-color 500ms ease, box-shadow 500ms ease"},body:{padding:"14px 16px 14px",display:"flex",flexDirection:"column",gap:"12px"},titleSection:{display:"flex",flexDirection:"column",gap:"4px"},titleWrap:{display:"flex",alignItems:"center",overflow:"hidden",minWidth:0},title:{fontSize:"14px",fontWeight:600,color:t.textPrimary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.35,letterSpacing:"-0.01em"},footer:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"10px"},footerLeft:{display:"flex",alignItems:"center",gap:"10px",minWidth:0},footerRight:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},activityChip:{display:"inline-flex",alignItems:"center",gap:"5px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",letterSpacing:"0.01em",lineHeight:1},badgePill:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 8px",borderRadius:"5px",border:"1px solid",cursor:"pointer",transition:"all 150ms ease",flexShrink:0},badgeLabel:{fontSize:"11px",fontWeight:600,fontVariantNumeric:"tabular-nums",lineHeight:1},viewBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:0,background:"transparent",border:"none",borderRadius:"4px",cursor:"pointer",transition:"all 200ms ease",flexShrink:0,marginLeft:"2px"}};function Ji(n){const o=new Map;for(const s of n){const r=s.git_worktree||"main",i=s.git_branch||"main",l=!s.git_worktree||r==="main";o.has(r)||o.set(r,{id:r,branch:i,isMain:l,sessions:[]}),o.get(r).sessions.push(s)}return[...o.values()].sort((s,r)=>s.isMain!==r.isMain?s.isMain?-1:1:s.id.localeCompare(r.id))}const Gi=/^[a-zA-Z0-9_-]+$/;function wo(n){return n?Gi.test(n)?n.length>100?"Max 100 characters":null:"Letters, numbers, hyphens, underscores only":null}function Vi(n,o){const s=n.includes("\\")?"\\":"/",r=n.split(/[\\/]/),i=r.pop()||"",l=r.slice(-2).join(s);return`${s==="\\"?"":"~/"}${l}${s}${i}-${o}`}const gt=4,lt=gt*2,cn=gt*2,Ae=gt*3,dt=8;function Ki({sessions:n,pendingWorktrees:o=[],focusedSessionId:s,keyboardFocusedId:r,badges:i,onSessionClick:l,onFocusSession:c,onPlanClick:p,onAgentClick:g,onTileSessions:d,onLaunchSession:h,onCreateWorktreeSubmit:y,onDismissPendingWorktree:m,worktreeCreation:x,selectedSessionIds:b,onSelectionChange:f}){var E;const u=a.useMemo(()=>Ji(n),[n]),[v,z]=a.useState(new Set),I=b??v,P=f??z,[k,_]=a.useState(!1),[B,W]=a.useState(""),[O,M]=a.useState(null),$=a.useRef(null),C=a.useRef(!1);a.useEffect(()=>{if(k){const j=setTimeout(()=>{var R;return(R=$.current)==null?void 0:R.focus()},50);return()=>clearTimeout(j)}},[k]),a.useEffect(()=>{const j=(x==null?void 0:x.loading)??!1;k&&C.current&&!j&&!(x!=null&&x.error)&&(_(!1),W(""),M(null)),C.current=j},[x,k]);const T=a.useCallback((j,R)=>{const H=new Set(I);R?H.add(j):H.delete(j),P(H)},[I,P]),S=((E=n[0])==null?void 0:E.git_repo_root)||"",F=a.useCallback(()=>{if(!B||x!=null&&x.loading)return;const j=wo(B);if(j){M(j);return}S&&y&&y(S,B)},[B,x,S,y]),J=a.useCallback(()=>{_(!1),W(""),M(null)},[]),K=a.useCallback(j=>{const R=j.target.value;W(R),M(wo(R))},[]),re=a.useCallback(j=>{j.key==="Enter"?(j.preventDefault(),F()):j.key==="Escape"&&(j.preventDefault(),J())},[F,J]);if(!n.length)return e.jsxs("div",{style:pe.empty,children:[e.jsx(ft,{size:20,style:{opacity:.3}}),e.jsx("span",{children:"No active sessions"})]});const U=j=>{const R=j.sessions[0];if(!R)return"";if(j.isMain)return R.git_repo_root||R.cwd||"";if(R.git_worktree&&R.cwd){const H="/"+R.git_worktree,w="\\"+R.git_worktree;for(const D of[H,w]){const Y=R.cwd.lastIndexOf(D);if(Y>=0){const G=Y+D.length;if(G===R.cwd.length||R.cwd[G]==="/"||R.cwd[G]==="\\")return R.cwd.substring(0,G)}}}return R.cwd||""},Z=u.length,q=(x==null?void 0:x.loading)??!1,X=x==null?void 0:x.error,Q=O||X,V=B.length>0&&!O&&!q;return e.jsxs("div",{style:pe.root,children:[u.map((j,R)=>{const H=R===0,w=o.length>0||k||!!y,D=R===Z-1&&!w,Y=j.isMain?t.success:t.accent,G=dt+(Ae-lt)/2;return e.jsxs("div",{style:pe.group,children:[e.jsxs("div",{style:pe.nodeRow,children:[!H&&e.jsx("div",{style:{position:"absolute",left:G,top:0,width:lt,height:Ae/2+2,backgroundColor:t.borderSubtle,opacity:.35}}),e.jsx("div",{style:{width:Ae,height:Ae,backgroundColor:Y,opacity:.8,boxShadow:`0 0 8px ${Y}60, 0 0 12px ${Y}30`,marginLeft:dt,flexShrink:0,position:"relative",zIndex:1}}),e.jsx("div",{style:{width:gt*3,height:cn,backgroundColor:Y,opacity:.35,flexShrink:0}}),e.jsxs("div",{style:pe.labelRow,children:[e.jsx(ht,{size:13,color:j.isMain?t.success:t.textSecondary,strokeWidth:2}),e.jsx("span",{style:{...pe.label,color:j.isMain?t.success:t.textSecondary},children:j.id}),j.branch!==j.id&&e.jsxs("span",{style:pe.branchHint,children:["→ ",j.branch]}),h&&e.jsx("button",{onClick:()=>h(U(j)),className:"jacques-window-toolbar-btn",title:"Launch new Claude session in this worktree",style:pe.launchBtn,children:e.jsx(Wt,{size:14})})]})]}),e.jsxs("div",{style:pe.cardArea,children:[!D&&e.jsx("div",{style:{position:"absolute",left:G,top:0,bottom:0,width:lt,backgroundColor:t.borderSubtle,opacity:.35}}),e.jsx("div",{style:pe.cards,children:j.sessions.map(de=>e.jsx(Ui,{session:de,isFocused:de.session_id===s,isKeyboardFocused:de.session_id===r,badges:i.get(de.session_id),onClick:()=>l(de),onFocusClick:c?()=>c(de.session_id):void 0,onPlanClick:p?()=>p(de.session_id):void 0,onAgentClick:g?()=>g(de.session_id):void 0,isSelected:I.has(de.session_id),onSelectionChange:d?Le=>T(de.session_id,Le):void 0},de.session_id))})]})]},j.id)}),k&&S&&(()=>{const j=t.accent,R=dt+(Ae-lt)/2;return e.jsxs("div",{style:pe.group,children:[e.jsxs("div",{style:pe.nodeRow,children:[(u.length>0||o.length>0)&&e.jsx("div",{style:{position:"absolute",left:R,top:0,width:lt,height:Ae/2+2,backgroundColor:t.borderSubtle,opacity:.35}}),e.jsx("div",{style:{width:Ae,height:Ae,backgroundColor:j,opacity:q?.5:.8,boxShadow:`0 0 8px ${j}60, 0 0 12px ${j}30`,marginLeft:dt,flexShrink:0,position:"relative",zIndex:1,animation:q?"pulse-glow 1.5s ease-in-out infinite":void 0}}),e.jsx("div",{style:{width:gt*3,height:cn,backgroundColor:j,opacity:.35,flexShrink:0}}),e.jsxs("div",{style:pe.labelRow,children:[e.jsx(ht,{size:13,color:t.textSecondary,strokeWidth:2}),e.jsx("input",{ref:$,type:"text",value:B,onChange:K,onKeyDown:re,placeholder:"worktree-name",disabled:q,autoComplete:"off",spellCheck:!1,style:pe.inlineInput}),B&&!O&&e.jsxs("span",{style:pe.branchHint,children:["→ ",Vi(S,B)]}),e.jsx("button",{onClick:F,className:"jacques-window-toolbar-btn",title:q?"Creating worktree...":"Create worktree (Enter)",style:{...pe.launchBtn,opacity:q?.8:V?.6:.25,cursor:V?"pointer":"default"},disabled:!V,children:q?e.jsx(Oe,{size:13,className:"jacques-spin"}):e.jsx(No,{size:14})})]})]}),Q&&e.jsx("div",{style:pe.inlineError,children:e.jsx("span",{style:pe.inlineErrorText,children:Q})})]})})(),o.map((j,R)=>{const H=t.accent,w=dt+(Ae-lt)/2,D=u.length+R,Y=R===o.length-1&&!k&&!y;return e.jsxs("div",{style:pe.group,children:[e.jsxs("div",{style:pe.nodeRow,children:[D>0&&e.jsx("div",{style:{position:"absolute",left:w,top:0,width:lt,height:Ae/2+2,backgroundColor:t.borderSubtle,opacity:.35}}),e.jsx("div",{style:{width:Ae,height:Ae,backgroundColor:H,opacity:.6,boxShadow:`0 0 8px ${H}60, 0 0 12px ${H}30`,marginLeft:dt,flexShrink:0,position:"relative",zIndex:1,animation:"pulse-glow 1.5s ease-in-out infinite"}}),e.jsx("div",{style:{width:gt*3,height:cn,backgroundColor:H,opacity:.35,flexShrink:0}}),e.jsxs("div",{style:pe.labelRow,children:[e.jsx(ht,{size:13,color:t.textSecondary,strokeWidth:2}),e.jsx("span",{style:{...pe.label,color:t.textSecondary},children:j.id}),e.jsxs("span",{style:pe.branchHint,children:["→ ",j.branch]}),e.jsx(Oe,{size:13,className:"jacques-spin",style:{marginLeft:4,color:t.accent}}),m&&e.jsx("button",{onClick:()=>m(j.id),className:"jacques-window-toolbar-btn",title:"Dismiss — Claude Code didn't start",style:pe.launchBtn,children:e.jsx(st,{size:14})})]})]}),e.jsxs("div",{style:pe.cardArea,children:[!Y&&e.jsx("div",{style:{position:"absolute",left:w,top:0,bottom:0,width:lt,backgroundColor:t.borderSubtle,opacity:.35}}),e.jsx("div",{style:pe.pendingHint,children:"Launching Claude Code..."})]})]},`pending-${j.id}`)}),!k&&y&&n.length>0&&S&&(()=>{const j=t.textMuted,R=dt+(Ae-lt)/2,H=u.length+o.length;return e.jsx("div",{style:pe.group,children:e.jsxs("div",{style:pe.nodeRow,children:[H>0&&e.jsx("div",{style:{position:"absolute",left:R,top:0,width:lt,height:Ae/2+2,backgroundColor:t.borderSubtle,opacity:.35}}),e.jsx("div",{style:{width:Ae,height:Ae,backgroundColor:j,opacity:.4,marginLeft:dt,flexShrink:0,position:"relative",zIndex:1}}),e.jsx("div",{style:{width:gt*3,height:cn,backgroundColor:j,opacity:.2,flexShrink:0}}),e.jsx("div",{style:pe.labelRow,children:e.jsx("button",{onClick:()=>_(!0),className:"jacques-window-toolbar-btn",title:"Create a new git worktree and launch Claude in it",style:pe.launchBtn,children:e.jsx(Wt,{size:14})})})]})})})()]})}const pe={root:{display:"flex",flexDirection:"column"},group:{display:"flex",flexDirection:"column",position:"relative"},nodeRow:{display:"flex",alignItems:"center",position:"relative",paddingTop:8},labelRow:{display:"flex",alignItems:"center",gap:6,marginLeft:8},label:{fontSize:11,fontWeight:600,fontFamily:"'JetBrains Mono', monospace",letterSpacing:"0.01em",textTransform:"uppercase"},branchHint:{color:t.textMuted,opacity:.6,textTransform:"none",fontWeight:400,fontSize:10},cardArea:{display:"flex",position:"relative",paddingTop:12,paddingBottom:12,paddingLeft:dt+Ae+gt*3+20},cards:{display:"flex",flexWrap:"wrap",gap:16,flex:1},empty:{display:"flex",alignItems:"center",justifyContent:"center",gap:12,padding:"48px 24px",color:t.textMuted,fontSize:13},launchBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,border:"none",borderRadius:4,backgroundColor:"transparent",color:t.textMuted,cursor:"pointer",opacity:.6,transition:"all 150ms ease",marginLeft:4,padding:0,flexShrink:0},pendingHint:{fontSize:11,color:t.textMuted,opacity:.6,fontStyle:"italic",fontFamily:"'JetBrains Mono', monospace"},inlineInput:{fontSize:11,fontWeight:600,fontFamily:"'JetBrains Mono', monospace",letterSpacing:"0.01em",textTransform:"uppercase",color:t.textSecondary,background:"transparent",border:"none",outline:"none",padding:0,margin:0,width:160,caretColor:t.accent},inlineError:{paddingLeft:dt+Ae+gt*3+8+6+13+6,paddingTop:2,paddingBottom:4},inlineErrorText:{fontSize:10,color:t.danger,fontFamily:"'JetBrains Mono', monospace",fontWeight:500}};function Yi(n){const o=n.split("_");return o.length>=3?o.slice(2).join("_").replace(/-/g," "):n.replace(/-/g," ")}function Xi(n){const o=n.toLowerCase();return o.startsWith("explore")?"explore":o.startsWith("plan")?"plan":o.includes("search")||o.includes("web")?"search":"general"}const Zi={explore:{icon:Yt,color:"#FF6600"},plan:{icon:Re,color:"#34D399"},search:{icon:qt,color:"#60A5FA"},general:{icon:Yt,color:"#FF6600"}};function Qi({sessionId:n,type:o,onClose:s}){const[r,i]=a.useState([]),[l,c]=a.useState([]),[p,g]=a.useState(0),[d,h]=a.useState(null),[y,m]=a.useState(!0),[x,b]=a.useState(!1),[f,u]=a.useState(null),[v,z]=a.useState(!1),I=o==="plan"?r:l,P=I.length>1;a.useEffect(()=>{const W=O=>{O.key==="Escape"&&s()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[s]),a.useEffect(()=>{const W=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=W}},[]),a.useEffect(()=>{let W=!1;async function O(){m(!0),u(null);try{const M=await Zo(n);if(W)return;if(o==="plan"){const $=M.metadata.planRefs||[];i($),$.length===0&&u("No plans found in this session")}else{const $=M.subagents||[];c($),$.length===0&&u("No subagents found in this session")}}catch(M){W||u(M instanceof Error?M.message:"Failed to load session")}finally{W||m(!1)}}return O(),()=>{W=!0}},[n,o]);const k=a.useCallback(async W=>{b(!0),h(null),z(!1);try{if(o==="plan"){const O=r[W];if(!O)return;const[M,$]=await Promise.all([Qo(n,O.messageIndex),gn(n).catch(()=>null)]);h({markdown:M.content,tasks:$==null?void 0:$.tasks,taskSummary:$==null?void 0:$.summary})}else{const O=l[W];if(!O)return;const $=(await Sn(n,O.id)).entries.filter(C=>C.type==="assistant_message"&&C.content.text).map(C=>C.content.text);h({markdown:$.length>0?$[$.length-1]:"*No response available*"})}}catch(O){h({markdown:`*Error loading content: ${O instanceof Error?O.message:"Unknown error"}*`})}finally{b(!1)}},[o,r,l,n]);a.useEffect(()=>{I.length>0&&p<I.length&&k(p)},[I,p,k]);const _=W=>{W!==p&&g(W)},B=o==="plan"?`Plans (${I.length})`:`Subagents (${I.length})`;return e.jsx("div",{style:he.overlay,onClick:s,children:e.jsxs("div",{style:{...he.modal,maxWidth:P?"960px":"820px"},onClick:W=>W.stopPropagation(),children:[e.jsxs("div",{style:he.chromeBar,children:[e.jsx("div",{style:he.chromeLeft,children:e.jsx("span",{style:he.chromeTitle,children:y?o==="plan"?"Plans":"Subagents":B})}),e.jsx("button",{type:"button",style:he.closeButton,onClick:s,title:"Close (Esc)",children:e.jsx(st,{size:16})})]}),y?e.jsxs("div",{style:he.loadingContainer,children:[e.jsx(Oe,{size:20,style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"Loading..."})]}):f?e.jsx("div",{style:he.errorContainer,children:f}):e.jsxs("div",{style:he.body,children:[P&&e.jsx("div",{style:he.sidebar,children:I.map((W,O)=>{const M=O===p;if(o==="plan"){const $=W;return e.jsxs("button",{type:"button",style:{...he.sidebarItem,backgroundColor:M?"rgba(255, 255, 255, 0.06)":"transparent",borderLeftColor:M?"#34D399":"transparent"},onClick:()=>_(O),children:[e.jsx(Re,{size:14,color:"#34D399",style:{flexShrink:0}}),e.jsx("span",{style:he.sidebarText,children:$.title})]},O)}else{const $=W,C=Xi($.id),T=Zi[C],S=T.icon;return e.jsxs("button",{type:"button",style:{...he.sidebarItem,backgroundColor:M?"rgba(255, 255, 255, 0.06)":"transparent",borderLeftColor:M?T.color:"transparent"},onClick:()=>_(O),children:[e.jsx(S,{size:14,color:T.color,style:{flexShrink:0}}),e.jsx("span",{style:he.sidebarText,children:Yi($.id)})]},O)}})}),e.jsx("div",{style:he.contentArea,children:x?e.jsxs("div",{style:he.loadingContainer,children:[e.jsx(Oe,{size:20,style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"Loading content..."})]}):d?e.jsxs(e.Fragment,{children:[o==="plan"&&d.taskSummary&&d.taskSummary.total>0&&e.jsxs("div",{style:he.progressSection,children:[e.jsxs("div",{style:he.progressHeader,children:[e.jsx(vt,{size:14,color:d.taskSummary.percentage===100?t.success:t.accent}),e.jsx("span",{style:he.progressLabel,children:"Tasks"}),e.jsxs("span",{style:{...he.progressPercentage,color:d.taskSummary.percentage===100?t.success:t.accent},children:[d.taskSummary.completed,"/",d.taskSummary.total," (",d.taskSummary.percentage,"%)"]})]}),e.jsx("div",{style:he.progressTrack,children:e.jsx("div",{style:{...he.progressFill,width:`${d.taskSummary.percentage}%`,backgroundColor:d.taskSummary.percentage===100?t.success:t.accent}})}),d.tasks&&d.tasks.length>0&&e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsxs("button",{type:"button",style:he.stepsToggle,onClick:()=>z(!v),children:[v?e.jsx(tt,{size:14}):e.jsx(Fe,{size:14}),e.jsxs("span",{children:["Show tasks (",d.tasks.length,")"]})]}),v&&e.jsx("div",{style:he.stepsList,children:d.tasks.map(W=>e.jsxs("div",{style:he.stepItem,children:[e.jsx("span",{style:{display:"inline-flex",flexShrink:0},children:W.status==="completed"?e.jsx(vt,{size:14,color:t.success}):W.status==="in_progress"?e.jsx(Zn,{size:14,color:t.warning}):e.jsx(Qn,{size:14,color:t.textMuted})}),e.jsx("span",{style:{flex:1,fontSize:"12px",lineHeight:1.4,textDecoration:W.status==="completed"?"line-through":"none",color:W.status==="completed"?t.textMuted:t.textSecondary},children:W.subject})]},W.id))})]})]}),e.jsx("div",{style:he.markdownArea,children:e.jsx(pt,{content:d.markdown})})]}):null})]}),e.jsx("div",{style:he.footer,children:e.jsx("span",{style:he.footerHint,children:"Esc to close"})})]})})}const he={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"24px",backdropFilter:"blur(4px)"},modal:{width:"100%",maxHeight:"85vh",display:"flex",flexDirection:"column",backgroundColor:t.bgSecondary,borderRadius:"10px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden",boxShadow:"0 24px 48px rgba(0, 0, 0, 0.4)"},chromeBar:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:t.bgElevated,borderBottom:`1px solid ${t.borderSubtle}`,flexShrink:0},chromeLeft:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},chromeTitle:{fontSize:"14px",fontWeight:600,color:t.textPrimary},closeButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"4px",backgroundColor:"transparent",border:"none",borderRadius:"4px",color:t.textMuted,cursor:"pointer",flexShrink:0},body:{display:"flex",flex:1,minHeight:0,overflow:"hidden"},sidebar:{width:"200px",flexShrink:0,borderRight:`1px solid ${t.borderSubtle}`,overflowY:"auto",backgroundColor:t.bgPrimary},sidebarItem:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 12px",border:"none",borderLeft:"3px solid transparent",cursor:"pointer",textAlign:"left",fontSize:"12px",color:t.textSecondary,transition:"all 150ms ease"},sidebarText:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},contentArea:{flex:1,overflow:"auto",minWidth:0,display:"flex",flexDirection:"column"},progressSection:{padding:"12px 20px",borderBottom:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgPrimary,flexShrink:0},progressHeader:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},progressLabel:{fontSize:"12px",fontWeight:500,color:t.textSecondary},progressPercentage:{fontSize:"12px",fontWeight:600,fontFamily:"monospace",marginLeft:"auto"},progressTrack:{width:"100%",height:"6px",backgroundColor:t.bgInput,borderRadius:"3px",overflow:"hidden"},progressFill:{height:"100%",borderRadius:"3px",transition:"width 300ms ease"},stepsToggle:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 8px",fontSize:"12px",fontWeight:500,color:t.textSecondary,backgroundColor:"transparent",border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",cursor:"pointer"},stepsList:{marginTop:"8px",maxHeight:"200px",overflowY:"auto",border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",backgroundColor:t.bgSecondary},stepItem:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderBottom:`1px solid ${t.borderSubtle}`,fontSize:"12px"},markdownArea:{flex:1,padding:"20px 24px",overflow:"auto"},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"48px 0",color:t.textMuted,fontSize:"13px",flex:1},errorContainer:{padding:"24px",color:"#EF4444",fontSize:"13px",textAlign:"center"},footer:{display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"8px 16px",borderTop:`1px solid ${t.borderSubtle}`,flexShrink:0},footerHint:{fontSize:"11px",color:t.textMuted}};function ea({repoRoot:n,activeSessions:o,onClose:s,onRemoveSuccess:r,listWorktrees:i,removeWorktree:l,onListWorktreesResult:c,onRemoveWorktreeResult:p}){const[g,d]=a.useState([]),[h,y]=a.useState(!0),[m,x]=a.useState(null),[b,f]=a.useState(null),[u,v]=a.useState(null),[z,I]=a.useState(!0),[P,k]=a.useState(!1),_=a.useCallback(M=>{const $=M.split("/").pop()||"";return o.filter(C=>!!(C.git_worktree===$||C.cwd&&(C.cwd===M||C.cwd.startsWith(M+"/")))).length},[o]);a.useEffect(()=>{c((M,$,C)=>{y(!1),M&&$?d($.filter(T=>!T.isMain)):x(C||"Failed to list worktrees")}),p((M,$,C,T)=>{v(null),M&&$?(r($),y(!0),f(null),k(!1),i(n)):x(T||"Failed to remove worktree")})},[c,p,r,i,n]),a.useEffect(()=>{i(n)},[i,n]),a.useEffect(()=>{const M=$=>{$.key==="Escape"&&(b?(f(null),k(!1)):s())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[s,b]),a.useEffect(()=>{const M=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=M}},[]);const B=a.useCallback(M=>{f(M),k(!1),I(!0),x(null)},[]),W=a.useCallback(()=>{b&&(v(b.path),x(null),l(n,b.path,P,z))},[b,n,l,P,z]),O=a.useCallback(()=>{f(null),k(!1),x(null)},[]);return e.jsx("div",{style:te.overlay,onClick:s,children:e.jsxs("div",{style:te.modal,onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{style:te.chromeBar,children:[e.jsxs("div",{style:te.chromeLeft,children:[e.jsx(ht,{size:15,color:t.textMuted}),e.jsx("span",{style:te.chromeTitle,children:"Remove Worktree"})]}),e.jsx("button",{type:"button",style:te.closeButton,onClick:s,title:"Close (Esc)",children:e.jsx(st,{size:16})})]}),e.jsxs("div",{style:te.contentArea,children:[h?e.jsxs("div",{style:te.loadingContainer,children:[e.jsx(Oe,{size:18,className:"jacques-spin"}),e.jsx("span",{children:"Loading worktrees..."})]}):g.length===0?e.jsx("div",{style:te.emptyState,children:"No linked worktrees found."}):e.jsx("div",{style:te.worktreeList,children:g.map(M=>{const $=_(M.path),C=(b==null?void 0:b.path)===M.path,T=u===M.path;return e.jsxs("div",{style:te.worktreeRow,children:[e.jsxs("div",{style:te.worktreeInfo,children:[e.jsxs("div",{style:te.worktreeHeader,children:[e.jsx("span",{style:te.worktreeName,children:M.name}),M.branch&&M.branch!==M.name&&e.jsx("span",{style:te.branchHint,children:M.branch})]}),e.jsxs("div",{style:te.statusRow,children:[M.status.hasUncommittedChanges&&e.jsxs("span",{style:te.badgeWarning,children:[e.jsx(At,{size:10}),"Uncommitted changes"]}),M.status.isMergedToMain?e.jsxs("span",{style:te.badgeMerged,children:[e.jsx(As,{size:10}),"Merged"]}):e.jsx("span",{style:te.badgeUnmerged,children:"Unmerged"}),$>0&&e.jsxs("span",{style:te.badgeSession,children:[$," active ",$===1?"session":"sessions"]})]})]}),!C&&e.jsx("button",{onClick:()=>B(M),style:te.deleteButton,className:"jacques-window-toolbar-btn",title:"Remove this worktree",disabled:T,children:T?e.jsx(Oe,{size:14,className:"jacques-spin"}):e.jsx(_o,{size:14})}),C&&e.jsxs("div",{style:te.confirmPanel,children:[e.jsxs("div",{style:te.confirmWarnings,children:[M.status.hasUncommittedChanges&&e.jsxs("div",{style:te.confirmWarning,children:[e.jsx(At,{size:12,color:t.warning}),e.jsx("span",{children:"Uncommitted changes will be lost"})]}),!M.status.isMergedToMain&&e.jsxs("div",{style:te.confirmWarning,children:[e.jsx(At,{size:12,color:t.warning}),e.jsx("span",{children:"Branch is not merged to main"})]}),$>0&&e.jsxs("div",{style:te.confirmWarning,children:[e.jsx(At,{size:12,color:t.danger}),e.jsxs("span",{children:[$," active ",$===1?"session":"sessions"," in this worktree"]})]})]}),e.jsxs("div",{style:te.confirmOptions,children:[M.branch&&e.jsxs("div",{style:te.checkboxRow,onClick:()=>I(!z),children:[e.jsx("div",{style:{...te.checkboxBox,backgroundColor:z?t.accent:"transparent",borderColor:z?t.accent:t.borderSubtle},children:z&&e.jsx(Dt,{size:10,color:"#fff",strokeWidth:3})}),e.jsxs("span",{style:te.checkboxLabel,children:["Delete branch ",e.jsx("code",{style:te.code,children:M.branch})]})]}),M.status.hasUncommittedChanges&&e.jsxs("div",{style:te.checkboxRow,onClick:()=>k(!P),children:[e.jsx("div",{style:{...te.checkboxBox,backgroundColor:P?t.danger:"transparent",borderColor:P?t.danger:t.borderSubtle},children:P&&e.jsx(Dt,{size:10,color:"#fff",strokeWidth:3})}),e.jsx("span",{style:te.checkboxLabel,children:"Force remove (discard changes)"})]})]}),e.jsxs("div",{style:te.confirmActions,children:[e.jsx("button",{onClick:O,style:te.cancelBtn,children:"Cancel"}),e.jsx("button",{onClick:W,style:{...te.confirmBtn,opacity:M.status.hasUncommittedChanges&&!P?.4:1,cursor:M.status.hasUncommittedChanges&&!P?"not-allowed":"pointer"},disabled:M.status.hasUncommittedChanges&&!P,children:T?e.jsx(Oe,{size:12,className:"jacques-spin"}):"Remove"})]})]})]},M.path)})}),m&&e.jsx("div",{style:te.errorBar,children:m})]}),e.jsx("div",{style:te.footer,children:e.jsx("span",{style:te.footerHint,children:"Esc to close"})})]})})}const te={overlay:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.75)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"24px",backdropFilter:"blur(4px)"},modal:{width:"100%",maxWidth:"520px",maxHeight:"70vh",display:"flex",flexDirection:"column",backgroundColor:t.bgSecondary,borderRadius:"10px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden",boxShadow:"0 24px 48px rgba(0, 0, 0, 0.4)"},chromeBar:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",backgroundColor:t.bgElevated,borderBottom:`1px solid ${t.borderSubtle}`,flexShrink:0},chromeLeft:{display:"flex",alignItems:"center",gap:"8px"},chromeTitle:{fontSize:"14px",fontWeight:600,color:t.textPrimary},closeButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"4px",backgroundColor:"transparent",border:"none",borderRadius:"4px",color:t.textMuted,cursor:"pointer",flexShrink:0},contentArea:{flex:1,overflow:"auto",padding:"12px 16px",minHeight:0},loadingContainer:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"36px 0",color:t.textMuted,fontSize:"13px"},emptyState:{padding:"36px 0",textAlign:"center",color:t.textMuted,fontSize:"13px"},worktreeList:{display:"flex",flexDirection:"column",gap:"4px"},worktreeRow:{display:"flex",flexDirection:"column",padding:"10px 12px",borderRadius:"6px",backgroundColor:t.bgPrimary,border:`1px solid ${t.borderSubtle}`},worktreeInfo:{display:"flex",flexDirection:"column",gap:"6px",flex:1},worktreeHeader:{display:"flex",alignItems:"center",gap:"8px",justifyContent:"space-between"},worktreeName:{fontSize:"12px",fontWeight:600,fontFamily:"'JetBrains Mono', monospace",color:t.textPrimary,letterSpacing:"0.01em"},branchHint:{fontSize:"10px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace"},statusRow:{display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap",justifyContent:"space-between"},badgeWarning:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:500,backgroundColor:"rgba(251, 191, 36, 0.12)",color:t.warning},badgeMerged:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:500,backgroundColor:"rgba(74, 222, 128, 0.12)",color:t.success},badgeUnmerged:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:500,backgroundColor:"rgba(239, 68, 68, 0.12)",color:t.danger},badgeSession:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"3px",fontSize:"10px",fontWeight:500,backgroundColor:"rgba(230, 126, 82, 0.12)",color:t.accent},deleteButton:{display:"flex",alignItems:"center",justifyContent:"center",alignSelf:"flex-end",width:28,height:28,border:"none",borderRadius:4,backgroundColor:"transparent",color:t.textMuted,cursor:"pointer",opacity:.6,transition:"all 150ms ease",padding:0,flexShrink:0,marginTop:4},confirmPanel:{marginTop:"8px",paddingTop:"8px",borderTop:`1px solid ${t.borderSubtle}`,display:"flex",flexDirection:"column",gap:"8px"},confirmWarnings:{display:"flex",flexDirection:"column",gap:"4px"},confirmWarning:{display:"flex",alignItems:"center",gap:"6px",fontSize:"11px",color:t.textSecondary},confirmOptions:{display:"flex",flexDirection:"column",gap:"4px"},checkboxRow:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",padding:"3px 0"},checkboxBox:{width:14,height:14,borderRadius:3,border:`1.5px solid ${t.borderSubtle}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 150ms ease"},checkboxLabel:{fontSize:"11px",color:t.textSecondary},code:{fontFamily:"'JetBrains Mono', monospace",fontSize:"10px",padding:"1px 4px",borderRadius:"3px",backgroundColor:t.bgElevated,color:t.textPrimary},confirmActions:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"4px"},cancelBtn:{padding:"4px 12px",fontSize:"11px",fontWeight:500,borderRadius:"4px",border:`1px solid ${t.borderSubtle}`,backgroundColor:"transparent",color:t.textSecondary,cursor:"pointer"},confirmBtn:{padding:"4px 12px",fontSize:"11px",fontWeight:600,borderRadius:"4px",border:"none",backgroundColor:t.danger,color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},errorBar:{marginTop:"8px",padding:"8px 12px",borderRadius:"4px",backgroundColor:"rgba(239, 68, 68, 0.1)",color:t.danger,fontSize:"11px",fontFamily:"'JetBrains Mono', monospace"},footer:{display:"flex",alignItems:"center",justifyContent:"flex-end",padding:"8px 16px",borderTop:`1px solid ${t.borderSubtle}`,flexShrink:0},footerHint:{fontSize:"11px",color:t.textMuted}};function Vt({icon:n,title:o,disabled:s,highlighted:r,onClick:i}){return e.jsx("button",{onClick:s?void 0:i,title:o,style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,border:"none",borderRadius:4,cursor:s?"not-allowed":"pointer",backgroundColor:"transparent",color:r?t.accent:t.textMuted,opacity:s?.2:r?.95:.6,transition:"all 150ms ease",flexShrink:0,padding:0,boxShadow:r?"inset 0 0 8px rgba(230, 126, 82, 0.35)":"none"},className:"jacques-window-toolbar-btn",disabled:s,children:n})}function ta({selectedCount:n,hasSelection:o,hasTwoSelected:s,onMaximize:r,onTileSelected:i,onFocus:l,onBrowserLayout:c,onManageWorktrees:p,manageWorktreesDisabled:g}){const d=n>=2;return e.jsxs("div",{style:Bn.toolbar,children:[e.jsx(Vt,{icon:e.jsx(_s,{size:14}),title:"(f)ullscreen",disabled:!o,highlighted:n<=1&&o,onClick:r}),e.jsx(Vt,{icon:e.jsx(Ho,{size:14}),title:"(t)ile selected",disabled:!s,highlighted:d,onClick:i}),e.jsx(Vt,{icon:e.jsx(Wo,{size:14}),title:"focus (Enter)",disabled:!o,highlighted:n<=1&&o,onClick:l}),e.jsx("div",{style:Bn.separator}),e.jsx(Vt,{icon:e.jsx(Fs,{size:14}),title:n>=2?"(b)rowser + 2 terminals":"(b)rowser + terminal",disabled:!o,highlighted:o,onClick:c}),p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:Bn.separator}),e.jsx(Vt,{icon:e.jsx(Ds,{size:14}),title:"(w)orktrees",disabled:g??!0,onClick:p})]})]})}const Bn={toolbar:{display:"flex",alignItems:"center",gap:2,flexShrink:0},separator:{width:1,height:16,backgroundColor:t.textMuted,opacity:.15,margin:"0 4px",flexShrink:0}},Mn={plan:"#34D399",agent:"#FF6600"},ae={coral:t.accent,teal:"#2DD4BF",blue:"#60A5FA",yellow:"#FBBF24",muted:t.textSecondary,text:"#E5E7EB",textDim:t.textMuted,bg:t.bgPrimary,bgCard:t.bgSecondary,success:t.success,danger:t.danger};function na(n){const o=new Date(n),r=new Date().getTime()-o.getTime(),i=Math.floor(r/6e4);if(i<60)return`${i}m ago`;const l=Math.floor(i/60);if(l<24)return`${l}h ago`;const c=Math.floor(l/24);return c===1?"Yesterday":c<7?`${c}d ago`:o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function oa(n,o){let s=0,r=0;for(const i of n)i.context_metrics&&(s+=i.context_metrics.total_input_tokens||0,r+=i.context_metrics.total_output_tokens||0);for(const i of o)i.tokens&&(s+=i.tokens.input+i.tokens.cacheRead,r+=i.tokens.output);return{totalSessions:n.length+o.length,totalInputTokens:s,totalOutputTokens:r}}function sa(n,o){var i,l,c,p,g;const s=[],r=new Set;for(const d of n){r.add(d.session_id);const{isPlan:h,displayTitle:y}=us(d.session_title);s.push({id:d.session_id,title:d.session_title||"Untitled",displayTitle:y,isPlan:h,source:"live",date:new Date(d.registered_at).toISOString(),contextPercent:(i=d.context_metrics)!=null&&i.used_percentage?Math.round(d.context_metrics.used_percentage):void 0,isActive:d.status==="active"||d.status==="working",status:d.status,inputTokens:((l=d.context_metrics)==null?void 0:l.total_input_tokens)||void 0,outputTokens:((c=d.context_metrics)==null?void 0:c.total_output_tokens)||void 0,project:d.project,gitBranch:d.git_branch||void 0,gitWorktree:d.git_worktree||void 0})}for(const d of o){if(r.has(d.id))continue;r.add(d.id);let h=d.title,y=!1;(d.mode==="execution"||d.mode==="acceptEdits")&&d.planRefs&&d.planRefs.length>0&&(h=d.planRefs[0].title.replace(/^Plan:\s*/i,""),y=!0),s.push({id:d.id,title:d.title,displayTitle:h,isPlan:y,source:"saved",date:d.endedAt,planCount:d.planCount,agentCount:(p=d.subagentIds)==null?void 0:p.length,inputTokens:d.tokens?d.tokens.input+d.tokens.cacheRead:void 0,outputTokens:((g=d.tokens)==null?void 0:g.output)||void 0,project:d.projectSlug,gitBranch:d.gitBranch||void 0,gitWorktree:d.gitWorktree||void 0})}return s.sort((d,h)=>new Date(h.date).getTime()-new Date(d.date).getTime()),s}function ra(){return e.jsxs("div",{style:ie.historyRow,children:[e.jsxs("div",{style:ie.historyRowMain,children:[e.jsx("div",{className:"jacques-skeleton",style:{width:10,height:10,borderRadius:"50%",flexShrink:0}}),e.jsx("div",{className:"jacques-skeleton",style:{flex:1,height:14,borderRadius:4}}),e.jsx("div",{className:"jacques-skeleton",style:{width:48,height:12,borderRadius:4,flexShrink:0}})]}),e.jsxs("div",{style:ie.historyMetaRow,children:[e.jsx("div",{className:"jacques-skeleton",style:{width:40,height:11,borderRadius:3}}),e.jsx("div",{className:"jacques-skeleton",style:{width:40,height:11,borderRadius:3}})]})]})}const ko=10,ia=10;function aa(){const{sessions:n,focusedSessionId:o,connected:s,focusTerminal:r,tileWindows:i,maximizeWindow:l,positionBrowserLayout:c,smartTileAdd:p,createWorktree:g,onCreateWorktreeResult:d,listWorktrees:h,removeWorktree:y,onListWorktreesResult:m,onRemoveWorktreeResult:x}=jn(),{selectedProject:b,filterSessions:f}=wt(),u=mt(),{projectSlug:v}=Lo(),[z,I]=a.useState({}),[P,k]=a.useState(!0),[_,B]=a.useState(null),[W,O]=a.useState(null),[M,$]=a.useState(null),[C,T]=a.useState(new Set),[S,F]=a.useState(null),[J,K]=a.useState(ko),[re,U]=a.useState(()=>{try{return localStorage.getItem("jacques-history-collapsed")!=="false"}catch{return!0}}),Z=a.useRef(null);a.useEffect(()=>{async function A(){try{k(!0);const N=await oo();I(N.projects)}catch(N){B(N instanceof Error?N.message:"Failed to load sessions")}finally{k(!1)}}A()},[]),a.useEffect(()=>{K(ko)},[b]);const q=a.useMemo(()=>f(n),[n,f]),X=a.useMemo(()=>b?z[b]||[]:Object.values(z).flat(),[b,z]),Q=a.useMemo(()=>oa(q,X),[q,X]),V=a.useMemo(()=>sa(q,X),[q,X]),E=a.useMemo(()=>V.filter(A=>A.source!=="live"),[V]);a.useEffect(()=>{const A=Z.current;if(!A)return;const N=new IntersectionObserver(ve=>{ve[0].isIntersecting&&K(rt=>Math.min(rt+ia,E.length))},{rootMargin:"100px"});return N.observe(A),()=>N.disconnect()},[E.length]);const j=a.useMemo(()=>q.map(A=>A.session_id),[q]),{badges:R}=Mi(j),H=A=>{const N=A.project||v;N&&u(`/${N}/sessions/${A.session_id}`)},w=a.useCallback(A=>{r(A)},[r]),D=a.useCallback((A,N)=>{i(A,N)},[i]),Y=a.useCallback(A=>{const N=Kn("dangerouslySkipPermissions",!1);p(A,void 0,N||void 0)},[p]),G=a.useCallback((A,N)=>{$({loading:!0});const ve=Kn("dangerouslySkipPermissions",!1);g(A,N,void 0,ve||void 0)},[g]);a.useEffect(()=>{d((A,N,ve,rt,Ql,js)=>{if(A){$(null);const Ss=(N==null?void 0:N.split(/[\\/]/).pop())||"worktree";xt.push({title:"Worktree Created",body:`Created ${Ss}`,priority:"low",category:"operation"})}else $({loading:!1,error:js||"Failed to create worktree"})})},[d]);const de=a.useCallback(()=>{var N;const A=(N=q.find(ve=>ve.git_repo_root))==null?void 0:N.git_repo_root;A&&F({repoRoot:A})},[q]),Le=a.useCallback(A=>{const N=A.split(/[\\/]/).pop()||"worktree";xt.push({title:"Worktree Removed",body:`Removed ${N}`,priority:"low",category:"operation"})},[]),kn=a.useCallback(A=>{O({sessionId:A,type:"plan"})},[]),tn=a.useCallback(A=>{O({sessionId:A,type:"agent"})},[]),ro=A=>{const N=A.project||v;N&&u(`/${N}/sessions/${A.id}`)},Cn=a.useCallback(()=>{U(A=>{const N=!A;try{localStorage.setItem("jacques-history-collapsed",String(N))}catch{}return N})},[]),{setActiveZone:io}=vn(),{registerAction:Pe}=wn(),[Ct,It]=a.useState(-1);a.useEffect(()=>{io("dashboard")},[io]);const Gt=a.useMemo(()=>q.map(A=>A.session_id),[q]),Tt=a.useMemo(()=>{const A=[0],N=new Set;for(let ve=0;ve<q.length;ve++){const rt=q[ve].git_worktree||"main";N.has(rt)||(N.size>0&&A.push(ve),N.add(rt))}return A},[q]),Be=Ct>=0&&Ct<Gt.length?Gt[Ct]:null,ut=a.useCallback(()=>C.size>0?Array.from(C)[0]:Be||o||null,[C,Be,o]),hs=a.useCallback(()=>{const A=ut();A&&l(A)},[ut,l]),In=a.useCallback(()=>{if(C.size>=2){const A=Array.from(C);i(A)}},[C,i]),fs=a.useCallback(()=>{const A=ut();A&&r(A)},[ut,r]),Tn=a.useCallback(()=>{if(C.size>=2){const A=Array.from(C).slice(0,2);c(A,"browser-two-terminals")}else{const A=ut();A&&c([A],"browser-terminal")}},[C,ut,c]);a.useEffect(()=>{if(!Be)return;const A=document.querySelector(`[data-session-id="${Be}"]`)||document.querySelector(".is-keyboard-focused");A&&A.scrollIntoView({block:"nearest",behavior:"smooth"})},[Be]),a.useEffect(()=>{const A=[Pe("session.next",()=>{It(N=>Math.min(N+1,Gt.length-1))}),Pe("session.next-arrow",()=>{It(N=>Math.min(N+1,Gt.length-1))}),Pe("session.prev",()=>{It(N=>Math.max(N-1,0))}),Pe("session.prev-arrow",()=>{It(N=>Math.max(N-1,0))}),Pe("session.next-worktree",()=>{const N=Tt.findIndex(ve=>ve>Ct);N>=0&&It(Tt[N])}),Pe("session.prev-worktree",()=>{const N=[...Tt].reverse().findIndex(ve=>ve<Ct);N>=0&&It(Tt[Tt.length-1-N])}),Pe("session.toggle-select",()=>{if(!Be)return;const N=new Set(C);N.has(Be)?N.delete(Be):N.add(Be),T(N)}),Pe("session.select-all",()=>{T(new Set(q.map(N=>N.session_id)))}),Pe("session.deselect-all",()=>{T(new Set)}),Pe("session.focus-terminal",()=>{const N=Be||ut();N&&r(N)}),Pe("session.open",()=>{if(!Be)return;const N=q.find(ve=>ve.session_id===Be);N&&H(N)}),Pe("tile.fullscreen",()=>{const N=Be||ut();N&&l(N)}),Pe("tile.tile-selected",()=>In()),Pe("tile.browser-layout",()=>Tn()),Pe("terminal.launch",()=>{var ve;if(!Be){(ve=q[0])!=null&&ve.cwd&&Y(q[0].cwd);return}const N=q.find(rt=>rt.session_id===Be);N!=null&&N.cwd&&Y(N.cwd)}),Pe("terminal.manage-worktrees",()=>de()),Pe("history.toggle",()=>Cn())];return()=>A.forEach(N=>N())},[Pe,Gt,Ct,Be,C,q,E,Tt,r,l,In,Tn,Y,de,Cn,ut,T,H,ro]);const ms=a.useCallback(A=>{if(C.size===0)return;const N=A.target;N.closest("button")||N.closest("input")||T(new Set)},[C,T]),ys=C.size>0||!!Be||!!o,bs=E.slice(0,J);return e.jsxs("div",{className:"jacques-dashboard",style:ie.viewport,children:[e.jsxs("div",{style:ie.container,children:[e.jsxs("header",{style:ie.header,className:"jacques-animate-in",children:[e.jsxs("div",{style:ie.headerLeft,children:[e.jsx("span",{style:ie.headerPrefix,children:"~/"}),e.jsx("h1",{style:ie.headerTitle,children:b?b.split("/").pop():"All Projects"}),e.jsx("span",{style:ie.headerSlash,children:"/"}),e.jsx("span",{style:ie.headerPage,children:"sessions"})]}),e.jsxs("div",{style:ie.headerRight,children:[e.jsxs("span",{style:ie.microStat,children:[e.jsx(Ws,{size:10}),_t(Q.totalInputTokens)]}),e.jsxs("span",{style:ie.microStat,children:[e.jsx(Ns,{size:10}),_t(Q.totalOutputTokens)]}),e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",backgroundColor:s?ae.success:ae.danger,opacity:s?.6:1,flexShrink:0},title:s?"Connected":"Disconnected"})]})]}),_&&e.jsx("div",{style:ie.errorBanner,children:_}),e.jsx(ta,{selectedCount:C.size,hasSelection:ys,hasTwoSelected:C.size>=2,onMaximize:hs,onTileSelected:In,onFocus:fs,onBrowserLayout:Tn,onManageWorktrees:de,manageWorktreesDisabled:!q.some(A=>A.git_repo_root)}),e.jsxs("section",{className:"jacques-animate-in",style:ie.activeSection,onClick:ms,children:[e.jsx(Ut,{title:`ACTIVE SESSIONS (${q.length})`,accentColor:ae.coral}),e.jsx(Ki,{sessions:q,focusedSessionId:o,keyboardFocusedId:Be,badges:R,selectedSessionIds:C,onSelectionChange:T,onSessionClick:H,onFocusSession:w,onPlanClick:kn,onAgentClick:tn,onTileSessions:D,onLaunchSession:Y,onCreateWorktreeSubmit:G,worktreeCreation:M||void 0})]}),e.jsxs("section",{className:"jacques-animate-in",style:ie.historySection,children:[e.jsxs("div",{onClick:Cn,style:ie.historyBar,className:"jacques-window-toolbar-btn",children:[e.jsx("span",{style:{color:ae.coral,marginRight:"8px",fontSize:"10px",opacity:.8,transition:"transform 0.2s ease",display:"inline-block",transform:re?"rotate(0deg)":"rotate(90deg)"},children:"▸"}),e.jsx("span",{style:ie.historyBarLabel,children:"SESSION HISTORY"}),E.length>0&&e.jsx("span",{style:ie.historyBarCount,children:E.length})]}),!re&&(P?e.jsx("div",{style:ie.historyList,children:Array.from({length:4},(A,N)=>e.jsx(ra,{},N))}):E.length===0?e.jsx("div",{style:ie.emptyText,children:"No sessions yet"}):e.jsx("div",{className:"jacques-dashboard",style:ie.historyScrollable,children:e.jsxs("div",{style:ie.historyList,children:[bs.map((A,N)=>{const ve=A.source==="live",rt=ve?A.status==="working"?ae.coral:ae.success:ae.textDim;return e.jsxs("div",{"data-session-id":A.id,className:"jacques-history-row jacques-animate-in",style:{...ie.historyRow,animationDelay:`${N*40}ms`},onClick:()=>ro(A),children:[e.jsxs("div",{style:ie.historyRowMain,children:[e.jsx(li,{size:10,color:rt,filled:ve,style:{flexShrink:0,filter:ve&&A.status==="working"?`drop-shadow(0 0 4px ${rt})`:"none"}}),e.jsxs("div",{style:ie.historyTitleWrap,children:[A.isPlan&&e.jsx(Ot,{size:13,color:Mn.plan,style:{flexShrink:0,marginRight:"6px"}}),e.jsx("span",{style:ie.historyTitle,children:A.displayTitle})]}),e.jsx("span",{style:ie.historyDate,children:na(A.date)}),A.contextPercent!==void 0&&e.jsxs("span",{style:{...ie.contextBadge,color:A.contextPercent>70?ae.yellow:ae.coral,backgroundColor:A.contextPercent>70?`${ae.yellow}20`:`${ae.coral}20`},children:[A.contextPercent,"%"]})]}),e.jsxs("div",{style:ie.historyMetaRow,children:[A.gitBranch&&e.jsxs("span",{style:ie.historyGit,children:[e.jsx(ht,{size:10,color:ae.muted}),e.jsx("span",{children:A.gitBranch}),A.gitWorktree&&e.jsxs("span",{style:{opacity:.6},children:["(",A.gitWorktree,")"]})]}),A.inputTokens!==void 0&&e.jsxs("span",{style:ie.historyTokens,children:[e.jsx("span",{style:{color:ae.teal},children:"↓"})," ",_t(A.inputTokens)]}),A.outputTokens!==void 0&&e.jsxs("span",{style:ie.historyTokens,children:[e.jsx("span",{style:{color:ae.blue},children:"↑"})," ",_t(A.outputTokens)]}),A.planCount!==void 0&&A.planCount>0&&e.jsxs("span",{style:ie.historyBadge,children:[e.jsx(Ot,{size:11,color:Mn.plan}),e.jsx("span",{children:A.planCount})]}),A.agentCount!==void 0&&A.agentCount>0&&e.jsxs("span",{style:ie.historyBadge,children:[e.jsx(rs,{size:11,color:Mn.agent}),e.jsx("span",{children:A.agentCount})]})]})]},A.id)}),J<E.length&&e.jsx("div",{ref:Z,style:{height:1}})]})}))]})]}),W&&e.jsx(Qi,{sessionId:W.sessionId,type:W.type,onClose:()=>O(null)}),S&&e.jsx(ea,{repoRoot:S.repoRoot,activeSessions:q,onClose:()=>F(null),onRemoveSuccess:Le,listWorktrees:h,removeWorktree:y,onListWorktreesResult:m,onRemoveWorktreeResult:x})]})}const ie={viewport:{width:"100%",height:"100%",backgroundColor:ae.bg,overflow:"hidden"},container:{height:"100%",padding:"24px 32px 0",fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",fontSize:"13px",color:ae.text,lineHeight:1.6,display:"flex",flexDirection:"column",gap:"16px",overflow:"hidden"},header:{display:"flex",justifyContent:"space-between",alignItems:"baseline",flexShrink:0},headerLeft:{display:"flex",alignItems:"baseline",gap:"2px",minWidth:0},headerPrefix:{fontSize:"15px",fontWeight:500,color:ae.textDim,opacity:.5,userSelect:"none",flexShrink:0},headerTitle:{fontSize:"18px",fontWeight:600,color:t.textPrimary,margin:0,whiteSpace:"nowrap"},headerSlash:{fontSize:"15px",fontWeight:400,color:ae.textDim,opacity:.3,margin:"0 5px"},headerPage:{fontSize:"18px",fontWeight:600,color:ae.muted},headerRight:{display:"flex",alignItems:"center",gap:"12px",flexShrink:0},microStat:{display:"inline-flex",alignItems:"center",gap:"3px",fontSize:"10px",color:ae.textDim,fontFamily:"monospace"},errorBanner:{padding:"12px 16px",backgroundColor:`${ae.danger}15`,border:`1px solid ${ae.danger}40`,borderRadius:"4px",fontSize:"12px",color:ae.danger,flexShrink:0},activeSection:{flex:1,overflow:"auto",minHeight:0},historySection:{flexShrink:0,marginTop:"auto",margin:"auto -32px 0",padding:"0 32px"},historyBar:{display:"flex",alignItems:"center",padding:"10px 32px",margin:"0 -32px",cursor:"pointer",borderTop:`1px solid ${t.borderSubtle}`,userSelect:"none",transition:"background-color 0.15s ease"},historyBarLabel:{fontSize:"11px",fontWeight:600,color:ae.muted,letterSpacing:"0.15em",textTransform:"uppercase",flex:1},historyBarCount:{fontSize:"10px",color:ae.textDim,fontWeight:500},historyScrollable:{maxHeight:"260px",overflowY:"auto",overflowX:"hidden"},historyList:{display:"flex",flexDirection:"column",gap:"6px"},historyRow:{display:"flex",flexDirection:"column",gap:"4px",padding:"12px 16px",backgroundColor:ae.bgCard,borderRadius:"8px",border:`1px solid ${ae.textDim}18`,cursor:"pointer"},historyRowMain:{display:"flex",alignItems:"center",gap:"12px"},historyTitleWrap:{flex:1,display:"flex",alignItems:"center",minWidth:0},historyTitle:{color:ae.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},historyDate:{fontSize:"11px",color:ae.muted,flexShrink:0},contextBadge:{fontSize:"10px",fontWeight:600,padding:"3px 8px",borderRadius:"3px",fontFamily:"monospace",flexShrink:0},historyMetaRow:{display:"flex",alignItems:"center",gap:"12px",paddingLeft:"22px"},historyGit:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",color:ae.muted,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"},historyTokens:{display:"inline-flex",alignItems:"center",gap:"3px",fontSize:"11px",color:ae.muted,fontFamily:"monospace"},historyBadge:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",color:ae.muted,opacity:.5},emptyText:{fontSize:"12px",color:ae.textDim,fontStyle:"italic",padding:"12px 0"}};function la(n){const o=new Date(n),r=Math.floor((new Date().getTime()-o.getTime())/(1e3*60*60*24));return r===0?"Today":r===1?"Yesterday":r<7?o.toLocaleDateString("en-US",{weekday:"long"}):o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function Co(n){return n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(0)}K`:n.toString()}function ca(){var T;const n=mt(),{openSession:o}=Jt(),{refreshProjects:s}=wt(),[r,i]=a.useState(null),[l,c]=a.useState({}),[p,g]=a.useState(new Set),[d,h]=a.useState(""),[y,m]=a.useState(null),[x,b]=a.useState(!0),[f,u]=a.useState(null),[v,z]=a.useState(null),[I,P]=a.useState(null),[k,_]=a.useState(!1),B=a.useCallback(async()=>{b(!0),u(null);try{const[S,F]=await Promise.all([Hr(),oo()]);i(S),c(F.projects);const J=Object.keys(F.projects);J.length===1&&g(new Set([J[0]]))}catch(S){u(S instanceof Error?S.message:"Failed to load sessions")}finally{b(!1)}},[]);a.useEffect(()=>{B()},[B]),a.useEffect(()=>{if(!d.trim()){m(null);return}const S=d.toLowerCase(),J=Object.values(l).flat().filter(K=>K.title.toLowerCase().includes(S)||K.projectSlug.toLowerCase().includes(S));m(J)},[d,l]);const W=()=>{_(!0),z(null),P(null),es({onProgress:S=>z(S),onComplete:S=>{P({indexed:S.indexed}),_(!1),B(),s()},onError:S=>{u(S),_(!1)}})},O=S=>{o({id:S.id,type:"archived",title:S.title,project:S.projectSlug}),n("/")},M=S=>{g(F=>{const J=new Set(F);return J.has(S)?J.delete(S):J.add(S),J})},$=y?{"Search Results":y}:l,C=Object.keys($).sort();return e.jsxs("div",{style:le.container,children:[e.jsxs("div",{style:le.header,children:[e.jsxs("div",{style:le.titleSection,children:[e.jsx(Ut,{title:"Sessions"}),r&&e.jsxs("div",{style:le.statsBadges,children:[e.jsx($e,{label:`${r.totalSessions} sessions`,variant:"default"}),e.jsx($e,{label:`${r.totalProjects} projects`,variant:"default"}),e.jsx($e,{label:r.sizeFormatted,variant:"default"})]})]}),e.jsxs("button",{style:{...le.rebuildButton,opacity:k?.7:1,cursor:k?"not-allowed":"pointer"},onClick:W,disabled:k,type:"button",title:"Sync sessions",children:[e.jsx(Nt,{size:14,style:{animation:k?"spin 1s linear infinite":"none"}}),k?"Syncing...":"Sync"]})]}),v&&e.jsxs(xn,{title:"rebuilding-index...",showDots:!0,children:[e.jsxs("div",{style:le.progressHeader,children:[e.jsx("span",{style:le.progressPhase,children:v.phase==="extracting"?"Extracting catalogs...":(T=v.current)!=null&&T.startsWith("Scanning")?"Scanning projects...":"Indexing sessions..."}),e.jsxs("span",{style:le.progressCount,children:[v.completed,"/",v.total]})]}),e.jsx("div",{style:le.progressBar,children:e.jsx("div",{style:{...le.progressFill,width:v.total>0?`${v.completed/v.total*100}%`:"0%"}})}),e.jsx("div",{style:le.progressDetails,children:e.jsx("span",{children:v.current})})]}),I&&!k&&e.jsxs("div",{style:le.resultBanner,children:["Synced: ",I.indexed," sessions indexed"]}),e.jsx("div",{style:le.searchSection,children:e.jsx(or,{value:d,onChange:h,placeholder:"Search sessions...",resultCount:y!==null?y.length:void 0})}),f&&e.jsxs("div",{style:le.errorBanner,children:[f,e.jsx("button",{style:le.dismissButton,onClick:()=>u(null),type:"button",children:"x"})]}),x&&e.jsxs("div",{style:le.loading,children:[e.jsx(Nt,{size:16,style:{animation:"spin 1s linear infinite"}}),"Loading sessions..."]}),!x&&C.length===0&&e.jsx(xn,{title:"sessions",showDots:!0,children:e.jsx(rr,{icon:Oo,title:"No sessions found",description:'Start a Claude Code session in any project to see it here. Click "Rebuild Index" to scan for existing sessions.'})}),!x&&C.length>0&&e.jsx("div",{style:le.projectList,children:C.map(S=>{const F=$[S],J=p.has(S);return e.jsxs(xn,{title:S,showDots:!0,headerRight:e.jsx($e,{label:`${F.length} session${F.length!==1?"s":""}`,variant:"default"}),noPadding:!0,children:[e.jsxs("button",{style:le.projectToggle,onClick:()=>M(S),type:"button",children:[e.jsx("span",{style:{...le.projectIcon,transform:J?"rotate(90deg)":"none"},children:"▶"}),e.jsxs("span",{style:le.projectName,children:[F.length," session",F.length!==1?"s":""," — click to ",J?"collapse":"expand"]})]}),J&&e.jsx("div",{style:le.sessionList,children:F.map((K,re)=>{var U;return e.jsx("button",{style:le.sessionCard,onClick:()=>O(K),type:"button",children:e.jsxs("div",{style:le.cardRow,children:[e.jsx("span",{style:le.lineNum,children:re+1}),e.jsxs("div",{style:le.cardContent,children:[e.jsxs("div",{style:le.cardHeader,children:[e.jsx("span",{style:le.cardTitle,children:K.title}),e.jsxs("div",{style:le.cardBadges,children:[(K.mode==="planning"||K.mode==="plan")&&e.jsx($e,{label:"Planning",variant:"planning"}),K.mode==="bypass"&&e.jsx($e,{label:"p-less",variant:"p-less"}),(K.mode==="execution"||K.mode==="acceptEdits"||K.mode==="default")&&K.mode!==null&&e.jsx($e,{label:"Executing",variant:"execution"}),K.planCount&&K.planCount>0&&e.jsx($e,{label:`${K.planCount} plan${K.planCount>1?"s":""}`,variant:"plan"}),K.hadAutoCompact&&e.jsx($e,{label:"compacted",variant:"compacted"})]}),e.jsx("span",{style:le.cardDate,children:la(K.endedAt)})]}),e.jsxs("div",{style:le.cardMeta,children:[e.jsx($e,{label:`${K.messageCount} msgs`,variant:"default"}),e.jsx($e,{label:`${K.toolCallCount} tools`,variant:"default"}),K.hasSubagents&&e.jsx($e,{label:`${((U=K.subagentIds)==null?void 0:U.length)||"?"} agents`,variant:"agent"}),K.tokens&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:le.tokenBadge,children:[Co(K.tokens.input+K.tokens.cacheCreation+K.tokens.cacheRead)," in"]}),e.jsxs("span",{style:le.tokenBadge,children:[Co(K.tokens.output)," out"]})]})]})]})]})},K.id)})})]},S)})})]})}const le={container:{maxWidth:"1200px",padding:"24px",display:"flex",flexDirection:"column",gap:"16px"},header:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},titleSection:{display:"flex",flexDirection:"column",gap:"8px"},statsBadges:{display:"flex",gap:"8px"},rebuildButton:{padding:"8px 16px",fontSize:"13px",fontWeight:500,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",backgroundColor:t.bgSecondary,color:t.textSecondary,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease"},progressHeader:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},progressPhase:{fontSize:"13px",color:t.textPrimary,fontWeight:500},progressCount:{fontSize:"12px",color:t.textMuted},progressBar:{height:"6px",backgroundColor:t.bgElevated,borderRadius:"3px",overflow:"hidden",marginBottom:"8px"},progressFill:{height:"100%",backgroundColor:t.accent,borderRadius:"3px",transition:"width 200ms ease"},progressDetails:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:t.textMuted},resultBanner:{padding:"12px 16px",backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.success}`,fontSize:"13px",color:t.success},searchSection:{display:"flex",alignItems:"center",gap:"12px"},errorBanner:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.danger}`,fontSize:"13px",color:t.danger},dismissButton:{padding:"4px 8px",backgroundColor:"transparent",border:"none",color:t.danger,cursor:"pointer",fontSize:"18px"},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"48px",color:t.textMuted,fontSize:"14px"},projectList:{display:"flex",flexDirection:"column",gap:"12px"},projectToggle:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",border:"none",borderBottom:`1px solid ${t.borderSubtle}`,cursor:"pointer",textAlign:"left",color:t.textSecondary,fontSize:"12px"},projectIcon:{fontSize:"8px",color:t.textMuted,transition:"transform 150ms ease"},projectName:{color:t.textMuted,fontSize:"12px"},sessionList:{display:"flex",flexDirection:"column"},sessionCard:{display:"block",width:"100%",padding:"0",backgroundColor:"transparent",border:"none",borderBottom:`1px solid ${t.borderSubtle}`,textAlign:"left",cursor:"pointer",transition:"background-color 150ms ease"},cardRow:{display:"flex",alignItems:"flex-start",padding:"12px 16px"},lineNum:{width:"32px",fontSize:"11px",color:t.textMuted,opacity:.4,textAlign:"right",paddingRight:"12px",flexShrink:0,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",paddingTop:"2px"},cardContent:{flex:1,minWidth:0},cardHeader:{display:"flex",alignItems:"flex-start",marginBottom:"6px",gap:"8px"},cardTitle:{fontSize:"14px",fontWeight:500,color:t.textPrimary,lineHeight:1.3,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},cardBadges:{display:"flex",gap:"6px",alignItems:"center",flexShrink:0},cardDate:{fontSize:"11px",color:t.textMuted,flexShrink:0},cardMeta:{display:"flex",gap:"6px",fontSize:"12px",color:t.textSecondary,flexWrap:"wrap",alignItems:"center"},tokenBadge:{color:t.accent,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",fontWeight:500,fontSize:"11px"}},da={plan:{icon:Re,label:"Plan",color:"#34D399"},exploration:{icon:Yt,label:"Exploration",color:t.accent},research:{icon:yt,label:"Research",color:"#A78BFA"},"web-search":{icon:qt,label:"Web Search",color:"#60A5FA"},handoff:{icon:eo,label:"Handoff",color:"#F59E0B"}};function Io({artifact:n,onClose:o,viewerIndex:s,loading:r,taskSummary:i,tasks:l}){var y;const[c,p]=a.useState(!1);if(!n)return e.jsx("div",{style:ne.emptyViewer,children:e.jsxs("div",{style:ne.emptyContent,children:[e.jsx("div",{style:ne.emptyIcon,children:e.jsx("div",{style:ne.emptyIconInner,children:s})}),e.jsx("p",{style:ne.emptyText,children:r?"Loading...":"Click an artifact to view"}),e.jsx("p",{style:ne.emptyHint,children:s===1?"First item opens here":"Second item for comparison"})]})});const g=da[n.type],d=g.icon,h=!n.content;return e.jsxs("div",{style:ne.viewer,children:[e.jsxs("div",{style:ne.header,children:[e.jsxs("div",{style:ne.headerLeft,children:[e.jsxs("div",{style:{...ne.typeBadge,backgroundColor:`${g.color}15`,color:g.color},children:[e.jsx(d,{size:12}),e.jsx("span",{children:g.label})]}),e.jsx("h3",{style:ne.title,children:n.title})]}),e.jsx("button",{style:ne.closeButton,onClick:o,title:"Close viewer",children:e.jsx(st,{size:14})})]}),n.metadata&&e.jsxs("div",{style:ne.metaBar,children:[n.timestamp&&e.jsx("span",{style:ne.metaItem,children:new Date(n.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),n.metadata.source&&e.jsx("span",{style:ne.metaItem,children:n.metadata.source}),n.metadata.tokenEstimate&&e.jsxs("span",{style:ne.metaItem,children:["~",Math.round(n.metadata.tokenEstimate/1e3),"k tokens"]})]}),n.type==="plan"&&i&&i.total>0&&e.jsxs("div",{style:ne.progressSection,children:[e.jsxs("div",{style:ne.progressHeader,children:[e.jsx(vt,{size:14,color:i.percentage===100?t.success:"#34D399"}),e.jsx("span",{style:ne.progressLabel,children:"Tasks"}),e.jsxs("span",{style:{...ne.progressPercentage,color:i.percentage===100?t.success:"#34D399"},children:[i.completed,"/",i.total," (",i.percentage,"%)"]})]}),e.jsx("div",{style:ne.progressTrack,children:e.jsx("div",{style:{...ne.progressFill,width:`${i.percentage}%`,backgroundColor:i.percentage===100?t.success:"#34D399"}})}),l&&l.length>0&&e.jsxs("div",{style:ne.stepsContainer,children:[e.jsxs("button",{style:ne.stepsToggle,onClick:()=>p(!c),type:"button",children:[c?e.jsx(tt,{size:14}):e.jsx(Fe,{size:14}),e.jsxs("span",{children:["Show tasks (",l.length,")"]})]}),c&&e.jsx("div",{style:ne.stepsList,children:l.map(m=>e.jsxs("div",{style:ne.stepItem,children:[e.jsx("span",{style:ne.stepCheckbox,children:m.status==="completed"?e.jsx(vt,{size:14,color:t.success}):m.status==="in_progress"?e.jsx(Zn,{size:14,color:t.warning}):e.jsx(Qn,{size:14,color:t.textMuted})}),e.jsx("span",{style:{...ne.stepText,textDecoration:m.status==="completed"?"line-through":"none",color:m.status==="completed"?t.textMuted:t.textSecondary},children:m.subject})]},m.id))})]})]}),e.jsx("div",{style:ne.content,children:h?e.jsxs("div",{style:ne.contentLoading,children:[e.jsx(Hs,{size:20,style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"Loading content..."})]}):n.type==="web-search"&&((y=n.metadata)!=null&&y.urls)?e.jsxs("div",{style:ne.webSearchContent,children:[e.jsxs("div",{style:ne.queryBlock,children:[e.jsx("span",{style:ne.queryLabel,children:"Query:"}),e.jsx("span",{style:ne.queryText,children:n.metadata.query||n.title})]}),e.jsx("div",{style:ne.urlList,children:n.metadata.urls.map((m,x)=>e.jsxs("a",{href:m.url,target:"_blank",rel:"noopener noreferrer",style:ne.urlItem,children:[e.jsx("span",{style:ne.urlTitle,children:m.title}),e.jsx("span",{style:ne.urlHref,children:m.url})]},x))}),n.content&&e.jsxs("div",{style:ne.responseBlock,children:[e.jsx("span",{style:ne.responseLabel,children:"Response:"}),e.jsx(pt,{content:n.content})]})]}):e.jsx(pt,{content:n.content})})]})}const ne={emptyViewer:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",border:`2px dashed ${t.borderSubtle}`,borderRadius:"8px",backgroundColor:t.bgSecondary},emptyContent:{display:"flex",flexDirection:"column",alignItems:"center",gap:"6px"},emptyIcon:{width:"40px",height:"40px",borderRadius:"50%",backgroundColor:t.bgElevated,display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"4px"},emptyIconInner:{fontSize:"16px",fontWeight:600,color:t.textMuted,fontFamily:ke.fontFamily.mono},emptyText:{fontSize:"13px",color:t.textSecondary,margin:0},emptyHint:{fontSize:"11px",color:t.textMuted,margin:0},viewer:{flex:1,display:"flex",flexDirection:"column",backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderBottom:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgElevated,flexShrink:0},headerLeft:{display:"flex",alignItems:"center",gap:"10px",minWidth:0,flex:1},typeBadge:{display:"flex",alignItems:"center",gap:"4px",padding:"3px 7px",borderRadius:"4px",fontSize:"11px",fontWeight:500,flexShrink:0},title:{margin:0,fontSize:"13px",fontWeight:500,color:t.textPrimary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},closeButton:{display:"flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:t.textMuted,cursor:"pointer",transition:"all 150ms ease",flexShrink:0},metaBar:{display:"flex",alignItems:"center",gap:"16px",padding:"6px 14px",backgroundColor:t.bgSecondary,borderBottom:`1px solid ${t.borderSubtle}`,fontSize:"11px",color:t.textMuted,flexShrink:0},metaItem:{display:"flex",alignItems:"center",gap:"4px"},progressSection:{padding:"12px 14px",borderBottom:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgPrimary,flexShrink:0},progressHeader:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},progressLabel:{fontSize:"12px",fontWeight:500,color:t.textSecondary},progressPercentage:{fontSize:"12px",fontWeight:600,fontFamily:ke.fontFamily.mono,marginLeft:"auto"},progressTrack:{width:"100%",height:"6px",backgroundColor:t.bgInput,borderRadius:"3px",overflow:"hidden"},progressFill:{height:"100%",borderRadius:"3px",transition:"width 300ms ease"},stepsContainer:{marginTop:"10px"},stepsToggle:{display:"flex",alignItems:"center",gap:"6px",padding:"5px 8px",fontSize:"11px",fontWeight:500,color:t.textSecondary,backgroundColor:"transparent",border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",cursor:"pointer",transition:"all 150ms ease"},stepsList:{marginTop:"8px",maxHeight:"180px",overflowY:"auto",border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",backgroundColor:t.bgSecondary},stepItem:{display:"flex",alignItems:"center",gap:"8px",padding:"7px 10px",borderBottom:`1px solid ${t.borderSubtle}`,fontSize:"11px"},stepCheckbox:{display:"inline-flex",flexShrink:0},stepText:{flex:1,lineHeight:1.4},content:{flex:1,padding:"16px",overflow:"auto"},contentLoading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",height:"100%",color:t.textMuted,fontSize:"13px"},webSearchContent:{display:"flex",flexDirection:"column",gap:"14px"},queryBlock:{display:"flex",alignItems:"baseline",gap:"8px",padding:"10px 12px",backgroundColor:t.bgElevated,borderRadius:"6px"},queryLabel:{fontSize:"10px",fontWeight:500,color:t.textMuted,textTransform:"uppercase",letterSpacing:"0.5px"},queryText:{fontSize:"13px",color:t.textPrimary,fontStyle:"italic"},urlList:{display:"flex",flexDirection:"column",gap:"6px"},urlItem:{display:"flex",flexDirection:"column",gap:"2px",padding:"8px 10px",backgroundColor:t.bgElevated,borderRadius:"6px",textDecoration:"none",transition:"background-color 150ms ease"},urlTitle:{fontSize:"12px",fontWeight:500,color:t.accent},urlHref:{fontSize:"10px",color:t.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},responseBlock:{display:"flex",flexDirection:"column",gap:"8px"},responseLabel:{fontSize:"10px",fontWeight:500,color:t.textMuted,textTransform:"uppercase",letterSpacing:"0.5px"}},dn=[{type:"plan",label:"Plans",icon:Re,color:"#34D399"},{type:"exploration",label:"Explorations",icon:Yt,color:t.accent},{type:"handoff",label:"Handoffs",icon:eo,color:"#F59E0B"},{type:"web-search",label:"Web Searches",icon:qt,color:"#60A5FA"}];function pn(n,o){if(!o.trim())return n;const s=o.toLowerCase();return n.filter(r=>r.title.toLowerCase().includes(s)||r.content.toLowerCase().includes(s))}function pa({plans:n,explorations:o,handoffs:s,webSearches:r,onSelectArtifact:i,selectedIds:l,searchQuery:c,taskSummaries:p}){const d=[{...dn[0],items:pn(n,c)},{...dn[1],items:pn(o,c)},{...dn[2],items:pn(s,c)},{...dn[3],items:pn(r,c)}].filter(h=>h.items.length>0);return d.length===0?e.jsxs("div",{style:De.emptyGrid,children:[e.jsx("p",{style:De.emptyText,children:c?"No artifacts match your search":"No artifacts found"}),e.jsx("p",{style:De.emptyHint,children:c?"Try a different search term":"Plans, explorations, and web searches from your sessions will appear here"})]}):e.jsx("div",{className:"jacques-artifact-grid",style:{...De.grid,gridTemplateColumns:`repeat(${Math.min(d.length,4)}, 1fr)`},children:d.map(h=>e.jsxs("div",{style:De.column,children:[e.jsxs("div",{style:De.columnHeader,children:[e.jsx("div",{style:{...De.columnIcon,backgroundColor:`${h.color}15`},children:e.jsx(h.icon,{size:14,style:{color:h.color}})}),e.jsx("span",{style:De.columnLabel,children:h.label}),e.jsx("span",{style:De.columnCount,children:h.items.length})]}),e.jsx("div",{style:De.columnItems,children:h.items.map(y=>{const m=l.has(y.id);return e.jsxs("button",{className:"jacques-artifact-item",style:{...De.item,backgroundColor:m?`${h.color}10`:"transparent",borderColor:m?`${h.color}40`:t.borderSubtle},onClick:()=>i(y),title:y.title,children:[e.jsx("span",{style:De.itemTitle,children:y.title}),e.jsxs("div",{style:De.itemMeta,children:[y.type==="plan"&&(p==null?void 0:p.get(y.id))&&(()=>{const x=p.get(y.id),f=x.percentage===100?t.success:"#34D399";return e.jsxs("span",{style:{...De.progressBadge,backgroundColor:`${f}15`,color:f},children:[e.jsx(vt,{size:9}),e.jsxs("span",{children:[x.completed,"/",x.total]})]})})(),y.timestamp&&e.jsx("span",{style:De.itemTime,children:ua(y.timestamp)})]})]},y.id)})})]},h.type))})}function ua(n){const o=new Date(n),r=Math.floor((new Date().getTime()-o.getTime())/(1e3*60*60*24));return r===0?"Today":r===1?"Yesterday":r<7?`${r}d ago`:o.toLocaleDateString("en-US",{month:"short",day:"numeric"})}const De={grid:{display:"grid",gap:"16px",minHeight:"200px"},emptyGrid:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px dashed ${t.borderSubtle}`},emptyText:{margin:0,fontSize:"14px",color:t.textSecondary},emptyHint:{margin:"8px 0 0",fontSize:"12px",color:t.textMuted,textAlign:"center"},column:{display:"flex",flexDirection:"column",backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden"},columnHeader:{display:"flex",alignItems:"center",gap:"10px",padding:"12px 14px",borderBottom:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgElevated},columnIcon:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px"},columnLabel:{fontSize:"13px",fontWeight:500,color:t.textPrimary,flex:1},columnCount:{fontSize:"11px",fontWeight:500,color:t.textMuted,backgroundColor:t.bgSecondary,padding:"2px 8px",borderRadius:"10px",fontFamily:ke.fontFamily.mono},columnItems:{flex:1,display:"flex",flexDirection:"column",padding:"8px",gap:"4px",overflowY:"auto",maxHeight:"280px"},item:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"4px",padding:"10px 12px",backgroundColor:"transparent",border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",cursor:"pointer",textAlign:"left",transition:"all 150ms ease",width:"100%"},itemTitle:{fontSize:"12px",fontWeight:500,color:t.textPrimary,lineHeight:1.3,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",width:"100%"},itemMeta:{display:"flex",alignItems:"center",gap:"6px"},progressBadge:{display:"inline-flex",alignItems:"center",gap:"3px",fontSize:"9px",fontWeight:600,padding:"2px 5px",borderRadius:"3px",fontFamily:ke.fontFamily.mono},itemTime:{fontSize:"10px",color:t.textMuted,fontFamily:ke.fontFamily.mono}},xa={plan:{icon:Re,label:"Plan",color:"#34D399"},exploration:{icon:Yt,label:"Explore",color:t.accent},research:{icon:yt,label:"Research",color:"#A78BFA"},"web-search":{icon:qt,label:"Web",color:"#60A5FA"},handoff:{icon:eo,label:"Handoff",color:"#F59E0B"}},ga=[{key:"all",label:"All"},{key:"plan",label:"Plans"},{key:"exploration",label:"Explorations"},{key:"handoff",label:"Handoffs"},{key:"web-search",label:"Web Searches"}];function St(n,o){if(!o.trim())return n;const s=o.toLowerCase();return n.filter(r=>r.title.toLowerCase().includes(s)||r.content.toLowerCase().includes(s))}function ha({plans:n,explorations:o,handoffs:s,webSearches:r,onSelectArtifact:i,selectedIds:l,searchQuery:c,taskSummaries:p}){const[g,d]=a.useState("all"),h=[...St(n,c),...St(o,c),...St(s,c),...St(r,c)].sort((x,b)=>!x.timestamp||!b.timestamp?0:new Date(b.timestamp).getTime()-new Date(x.timestamp).getTime()),y=g==="all"?h:h.filter(x=>x.type===g),m={all:h.length,plan:St(n,c).length,exploration:St(o,c).length,handoff:St(s,c).length,research:0,"web-search":St(r,c).length};return e.jsxs("div",{style:We.container,children:[e.jsx("div",{style:We.filterBar,children:ga.map(x=>{const b=g===x.key,f=m[x.key];return e.jsxs("button",{style:{...We.filterTab,backgroundColor:b?t.bgElevated:"transparent",color:b?t.textPrimary:t.textMuted,borderColor:b?t.accent:"transparent"},onClick:()=>d(x.key),children:[e.jsx("span",{children:x.label}),f>0&&e.jsx("span",{style:{...We.filterCount,backgroundColor:b?t.accent:t.bgElevated,color:b?"#fff":t.textMuted},children:f})]},x.key)})}),e.jsx("div",{style:We.list,children:y.length===0?e.jsx("div",{style:We.emptyList,children:e.jsx("p",{style:We.emptyText,children:c?"No artifacts match your search":"No artifacts in this category"})}):y.map(x=>{const b=xa[x.type],f=b.icon,u=l.has(x.id);return e.jsxs("button",{className:"jacques-artifact-item",style:{...We.listItem,backgroundColor:u?`${b.color}08`:"transparent",borderLeftColor:u?b.color:"transparent"},onClick:()=>i(x),children:[e.jsxs("div",{style:We.itemLeft,children:[e.jsx("div",{style:{...We.itemIcon,backgroundColor:`${b.color}15`,color:b.color},children:e.jsx(f,{size:12})}),e.jsxs("div",{style:We.itemContent,children:[e.jsx("span",{style:We.itemTitle,children:x.title}),x.timestamp&&e.jsx("span",{style:We.itemTime,children:fa(x.timestamp)})]})]}),x.type==="plan"&&(p==null?void 0:p.get(x.id))&&(()=>{const v=p.get(x.id),I=v.percentage===100?t.success:"#34D399";return e.jsxs("div",{style:{...We.progressBadge,backgroundColor:`${I}15`,color:I},children:[e.jsx(vt,{size:10}),e.jsxs("span",{children:[v.completed,"/",v.total]})]})})(),e.jsx("div",{style:{...We.typeBadge,backgroundColor:`${b.color}15`,color:b.color},children:b.label})]},x.id)})})]})}function fa(n){return new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}const We={container:{display:"flex",flexDirection:"column",backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden"},filterBar:{display:"flex",alignItems:"center",gap:"4px",padding:"10px 12px",borderBottom:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgSecondary,overflowX:"auto"},filterTab:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",fontSize:"12px",fontWeight:500,border:"none",borderRadius:"6px",borderBottom:"2px solid transparent",cursor:"pointer",transition:"all 150ms ease",whiteSpace:"nowrap"},filterCount:{fontSize:"10px",fontWeight:500,padding:"2px 6px",borderRadius:"8px",fontFamily:ke.fontFamily.mono},list:{flex:1,display:"flex",flexDirection:"column",overflowY:"auto",maxHeight:"320px"},emptyList:{display:"flex",alignItems:"center",justifyContent:"center",padding:"32px"},emptyText:{margin:0,fontSize:"13px",color:t.textMuted},listItem:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",padding:"12px 16px",backgroundColor:"transparent",border:"none",borderLeft:"3px solid transparent",borderBottom:`1px solid ${t.borderSubtle}`,cursor:"pointer",textAlign:"left",transition:"all 150ms ease",width:"100%"},itemLeft:{display:"flex",alignItems:"center",gap:"12px",minWidth:0,flex:1},itemIcon:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",flexShrink:0},itemContent:{display:"flex",flexDirection:"column",gap:"3px",minWidth:0,flex:1},itemTitle:{fontSize:"13px",fontWeight:500,color:t.textPrimary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},itemTime:{fontSize:"11px",color:t.textMuted,fontFamily:ke.fontFamily.mono},progressBadge:{display:"flex",alignItems:"center",gap:"4px",fontSize:"10px",fontWeight:600,padding:"3px 7px",borderRadius:"4px",flexShrink:0,fontFamily:ke.fontFamily.mono},typeBadge:{fontSize:"10px",fontWeight:500,padding:"4px 8px",borderRadius:"4px",flexShrink:0}};function ma(){var M,$,C,T;const{selectedProject:n}=wt(),[o,s]=a.useState(()=>localStorage.getItem("jacques-artifacts-view")||"grid"),[r,i]=a.useState(""),[l,c]=a.useState({viewer1:null,viewer2:null,viewer1Tasks:null,viewer2Tasks:null}),[p,g]=a.useState([]),[d,h]=a.useState([]),[y,m]=a.useState([]),[x,b]=a.useState([]),[f,u]=a.useState(!0),[v,z]=a.useState(null),[I,P]=a.useState(new Map);a.useEffect(()=>{localStorage.setItem("jacques-artifacts-view",o)},[o]);const k=a.useCallback(async()=>{var S;if(!n){g([]),h([]),m([]),b([]),u(!1);return}u(!0),z(null);try{const J=(await oo()).projects[n]||[];if(J.length===0){g([]),h([]),m([]),b([]),u(!1);return}const K=new Map;for(const V of J)if(V.planRefs)for(const E of V.planRefs){const j=E.title.replace(/^Plan:\s*/i,""),R=j.toLowerCase().trim();K.has(R)||K.set(R,{title:j,sessionId:V.id,messageIndex:E.messageIndex,source:E.source,timestamp:V.endedAt})}const re=Array.from(K.values()).map(V=>({id:`${V.sessionId}-plan-${V.messageIndex}`,type:"plan",title:V.title,content:"",timestamp:V.timestamp,metadata:{sessionId:V.sessionId,messageIndex:V.messageIndex,source:V.source}}));g(re);const U=[...new Set(re.map(V=>{var E;return(E=V.metadata)==null?void 0:E.sessionId}).filter(Boolean))],Z=new Map;await Promise.all(U.map(async V=>{var E;try{const j=await gn(V);if(j.summary&&j.summary.total>0)for(const R of re)((E=R.metadata)==null?void 0:E.sessionId)===V&&Z.set(R.id,j.summary)}catch{}})),P(Z);const q=[];for(const V of J)if(V.exploreAgents)for(const E of V.exploreAgents)q.push({id:E.id,type:"exploration",title:E.description||"Exploration",content:"",timestamp:E.timestamp,metadata:{sessionId:V.id,source:V.projectSlug}});h(q);const X=new Map;for(const V of J)if(V.webSearches)for(const E of V.webSearches){const j=E.query.toLowerCase().trim();X.has(j)||X.set(j,{id:`${V.id}-ws-${E.timestamp}`,type:"web-search",title:E.query,content:"",timestamp:E.timestamp,metadata:{sessionId:V.id,query:E.query}})}b(Array.from(X.values()));const Q=(S=J[0])==null?void 0:S.projectPath;if(Q)try{const V=encodeURIComponent(Q),j=(await Yr(V)).handoffs.map(R=>({id:R.filename,type:"handoff",title:R.filename.replace(/-handoff\.md$/,"").replace(/-/g," "),content:"",timestamp:R.timestamp,metadata:{source:R.filename,tokenEstimate:R.tokenEstimate,projectPath:V}}));m(j)}catch{m([])}else m([])}catch(F){console.error("Failed to load artifacts:",F),z(F instanceof Error?F.message:"Failed to load artifacts")}finally{u(!1)}},[n]);a.useEffect(()=>{k()},[k]);const _=a.useCallback(async S=>{var K,re,U,Z,q;let F=S,J=null;if(S.content){if(S.type==="plan"&&((q=S.metadata)!=null&&q.sessionId))try{const X=await gn(S.metadata.sessionId);X.summary&&X.summary.total>0&&(J={tasks:X.tasks,summary:X.summary})}catch{}}else try{if(S.type==="plan"&&((K=S.metadata)!=null&&K.sessionId)){const[X,Q]=await Promise.all([Qo(S.metadata.sessionId,S.metadata.messageIndex),gn(S.metadata.sessionId).catch(()=>null)]);F={...S,content:X.content},Q&&Q.summary&&Q.summary.total>0&&(J={tasks:Q.tasks,summary:Q.summary})}else if(S.type==="exploration"&&((re=S.metadata)!=null&&re.sessionId)){const X=await Sn(S.metadata.sessionId,S.id),Q=X.entries.filter(V=>V.type==="assistant_message").map(V=>V.content.text||"").filter(Boolean).join(`
109
+
110
+ ---
111
+
112
+ `);F={...S,content:Q||X.prompt||"(No content)"}}else if(S.type==="web-search"&&((U=S.metadata)!=null&&U.sessionId)){const Q=(await Ur(S.metadata.sessionId)).searches.find(V=>{var E;return V.query===((E=S.metadata)==null?void 0:E.query)});if(Q){let V=Q.response||"";!V&&Q.urls&&Q.urls.length>0&&(V=`## Sources
113
+
114
+ `+Q.urls.map((E,j)=>`${j+1}. **${E.title}**
115
+ ${E.url}`).join(`
116
+
117
+ `)),F={...S,content:V||"(No results)",metadata:{...S.metadata,urls:Q.urls}}}}else if(S.type==="handoff"&&((Z=S.metadata)!=null&&Z.projectPath)){const X=await Xr(S.metadata.projectPath,S.id),Q=X.content.match(/^#\s+(.+)$/m);F={...S,title:Q?Q[1]:S.title,content:X.content}}}catch(X){console.error("Failed to load content:",X),F={...S,content:"(Failed to load content)"}}c(X=>{var Q,V;return((Q=X.viewer1)==null?void 0:Q.id)===F.id?{...X,viewer1:F,viewer1Tasks:J}:((V=X.viewer2)==null?void 0:V.id)===F.id?{...X,viewer2:F,viewer2Tasks:J}:X.viewer1?X.viewer2?{...X,viewer2:F,viewer2Tasks:J}:{...X,viewer2:F,viewer2Tasks:J}:{...X,viewer1:F,viewer1Tasks:J}})},[]),B=S=>{c(F=>({...F,[S===1?"viewer1":"viewer2"]:null,[S===1?"viewer1Tasks":"viewer2Tasks"]:null}))},W=new Set;l.viewer1&&W.add(l.viewer1.id),l.viewer2&&W.add(l.viewer2.id);const O=p.length+d.length+y.length+x.length;return e.jsxs("div",{style:Ee.container,children:[e.jsxs("div",{style:Ee.header,children:[e.jsxs("div",{style:Ee.headerLeft,children:[e.jsx(Ut,{title:"Artifacts"}),!f&&O>0&&e.jsxs("span",{style:Ee.count,children:[O," artifact",O!==1?"s":""]})]}),e.jsxs("div",{style:Ee.headerRight,children:[e.jsxs("div",{style:Ee.searchBox,children:[e.jsx(yt,{size:14,style:{color:t.textMuted}}),e.jsx("input",{type:"text",placeholder:"Search...",value:r,onChange:S=>i(S.target.value),style:Ee.searchInput})]}),e.jsxs("div",{style:Ee.viewToggle,children:[e.jsx("button",{style:{...Ee.toggleBtn,...o==="grid"?Ee.toggleActive:{}},onClick:()=>s("grid"),children:e.jsx(Ho,{size:14})}),e.jsx("button",{style:{...Ee.toggleBtn,...o==="list"?Ee.toggleActive:{}},onClick:()=>s("list"),children:e.jsx(Os,{size:14})})]}),e.jsx("button",{style:Ee.refreshBtn,onClick:k,disabled:f,children:e.jsx(Nt,{size:14,style:{animation:f?"spin 1s linear infinite":"none"}})})]})]}),v&&e.jsxs("div",{style:Ee.error,children:[v,e.jsx("button",{onClick:()=>z(null),style:Ee.errorClose,children:"×"})]}),!n&&!f&&e.jsxs("div",{style:Ee.empty,children:[e.jsx("p",{style:{margin:0,fontSize:15,color:t.textSecondary},children:"Select a project"}),e.jsx("p",{style:{margin:"8px 0 0",fontSize:13,color:t.textMuted},children:"Choose from dropdown above"})]}),n&&e.jsxs("div",{style:Ee.main,children:[e.jsxs("div",{style:Ee.viewers,children:[e.jsx(Io,{artifact:l.viewer1,onClose:()=>B(1),viewerIndex:1,loading:f,taskSummary:(M=l.viewer1Tasks)==null?void 0:M.summary,tasks:($=l.viewer1Tasks)==null?void 0:$.tasks}),e.jsx(Io,{artifact:l.viewer2,onClose:()=>B(2),viewerIndex:2,loading:f,taskSummary:(C=l.viewer2Tasks)==null?void 0:C.summary,tasks:(T=l.viewer2Tasks)==null?void 0:T.tasks})]}),e.jsx("div",{style:Ee.lists,children:f?e.jsxs("div",{style:Ee.loading,children:[e.jsx(Nt,{size:20,style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"Loading..."})]}):o==="grid"?e.jsx(pa,{plans:p,explorations:d,handoffs:y,webSearches:x,onSelectArtifact:_,selectedIds:W,searchQuery:r,taskSummaries:I}):e.jsx(ha,{plans:p,explorations:d,handoffs:y,webSearches:x,onSelectArtifact:_,selectedIds:W,searchQuery:r,taskSummaries:I})})]})]})}const Ee={container:{display:"flex",flexDirection:"column",height:"100%",padding:"20px 24px",gap:"16px",overflow:"hidden"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},headerLeft:{display:"flex",alignItems:"baseline",gap:"12px"},headerRight:{display:"flex",alignItems:"center",gap:"12px"},count:{fontSize:"13px",color:t.textMuted,fontFamily:ke.fontFamily.mono},searchBox:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",backgroundColor:t.bgSecondary,borderRadius:"6px",border:`1px solid ${t.borderSubtle}`,width:"180px"},searchInput:{flex:1,border:"none",backgroundColor:"transparent",color:t.textPrimary,fontSize:"13px",outline:"none"},viewToggle:{display:"flex",backgroundColor:t.bgSecondary,borderRadius:"6px",padding:"2px",border:`1px solid ${t.borderSubtle}`},toggleBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"24px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:t.textMuted,cursor:"pointer"},toggleActive:{backgroundColor:t.bgElevated,color:t.textPrimary},refreshBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",backgroundColor:t.bgSecondary,color:t.textMuted,cursor:"pointer"},error:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 14px",backgroundColor:`${t.danger}10`,borderRadius:"6px",border:`1px solid ${t.danger}30`,fontSize:"13px",color:t.danger},errorClose:{border:"none",backgroundColor:"transparent",color:t.danger,cursor:"pointer",fontSize:"18px"},empty:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px dashed ${t.borderSubtle}`},main:{flex:1,display:"flex",flexDirection:"column",gap:"12px",minHeight:0,overflow:"hidden"},viewers:{flex:1,display:"flex",gap:"16px",minHeight:0},lists:{flexShrink:0,height:"320px",overflow:"auto",borderTop:`1px solid ${t.borderSubtle}`,paddingTop:"12px"},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",height:"100%",color:t.textMuted,fontSize:"14px"}};function ya(n){const[o,s]=a.useState(null),[r,i]=a.useState(!1),[l,c]=a.useState(null),p=a.useCallback(async()=>{if(!n){s(null);return}i(!0),c(null);try{const g=await Vr(n);s(g)}catch(g){c(g instanceof Error?g.message:"Failed to load catalog")}finally{i(!1)}},[n]);return a.useEffect(()=>{p()},[p]),{catalog:o,loading:r,error:l,refresh:p}}let ba=0;function Ln(){return`msg-${++ba}-${Date.now()}`}function ja({projectPath:n,sendChatMessage:o,abortChat:s,setChatCallbacks:r,onCatalogRefresh:i}){const[l,c]=a.useState([]),[p,g]=a.useState(!1),[d,h]=a.useState(""),[y,m]=a.useState([]),[x,b]=a.useState(null),f=a.useRef(n);a.useEffect(()=>{f.current!==n&&(c([]),g(!1),h(""),m([]),b(null),f.current=n)},[n]),a.useEffect(()=>(r({onChatDelta:(I,P)=>{I===n&&h(k=>k+P)},onChatToolEvent:(I,P)=>{I===n&&m(k=>[...k,P])},onChatComplete:(I,P)=>{I===n&&(c(k=>[...k,{id:Ln(),role:"assistant",content:P,timestamp:Date.now(),tools:y.length>0?[...y]:void 0}]),g(!1),h(""),m([]))},onChatError:(I,P,k)=>{I===n&&(P==="aborted"?d&&c(_=>[..._,{id:Ln(),role:"assistant",content:d+`
118
+
119
+ *(aborted)*`,timestamp:Date.now()}]):P!=="already_active"&&b(k),g(!1),h(""),m([]))},onCatalogUpdated:I=>{I===n&&(i==null||i())}}),()=>{r({})}),[n,r,i]);const u=a.useCallback(I=>{!n||!I.trim()||p||(c(P=>[...P,{id:Ln(),role:"user",content:I.trim(),timestamp:Date.now()}]),g(!0),h(""),m([]),b(null),o(n,I.trim()))},[n,p,o]),v=a.useCallback(()=>{n&&s(n)},[n,s]),z=a.useCallback(()=>{c([]),h(""),m([]),b(null)},[]);return{messages:l,isStreaming:p,currentStreamText:d,currentTools:y,sendMessage:u,abort:v,clearChat:z,error:x}}function Sa(){const{openModal:n,updateModal:o,closeModal:s,modalProps:r}=fr();return{openAsset:a.useCallback(async(l,c)=>{if(!c){n(l);return}n({...l,loading:!0,content:""});try{const p=await c();o({...p,loading:!1})}catch{o({content:"*Failed to load content*",loading:!1})}},[n,o]),closeModal:s,modalProps:r}}function va({catalog:n,loading:o,collapsed:s,onToggleCollapse:r,onItemClick:i,onAddContext:l}){const[c,p]=a.useState(""),[g,d]=a.useState({context:!0,plans:!0,sessions:!1}),h=u=>{d(v=>({...v,[u]:!v[u]}))},y=c.toLowerCase(),m=(n==null?void 0:n.context.filter(u=>{var v;return u.name.toLowerCase().includes(y)||((v=u.description)==null?void 0:v.toLowerCase().includes(y))}))??[],x=(n==null?void 0:n.plans.filter(u=>u.title.toLowerCase().includes(y)))??[],b=(n==null?void 0:n.sessions.filter(u=>u.title.toLowerCase().includes(y)))??[],f=m.length+x.length+b.length;return s?e.jsxs("div",{style:ge.collapsedContainer,children:[e.jsx("button",{style:ge.expandBtn,onClick:r,title:"Expand",children:e.jsx(Fe,{size:14})}),e.jsxs("div",{style:ge.collapsedIcons,children:[e.jsx(Pn,{icon:e.jsx(lo,{size:15}),count:m.length}),e.jsx(Pn,{icon:e.jsx(ht,{size:15}),count:x.length}),e.jsx(Pn,{icon:e.jsx(co,{size:15}),count:b.length})]}),e.jsx("button",{style:ge.collapsedAddBtn,onClick:l,title:"New context",children:e.jsx(Wt,{size:16,strokeWidth:2})})]}):e.jsxs("div",{style:ge.container,children:[e.jsxs("div",{style:ge.header,children:[e.jsxs("div",{style:ge.headerLeft,children:[e.jsx(Fo,{size:14,color:t.accent,strokeWidth:2}),e.jsx("span",{style:ge.headerTitle,children:"Context"})]}),e.jsx("button",{style:ge.collapseBtn,onClick:r,title:"Collapse",children:e.jsx(qs,{size:14})})]}),e.jsxs("div",{style:ge.searchWrap,children:[e.jsx("input",{type:"text",value:c,onChange:u=>p(u.target.value),placeholder:"filter...",style:ge.searchInput}),c&&e.jsx("span",{style:ge.searchCount,children:f})]}),e.jsxs("div",{style:ge.sections,children:[e.jsx(An,{icon:e.jsx(lo,{size:13}),label:"Files",count:m.length,expanded:g.context,onToggle:()=>h("context"),children:o&&m.length===0?e.jsx(wa,{}):m.length===0?e.jsx(Fn,{text:"No context files"}):m.map(u=>e.jsx(_n,{label:u.name,meta:u.source,onClick:()=>i("context",u)},u.id))}),e.jsx(An,{icon:e.jsx(ht,{size:13}),label:"Plans",count:x.length,expanded:g.plans,onToggle:()=>h("plans"),children:x.length===0?e.jsx(Fn,{text:"No plans"}):x.map(u=>e.jsx(_n,{label:u.title,meta:u.sessions.length>0?`${u.sessions.length}`:void 0,onClick:()=>i("plan",u)},u.id))}),e.jsx(An,{icon:e.jsx(co,{size:13}),label:"Sessions",count:b.length,expanded:g.sessions,onToggle:()=>h("sessions"),children:b.length===0?e.jsx(Fn,{text:"No saved sessions"}):b.map(u=>e.jsx(_n,{label:u.title,meta:`${u.messageCount}`,onClick:()=>i("session",u)},u.id))})]}),e.jsx("div",{style:ge.footer,children:e.jsxs("button",{style:ge.addButton,onClick:l,children:[e.jsx(Wt,{size:14,strokeWidth:2.5}),e.jsx("span",{children:"New Context"})]})})]})}function Pn({icon:n,count:o}){return e.jsxs("div",{style:ge.collapsedIcon,children:[e.jsx("span",{style:{color:t.textMuted},children:n}),o>0&&e.jsx("span",{style:ge.collapsedCount,children:o})]})}function An({icon:n,label:o,count:s,expanded:r,onToggle:i,children:l}){return e.jsxs("div",{style:ge.section,children:[e.jsxs("button",{style:ge.sectionHeader,onClick:i,children:[e.jsx("span",{style:ge.sectionChevron,children:r?e.jsx(tt,{size:11}):e.jsx(Fe,{size:11})}),e.jsx("span",{style:ge.sectionIcon,children:n}),e.jsx("span",{style:ge.sectionLabel,children:o}),e.jsx("span",{style:ge.sectionCount,children:s})]}),r&&e.jsx("div",{style:ge.sectionContent,children:l})]})}function _n({label:n,meta:o,onClick:s}){return e.jsxs("button",{style:ge.itemRow,onClick:s,children:[e.jsx(Re,{size:12,color:t.textMuted}),e.jsx("span",{style:ge.itemLabel,children:n}),o&&e.jsx("span",{style:ge.itemMeta,children:o})]})}function Fn({text:n}){return e.jsx("div",{style:ge.emptyRow,children:n})}function wa(){return e.jsxs("div",{style:ge.loadingRow,children:[e.jsx(Oe,{size:11,style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"Loading..."})]})}const ge={container:{width:"240px",flexShrink:0,display:"flex",flexDirection:"column",borderRight:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgSecondary,height:"100%",overflow:"hidden"},collapsedContainer:{width:"52px",flexShrink:0,display:"flex",flexDirection:"column",alignItems:"center",borderRight:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgSecondary,height:"100%",paddingTop:"14px"},expandBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,border:"none",borderRadius:"6px",backgroundColor:"transparent",color:t.textMuted,cursor:"pointer"},collapsedIcons:{display:"flex",flexDirection:"column",alignItems:"center",gap:"24px",paddingTop:"24px",flex:1},collapsedIcon:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px"},collapsedCount:{fontSize:"10px",fontFamily:"'JetBrains Mono', monospace",fontWeight:500,color:t.textMuted},collapsedAddBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:36,height:36,marginBottom:"16px",border:"none",borderRadius:"8px",backgroundColor:t.accent,color:"#000",cursor:"pointer"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 14px 14px",borderBottom:`1px solid ${t.borderSubtle}`},headerLeft:{display:"flex",alignItems:"center",gap:"10px"},headerTitle:{fontSize:"14px",fontWeight:600,color:t.textPrimary,letterSpacing:"-0.01em"},collapseBtn:{display:"flex",alignItems:"center",justifyContent:"center",width:26,height:26,border:"none",borderRadius:"6px",backgroundColor:"transparent",color:t.textMuted,cursor:"pointer"},searchWrap:{position:"relative",padding:"12px 12px 8px"},searchInput:{width:"100%",padding:"8px 12px",fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",backgroundColor:t.bgPrimary,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",color:t.textPrimary,outline:"none"},searchCount:{position:"absolute",right:"22px",top:"50%",transform:"translateY(-50%)",fontSize:"10px",color:t.accent,fontFamily:"'JetBrains Mono', monospace",fontWeight:600},sections:{flex:1,overflow:"auto",padding:"8px 0 16px"},section:{marginBottom:"20px"},sectionHeader:{display:"flex",alignItems:"center",gap:"6px",width:"100%",padding:"6px 14px",border:"none",backgroundColor:"transparent",cursor:"pointer",textAlign:"left"},sectionChevron:{display:"inline-flex",alignItems:"center",color:t.textMuted},sectionIcon:{display:"inline-flex",alignItems:"center",color:t.textMuted},sectionLabel:{fontSize:"12px",fontWeight:500,color:t.textSecondary},sectionCount:{marginLeft:"auto",fontSize:"11px",fontFamily:"'JetBrains Mono', monospace",color:t.textMuted},sectionContent:{marginTop:"4px",marginLeft:"22px",paddingLeft:"12px",borderLeft:`1px solid ${t.borderSubtle}`},itemRow:{display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 10px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:t.textPrimary,cursor:"pointer",fontSize:"12px",textAlign:"left",transition:"background-color 100ms ease"},itemLabel:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"12px"},itemMeta:{fontSize:"10px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace"},emptyRow:{padding:"10px",fontSize:"11px",color:t.textMuted,fontStyle:"italic"},loadingRow:{display:"flex",alignItems:"center",gap:"8px",padding:"10px",fontSize:"11px",color:t.textMuted},footer:{padding:"12px 14px 16px",borderTop:`1px solid ${t.borderSubtle}`},addButton:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"11px 16px",border:"none",borderRadius:"8px",backgroundColor:t.accent,color:"#000",cursor:"pointer",fontSize:"13px",fontWeight:600,letterSpacing:"-0.01em",transition:"opacity 150ms ease"}};function ka({message:n}){return n.role==="user"?e.jsxs("div",{style:ct.userContainer,children:[e.jsxs("div",{style:ct.userHeader,children:[e.jsx(Us,{size:10,color:t.textMuted}),e.jsx("span",{style:ct.userLabel,children:"you"})]}),e.jsx("div",{style:ct.userContent,children:n.content})]}):e.jsxs("div",{style:ct.assistantContainer,children:[e.jsxs("div",{style:ct.assistantHeader,children:[e.jsx(Un,{size:10,color:t.accent}),e.jsx("span",{style:ct.assistantLabel,children:"claude"}),n.tools&&n.tools.length>0&&e.jsx("div",{style:ct.toolsInline,children:n.tools.map((s,r)=>e.jsx("span",{style:ct.toolBadge,children:s},r))})]}),e.jsx("div",{style:ct.assistantContent,children:e.jsx(pt,{content:n.content})})]})}const ct={userContainer:{marginBottom:"20px"},userHeader:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"6px"},userLabel:{fontSize:"10px",fontWeight:500,color:t.textMuted,fontFamily:"'JetBrains Mono', monospace",textTransform:"lowercase"},userContent:{paddingLeft:"16px",fontSize:"13px",color:t.textPrimary,whiteSpace:"pre-wrap",lineHeight:1.6,borderLeft:`1px solid ${t.borderSubtle}`},assistantContainer:{marginBottom:"20px",padding:"14px 16px",borderRadius:"6px",backgroundColor:t.bgSecondary,borderLeft:`2px solid ${t.accent}`},assistantHeader:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},assistantLabel:{fontSize:"10px",fontWeight:600,color:t.textSecondary,fontFamily:"'JetBrains Mono', monospace",textTransform:"lowercase"},toolsInline:{display:"flex",flexWrap:"wrap",gap:"4px",marginLeft:"auto"},toolBadge:{display:"inline-flex",padding:"2px 6px",borderRadius:"3px",fontSize:"9px",fontWeight:500,color:t.textMuted,backgroundColor:t.bgElevated,fontFamily:"'JetBrains Mono', monospace",letterSpacing:"-0.02em"},assistantContent:{fontSize:"13px",lineHeight:1.6}};function Ca({onSend:n,onAbort:o,isStreaming:s,disabled:r=!1,placeholder:i="ask about your context..."}){const[l,c]=a.useState(""),p=a.useRef(null),g=a.useCallback(()=>{!l.trim()||r||s||(n(l),c(""),p.current&&(p.current.style.height="auto"))},[l,r,s,n]),d=y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),g())},h=y=>{c(y.target.value);const m=y.target;m.style.height="auto",m.style.height=Math.min(m.scrollHeight,100)+"px"};return e.jsxs("div",{style:Et.container,children:[e.jsxs("div",{style:Et.inputWrapper,children:[e.jsx("span",{style:Et.prompt,children:">"}),e.jsx("textarea",{ref:p,value:l,onChange:h,onKeyDown:d,placeholder:i,disabled:r,rows:1,style:{...Et.textarea,opacity:r?.4:1}})]}),s?e.jsxs("button",{style:Et.stopButton,onClick:o,title:"Stop (Esc)",children:[e.jsx(Js,{size:10,fill:"currentColor"}),e.jsx("span",{children:"stop"})]}):e.jsx("button",{style:{...Et.sendButton,opacity:l.trim()&&!r?1:.3,pointerEvents:l.trim()&&!r?"auto":"none"},onClick:g,disabled:!l.trim()||r,title:"Send (Enter)",children:e.jsx(No,{size:12})})]})}const Et={container:{display:"flex",alignItems:"flex-end",gap:"10px"},inputWrapper:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px",padding:"10px 14px",backgroundColor:t.bgSecondary,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",transition:"border-color 150ms ease"},prompt:{color:t.accent,fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",fontWeight:600,lineHeight:"20px",flexShrink:0,userSelect:"none"},textarea:{flex:1,padding:0,fontSize:"12px",fontFamily:"'JetBrains Mono', monospace",backgroundColor:"transparent",border:"none",color:t.textPrimary,outline:"none",resize:"none",lineHeight:"20px",maxHeight:"100px",letterSpacing:"-0.02em"},sendButton:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",backgroundColor:t.bgSecondary,color:t.textMuted,cursor:"pointer",flexShrink:0,transition:"all 150ms ease"},stopButton:{display:"flex",alignItems:"center",justifyContent:"center",gap:"5px",height:32,padding:"0 12px",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"6px",backgroundColor:"rgba(239, 68, 68, 0.1)",color:t.danger,cursor:"pointer",flexShrink:0,fontSize:"10px",fontFamily:"'JetBrains Mono', monospace",fontWeight:500,transition:"all 150ms ease"}};function Ia({catalog:n,onSelect:o}){const s=Ta(n);return s.length===0?null:e.jsxs("div",{style:un.container,children:[e.jsxs("div",{style:un.label,children:[e.jsx(yn,{size:9,color:t.textMuted}),e.jsx("span",{children:"suggestions"})]}),e.jsx("div",{style:un.chips,children:s.map((r,i)=>e.jsx("button",{style:un.chip,onClick:()=>o(r),children:r},i))})]})}function Ta(n){if(!n)return[];const o=[];if(n.context.length===0&&n.plans.length===0)o.push("how do I add context files?"),o.push("create a project overview");else{if(n.context.length>0){const s=n.context[0].name;o.push(`summarize "${s}"`),o.push("what's missing from my context?")}n.plans.length>0&&o.push("list implementation plans"),n.context.length>2&&o.push("create table of contents")}return o.slice(0,4)}const un={container:{marginBottom:"12px"},label:{display:"flex",alignItems:"center",gap:"5px",marginBottom:"8px",fontSize:"9px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace",textTransform:"lowercase",letterSpacing:"0.02em"},chips:{display:"flex",flexWrap:"wrap",gap:"6px"},chip:{display:"inline-flex",alignItems:"center",padding:"5px 10px",borderRadius:"4px",border:`1px solid ${t.borderSubtle}`,backgroundColor:"transparent",color:t.textSecondary,fontSize:"11px",fontFamily:"'JetBrains Mono', monospace",cursor:"pointer",transition:"all 150ms ease",whiteSpace:"nowrap",letterSpacing:"-0.02em"}};function za({messages:n,isStreaming:o,currentStreamText:s,currentTools:r,catalog:i,error:l,projectSelected:c,onSend:p,onAbort:g}){const d=a.useRef(null),h=n.length>0;return a.useEffect(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[n,s]),c?e.jsxs("div",{style:ce.container,children:[e.jsxs("div",{style:ce.header,children:[e.jsxs("div",{style:ce.headerLeft,children:[e.jsx(Un,{size:12,color:t.accent}),e.jsx("span",{style:ce.headerTitle,children:"context assistant"})]}),e.jsx("div",{style:ce.headerRight,children:o&&e.jsxs("span",{style:ce.streamingBadge,children:[e.jsx("span",{style:ce.streamingDot}),"streaming"]})})]}),e.jsxs("div",{ref:d,style:ce.messagesArea,children:[!h&&!o?e.jsx("div",{style:ce.welcomeState,children:e.jsxs("div",{style:ce.welcomeBox,children:[e.jsxs("div",{style:ce.welcomeHeader,children:[e.jsx(ft,{size:14,color:t.accent,strokeWidth:1.5}),e.jsx("span",{children:"ready"})]}),e.jsxs("div",{style:ce.welcomeBody,children:[e.jsx("p",{style:ce.welcomeLine,children:"Ask questions about your project context,"}),e.jsx("p",{style:ce.welcomeLine,children:"create notes, or organize your knowledge base."})]}),e.jsxs("div",{style:ce.welcomeHint,children:[e.jsx("span",{style:ce.hintKey,children:"enter"})," to send",e.jsx("span",{style:ce.hintDivider,children:"|"}),e.jsx("span",{style:ce.hintKey,children:"shift+enter"})," for newline"]})]})}):e.jsxs(e.Fragment,{children:[n.map(y=>e.jsx(ka,{message:y},y.id)),o&&e.jsxs("div",{style:ce.streamingContainer,children:[e.jsxs("div",{style:ce.streamingHeader,children:[e.jsx("span",{style:ce.streamingIcon,children:e.jsx(Un,{size:10,color:t.accent})}),e.jsx("span",{style:ce.streamingLabel,children:"claude"}),r.length>0&&e.jsx("span",{style:ce.toolIndicator,children:r[r.length-1]})]}),s?e.jsx("div",{style:ce.streamingContent,children:e.jsx(pt,{content:s})}):e.jsxs("div",{style:ce.thinkingRow,children:[e.jsx(Oe,{size:10,style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"processing..."})]})]})]}),l&&e.jsxs("div",{style:ce.errorBar,children:[e.jsx("span",{style:ce.errorPrefix,children:"error:"})," ",l]})]}),e.jsxs("div",{style:ce.inputArea,children:[!h&&!o&&e.jsx(Ia,{catalog:i,onSelect:p}),e.jsx(Ca,{onSend:p,onAbort:g,isStreaming:o,disabled:!c})]})]}):e.jsx("div",{style:ce.container,children:e.jsxs("div",{style:ce.emptyState,children:[e.jsx(ft,{size:20,color:t.textMuted,strokeWidth:1.5}),e.jsxs("div",{style:ce.emptyText,children:[e.jsx("span",{style:ce.emptyPrompt,children:"$"})," select a project to continue"]})]})})}const ce={container:{flex:1,display:"flex",flexDirection:"column",minWidth:0,height:"100%",overflow:"hidden",backgroundColor:t.bgPrimary},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:`1px solid ${t.borderSubtle}`,flexShrink:0},headerLeft:{display:"flex",alignItems:"center",gap:"8px"},headerTitle:{fontSize:"11px",fontWeight:500,color:t.textSecondary,fontFamily:"'JetBrains Mono', monospace",letterSpacing:"-0.02em"},headerRight:{display:"flex",alignItems:"center",gap:"8px"},streamingBadge:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"3px 8px",borderRadius:"3px",backgroundColor:"rgba(230, 126, 82, 0.1)",fontSize:"10px",fontFamily:"'JetBrains Mono', monospace",color:t.accent},streamingDot:{width:"5px",height:"5px",borderRadius:"50%",backgroundColor:t.accent,animation:"pulse 1.5s ease-in-out infinite"},messagesArea:{flex:1,overflow:"auto",padding:"20px 24px",minHeight:0},inputArea:{padding:"16px 24px 20px",borderTop:`1px solid ${t.borderSubtle}`,flexShrink:0},emptyState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"16px",padding:"40px"},emptyText:{fontSize:"12px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace"},emptyPrompt:{color:t.accent,marginRight:"8px"},welcomeState:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px"},welcomeBox:{maxWidth:"360px",padding:"20px 24px",borderRadius:"6px",border:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgSecondary},welcomeHeader:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"16px",paddingBottom:"12px",borderBottom:`1px solid ${t.borderSubtle}`,fontSize:"12px",fontWeight:500,color:t.textPrimary,fontFamily:"'JetBrains Mono', monospace"},welcomeBody:{marginBottom:"16px"},welcomeLine:{margin:"0 0 4px 0",fontSize:"12px",color:t.textSecondary,lineHeight:1.6},welcomeHint:{display:"flex",alignItems:"center",gap:"6px",fontSize:"10px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace"},hintKey:{padding:"2px 5px",borderRadius:"3px",backgroundColor:t.bgElevated,border:`1px solid ${t.borderSubtle}`,fontSize:"9px"},hintDivider:{opacity:.3},streamingContainer:{marginTop:"16px",padding:"12px 16px",borderRadius:"6px",backgroundColor:t.bgSecondary,borderLeft:`2px solid ${t.accent}`},streamingHeader:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},streamingIcon:{display:"inline-flex",alignItems:"center"},streamingLabel:{fontSize:"10px",fontWeight:600,color:t.textSecondary,fontFamily:"'JetBrains Mono', monospace",textTransform:"lowercase"},toolIndicator:{marginLeft:"auto",fontSize:"9px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace",padding:"2px 6px",borderRadius:"3px",backgroundColor:t.bgElevated},streamingContent:{fontSize:"13px",lineHeight:1.6},thinkingRow:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:t.textMuted,fontFamily:"'JetBrains Mono', monospace"},errorBar:{marginTop:"16px",padding:"10px 14px",borderRadius:"4px",backgroundColor:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.2)",fontSize:"11px",fontFamily:"'JetBrains Mono', monospace",color:t.textSecondary},errorPrefix:{color:t.danger,fontWeight:500}};function Ra(n,o,s,r){const i=o==="embedded"?"Embedded":o==="write"?"Written":"Agent";return{title:n,badge:{label:"Plan",variant:"plan"},icon:e.jsx(Re,{size:16}),subtitle:r||void 0,mode:"markdown",content:s,footerInfo:i,size:"lg"}}function Ea(n,o,s,r){return{title:n,badge:{label:"Context",variant:"agent"},icon:e.jsx(Re,{size:16}),subtitle:r,mode:"markdown",content:s,footerInfo:o,size:"lg"}}function $a(n){return n.replace(/\//g,"-")}function Ba(){const{selectedProject:n}=wt(),{sendChatMessage:o,abortChat:s,setChatCallbacks:r}=jn(),i=n?$a(n):null,{catalog:l,loading:c,refresh:p}=ya(i),{messages:g,isStreaming:d,currentStreamText:h,currentTools:y,sendMessage:m,abort:x,error:b}=ja({projectPath:n,sendChatMessage:o,abortChat:s,setChatCallbacks:r,onCatalogRefresh:p}),{openAsset:f,modalProps:u}=Sa(),[v,z]=Xt("catalogCollapsed",!1),I=a.useCallback(()=>{z(!v)},[v,z]),P=a.useCallback(async(C,T)=>{if(i){if(C==="context"){const S=T;f(Ea(S.name,S.source,"",S.description),async()=>({content:(await Kr(i,S.id)).content}))}else if(C==="plan"){const S=T;f(Ra(S.title,"embedded",""),async()=>({content:(await Gr(i,S.id)).content}))}}},[i,f]),k=a.useRef(null),[_,B]=a.useState(!1),W=a.useRef(!1);a.useEffect(()=>{const C=k.current;if(!C)return;const T=new ResizeObserver(S=>{for(const F of S){const J=F.contentRect.width;W.current||(J<800&&!v?B(!0):J>=800&&_&&B(!1))}});return T.observe(C),()=>T.disconnect()},[v,_]);const O=W.current?v:v||_,M=a.useCallback(()=>{W.current=!0,I()},[I]),$=a.useCallback(()=>{n&&m("Create a new context note for this project")},[n,m]);return e.jsxs("div",{ref:k,style:Ma.container,children:[e.jsx(va,{catalog:l,loading:c,collapsed:O,onToggleCollapse:M,onItemClick:P,onAddContext:$}),e.jsx(za,{messages:g,isStreaming:d,currentStreamText:h,currentTools:y,catalog:l,error:b,projectSelected:!!n,onSend:m,onAbort:x}),u&&e.jsx(mr,{...u})]})}const Ma={container:{display:"flex",height:"100%",overflow:"hidden"}},Dn={context:{label:"Context thresholds",description:"Alert at 50%, 70% usage"},operation:{label:"Large operations",description:"Coming soon"},plan:{label:"Plan creation",description:"New plan detected in a session"},"auto-compact":{label:"Auto-compact",description:"Session automatically compacted"},handoff:{label:"Handoff ready",description:"Handoff file generated for a session"},"bug-alert":{label:"Bug alert",description:"Coming soon"}},La=new Set(["operation","bug-alert"]),To={granted:{text:"Granted",color:t.success},denied:{text:"Denied (reset in browser settings)",color:t.danger},default:{text:"Not yet asked",color:t.textMuted},unsupported:{text:"Not supported in this browser",color:t.textMuted}},zo=10,Pa="rgba(255,255,255,0.15)";function Ro(n){return Math.round(n>1?n:n*100)}function Aa(n){if(!n)return"";const o=new Date(n);if(isNaN(o.getTime()))return"";const s=new Date;if(o.toDateString()===s.toDateString())return o.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}).toLowerCase();const r=o.getTime()-s.getTime(),i=o.toLocaleString("en-US",{month:"short"}).toLowerCase(),l=o.getDate();if(r>0&&r<7*864e5){const c=o.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}).toLowerCase();return`${i} ${l}, ${c}`}return`${i} ${l}`}function Wn({label:n,utilization:o,valueText:s,resetTime:r,color:i}){const l=o>1?o/100:o,c=Math.round(l*zo),p=Aa(r);return e.jsxs("div",{style:se.usageRow,children:[e.jsx("span",{style:se.usageLabel,children:n}),e.jsx("span",{style:se.usageDots,children:Array.from({length:zo},(g,d)=>e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",display:"inline-block",backgroundColor:d<c?i:Pa}},d))}),e.jsx("span",{style:{...se.usageValue,color:i},children:s}),p&&e.jsxs("span",{style:se.usageReset,children:["resets ",p]})]})}function _a(){var C;const{settings:n,updateSettings:o,toggleCategory:s,browserPermission:r,requestBrowserPermission:i}=gi(),{refreshProjects:l}=wt(),[c,p]=Xt("dangerouslySkipPermissions",!1),[g,d]=a.useState(null),[h,y]=a.useState(""),[m,x]=a.useState(null),[b,f]=a.useState(!1),[u,v]=a.useState(null),z=a.useCallback(async()=>{const T=await Zr();T&&v(T)},[]);a.useEffect(()=>{z();const T=setInterval(z,3e4);return()=>clearInterval(T)},[z]);const[I,P]=a.useState(!1),[k,_]=a.useState(null),[B,W]=a.useState(null);a.useEffect(()=>{mo().then(T=>{d(T),y(T.path)}).catch(T=>{console.error("Failed to load root path:",T)})},[]);const O=T=>{P(!0),_(null),W(null),es({onProgress:S=>_(S),onComplete:S=>{W(S),P(!1),l(),_(null)},onError:S=>{console.error("Sync failed:",S),P(!1),_(null)}},{force:T})},M=async()=>{if(!h.trim()){x("Path cannot be empty");return}f(!0),x(null);try{await Nr(h.trim());const T=await mo();d(T),y(T.path)}catch(T){x(T instanceof Error?T.message:"Failed to save")}finally{f(!1)}},$=To[r]??To.unsupported;return e.jsxs("div",{style:se.container,children:[e.jsx(Ut,{title:"Settings"}),e.jsx("p",{style:se.description,children:"Configure Jacques preferences and integrations."}),e.jsx(zt,{title:"Root Catalog Path",icon:e.jsx(Gs,{size:16}),description:g?`Currently: ${g.path}`:"Loading...",badge:g&&e.jsx("span",{style:{fontSize:"11px",fontWeight:500,padding:"2px 8px",borderRadius:"6px",color:g.exists?t.success:t.warning,backgroundColor:g.exists?"rgba(74, 222, 128, 0.15)":"rgba(251, 191, 36, 0.15)"},children:g.exists?"Found":"Not Found"}),defaultExpanded:!0,children:e.jsxs("div",{style:se.settingBlock,children:[e.jsx("div",{style:se.settingLabel,children:"Claude Data Directory"}),e.jsxs("p",{style:se.settingDescription,children:["Path to your Claude Code .claude directory where session data is stored.",(g==null?void 0:g.isDefault)&&e.jsx("span",{style:se.autoDetected,children:" Auto-detected from default location."})]}),e.jsxs("div",{style:se.pathInputRow,children:[e.jsx("input",{type:"text",value:h,onChange:T=>y(T.target.value),placeholder:(g==null?void 0:g.defaultPath)||"~/.claude",style:se.pathInput}),e.jsx("button",{style:{...se.primaryBtn,opacity:b?.7:1},onClick:M,disabled:b,children:b?"Saving...":"Save"})]}),m&&e.jsx("div",{style:se.errorText,children:m})]})}),e.jsxs(zt,{title:"Dangerously Skip Permissions",icon:e.jsx(Yn,{size:16}),description:c?"All launched sessions will skip permission prompts":"Sessions launch with normal permissions",badge:e.jsx("span",{style:{fontSize:"11px",fontWeight:500,padding:"2px 8px",borderRadius:"6px",color:c?t.danger:t.textMuted,backgroundColor:c?"rgba(239, 68, 68, 0.15)":"rgba(107, 112, 117, 0.15)"},children:c?"On":"Off"}),children:[e.jsx(Rn,{checked:c,onChange:p,label:"Skip all permission prompts",description:"Launch Claude Code with --dangerously-skip-permissions"}),e.jsx("div",{style:se.settingDescription,children:"When enabled, new Claude Code sessions launched from Jacques will bypass all tool approval prompts. Claude will be able to edit files, run commands, and make network requests without asking. Only enable this in isolated environments (containers, VMs) where unintended changes are acceptable."})]}),e.jsxs(zt,{title:"Notifications",icon:e.jsx(Ao,{size:16}),description:n.enabled?"Enabled":"Disabled",badge:e.jsx("span",{style:{fontSize:"11px",fontWeight:500,padding:"2px 8px",borderRadius:"6px",color:n.enabled?t.success:t.textMuted,backgroundColor:n.enabled?"rgba(74, 222, 128, 0.15)":"rgba(107, 112, 117, 0.15)"},children:n.enabled?"On":"Off"}),children:[e.jsx(Rn,{checked:n.enabled,onChange:()=>o({enabled:!n.enabled}),label:"Enable notifications",description:"Show desktop notifications for Claude events"}),e.jsx("div",{style:se.settingBlock,children:e.jsxs("div",{style:se.settingRow,children:[e.jsxs("div",{children:[e.jsx("div",{style:se.settingLabel,children:"Browser Permission"}),e.jsx("div",{style:se.settingDescription,children:e.jsx("span",{style:{color:$.color},children:$.text})})]}),e.jsx("button",{style:{...se.secondaryBtn,opacity:r==="granted"||r==="unsupported"?.5:1,cursor:r==="granted"||r==="unsupported"?"default":"pointer"},onClick:i,disabled:r==="granted"||r==="unsupported",children:"Request Permission"})]})}),e.jsxs("div",{style:{opacity:n.enabled?1:.4,pointerEvents:n.enabled?"auto":"none"},children:[e.jsx("div",{style:se.settingLabel,children:"Categories"}),e.jsx("div",{style:se.categoryList,children:Object.keys(Dn).map(T=>{const S=La.has(T);return e.jsx("div",{style:S?{opacity:.4,pointerEvents:"none"}:void 0,children:e.jsx(Rn,{checked:S?!1:n.categories[T],onChange:()=>s(T),label:Dn[T].label,description:Dn[T].description,size:"sm"})},T)})})]})]}),e.jsx(zt,{title:"Sync",icon:e.jsx(Oo,{size:16}),description:"Sync sessions, plans, and subagents from Claude Code transcripts",children:e.jsxs("div",{style:se.settingBlock,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[e.jsxs("button",{style:{...se.rebuildBtn,opacity:I?.7:1,cursor:I?"not-allowed":"pointer"},onClick:()=>O(!1),disabled:I,children:[e.jsx(Nt,{size:14,style:{animation:I?"spin 1s linear infinite":"none"}}),I?"Syncing...":"Sync New"]}),e.jsx("button",{style:{...se.secondaryBtn,opacity:I?.7:1,cursor:I?"not-allowed":"pointer"},onClick:()=>O(!0),disabled:I,children:"Re-sync All"}),e.jsxs(qn,{to:"/archive",style:se.archiveLink,children:["See Full Archive",e.jsx(Vs,{size:12,style:{opacity:.7}})]})]}),k&&e.jsxs("div",{style:se.progressContainer,children:[e.jsxs("div",{style:se.progressHeader,children:[e.jsx("span",{style:se.progressPhase,children:k.phase==="extracting"?"Extracting catalogs...":k.phase==="indexing"?(C=k.current)!=null&&C.startsWith("Scanning")?"Scanning projects...":"Indexing sessions...":"Processing..."}),e.jsxs("span",{style:se.progressCount,children:[k.completed,"/",k.total]})]}),e.jsx("div",{style:se.progressBar,children:e.jsx("div",{style:{...se.progressFill,width:k.total>0?`${k.completed/k.total*100}%`:"0%"}})}),e.jsx("div",{style:se.progressCurrent,children:k.current})]}),B&&!I&&e.jsxs("div",{style:se.successBanner,children:["Synced: ",B.extracted," extracted, ",B.indexed," indexed",B.skipped>0&&`, ${B.skipped} skipped`]}),e.jsx("span",{style:{fontSize:"12px",color:t.textMuted,marginTop:"8px",display:"block"},children:"Extract catalog data and rebuild the session index"})]})}),e.jsx(zt,{title:"Sources",icon:e.jsx(bn,{size:16}),description:"External source integrations",children:e.jsx("div",{style:se.placeholder,children:"Source configuration coming soon"})}),u&&e.jsx(zt,{title:"Subscription Usage",icon:e.jsx(Ks,{size:16}),description:"Current rate limits",defaultExpanded:!0,children:e.jsxs("div",{style:se.usageGrid,children:[u.fiveHour&&e.jsx(Wn,{label:"current",utilization:u.fiveHour.utilization,valueText:`${Ro(u.fiveHour.utilization)}%`,resetTime:u.fiveHour.resetsAt,color:t.warning}),u.sevenDay&&e.jsx(Wn,{label:"weekly",utilization:u.sevenDay.utilization,valueText:`${Ro(u.sevenDay.utilization)}%`,resetTime:u.sevenDay.resetsAt,color:t.success}),u.extraUsage&&e.jsx(Wn,{label:"extra",utilization:u.extraUsage.utilization,valueText:`$${u.extraUsage.usedCredits.toFixed(0)}/$${u.extraUsage.monthlyLimit.toFixed(0)}`,resetTime:u.extraUsage.resetsAt,color:t.success})]})})]})}const se={container:{maxWidth:"700px",padding:"24px",display:"flex",flexDirection:"column",gap:"16px"},description:{fontSize:"14px",color:t.textSecondary,marginBottom:"8px"},settingBlock:{display:"flex",flexDirection:"column",gap:"8px"},settingRow:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"16px"},settingLabel:{fontSize:"14px",fontWeight:500,color:t.textPrimary},settingDescription:{fontSize:"12px",color:t.textMuted},autoDetected:{color:t.success},pathInputRow:{display:"flex",gap:"8px",marginTop:"4px"},pathInput:{flex:1,padding:"8px 12px",fontSize:"13px",fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",color:t.textPrimary,backgroundColor:t.bgInput,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",outline:"none"},primaryBtn:{padding:"8px 16px",fontSize:"13px",fontWeight:500,color:"#ffffff",backgroundColor:t.accent,border:"none",borderRadius:"6px",cursor:"pointer",transition:"opacity 150ms ease",whiteSpace:"nowrap"},secondaryBtn:{padding:"8px 12px",fontSize:"12px",fontWeight:500,color:t.textPrimary,backgroundColor:t.bgElevated,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",cursor:"pointer",transition:"background-color 150ms ease"},categoryList:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"8px"},errorText:{fontSize:"12px",color:t.danger,marginTop:"4px"},placeholder:{padding:"24px",textAlign:"center",backgroundColor:t.bgElevated,borderRadius:"6px",color:t.textMuted,fontSize:"13px"},rebuildBtn:{padding:"8px 14px",fontSize:"12px",fontWeight:500,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",color:t.textPrimary,backgroundColor:t.bgElevated,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease"},archiveLink:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 14px",fontSize:"12px",fontWeight:500,color:t.accent,backgroundColor:"transparent",border:`1px solid ${t.accent}40`,borderRadius:"6px",textDecoration:"none",transition:"all 150ms ease"},progressContainer:{marginTop:"12px",padding:"12px",backgroundColor:t.bgElevated,borderRadius:"6px"},progressHeader:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},progressPhase:{fontSize:"12px",color:t.textPrimary,fontWeight:500},progressCount:{fontSize:"11px",color:t.textMuted,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"},progressBar:{height:"4px",backgroundColor:t.bgSecondary,borderRadius:"2px",overflow:"hidden",marginBottom:"6px"},progressFill:{height:"100%",backgroundColor:t.accent,borderRadius:"2px",transition:"width 200ms ease"},progressCurrent:{fontSize:"11px",color:t.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},usageGrid:{display:"flex",flexDirection:"column",gap:"10px"},usageRow:{display:"flex",alignItems:"center",gap:"10px"},usageLabel:{fontSize:"11px",fontWeight:500,color:t.textMuted,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",width:"52px",flexShrink:0},usageDots:{display:"inline-flex",alignItems:"center",gap:"2px",flexShrink:0},usageValue:{fontSize:"11px",fontWeight:600,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",flexShrink:0},usageReset:{fontSize:"10px",color:t.textMuted,opacity:.6,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",marginLeft:"4px"},successBanner:{marginTop:"12px",padding:"10px 12px",backgroundColor:`${t.success}10`,borderRadius:"6px",border:`1px solid ${t.success}30`,fontSize:"12px",color:t.success}};function Fa(){const[n,o]=a.useState({obsidian:{connected:!1},googleDocs:{connected:!1},notion:{connected:!1}});a.useEffect(()=>{async function r(){try{const i=await Xo();o(i)}catch(i){console.error("Failed to load source status:",i)}}r()},[]);const s=[{key:"obsidian",label:"Obsidian",filename:"obsidian.md",description:"Connect to your Obsidian vault to import markdown notes as context."},{key:"googleDocs",label:"Google Docs",filename:"google-docs.api",description:"Import documents from Google Docs (coming soon)."},{key:"notion",label:"Notion",filename:"notion.api",description:"Import pages from Notion workspaces (coming soon)."}];return e.jsxs("div",{style:$t.container,children:[e.jsx(Ut,{title:"Sources"}),e.jsx("p",{style:$t.description,children:"Connect external knowledge sources to enrich your project context."}),e.jsx("div",{style:$t.grid,children:s.map(({key:r,label:i,filename:l,description:c})=>e.jsxs(xn,{title:l,showDots:!0,headerRight:e.jsx($e,{label:n[r].connected?"Connected":"Not connected",variant:n[r].connected?"live":"idle"}),children:[e.jsx("h3",{style:$t.sourceTitle,children:i}),e.jsx("p",{style:$t.sourceDescription,children:c}),e.jsxs("button",{style:$t.configButton,type:"button",children:[e.jsx(Ys,{size:14}),n[r].connected?"Configure":"Connect"]})]},r))})]})}const $t={container:{maxWidth:"1200px"},description:{fontSize:"14px",color:t.textSecondary,marginBottom:"24px"},grid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:"16px"},sourceTitle:{fontSize:"16px",fontWeight:500,color:t.textPrimary,margin:"0 0 8px 0"},sourceDescription:{fontSize:"13px",color:t.textMuted,lineHeight:1.5,margin:"0 0 16px 0"},configButton:{display:"inline-flex",alignItems:"center",gap:"8px",padding:"8px 16px",fontSize:"13px",fontWeight:500,backgroundColor:t.bgElevated,color:t.textSecondary,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",cursor:"pointer",transition:"all 150ms ease"}},Da="https://accounts.google.com/o/oauth2/v2/auth",Wa="https://oauth2.googleapis.com/token",Na="https://www.googleapis.com/oauth2/v2/userinfo",Ha=["https://www.googleapis.com/auth/drive.readonly","https://www.googleapis.com/auth/userinfo.email"];function Oa(n){const o=new URLSearchParams({client_id:n.client_id,redirect_uri:n.redirect_uri,response_type:"code",scope:Ha.join(" "),access_type:"offline",prompt:"consent"});return`${Da}?${o}`}async function qa(n,o){const s=await fetch(Wa,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:o.client_id,client_secret:o.client_secret,code:n,redirect_uri:o.redirect_uri,grant_type:"authorization_code"})});if(!s.ok){const r=await s.text();throw new Error(`Token exchange failed: ${r}`)}return s.json()}async function Ua(n){const o=await fetch(Na,{headers:{Authorization:`Bearer ${n}`}});if(!o.ok)throw new Error("Failed to get user info");return o.json()}function Ja(n){const o=new URLSearchParams(new URL(n).search),s=o.get("code"),r=o.get("error");return r?{error:r}:s?{code:s}:{error:"No code or error in callback URL"}}const Ga="https://api.notion.com/v1/oauth/authorize",Va="https://api.notion.com/v1/oauth/token";function Ka(n){const o=new URLSearchParams({client_id:n.client_id,redirect_uri:n.redirect_uri,response_type:"code",owner:"user"});return`${Ga}?${o}`}async function Ya(n,o){const s=btoa(`${o.client_id}:${o.client_secret}`),r=await fetch(Va,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${s}`},body:JSON.stringify({grant_type:"authorization_code",code:n,redirect_uri:o.redirect_uri})});if(!r.ok){const i=await r.text();throw new Error(`Token exchange failed: ${i}`)}return r.json()}function Xa(n){const o=new URLSearchParams(new URL(n).search),s=o.get("code"),r=o.get("error");return r?{error:r}:s?{code:s}:{error:"No code or error in callback URL"}}const Nn="http://localhost:5173/oauth/google/callback";function Eo(){const n=mt(),[o]=Po(),[s,r]=a.useState(""),[i,l]=a.useState(""),[c,p]=a.useState(null),[g,d]=a.useState(!1),[h,y]=a.useState(!1);a.useEffect(()=>{const f=o.get("code"),u=o.get("error");f||u?(y(!0),x()):m()},[o]);const m=()=>{try{const f=localStorage.getItem("jacques_google_oauth");if(f){const{client_id:u,client_secret:v}=JSON.parse(f);u&&r(u),v&&l(v)}}catch(f){console.error("Failed to load saved credentials:",f)}},x=async()=>{d(!0),p(null);try{const f=window.location.href,{code:u,error:v}=Ja(f);if(v)throw new Error(`OAuth error: ${v}`);if(!u)throw new Error("No authorization code received");const z=localStorage.getItem("jacques_google_oauth");if(!z)throw new Error("OAuth credentials not found. Please try connecting again.");const{client_id:I,client_secret:P}=JSON.parse(z),k=await qa(u,{client_id:I,client_secret:P,redirect_uri:Nn}),_=await Ua(k.access_token);await Dr({client_id:I,client_secret:P,tokens:{access_token:k.access_token,refresh_token:k.refresh_token,expires_at:Date.now()+k.expires_in*1e3},connected_email:_.email}),localStorage.removeItem("jacques_google_oauth"),n("/sources")}catch(f){p(f instanceof Error?f.message:"OAuth failed"),y(!1)}finally{d(!1)}},b=()=>{if(!s.trim()||!i.trim()){p("Please enter both Client ID and Client Secret");return}localStorage.setItem("jacques_google_oauth",JSON.stringify({client_id:s.trim(),client_secret:i.trim()}));const f=Oa({client_id:s.trim(),client_secret:i.trim(),redirect_uri:Nn});window.location.href=f};return h&&g?e.jsxs("div",{style:Ie.container,children:[e.jsx("h1",{style:Ie.title,children:"Connecting Google Docs..."}),e.jsx("p",{style:Ie.description,children:"Please wait while we complete the authorization."})]}):e.jsxs("div",{style:Ie.container,children:[e.jsx("button",{style:Ie.backButton,onClick:()=>n("/sources"),children:"← Back to Sources"}),e.jsx("h1",{style:Ie.title,children:"Connect Google Docs"}),e.jsx("p",{style:Ie.description,children:"Import documents from your Google Drive into your projects."}),e.jsxs("div",{style:Ie.section,children:[e.jsx("h2",{style:Ie.sectionTitle,children:"Setup Instructions"}),e.jsxs("ol",{style:Ie.instructions,children:[e.jsxs("li",{children:["Go to the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",style:Ie.link,children:"Google Cloud Console"})]}),e.jsx("li",{children:"Create a new project or select an existing one"}),e.jsx("li",{children:"Enable the Google Drive API"}),e.jsx("li",{children:"Create OAuth 2.0 credentials (Web application type)"}),e.jsxs("li",{children:["Add ",e.jsx("code",{style:Ie.code,children:Nn})," as an authorized redirect URI"]}),e.jsx("li",{children:"Copy your Client ID and Client Secret below"})]})]}),e.jsxs("div",{style:Ie.section,children:[e.jsx("h2",{style:Ie.sectionTitle,children:"Credentials"}),e.jsxs("div",{style:Ie.field,children:[e.jsx("label",{style:Ie.label,children:"Client ID"}),e.jsx("input",{type:"text",value:s,onChange:f=>r(f.target.value),placeholder:"your-client-id.apps.googleusercontent.com",style:Ie.input})]}),e.jsxs("div",{style:Ie.field,children:[e.jsx("label",{style:Ie.label,children:"Client Secret"}),e.jsx("input",{type:"password",value:i,onChange:f=>l(f.target.value),placeholder:"your-client-secret",style:Ie.input})]}),c&&e.jsx("div",{style:Ie.error,children:c}),e.jsx("button",{style:Ie.connectButton,onClick:b,disabled:g,children:g?"Connecting...":"Connect Google Docs"})]})]})}const Ie={container:{maxWidth:"600px"},backButton:{fontSize:"13px",color:t.textSecondary,background:"none",border:"none",cursor:"pointer",padding:0,marginBottom:"24px"},title:{fontSize:"24px",fontWeight:600,color:t.textPrimary,marginBottom:"8px"},description:{fontSize:"14px",color:t.textSecondary,marginBottom:"24px"},section:{backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.borderSubtle}`,padding:"20px",marginBottom:"16px"},sectionTitle:{fontSize:"16px",fontWeight:500,color:t.textPrimary,marginTop:0,marginBottom:"16px"},instructions:{color:t.textSecondary,fontSize:"14px",lineHeight:1.8,paddingLeft:"20px",margin:0},link:{color:t.accent},code:{backgroundColor:t.bgInput,padding:"2px 6px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace"},field:{marginBottom:"16px"},label:{display:"block",fontSize:"13px",color:t.textSecondary,marginBottom:"6px"},input:{width:"100%",padding:"10px 12px",fontSize:"14px",backgroundColor:t.bgInput,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",color:t.textPrimary,boxSizing:"border-box"},error:{color:t.danger,fontSize:"13px",marginBottom:"16px",padding:"10px",backgroundColor:`${t.danger}20`,borderRadius:"6px"},connectButton:{width:"100%",padding:"12px",fontSize:"14px",fontWeight:500,backgroundColor:t.accent,color:t.textPrimary,border:"none",borderRadius:"6px",cursor:"pointer"}},Hn="http://localhost:5173/oauth/notion/callback";function $o(){const n=mt(),[o]=Po(),[s,r]=a.useState(""),[i,l]=a.useState(""),[c,p]=a.useState(null),[g,d]=a.useState(!1),[h,y]=a.useState(!1);a.useEffect(()=>{const f=o.get("code"),u=o.get("error");f||u?(y(!0),x()):m()},[o]);const m=()=>{try{const f=localStorage.getItem("jacques_notion_oauth");if(f){const{client_id:u,client_secret:v}=JSON.parse(f);u&&r(u),v&&l(v)}}catch(f){console.error("Failed to load saved credentials:",f)}},x=async()=>{d(!0),p(null);try{const f=window.location.href,{code:u,error:v}=Xa(f);if(v)throw new Error(`OAuth error: ${v}`);if(!u)throw new Error("No authorization code received");const z=localStorage.getItem("jacques_notion_oauth");if(!z)throw new Error("OAuth credentials not found. Please try connecting again.");const{client_id:I,client_secret:P}=JSON.parse(z),k=await Ya(u,{client_id:I,client_secret:P,redirect_uri:Hn});await Wr({client_id:I,client_secret:P,tokens:{access_token:k.access_token},workspace_id:k.workspace_id,workspace_name:k.workspace_name}),localStorage.removeItem("jacques_notion_oauth"),n("/sources")}catch(f){p(f instanceof Error?f.message:"OAuth failed"),y(!1)}finally{d(!1)}},b=()=>{if(!s.trim()||!i.trim()){p("Please enter both Client ID and Client Secret");return}localStorage.setItem("jacques_notion_oauth",JSON.stringify({client_id:s.trim(),client_secret:i.trim()}));const f=Ka({client_id:s.trim(),client_secret:i.trim(),redirect_uri:Hn});window.location.href=f};return h&&g?e.jsxs("div",{style:Te.container,children:[e.jsx("h1",{style:Te.title,children:"Connecting Notion..."}),e.jsx("p",{style:Te.description,children:"Please wait while we complete the authorization."})]}):e.jsxs("div",{style:Te.container,children:[e.jsx("button",{style:Te.backButton,onClick:()=>n("/sources"),children:"← Back to Sources"}),e.jsx("h1",{style:Te.title,children:"Connect Notion"}),e.jsx("p",{style:Te.description,children:"Import pages from your Notion workspace into your projects."}),e.jsxs("div",{style:Te.section,children:[e.jsx("h2",{style:Te.sectionTitle,children:"Setup Instructions"}),e.jsxs("ol",{style:Te.instructions,children:[e.jsxs("li",{children:["Go to"," ",e.jsx("a",{href:"https://www.notion.so/my-integrations",target:"_blank",rel:"noopener noreferrer",style:Te.link,children:"Notion Integrations"})]}),e.jsx("li",{children:'Click "New integration"'}),e.jsx("li",{children:'Choose "Public integration" and fill in the required fields'}),e.jsxs("li",{children:["In the OAuth settings, add"," ",e.jsx("code",{style:Te.code,children:Hn})," as a redirect URI"]}),e.jsx("li",{children:"Copy your OAuth Client ID and Client Secret below"})]})]}),e.jsxs("div",{style:Te.section,children:[e.jsx("h2",{style:Te.sectionTitle,children:"Credentials"}),e.jsxs("div",{style:Te.field,children:[e.jsx("label",{style:Te.label,children:"OAuth Client ID"}),e.jsx("input",{type:"text",value:s,onChange:f=>r(f.target.value),placeholder:"your-notion-oauth-client-id",style:Te.input})]}),e.jsxs("div",{style:Te.field,children:[e.jsx("label",{style:Te.label,children:"OAuth Client Secret"}),e.jsx("input",{type:"password",value:i,onChange:f=>l(f.target.value),placeholder:"your-notion-oauth-client-secret",style:Te.input})]}),c&&e.jsx("div",{style:Te.error,children:c}),e.jsx("button",{style:Te.connectButton,onClick:b,disabled:g,children:g?"Connecting...":"Connect Notion"})]})]})}const Te={container:{maxWidth:"600px"},backButton:{fontSize:"13px",color:t.textSecondary,background:"none",border:"none",cursor:"pointer",padding:0,marginBottom:"24px"},title:{fontSize:"24px",fontWeight:600,color:t.textPrimary,marginBottom:"8px"},description:{fontSize:"14px",color:t.textSecondary,marginBottom:"24px"},section:{backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.borderSubtle}`,padding:"20px",marginBottom:"16px"},sectionTitle:{fontSize:"16px",fontWeight:500,color:t.textPrimary,marginTop:0,marginBottom:"16px"},instructions:{color:t.textSecondary,fontSize:"14px",lineHeight:1.8,paddingLeft:"20px",margin:0},link:{color:t.accent},code:{backgroundColor:t.bgInput,padding:"2px 6px",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace"},field:{marginBottom:"16px"},label:{display:"block",fontSize:"13px",color:t.textSecondary,marginBottom:"6px"},input:{width:"100%",padding:"10px 12px",fontSize:"14px",backgroundColor:t.bgInput,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",color:t.textPrimary,boxSizing:"border-box"},error:{color:t.danger,fontSize:"13px",marginBottom:"16px",padding:"10px",backgroundColor:`${t.danger}20`,borderRadius:"6px"},connectButton:{width:"100%",padding:"12px",fontSize:"14px",fontWeight:500,backgroundColor:t.accent,color:t.textPrimary,border:"none",borderRadius:"6px",cursor:"pointer"}};function Ke(n){return n?Math.ceil(n.length/4):0}function xs(n){if(!n||typeof n!="object")return 0;const o=n;switch(o.type){case"text":return Ke(o.text||"");case"thinking":return Ke(o.text||"");case"tool_use":{const s=o.name||"",r=JSON.stringify(o.input||{});return Ke(s)+Ke(r)}case"tool_result":return Ke(o.content||"");case"code":return Ke(o.code||"");default:try{return Ke(JSON.stringify(n))}catch{return 0}}}function be(n){return n<1e3?`${n}`:`${(n/1e3).toFixed(1)}k`}const Za=[{pattern:/^implement the following plan[:\s]*/i,label:"Implement the following plan:"},{pattern:/^here is the plan[:\s]*/i,label:"Here is the plan:"},{pattern:/^follow this plan[:\s]*/i,label:"Follow this plan:"}];function Qa(n){const o=n.match(/^#\s+(.+)$/m);if(o){const s=o[1].trim();return s.startsWith("Plan:")?s:`Plan: ${s}`}return"Plan"}function el(n){return!n||n.length<100||!/^#+\s+.+/m.test(n)?!1:/^[-*]\s+.+/m.test(n)||n.split(`
120
+
121
+ `).length>1}function tl(n){const o=[];for(const{pattern:s,label:r}of Za){const i=n.match(s);if(i){const l=n.substring(0,i.index||0).trim(),c=n.substring((i.index||0)+i[0].length).trim();if(el(c))return l.length>0&&o.push({type:"text",content:l}),o.push({type:"plan",content:c,planTitle:Qa(c),triggerLabel:r}),o}}return[{type:"text",content:n}]}function nl({message:n}){const[o,s]=a.useState(!1),[r,i]=a.useState(!1),l=new Date(n.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),c=n.content.filter(x=>x.type==="text").map(x=>x.text).join(`
122
+ `),p=tl(c),g=p.some(x=>x.type==="plan"),d=Ke(c),h=c.split(`
123
+ `).length,y=c.length>400||h>15,m=y&&!o;return e.jsxs("div",{style:Me.container,children:[e.jsxs("div",{style:Me.header,children:[e.jsx("span",{style:Me.role,children:"User"}),e.jsxs("div",{style:Me.headerRight,children:[g&&e.jsxs("span",{style:Me.planIndicator,children:[e.jsx(Re,{size:12})," Has Plan"]}),e.jsxs("span",{style:Me.tokenBadge,title:`~${d} tokens`,children:[be(d)," tok"]}),e.jsx("span",{style:Me.timestamp,children:l})]})]}),e.jsxs("div",{style:Me.content,children:[p.map((x,b)=>{if(x.type==="plan")return e.jsxs("div",{children:[x.triggerLabel&&e.jsx("div",{style:Me.triggerText,children:x.triggerLabel}),e.jsxs("div",{style:Me.planBox,children:[e.jsxs("button",{type:"button",style:Me.planHeader,onClick:()=>i(!r),children:[e.jsx("span",{style:Me.planIcon,children:e.jsx(Re,{size:16})}),e.jsx("span",{style:Me.planTitle,children:x.planTitle}),e.jsx("span",{style:Me.planToggle,children:r?e.jsx(tt,{size:14}):e.jsx(Fe,{size:14})})]}),r&&e.jsx("div",{className:"jacques-expand-content",style:Me.planContent,children:e.jsx(pt,{content:x.content})}),!r&&e.jsxs("div",{style:Me.planPreview,children:[x.content.split(`
124
+ `).slice(0,3).join(`
125
+ `),"..."]})]})]},b);const f=m?x.content.slice(0,300)+"...":x.content;return e.jsx("div",{style:Me.textContent,children:f},b)}),y&&!g&&e.jsxs("button",{type:"button",style:Me.expandButton,onClick:()=>s(!o),children:[e.jsx("span",{style:Me.expandIcon,children:o?e.jsx(Xs,{size:12}):e.jsx(tt,{size:12})}),o?"Show less":`Show more (${h} lines)`]})]})]})}const Me={container:{backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.borderSubtle}`,borderLeft:`2px solid ${t.accent}`,overflow:"hidden",marginBottom:"16px",width:"100%"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",backgroundColor:t.bgElevated,borderBottom:`1px solid ${t.borderSubtle}`},headerRight:{display:"flex",alignItems:"center",gap:"12px"},role:{fontWeight:600,color:t.textPrimary},planIndicator:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"11px",color:"#34D399",backgroundColor:"rgba(52, 211, 153, 0.15)",padding:"2px 8px",borderRadius:"4px",fontWeight:500},tokenBadge:{fontSize:"11px",color:t.textMuted,backgroundColor:t.bgSecondary,padding:"2px 8px",borderRadius:"4px",fontFamily:"monospace"},timestamp:{fontSize:"12px",color:t.textMuted},content:{padding:"16px"},textContent:{color:t.textPrimary,whiteSpace:"pre-wrap",lineHeight:1.6},triggerText:{color:t.textSecondary,marginBottom:"12px",fontStyle:"italic"},planBox:{backgroundColor:t.bgPrimary,borderRadius:"8px",border:"1px solid #34D399",overflow:"hidden"},planHeader:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 12px",minHeight:"36px",backgroundColor:"rgba(52, 211, 153, 0.1)",border:"none",borderBottom:"1px solid rgba(52, 211, 153, 0.3)",cursor:"pointer",textAlign:"left"},planIcon:{display:"inline-flex",alignItems:"center",color:"#34D399"},planTitle:{flex:1,fontSize:"14px",fontWeight:600,color:"#34D399",overflow:"visible",whiteSpace:"normal",wordBreak:"break-word"},planToggle:{display:"inline-flex",alignItems:"center",color:t.textMuted},planContent:{padding:"8px 12px",maxHeight:"500px",overflow:"auto"},planPreview:{padding:"8px 12px",color:t.textMuted,fontSize:"13px",whiteSpace:"pre-wrap",maxHeight:"80px",overflow:"hidden"},expandButton:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"6px 12px",marginTop:"12px",backgroundColor:t.bgElevated,border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",color:t.textMuted,fontSize:"12px",cursor:"pointer"},expandIcon:{display:"inline-flex",alignItems:"center"}},Ft=a.forwardRef(function({title:o,icon:s,summary:r,defaultExpanded:i=!1,forceExpanded:l,headerStyle:c,children:p},g){const[d,h]=a.useState(i),y=a.useRef(null);a.useEffect(()=>{l&&h(!0)},[l]),a.useImperativeHandle(g,()=>({expand:()=>h(!0),scrollIntoView:()=>{var x;(x=y.current)==null||x.scrollIntoView({behavior:"smooth",block:"center"})}}));const m=e.jsx(Fe,{size:14});return e.jsxs("div",{ref:y,style:Bt.container,children:[e.jsxs("button",{style:{...Bt.header,...c},onClick:()=>h(!d),type:"button",children:[e.jsx("span",{style:{...Bt.icon,transform:d?"rotate(90deg)":"none"},children:s||m}),e.jsx("span",{style:Bt.title,children:o}),!d&&r&&e.jsx("span",{style:Bt.summary,children:r})]}),d&&e.jsx("div",{className:"jacques-expand-content",style:Bt.content,children:p})]})}),Bt={container:{borderRadius:"6px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden",marginTop:"12px"},header:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 12px",minHeight:"44px",backgroundColor:t.bgElevated,border:"none",cursor:"pointer",textAlign:"left",color:t.textSecondary,fontSize:"13px",transition:"background-color 150ms ease"},icon:{display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"transform 150ms ease",flexShrink:0},title:{fontWeight:500},summary:{marginLeft:"auto",fontSize:"12px",color:t.textMuted},content:{padding:"12px",backgroundColor:t.bgInput,borderTop:`1px solid ${t.borderSubtle}`}};function gs({code:n,language:o}){const[s,r]=a.useState(!1),i=async()=>{try{await navigator.clipboard.writeText(n),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},l=n.split(`
126
+ `).length;return e.jsxs("div",{style:Mt.container,children:[e.jsxs("div",{style:Mt.header,children:[o&&e.jsx("span",{style:Mt.language,children:o}),e.jsxs("span",{style:Mt.lineCount,children:[l," lines"]}),e.jsx("button",{style:Mt.copyButton,onClick:i,type:"button",children:s?"✓ Copied":"Copy"})]}),e.jsx("pre",{style:Mt.code,children:e.jsx("code",{children:n})})]})}const Mt={container:{borderRadius:"6px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden",marginTop:"12px",marginBottom:"12px"},header:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",backgroundColor:t.bgElevated,borderBottom:`1px solid ${t.borderSubtle}`,fontSize:"12px"},language:{color:t.accent,fontWeight:500},lineCount:{color:t.textMuted},copyButton:{marginLeft:"auto",padding:"4px 8px",fontSize:"11px",color:t.textSecondary,backgroundColor:t.bgInput,border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",cursor:"pointer",transition:"all 150ms ease"},code:{margin:0,padding:"12px",backgroundColor:t.bgInput,fontSize:"13px",lineHeight:1.5,overflow:"auto",color:t.textPrimary}};function ol({agentId:n,sessionId:o,promptPreview:s}){const[r,i]=a.useState(null),[l,c]=a.useState(!0),[p,g]=a.useState(null);if(a.useEffect(()=>{let h=!1;async function y(){c(!0),g(null);try{const m=await Sn(o,n);h||i(m)}catch(m){h||g(m instanceof Error?m.message:"Failed to load subagent")}finally{h||c(!1)}}return y(),()=>{h=!0}},[n,o]),l)return e.jsxs("div",{style:oe.loadingContainer,children:[e.jsx(Oe,{size:14,style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"Loading subagent conversation..."})]});if(p)return e.jsxs("div",{style:oe.errorContainer,children:[e.jsx("span",{style:oe.errorIcon,children:e.jsx(At,{size:16})}),e.jsx("span",{children:p}),s&&e.jsxs("div",{style:oe.fallbackPrompt,children:[e.jsx("strong",{children:"Task prompt:"})," ",s]})]});if(!r)return e.jsxs("div",{style:oe.errorContainer,children:[e.jsx("span",{children:"Subagent not found"}),s&&e.jsxs("div",{style:oe.fallbackPrompt,children:[e.jsx("strong",{children:"Task prompt:"})," ",s]})]});const d=r.statistics.tokens.totalInput+r.statistics.tokens.totalOutput;return e.jsxs("div",{style:oe.container,children:[e.jsxs("div",{style:oe.header,children:[e.jsxs("div",{style:oe.headerLeft,children:[e.jsxs("span",{style:oe.agentId,children:["Agent ",n]}),r.model&&e.jsx("span",{style:oe.model,children:r.model})]}),e.jsxs("div",{style:oe.headerRight,children:[e.jsxs("span",{style:oe.stat,children:[be(r.statistics.tokens.totalInput)," in"]}),e.jsx("span",{style:oe.statDivider,children:"•"}),e.jsxs("span",{style:oe.stat,children:[be(r.statistics.tokens.totalOutput)," out"]}),e.jsx("span",{style:oe.statDivider,children:"•"}),e.jsxs("span",{style:oe.statTotal,children:[be(d)," total"]}),e.jsx("span",{style:oe.statDivider,children:"•"}),e.jsxs("span",{style:oe.stat,children:[r.statistics.messageCount," msgs"]})]})]}),e.jsxs("div",{style:oe.promptSection,children:[e.jsx("div",{style:oe.promptLabel,children:"Task:"}),e.jsx("div",{style:oe.promptText,children:r.prompt})]}),e.jsx("div",{style:oe.messagesContainer,children:r.entries.map((h,y)=>e.jsx(sl,{entry:h},h.uuid||y))})]})}function sl({entry:n}){var h,y,m,x,b;const o=n.type==="user_message",s=n.type==="tool_call",r=n.type==="tool_result",i=n.type==="assistant_message",l=(h=n.content)==null?void 0:h.text,c=(y=n.content)==null?void 0:y.thinking,p=(m=n.content)==null?void 0:m.toolName,g=(x=n.content)==null?void 0:x.toolInput,d=(b=n.content)==null?void 0:b.toolResultContent;if(n.type==="hook_progress"||n.type==="turn_duration"||n.type==="system_event"||n.type==="summary"||n.type==="bash_progress"||n.type==="mcp_progress"||n.type==="web_search")return null;if(s&&p){const f=rl(p,g);return e.jsxs("div",{style:oe.toolMessage,children:[e.jsx("span",{style:oe.toolIcon,children:e.jsx(Zt,{size:12})}),e.jsx("span",{style:oe.toolName,children:p}),f&&e.jsx("span",{style:oe.toolSummary,children:f})]})}if(r&&d){const f=d.length>150?d.slice(0,150)+"...":d;return e.jsxs("div",{style:oe.toolResultMessage,children:[e.jsx("span",{style:oe.toolResultIcon,children:e.jsx(Dt,{size:12})}),e.jsx("pre",{style:oe.toolResultContent,children:f})]})}return s||r||!o&&!i||!l&&!c?null:e.jsxs("div",{style:{...oe.message,...o?oe.userMessage:oe.assistantMessage},children:[e.jsx("div",{style:oe.messageRole,children:o?"User":"Assistant"}),c&&e.jsxs("div",{style:oe.thinkingBlock,children:[e.jsx("span",{style:oe.thinkingLabel,children:"Thinking:"}),e.jsx("pre",{style:oe.thinkingContent,children:c.length>500?c.slice(0,500)+"...":c})]}),l&&e.jsx("div",{style:oe.messageText,children:l})]})}function rl(n,o){if(!o)return"";switch(n){case"Read":case"Write":case"Edit":if(typeof o.file_path=="string"){const s=o.file_path;return s.split("/").pop()||s}break;case"Bash":if(typeof o.command=="string"){const s=o.command;return s.length>40?s.slice(0,40)+"...":s}break;case"Glob":if(typeof o.pattern=="string")return o.pattern;break;case"Grep":if(typeof o.pattern=="string")return o.pattern;break}return""}const oe={container:{display:"flex",flexDirection:"column",gap:"12px"},loadingContainer:{display:"flex",alignItems:"center",gap:"8px",padding:"16px",color:t.textMuted,fontSize:"13px"},errorContainer:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px",color:t.warning,fontSize:"13px"},errorIcon:{display:"inline-flex",alignItems:"center"},fallbackPrompt:{marginTop:"8px",padding:"8px",backgroundColor:t.bgSecondary,borderRadius:"4px",fontSize:"12px",color:t.textSecondary},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",backgroundColor:t.bgSecondary,borderRadius:"4px",borderLeft:`3px solid ${t.accentOrange}`},headerLeft:{display:"flex",alignItems:"center",gap:"8px"},headerRight:{display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",fontFamily:"monospace"},agentId:{fontWeight:600,color:t.textPrimary,fontSize:"13px"},model:{padding:"2px 6px",backgroundColor:t.bgElevated,borderRadius:"3px",fontSize:"11px",color:t.textMuted},stat:{color:t.textSecondary},statTotal:{color:t.accentOrange,fontWeight:500},statDivider:{color:t.textMuted},promptSection:{padding:"8px 12px",backgroundColor:t.bgPrimary,borderRadius:"4px",border:`1px solid ${t.borderSubtle}`},promptLabel:{fontSize:"11px",fontWeight:600,color:t.textMuted,textTransform:"uppercase",marginBottom:"4px"},promptText:{fontSize:"13px",color:t.textSecondary,lineHeight:1.5},messagesContainer:{display:"flex",flexDirection:"column",gap:"8px",maxHeight:"400px",overflow:"auto"},message:{padding:"10px 12px",borderRadius:"6px",fontSize:"13px",lineHeight:1.5},userMessage:{backgroundColor:t.bgSecondary,borderLeft:`2px solid ${t.accent}`},assistantMessage:{backgroundColor:t.bgElevated,borderLeft:`2px solid ${t.textMuted}`},messageRole:{fontSize:"11px",fontWeight:600,color:t.textMuted,textTransform:"uppercase",marginBottom:"4px"},messageText:{color:t.textPrimary,whiteSpace:"pre-wrap"},thinkingBlock:{marginBottom:"8px",padding:"6px 8px",backgroundColor:t.bgPrimary,borderRadius:"4px",opacity:.8},thinkingLabel:{fontSize:"10px",fontWeight:600,color:t.textMuted,textTransform:"uppercase",display:"block",marginBottom:"4px"},thinkingContent:{margin:0,fontSize:"12px",color:t.textMuted,whiteSpace:"pre-wrap",fontFamily:"inherit"},toolMessage:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",backgroundColor:t.bgSecondary,borderRadius:"4px",fontSize:"12px",color:t.textMuted},toolIcon:{display:"inline-flex",alignItems:"center"},toolName:{fontWeight:500,color:t.textSecondary},toolSummary:{color:t.textMuted,fontFamily:"monospace",fontSize:"11px"},toolResultMessage:{display:"flex",alignItems:"flex-start",gap:"6px",padding:"4px 10px",backgroundColor:t.bgPrimary,borderRadius:"4px",fontSize:"11px",color:t.textMuted},toolResultIcon:{display:"inline-flex",alignItems:"center",color:t.success},toolResultContent:{flex:1,margin:0,fontFamily:"monospace",fontSize:"11px",whiteSpace:"pre-wrap",overflow:"hidden",maxHeight:"40px",color:t.textSecondary}};function il(n){switch(n==null?void 0:n.toLowerCase()){case"explore":return{icon:e.jsx(yt,{size:14}),color:"#60A5FA",label:"Explore"};case"plan":return{icon:e.jsx(Re,{size:14}),color:"#34D399",label:"Plan"};case"general-purpose":return{icon:e.jsx(et,{size:14}),color:"#A78BFA",label:"General"};case"bash":return{icon:e.jsx(ft,{size:14}),color:"#F472B6",label:"Bash"};default:return{icon:e.jsx(et,{size:14}),color:"#9CA3AF",label:n||"Agent"}}}function al(n){var o;for(let s=n.length-1;s>=0;s--){const r=n[s];if(r.type==="assistant_message"&&((o=r.content)!=null&&o.text))return r.content.text}return null}const ll=a.forwardRef(function({content:o,expanded:s=!1,sessionId:r},i){var re,U,Z,q;const[l,c]=a.useState(!1),[p,g]=a.useState(!1),[d,h]=a.useState(null),[y,m]=a.useState(!1),[x,b]=a.useState(null),[f,u]=a.useState(!1),v=a.useRef(null);a.useImperativeHandle(i,()=>({expand:()=>{var X;u(!0),(X=v.current)==null||X.expand()},scrollIntoView:()=>{var X;(X=v.current)==null||X.scrollIntoView()}}));const z=il(o.agentType),I=o.agentType?`${z.label} Agent`:o.agentId?`Agent ${o.agentId.slice(0,7)}`:"Subagent",P=o.prompt?o.prompt.length>60?o.prompt.slice(0,60)+"...":o.prompt:"Subagent task",k=[];o.messageCount&&k.push(`${o.messageCount} msgs`),o.tokenCount&&k.push(`${be(o.tokenCount)} tok`);const _=k.length>0?` (${k.join(", ")})`:"",B=P+_,W=!!o.agentId&&!!r;a.useEffect(()=>{!o.agentId||!r||d||y||(m(!0),Sn(r,o.agentId).then(X=>{h(X),b(null)}).catch(X=>{b(X.message||"Failed to load response")}).finally(()=>{m(!1)}))},[o.agentId,r,d,y]);const O=d?al(d.entries):null,M=O?O.split(`
127
+ `).length:0,$=(re=d==null?void 0:d.statistics)==null?void 0:re.tokens,C=($==null?void 0:$.totalInput)||0,T=($==null?void 0:$.totalOutput)||0,S=($==null?void 0:$.cacheCreation)||0,F=($==null?void 0:$.cacheRead)||0,J=($==null?void 0:$.freshInput)||0,K=S>0||F>0;return e.jsx(Ft,{ref:v,title:I,icon:z.icon,summary:B,defaultExpanded:s,forceExpanded:f,children:e.jsxs("div",{style:ue.container,children:[e.jsxs("div",{style:ue.statsBar,children:[o.agentType&&e.jsxs("span",{style:{...ue.typeBadge,backgroundColor:z.color},children:[e.jsx("span",{style:ue.badgeIcon,children:z.icon})," ",z.label]}),o.model&&e.jsx("span",{style:ue.modelBadge,children:o.model}),$?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:ue.tokenBadge,children:[be(C)," in"]}),e.jsxs("span",{style:ue.tokenBadge,children:[be(T)," out"]}),K&&e.jsxs("span",{style:ue.cacheBadge,title:`Fresh: ${be(J)}, Cache write: ${be(S)}, Cache read: ${be(F)}`,children:["(",be(F)," cached)"]})]}):o.tokenCount?e.jsxs("span",{style:ue.tokenBadge,children:[be(o.tokenCount)," tokens"]}):null,((U=d==null?void 0:d.statistics)==null?void 0:U.messageCount)&&e.jsxs("span",{style:ue.messageBadge,children:[d.statistics.messageCount," msgs"]})]}),o.prompt&&!l&&e.jsxs("div",{style:ue.section,children:[e.jsx("div",{style:ue.label,children:"Query:"}),e.jsx("pre",{style:ue.queryContent,children:o.prompt})]}),!l&&e.jsxs("div",{style:ue.section,children:[e.jsx("div",{style:ue.label,children:"Response:"}),y?e.jsxs("div",{style:ue.loadingResponse,children:[e.jsx(Oe,{size:14,style:{animation:"spin 1s linear infinite"}}),"Loading response..."]}):x?e.jsxs("div",{style:ue.errorResponse,children:[e.jsx(At,{size:14})," ",x]}):O?e.jsxs("div",{style:{...ue.responseBlock,...((Z=o.agentType)==null?void 0:Z.toLowerCase())==="plan"?ue.responseBlockPlan:{}},children:[e.jsxs("button",{type:"button",style:{...ue.responseHeader,...((q=o.agentType)==null?void 0:q.toLowerCase())==="plan"?ue.responseHeaderPlan:{}},onClick:()=>g(!p),children:[e.jsx("span",{style:{...ue.expandIcon,transform:p?"rotate(90deg)":"none",transition:"transform 150ms ease"},children:e.jsx(Fe,{size:12})}),e.jsx("span",{style:ue.responseHeaderTitle,children:"Response"}),!p&&e.jsxs("span",{style:ue.responseHeaderHint,children:[M," lines"]})]}),p&&e.jsx("div",{style:ue.responseContent,children:e.jsx(pt,{content:O})})]}):e.jsx("div",{style:ue.noResponse,children:"Click to load agent response"})]}),W&&e.jsxs("button",{type:"button",style:{...ue.toggleButton,...l?ue.toggleButtonActive:{}},onClick:()=>c(!l),children:[e.jsx("span",{style:ue.expandIcon,children:l?e.jsx(tt,{size:12}):e.jsx(Fe,{size:12})}),l?"Hide Full Conversation":"View Full Conversation"]}),l&&o.agentId&&r&&e.jsx("div",{style:ue.fullConversation,children:e.jsx(ol,{agentId:o.agentId,sessionId:r,promptPreview:o.prompt})})]})})}),ue={container:{display:"flex",flexDirection:"column",gap:"12px"},statsBar:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},typeBadge:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 12px",borderRadius:"12px",fontSize:"13px",fontWeight:600,color:"white"},badgeIcon:{display:"inline-flex",alignItems:"center"},modelBadge:{padding:"4px 10px",backgroundColor:t.bgSecondary,borderRadius:"4px",fontSize:"13px",color:t.textMuted,fontWeight:500},tokenBadge:{padding:"4px 10px",backgroundColor:"rgba(230, 126, 82, 0.15)",borderRadius:"4px",fontSize:"13px",fontFamily:"monospace",color:t.accentOrange,fontWeight:600},messageBadge:{padding:"4px 10px",backgroundColor:t.bgSecondary,borderRadius:"4px",fontSize:"13px",color:t.textMuted,fontWeight:500},cacheBadge:{padding:"4px 10px",backgroundColor:t.bgSecondary,borderRadius:"4px",fontSize:"12px",color:t.textMuted,fontStyle:"italic",cursor:"help"},toggleButton:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 12px",backgroundColor:t.bgSecondary,border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",color:t.accent,fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"all 150ms ease"},toggleButtonActive:{backgroundColor:t.bgElevated,borderColor:t.accent},fullConversation:{marginTop:"4px",padding:"12px",backgroundColor:t.bgPrimary,borderRadius:"6px",border:`1px solid ${t.borderSubtle}`},section:{display:"flex",flexDirection:"column",gap:"4px"},label:{fontSize:"13px",fontWeight:600,color:t.textSecondary,textTransform:"uppercase",letterSpacing:"0.5px"},queryContent:{margin:0,padding:"12px",backgroundColor:t.bgPrimary,borderRadius:"6px",fontSize:"13px",color:t.textSecondary,whiteSpace:"pre-wrap",maxHeight:"150px",overflow:"auto",border:`1px solid ${t.borderSubtle}`},loadingResponse:{display:"flex",alignItems:"center",gap:"8px",padding:"12px",color:t.textMuted,fontSize:"12px"},errorResponse:{display:"flex",alignItems:"center",gap:"6px",padding:"12px",color:t.warning,fontSize:"12px",backgroundColor:t.bgPrimary,borderRadius:"4px"},noResponse:{padding:"12px",color:t.textMuted,fontSize:"12px",backgroundColor:t.bgPrimary,borderRadius:"4px",fontStyle:"italic"},responseBlock:{borderRadius:"6px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden"},responseBlockPlan:{borderLeft:"3px solid #34D399"},responseHeader:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 12px",backgroundColor:t.bgElevated,border:"none",cursor:"pointer",textAlign:"left",color:t.textSecondary,fontSize:"12px",transition:"background-color 150ms ease"},responseHeaderPlan:{backgroundColor:"rgba(52, 211, 153, 0.1)"},responseHeaderTitle:{fontWeight:500},responseHeaderHint:{marginLeft:"auto",fontSize:"11px",color:t.textMuted},responseContent:{padding:"12px 16px",backgroundColor:t.bgInput,borderTop:`1px solid ${t.borderSubtle}`,maxHeight:"60vh",overflow:"auto"},expandIcon:{display:"inline-flex",alignItems:"center"}},cl=a.forwardRef(function({content:o,expanded:s=!1},r){const[i,l]=a.useState(!1),c=a.useRef(null);a.useImperativeHandle(r,()=>({expand:()=>{var m;l(!0),(m=c.current)==null||m.expand()},scrollIntoView:()=>{var m;(m=c.current)==null||m.scrollIntoView()}}));const p=o.elapsedSeconds?`${o.elapsedSeconds}s`:"",g=o.totalLines!==void 0?`${o.totalLines} lines`:"",d=[p,g].filter(Boolean).join(" • ")||"Running...",h=o.fullOutput||o.output||"",y=h.length>0;return e.jsx(Ft,{ref:c,title:"Bash Output",icon:e.jsx(ft,{size:14}),summary:d,defaultExpanded:s,forceExpanded:i,children:e.jsx("div",{style:On.container,children:y?e.jsx("pre",{style:On.output,children:h}):e.jsx("span",{style:On.empty,children:"No output"})})})}),On={container:{maxHeight:"300px",overflow:"auto"},output:{margin:0,padding:"8px",backgroundColor:t.bgPrimary,borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",color:t.textSecondary,whiteSpace:"pre-wrap",wordBreak:"break-all"},empty:{fontSize:"12px",color:t.textMuted,fontStyle:"italic"}};function dl({content:n}){const o=n.status==="completed",s=o?t.success:t.accent;return e.jsxs("div",{style:Kt.container,children:[e.jsx("span",{style:{...Kt.icon,color:s},children:o?e.jsx(Dt,{size:14}):e.jsx(Oe,{size:14,style:{animation:"spin 1s linear infinite"}})}),e.jsx("span",{style:Kt.label,children:"MCP"}),n.serverName&&e.jsx("span",{style:Kt.server,children:n.serverName}),n.toolName&&e.jsx("span",{style:Kt.tool,children:n.toolName})]})}const Kt={container:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",backgroundColor:t.bgElevated,borderRadius:"6px",border:`1px solid ${t.borderSubtle}`,marginTop:"8px"},icon:{display:"inline-flex",alignItems:"center"},label:{fontSize:"12px",fontWeight:600,color:t.textMuted},server:{fontSize:"12px",color:t.textSecondary,backgroundColor:t.bgSecondary,padding:"2px 6px",borderRadius:"3px"},tool:{fontSize:"12px",color:t.accent}};function pl({content:n}){const[o,s]=a.useState(!1),r=n.searchType==="results",i=r?`${n.resultCount||0} results`:"Searching...",l=n.urls&&n.urls.length>0;return e.jsxs("div",{style:Xe.container,children:[e.jsxs("div",{style:Xe.header,children:[e.jsx("span",{style:Xe.icon,children:r?e.jsx(Re,{size:14}):e.jsx(yt,{size:14})}),e.jsx("span",{style:Xe.label,children:"Web Search"}),n.query&&e.jsxs("span",{style:Xe.query,children:['"',n.query,'"']}),e.jsx("span",{style:Xe.status,children:i}),l&&e.jsxs("button",{type:"button",style:Xe.toggleButton,onClick:()=>s(!o),children:[e.jsx("span",{style:Xe.toggleIcon,children:o?e.jsx(tt,{size:12}):e.jsx(Fe,{size:12})}),o?"Hide URLs":"Show URLs"]})]}),o&&n.urls&&e.jsx("div",{className:"jacques-expand-content",style:Xe.urlList,children:n.urls.map((c,p)=>e.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",style:Xe.urlItem,title:c.url,children:[e.jsxs("span",{style:Xe.urlNumber,children:[p+1,"."]}),e.jsx("span",{style:Xe.urlTitle,children:c.title})]},p))})]})}const Xe={container:{display:"flex",flexDirection:"column",gap:"8px",padding:"8px 12px",backgroundColor:t.bgElevated,borderRadius:"6px",border:`1px solid ${t.borderSubtle}`,marginTop:"8px"},header:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},icon:{display:"inline-flex",alignItems:"center",color:t.textMuted},label:{fontSize:"12px",fontWeight:600,color:t.textMuted},query:{fontSize:"12px",color:t.textSecondary,fontStyle:"italic",flex:1,minWidth:"100px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},status:{fontSize:"11px",color:t.textMuted,backgroundColor:t.bgSecondary,padding:"2px 6px",borderRadius:"3px"},toggleButton:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",backgroundColor:"transparent",border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",color:t.accent,fontSize:"11px",cursor:"pointer"},toggleIcon:{display:"inline-flex",alignItems:"center"},urlList:{display:"flex",flexDirection:"column",gap:"4px",marginTop:"4px",paddingTop:"8px",borderTop:`1px solid ${t.borderSubtle}`,maxHeight:"200px",overflow:"auto"},urlItem:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",backgroundColor:t.bgSecondary,borderRadius:"4px",color:t.textSecondary,textDecoration:"none",fontSize:"12px",transition:"background-color 150ms ease"},urlNumber:{fontSize:"11px",color:t.textMuted,minWidth:"16px"},urlTitle:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}};function ul(n){for(const o of n)for(const s of o.content)if(s.type==="text"&&s.text.trim()){const i=s.text.trim().split(`
128
+ `)[0];return i.length>80?i.slice(0,77)+"...":i}return""}function xl(n){const o=[],s=new Set;return n.forEach((r,i)=>{r.content.forEach((l,c)=>{if(l.type==="agent_progress"){const p=l,g=p.agentType||"agent";p.agentId&&!s.has(p.agentId)&&(s.add(p.agentId),o.push({type:"agent",label:g.charAt(0).toUpperCase()+g.slice(1),icon:e.jsx(et,{size:12}),color:"#A78BFA",messageIndex:i,contentIndex:c,id:p.agentId}))}})}),o}function gl(n){let o=0,s=0,r=0,i=0,l=0,c=0;const p=new Set;return n.forEach(g=>{g.content.forEach(d=>{const h=xs(d);if(o+=h,d.type==="thinking")s+=h;else if(d.type==="tool_use"||d.type==="tool_result")r+=h,d.type==="tool_use"&&l++;else if(d.type==="text")i+=h;else if(d.type==="agent_progress"){const y=d;y.agentId&&!p.has(y.agentId)&&(p.add(y.agentId),c++)}})}),{totalTokens:o,thinkingTokens:s,toolTokens:r,textTokens:i,toolCalls:l,agentCount:c}}function hl({messages:n,allExpanded:o=!1,sessionId:s,targetMessageIndex:r,targetContentIndex:i,targetContentId:l}){const[c,p]=a.useState(!1),[g,d]=a.useState(!1),[h,y]=a.useState(null),m=a.useRef(null),x=a.useRef(new Map),b=new Date(n[0].timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),f=a.useMemo(()=>gl(n),[n]),u=a.useMemo(()=>xl(n),[n]),v=a.useMemo(()=>ul(n),[n]);a.useEffect(()=>{(r!==void 0||l)&&(p(!0),l?n.forEach((k,_)=>{k.content.forEach((B,W)=>{B.type==="agent_progress"&&B.agentId===l&&(y({msgIdx:_,contentIdx:W}),setTimeout(()=>{const M=`${_}-${W}`,$=x.current.get(M);$&&($.expand(),setTimeout(()=>$.scrollIntoView(),50))},100))})}):r!==void 0&&i!==void 0&&(y({msgIdx:r,contentIdx:i}),setTimeout(()=>{const k=`${r}-${i}`,_=x.current.get(k);_&&(_.expand(),setTimeout(()=>_.scrollIntoView(),50))},100)))},[r,i,l,n]);const z=k=>{p(!0),y({msgIdx:k.messageIndex,contentIdx:k.contentIndex}),setTimeout(()=>{const _=`${k.messageIndex}-${k.contentIndex}`,B=x.current.get(_);B&&(B.expand(),setTimeout(()=>B.scrollIntoView(),50))},100)},I=g?!1:c||o,P=()=>{o&&!g?d(!0):o&&g?d(!1):p(!c)};return a.useEffect(()=>{d(!1)},[o]),e.jsxs("div",{style:Se.container,ref:m,children:[e.jsxs("div",{style:Se.header,onClick:P,children:[e.jsxs("div",{style:Se.headerLeft,children:[e.jsx("span",{style:Se.expandToggle,children:I?e.jsx(tt,{size:14}):e.jsx(Fe,{size:14})}),e.jsx("span",{style:Se.role,children:"Claude"}),e.jsx("div",{style:Se.indicators,children:u.map((k,_)=>e.jsxs("button",{type:"button",style:{...Se.indicator,backgroundColor:`${k.color}20`,color:k.color},onClick:B=>{B.stopPropagation(),z(k)},title:`Jump to ${k.label}`,children:[e.jsx("span",{style:Se.indicatorIcon,children:k.icon})," ",k.label]},`${k.type}-${_}`))})]}),e.jsxs("div",{style:Se.headerRight,children:[f.thinkingTokens>0&&e.jsxs("span",{style:Se.tokenPill,title:"Thinking tokens",children:[e.jsx(to,{size:10})," ",be(f.thinkingTokens)]}),f.toolCalls>0&&e.jsxs("span",{style:Se.tokenPill,title:"Tool calls",children:[e.jsx(Zt,{size:10})," ",f.toolCalls]}),f.agentCount>0&&e.jsxs("span",{style:Se.tokenPill,title:"Agents",children:[e.jsx(et,{size:10})," ",f.agentCount]}),e.jsxs("span",{style:Se.tokenBadge,title:`~${f.totalTokens} tokens`,children:[be(f.totalTokens)," tok"]}),e.jsx("span",{style:Se.timestamp,children:b})]})]}),!I&&v&&e.jsx("div",{style:Se.preview,onClick:()=>p(!0),children:v}),I&&e.jsx("div",{className:"jacques-expand-content",style:Se.content,children:n.map((k,_)=>e.jsx("div",{style:Se.messageBlock,children:k.content.map((B,W)=>{const O=`${_}-${W}`,M=(h==null?void 0:h.msgIdx)===_&&(h==null?void 0:h.contentIdx)===W;return e.jsx(Sl,{content:B,expanded:o||M,sessionId:s,contentRef:$=>{$?x.current.set(O,$):x.current.delete(O)}},O)})},k.id))})]})}const fl=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".rb",".go",".rs",".java",".kt",".swift",".c",".cpp",".h",".hpp",".cs",".php",".vue",".svelte",".astro",".css",".scss",".less",".sass",".html",".htm",".xml",".svg",".json",".yaml",".yml",".toml",".sh",".bash",".zsh",".fish",".sql",".graphql",".prisma"];function ml(n){const o=n.toLowerCase();return fl.some(s=>o.endsWith(s))}function yl(n){if(!n.includes("#"))return!1;const o=n.split(`
129
+ `).find(l=>l.trim().length>0)||"";if([/^import\s+/,/^export\s+/,/^const\s+/,/^let\s+/,/^var\s+/,/^function\s+/,/^class\s+/,/^interface\s+/,/^type\s+/,/^def\s+/,/^from\s+.*\s+import/,/^package\s+/,/^use\s+/,/^#include/,/^#!\//].some(l=>l.test(o.trim())))return!1;const r=/^#+\s+.+/m.test(n),i=/^[-*]\s+.+/m.test(n)||n.split(`
130
+
131
+ `).length>1;return r&&i}function bl(n){const o=n.match(/^#\s+(.+)$/m);if(o)return o[1].trim();const s=n.split(`
132
+ `)[0].trim();return s.length<=50?s:s.substring(0,47)+"..."}function jl(n){if(n.name!=="Write")return{isPlan:!1};const o=n.input,s=(o==null?void 0:o.file_path)||"",r=(o==null?void 0:o.content)||"";if(ml(s))return{isPlan:!1};if((s.toLowerCase().includes("plan")||s.endsWith(".plan.md")||s.includes(".jacques/plans/")||s.includes(".claude/plans/"))&&yl(r)){const l=bl(r);return{isPlan:!0,filePath:s,content:r,title:l.startsWith("Plan:")?l:`Plan: ${l}`}}return{isPlan:!1}}function Sl({content:n,expanded:o=!1,sessionId:s,contentRef:r}){switch(n.type){case"text":return e.jsx(vl,{text:n.text,expanded:o});case"thinking":{const i=Ke(n.text);return e.jsx(Ft,{ref:r,title:"Thinking",icon:e.jsx(to,{size:14}),summary:`${be(i)} tok`,defaultExpanded:o,children:e.jsx("div",{style:Se.thinkingContent,children:n.text})})}case"tool_use":{const i=jl(n);if(i.isPlan&&i.content){const p=Ke(i.content);return e.jsx(Ft,{ref:r,title:i.title||"Plan",icon:e.jsx(Re,{size:14}),summary:`${be(p)} tok`,defaultExpanded:o,headerStyle:{backgroundColor:"rgba(52, 211, 153, 0.1)",borderLeft:"3px solid #34D399"},children:e.jsx("div",{style:Se.planContent,children:e.jsx(pt,{content:i.content})})})}const l=JSON.stringify(n.input,null,2),c=Ke(n.name)+Ke(l);return e.jsx(Ft,{ref:r,title:`Tool: ${n.name}`,icon:e.jsx(Zt,{size:14}),summary:`${wl(n.name,n.input)} · ${be(c)} tok`,defaultExpanded:o,children:e.jsx("div",{style:Se.toolContent,children:e.jsx("pre",{style:Se.toolInput,children:l})})})}case"tool_result":{const i=Ke(n.content);return e.jsx(Ft,{ref:r,title:"Tool Result",icon:n.is_error?e.jsx(Zs,{size:14}):e.jsx(Dt,{size:14}),summary:n.is_error?"Error":`${be(i)} tok`,defaultExpanded:o,children:e.jsx("div",{style:{...Se.toolResult,...n.is_error?Se.toolResultError:{}},children:n.content})})}case"code":return e.jsx(gs,{code:n.code,language:n.language});case"agent_progress":return e.jsx(ll,{ref:r,content:n,expanded:o,sessionId:s});case"bash_progress":return e.jsx(cl,{ref:r,content:n,expanded:o});case"mcp_progress":return e.jsx(dl,{content:n});case"web_search":return e.jsx(pl,{content:n});default:return null}}function vl({text:n,expanded:o=!1}){const[s,r]=a.useState(o),i=n.split(/(```[\s\S]*?```)/g),l=n.split(`
133
+ `).length,p=(n.length>500||l>20)&&!o,g=s||o,d=p&&!g?n.slice(0,400).split(/(```[\s\S]*?```)/g):i;return e.jsxs("div",{style:Se.textBlock,children:[d.map((h,y)=>{if(h.startsWith("```")){const m=h.match(/```(\w+)?\n?([\s\S]*?)```/);if(m)return e.jsx(gs,{language:m[1],code:m[2].trim()},y)}return e.jsx("span",{children:h},y)}),p&&!g&&e.jsxs("button",{style:Se.expandTextButton,onClick:()=>r(!0),type:"button",children:["... Show more (",l," lines)"]})]})}function wl(n,o){if(n==="Read"&&typeof o.file_path=="string"||n==="Write"&&typeof o.file_path=="string"||n==="Edit"&&typeof o.file_path=="string")return o.file_path.split("/").pop()||"";if(n==="Bash"&&typeof o.command=="string"){const s=o.command;return s.length>40?s.slice(0,40)+"...":s}return""}const Se={container:{backgroundColor:t.bgSecondary,borderRadius:"8px",border:`1px solid ${t.borderSubtle}`,overflow:"hidden",marginBottom:"16px",width:"100%"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",minHeight:"44px",backgroundColor:t.bgElevated,borderBottom:`1px solid ${t.borderSubtle}`,cursor:"pointer",transition:"background-color 150ms ease"},headerLeft:{display:"flex",alignItems:"center",gap:"12px"},expandToggle:{display:"inline-flex",alignItems:"center",color:t.textMuted},role:{fontWeight:600,color:t.accent},indicators:{display:"flex",gap:"6px",flexWrap:"wrap"},indicator:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:500,border:"none",cursor:"pointer",transition:"all 150ms ease"},indicatorIcon:{display:"inline-flex",alignItems:"center"},headerRight:{display:"flex",alignItems:"center",gap:"8px"},tokenPill:{display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"10px",color:t.textMuted,backgroundColor:t.bgSecondary,padding:"2px 6px",borderRadius:"3px",fontFamily:"monospace"},tokenBadge:{fontSize:"11px",color:t.textSecondary,backgroundColor:t.bgSecondary,padding:"2px 8px",borderRadius:"4px",fontFamily:"monospace",fontWeight:500},timestamp:{fontSize:"12px",color:t.textMuted},preview:{padding:"12px 16px",color:t.textSecondary,fontSize:"14px",cursor:"pointer",borderTop:`1px solid ${t.borderSubtle}`},content:{padding:"16px"},messageBlock:{marginBottom:"8px"},textBlock:{color:t.textPrimary,whiteSpace:"pre-wrap",lineHeight:1.6,marginBottom:"12px"},thinkingContent:{color:t.textSecondary,fontStyle:"italic",whiteSpace:"pre-wrap",lineHeight:1.5,fontSize:"13px"},toolContent:{fontSize:"13px"},toolInput:{margin:0,padding:"8px",backgroundColor:t.bgPrimary,borderRadius:"4px",fontSize:"12px",overflow:"auto",color:t.textSecondary},planContent:{padding:0,fontSize:"14px",lineHeight:1.6},toolResult:{whiteSpace:"pre-wrap",fontSize:"12px",color:t.textSecondary,maxHeight:"300px",overflow:"auto"},toolResultError:{color:t.danger},expandTextButton:{display:"inline-block",padding:"4px 8px",marginTop:"8px",backgroundColor:t.bgElevated,border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",color:t.accent,fontSize:"12px",cursor:"pointer"}};function kl({messages:n,currentIndex:o,onNavigate:s}){const[r,i]=a.useState(null),[l,c]=a.useState(!1),p=n.map((h,y)=>({msg:h,index:y})).filter(({msg:h})=>h.role==="user");if(p.length===0)return null;const d=(()=>{for(let h=p.length-1;h>=0;h--)if(p[h].index<=o)return h;return 0})();return e.jsxs("div",{style:Ze.container,children:[e.jsxs("div",{style:{...Ze.header,cursor:"pointer"},onClick:()=>c(!l),children:[e.jsx("span",{style:Ze.headerIcon,children:e.jsx(Do,{size:14})}),e.jsxs("span",{style:{flex:1},children:["Questions (",p.length,")"]}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",color:t.textMuted},children:l?e.jsx(Fe,{size:12}):e.jsx(tt,{size:12})})]}),!l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:Ze.list,children:p.map((h,y)=>{const m=y===d,x=y===r,b=Cl(h.msg);return e.jsxs("button",{style:{...Ze.item,...m?Ze.itemActive:{},...x&&!m?Ze.itemHovered:{}},onClick:()=>s(h.index),onMouseEnter:()=>i(y),onMouseLeave:()=>i(null),title:b,type:"button",children:[e.jsx("span",{style:{...Ze.marker,backgroundColor:m?t.accent:"transparent",border:m?"none":`1px solid ${t.borderSubtle}`}}),e.jsx("span",{style:Ze.preview,children:b})]},h.index)})}),e.jsxs("div",{style:Ze.hint,children:[e.jsx("span",{style:Ze.key,children:"["})," / ",e.jsx("span",{style:Ze.key,children:"]"})," Jump"]})]})]})}function Cl(n){const o=n.content.find(s=>s.type==="text");if(o&&o.type==="text"){const r=o.text.trim().split(`
134
+ `)[0];return r.length>50?r.slice(0,47)+"...":r}return"User message"}const Ze={container:{display:"flex",flexDirection:"column",flexShrink:0},header:{display:"flex",alignItems:"center",gap:"6px",padding:"12px 16px",fontSize:"12px",fontWeight:600,color:t.textSecondary,borderBottom:`1px solid ${t.borderSubtle}`},headerIcon:{display:"inline-flex",alignItems:"center",color:t.accent},list:{flex:1,overflow:"auto",padding:"8px"},item:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 12px",minHeight:"36px",border:"none",backgroundColor:"transparent",borderRadius:"4px",cursor:"pointer",textAlign:"left",color:t.textMuted,fontSize:"12px",transition:"all 150ms ease"},itemActive:{backgroundColor:t.bgElevated,color:t.accent},itemHovered:{backgroundColor:t.bgElevated},marker:{width:"6px",height:"6px",borderRadius:"50%",flexShrink:0},preview:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},hint:{padding:"12px 16px",fontSize:"11px",color:t.textMuted,borderTop:`1px solid ${t.borderSubtle}`,textAlign:"center"},key:{color:t.accent,fontWeight:600}};function Il(n){switch(n==null?void 0:n.toLowerCase()){case"explore":return{icon:e.jsx(yt,{size:12}),color:"#60A5FA",label:"Explore"};case"plan":return{icon:e.jsx(Re,{size:12}),color:"#34D399",label:"Plan"};case"general-purpose":return{icon:e.jsx(et,{size:12}),color:"#A78BFA",label:"General"};case"bash":return{icon:e.jsx(ft,{size:12}),color:"#F472B6",label:"Bash"};default:return{icon:e.jsx(et,{size:12}),color:"#9CA3AF",label:n||"Agent"}}}function Tl({messages:n,currentIndex:o,onNavigate:s}){const[r,i]=a.useState(null),[l,c]=a.useState(!1),p=[];if(n.forEach((x,b)=>{x.role==="assistant"&&x.content.forEach((f,u)=>{if(f.type==="agent_progress"){const v=f;v.agentId&&p.push({agentId:v.agentId,agentType:v.agentType,prompt:v.prompt,messageIndex:b,contentIndex:u})}})}),p.length===0)return null;const g=new Map;for(const x of p){const b=x.agentType||"unknown",f=g.get(b)||[];f.push(x),g.set(b,f)}const d=["explore","plan","general-purpose","bash"],h=Array.from(g.keys()).sort((x,b)=>{const f=d.indexOf(x.toLowerCase()),u=d.indexOf(b.toLowerCase());return f===-1&&u===-1?x.localeCompare(b):f===-1?1:u===-1?-1:f-u}),m=(()=>{var x;for(let b=p.length-1;b>=0;b--)if(p[b].messageIndex<=o)return p[b].agentId;return(x=p[0])==null?void 0:x.agentId})();return e.jsxs("div",{style:Qe.container,children:[e.jsxs("div",{style:{...Qe.header,cursor:"pointer"},onClick:()=>c(!l),children:[e.jsx("span",{style:Qe.headerIcon,children:e.jsx(et,{size:14})}),e.jsxs("span",{style:{flex:1},children:["Subagents (",p.length,")"]}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",color:t.textMuted},children:l?e.jsx(Fe,{size:12}):e.jsx(tt,{size:12})})]}),!l&&e.jsx("div",{style:Qe.list,children:h.map(x=>{const b=g.get(x)||[],f=Il(x);return e.jsxs("div",{style:Qe.typeGroup,children:[e.jsxs("div",{style:Qe.typeHeader,children:[e.jsx("span",{style:{color:f.color,display:"inline-flex",alignItems:"center"},children:f.icon}),e.jsx("span",{style:{color:f.color,fontWeight:500},children:f.label}),e.jsxs("span",{style:Qe.typeCount,children:["(",b.length,")"]})]}),b.map(u=>{const v=u.agentId===m,z=u.agentId===r,I=zl(u.prompt);return e.jsxs("button",{style:{...Qe.item,...v?Qe.itemActive:{},...z&&!v?Qe.itemHovered:{}},onClick:()=>s(u.messageIndex,u.contentIndex,u.agentId),onMouseEnter:()=>i(u.agentId),onMouseLeave:()=>i(null),title:u.prompt,type:"button",children:[e.jsx("span",{style:{...Qe.marker,backgroundColor:v?t.accent:"transparent",border:v?"none":`1px solid ${t.borderSubtle}`}}),e.jsx("span",{style:Qe.preview,children:I})]},u.agentId)})]},x)})})]})}function zl(n){if(!n)return"Agent task";const o=n.split(`
135
+ `)[0].trim();return o.length>50?o.slice(0,47)+"...":o}const Qe={container:{display:"flex",flexDirection:"column",flexShrink:0,borderTop:`1px solid ${t.borderSubtle}`},header:{display:"flex",alignItems:"center",gap:"6px",padding:"12px 16px",fontSize:"12px",fontWeight:600,color:t.textSecondary,borderBottom:`1px solid ${t.borderSubtle}`},headerIcon:{display:"inline-flex",alignItems:"center",color:t.accent},list:{flex:1,overflow:"auto",padding:"8px"},typeGroup:{marginBottom:"12px"},typeHeader:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",fontSize:"11px",textTransform:"uppercase"},typeCount:{color:t.textMuted,marginLeft:"auto"},item:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 10px",minHeight:"36px",border:"none",backgroundColor:"transparent",borderRadius:"4px",cursor:"pointer",textAlign:"left",color:t.textMuted,fontSize:"11px",transition:"all 150ms ease",marginLeft:"8px"},itemActive:{backgroundColor:t.bgElevated,color:t.accent},itemHovered:{backgroundColor:t.bgElevated},marker:{width:"6px",height:"6px",borderRadius:"50%",flexShrink:0},preview:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Rl=[/^implement the following plan[:\s]*/i,/^here is the plan[:\s]*/i,/^follow this plan[:\s]*/i],El=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".rb",".go",".rs",".java",".kt",".swift",".c",".cpp",".h",".hpp",".cs",".php",".vue",".svelte",".astro",".css",".scss",".less",".sass",".html",".htm",".xml",".svg",".json",".yaml",".yml",".toml",".sh",".bash",".zsh",".fish",".sql",".graphql",".prisma"];function $l(n){const o=n.toLowerCase();return El.some(s=>o.endsWith(s))}function Bo(n){if(!n.includes("#"))return!1;const o=n.split(`
136
+ `).find(l=>l.trim().length>0)||"";if([/^import\s+/,/^export\s+/,/^const\s+/,/^let\s+/,/^var\s+/,/^function\s+/,/^class\s+/,/^interface\s+/,/^type\s+/,/^def\s+/,/^from\s+.*\s+import/,/^package\s+/,/^use\s+/,/^#include/,/^#!\//].some(l=>l.test(o.trim())))return!1;const r=/^#+\s+.+/m.test(n),i=/^[-*]\s+.+/m.test(n)||n.split(`
137
+
138
+ `).length>1;return r&&i}function Bl(n){return n==="embedded"?{icon:e.jsx(Re,{size:12}),color:"#34D399",label:"Embedded"}:n==="agent"?{icon:e.jsx(et,{size:12}),color:"#A78BFA",label:"Agent"}:{icon:e.jsx(Xn,{size:12}),color:"#60A5FA",label:"Written"}}function Mo(n){const o=n.match(/^#\s+(.+)$/m);if(o)return o[1].trim().replace(/^Plan:\s*/i,"");const s=n.split(`
139
+ `)[0].trim();return s.length<=50?s:s.substring(0,47)+"..."}function Ml(n){const o=[];if(n.forEach((l,c)=>{if(l.role==="user"){for(const p of l.content)if(p.type==="text"){const g=p.text.trim();for(const d of Rl){const h=g.match(d);if(h){const y=g.substring(h[0].length).trim();if(y.length>=100&&Bo(y)){const m=Mo(y),x=y.split(`
140
+ `).slice(0,2).join(" ").substring(0,60);o.push({title:m,source:"embedded",messageIndex:c,preview:x+(x.length>=60?"...":"")})}break}}}}if(l.role==="assistant"){const p=new Set;l.content.forEach((g,d)=>{var h;if(g.type==="tool_use"){const y=g;if(y.name==="Write"){const m=y.input,x=(m==null?void 0:m.file_path)||"",b=(m==null?void 0:m.content)||"";if($l(x))return;if((x.toLowerCase().includes("plan")||x.endsWith(".plan.md")||x.includes(".jacques/plans/"))&&Bo(b)){const u=Mo(b),v=b.split(`
141
+ `).slice(0,2).join(" ").substring(0,60);o.push({title:u,source:"write",messageIndex:c,contentIndex:d,filePath:x,preview:v+(v.length>=60?"...":"")})}}}if(g.type==="agent_progress"){const y=g;if(y.agentType==="Plan"&&y.agentId&&!p.has(y.agentId)){p.add(y.agentId);const m=y.agentDescription||"Agent-Generated Plan";o.push({title:m,source:"agent",messageIndex:c,contentIndex:d,agentId:y.agentId,preview:((h=y.prompt)==null?void 0:h.substring(0,60))||m})}}})}}),o.length===0)return[];const s=l=>l.toLowerCase().replace(/^plan:\s*/i,"").replace(/[^a-z0-9]+/g," ").trim(),r=[],i=new Map;for(const l of o){const c=s(l.title),p=i.get(c);if(p!==void 0){const g=r[p];g.mergedSources||(g.mergedSources=[g.source]),g.mergedSources.includes(l.source)||g.mergedSources.push(l.source),!g.filePath&&l.filePath&&(g.filePath=l.filePath),!g.agentId&&l.agentId&&(g.agentId=l.agentId)}else i.set(c,r.length),r.push({...l,mergedSources:[l.source]})}return r}function Ll(n){return n.map(o=>({title:o.title,source:o.source,mergedSources:o.sources||[o.source],messageIndex:o.messageIndex,filePath:o.filePath,agentId:o.agentId,catalogId:o.catalogId,preview:o.title}))}function Pl({messages:n,currentIndex:o,onNavigate:s,onViewPlan:r,planRefs:i}){const[l,c]=a.useState(null),[p,g]=a.useState(!1),d=i&&i.length>0?Ll(i):Ml(n);if(d.length===0)return null;const y=(()=>{for(let m=d.length-1;m>=0;m--)if(d[m].messageIndex<=o)return d[m];return d[0]})();return e.jsxs("div",{style:Ve.container,children:[e.jsxs("div",{style:{...Ve.header,cursor:"pointer"},onClick:()=>g(!p),children:[e.jsx("span",{style:Ve.headerIcon,children:e.jsx(Re,{size:14})}),e.jsxs("span",{style:{flex:1},children:["Plans (",d.length,")"]}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",color:t.textMuted},children:p?e.jsx(Fe,{size:12}):e.jsx(tt,{size:12})})]}),!p&&e.jsx("div",{style:Ve.list,children:d.map((m,x)=>{const b=m===y,f=`plan-${m.messageIndex}-${x}`,u=l===f,v=m.mergedSources||[m.source];return e.jsxs("div",{style:Ve.planItem,children:[e.jsxs("button",{style:{...Ve.navButton,...b?Ve.navButtonActive:{},...u&&!b?Ve.navButtonHovered:{}},onClick:()=>s(m.messageIndex,m.contentIndex),onMouseEnter:()=>c(f),onMouseLeave:()=>c(null),title:m.preview,type:"button",children:[e.jsx("span",{style:{...Ve.marker,backgroundColor:b?t.accent:"transparent",border:b?"none":`1px solid ${t.borderSubtle}`}}),e.jsx("span",{style:Ve.planTitle,children:m.title}),e.jsx("span",{style:Ve.sourceBadges,children:v.map(z=>{const I=Bl(z);return e.jsx("span",{style:{...Ve.sourceBadge,color:I.color,borderColor:I.color},title:I.label,children:I.icon},z)})})]}),r&&e.jsx("button",{style:Ve.viewButton,onClick:()=>r({title:m.title,source:m.source,sources:v,messageIndex:m.messageIndex,filePath:m.filePath,agentId:m.agentId,catalogId:m.catalogId}),title:"View full plan",type:"button",children:"View"})]},f)})})]})}const Ve={container:{display:"flex",flexDirection:"column",flexShrink:0,borderTop:`1px solid ${t.borderSubtle}`},header:{display:"flex",alignItems:"center",gap:"6px",padding:"12px 16px",fontSize:"12px",fontWeight:600,color:t.textSecondary,borderBottom:`1px solid ${t.borderSubtle}`},headerIcon:{display:"inline-flex",alignItems:"center",color:t.accent},list:{flex:1,overflow:"auto",padding:"8px"},planItem:{display:"flex",alignItems:"center",gap:"4px",marginLeft:"8px"},navButton:{display:"flex",alignItems:"center",gap:"8px",flex:1,padding:"8px 10px",minHeight:"36px",border:"none",backgroundColor:"transparent",borderRadius:"4px",cursor:"pointer",textAlign:"left",color:t.textMuted,fontSize:"11px",transition:"all 150ms ease"},navButtonActive:{backgroundColor:t.bgElevated,color:t.accent},navButtonHovered:{backgroundColor:t.bgElevated},marker:{width:"6px",height:"6px",borderRadius:"50%",flexShrink:0},planTitle:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sourceBadges:{display:"inline-flex",alignItems:"center",gap:"3px",marginLeft:"auto",flexShrink:0},sourceBadge:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",borderRadius:"3px",border:"1px solid",opacity:.7},viewButton:{padding:"4px 8px",fontSize:"10px",fontWeight:500,color:t.textMuted,backgroundColor:"transparent",border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",cursor:"pointer",transition:"all 150ms ease",flexShrink:0}};function Al(n){return n.replace(/\//g,"-")}function _l({plan:n,sessionId:o,projectPath:s,onClose:r}){const[i,l]=a.useState(null),[c,p]=a.useState(!0),[g,d]=a.useState(null),[h,y]=a.useState([]),[m,x]=a.useState(null),[b,f]=a.useState(!1);a.useEffect(()=>{const k=async()=>{p(!0),d(null);try{if(n.catalogId&&s){const O=encodeURIComponent(Al(s)),M=await fetch(`${me}/projects/${O}/plans/${encodeURIComponent(n.catalogId)}/content`);if(M.ok){const $=await M.json();l($.content);return}}const B=await fetch(`${me}/sessions/${o}/plans/${n.messageIndex}`);if(!B.ok){d(B.status===404?"Plan content not found":`Failed to load plan: ${B.statusText}`);return}const W=await B.json();l(W.content)}catch(B){d(B instanceof Error?B.message:"Failed to load plan")}finally{p(!1)}},_=async()=>{try{const B=await fetch(`${me}/sessions/${o}/tasks`);if(B.ok){const W=await B.json();y(W.tasks||[]),x(W.summary||null)}}catch{}};k(),_()},[o,n.messageIndex,n.source,n.agentId,n.catalogId,s]),a.useEffect(()=>{const k=_=>{_.key==="Escape"&&r()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[r]);const u={embedded:"Embedded",write:"Written",agent:"Agent"},v={embedded:e.jsx(Re,{size:24}),write:e.jsx(Xn,{size:24}),agent:e.jsx(et,{size:24})},z=n.sources||[n.source],I=z.length>1?z.map(k=>u[k]||k).join(" + ")+" Plan":(u[n.source]||"")+" Plan",P=v[n.source]||e.jsx(Re,{size:24});return e.jsx("div",{style:fe.overlay,onClick:r,children:e.jsxs("div",{style:fe.modal,onClick:k=>k.stopPropagation(),children:[e.jsxs("div",{style:fe.header,children:[e.jsxs("div",{style:fe.titleSection,children:[e.jsx("span",{style:fe.sourceIcon,children:P}),e.jsxs("div",{children:[e.jsx("h2",{style:fe.title,children:n.title}),e.jsxs("span",{style:fe.subtitle,children:[I,n.filePath&&e.jsxs("span",{style:fe.filePath,children:[" • ",n.filePath]})]})]})]}),e.jsx("button",{style:fe.closeButton,onClick:r,type:"button",children:e.jsx(st,{size:20})})]}),m&&m.total>0&&e.jsxs("div",{style:fe.progressSection,children:[e.jsxs("div",{style:fe.progressHeader,children:[e.jsx(vt,{size:14,color:m.percentage===100?t.success:t.accent}),e.jsx("span",{style:fe.progressLabel,children:"Tasks"}),e.jsxs("span",{style:{...fe.progressPercentage,color:m.percentage===100?t.success:t.accent},children:[m.completed,"/",m.total," (",m.percentage,"%)"]})]}),e.jsx("div",{style:fe.progressTrack,children:e.jsx("div",{style:{...fe.progressFill,width:`${m.percentage}%`,backgroundColor:m.percentage===100?t.success:t.accent}})}),h.length>0&&e.jsxs("div",{style:fe.stepsContainer,children:[e.jsxs("button",{style:fe.stepsToggle,onClick:()=>f(!b),type:"button",children:[b?e.jsx(tt,{size:14}):e.jsx(Fe,{size:14}),e.jsxs("span",{children:["Show tasks (",h.length,")"]})]}),b&&e.jsx("div",{style:fe.stepsList,children:h.map(k=>e.jsxs("div",{style:fe.stepItem,children:[e.jsx("span",{style:fe.stepCheckbox,children:k.status==="completed"?e.jsx(vt,{size:14,color:t.success}):k.status==="in_progress"?e.jsx(Zn,{size:14,color:t.warning}):e.jsx(Qn,{size:14,color:t.textMuted})}),e.jsx("span",{style:{...fe.stepText,textDecoration:k.status==="completed"?"line-through":"none",color:k.status==="completed"?t.textMuted:t.textSecondary},children:k.subject})]},k.id))})]})]}),e.jsxs("div",{style:fe.content,children:[c&&e.jsxs("div",{style:fe.loading,children:[e.jsx(Oe,{size:16,style:{animation:"spin 1s linear infinite"}}),"Loading plan content..."]}),g&&e.jsx("div",{style:fe.error,children:g}),!c&&!g&&i&&e.jsx("div",{style:fe.planContent,children:e.jsx(pt,{content:i})})]}),e.jsxs("div",{style:fe.footer,children:[e.jsx("span",{style:fe.hint,children:"Press Escape to close"}),e.jsx("button",{style:fe.closeButtonSecondary,onClick:r,type:"button",children:"Close"})]})]})})}const fe={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},modal:{backgroundColor:t.bgSecondary,borderRadius:"12px",border:`1px solid ${t.borderSubtle}`,width:"80%",maxWidth:"900px",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.4)"},header:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"16px 20px",borderBottom:`1px solid ${t.borderSubtle}`},titleSection:{display:"flex",alignItems:"flex-start",gap:"12px"},sourceIcon:{display:"inline-flex",alignItems:"center",color:t.textMuted,marginTop:"2px"},title:{fontSize:"18px",fontWeight:600,color:t.textPrimary,margin:0,lineHeight:1.3},subtitle:{fontSize:"12px",color:t.textMuted,marginTop:"4px"},filePath:{fontFamily:"monospace",fontSize:"11px"},closeButton:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"4px",color:t.textMuted,backgroundColor:"transparent",border:"none",cursor:"pointer",borderRadius:"4px",transition:"color 150ms ease"},progressSection:{padding:"12px 20px",borderBottom:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgPrimary},progressHeader:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},progressLabel:{fontSize:"12px",fontWeight:500,color:t.textSecondary},progressPercentage:{fontSize:"12px",fontWeight:600,fontFamily:"monospace",marginLeft:"auto"},progressTrack:{width:"100%",height:"6px",backgroundColor:t.bgInput,borderRadius:"3px",overflow:"hidden"},progressFill:{height:"100%",borderRadius:"3px",transition:"width 300ms ease"},stepsContainer:{marginTop:"12px"},stepsToggle:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 8px",fontSize:"12px",fontWeight:500,color:t.textSecondary,backgroundColor:"transparent",border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",cursor:"pointer",transition:"all 150ms ease"},stepsList:{marginTop:"8px",maxHeight:"200px",overflowY:"auto",border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",backgroundColor:t.bgSecondary},stepItem:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderBottom:`1px solid ${t.borderSubtle}`,fontSize:"12px"},stepCheckbox:{display:"inline-flex",flexShrink:0},stepText:{flex:1,lineHeight:1.4},content:{flex:1,overflow:"auto",padding:"20px",minHeight:"200px"},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",padding:"48px",color:t.textMuted,fontSize:"14px"},error:{padding:"16px",backgroundColor:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"8px",color:"#EF4444",fontSize:"13px"},planContent:{padding:"16px",backgroundColor:t.bgPrimary,borderRadius:"8px",overflow:"auto"},footer:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",borderTop:`1px solid ${t.borderSubtle}`},hint:{fontSize:"12px",color:t.textMuted},closeButtonSecondary:{padding:"8px 16px",fontSize:"13px",fontWeight:500,color:t.textPrimary,backgroundColor:t.bgElevated,border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",cursor:"pointer"}};function Fl({type:n,timestamp:o}){const s=Dl[n],r=o?new Date(o).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"";return e.jsxs("div",{style:Lt.container,children:[e.jsx("div",{style:{...Lt.line,borderColor:s.color}}),e.jsxs("div",{style:{...Lt.label,color:s.color,backgroundColor:s.bgColor},children:[e.jsx("span",{style:Lt.iconWrap,children:s.icon})," ",s.label,r&&e.jsxs("span",{style:Lt.time,children:[" • ",r]})]}),e.jsx("div",{style:{...Lt.line,borderColor:s.color}})]})}const Dl={auto_compact:{icon:e.jsx(yn,{size:14}),label:"Context Auto-Compacted",color:"#f5a623",bgColor:"rgba(245, 166, 35, 0.1)"},clear:{icon:e.jsx(Nt,{size:14}),label:"Context Cleared",color:"#60A5FA",bgColor:"rgba(96, 165, 250, 0.1)"}},Lt={container:{display:"flex",alignItems:"center",gap:"12px",margin:"24px 0"},line:{flex:1,height:0,borderTop:"2px dashed",opacity:.5},label:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap"},iconWrap:{display:"inline-flex",alignItems:"center"},time:{opacity:.7}};function Wl(n){if(n.role!=="user")return!1;for(const o of n.content)if(o.type==="text"&&o.text.includes("<command-name>/clear</command-name>"))return!0;return!1}function Nl(n,o){const s=[];let r=null,i=!1;const l=o?new Date(o).getTime():null;return n.forEach((c,p)=>{if(l&&!i&&c.timestamp>l&&(r&&(s.push(r),r=null),s.push({type:"marker",messages:[],startIndex:p,markerType:"auto_compact",markerTimestamp:o}),i=!0),c.role==="user"){if(Wl(c)){r&&(s.push(r),r=null),s.push({type:"marker",messages:[],startIndex:p,markerType:"clear",markerTimestamp:new Date(c.timestamp).toISOString()});return}r&&(s.push(r),r=null),s.push({type:"user",messages:[c],startIndex:p})}else r&&r.type==="assistant"?r.messages.push(c):(r&&s.push(r),r={type:"assistant",messages:[c],startIndex:p})}),r&&s.push(r),l&&!i&&s.push({type:"marker",messages:[],startIndex:n.length,markerType:"auto_compact",markerTimestamp:o}),s}const Hl={agentProgress:!0,bashProgress:!0,mcpProgress:!0,webSearch:!0,toolCalls:!0,thinking:!0},Ol=[/^implement the following plan[:\s]*/i,/^here is the plan[:\s]*/i,/^follow this plan[:\s]*/i];function ql(n){for(const o of Ol)if(o.test(n)){const s=n.replace(o,"").trim(),r=s.match(/^#\s+(.+)$/m);if(r)return r[1].trim();const i=s.split(`
142
+ `)[0].trim();if(i)return i.length>60?i.slice(0,57)+"...":i}return null}function Ul({conversation:n,onBack:o}){const{viewDashboard:s}=Jt(),r=o||s,[i,l]=a.useState(Hl),[c,p]=a.useState(!1),[g,d]=a.useState(!1),[h,y]=a.useState(0),[m,x]=a.useState(!1),[b,f]=a.useState(null),[u,v]=a.useState(null),z=a.useRef(null),I=a.useRef(new Map),P=a.useMemo(()=>Gl(n.messages,i),[n.messages,i]),k=a.useMemo(()=>Nl(P,n.metadata.autoCompactAt),[P,n.metadata.autoCompactAt]),_=a.useCallback(C=>{l(T=>({...T,[C]:!T[C]}))},[]),B=a.useMemo(()=>{let C=0,T=0,S=0,F=0,J=!1;if(n.metadata.actualTokens)J=!0,C=n.metadata.actualTokens.input||0,T=n.metadata.actualTokens.output||0,S=n.metadata.actualTokens.cacheCreation||0,F=n.metadata.actualTokens.cacheRead||0;else for(const U of P)U.tokens&&(U.tokens.input||U.tokens.output)&&(J=!0,C+=U.tokens.input||0,T+=U.tokens.output||0,S+=U.tokens.cacheCreation||0,F+=U.tokens.cacheRead||0);const K=P.reduce((U,Z)=>U+Z.content.reduce((q,X)=>q+xs(X),0),0),re=C+S+F;return{hasActualTokens:J,actualInputTokens:C,actualOutputTokens:T,actualCacheCreation:S,actualCacheRead:F,totalContextTokens:re,estimatedTokens:K}},[P,n.metadata.actualTokens]),W=B.hasActualTokens?B.actualInputTokens+B.actualOutputTokens:B.estimatedTokens;a.useEffect(()=>{const C=T=>{const S=P.map((F,J)=>({msg:F,idx:J})).filter(({msg:F})=>F.role==="user");if(T.key==="["){const F=S.findIndex(({idx:J})=>J>=h);F>0&&O(S[F-1].idx)}else if(T.key==="]"){const F=S.findIndex(({idx:J})=>J>h);F!==-1&&O(S[F].idx)}else T.key==="e"?d(!0):T.key==="c"&&!T.metaKey&&!T.ctrlKey?d(!1):(T.key==="End"||T.key==="G"&&T.shiftKey)&&M()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[P,h]);const O=a.useCallback((C,T,S)=>{const F=I.current.get(C);F&&(F.scrollIntoView({behavior:"smooth",block:"start"}),y(C),(T!==void 0||S!==void 0)&&(v({messageIndex:C,contentIndex:T,contentId:S}),setTimeout(()=>v(null),500)))},[]),M=a.useCallback(()=>{z.current&&z.current.scrollTo({top:z.current.scrollHeight,behavior:"smooth"})},[]),$=()=>{if(!z.current)return;const{scrollTop:C,scrollHeight:T,clientHeight:S}=z.current,F=T-C-S;x(F>200);let J=0,K=1/0;I.current.forEach((re,U)=>{const Z=Math.abs(re.offsetTop-C);Z<K&&(K=Z,J=U)}),y(J)};return e.jsxs("div",{style:ee.container,children:[e.jsxs("div",{style:ee.header,children:[e.jsxs("div",{style:ee.headerTop,children:[e.jsxs("div",{style:ee.headerChrome,children:[e.jsxs("button",{style:ee.backButton,onClick:r,type:"button",children:[e.jsx(Qs,{size:14}),e.jsx("span",{children:"back"})]}),e.jsxs("div",{style:ee.chromeDots,children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",backgroundColor:t.dotRed,opacity:.7}}),e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",backgroundColor:t.dotYellow,opacity:.7}}),e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",backgroundColor:t.dotGreen,opacity:.7}})]}),e.jsxs("span",{style:ee.chromeTitle,children:["conversation/",n.project,"/",n.date,".jsonl"]}),n.metadata.hadAutoCompact&&e.jsx($e,{label:"Auto-compacted",variant:"compacted"})]}),e.jsx("div",{style:ee.titleSection,children:(()=>{const C=ql(n.title);return C?e.jsxs("h2",{style:ee.title,children:[e.jsx(Re,{size:18,style:{display:"inline",verticalAlign:"middle",marginRight:"8px",color:"#34D399"}}),"Plan: ",C]}):e.jsx("h2",{style:ee.title,children:n.title})})()})]}),e.jsxs("div",{style:ee.controls,children:[e.jsxs("div",{style:ee.filterDropdownContainer,children:[e.jsx("button",{style:{...ee.iconButton,...c?{backgroundColor:t.bgElevated}:{}},onClick:()=>p(!c),type:"button",title:"Filter content types",children:e.jsx(er,{size:14})}),c&&e.jsxs("div",{style:ee.filterDropdown,children:[e.jsxs("label",{style:ee.filterCheckboxLabel,children:[e.jsx("input",{type:"checkbox",checked:i.agentProgress,onChange:()=>_("agentProgress"),style:ee.filterCheckbox}),e.jsx(et,{size:14,style:ee.filterIconLucide})," Agents"]}),e.jsxs("label",{style:ee.filterCheckboxLabel,children:[e.jsx("input",{type:"checkbox",checked:i.bashProgress,onChange:()=>_("bashProgress"),style:ee.filterCheckbox}),e.jsx(ft,{size:14,style:ee.filterIconLucide})," Bash"]}),e.jsxs("label",{style:ee.filterCheckboxLabel,children:[e.jsx("input",{type:"checkbox",checked:i.mcpProgress,onChange:()=>_("mcpProgress"),style:ee.filterCheckbox}),e.jsx(bn,{size:14,style:ee.filterIconLucide})," MCP"]}),e.jsxs("label",{style:ee.filterCheckboxLabel,children:[e.jsx("input",{type:"checkbox",checked:i.webSearch,onChange:()=>_("webSearch"),style:ee.filterCheckbox}),e.jsx(yt,{size:14,style:ee.filterIconLucide})," Search"]}),e.jsxs("label",{style:ee.filterCheckboxLabel,children:[e.jsx("input",{type:"checkbox",checked:i.toolCalls,onChange:()=>_("toolCalls"),style:ee.filterCheckbox}),e.jsx(Zt,{size:14,style:ee.filterIconLucide})," Tools"]}),e.jsxs("label",{style:ee.filterCheckboxLabel,children:[e.jsx("input",{type:"checkbox",checked:i.thinking,onChange:()=>_("thinking"),style:ee.filterCheckbox}),e.jsx(to,{size:14,style:ee.filterIconLucide})," Thinking"]})]})]}),e.jsx("button",{style:ee.iconButton,onClick:()=>d(!g),type:"button",title:g?"Collapse all":"Expand all",children:g?e.jsx(tr,{size:14}):e.jsx(nr,{size:14})})]})]}),e.jsxs("div",{style:ee.contentArea,children:[e.jsx("div",{ref:z,style:ee.messages,onScroll:$,children:k.map((C,T)=>{var J;if(C.type==="marker"&&C.markerType)return e.jsx(Fl,{type:C.markerType,timestamp:C.markerTimestamp},`marker-${T}`);const S=u&&u.messageIndex>=C.startIndex&&u.messageIndex<C.startIndex+C.messages.length,F=S?u.messageIndex-C.startIndex:void 0;return e.jsx("div",{ref:K=>{if(K)for(let re=0;re<C.messages.length;re++)I.current.set(C.startIndex+re,K)},style:C.type==="user"?ee.userMessageWrapper:ee.assistantMessageWrapper,children:C.type==="user"?e.jsx(nl,{message:C.messages[0]}):e.jsx(hl,{messages:C.messages,allExpanded:g,sessionId:n.sessionId,targetMessageIndex:F,targetContentIndex:S?u.contentIndex:void 0,targetContentId:S?u.contentId:void 0})},`group-${T}-${((J=C.messages[0])==null?void 0:J.id)||T}`)})}),m&&e.jsx("button",{style:ee.scrollButton,onClick:M,title:"Scroll to end (End or Shift+G)",type:"button",children:"↓ End"}),e.jsxs("div",{style:ee.navigatorsPanel,children:[e.jsx(kl,{messages:P,currentIndex:h,onNavigate:O}),e.jsx(Pl,{messages:P,currentIndex:h,onNavigate:O,onViewPlan:C=>f(C),planRefs:n.metadata.planRefs}),e.jsx(Tl,{messages:P,currentIndex:h,onNavigate:O})]})]}),b&&n.sessionId&&e.jsx(_l,{plan:b,sessionId:n.sessionId,projectPath:n.projectPath,onClose:()=>f(null)}),e.jsxs("div",{style:ee.footer,children:[e.jsx($e,{label:`${P.length} messages`,variant:"default"}),B.hasActualTokens?e.jsxs(e.Fragment,{children:[e.jsx($e,{label:`${be(B.totalContextTokens)} context`,variant:"default"}),e.jsx($e,{label:`${be(B.actualOutputTokens)} out`,variant:"default"}),(B.actualCacheCreation>0||B.actualCacheRead>0)&&e.jsxs("span",{style:ee.cacheStat,title:`Non-cached: ${be(B.actualInputTokens)}, Cache created: ${be(B.actualCacheCreation)}, Cache read: ${be(B.actualCacheRead)}`,children:["(",be(B.actualCacheRead)," cached)"]}),n.metadata.subagents&&n.metadata.subagents.totalTokens>0&&e.jsx($e,{label:`+ ${be(n.metadata.subagents.totalTokens)} subagents`,variant:"agent"})]}):e.jsx($e,{label:`~${be(W)} tokens`,variant:"default"}),n.metadata.technologies&&n.metadata.technologies.length>0&&e.jsx(e.Fragment,{children:n.metadata.technologies.map(C=>e.jsx($e,{label:C,variant:"default"},C))})]})]})}function Jl(n,o){switch(n.type){case"agent_progress":return o.agentProgress;case"bash_progress":return o.bashProgress;case"mcp_progress":return o.mcpProgress;case"web_search":return o.webSearch;case"tool_use":case"tool_result":return o.toolCalls;case"thinking":return o.thinking;default:return!0}}function Gl(n,o){return n.map(s=>{if(s.role==="user")return s;const r=s.content.filter(i=>Jl(i,o));return{...s,content:r}}).filter(s=>s.content.length>0)}const ee={container:{display:"flex",flexDirection:"column",height:"100%",maxHeight:"100vh"},header:{display:"flex",flexDirection:"column",gap:"12px",padding:"12px 16px",borderBottom:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgSecondary,overflow:"visible",position:"relative",zIndex:10},headerTop:{display:"flex",flexDirection:"column",gap:"8px"},headerChrome:{display:"flex",alignItems:"center",gap:"10px"},chromeDots:{display:"flex",gap:"6px",flexShrink:0},chromeTitle:{fontSize:"11px",color:t.textMuted,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},backButton:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",backgroundColor:"transparent",color:t.textSecondary,cursor:"pointer",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace",flexShrink:0},titleSection:{flex:1},title:{fontSize:"18px",fontWeight:600,color:t.textPrimary,margin:0},controls:{display:"flex",alignItems:"center",gap:"12px"},iconButton:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${t.borderSubtle}`,borderRadius:"4px",backgroundColor:"transparent",color:t.textSecondary,cursor:"pointer",padding:0},filterDropdownContainer:{position:"relative"},filterDropdown:{position:"absolute",top:"100%",left:0,marginTop:"4px",backgroundColor:t.bgElevated,border:`1px solid ${t.borderSubtle}`,borderRadius:"8px",padding:"8px",zIndex:100,minWidth:"140px",boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},filterCheckboxLabel:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",borderRadius:"4px",cursor:"pointer",fontSize:"12px",color:t.textSecondary,transition:"background-color 150ms ease"},filterCheckbox:{width:"14px",height:"14px",cursor:"pointer",accentColor:t.accent},filterIconLucide:{opacity:.7,flexShrink:0},contentArea:{display:"flex",flex:1,overflow:"hidden"},messages:{flex:1,padding:"16px",overflow:"auto",position:"relative"},navigatorsPanel:{display:"flex",flexDirection:"column",width:"260px",flexShrink:0,backgroundColor:t.bgSecondary,borderLeft:`1px solid ${t.borderSubtle}`,overflow:"auto"},scrollButton:{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)",padding:"8px 16px",backgroundColor:t.accent,color:t.textPrimary,border:"none",borderRadius:"20px",cursor:"pointer",fontSize:"13px",fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.3)",zIndex:10,transition:"all 150ms ease"},footer:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",borderTop:`1px solid ${t.borderSubtle}`,backgroundColor:t.bgSecondary,fontSize:"12px",color:t.textMuted},cacheStat:{fontFamily:"monospace",fontWeight:400,color:t.textMuted,fontSize:"11px",marginLeft:"4px",cursor:"help"},userMessageWrapper:{display:"flex",marginBottom:"8px"},assistantMessageWrapper:{display:"flex",marginBottom:"8px"}};function Vl(n){const o=[];let s=null;const r=new Set;for(const i of n)if(i.type==="user_message"){const l=i.content.text||"";if(l.startsWith("<local-command-caveat>")||l.startsWith("<command-name>")||l.startsWith("<local-command-stdout>")||l.startsWith("<command-message>")||l.startsWith("<command-args>")||l.trim().length===0)continue;s&&(o.push(s),s=null),o.push({id:i.uuid,role:"user",timestamp:new Date(i.timestamp).getTime(),content:i.content.text?[{type:"text",text:i.content.text}]:[]})}else if(i.type==="assistant_message"){s&&o.push(s);const l=[];i.content.thinking&&l.push({type:"thinking",text:i.content.thinking}),i.content.text&&l.push({type:"text",text:i.content.text}),s={id:i.uuid,role:"assistant",timestamp:new Date(i.timestamp).getTime(),content:l,tokens:i.content.usage?{input:i.content.usage.inputTokens,output:i.content.usage.outputTokens,cacheCreation:i.content.usage.cacheCreation,cacheRead:i.content.usage.cacheRead}:void 0,model:i.content.model,durationMs:i.content.durationMs,costUSD:i.content.costUSD}}else if(i.type==="tool_call")s?i.content.usage&&(s.tokens||(s.tokens={input:0,output:0}),s.tokens.input=(s.tokens.input||0)+(i.content.usage.inputTokens||0),s.tokens.output=(s.tokens.output||0)+(i.content.usage.outputTokens||0),s.tokens.cacheCreation=(s.tokens.cacheCreation||0)+(i.content.usage.cacheCreation||0),s.tokens.cacheRead=(s.tokens.cacheRead||0)+(i.content.usage.cacheRead||0),i.content.costUSD&&(s.costUSD=(s.costUSD||0)+i.content.costUSD),i.content.durationMs&&(s.durationMs=(s.durationMs||0)+i.content.durationMs)):s={id:`assistant-${i.uuid}`,role:"assistant",timestamp:new Date(i.timestamp).getTime(),content:[],tokens:i.content.usage?{input:i.content.usage.inputTokens,output:i.content.usage.outputTokens,cacheCreation:i.content.usage.cacheCreation,cacheRead:i.content.usage.cacheRead}:void 0,model:i.content.model,durationMs:i.content.durationMs,costUSD:i.content.costUSD},s.content.push({type:"tool_use",id:i.uuid,name:i.content.toolName||"Unknown",input:i.content.toolInput||{}});else if(i.type==="tool_result")s&&s.content.push({type:"tool_result",tool_use_id:i.uuid,content:i.content.toolResultContent||"",is_error:!1});else if(i.type==="agent_progress"){const l=i.content.agentId;if(!l||r.has(l))continue;r.add(l),s||(s={id:`assistant-${i.uuid}`,role:"assistant",timestamp:new Date(i.timestamp).getTime(),content:[]}),s.content.push({type:"agent_progress",prompt:i.content.agentPrompt,agentId:l,agentType:i.content.agentType,agentDescription:i.content.agentDescription})}else i.type==="bash_progress"?(s||(s={id:`assistant-${i.uuid}`,role:"assistant",timestamp:new Date(i.timestamp).getTime(),content:[]}),s.content.push({type:"bash_progress",output:i.content.bashOutput,fullOutput:i.content.bashFullOutput,elapsedSeconds:i.content.bashElapsedSeconds,totalLines:i.content.bashTotalLines})):i.type==="mcp_progress"?(s||(s={id:`assistant-${i.uuid}`,role:"assistant",timestamp:new Date(i.timestamp).getTime(),content:[]}),s.content.push({type:"mcp_progress",status:i.content.mcpStatus,serverName:i.content.mcpServerName,toolName:i.content.mcpToolName})):i.type==="web_search"&&(s||(s={id:`assistant-${i.uuid}`,role:"assistant",timestamp:new Date(i.timestamp).getTime(),content:[]}),s.content.push({type:"web_search",searchType:i.content.searchType,query:i.content.searchQuery,resultCount:i.content.searchResultCount,urls:i.content.searchUrls}));return s&&o.push(s),o}function Kl(n){const o=Vl(n.entries);return{id:n.metadata.id,sessionId:n.metadata.id,title:n.metadata.title,project:n.metadata.projectSlug,projectPath:n.metadata.projectPath,date:n.metadata.endedAt.split("T")[0],messages:o,metadata:{messageCount:n.metadata.messageCount,toolCallCount:n.metadata.toolCallCount,estimatedTokens:0,actualTokens:{input:n.statistics.totalInputTokens,output:n.statistics.totalOutputTokens,cacheCreation:n.statistics.totalCacheCreation>0?n.statistics.totalCacheCreation:void 0,cacheRead:n.statistics.totalCacheRead>0?n.statistics.totalCacheRead:void 0},subagents:n.subagents&&n.subagents.length>0?{count:n.subagents.length,totalTokens:0,ids:n.subagents.map(s=>s.id)}:void 0,hadAutoCompact:n.metadata.hadAutoCompact,planRefs:n.metadata.planRefs}}}function Yl({sessionId:n,onBack:o}){const{viewDashboard:s}=Jt(),r=o||s,[i,l]=a.useState(null),[c,p]=a.useState(!0),[g,d]=a.useState(null),[h,y]=a.useState(!1),m=a.useCallback(async()=>{p(!0),d(null),y(!1);try{const x=await Zo(n);if(x.awaitingFirstResponse||x.entries.length===0)y(!0),l(null);else{const b=Kl(x);l(b)}}catch(x){d(x instanceof Error?x.message:"Failed to load session")}finally{p(!1)}},[n]);return a.useEffect(()=>{m()},[m]),c?e.jsxs("div",{style:Ne.loadingContainer,children:[e.jsx("div",{style:Ne.spinner,children:"◐"}),e.jsx("span",{children:"Loading session..."})]}):g?e.jsxs("div",{style:Ne.errorContainer,children:[e.jsx("button",{style:Ne.backButton,onClick:r,type:"button",children:"← Back"}),e.jsxs("div",{style:Ne.errorContent,children:[e.jsx("span",{style:Ne.errorIcon,children:"⚠️"}),e.jsx("p",{style:Ne.errorText,children:g}),e.jsx("button",{style:Ne.retryButton,onClick:m,type:"button",children:"Retry"})]})]}):h?e.jsxs("div",{style:Ne.awaitingContainer,children:[e.jsx("button",{style:Ne.backButton,onClick:r,type:"button",children:"← Back"}),e.jsxs("div",{style:Ne.awaitingContent,children:[e.jsx("span",{style:Ne.awaitingIcon,children:"⏳"}),e.jsx("p",{style:Ne.awaitingText,children:"Waiting for first response..."}),e.jsx("p",{style:Ne.awaitingHint,children:"This session just started. Content will appear after Claude responds."}),e.jsx("button",{style:Ne.retryButton,onClick:m,type:"button",children:"Refresh"})]})]}):i?e.jsx(Ul,{conversation:i,onBack:r}):null}const Ne={loadingContainer:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",gap:"16px",color:t.textMuted,fontSize:"14px"},spinner:{fontSize:"32px",animation:"spin 1s linear infinite"},errorContainer:{display:"flex",flexDirection:"column",height:"100%",padding:"16px"},backButton:{padding:"8px 12px",border:`1px solid ${t.borderSubtle}`,borderRadius:"6px",backgroundColor:"transparent",color:t.textSecondary,cursor:"pointer",fontSize:"13px",alignSelf:"flex-start",marginBottom:"24px"},errorContent:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,gap:"16px"},errorIcon:{fontSize:"48px"},errorText:{color:t.danger,fontSize:"14px",margin:0},retryButton:{padding:"8px 16px",backgroundColor:t.accent,color:t.textPrimary,border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"13px",fontWeight:500},awaitingContainer:{display:"flex",flexDirection:"column",height:"100%",padding:"16px"},awaitingContent:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,gap:"16px"},awaitingIcon:{fontSize:"48px"},awaitingText:{color:t.textSecondary,fontSize:"16px",fontWeight:500,margin:0},awaitingHint:{color:t.textMuted,fontSize:"13px",margin:0,textAlign:"center",maxWidth:"300px"}};function Xl(){const{projectSlug:n,sessionId:o}=Lo(),s=mt(),{openSession:r}=Jt();if(a.useEffect(()=>{o&&r({id:o,type:"active",title:"Loading..."})},[o,r]),!o||!n)return null;const i=()=>{s(`/${n}/sessions`)};return e.jsx(Yl,{sessionId:o,onBack:i})}function Zl(){return e.jsx(ji,{children:e.jsx(Si,{children:e.jsx(_r,{children:e.jsx(ei,{children:e.jsx(ai,{children:e.jsx(Ko,{level:"app",children:e.jsx(zs,{children:e.jsxs(_e,{path:"/",element:e.jsx($i,{}),children:[e.jsx(_e,{index:!0,element:e.jsx(vo,{})}),e.jsxs(_e,{path:":projectSlug",children:[e.jsx(_e,{path:"sessions",element:e.jsx(aa,{})}),e.jsx(_e,{path:"sessions/:sessionId",element:e.jsx(Xl,{})}),e.jsx(_e,{path:"artifacts",element:e.jsx(ma,{})}),e.jsx(_e,{path:"context",element:e.jsx(Ba,{})}),e.jsx(_e,{index:!0,element:e.jsx(Rs,{to:"sessions",replace:!0})})]}),e.jsx(_e,{path:"archive",element:e.jsx(ca,{})}),e.jsx(_e,{path:"settings",element:e.jsx(_a,{})}),e.jsx(_e,{path:"sources",element:e.jsx(Fa,{})}),e.jsx(_e,{path:"sources/google",element:e.jsx(Eo,{})}),e.jsx(_e,{path:"sources/notion",element:e.jsx($o,{})}),e.jsx(_e,{path:"oauth/google/callback",element:e.jsx(Eo,{})}),e.jsx(_e,{path:"oauth/notion/callback",element:e.jsx($o,{})}),e.jsx(_e,{path:"*",element:e.jsx(vo,{})})]})})})})})})})})}Jn.createRoot(document.getElementById("root")).render(e.jsx(mn.StrictMode,{children:e.jsx(Es,{children:e.jsx(Zl,{})})}));