gsd-pi 2.78.1 → 2.79.0

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 (1692) hide show
  1. package/README.md +28 -21
  2. package/dist/bundled-resource-path.d.ts +7 -0
  3. package/dist/bundled-resource-path.js +34 -2
  4. package/dist/claude-cli-check.js +18 -6
  5. package/dist/cli-auto-routing.d.ts +1 -0
  6. package/dist/cli-auto-routing.js +5 -0
  7. package/dist/cli-policy.d.ts +13 -0
  8. package/dist/cli-policy.js +17 -0
  9. package/dist/cli.js +100 -69
  10. package/dist/headless-query.d.ts +22 -0
  11. package/dist/headless-query.js +43 -8
  12. package/dist/headless-recover.d.ts +23 -0
  13. package/dist/headless-recover.js +93 -0
  14. package/dist/headless.d.ts +10 -0
  15. package/dist/headless.js +25 -1
  16. package/dist/help-text.js +1 -0
  17. package/dist/loader.js +24 -16
  18. package/dist/onboarding.d.ts +10 -0
  19. package/dist/onboarding.js +2 -2
  20. package/dist/provider-migrations.d.ts +2 -2
  21. package/dist/provider-migrations.js +5 -2
  22. package/dist/resource-loader.d.ts +5 -2
  23. package/dist/resource-loader.js +62 -31
  24. package/dist/resources/.managed-resources-content-hash +1 -0
  25. package/dist/resources/GSD-WORKFLOW.md +29 -42
  26. package/dist/resources/extensions/async-jobs/job-manager.js +4 -0
  27. package/dist/resources/extensions/bg-shell/bg-shell-lifecycle.js +3 -2
  28. package/dist/resources/extensions/bg-shell/utilities.js +2 -1
  29. package/dist/resources/extensions/browser-tools/tools/intent.js +8 -1
  30. package/dist/resources/extensions/claude-code-cli/readiness.js +19 -7
  31. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +22 -8
  32. package/dist/resources/extensions/github-sync/cli.js +3 -0
  33. package/dist/resources/extensions/github-sync/sync.js +86 -58
  34. package/dist/resources/extensions/google-search/index.js +2 -6
  35. package/dist/resources/extensions/gsd/auto/detect-stuck.js +41 -5
  36. package/dist/resources/extensions/gsd/auto/loop.js +258 -36
  37. package/dist/resources/extensions/gsd/auto/phases.js +96 -38
  38. package/dist/resources/extensions/gsd/auto/run-unit.js +26 -12
  39. package/dist/resources/extensions/gsd/auto/session.js +44 -6
  40. package/dist/resources/extensions/gsd/auto-artifact-paths.js +49 -31
  41. package/dist/resources/extensions/gsd/auto-dashboard.js +14 -2
  42. package/dist/resources/extensions/gsd/auto-direct-dispatch.js +57 -21
  43. package/dist/resources/extensions/gsd/auto-dispatch.js +301 -97
  44. package/dist/resources/extensions/gsd/auto-post-unit.js +127 -57
  45. package/dist/resources/extensions/gsd/auto-prompts.js +145 -8
  46. package/dist/resources/extensions/gsd/auto-recovery.js +112 -19
  47. package/dist/resources/extensions/gsd/auto-runtime-state.js +31 -0
  48. package/dist/resources/extensions/gsd/auto-start.js +55 -65
  49. package/dist/resources/extensions/gsd/auto-timeout-recovery.js +18 -0
  50. package/dist/resources/extensions/gsd/auto-timers.js +24 -4
  51. package/dist/resources/extensions/gsd/auto-tool-tracking.js +2 -2
  52. package/dist/resources/extensions/gsd/auto-worktree.js +368 -376
  53. package/dist/resources/extensions/gsd/auto.js +226 -78
  54. package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +21 -3
  55. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +54 -9
  56. package/dist/resources/extensions/gsd/bootstrap/dynamic-tools.js +9 -77
  57. package/dist/resources/extensions/gsd/bootstrap/exec-tools.js +7 -5
  58. package/dist/resources/extensions/gsd/bootstrap/query-tools.js +2 -2
  59. package/dist/resources/extensions/gsd/bootstrap/register-extension.js +5 -4
  60. package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +204 -46
  61. package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +11 -6
  62. package/dist/resources/extensions/gsd/bootstrap/subagent-input.js +22 -0
  63. package/dist/resources/extensions/gsd/bootstrap/system-context.js +48 -12
  64. package/dist/resources/extensions/gsd/bootstrap/write-gate.js +263 -66
  65. package/dist/resources/extensions/gsd/branch-patterns.js +3 -3
  66. package/dist/resources/extensions/gsd/commands/catalog.js +81 -9
  67. package/dist/resources/extensions/gsd/commands/context.js +41 -5
  68. package/dist/resources/extensions/gsd/commands/dispatcher.js +11 -5
  69. package/dist/resources/extensions/gsd/commands/handlers/auto.js +2 -1
  70. package/dist/resources/extensions/gsd/commands/handlers/core.js +25 -1
  71. package/dist/resources/extensions/gsd/commands/handlers/ops.js +13 -0
  72. package/dist/resources/extensions/gsd/commands/handlers/workflow.js +24 -2
  73. package/dist/resources/extensions/gsd/commands-bootstrap.js +6 -0
  74. package/dist/resources/extensions/gsd/commands-codebase.js +2 -1
  75. package/dist/resources/extensions/gsd/commands-config.js +3 -2
  76. package/dist/resources/extensions/gsd/commands-debug.js +22 -1
  77. package/dist/resources/extensions/gsd/commands-eval-review.js +534 -0
  78. package/dist/resources/extensions/gsd/commands-extensions.js +50 -7
  79. package/dist/resources/extensions/gsd/commands-handlers.js +8 -7
  80. package/dist/resources/extensions/gsd/commands-logs.js +2 -1
  81. package/dist/resources/extensions/gsd/commands-mcp-status.js +3 -1
  82. package/dist/resources/extensions/gsd/commands-prefs-wizard.js +10 -1
  83. package/dist/resources/extensions/gsd/commands-scan.js +2 -1
  84. package/dist/resources/extensions/gsd/commands-ship.js +67 -1
  85. package/dist/resources/extensions/gsd/commands-workflow-templates.js +5 -4
  86. package/dist/resources/extensions/gsd/commands-worktree.js +309 -0
  87. package/dist/resources/extensions/gsd/context-budget.js +11 -3
  88. package/dist/resources/extensions/gsd/crash-recovery.js +160 -47
  89. package/dist/resources/extensions/gsd/dashboard-overlay.js +1 -1
  90. package/dist/resources/extensions/gsd/db/auto-workers.js +227 -0
  91. package/dist/resources/extensions/gsd/db/command-queue.js +105 -0
  92. package/dist/resources/extensions/gsd/db/milestone-leases.js +210 -0
  93. package/dist/resources/extensions/gsd/db/runtime-kv.js +91 -0
  94. package/dist/resources/extensions/gsd/db/unit-dispatches.js +322 -0
  95. package/dist/resources/extensions/gsd/db-writer.js +150 -92
  96. package/dist/resources/extensions/gsd/deep-project-setup-policy.js +212 -0
  97. package/dist/resources/extensions/gsd/delegation-policy.js +155 -0
  98. package/dist/resources/extensions/gsd/detection.js +7 -7
  99. package/dist/resources/extensions/gsd/dispatch-guard.js +6 -10
  100. package/dist/resources/extensions/gsd/docs/COORDINATION.md +42 -0
  101. package/dist/resources/extensions/gsd/docs/preferences-reference.md +16 -4
  102. package/dist/resources/extensions/gsd/doctor-engine-checks.js +2 -2
  103. package/dist/resources/extensions/gsd/doctor-proactive.js +4 -0
  104. package/dist/resources/extensions/gsd/doctor-providers.js +2 -1
  105. package/dist/resources/extensions/gsd/doctor-runtime-checks.js +115 -7
  106. package/dist/resources/extensions/gsd/doctor.js +12 -2
  107. package/dist/resources/extensions/gsd/error-classifier.js +1 -1
  108. package/dist/resources/extensions/gsd/eval-review-schema.js +208 -0
  109. package/dist/resources/extensions/gsd/forensics.js +17 -9
  110. package/dist/resources/extensions/gsd/git-service.js +86 -9
  111. package/dist/resources/extensions/gsd/gsd-db.js +442 -14
  112. package/dist/resources/extensions/gsd/gsd-home.js +29 -0
  113. package/dist/resources/extensions/gsd/guided-flow-queue.js +1 -1
  114. package/dist/resources/extensions/gsd/guided-flow.js +416 -142
  115. package/dist/resources/extensions/gsd/init-wizard.js +16 -23
  116. package/dist/resources/extensions/gsd/interrupted-session.js +45 -7
  117. package/dist/resources/extensions/gsd/key-manager.js +2 -1
  118. package/dist/resources/extensions/gsd/markdown-renderer.js +59 -66
  119. package/dist/resources/extensions/gsd/memory-store.js +66 -31
  120. package/dist/resources/extensions/gsd/metrics.js +287 -1
  121. package/dist/resources/extensions/gsd/migrate/command.js +3 -2
  122. package/dist/resources/extensions/gsd/milestone-id-reservation.js +36 -0
  123. package/dist/resources/extensions/gsd/milestone-scope-classifier.js +10 -8
  124. package/dist/resources/extensions/gsd/model-router.js +114 -9
  125. package/dist/resources/extensions/gsd/native-git-bridge.js +26 -43
  126. package/dist/resources/extensions/gsd/onboarding-state.js +2 -2
  127. package/dist/resources/extensions/gsd/parallel-merge.js +14 -13
  128. package/dist/resources/extensions/gsd/parallel-monitor-overlay.js +5 -2
  129. package/dist/resources/extensions/gsd/paths.js +151 -9
  130. package/dist/resources/extensions/gsd/planning-depth.js +114 -0
  131. package/dist/resources/extensions/gsd/preferences-models.js +109 -16
  132. package/dist/resources/extensions/gsd/preferences-skills.js +2 -1
  133. package/dist/resources/extensions/gsd/preferences-types.js +6 -0
  134. package/dist/resources/extensions/gsd/preferences-validation.js +41 -0
  135. package/dist/resources/extensions/gsd/preferences.js +25 -7
  136. package/dist/resources/extensions/gsd/project-research-policy.js +182 -0
  137. package/dist/resources/extensions/gsd/prompt-loader.js +25 -15
  138. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +10 -0
  139. package/dist/resources/extensions/gsd/prompts/complete-slice.md +14 -4
  140. package/dist/resources/extensions/gsd/prompts/execute-task.md +3 -3
  141. package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +10 -1
  142. package/dist/resources/extensions/gsd/prompts/guided-discuss-project.md +148 -0
  143. package/dist/resources/extensions/gsd/prompts/guided-discuss-requirements.md +126 -0
  144. package/dist/resources/extensions/gsd/prompts/guided-discuss-slice.md +8 -1
  145. package/dist/resources/extensions/gsd/prompts/guided-research-decision.md +70 -0
  146. package/dist/resources/extensions/gsd/prompts/guided-research-project.md +120 -0
  147. package/dist/resources/extensions/gsd/prompts/guided-workflow-preferences.md +68 -0
  148. package/dist/resources/extensions/gsd/prompts/parallel-research-slices.md +2 -0
  149. package/dist/resources/extensions/gsd/prompts/plan-milestone.md +8 -2
  150. package/dist/resources/extensions/gsd/prompts/plan-slice.md +18 -6
  151. package/dist/resources/extensions/gsd/prompts/refine-slice.md +10 -0
  152. package/dist/resources/extensions/gsd/prompts/rewrite-docs.md +2 -0
  153. package/dist/resources/extensions/gsd/prompts/system.md +4 -4
  154. package/dist/resources/extensions/gsd/queue-order.js +6 -1
  155. package/dist/resources/extensions/gsd/repo-identity.js +20 -9
  156. package/dist/resources/extensions/gsd/rethink.js +2 -1
  157. package/dist/resources/extensions/gsd/safety/git-checkpoint.js +8 -1
  158. package/dist/resources/extensions/gsd/schemas/__fixtures__/valid-project.md +26 -0
  159. package/dist/resources/extensions/gsd/schemas/__fixtures__/valid-requirements.md +57 -0
  160. package/dist/resources/extensions/gsd/schemas/__fixtures__/valid-roadmap.md +19 -0
  161. package/dist/resources/extensions/gsd/schemas/parsers.js +276 -0
  162. package/dist/resources/extensions/gsd/schemas/validate.js +364 -0
  163. package/dist/resources/extensions/gsd/skill-telemetry.js +3 -2
  164. package/dist/resources/extensions/gsd/slice-cadence.js +56 -7
  165. package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +9 -3
  166. package/dist/resources/extensions/gsd/state.js +153 -377
  167. package/dist/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
  168. package/dist/resources/extensions/gsd/templates/project.md +10 -0
  169. package/dist/resources/extensions/gsd/token-counter.js +1 -0
  170. package/dist/resources/extensions/gsd/tools/complete-milestone.js +6 -5
  171. package/dist/resources/extensions/gsd/tools/complete-slice.js +7 -12
  172. package/dist/resources/extensions/gsd/tools/complete-task.js +19 -31
  173. package/dist/resources/extensions/gsd/tools/memory-tools.js +18 -1
  174. package/dist/resources/extensions/gsd/tools/plan-slice.js +6 -5
  175. package/dist/resources/extensions/gsd/tools/validate-milestone.js +7 -5
  176. package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +74 -11
  177. package/dist/resources/extensions/gsd/unit-context-manifest.js +125 -5
  178. package/dist/resources/extensions/gsd/unit-runtime.js +88 -24
  179. package/dist/resources/extensions/gsd/uok/plan-v2.js +14 -1
  180. package/dist/resources/extensions/gsd/user-input-boundary.js +157 -0
  181. package/dist/resources/extensions/gsd/visualizer-overlay.js +1 -1
  182. package/dist/resources/extensions/gsd/watch/header-renderer.js +4 -1
  183. package/dist/resources/extensions/gsd/workflow-install.js +2 -3
  184. package/dist/resources/extensions/gsd/workflow-manifest.js +2 -1
  185. package/dist/resources/extensions/gsd/workflow-mcp-auto-prep.js +3 -21
  186. package/dist/resources/extensions/gsd/workflow-mcp.js +41 -5
  187. package/dist/resources/extensions/gsd/workflow-migration.js +4 -3
  188. package/dist/resources/extensions/gsd/workflow-plugins.js +3 -5
  189. package/dist/resources/extensions/gsd/workflow-reconcile.js +3 -3
  190. package/dist/resources/extensions/gsd/workflow-templates.js +2 -3
  191. package/dist/resources/extensions/gsd/workspace.js +59 -0
  192. package/dist/resources/extensions/gsd/worktree-command.js +30 -49
  193. package/dist/resources/extensions/gsd/worktree-manager.js +26 -7
  194. package/dist/resources/extensions/gsd/worktree-resolver.js +111 -19
  195. package/dist/resources/extensions/gsd/worktree-root.js +163 -0
  196. package/dist/resources/extensions/gsd/worktree-session-state.js +33 -0
  197. package/dist/resources/extensions/gsd/worktree.js +4 -115
  198. package/dist/resources/extensions/gsd/write-intercept.js +3 -3
  199. package/dist/resources/extensions/mcp-client/index.js +6 -9
  200. package/dist/resources/extensions/ollama/index.js +15 -2
  201. package/dist/resources/extensions/ollama/model-capabilities.js +31 -0
  202. package/dist/resources/extensions/ollama/ollama-client.js +40 -4
  203. package/dist/resources/extensions/remote-questions/remote-command.js +2 -1
  204. package/dist/resources/extensions/remote-questions/status.js +2 -5
  205. package/dist/resources/extensions/remote-questions/store.js +2 -5
  206. package/dist/resources/extensions/search-the-web/provider.js +9 -8
  207. package/dist/resources/extensions/shared/next-action-ui.js +7 -0
  208. package/dist/resources/extensions/slash-commands/create-extension.js +36 -22
  209. package/dist/resources/extensions/subagent/index.js +341 -190
  210. package/dist/resources/extensions/subagent/isolation.js +2 -2
  211. package/dist/resources/extensions/ttsr/rule-loader.js +2 -3
  212. package/dist/resources/extensions/voice/index.js +3 -2
  213. package/dist/resources/extensions/voice/linux-ready.js +2 -2
  214. package/dist/resources/skills/create-gsd-extension/SKILL.md +9 -5
  215. package/dist/resources/skills/create-gsd-extension/references/custom-commands.md +1 -1
  216. package/dist/resources/skills/create-gsd-extension/references/custom-rendering.md +5 -5
  217. package/dist/resources/skills/create-gsd-extension/references/custom-tools.md +4 -4
  218. package/dist/resources/skills/create-gsd-extension/references/custom-ui.md +6 -6
  219. package/dist/resources/skills/create-gsd-extension/references/events-reference.md +3 -3
  220. package/dist/resources/skills/create-gsd-extension/references/packaging-distribution.md +1 -1
  221. package/dist/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +3 -3
  222. package/dist/resources/skills/create-gsd-extension/workflows/create-extension.md +32 -12
  223. package/dist/resources/skills/lint/SKILL.md +4 -0
  224. package/dist/resources/skills/review/SKILL.md +4 -0
  225. package/dist/resources/skills/test/SKILL.md +3 -0
  226. package/dist/resources/skills/verify-before-complete/SKILL.md +1 -1
  227. package/dist/rtk-shared.d.ts +3 -0
  228. package/dist/rtk-shared.js +17 -0
  229. package/dist/rtk.d.ts +2 -5
  230. package/dist/rtk.js +3 -20
  231. package/dist/runtime-checks.d.ts +27 -0
  232. package/dist/runtime-checks.js +38 -0
  233. package/dist/tool-bootstrap.js +7 -0
  234. package/dist/tsconfig.extensions.tsbuildinfo +1 -1
  235. package/dist/web/standalone/.next/BUILD_ID +1 -1
  236. package/dist/web/standalone/.next/app-path-routes-manifest.json +16 -16
  237. package/dist/web/standalone/.next/build-manifest.json +4 -4
  238. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  239. package/dist/web/standalone/.next/react-loadable-manifest.json +47 -7
  240. package/dist/web/standalone/.next/required-server-files.json +1 -1
  241. package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
  242. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  243. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  244. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  245. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  246. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  247. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  248. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  249. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  250. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  251. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  252. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  253. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  254. package/dist/web/standalone/.next/server/app/_not-found.rsc +2 -2
  255. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  256. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  257. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  258. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  259. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  260. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  261. package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
  262. package/dist/web/standalone/.next/server/app/api/boot/route.js.nft.json +1 -1
  263. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
  264. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js.nft.json +1 -1
  265. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
  266. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js.nft.json +1 -1
  267. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
  268. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js.nft.json +1 -1
  269. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  270. package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
  271. package/dist/web/standalone/.next/server/app/api/captures/route.js.nft.json +1 -1
  272. package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
  273. package/dist/web/standalone/.next/server/app/api/cleanup/route.js.nft.json +1 -1
  274. package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
  275. package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
  276. package/dist/web/standalone/.next/server/app/api/doctor/route.js.nft.json +1 -1
  277. package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
  278. package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
  279. package/dist/web/standalone/.next/server/app/api/export-data/route.js.nft.json +1 -1
  280. package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
  281. package/dist/web/standalone/.next/server/app/api/files/route.js.nft.json +1 -1
  282. package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
  283. package/dist/web/standalone/.next/server/app/api/forensics/route.js.nft.json +1 -1
  284. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  285. package/dist/web/standalone/.next/server/app/api/git/route.js.nft.json +1 -1
  286. package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
  287. package/dist/web/standalone/.next/server/app/api/history/route.js.nft.json +1 -1
  288. package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
  289. package/dist/web/standalone/.next/server/app/api/hooks/route.js.nft.json +1 -1
  290. package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
  291. package/dist/web/standalone/.next/server/app/api/inspect/route.js.nft.json +1 -1
  292. package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
  293. package/dist/web/standalone/.next/server/app/api/knowledge/route.js.nft.json +1 -1
  294. package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
  295. package/dist/web/standalone/.next/server/app/api/live-state/route.js.nft.json +1 -1
  296. package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
  297. package/dist/web/standalone/.next/server/app/api/notifications/route.js.nft.json +1 -1
  298. package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
  299. package/dist/web/standalone/.next/server/app/api/onboarding/route.js.nft.json +1 -1
  300. package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
  301. package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
  302. package/dist/web/standalone/.next/server/app/api/projects/route.js.nft.json +1 -1
  303. package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
  304. package/dist/web/standalone/.next/server/app/api/recovery/route.js.nft.json +1 -1
  305. package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
  306. package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
  307. package/dist/web/standalone/.next/server/app/api/session/browser/route.js.nft.json +1 -1
  308. package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
  309. package/dist/web/standalone/.next/server/app/api/session/command/route.js.nft.json +1 -1
  310. package/dist/web/standalone/.next/server/app/api/session/events/route.js +4 -2
  311. package/dist/web/standalone/.next/server/app/api/session/events/route.js.nft.json +1 -1
  312. package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
  313. package/dist/web/standalone/.next/server/app/api/session/manage/route.js.nft.json +1 -1
  314. package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
  315. package/dist/web/standalone/.next/server/app/api/settings-data/route.js.nft.json +1 -1
  316. package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
  317. package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
  318. package/dist/web/standalone/.next/server/app/api/skill-health/route.js.nft.json +1 -1
  319. package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
  320. package/dist/web/standalone/.next/server/app/api/steer/route.js.nft.json +1 -1
  321. package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
  322. package/dist/web/standalone/.next/server/app/api/switch-root/route.js.nft.json +1 -1
  323. package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +2 -2
  324. package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
  325. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +2 -2
  326. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js.nft.json +1 -1
  327. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +4 -4
  328. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js.nft.json +1 -1
  329. package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
  330. package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
  331. package/dist/web/standalone/.next/server/app/api/undo/route.js.nft.json +1 -1
  332. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  333. package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
  334. package/dist/web/standalone/.next/server/app/api/visualizer/route.js.nft.json +1 -1
  335. package/dist/web/standalone/.next/server/app/index.html +1 -1
  336. package/dist/web/standalone/.next/server/app/index.rsc +3 -3
  337. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  338. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  339. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  340. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
  341. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  342. package/dist/web/standalone/.next/server/app/page.js +2 -2
  343. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  344. package/dist/web/standalone/.next/server/app-paths-manifest.json +16 -16
  345. package/dist/web/standalone/.next/server/chunks/2331.js +16 -16
  346. package/dist/web/standalone/.next/server/chunks/4741.js +12 -12
  347. package/dist/web/standalone/.next/server/chunks/5822.js +2 -2
  348. package/dist/web/standalone/.next/server/chunks/63.js +8 -8
  349. package/dist/web/standalone/.next/server/chunks/6336.js +1 -0
  350. package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
  351. package/dist/web/standalone/.next/server/functions-config-manifest.json +9 -0
  352. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  353. package/dist/web/standalone/.next/server/middleware-manifest.json +2 -29
  354. package/dist/web/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  355. package/dist/web/standalone/.next/server/middleware.js +12 -4
  356. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  357. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  358. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  359. package/dist/web/standalone/.next/server/webpack-runtime.js +1 -1
  360. package/dist/web/standalone/.next/static/chunks/2059.d6f49d697b624f2b.js +20 -0
  361. package/dist/web/standalone/.next/static/chunks/2556.0527fea66e123b7f.js +1 -0
  362. package/dist/web/standalone/.next/static/chunks/2824.461404167557f2cd.js +1 -0
  363. package/dist/web/standalone/.next/static/chunks/3026.3af53b279375f082.js +1 -0
  364. package/dist/web/standalone/.next/static/chunks/315.6f68ae79b67d25cf.js +1 -0
  365. package/dist/web/standalone/.next/static/chunks/3497.4bfc60a3b3dea717.js +1 -0
  366. package/dist/web/standalone/.next/static/chunks/363642f4.c6481b47ee815ba0.js +1 -0
  367. package/dist/web/standalone/.next/static/chunks/{3794-42fdce068d44fa4f.js → 3794-3fb4e6ee851037bb.js} +1 -1
  368. package/dist/web/standalone/.next/static/chunks/{4447.5bad7871be61ca73.js → 4447.fe6f304888d5ac71.js} +2 -2
  369. package/dist/web/standalone/.next/static/chunks/5326.def6842b53fecd26.js +1 -0
  370. package/dist/web/standalone/.next/static/chunks/5516.4a07c872b5c3a663.js +1 -0
  371. package/dist/web/standalone/.next/static/chunks/8336.6f6f30e410419aff.js +10 -0
  372. package/dist/web/standalone/.next/static/chunks/8845.c9702695e8c5a9c5.js +2 -0
  373. package/dist/web/standalone/.next/static/chunks/9441.1081da1125d1764f.js +1 -0
  374. package/dist/web/standalone/.next/static/chunks/app/{page-151349214571e2b6.js → page-ff639266d978f2a0.js} +1 -1
  375. package/dist/web/standalone/.next/static/chunks/{framework-711ef29bc66f648c.js → framework-34a8c4228d7fd161.js} +1 -1
  376. package/dist/web/standalone/.next/static/chunks/{main-6919d9dd919bd15f.js → main-2b7d1294417bb6bc.js} +1 -1
  377. package/dist/web/standalone/.next/static/chunks/webpack-d82dbee6356c1733.js +1 -0
  378. package/dist/web/standalone/.next/static/css/{632cd626b1731d88.css → 54ec2745c1da488b.css} +1 -1
  379. package/dist/web/standalone/node_modules/@next/env/package.json +1 -1
  380. package/dist/web/standalone/node_modules/baseline-browser-mapping/dist/index.cjs +1 -1
  381. package/dist/web/standalone/node_modules/baseline-browser-mapping/package.json +3 -3
  382. package/dist/web/standalone/node_modules/caniuse-lite/data/agents.js +1 -1
  383. package/dist/web/standalone/node_modules/caniuse-lite/data/browserVersions.js +1 -1
  384. package/dist/web/standalone/node_modules/caniuse-lite/data/features/aac.js +1 -1
  385. package/dist/web/standalone/node_modules/caniuse-lite/data/features/abortcontroller.js +1 -1
  386. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ac3-ec3.js +1 -1
  387. package/dist/web/standalone/node_modules/caniuse-lite/data/features/accelerometer.js +1 -1
  388. package/dist/web/standalone/node_modules/caniuse-lite/data/features/addeventlistener.js +1 -1
  389. package/dist/web/standalone/node_modules/caniuse-lite/data/features/alternate-stylesheet.js +1 -1
  390. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ambient-light.js +1 -1
  391. package/dist/web/standalone/node_modules/caniuse-lite/data/features/apng.js +1 -1
  392. package/dist/web/standalone/node_modules/caniuse-lite/data/features/array-find-index.js +1 -1
  393. package/dist/web/standalone/node_modules/caniuse-lite/data/features/array-find.js +1 -1
  394. package/dist/web/standalone/node_modules/caniuse-lite/data/features/array-flat.js +1 -1
  395. package/dist/web/standalone/node_modules/caniuse-lite/data/features/array-includes.js +1 -1
  396. package/dist/web/standalone/node_modules/caniuse-lite/data/features/arrow-functions.js +1 -1
  397. package/dist/web/standalone/node_modules/caniuse-lite/data/features/asmjs.js +1 -1
  398. package/dist/web/standalone/node_modules/caniuse-lite/data/features/async-clipboard.js +1 -1
  399. package/dist/web/standalone/node_modules/caniuse-lite/data/features/async-functions.js +1 -1
  400. package/dist/web/standalone/node_modules/caniuse-lite/data/features/atob-btoa.js +1 -1
  401. package/dist/web/standalone/node_modules/caniuse-lite/data/features/audio-api.js +1 -1
  402. package/dist/web/standalone/node_modules/caniuse-lite/data/features/audio.js +1 -1
  403. package/dist/web/standalone/node_modules/caniuse-lite/data/features/audiotracks.js +1 -1
  404. package/dist/web/standalone/node_modules/caniuse-lite/data/features/autofocus.js +1 -1
  405. package/dist/web/standalone/node_modules/caniuse-lite/data/features/auxclick.js +1 -1
  406. package/dist/web/standalone/node_modules/caniuse-lite/data/features/av1.js +1 -1
  407. package/dist/web/standalone/node_modules/caniuse-lite/data/features/avif.js +1 -1
  408. package/dist/web/standalone/node_modules/caniuse-lite/data/features/background-attachment.js +1 -1
  409. package/dist/web/standalone/node_modules/caniuse-lite/data/features/background-clip-text.js +1 -1
  410. package/dist/web/standalone/node_modules/caniuse-lite/data/features/background-img-opts.js +1 -1
  411. package/dist/web/standalone/node_modules/caniuse-lite/data/features/background-position-x-y.js +1 -1
  412. package/dist/web/standalone/node_modules/caniuse-lite/data/features/background-repeat-round-space.js +1 -1
  413. package/dist/web/standalone/node_modules/caniuse-lite/data/features/background-sync.js +1 -1
  414. package/dist/web/standalone/node_modules/caniuse-lite/data/features/battery-status.js +1 -1
  415. package/dist/web/standalone/node_modules/caniuse-lite/data/features/beacon.js +1 -1
  416. package/dist/web/standalone/node_modules/caniuse-lite/data/features/beforeafterprint.js +1 -1
  417. package/dist/web/standalone/node_modules/caniuse-lite/data/features/bigint.js +1 -1
  418. package/dist/web/standalone/node_modules/caniuse-lite/data/features/blobbuilder.js +1 -1
  419. package/dist/web/standalone/node_modules/caniuse-lite/data/features/bloburls.js +1 -1
  420. package/dist/web/standalone/node_modules/caniuse-lite/data/features/border-image.js +1 -1
  421. package/dist/web/standalone/node_modules/caniuse-lite/data/features/border-radius.js +1 -1
  422. package/dist/web/standalone/node_modules/caniuse-lite/data/features/broadcastchannel.js +1 -1
  423. package/dist/web/standalone/node_modules/caniuse-lite/data/features/brotli.js +1 -1
  424. package/dist/web/standalone/node_modules/caniuse-lite/data/features/calc.js +1 -1
  425. package/dist/web/standalone/node_modules/caniuse-lite/data/features/canvas-blending.js +1 -1
  426. package/dist/web/standalone/node_modules/caniuse-lite/data/features/canvas-text.js +1 -1
  427. package/dist/web/standalone/node_modules/caniuse-lite/data/features/canvas.js +1 -1
  428. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ch-unit.js +1 -1
  429. package/dist/web/standalone/node_modules/caniuse-lite/data/features/chacha20-poly1305.js +1 -1
  430. package/dist/web/standalone/node_modules/caniuse-lite/data/features/channel-messaging.js +1 -1
  431. package/dist/web/standalone/node_modules/caniuse-lite/data/features/childnode-remove.js +1 -1
  432. package/dist/web/standalone/node_modules/caniuse-lite/data/features/classlist.js +1 -1
  433. package/dist/web/standalone/node_modules/caniuse-lite/data/features/client-hints-dpr-width-viewport.js +1 -1
  434. package/dist/web/standalone/node_modules/caniuse-lite/data/features/clipboard.js +1 -1
  435. package/dist/web/standalone/node_modules/caniuse-lite/data/features/colr-v1.js +1 -1
  436. package/dist/web/standalone/node_modules/caniuse-lite/data/features/colr.js +1 -1
  437. package/dist/web/standalone/node_modules/caniuse-lite/data/features/comparedocumentposition.js +1 -1
  438. package/dist/web/standalone/node_modules/caniuse-lite/data/features/console-basic.js +1 -1
  439. package/dist/web/standalone/node_modules/caniuse-lite/data/features/console-time.js +1 -1
  440. package/dist/web/standalone/node_modules/caniuse-lite/data/features/const.js +1 -1
  441. package/dist/web/standalone/node_modules/caniuse-lite/data/features/constraint-validation.js +1 -1
  442. package/dist/web/standalone/node_modules/caniuse-lite/data/features/contenteditable.js +1 -1
  443. package/dist/web/standalone/node_modules/caniuse-lite/data/features/contentsecuritypolicy.js +1 -1
  444. package/dist/web/standalone/node_modules/caniuse-lite/data/features/contentsecuritypolicy2.js +1 -1
  445. package/dist/web/standalone/node_modules/caniuse-lite/data/features/cookie-store-api.js +1 -1
  446. package/dist/web/standalone/node_modules/caniuse-lite/data/features/cors.js +1 -1
  447. package/dist/web/standalone/node_modules/caniuse-lite/data/features/createimagebitmap.js +1 -1
  448. package/dist/web/standalone/node_modules/caniuse-lite/data/features/credential-management.js +1 -1
  449. package/dist/web/standalone/node_modules/caniuse-lite/data/features/cross-document-view-transitions.js +1 -1
  450. package/dist/web/standalone/node_modules/caniuse-lite/data/features/cryptography.js +1 -1
  451. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-all.js +1 -1
  452. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-anchor-positioning.js +1 -1
  453. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-animation.js +1 -1
  454. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-any-link.js +1 -1
  455. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-appearance.js +1 -1
  456. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-at-counter-style.js +1 -1
  457. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-autofill.js +1 -1
  458. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-backdrop-filter.js +1 -1
  459. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-background-offsets.js +1 -1
  460. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-backgroundblendmode.js +1 -1
  461. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-boxdecorationbreak.js +1 -1
  462. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-boxshadow.js +1 -1
  463. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-canvas.js +1 -1
  464. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-caret-color.js +1 -1
  465. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-cascade-layers.js +1 -1
  466. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-cascade-scope.js +1 -1
  467. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-case-insensitive.js +1 -1
  468. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-clip-path.js +1 -1
  469. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-color-adjust.js +1 -1
  470. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-color-function.js +1 -1
  471. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-conic-gradients.js +1 -1
  472. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-container-queries-style.js +1 -1
  473. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-container-queries.js +1 -1
  474. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-container-query-units.js +1 -1
  475. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-containment.js +1 -1
  476. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-content-visibility.js +1 -1
  477. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-counters.js +1 -1
  478. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-crisp-edges.js +1 -1
  479. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-cross-fade.js +1 -1
  480. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-default-pseudo.js +1 -1
  481. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-descendant-gtgt.js +1 -1
  482. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-deviceadaptation.js +1 -1
  483. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-dir-pseudo.js +1 -1
  484. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-display-contents.js +1 -1
  485. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-element-function.js +1 -1
  486. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-env-function.js +1 -1
  487. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-exclusions.js +1 -1
  488. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-featurequeries.js +1 -1
  489. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-file-selector-button.js +1 -1
  490. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-filter-function.js +1 -1
  491. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-filters.js +1 -1
  492. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-first-letter.js +1 -1
  493. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-first-line.js +1 -1
  494. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-fixed.js +1 -1
  495. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-focus-visible.js +1 -1
  496. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-focus-within.js +1 -1
  497. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-font-palette.js +1 -1
  498. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-font-rendering-controls.js +1 -1
  499. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-font-stretch.js +1 -1
  500. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-gencontent.js +1 -1
  501. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-gradients.js +1 -1
  502. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-grid-animation.js +1 -1
  503. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-grid-lanes.js +1 -1
  504. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-grid.js +1 -1
  505. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-hanging-punctuation.js +1 -1
  506. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-has.js +1 -1
  507. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-hyphens.js +1 -1
  508. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-if.js +1 -1
  509. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-image-orientation.js +1 -1
  510. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-image-set.js +1 -1
  511. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-in-out-of-range.js +1 -1
  512. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-indeterminate-pseudo.js +1 -1
  513. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-initial-letter.js +1 -1
  514. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-initial-value.js +1 -1
  515. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-lch-lab.js +1 -1
  516. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-letter-spacing.js +1 -1
  517. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-line-clamp.js +1 -1
  518. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-logical-props.js +1 -1
  519. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-marker-pseudo.js +1 -1
  520. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-masks.js +1 -1
  521. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-matches-pseudo.js +1 -1
  522. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-math-functions.js +1 -1
  523. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-media-interaction.js +1 -1
  524. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-media-range-syntax.js +1 -1
  525. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-media-resolution.js +1 -1
  526. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-media-scripting.js +1 -1
  527. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-mediaqueries.js +1 -1
  528. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-mixblendmode.js +1 -1
  529. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-module-scripts.js +1 -1
  530. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-motion-paths.js +1 -1
  531. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-namespaces.js +1 -1
  532. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-nesting.js +1 -1
  533. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-not-sel-list.js +1 -1
  534. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-nth-child-of.js +1 -1
  535. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-opacity.js +1 -1
  536. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-optional-pseudo.js +1 -1
  537. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-overflow-anchor.js +1 -1
  538. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-overflow-overlay.js +1 -1
  539. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-overflow.js +1 -1
  540. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-overscroll-behavior.js +1 -1
  541. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-page-break.js +1 -1
  542. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-paged-media.js +1 -1
  543. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-paint-api.js +1 -1
  544. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-placeholder-shown.js +1 -1
  545. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-placeholder.js +1 -1
  546. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-print-color-adjust.js +1 -1
  547. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-read-only-write.js +1 -1
  548. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-rebeccapurple.js +1 -1
  549. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-reflections.js +1 -1
  550. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-regions.js +1 -1
  551. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-relative-colors.js +1 -1
  552. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-repeating-gradients.js +1 -1
  553. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-resize.js +1 -1
  554. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-revert-value.js +1 -1
  555. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-rrggbbaa.js +1 -1
  556. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-scroll-behavior.js +1 -1
  557. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-scrollbar.js +1 -1
  558. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-sel2.js +1 -1
  559. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-sel3.js +1 -1
  560. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-selection.js +1 -1
  561. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-shapes.js +1 -1
  562. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-snappoints.js +1 -1
  563. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-sticky.js +1 -1
  564. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-subgrid.js +1 -1
  565. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-supports-api.js +1 -1
  566. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-table.js +1 -1
  567. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-text-align-last.js +1 -1
  568. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-text-box-trim.js +1 -1
  569. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-text-indent.js +1 -1
  570. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-text-justify.js +1 -1
  571. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-text-orientation.js +1 -1
  572. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-text-spacing.js +1 -1
  573. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-text-wrap-balance.js +1 -1
  574. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-textshadow.js +1 -1
  575. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-touch-action.js +1 -1
  576. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-transitions.js +1 -1
  577. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-unicode-bidi.js +1 -1
  578. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-unset-value.js +1 -1
  579. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-variables.js +1 -1
  580. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-when-else.js +1 -1
  581. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-widows-orphans.js +1 -1
  582. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-width-stretch.js +1 -1
  583. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-writing-mode.js +1 -1
  584. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css-zoom.js +1 -1
  585. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css3-attr.js +1 -1
  586. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css3-boxsizing.js +1 -1
  587. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css3-colors.js +1 -1
  588. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css3-cursors-grab.js +1 -1
  589. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css3-cursors-newer.js +1 -1
  590. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css3-cursors.js +1 -1
  591. package/dist/web/standalone/node_modules/caniuse-lite/data/features/css3-tabsize.js +1 -1
  592. package/dist/web/standalone/node_modules/caniuse-lite/data/features/currentcolor.js +1 -1
  593. package/dist/web/standalone/node_modules/caniuse-lite/data/features/custom-elements.js +1 -1
  594. package/dist/web/standalone/node_modules/caniuse-lite/data/features/custom-elementsv1.js +1 -1
  595. package/dist/web/standalone/node_modules/caniuse-lite/data/features/customevent.js +1 -1
  596. package/dist/web/standalone/node_modules/caniuse-lite/data/features/customizable-select.js +1 -1
  597. package/dist/web/standalone/node_modules/caniuse-lite/data/features/datalist.js +1 -1
  598. package/dist/web/standalone/node_modules/caniuse-lite/data/features/dataset.js +1 -1
  599. package/dist/web/standalone/node_modules/caniuse-lite/data/features/datauri.js +1 -1
  600. package/dist/web/standalone/node_modules/caniuse-lite/data/features/date-tolocaledatestring.js +1 -1
  601. package/dist/web/standalone/node_modules/caniuse-lite/data/features/declarative-shadow-dom.js +1 -1
  602. package/dist/web/standalone/node_modules/caniuse-lite/data/features/decorators.js +1 -1
  603. package/dist/web/standalone/node_modules/caniuse-lite/data/features/details.js +1 -1
  604. package/dist/web/standalone/node_modules/caniuse-lite/data/features/deviceorientation.js +1 -1
  605. package/dist/web/standalone/node_modules/caniuse-lite/data/features/devicepixelratio.js +1 -1
  606. package/dist/web/standalone/node_modules/caniuse-lite/data/features/dialog.js +1 -1
  607. package/dist/web/standalone/node_modules/caniuse-lite/data/features/dispatchevent.js +1 -1
  608. package/dist/web/standalone/node_modules/caniuse-lite/data/features/dnssec.js +1 -1
  609. package/dist/web/standalone/node_modules/caniuse-lite/data/features/do-not-track.js +1 -1
  610. package/dist/web/standalone/node_modules/caniuse-lite/data/features/document-currentscript.js +1 -1
  611. package/dist/web/standalone/node_modules/caniuse-lite/data/features/document-evaluate-xpath.js +1 -1
  612. package/dist/web/standalone/node_modules/caniuse-lite/data/features/document-execcommand.js +1 -1
  613. package/dist/web/standalone/node_modules/caniuse-lite/data/features/document-policy.js +1 -1
  614. package/dist/web/standalone/node_modules/caniuse-lite/data/features/document-scrollingelement.js +1 -1
  615. package/dist/web/standalone/node_modules/caniuse-lite/data/features/documenthead.js +1 -1
  616. package/dist/web/standalone/node_modules/caniuse-lite/data/features/dom-manip-convenience.js +1 -1
  617. package/dist/web/standalone/node_modules/caniuse-lite/data/features/dom-range.js +1 -1
  618. package/dist/web/standalone/node_modules/caniuse-lite/data/features/domcontentloaded.js +1 -1
  619. package/dist/web/standalone/node_modules/caniuse-lite/data/features/dommatrix.js +1 -1
  620. package/dist/web/standalone/node_modules/caniuse-lite/data/features/download.js +1 -1
  621. package/dist/web/standalone/node_modules/caniuse-lite/data/features/dragndrop.js +1 -1
  622. package/dist/web/standalone/node_modules/caniuse-lite/data/features/element-closest.js +1 -1
  623. package/dist/web/standalone/node_modules/caniuse-lite/data/features/element-from-point.js +1 -1
  624. package/dist/web/standalone/node_modules/caniuse-lite/data/features/element-scroll-methods.js +1 -1
  625. package/dist/web/standalone/node_modules/caniuse-lite/data/features/eme.js +1 -1
  626. package/dist/web/standalone/node_modules/caniuse-lite/data/features/eot.js +1 -1
  627. package/dist/web/standalone/node_modules/caniuse-lite/data/features/es5.js +1 -1
  628. package/dist/web/standalone/node_modules/caniuse-lite/data/features/es6-class.js +1 -1
  629. package/dist/web/standalone/node_modules/caniuse-lite/data/features/es6-generators.js +1 -1
  630. package/dist/web/standalone/node_modules/caniuse-lite/data/features/es6-module-dynamic-import.js +1 -1
  631. package/dist/web/standalone/node_modules/caniuse-lite/data/features/es6-module.js +1 -1
  632. package/dist/web/standalone/node_modules/caniuse-lite/data/features/es6-number.js +1 -1
  633. package/dist/web/standalone/node_modules/caniuse-lite/data/features/es6-string-includes.js +1 -1
  634. package/dist/web/standalone/node_modules/caniuse-lite/data/features/es6.js +1 -1
  635. package/dist/web/standalone/node_modules/caniuse-lite/data/features/eventsource.js +1 -1
  636. package/dist/web/standalone/node_modules/caniuse-lite/data/features/extended-system-fonts.js +1 -1
  637. package/dist/web/standalone/node_modules/caniuse-lite/data/features/feature-policy.js +1 -1
  638. package/dist/web/standalone/node_modules/caniuse-lite/data/features/fetch.js +1 -1
  639. package/dist/web/standalone/node_modules/caniuse-lite/data/features/fieldset-disabled.js +1 -1
  640. package/dist/web/standalone/node_modules/caniuse-lite/data/features/fileapi.js +1 -1
  641. package/dist/web/standalone/node_modules/caniuse-lite/data/features/filereader.js +1 -1
  642. package/dist/web/standalone/node_modules/caniuse-lite/data/features/filereadersync.js +1 -1
  643. package/dist/web/standalone/node_modules/caniuse-lite/data/features/filesystem.js +1 -1
  644. package/dist/web/standalone/node_modules/caniuse-lite/data/features/flac.js +1 -1
  645. package/dist/web/standalone/node_modules/caniuse-lite/data/features/flexbox-gap.js +1 -1
  646. package/dist/web/standalone/node_modules/caniuse-lite/data/features/flexbox.js +1 -1
  647. package/dist/web/standalone/node_modules/caniuse-lite/data/features/flow-root.js +1 -1
  648. package/dist/web/standalone/node_modules/caniuse-lite/data/features/focusin-focusout-events.js +1 -1
  649. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-family-system-ui.js +1 -1
  650. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-feature.js +1 -1
  651. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-kerning.js +1 -1
  652. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-loading.js +1 -1
  653. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-size-adjust.js +1 -1
  654. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-smooth.js +1 -1
  655. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-unicode-range.js +1 -1
  656. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-variant-alternates.js +1 -1
  657. package/dist/web/standalone/node_modules/caniuse-lite/data/features/font-variant-numeric.js +1 -1
  658. package/dist/web/standalone/node_modules/caniuse-lite/data/features/fontface.js +1 -1
  659. package/dist/web/standalone/node_modules/caniuse-lite/data/features/form-attribute.js +1 -1
  660. package/dist/web/standalone/node_modules/caniuse-lite/data/features/form-submit-attributes.js +1 -1
  661. package/dist/web/standalone/node_modules/caniuse-lite/data/features/form-validation.js +1 -1
  662. package/dist/web/standalone/node_modules/caniuse-lite/data/features/forms.js +1 -1
  663. package/dist/web/standalone/node_modules/caniuse-lite/data/features/fullscreen.js +1 -1
  664. package/dist/web/standalone/node_modules/caniuse-lite/data/features/gamepad.js +1 -1
  665. package/dist/web/standalone/node_modules/caniuse-lite/data/features/geolocation.js +1 -1
  666. package/dist/web/standalone/node_modules/caniuse-lite/data/features/getboundingclientrect.js +1 -1
  667. package/dist/web/standalone/node_modules/caniuse-lite/data/features/getcomputedstyle.js +1 -1
  668. package/dist/web/standalone/node_modules/caniuse-lite/data/features/getelementsbyclassname.js +1 -1
  669. package/dist/web/standalone/node_modules/caniuse-lite/data/features/getrandomvalues.js +1 -1
  670. package/dist/web/standalone/node_modules/caniuse-lite/data/features/gyroscope.js +1 -1
  671. package/dist/web/standalone/node_modules/caniuse-lite/data/features/hardwareconcurrency.js +1 -1
  672. package/dist/web/standalone/node_modules/caniuse-lite/data/features/hashchange.js +1 -1
  673. package/dist/web/standalone/node_modules/caniuse-lite/data/features/heif.js +1 -1
  674. package/dist/web/standalone/node_modules/caniuse-lite/data/features/hevc.js +1 -1
  675. package/dist/web/standalone/node_modules/caniuse-lite/data/features/hidden.js +1 -1
  676. package/dist/web/standalone/node_modules/caniuse-lite/data/features/high-resolution-time.js +1 -1
  677. package/dist/web/standalone/node_modules/caniuse-lite/data/features/history.js +1 -1
  678. package/dist/web/standalone/node_modules/caniuse-lite/data/features/html-media-capture.js +1 -1
  679. package/dist/web/standalone/node_modules/caniuse-lite/data/features/html5semantic.js +1 -1
  680. package/dist/web/standalone/node_modules/caniuse-lite/data/features/http-live-streaming.js +1 -1
  681. package/dist/web/standalone/node_modules/caniuse-lite/data/features/http2.js +1 -1
  682. package/dist/web/standalone/node_modules/caniuse-lite/data/features/http3.js +1 -1
  683. package/dist/web/standalone/node_modules/caniuse-lite/data/features/iframe-sandbox.js +1 -1
  684. package/dist/web/standalone/node_modules/caniuse-lite/data/features/iframe-seamless.js +1 -1
  685. package/dist/web/standalone/node_modules/caniuse-lite/data/features/iframe-srcdoc.js +1 -1
  686. package/dist/web/standalone/node_modules/caniuse-lite/data/features/imagecapture.js +1 -1
  687. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ime.js +1 -1
  688. package/dist/web/standalone/node_modules/caniuse-lite/data/features/img-naturalwidth-naturalheight.js +1 -1
  689. package/dist/web/standalone/node_modules/caniuse-lite/data/features/import-maps.js +1 -1
  690. package/dist/web/standalone/node_modules/caniuse-lite/data/features/imports.js +1 -1
  691. package/dist/web/standalone/node_modules/caniuse-lite/data/features/indeterminate-checkbox.js +1 -1
  692. package/dist/web/standalone/node_modules/caniuse-lite/data/features/indexeddb.js +1 -1
  693. package/dist/web/standalone/node_modules/caniuse-lite/data/features/indexeddb2.js +1 -1
  694. package/dist/web/standalone/node_modules/caniuse-lite/data/features/inline-block.js +1 -1
  695. package/dist/web/standalone/node_modules/caniuse-lite/data/features/innertext.js +1 -1
  696. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-autocomplete-onoff.js +1 -1
  697. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-color.js +1 -1
  698. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-datetime.js +1 -1
  699. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-email-tel-url.js +1 -1
  700. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-event.js +1 -1
  701. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-file-accept.js +1 -1
  702. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-file-directory.js +1 -1
  703. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-file-multiple.js +1 -1
  704. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-inputmode.js +1 -1
  705. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-minlength.js +1 -1
  706. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-number.js +1 -1
  707. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-pattern.js +1 -1
  708. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-placeholder.js +1 -1
  709. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-range.js +1 -1
  710. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-search.js +1 -1
  711. package/dist/web/standalone/node_modules/caniuse-lite/data/features/input-selection.js +1 -1
  712. package/dist/web/standalone/node_modules/caniuse-lite/data/features/insert-adjacent.js +1 -1
  713. package/dist/web/standalone/node_modules/caniuse-lite/data/features/insertadjacenthtml.js +1 -1
  714. package/dist/web/standalone/node_modules/caniuse-lite/data/features/internationalization.js +1 -1
  715. package/dist/web/standalone/node_modules/caniuse-lite/data/features/intersectionobserver-v2.js +1 -1
  716. package/dist/web/standalone/node_modules/caniuse-lite/data/features/intersectionobserver.js +1 -1
  717. package/dist/web/standalone/node_modules/caniuse-lite/data/features/intl-pluralrules.js +1 -1
  718. package/dist/web/standalone/node_modules/caniuse-lite/data/features/intrinsic-width.js +1 -1
  719. package/dist/web/standalone/node_modules/caniuse-lite/data/features/jpeg2000.js +1 -1
  720. package/dist/web/standalone/node_modules/caniuse-lite/data/features/jpegxl.js +1 -1
  721. package/dist/web/standalone/node_modules/caniuse-lite/data/features/jpegxr.js +1 -1
  722. package/dist/web/standalone/node_modules/caniuse-lite/data/features/js-regexp-lookbehind.js +1 -1
  723. package/dist/web/standalone/node_modules/caniuse-lite/data/features/json.js +1 -1
  724. package/dist/web/standalone/node_modules/caniuse-lite/data/features/justify-content-space-evenly.js +1 -1
  725. package/dist/web/standalone/node_modules/caniuse-lite/data/features/kerning-pairs-ligatures.js +1 -1
  726. package/dist/web/standalone/node_modules/caniuse-lite/data/features/keyboardevent-charcode.js +1 -1
  727. package/dist/web/standalone/node_modules/caniuse-lite/data/features/keyboardevent-code.js +1 -1
  728. package/dist/web/standalone/node_modules/caniuse-lite/data/features/keyboardevent-getmodifierstate.js +1 -1
  729. package/dist/web/standalone/node_modules/caniuse-lite/data/features/keyboardevent-key.js +1 -1
  730. package/dist/web/standalone/node_modules/caniuse-lite/data/features/keyboardevent-location.js +1 -1
  731. package/dist/web/standalone/node_modules/caniuse-lite/data/features/keyboardevent-which.js +1 -1
  732. package/dist/web/standalone/node_modules/caniuse-lite/data/features/lazyload.js +1 -1
  733. package/dist/web/standalone/node_modules/caniuse-lite/data/features/let.js +1 -1
  734. package/dist/web/standalone/node_modules/caniuse-lite/data/features/link-icon-png.js +1 -1
  735. package/dist/web/standalone/node_modules/caniuse-lite/data/features/link-icon-svg.js +1 -1
  736. package/dist/web/standalone/node_modules/caniuse-lite/data/features/link-rel-dns-prefetch.js +1 -1
  737. package/dist/web/standalone/node_modules/caniuse-lite/data/features/link-rel-modulepreload.js +1 -1
  738. package/dist/web/standalone/node_modules/caniuse-lite/data/features/link-rel-preconnect.js +1 -1
  739. package/dist/web/standalone/node_modules/caniuse-lite/data/features/link-rel-prefetch.js +1 -1
  740. package/dist/web/standalone/node_modules/caniuse-lite/data/features/link-rel-preload.js +1 -1
  741. package/dist/web/standalone/node_modules/caniuse-lite/data/features/link-rel-prerender.js +1 -1
  742. package/dist/web/standalone/node_modules/caniuse-lite/data/features/loading-lazy-attr.js +1 -1
  743. package/dist/web/standalone/node_modules/caniuse-lite/data/features/loading-lazy-media.js +1 -1
  744. package/dist/web/standalone/node_modules/caniuse-lite/data/features/localecompare.js +1 -1
  745. package/dist/web/standalone/node_modules/caniuse-lite/data/features/magnetometer.js +1 -1
  746. package/dist/web/standalone/node_modules/caniuse-lite/data/features/matchesselector.js +1 -1
  747. package/dist/web/standalone/node_modules/caniuse-lite/data/features/matchmedia.js +1 -1
  748. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mathml.js +1 -1
  749. package/dist/web/standalone/node_modules/caniuse-lite/data/features/maxlength.js +1 -1
  750. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mdn-css-backdrop-pseudo-element.js +1 -1
  751. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mdn-css-unicode-bidi-isolate-override.js +1 -1
  752. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mdn-css-unicode-bidi-isolate.js +1 -1
  753. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mdn-css-unicode-bidi-plaintext.js +1 -1
  754. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mdn-text-decoration-color.js +1 -1
  755. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mdn-text-decoration-line.js +1 -1
  756. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mdn-text-decoration-shorthand.js +1 -1
  757. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mdn-text-decoration-style.js +1 -1
  758. package/dist/web/standalone/node_modules/caniuse-lite/data/features/media-fragments.js +1 -1
  759. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mediacapture-fromelement.js +1 -1
  760. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mediarecorder.js +1 -1
  761. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mediasource.js +1 -1
  762. package/dist/web/standalone/node_modules/caniuse-lite/data/features/menu.js +1 -1
  763. package/dist/web/standalone/node_modules/caniuse-lite/data/features/meta-theme-color.js +1 -1
  764. package/dist/web/standalone/node_modules/caniuse-lite/data/features/meter.js +1 -1
  765. package/dist/web/standalone/node_modules/caniuse-lite/data/features/midi.js +1 -1
  766. package/dist/web/standalone/node_modules/caniuse-lite/data/features/minmaxwh.js +1 -1
  767. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mp3.js +1 -1
  768. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mpeg-dash.js +1 -1
  769. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mpeg4.js +1 -1
  770. package/dist/web/standalone/node_modules/caniuse-lite/data/features/multibackgrounds.js +1 -1
  771. package/dist/web/standalone/node_modules/caniuse-lite/data/features/multicolumn.js +1 -1
  772. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mutation-events.js +1 -1
  773. package/dist/web/standalone/node_modules/caniuse-lite/data/features/mutationobserver.js +1 -1
  774. package/dist/web/standalone/node_modules/caniuse-lite/data/features/namevalue-storage.js +1 -1
  775. package/dist/web/standalone/node_modules/caniuse-lite/data/features/native-filesystem-api.js +1 -1
  776. package/dist/web/standalone/node_modules/caniuse-lite/data/features/nav-timing.js +1 -1
  777. package/dist/web/standalone/node_modules/caniuse-lite/data/features/netinfo.js +1 -1
  778. package/dist/web/standalone/node_modules/caniuse-lite/data/features/notifications.js +1 -1
  779. package/dist/web/standalone/node_modules/caniuse-lite/data/features/object-entries.js +1 -1
  780. package/dist/web/standalone/node_modules/caniuse-lite/data/features/object-fit.js +1 -1
  781. package/dist/web/standalone/node_modules/caniuse-lite/data/features/object-observe.js +1 -1
  782. package/dist/web/standalone/node_modules/caniuse-lite/data/features/object-values.js +1 -1
  783. package/dist/web/standalone/node_modules/caniuse-lite/data/features/objectrtc.js +1 -1
  784. package/dist/web/standalone/node_modules/caniuse-lite/data/features/offline-apps.js +1 -1
  785. package/dist/web/standalone/node_modules/caniuse-lite/data/features/offscreencanvas.js +1 -1
  786. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ogg-vorbis.js +1 -1
  787. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ogv.js +1 -1
  788. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ol-reversed.js +1 -1
  789. package/dist/web/standalone/node_modules/caniuse-lite/data/features/once-event-listener.js +1 -1
  790. package/dist/web/standalone/node_modules/caniuse-lite/data/features/online-status.js +1 -1
  791. package/dist/web/standalone/node_modules/caniuse-lite/data/features/opus.js +1 -1
  792. package/dist/web/standalone/node_modules/caniuse-lite/data/features/orientation-sensor.js +1 -1
  793. package/dist/web/standalone/node_modules/caniuse-lite/data/features/outline.js +1 -1
  794. package/dist/web/standalone/node_modules/caniuse-lite/data/features/pad-start-end.js +1 -1
  795. package/dist/web/standalone/node_modules/caniuse-lite/data/features/page-transition-events.js +1 -1
  796. package/dist/web/standalone/node_modules/caniuse-lite/data/features/pagevisibility.js +1 -1
  797. package/dist/web/standalone/node_modules/caniuse-lite/data/features/passive-event-listener.js +1 -1
  798. package/dist/web/standalone/node_modules/caniuse-lite/data/features/passkeys.js +1 -1
  799. package/dist/web/standalone/node_modules/caniuse-lite/data/features/passwordrules.js +1 -1
  800. package/dist/web/standalone/node_modules/caniuse-lite/data/features/path2d.js +1 -1
  801. package/dist/web/standalone/node_modules/caniuse-lite/data/features/payment-request.js +1 -1
  802. package/dist/web/standalone/node_modules/caniuse-lite/data/features/pdf-viewer.js +1 -1
  803. package/dist/web/standalone/node_modules/caniuse-lite/data/features/permissions-api.js +1 -1
  804. package/dist/web/standalone/node_modules/caniuse-lite/data/features/permissions-policy.js +1 -1
  805. package/dist/web/standalone/node_modules/caniuse-lite/data/features/picture-in-picture.js +1 -1
  806. package/dist/web/standalone/node_modules/caniuse-lite/data/features/picture.js +1 -1
  807. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ping.js +1 -1
  808. package/dist/web/standalone/node_modules/caniuse-lite/data/features/png-alpha.js +1 -1
  809. package/dist/web/standalone/node_modules/caniuse-lite/data/features/pointer-events.js +1 -1
  810. package/dist/web/standalone/node_modules/caniuse-lite/data/features/pointer.js +1 -1
  811. package/dist/web/standalone/node_modules/caniuse-lite/data/features/pointerlock.js +1 -1
  812. package/dist/web/standalone/node_modules/caniuse-lite/data/features/portals.js +1 -1
  813. package/dist/web/standalone/node_modules/caniuse-lite/data/features/prefers-color-scheme.js +1 -1
  814. package/dist/web/standalone/node_modules/caniuse-lite/data/features/prefers-reduced-motion.js +1 -1
  815. package/dist/web/standalone/node_modules/caniuse-lite/data/features/progress.js +1 -1
  816. package/dist/web/standalone/node_modules/caniuse-lite/data/features/promise-finally.js +1 -1
  817. package/dist/web/standalone/node_modules/caniuse-lite/data/features/promises.js +1 -1
  818. package/dist/web/standalone/node_modules/caniuse-lite/data/features/proximity.js +1 -1
  819. package/dist/web/standalone/node_modules/caniuse-lite/data/features/proxy.js +1 -1
  820. package/dist/web/standalone/node_modules/caniuse-lite/data/features/publickeypinning.js +1 -1
  821. package/dist/web/standalone/node_modules/caniuse-lite/data/features/push-api.js +1 -1
  822. package/dist/web/standalone/node_modules/caniuse-lite/data/features/queryselector.js +1 -1
  823. package/dist/web/standalone/node_modules/caniuse-lite/data/features/readonly-attr.js +1 -1
  824. package/dist/web/standalone/node_modules/caniuse-lite/data/features/referrer-policy.js +1 -1
  825. package/dist/web/standalone/node_modules/caniuse-lite/data/features/registerprotocolhandler.js +1 -1
  826. package/dist/web/standalone/node_modules/caniuse-lite/data/features/rel-noopener.js +1 -1
  827. package/dist/web/standalone/node_modules/caniuse-lite/data/features/rel-noreferrer.js +1 -1
  828. package/dist/web/standalone/node_modules/caniuse-lite/data/features/rellist.js +1 -1
  829. package/dist/web/standalone/node_modules/caniuse-lite/data/features/rem.js +1 -1
  830. package/dist/web/standalone/node_modules/caniuse-lite/data/features/requestanimationframe.js +1 -1
  831. package/dist/web/standalone/node_modules/caniuse-lite/data/features/requestidlecallback.js +1 -1
  832. package/dist/web/standalone/node_modules/caniuse-lite/data/features/resizeobserver.js +1 -1
  833. package/dist/web/standalone/node_modules/caniuse-lite/data/features/resource-timing.js +1 -1
  834. package/dist/web/standalone/node_modules/caniuse-lite/data/features/rest-parameters.js +1 -1
  835. package/dist/web/standalone/node_modules/caniuse-lite/data/features/rtcpeerconnection.js +1 -1
  836. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ruby.js +1 -1
  837. package/dist/web/standalone/node_modules/caniuse-lite/data/features/run-in.js +1 -1
  838. package/dist/web/standalone/node_modules/caniuse-lite/data/features/same-site-cookie-attribute.js +1 -1
  839. package/dist/web/standalone/node_modules/caniuse-lite/data/features/screen-orientation.js +1 -1
  840. package/dist/web/standalone/node_modules/caniuse-lite/data/features/script-async.js +1 -1
  841. package/dist/web/standalone/node_modules/caniuse-lite/data/features/script-defer.js +1 -1
  842. package/dist/web/standalone/node_modules/caniuse-lite/data/features/scrollintoview.js +1 -1
  843. package/dist/web/standalone/node_modules/caniuse-lite/data/features/scrollintoviewifneeded.js +1 -1
  844. package/dist/web/standalone/node_modules/caniuse-lite/data/features/sdch.js +1 -1
  845. package/dist/web/standalone/node_modules/caniuse-lite/data/features/selection-api.js +1 -1
  846. package/dist/web/standalone/node_modules/caniuse-lite/data/features/server-timing.js +1 -1
  847. package/dist/web/standalone/node_modules/caniuse-lite/data/features/serviceworkers.js +1 -1
  848. package/dist/web/standalone/node_modules/caniuse-lite/data/features/setimmediate.js +1 -1
  849. package/dist/web/standalone/node_modules/caniuse-lite/data/features/shadowdom.js +1 -1
  850. package/dist/web/standalone/node_modules/caniuse-lite/data/features/shadowdomv1.js +1 -1
  851. package/dist/web/standalone/node_modules/caniuse-lite/data/features/sharedarraybuffer.js +1 -1
  852. package/dist/web/standalone/node_modules/caniuse-lite/data/features/sharedworkers.js +1 -1
  853. package/dist/web/standalone/node_modules/caniuse-lite/data/features/sni.js +1 -1
  854. package/dist/web/standalone/node_modules/caniuse-lite/data/features/spdy.js +1 -1
  855. package/dist/web/standalone/node_modules/caniuse-lite/data/features/speech-recognition.js +1 -1
  856. package/dist/web/standalone/node_modules/caniuse-lite/data/features/speech-synthesis.js +1 -1
  857. package/dist/web/standalone/node_modules/caniuse-lite/data/features/spellcheck-attribute.js +1 -1
  858. package/dist/web/standalone/node_modules/caniuse-lite/data/features/sql-storage.js +1 -1
  859. package/dist/web/standalone/node_modules/caniuse-lite/data/features/srcset.js +1 -1
  860. package/dist/web/standalone/node_modules/caniuse-lite/data/features/stream.js +1 -1
  861. package/dist/web/standalone/node_modules/caniuse-lite/data/features/streams.js +1 -1
  862. package/dist/web/standalone/node_modules/caniuse-lite/data/features/stricttransportsecurity.js +1 -1
  863. package/dist/web/standalone/node_modules/caniuse-lite/data/features/style-scoped.js +1 -1
  864. package/dist/web/standalone/node_modules/caniuse-lite/data/features/subresource-bundling.js +1 -1
  865. package/dist/web/standalone/node_modules/caniuse-lite/data/features/subresource-integrity.js +1 -1
  866. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg-css.js +1 -1
  867. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg-filters.js +1 -1
  868. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg-fonts.js +1 -1
  869. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg-fragment.js +1 -1
  870. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg-html.js +1 -1
  871. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg-html5.js +1 -1
  872. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg-img.js +1 -1
  873. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg-smil.js +1 -1
  874. package/dist/web/standalone/node_modules/caniuse-lite/data/features/svg.js +1 -1
  875. package/dist/web/standalone/node_modules/caniuse-lite/data/features/sxg.js +1 -1
  876. package/dist/web/standalone/node_modules/caniuse-lite/data/features/tabindex-attr.js +1 -1
  877. package/dist/web/standalone/node_modules/caniuse-lite/data/features/template-literals.js +1 -1
  878. package/dist/web/standalone/node_modules/caniuse-lite/data/features/template.js +1 -1
  879. package/dist/web/standalone/node_modules/caniuse-lite/data/features/temporal.js +1 -1
  880. package/dist/web/standalone/node_modules/caniuse-lite/data/features/testfeat.js +1 -1
  881. package/dist/web/standalone/node_modules/caniuse-lite/data/features/text-decoration.js +1 -1
  882. package/dist/web/standalone/node_modules/caniuse-lite/data/features/text-emphasis.js +1 -1
  883. package/dist/web/standalone/node_modules/caniuse-lite/data/features/text-overflow.js +1 -1
  884. package/dist/web/standalone/node_modules/caniuse-lite/data/features/text-size-adjust.js +1 -1
  885. package/dist/web/standalone/node_modules/caniuse-lite/data/features/text-stroke.js +1 -1
  886. package/dist/web/standalone/node_modules/caniuse-lite/data/features/textcontent.js +1 -1
  887. package/dist/web/standalone/node_modules/caniuse-lite/data/features/textencoder.js +1 -1
  888. package/dist/web/standalone/node_modules/caniuse-lite/data/features/tls1-1.js +1 -1
  889. package/dist/web/standalone/node_modules/caniuse-lite/data/features/tls1-2.js +1 -1
  890. package/dist/web/standalone/node_modules/caniuse-lite/data/features/tls1-3.js +1 -1
  891. package/dist/web/standalone/node_modules/caniuse-lite/data/features/touch.js +1 -1
  892. package/dist/web/standalone/node_modules/caniuse-lite/data/features/transforms2d.js +1 -1
  893. package/dist/web/standalone/node_modules/caniuse-lite/data/features/transforms3d.js +1 -1
  894. package/dist/web/standalone/node_modules/caniuse-lite/data/features/trusted-types.js +1 -1
  895. package/dist/web/standalone/node_modules/caniuse-lite/data/features/ttf.js +1 -1
  896. package/dist/web/standalone/node_modules/caniuse-lite/data/features/typedarrays.js +1 -1
  897. package/dist/web/standalone/node_modules/caniuse-lite/data/features/u2f.js +1 -1
  898. package/dist/web/standalone/node_modules/caniuse-lite/data/features/unhandledrejection.js +1 -1
  899. package/dist/web/standalone/node_modules/caniuse-lite/data/features/upgradeinsecurerequests.js +1 -1
  900. package/dist/web/standalone/node_modules/caniuse-lite/data/features/url-scroll-to-text-fragment.js +1 -1
  901. package/dist/web/standalone/node_modules/caniuse-lite/data/features/url.js +1 -1
  902. package/dist/web/standalone/node_modules/caniuse-lite/data/features/urlsearchparams.js +1 -1
  903. package/dist/web/standalone/node_modules/caniuse-lite/data/features/use-strict.js +1 -1
  904. package/dist/web/standalone/node_modules/caniuse-lite/data/features/user-select-none.js +1 -1
  905. package/dist/web/standalone/node_modules/caniuse-lite/data/features/user-timing.js +1 -1
  906. package/dist/web/standalone/node_modules/caniuse-lite/data/features/variable-fonts.js +1 -1
  907. package/dist/web/standalone/node_modules/caniuse-lite/data/features/vector-effect.js +1 -1
  908. package/dist/web/standalone/node_modules/caniuse-lite/data/features/vibration.js +1 -1
  909. package/dist/web/standalone/node_modules/caniuse-lite/data/features/video.js +1 -1
  910. package/dist/web/standalone/node_modules/caniuse-lite/data/features/videotracks.js +1 -1
  911. package/dist/web/standalone/node_modules/caniuse-lite/data/features/view-transitions.js +1 -1
  912. package/dist/web/standalone/node_modules/caniuse-lite/data/features/viewport-unit-variants.js +1 -1
  913. package/dist/web/standalone/node_modules/caniuse-lite/data/features/viewport-units.js +1 -1
  914. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wai-aria.js +1 -1
  915. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wake-lock.js +1 -1
  916. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-bigint.js +1 -1
  917. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-bulk-memory.js +1 -1
  918. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-extended-const.js +1 -1
  919. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-gc.js +1 -1
  920. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-multi-memory.js +1 -1
  921. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-multi-value.js +1 -1
  922. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-mutable-globals.js +1 -1
  923. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-nontrapping-fptoint.js +1 -1
  924. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-reference-types.js +1 -1
  925. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-relaxed-simd.js +1 -1
  926. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-signext.js +1 -1
  927. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-simd.js +1 -1
  928. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-tail-calls.js +1 -1
  929. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm-threads.js +1 -1
  930. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wasm.js +1 -1
  931. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wav.js +1 -1
  932. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wbr-element.js +1 -1
  933. package/dist/web/standalone/node_modules/caniuse-lite/data/features/web-animation.js +1 -1
  934. package/dist/web/standalone/node_modules/caniuse-lite/data/features/web-app-manifest.js +1 -1
  935. package/dist/web/standalone/node_modules/caniuse-lite/data/features/web-bluetooth.js +1 -1
  936. package/dist/web/standalone/node_modules/caniuse-lite/data/features/web-serial.js +1 -1
  937. package/dist/web/standalone/node_modules/caniuse-lite/data/features/web-share.js +1 -1
  938. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webauthn.js +1 -1
  939. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webcodecs.js +1 -1
  940. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webgl.js +1 -1
  941. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webgl2.js +1 -1
  942. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webgpu.js +1 -1
  943. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webhid.js +1 -1
  944. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webkit-user-drag.js +1 -1
  945. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webm.js +1 -1
  946. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webnfc.js +1 -1
  947. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webp.js +1 -1
  948. package/dist/web/standalone/node_modules/caniuse-lite/data/features/websockets.js +1 -1
  949. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webtransport.js +1 -1
  950. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webusb.js +1 -1
  951. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webvr.js +1 -1
  952. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webvtt.js +1 -1
  953. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webworkers.js +1 -1
  954. package/dist/web/standalone/node_modules/caniuse-lite/data/features/webxr.js +1 -1
  955. package/dist/web/standalone/node_modules/caniuse-lite/data/features/will-change.js +1 -1
  956. package/dist/web/standalone/node_modules/caniuse-lite/data/features/woff.js +1 -1
  957. package/dist/web/standalone/node_modules/caniuse-lite/data/features/woff2.js +1 -1
  958. package/dist/web/standalone/node_modules/caniuse-lite/data/features/word-break.js +1 -1
  959. package/dist/web/standalone/node_modules/caniuse-lite/data/features/wordwrap.js +1 -1
  960. package/dist/web/standalone/node_modules/caniuse-lite/data/features/x-doc-messaging.js +1 -1
  961. package/dist/web/standalone/node_modules/caniuse-lite/data/features/x-frame-options.js +1 -1
  962. package/dist/web/standalone/node_modules/caniuse-lite/data/features/xhr2.js +1 -1
  963. package/dist/web/standalone/node_modules/caniuse-lite/data/features/xhtml.js +1 -1
  964. package/dist/web/standalone/node_modules/caniuse-lite/data/features/xhtmlsmil.js +1 -1
  965. package/dist/web/standalone/node_modules/caniuse-lite/data/features/xml-serializer.js +1 -1
  966. package/dist/web/standalone/node_modules/caniuse-lite/data/features/zstd.js +1 -1
  967. package/dist/web/standalone/node_modules/caniuse-lite/package.json +7 -7
  968. package/dist/web/standalone/node_modules/next/dist/build/swc/index.js +1 -1
  969. package/dist/web/standalone/node_modules/next/dist/build/webpack-config.js +3 -3
  970. package/dist/web/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +7 -7
  971. package/dist/web/standalone/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js +6 -6
  972. package/dist/web/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
  973. package/dist/web/standalone/node_modules/next/dist/server/config-schema.js +10 -2
  974. package/dist/web/standalone/node_modules/next/dist/server/config.js +1 -1
  975. package/dist/web/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +2 -2
  976. package/dist/web/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
  977. package/dist/web/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
  978. package/dist/web/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
  979. package/dist/web/standalone/node_modules/next/dist/server/render.js +27 -20
  980. package/dist/web/standalone/node_modules/next/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  981. package/dist/web/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
  982. package/dist/web/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
  983. package/dist/web/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
  984. package/dist/web/standalone/node_modules/next/package.json +15 -15
  985. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/container.js +26 -18
  986. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/css-syntax-error.js +47 -14
  987. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/input.js +54 -29
  988. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/lazy-result.js +47 -37
  989. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/map-generator.js +26 -9
  990. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/no-work-result.js +57 -55
  991. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/node.js +99 -31
  992. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/parser.js +10 -9
  993. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/previous-map.js +30 -11
  994. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/processor.js +7 -7
  995. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/result.js +5 -5
  996. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/stringifier.js +69 -28
  997. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/tokenize.js +6 -2
  998. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/package.json +48 -48
  999. package/dist/web/standalone/node_modules/react/cjs/react.development.js +1 -1
  1000. package/dist/web/standalone/node_modules/react/cjs/react.production.js +1 -1
  1001. package/dist/web/standalone/node_modules/react/package.json +1 -1
  1002. package/dist/web/standalone/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js +1 -1
  1003. package/dist/web/standalone/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.js +1 -1
  1004. package/dist/web/standalone/node_modules/react-dom/cjs/react-dom-server.browser.production.js +3 -3
  1005. package/dist/web/standalone/node_modules/react-dom/cjs/react-dom-server.edge.production.js +3 -3
  1006. package/dist/web/standalone/node_modules/react-dom/cjs/react-dom-server.node.production.js +3 -3
  1007. package/dist/web/standalone/node_modules/react-dom/cjs/react-dom.production.js +1 -1
  1008. package/dist/web/standalone/node_modules/react-dom/package.json +2 -2
  1009. package/dist/web/standalone/package.json +14 -8
  1010. package/dist/web/standalone/server.js +1 -1
  1011. package/dist/welcome-screen.js +27 -1
  1012. package/dist/worktree-cli.d.ts +6 -4
  1013. package/dist/worktree-cli.js +26 -20
  1014. package/dist/worktree-status-banner.d.ts +1 -0
  1015. package/dist/worktree-status-banner.js +132 -0
  1016. package/package.json +2 -4
  1017. package/packages/daemon/package.json +2 -2
  1018. package/packages/mcp-server/README.md +13 -11
  1019. package/packages/mcp-server/dist/alias-telemetry.d.ts +8 -0
  1020. package/packages/mcp-server/dist/alias-telemetry.d.ts.map +1 -0
  1021. package/packages/mcp-server/dist/alias-telemetry.js +30 -0
  1022. package/packages/mcp-server/dist/alias-telemetry.js.map +1 -0
  1023. package/packages/mcp-server/dist/env-writer.d.ts +5 -1
  1024. package/packages/mcp-server/dist/env-writer.d.ts.map +1 -1
  1025. package/packages/mcp-server/dist/env-writer.js +41 -8
  1026. package/packages/mcp-server/dist/env-writer.js.map +1 -1
  1027. package/packages/mcp-server/dist/readers/graph.d.ts.map +1 -1
  1028. package/packages/mcp-server/dist/readers/graph.js +7 -6
  1029. package/packages/mcp-server/dist/readers/graph.js.map +1 -1
  1030. package/packages/mcp-server/dist/readers/paths.d.ts +2 -0
  1031. package/packages/mcp-server/dist/readers/paths.d.ts.map +1 -1
  1032. package/packages/mcp-server/dist/readers/paths.js +163 -59
  1033. package/packages/mcp-server/dist/readers/paths.js.map +1 -1
  1034. package/packages/mcp-server/dist/remote-questions.d.ts +27 -0
  1035. package/packages/mcp-server/dist/remote-questions.d.ts.map +1 -1
  1036. package/packages/mcp-server/dist/remote-questions.js +47 -2
  1037. package/packages/mcp-server/dist/remote-questions.js.map +1 -1
  1038. package/packages/mcp-server/dist/server.d.ts +39 -1
  1039. package/packages/mcp-server/dist/server.d.ts.map +1 -1
  1040. package/packages/mcp-server/dist/server.js +228 -52
  1041. package/packages/mcp-server/dist/server.js.map +1 -1
  1042. package/packages/mcp-server/dist/session-manager.d.ts +6 -1
  1043. package/packages/mcp-server/dist/session-manager.d.ts.map +1 -1
  1044. package/packages/mcp-server/dist/session-manager.js +35 -13
  1045. package/packages/mcp-server/dist/session-manager.js.map +1 -1
  1046. package/packages/mcp-server/dist/workflow-tools.d.ts +7 -1
  1047. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  1048. package/packages/mcp-server/dist/workflow-tools.js +234 -76
  1049. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  1050. package/packages/mcp-server/package.json +2 -2
  1051. package/packages/mcp-server/src/alias-telemetry.test.ts +78 -0
  1052. package/packages/mcp-server/src/alias-telemetry.ts +30 -0
  1053. package/packages/mcp-server/src/env-writer.test.ts +76 -1
  1054. package/packages/mcp-server/src/env-writer.ts +48 -9
  1055. package/packages/mcp-server/src/import-candidates.test.ts +9 -4
  1056. package/packages/mcp-server/src/mcp-server.test.ts +422 -2
  1057. package/packages/mcp-server/src/parse-workflow-args.test.ts +80 -0
  1058. package/packages/mcp-server/src/readers/graph.test.ts +5 -2
  1059. package/packages/mcp-server/src/readers/graph.ts +14 -6
  1060. package/packages/mcp-server/src/readers/paths.test.ts +67 -0
  1061. package/packages/mcp-server/src/readers/paths.ts +173 -56
  1062. package/packages/mcp-server/src/remote-questions.test.ts +103 -0
  1063. package/packages/mcp-server/src/remote-questions.ts +53 -2
  1064. package/packages/mcp-server/src/server.ts +284 -59
  1065. package/packages/mcp-server/src/session-manager.ts +33 -12
  1066. package/packages/mcp-server/src/workflow-tools.test.ts +308 -136
  1067. package/packages/mcp-server/src/workflow-tools.ts +265 -92
  1068. package/packages/mcp-server/tsconfig.tsbuildinfo +1 -1
  1069. package/packages/native/dist/stream-process/index.js +207 -6
  1070. package/packages/native/package.json +1 -1
  1071. package/packages/native/src/__tests__/stream-process.test.mjs +51 -18
  1072. package/packages/native/src/stream-process/index.ts +249 -11
  1073. package/packages/native/tsconfig.tsbuildinfo +1 -1
  1074. package/packages/pi-agent-core/package.json +1 -1
  1075. package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -1
  1076. package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js +8 -2
  1077. package/packages/pi-ai/dist/providers/anthropic-bearer-auth.test.js.map +1 -1
  1078. package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.d.ts +2 -0
  1079. package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.d.ts.map +1 -0
  1080. package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.js +231 -0
  1081. package/packages/pi-ai/dist/providers/anthropic-shared.cache-breakpoint.test.js.map +1 -0
  1082. package/packages/pi-ai/dist/providers/anthropic-shared.d.ts.map +1 -1
  1083. package/packages/pi-ai/dist/providers/anthropic-shared.js +48 -19
  1084. package/packages/pi-ai/dist/providers/anthropic-shared.js.map +1 -1
  1085. package/packages/pi-ai/dist/providers/minimax-tool-name.test.js +8 -2
  1086. package/packages/pi-ai/dist/providers/minimax-tool-name.test.js.map +1 -1
  1087. package/packages/pi-ai/dist/types.d.ts +13 -0
  1088. package/packages/pi-ai/dist/types.d.ts.map +1 -1
  1089. package/packages/pi-ai/dist/types.js.map +1 -1
  1090. package/packages/pi-ai/dist/utils/repair-tool-json.d.ts.map +1 -1
  1091. package/packages/pi-ai/dist/utils/repair-tool-json.js +24 -3
  1092. package/packages/pi-ai/dist/utils/repair-tool-json.js.map +1 -1
  1093. package/packages/pi-ai/dist/utils/tests/repair-tool-json.test.js +26 -0
  1094. package/packages/pi-ai/dist/utils/tests/repair-tool-json.test.js.map +1 -1
  1095. package/packages/pi-ai/package.json +1 -1
  1096. package/packages/pi-ai/src/providers/anthropic-bearer-auth.test.ts +8 -2
  1097. package/packages/pi-ai/src/providers/anthropic-shared.cache-breakpoint.test.ts +289 -0
  1098. package/packages/pi-ai/src/providers/anthropic-shared.ts +52 -20
  1099. package/packages/pi-ai/src/providers/minimax-tool-name.test.ts +9 -2
  1100. package/packages/pi-ai/src/types.ts +13 -0
  1101. package/packages/pi-ai/src/utils/repair-tool-json.ts +24 -3
  1102. package/packages/pi-ai/src/utils/tests/repair-tool-json.test.ts +32 -0
  1103. package/packages/pi-ai/tsconfig.tsbuildinfo +1 -1
  1104. package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js +278 -0
  1105. package/packages/pi-coding-agent/dist/core/agent-session-abort-order.test.js.map +1 -1
  1106. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +7 -0
  1107. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  1108. package/packages/pi-coding-agent/dist/core/agent-session.js +131 -55
  1109. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  1110. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +1 -0
  1111. package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  1112. package/packages/pi-coding-agent/dist/core/extensions/runner.js +43 -2
  1113. package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  1114. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js +79 -1
  1115. package/packages/pi-coding-agent/dist/core/extensions/runner.test.js.map +1 -1
  1116. package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -1
  1117. package/packages/pi-coding-agent/dist/core/messages.js +4 -0
  1118. package/packages/pi-coding-agent/dist/core/messages.js.map +1 -1
  1119. package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js +19 -2
  1120. package/packages/pi-coding-agent/dist/core/model-registry-auth-mode.test.js.map +1 -1
  1121. package/packages/pi-coding-agent/dist/core/model-registry.d.ts +10 -0
  1122. package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  1123. package/packages/pi-coding-agent/dist/core/model-registry.js +18 -0
  1124. package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  1125. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts +13 -0
  1126. package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  1127. package/packages/pi-coding-agent/dist/core/system-prompt.js +20 -16
  1128. package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  1129. package/packages/pi-coding-agent/dist/core/token-telemetry.d.ts +37 -0
  1130. package/packages/pi-coding-agent/dist/core/token-telemetry.d.ts.map +1 -0
  1131. package/packages/pi-coding-agent/dist/core/token-telemetry.js +49 -0
  1132. package/packages/pi-coding-agent/dist/core/token-telemetry.js.map +1 -0
  1133. package/packages/pi-coding-agent/dist/core/tools/bash-spawn-windows.test.js +24 -6
  1134. package/packages/pi-coding-agent/dist/core/tools/bash-spawn-windows.test.js.map +1 -1
  1135. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.d.ts +2 -0
  1136. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.d.ts.map +1 -0
  1137. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js +133 -0
  1138. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.js.map +1 -0
  1139. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js +1 -1
  1140. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.js.map +1 -1
  1141. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js +14 -1
  1142. package/packages/pi-coding-agent/dist/modes/interactive/controllers/input-controller.test.js.map +1 -1
  1143. package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.d.ts +2 -0
  1144. package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.d.ts.map +1 -0
  1145. package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.js +78 -0
  1146. package/packages/pi-coding-agent/dist/tests/system-prompt-cache-stability.test.js.map +1 -0
  1147. package/packages/pi-coding-agent/dist/tests/token-telemetry.test.d.ts +2 -0
  1148. package/packages/pi-coding-agent/dist/tests/token-telemetry.test.d.ts.map +1 -0
  1149. package/packages/pi-coding-agent/dist/tests/token-telemetry.test.js +181 -0
  1150. package/packages/pi-coding-agent/dist/tests/token-telemetry.test.js.map +1 -0
  1151. package/packages/pi-coding-agent/package.json +1 -1
  1152. package/packages/pi-coding-agent/src/core/agent-session-abort-order.test.ts +319 -0
  1153. package/packages/pi-coding-agent/src/core/agent-session.ts +135 -59
  1154. package/packages/pi-coding-agent/src/core/extensions/runner.test.ts +89 -1
  1155. package/packages/pi-coding-agent/src/core/extensions/runner.ts +46 -2
  1156. package/packages/pi-coding-agent/src/core/messages.ts +4 -0
  1157. package/packages/pi-coding-agent/src/core/model-registry-auth-mode.test.ts +32 -2
  1158. package/packages/pi-coding-agent/src/core/model-registry.ts +21 -0
  1159. package/packages/pi-coding-agent/src/core/system-prompt.ts +33 -15
  1160. package/packages/pi-coding-agent/src/core/token-telemetry.ts +77 -0
  1161. package/packages/pi-coding-agent/src/core/tools/bash-spawn-windows.test.ts +26 -6
  1162. package/packages/pi-coding-agent/src/modes/interactive/components/tool-card-cleanup-and-success-runtime.test.ts +212 -0
  1163. package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.test.ts +17 -1
  1164. package/packages/pi-coding-agent/src/modes/interactive/controllers/input-controller.ts +1 -1
  1165. package/packages/pi-coding-agent/src/tests/system-prompt-cache-stability.test.ts +102 -0
  1166. package/packages/pi-coding-agent/src/tests/token-telemetry.test.ts +200 -0
  1167. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  1168. package/packages/pi-tui/dist/__tests__/autocomplete.test.js +17 -3
  1169. package/packages/pi-tui/dist/__tests__/autocomplete.test.js.map +1 -1
  1170. package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.d.ts +2 -0
  1171. package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.d.ts.map +1 -0
  1172. package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.js +161 -0
  1173. package/packages/pi-tui/dist/components/__tests__/leak-fixes-runtime.test.js.map +1 -0
  1174. package/packages/pi-tui/package.json +1 -1
  1175. package/packages/pi-tui/src/__tests__/autocomplete.test.ts +20 -3
  1176. package/packages/pi-tui/src/components/__tests__/leak-fixes-runtime.test.ts +219 -0
  1177. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  1178. package/packages/rpc-client/package.json +1 -1
  1179. package/pkg/package.json +1 -1
  1180. package/src/resources/GSD-WORKFLOW.md +29 -42
  1181. package/src/resources/extensions/async-jobs/job-manager.ts +3 -0
  1182. package/src/resources/extensions/bg-shell/bg-shell-lifecycle.ts +3 -2
  1183. package/src/resources/extensions/bg-shell/utilities.ts +2 -1
  1184. package/src/resources/extensions/browser-tools/tools/intent.ts +13 -2
  1185. package/src/resources/extensions/claude-code-cli/readiness.ts +20 -7
  1186. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +21 -8
  1187. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +34 -13
  1188. package/src/resources/extensions/github-sync/cli.ts +3 -0
  1189. package/src/resources/extensions/github-sync/sync.ts +88 -58
  1190. package/src/resources/extensions/github-sync/tests/sync-source.test.ts +26 -0
  1191. package/src/resources/extensions/google-search/index.ts +2 -9
  1192. package/src/resources/extensions/gsd/auto/detect-stuck.ts +37 -5
  1193. package/src/resources/extensions/gsd/auto/loop-deps.ts +1 -1
  1194. package/src/resources/extensions/gsd/auto/loop.ts +287 -43
  1195. package/src/resources/extensions/gsd/auto/phases.ts +110 -44
  1196. package/src/resources/extensions/gsd/auto/run-unit.ts +26 -12
  1197. package/src/resources/extensions/gsd/auto/session.ts +48 -6
  1198. package/src/resources/extensions/gsd/auto/types.ts +1 -0
  1199. package/src/resources/extensions/gsd/auto-artifact-paths.ts +60 -30
  1200. package/src/resources/extensions/gsd/auto-dashboard.ts +13 -2
  1201. package/src/resources/extensions/gsd/auto-direct-dispatch.ts +62 -24
  1202. package/src/resources/extensions/gsd/auto-dispatch.ts +327 -100
  1203. package/src/resources/extensions/gsd/auto-post-unit.ts +150 -56
  1204. package/src/resources/extensions/gsd/auto-prompts.ts +170 -9
  1205. package/src/resources/extensions/gsd/auto-recovery.ts +121 -21
  1206. package/src/resources/extensions/gsd/auto-runtime-state.ts +51 -0
  1207. package/src/resources/extensions/gsd/auto-start.ts +73 -73
  1208. package/src/resources/extensions/gsd/auto-timeout-recovery.ts +22 -0
  1209. package/src/resources/extensions/gsd/auto-timers.ts +37 -5
  1210. package/src/resources/extensions/gsd/auto-tool-tracking.ts +2 -4
  1211. package/src/resources/extensions/gsd/auto-worktree.ts +430 -419
  1212. package/src/resources/extensions/gsd/auto.ts +252 -66
  1213. package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +21 -2
  1214. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +53 -20
  1215. package/src/resources/extensions/gsd/bootstrap/dynamic-tools.ts +9 -84
  1216. package/src/resources/extensions/gsd/bootstrap/exec-tools.ts +8 -7
  1217. package/src/resources/extensions/gsd/bootstrap/query-tools.ts +2 -2
  1218. package/src/resources/extensions/gsd/bootstrap/register-extension.ts +10 -9
  1219. package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +217 -47
  1220. package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +12 -6
  1221. package/src/resources/extensions/gsd/bootstrap/subagent-input.ts +20 -0
  1222. package/src/resources/extensions/gsd/bootstrap/system-context.ts +53 -12
  1223. package/src/resources/extensions/gsd/bootstrap/tests/write-gate-basepath.test.ts +103 -0
  1224. package/src/resources/extensions/gsd/bootstrap/write-gate.ts +306 -74
  1225. package/src/resources/extensions/gsd/branch-patterns.ts +3 -3
  1226. package/src/resources/extensions/gsd/commands/catalog.ts +87 -9
  1227. package/src/resources/extensions/gsd/commands/context.ts +40 -6
  1228. package/src/resources/extensions/gsd/commands/dispatcher.ts +11 -5
  1229. package/src/resources/extensions/gsd/commands/handlers/auto.ts +2 -1
  1230. package/src/resources/extensions/gsd/commands/handlers/core.ts +25 -1
  1231. package/src/resources/extensions/gsd/commands/handlers/ops.ts +15 -0
  1232. package/src/resources/extensions/gsd/commands/handlers/workflow.ts +23 -2
  1233. package/src/resources/extensions/gsd/commands-bootstrap.ts +7 -0
  1234. package/src/resources/extensions/gsd/commands-codebase.ts +2 -1
  1235. package/src/resources/extensions/gsd/commands-config.ts +3 -2
  1236. package/src/resources/extensions/gsd/commands-debug.ts +27 -1
  1237. package/src/resources/extensions/gsd/commands-eval-review.ts +716 -0
  1238. package/src/resources/extensions/gsd/commands-extensions.ts +47 -7
  1239. package/src/resources/extensions/gsd/commands-handlers.ts +8 -7
  1240. package/src/resources/extensions/gsd/commands-logs.ts +2 -1
  1241. package/src/resources/extensions/gsd/commands-mcp-status.ts +3 -1
  1242. package/src/resources/extensions/gsd/commands-prefs-wizard.ts +15 -1
  1243. package/src/resources/extensions/gsd/commands-scan.ts +2 -1
  1244. package/src/resources/extensions/gsd/commands-ship.ts +101 -1
  1245. package/src/resources/extensions/gsd/commands-workflow-templates.ts +5 -4
  1246. package/src/resources/extensions/gsd/commands-worktree.ts +383 -0
  1247. package/src/resources/extensions/gsd/context-budget.ts +13 -2
  1248. package/src/resources/extensions/gsd/crash-recovery.ts +177 -43
  1249. package/src/resources/extensions/gsd/dashboard-overlay.ts +1 -1
  1250. package/src/resources/extensions/gsd/db/auto-workers.ts +273 -0
  1251. package/src/resources/extensions/gsd/db/command-queue.ts +149 -0
  1252. package/src/resources/extensions/gsd/db/milestone-leases.ts +274 -0
  1253. package/src/resources/extensions/gsd/db/runtime-kv.ts +127 -0
  1254. package/src/resources/extensions/gsd/db/unit-dispatches.ts +446 -0
  1255. package/src/resources/extensions/gsd/db-writer.ts +169 -89
  1256. package/src/resources/extensions/gsd/deep-project-setup-policy.ts +257 -0
  1257. package/src/resources/extensions/gsd/delegation-policy.ts +197 -0
  1258. package/src/resources/extensions/gsd/detection.ts +7 -7
  1259. package/src/resources/extensions/gsd/dispatch-guard.ts +6 -11
  1260. package/src/resources/extensions/gsd/docs/COORDINATION.md +42 -0
  1261. package/src/resources/extensions/gsd/docs/preferences-reference.md +16 -4
  1262. package/src/resources/extensions/gsd/doctor-engine-checks.ts +2 -2
  1263. package/src/resources/extensions/gsd/doctor-proactive.ts +4 -0
  1264. package/src/resources/extensions/gsd/doctor-providers.ts +2 -1
  1265. package/src/resources/extensions/gsd/doctor-runtime-checks.ts +116 -7
  1266. package/src/resources/extensions/gsd/doctor-types.ts +4 -1
  1267. package/src/resources/extensions/gsd/doctor.ts +10 -2
  1268. package/src/resources/extensions/gsd/error-classifier.ts +1 -1
  1269. package/src/resources/extensions/gsd/eval-review-schema.ts +243 -0
  1270. package/src/resources/extensions/gsd/forensics.ts +19 -8
  1271. package/src/resources/extensions/gsd/git-service.ts +94 -8
  1272. package/src/resources/extensions/gsd/gsd-db.ts +453 -14
  1273. package/src/resources/extensions/gsd/gsd-home.ts +30 -0
  1274. package/src/resources/extensions/gsd/guided-flow-queue.ts +1 -1
  1275. package/src/resources/extensions/gsd/guided-flow.ts +525 -143
  1276. package/src/resources/extensions/gsd/init-wizard.ts +17 -20
  1277. package/src/resources/extensions/gsd/interrupted-session.ts +50 -6
  1278. package/src/resources/extensions/gsd/journal.ts +4 -1
  1279. package/src/resources/extensions/gsd/key-manager.ts +2 -1
  1280. package/src/resources/extensions/gsd/markdown-renderer.ts +58 -79
  1281. package/src/resources/extensions/gsd/memory-store.ts +81 -28
  1282. package/src/resources/extensions/gsd/metrics.ts +321 -1
  1283. package/src/resources/extensions/gsd/migrate/command.ts +3 -2
  1284. package/src/resources/extensions/gsd/milestone-id-reservation.ts +47 -0
  1285. package/src/resources/extensions/gsd/milestone-scope-classifier.ts +15 -8
  1286. package/src/resources/extensions/gsd/model-router.ts +172 -9
  1287. package/src/resources/extensions/gsd/native-git-bridge.ts +26 -42
  1288. package/src/resources/extensions/gsd/onboarding-state.ts +2 -2
  1289. package/src/resources/extensions/gsd/parallel-merge.ts +14 -13
  1290. package/src/resources/extensions/gsd/parallel-monitor-overlay.ts +5 -2
  1291. package/src/resources/extensions/gsd/paths.ts +158 -9
  1292. package/src/resources/extensions/gsd/planning-depth.ts +137 -0
  1293. package/src/resources/extensions/gsd/preferences-models.ts +119 -16
  1294. package/src/resources/extensions/gsd/preferences-skills.ts +2 -1
  1295. package/src/resources/extensions/gsd/preferences-types.ts +17 -0
  1296. package/src/resources/extensions/gsd/preferences-validation.ts +44 -0
  1297. package/src/resources/extensions/gsd/preferences.ts +42 -7
  1298. package/src/resources/extensions/gsd/project-research-policy.ts +259 -0
  1299. package/src/resources/extensions/gsd/prompt-loader.ts +28 -15
  1300. package/src/resources/extensions/gsd/prompts/complete-milestone.md +10 -0
  1301. package/src/resources/extensions/gsd/prompts/complete-slice.md +14 -4
  1302. package/src/resources/extensions/gsd/prompts/execute-task.md +3 -3
  1303. package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +10 -1
  1304. package/src/resources/extensions/gsd/prompts/guided-discuss-project.md +148 -0
  1305. package/src/resources/extensions/gsd/prompts/guided-discuss-requirements.md +126 -0
  1306. package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +8 -1
  1307. package/src/resources/extensions/gsd/prompts/guided-research-decision.md +70 -0
  1308. package/src/resources/extensions/gsd/prompts/guided-research-project.md +120 -0
  1309. package/src/resources/extensions/gsd/prompts/guided-workflow-preferences.md +68 -0
  1310. package/src/resources/extensions/gsd/prompts/parallel-research-slices.md +2 -0
  1311. package/src/resources/extensions/gsd/prompts/plan-milestone.md +8 -2
  1312. package/src/resources/extensions/gsd/prompts/plan-slice.md +18 -6
  1313. package/src/resources/extensions/gsd/prompts/refine-slice.md +10 -0
  1314. package/src/resources/extensions/gsd/prompts/rewrite-docs.md +2 -0
  1315. package/src/resources/extensions/gsd/prompts/system.md +4 -4
  1316. package/src/resources/extensions/gsd/queue-order.ts +6 -1
  1317. package/src/resources/extensions/gsd/repo-identity.ts +15 -9
  1318. package/src/resources/extensions/gsd/rethink.ts +2 -1
  1319. package/src/resources/extensions/gsd/safety/git-checkpoint.ts +10 -1
  1320. package/src/resources/extensions/gsd/schemas/__fixtures__/valid-project.md +26 -0
  1321. package/src/resources/extensions/gsd/schemas/__fixtures__/valid-requirements.md +57 -0
  1322. package/src/resources/extensions/gsd/schemas/__fixtures__/valid-roadmap.md +19 -0
  1323. package/src/resources/extensions/gsd/schemas/parsers.ts +346 -0
  1324. package/src/resources/extensions/gsd/schemas/validate.ts +452 -0
  1325. package/src/resources/extensions/gsd/skill-telemetry.ts +3 -2
  1326. package/src/resources/extensions/gsd/slice-cadence.ts +71 -6
  1327. package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +9 -3
  1328. package/src/resources/extensions/gsd/state.ts +176 -394
  1329. package/src/resources/extensions/gsd/templates/PREFERENCES.md +1 -0
  1330. package/src/resources/extensions/gsd/templates/project.md +10 -0
  1331. package/src/resources/extensions/gsd/tests/artifact-corruption-2630.test.ts +1 -0
  1332. package/src/resources/extensions/gsd/tests/artifact-validators.test.ts +524 -0
  1333. package/src/resources/extensions/gsd/tests/auto-dashboard.test.ts +20 -0
  1334. package/src/resources/extensions/gsd/tests/auto-discuss-milestone-deadlock-4973.test.ts +42 -17
  1335. package/src/resources/extensions/gsd/tests/auto-loop-no-copy-artifacts.test.ts +72 -0
  1336. package/src/resources/extensions/gsd/tests/auto-loop-symlink-worktree.test.ts +190 -0
  1337. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +274 -30
  1338. package/src/resources/extensions/gsd/tests/auto-paused-session-validation.test.ts +6 -0
  1339. package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +58 -0
  1340. package/src/resources/extensions/gsd/tests/auto-remediate-slice-status.test.ts +21 -34
  1341. package/src/resources/extensions/gsd/tests/auto-session-encapsulation.test.ts +24 -5
  1342. package/src/resources/extensions/gsd/tests/auto-session-scope.test.ts +331 -0
  1343. package/src/resources/extensions/gsd/tests/auto-start-clean-runtime-db-gated.test.ts +32 -1
  1344. package/src/resources/extensions/gsd/tests/auto-start-index-lock.test.ts +38 -0
  1345. package/src/resources/extensions/gsd/tests/auto-supervisor.test.mjs +21 -4
  1346. package/src/resources/extensions/gsd/tests/auto-workers.test.ts +105 -0
  1347. package/src/resources/extensions/gsd/tests/auto-worktree-registry.test.ts +176 -0
  1348. package/src/resources/extensions/gsd/tests/auto-wrapup-inflight-guard.test.ts +56 -0
  1349. package/src/resources/extensions/gsd/tests/bootstrap-derive-state-db-open.test.ts +1 -1
  1350. package/src/resources/extensions/gsd/tests/budget-prediction.test.ts +138 -211
  1351. package/src/resources/extensions/gsd/tests/bundled-skill-triggers.test.ts +50 -27
  1352. package/src/resources/extensions/gsd/tests/command-queue.test.ts +141 -0
  1353. package/src/resources/extensions/gsd/tests/commands-eval-review.test.ts +612 -0
  1354. package/src/resources/extensions/gsd/tests/commands-extensions-version-compare.test.ts +58 -0
  1355. package/src/resources/extensions/gsd/tests/commands-ship-eval-warn.test.ts +155 -0
  1356. package/src/resources/extensions/gsd/tests/commands-worktree-clean.test.ts +48 -0
  1357. package/src/resources/extensions/gsd/tests/complete-slice-verification-gate.test.ts +142 -59
  1358. package/src/resources/extensions/gsd/tests/complete-slice.test.ts +7 -4
  1359. package/src/resources/extensions/gsd/tests/complete-task-rollback-evidence.test.ts +6 -7
  1360. package/src/resources/extensions/gsd/tests/complete-task.test.ts +8 -6
  1361. package/src/resources/extensions/gsd/tests/completed-at-reconcile.test.ts +76 -34
  1362. package/src/resources/extensions/gsd/tests/completed-units-metrics-sync.test.ts +18 -5
  1363. package/src/resources/extensions/gsd/tests/context-budget.test.ts +28 -0
  1364. package/src/resources/extensions/gsd/tests/crash-recovery-via-db.test.ts +203 -0
  1365. package/src/resources/extensions/gsd/tests/crash-recovery.test.ts +191 -31
  1366. package/src/resources/extensions/gsd/tests/custom-engine-loop-integration.test.ts +42 -23
  1367. package/src/resources/extensions/gsd/tests/db-path-worktree-symlink.test.ts +7 -47
  1368. package/src/resources/extensions/gsd/tests/db-writer-path-containment.test.ts +152 -0
  1369. package/src/resources/extensions/gsd/tests/db-writer-root-artifact.test.ts +221 -0
  1370. package/src/resources/extensions/gsd/tests/db-writer-scope.test.ts +230 -0
  1371. package/src/resources/extensions/gsd/tests/db-writer.test.ts +165 -21
  1372. package/src/resources/extensions/gsd/tests/debug-command-handler.test.ts +37 -0
  1373. package/src/resources/extensions/gsd/tests/debug-logger.test.ts +5 -3
  1374. package/src/resources/extensions/gsd/tests/deep-mode-integration.test.ts +406 -0
  1375. package/src/resources/extensions/gsd/tests/deep-planning-mode-dispatch.test.ts +881 -0
  1376. package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +1562 -0
  1377. package/src/resources/extensions/gsd/tests/deep-project-setup-policy.test.ts +193 -0
  1378. package/src/resources/extensions/gsd/tests/deferred-milestone-dir-4996.test.ts +116 -0
  1379. package/src/resources/extensions/gsd/tests/delegation-policy.test.ts +151 -0
  1380. package/src/resources/extensions/gsd/tests/derive-state-crossval.test.ts +6 -5
  1381. package/src/resources/extensions/gsd/tests/derive-state-db-disk-reconcile.test.ts +10 -38
  1382. package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +136 -56
  1383. package/src/resources/extensions/gsd/tests/derive-state-draft.test.ts +3 -0
  1384. package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +119 -61
  1385. package/src/resources/extensions/gsd/tests/derive-state.test.ts +4 -0
  1386. package/src/resources/extensions/gsd/tests/detect-stuck-respects-retry.test.ts +173 -0
  1387. package/src/resources/extensions/gsd/tests/discuss-empty-db-fallback.test.ts +22 -87
  1388. package/src/resources/extensions/gsd/tests/discuss-queued-milestones.test.ts +7 -118
  1389. package/src/resources/extensions/gsd/tests/discuss-tool-scope-leak.test.ts +18 -60
  1390. package/src/resources/extensions/gsd/tests/dispatch-backgroundable-annotation.test.ts +55 -0
  1391. package/src/resources/extensions/gsd/tests/dispatch-complete-milestone-guard.test.ts +6 -20
  1392. package/src/resources/extensions/gsd/tests/dispatch-guard.test.ts +4 -5
  1393. package/src/resources/extensions/gsd/tests/dispatcher-stuck-planning.test.ts +14 -15
  1394. package/src/resources/extensions/gsd/tests/doctor-orphan-milestone-4996.test.ts +100 -0
  1395. package/src/resources/extensions/gsd/tests/double-merge-guard.test.ts +14 -76
  1396. package/src/resources/extensions/gsd/tests/draft-promotion.test.ts +3 -23
  1397. package/src/resources/extensions/gsd/tests/ensure-db-open.test.ts +11 -16
  1398. package/src/resources/extensions/gsd/tests/ensure-preconditions-guard-4996.test.ts +93 -0
  1399. package/src/resources/extensions/gsd/tests/escalation.test.ts +2 -1
  1400. package/src/resources/extensions/gsd/tests/eval-review-schema.test.ts +282 -0
  1401. package/src/resources/extensions/gsd/tests/false-degraded-mode-warning.test.ts +22 -83
  1402. package/src/resources/extensions/gsd/tests/finalize-timeout-guard.test.ts +1 -63
  1403. package/src/resources/extensions/gsd/tests/find-missing-summaries-closed-runtime.test.ts +47 -0
  1404. package/src/resources/extensions/gsd/tests/forensics-stuck-loops.test.ts +26 -1
  1405. package/src/resources/extensions/gsd/tests/gate-1b-orphan-discrimination.test.ts +193 -0
  1406. package/src/resources/extensions/gsd/tests/gate-1b-recovery-bound-corrections.test.ts +246 -0
  1407. package/src/resources/extensions/gsd/tests/gate-1b-recovery-bound.test.ts +218 -0
  1408. package/src/resources/extensions/gsd/tests/git-checkpoint.test.ts +9 -0
  1409. package/src/resources/extensions/gsd/tests/gitignore-bg-shell-runtime.test.ts +63 -0
  1410. package/src/resources/extensions/gsd/tests/google-search-stub.test.ts +25 -65
  1411. package/src/resources/extensions/gsd/tests/gsd-db-failed-open-restore.test.ts +117 -0
  1412. package/src/resources/extensions/gsd/tests/gsd-db-workspace-scope.test.ts +226 -0
  1413. package/src/resources/extensions/gsd/tests/gsd-db.test.ts +32 -1
  1414. package/src/resources/extensions/gsd/tests/gsd-home.test.ts +43 -0
  1415. package/src/resources/extensions/gsd/tests/gsd-no-project-error-runtime.test.ts +95 -0
  1416. package/src/resources/extensions/gsd/tests/gsd-root-canonical.test.ts +66 -0
  1417. package/src/resources/extensions/gsd/tests/gsd-root-home-guard.test.ts +149 -0
  1418. package/src/resources/extensions/gsd/tests/gsdroot-worktree-detection.test.ts +15 -36
  1419. package/src/resources/extensions/gsd/tests/guided-flow-prompt-consolidation.test.ts +133 -0
  1420. package/src/resources/extensions/gsd/tests/handler-worktree-write-isolation.test.ts +57 -0
  1421. package/src/resources/extensions/gsd/tests/has-pending-deep-stage.test.ts +98 -0
  1422. package/src/resources/extensions/gsd/tests/headless-answers.test.ts +14 -4
  1423. package/src/resources/extensions/gsd/tests/health-widget.test.ts +22 -12
  1424. package/src/resources/extensions/gsd/tests/help-menu-coverage.test.ts +57 -0
  1425. package/src/resources/extensions/gsd/tests/import-done-milestones-runtime.test.ts +145 -0
  1426. package/src/resources/extensions/gsd/tests/init-prefs-routing.test.ts +64 -1
  1427. package/src/resources/extensions/gsd/tests/init-skip-git.test.ts +19 -0
  1428. package/src/resources/extensions/gsd/tests/init-wizard.test.ts +17 -0
  1429. package/src/resources/extensions/gsd/tests/integration/auto-worktree.test.ts +93 -11
  1430. package/src/resources/extensions/gsd/tests/integration/commands-eval-review.integration.test.ts +254 -0
  1431. package/src/resources/extensions/gsd/tests/integration/doctor-proactive.test.ts +24 -10
  1432. package/src/resources/extensions/gsd/tests/integration/doctor-runtime.test.ts +75 -23
  1433. package/src/resources/extensions/gsd/tests/integration/git-service.test.ts +42 -0
  1434. package/src/resources/extensions/gsd/tests/integration/parallel-merge.test.ts +15 -15
  1435. package/src/resources/extensions/gsd/tests/integration/state-machine-edge-cases.test.ts +15 -5
  1436. package/src/resources/extensions/gsd/tests/integration/token-savings.test.ts +0 -23
  1437. package/src/resources/extensions/gsd/tests/integration/workspace-collapse-integration.test.ts +369 -0
  1438. package/src/resources/extensions/gsd/tests/interrupted-session-auto.test.ts +72 -25
  1439. package/src/resources/extensions/gsd/tests/interrupted-session-ui.test.ts +72 -25
  1440. package/src/resources/extensions/gsd/tests/journal-integration.test.ts +124 -7
  1441. package/src/resources/extensions/gsd/tests/markdown-renderer.test.ts +84 -9
  1442. package/src/resources/extensions/gsd/tests/md-importer.test.ts +2 -1
  1443. package/src/resources/extensions/gsd/tests/memory-pressure-stuck-state.test.ts +9 -6
  1444. package/src/resources/extensions/gsd/tests/memory-store.test.ts +131 -2
  1445. package/src/resources/extensions/gsd/tests/memory-tools.test.ts +33 -1
  1446. package/src/resources/extensions/gsd/tests/merge-self-branch-guard.test.ts +124 -0
  1447. package/src/resources/extensions/gsd/tests/metrics-atomic-merge.test.ts +222 -0
  1448. package/src/resources/extensions/gsd/tests/metrics-lock-hardening.test.ts +400 -0
  1449. package/src/resources/extensions/gsd/tests/metrics-lock-not-acquired.test.ts +141 -0
  1450. package/src/resources/extensions/gsd/tests/metrics-lock-retry-sleep.test.ts +287 -0
  1451. package/src/resources/extensions/gsd/tests/metrics-prune-cache-invalidation.test.ts +149 -0
  1452. package/src/resources/extensions/gsd/tests/metrics-scope.test.ts +378 -0
  1453. package/src/resources/extensions/gsd/tests/milestone-id-gap-reuse-4996.test.ts +152 -0
  1454. package/src/resources/extensions/gsd/tests/milestone-leases.test.ts +152 -0
  1455. package/src/resources/extensions/gsd/tests/milestone-report-path.test.ts +18 -1
  1456. package/src/resources/extensions/gsd/tests/milestone-scope-classifier.test.ts +19 -0
  1457. package/src/resources/extensions/gsd/tests/model-router.test.ts +169 -8
  1458. package/src/resources/extensions/gsd/tests/model-unittype-mapping.test.ts +19 -0
  1459. package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +22 -2
  1460. package/src/resources/extensions/gsd/tests/native-git-infra-errors.test.ts +50 -0
  1461. package/src/resources/extensions/gsd/tests/none-mode-gates.test.ts +51 -3
  1462. package/src/resources/extensions/gsd/tests/originalbase-path-comparison.test.ts +329 -0
  1463. package/src/resources/extensions/gsd/tests/orphaned-worktree-audit.test.ts +8 -0
  1464. package/src/resources/extensions/gsd/tests/parallel-crash-recovery.test.ts +32 -43
  1465. package/src/resources/extensions/gsd/tests/parallel-milestone-isolation.test.ts +106 -0
  1466. package/src/resources/extensions/gsd/tests/park-milestone.test.ts +2 -0
  1467. package/src/resources/extensions/gsd/tests/path-cache-decoupled.test.ts +209 -0
  1468. package/src/resources/extensions/gsd/tests/path-normalization-unified.test.ts +175 -0
  1469. package/src/resources/extensions/gsd/tests/paths-cache.test.ts +170 -0
  1470. package/src/resources/extensions/gsd/tests/paused-session-via-db.test.ts +119 -0
  1471. package/src/resources/extensions/gsd/tests/pending-autostart-scope.test.ts +120 -0
  1472. package/src/resources/extensions/gsd/tests/phases-merge-error-stops-auto.test.ts +4 -10
  1473. package/src/resources/extensions/gsd/tests/pipeline-variant-dispatch.test.ts +58 -0
  1474. package/src/resources/extensions/gsd/tests/plan-milestone-artifact-verification.test.ts +40 -0
  1475. package/src/resources/extensions/gsd/tests/plan-slice-prompt.test.ts +0 -43
  1476. package/src/resources/extensions/gsd/tests/plan-slice.test.ts +33 -0
  1477. package/src/resources/extensions/gsd/tests/planning-depth-setter.test.ts +172 -0
  1478. package/src/resources/extensions/gsd/tests/post-unit-git-failure.test.ts +18 -0
  1479. package/src/resources/extensions/gsd/tests/preferences-worktree-sync.test.ts +3 -17
  1480. package/src/resources/extensions/gsd/tests/preferences.test.ts +199 -0
  1481. package/src/resources/extensions/gsd/tests/prefs-wizard-coverage.test.ts +1 -0
  1482. package/src/resources/extensions/gsd/tests/progressive-planning.test.ts +25 -16
  1483. package/src/resources/extensions/gsd/tests/project-root-cwd-crash.test.ts +4 -4
  1484. package/src/resources/extensions/gsd/tests/projection-regression.test.ts +1 -0
  1485. package/src/resources/extensions/gsd/tests/prompt-budget-enforcement.test.ts +2 -2
  1486. package/src/resources/extensions/gsd/tests/prompt-contracts.test.ts +232 -28
  1487. package/src/resources/extensions/gsd/tests/prompt-step-ordering.test.ts +16 -0
  1488. package/src/resources/extensions/gsd/tests/provider-errors.test.ts +7 -0
  1489. package/src/resources/extensions/gsd/tests/quality-gates.test.ts +7 -16
  1490. package/src/resources/extensions/gsd/tests/quick-turn-end-cleanup.test.ts +6 -6
  1491. package/src/resources/extensions/gsd/tests/ready-phrase-no-files-4573.test.ts +267 -0
  1492. package/src/resources/extensions/gsd/tests/register-hooks-compaction-checkpoint.test.ts +98 -0
  1493. package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +286 -8
  1494. package/src/resources/extensions/gsd/tests/replan-slice.test.ts +3 -0
  1495. package/src/resources/extensions/gsd/tests/resolve-ts.mjs +4 -0
  1496. package/src/resources/extensions/gsd/tests/resume-missing-worktree-warning.test.ts +209 -0
  1497. package/src/resources/extensions/gsd/tests/rogue-file-detection.test.ts +3 -4
  1498. package/src/resources/extensions/gsd/tests/runtime-kv.test.ts +120 -0
  1499. package/src/resources/extensions/gsd/tests/safety-harness-false-positives.test.ts +34 -0
  1500. package/src/resources/extensions/gsd/tests/session-start-footer.test.ts +168 -19
  1501. package/src/resources/extensions/gsd/tests/skipped-validation-completion.test.ts +133 -28
  1502. package/src/resources/extensions/gsd/tests/skipped-validation-db-atomicity.test.ts +17 -0
  1503. package/src/resources/extensions/gsd/tests/slice-cadence.test.ts +36 -0
  1504. package/src/resources/extensions/gsd/tests/slice-disk-reconcile.test.ts +10 -56
  1505. package/src/resources/extensions/gsd/tests/slice-parallel-orchestrator.test.ts +7 -1
  1506. package/src/resources/extensions/gsd/tests/smart-entry-complete.test.ts +23 -1
  1507. package/src/resources/extensions/gsd/tests/stale-slice-rows.test.ts +15 -16
  1508. package/src/resources/extensions/gsd/tests/start-auto-detached.test.ts +53 -0
  1509. package/src/resources/extensions/gsd/tests/stash-pop-gsd-conflict.test.ts +8 -2
  1510. package/src/resources/extensions/gsd/tests/stash-queued-context-files.test.ts +12 -6
  1511. package/src/resources/extensions/gsd/tests/state-corruption-2945.test.ts +1 -0
  1512. package/src/resources/extensions/gsd/tests/state-machine-full-walkthrough.test.ts +23 -27
  1513. package/src/resources/extensions/gsd/tests/steer-worktree-path.test.ts +30 -15
  1514. package/src/resources/extensions/gsd/tests/stuck-state-via-db.test.ts +134 -0
  1515. package/src/resources/extensions/gsd/tests/sync-layer-scope.test.ts +434 -0
  1516. package/src/resources/extensions/gsd/tests/sync-worktree-skip-current.test.ts +10 -33
  1517. package/src/resources/extensions/gsd/tests/system-context-message-routing.test.ts +101 -0
  1518. package/src/resources/extensions/gsd/tests/teardown-chdir-failure-clears-registry.test.ts +162 -0
  1519. package/src/resources/extensions/gsd/tests/teardown-cleanup-parity.test.ts +98 -0
  1520. package/src/resources/extensions/gsd/tests/teardown-failure-clears-registry.test.ts +186 -0
  1521. package/src/resources/extensions/gsd/tests/token-counter.test.ts +9 -0
  1522. package/src/resources/extensions/gsd/tests/token-profile.test.ts +51 -4
  1523. package/src/resources/extensions/gsd/tests/tool-invocation-error-loop-break.test.ts +1 -1
  1524. package/src/resources/extensions/gsd/tests/tool-param-optionality.test.ts +34 -0
  1525. package/src/resources/extensions/gsd/tests/turn-epoch.test.ts +7 -16
  1526. package/src/resources/extensions/gsd/tests/unit-context-manifest.test.ts +48 -3
  1527. package/src/resources/extensions/gsd/tests/unit-dispatches.test.ts +247 -0
  1528. package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +41 -0
  1529. package/src/resources/extensions/gsd/tests/unstructured-continue-context-injection.test.ts +5 -7
  1530. package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +15 -1
  1531. package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +48 -0
  1532. package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +7 -8
  1533. package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +50 -16
  1534. package/src/resources/extensions/gsd/tests/validator-scope-parity.test.ts +239 -0
  1535. package/src/resources/extensions/gsd/tests/verify-artifact-tightened.test.ts +52 -1
  1536. package/src/resources/extensions/gsd/tests/visualizer-overlay.test.ts +6 -6
  1537. package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +12 -7
  1538. package/src/resources/extensions/gsd/tests/workflow-mcp-auto-prep.test.ts +4 -4
  1539. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +83 -4
  1540. package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +241 -4
  1541. package/src/resources/extensions/gsd/tests/workspace.test.ts +196 -0
  1542. package/src/resources/extensions/gsd/tests/worktree-db-same-file.test.ts +13 -0
  1543. package/src/resources/extensions/gsd/tests/worktree-main-branch.test.ts +5 -0
  1544. package/src/resources/extensions/gsd/tests/worktree-path-injection.test.ts +236 -0
  1545. package/src/resources/extensions/gsd/tests/worktree-resolver.test.ts +103 -0
  1546. package/src/resources/extensions/gsd/tests/worktree-root-resolution.test.ts +50 -0
  1547. package/src/resources/extensions/gsd/tests/worktree-root.test.ts +69 -0
  1548. package/src/resources/extensions/gsd/tests/worktree-symlink-removal.test.ts +34 -33
  1549. package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +65 -71
  1550. package/src/resources/extensions/gsd/tests/worktree-sync-tasks.test.ts +26 -151
  1551. package/src/resources/extensions/gsd/tests/worktree.test.ts +8 -0
  1552. package/src/resources/extensions/gsd/tests/write-gate-planning-unit.test.ts +131 -1
  1553. package/src/resources/extensions/gsd/tests/write-gate-predicates.test.ts +43 -41
  1554. package/src/resources/extensions/gsd/tests/write-gate.test.ts +188 -57
  1555. package/src/resources/extensions/gsd/tests/write-intercept.test.ts +1 -1
  1556. package/src/resources/extensions/gsd/token-counter.ts +2 -1
  1557. package/src/resources/extensions/gsd/tools/complete-milestone.ts +7 -5
  1558. package/src/resources/extensions/gsd/tools/complete-slice.ts +7 -14
  1559. package/src/resources/extensions/gsd/tools/complete-task.ts +19 -34
  1560. package/src/resources/extensions/gsd/tools/memory-tools.ts +17 -1
  1561. package/src/resources/extensions/gsd/tools/plan-slice.ts +10 -9
  1562. package/src/resources/extensions/gsd/tools/validate-milestone.ts +7 -5
  1563. package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +81 -14
  1564. package/src/resources/extensions/gsd/unit-context-manifest.ts +141 -13
  1565. package/src/resources/extensions/gsd/unit-runtime.ts +76 -24
  1566. package/src/resources/extensions/gsd/uok/plan-v2.ts +19 -1
  1567. package/src/resources/extensions/gsd/user-input-boundary.ts +166 -0
  1568. package/src/resources/extensions/gsd/visualizer-overlay.ts +1 -1
  1569. package/src/resources/extensions/gsd/watch/header-renderer.ts +4 -1
  1570. package/src/resources/extensions/gsd/workflow-install.ts +2 -3
  1571. package/src/resources/extensions/gsd/workflow-logger.ts +1 -0
  1572. package/src/resources/extensions/gsd/workflow-manifest.ts +4 -1
  1573. package/src/resources/extensions/gsd/workflow-mcp-auto-prep.ts +2 -18
  1574. package/src/resources/extensions/gsd/workflow-mcp.ts +43 -6
  1575. package/src/resources/extensions/gsd/workflow-migration.ts +4 -3
  1576. package/src/resources/extensions/gsd/workflow-plugins.ts +4 -5
  1577. package/src/resources/extensions/gsd/workflow-reconcile.ts +3 -3
  1578. package/src/resources/extensions/gsd/workflow-templates.ts +2 -3
  1579. package/src/resources/extensions/gsd/workspace.ts +95 -0
  1580. package/src/resources/extensions/gsd/worktree-command.ts +35 -47
  1581. package/src/resources/extensions/gsd/worktree-manager.ts +46 -7
  1582. package/src/resources/extensions/gsd/worktree-resolver.ts +112 -22
  1583. package/src/resources/extensions/gsd/worktree-root.ts +182 -0
  1584. package/src/resources/extensions/gsd/worktree-session-state.ts +35 -0
  1585. package/src/resources/extensions/gsd/worktree.ts +8 -119
  1586. package/src/resources/extensions/gsd/write-intercept.ts +3 -3
  1587. package/src/resources/extensions/mcp-client/index.ts +6 -10
  1588. package/src/resources/extensions/mcp-client/tests/global-config.test.ts +91 -0
  1589. package/src/resources/extensions/ollama/index.ts +16 -2
  1590. package/src/resources/extensions/ollama/model-capabilities.ts +34 -0
  1591. package/src/resources/extensions/ollama/ollama-client.ts +41 -4
  1592. package/src/resources/extensions/ollama/tests/model-capabilities.test.ts +96 -0
  1593. package/src/resources/extensions/ollama/tests/ollama-client-timeout-env.test.ts +147 -0
  1594. package/src/resources/extensions/remote-questions/remote-command.ts +2 -1
  1595. package/src/resources/extensions/remote-questions/status.ts +2 -6
  1596. package/src/resources/extensions/remote-questions/store.ts +2 -6
  1597. package/src/resources/extensions/search-the-web/provider.ts +9 -8
  1598. package/src/resources/extensions/shared/next-action-ui.ts +8 -0
  1599. package/src/resources/extensions/shared/tests/next-action-ui-hasui.test.ts +112 -0
  1600. package/src/resources/extensions/slash-commands/create-extension.ts +38 -24
  1601. package/src/resources/extensions/subagent/index.ts +187 -16
  1602. package/src/resources/extensions/subagent/isolation.ts +2 -2
  1603. package/src/resources/extensions/subagent/tests/model-override.test.ts +55 -0
  1604. package/src/resources/extensions/ttsr/rule-loader.ts +2 -3
  1605. package/src/resources/extensions/voice/index.ts +3 -2
  1606. package/src/resources/extensions/voice/linux-ready.ts +2 -3
  1607. package/src/resources/skills/create-gsd-extension/SKILL.md +9 -5
  1608. package/src/resources/skills/create-gsd-extension/references/custom-commands.md +1 -1
  1609. package/src/resources/skills/create-gsd-extension/references/custom-rendering.md +5 -5
  1610. package/src/resources/skills/create-gsd-extension/references/custom-tools.md +4 -4
  1611. package/src/resources/skills/create-gsd-extension/references/custom-ui.md +6 -6
  1612. package/src/resources/skills/create-gsd-extension/references/events-reference.md +3 -3
  1613. package/src/resources/skills/create-gsd-extension/references/packaging-distribution.md +1 -1
  1614. package/src/resources/skills/create-gsd-extension/references/remote-execution-overrides.md +3 -3
  1615. package/src/resources/skills/create-gsd-extension/templates/extension-skeleton.ts +2 -2
  1616. package/src/resources/skills/create-gsd-extension/templates/stateful-tool-skeleton.ts +3 -3
  1617. package/src/resources/skills/create-gsd-extension/templates/templates.test.ts +58 -0
  1618. package/src/resources/skills/create-gsd-extension/workflows/create-extension.md +32 -12
  1619. package/src/resources/skills/lint/SKILL.md +4 -0
  1620. package/src/resources/skills/review/SKILL.md +4 -0
  1621. package/src/resources/skills/test/SKILL.md +3 -0
  1622. package/src/resources/skills/verify-before-complete/SKILL.md +1 -1
  1623. package/dist/resources/extensions/browser-tools/tests/browser-tools-integration.test.mjs +0 -601
  1624. package/dist/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +0 -651
  1625. package/dist/resources/extensions/browser-tools/tests/capture-sharp-optional.test.cjs +0 -91
  1626. package/dist/resources/extensions/gsd/auto-loop.js +0 -13
  1627. package/dist/resources/extensions/gsd/prompts/guided-complete-slice.md +0 -3
  1628. package/dist/resources/extensions/gsd/prompts/guided-execute-task.md +0 -3
  1629. package/dist/resources/extensions/gsd/prompts/guided-plan-milestone.md +0 -30
  1630. package/dist/resources/extensions/gsd/prompts/guided-plan-slice.md +0 -3
  1631. package/dist/resources/extensions/gsd/tests/auto-supervisor.test.mjs +0 -53
  1632. package/dist/resources/extensions/gsd/tests/dist-redirect.mjs +0 -112
  1633. package/dist/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +0 -23
  1634. package/dist/resources/extensions/gsd/tests/resolve-ts.mjs +0 -5
  1635. package/dist/resources/skills/github-workflows/references/gh/tests/__init__.py +0 -0
  1636. package/dist/resources/skills/github-workflows/references/gh/tests/test_github_project_setup.py +0 -608
  1637. package/dist/web/standalone/.next/server/chunks/1926.js +0 -1
  1638. package/dist/web/standalone/.next/server/edge-runtime-webpack.js +0 -2
  1639. package/dist/web/standalone/.next/static/chunks/2826.e9f5195e91f9cad2.js +0 -11
  1640. package/dist/web/standalone/.next/static/chunks/3621.fc7480022c972438.js +0 -20
  1641. package/dist/web/standalone/.next/static/chunks/363642f4.cf8b455e0d94b478.js +0 -1
  1642. package/dist/web/standalone/.next/static/chunks/5326.adc4bf49a22f4e67.js +0 -1
  1643. package/dist/web/standalone/.next/static/chunks/webpack-2e68521d7c82f7c2.js +0 -1
  1644. package/src/resources/extensions/gsd/auto-loop.ts +0 -16
  1645. package/src/resources/extensions/gsd/prompts/guided-complete-slice.md +0 -3
  1646. package/src/resources/extensions/gsd/prompts/guided-execute-task.md +0 -3
  1647. package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +0 -30
  1648. package/src/resources/extensions/gsd/prompts/guided-plan-slice.md +0 -3
  1649. package/src/resources/extensions/gsd/tests/auto-lock-creation.test.ts +0 -213
  1650. package/src/resources/extensions/gsd/tests/auto-stale-lock-self-kill.test.ts +0 -87
  1651. package/src/resources/extensions/gsd/tests/copy-planning-artifacts-samepath.test.ts +0 -22
  1652. package/src/resources/extensions/gsd/tests/discuss-slice-structured-questions.test.ts +0 -47
  1653. package/src/resources/extensions/gsd/tests/empty-content-abort-loop.test.ts +0 -75
  1654. package/src/resources/extensions/gsd/tests/stop-auto-remote.test.ts +0 -158
  1655. package/dist/web/standalone/.next/static/{7afp7gq8-DVbxum83zRQ- → J-CU-p_sp45CJHT3R9TJS}/_buildManifest.js +0 -0
  1656. package/dist/web/standalone/.next/static/{7afp7gq8-DVbxum83zRQ- → J-CU-p_sp45CJHT3R9TJS}/_ssgManifest.js +0 -0
  1657. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/at-rule.js +0 -0
  1658. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/comment.js +0 -0
  1659. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/declaration.js +4 -4
  1660. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/document.js +0 -0
  1661. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/fromJSON.js +3 -3
  1662. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/list.js +0 -0
  1663. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/parse.js +1 -1
  1664. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/postcss.js +12 -12
  1665. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/root.js +0 -0
  1666. package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/rule.js +6 -6
  1667. /package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/stringify.js +0 -0
  1668. /package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/symbols.js +0 -0
  1669. /package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/terminal-highlight.js +0 -0
  1670. /package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/warn-once.js +0 -0
  1671. /package/dist/web/standalone/node_modules/{next/node_modules/postcss → postcss}/lib/warning.js +0 -0
  1672. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/classes/comparator.js +0 -0
  1673. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/classes/range.js +0 -0
  1674. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/classes/semver.js +0 -0
  1675. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/cmp.js +0 -0
  1676. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/coerce.js +0 -0
  1677. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/compare.js +0 -0
  1678. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/eq.js +0 -0
  1679. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/gt.js +0 -0
  1680. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/gte.js +0 -0
  1681. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/lt.js +0 -0
  1682. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/lte.js +0 -0
  1683. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/neq.js +0 -0
  1684. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/parse.js +0 -0
  1685. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/functions/satisfies.js +0 -0
  1686. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/internal/constants.js +0 -0
  1687. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/internal/debug.js +0 -0
  1688. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/internal/identifiers.js +0 -0
  1689. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/internal/lrucache.js +0 -0
  1690. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/internal/parse-options.js +0 -0
  1691. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/internal/re.js +0 -0
  1692. /package/dist/web/standalone/node_modules/{semver → sharp/node_modules/semver}/package.json +0 -0
@@ -0,0 +1,10 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8336],{10654:(e,t,s)=>{function a(e,t){if(e.status)switch(e.status){case"complete":return"done";case"active":return"in-progress";case"pending":return"pending";case"parked":return"parked"}return e.slices.length>0&&e.slices.every(e=>e.done)?"done":t.milestoneId===e.id||e.slices.some(e=>e.done)?"in-progress":"pending"}function r(e,t,s){return t.done?"done":s.milestoneId===e&&s.sliceId===t.id?"in-progress":"pending"}function n(e,t,s,a){return s.done?"done":a.milestoneId===e&&a.sliceId===t&&a.taskId===s.id?"in-progress":"pending"}s.d(t,{Jq:()=>a,g$:()=>n,z3:()=>r})},12774:(e,t,s)=>{s.d(t,{Aw:()=>l,Wl:()=>n,wN:()=>r,zF:()=>o});let a=new Set(["image/jpeg","image/png","image/gif","image/webp"]),r=5;function n(e){if(!a.has(e.type)){let t=`Unsupported image type: ${e.type||"unknown"}. Accepted: JPEG, PNG, GIF, WebP.`;return console.warn("[image-utils] validation failed:",t),{valid:!1,error:t}}if(e.size>0x1400000){let t=(e.size/1048576).toFixed(1),s=`Image too large (${t} MB). Maximum: 20 MB.`;return console.warn("[image-utils] validation failed:",s),{valid:!1,error:s}}return{valid:!0}}async function i(e,t){var s,a;let r=.75*e.length;if(("image/gif"===t||"image/webp"===t)&&r<=4718592)return{data:e,mimeType:t};let n=await (s=e,a=t,new Promise((e,t)=>{let r=new Image;r.onload=()=>e(r),r.onerror=()=>t(Error("Failed to decode image")),r.src=`data:${a};base64,${s}`})),i=n.width>2e3||n.height>2e3;if(!i&&!(r>4718592))return{data:e,mimeType:t};let o="image/gif"===t||"image/webp"===t?"image/jpeg":t,l=n.width,d=n.height;if(i){let e=Math.min(2e3/n.width,2e3/n.height);l=Math.round(n.width*e),d=Math.round(n.height*e)}let c=document.createElement("canvas");c.width=l,c.height=d;let u=c.getContext("2d");if(!u)throw Error("Canvas 2D context not available");u.drawImage(n,0,0,l,d);let m=c.toDataURL(o,"image/jpeg"===o?.85:void 0).split(",")[1],h=.75*m.length;if(h>4718592)throw Error(`Image still exceeds 4.5 MB after resize (${(h/1048576).toFixed(1)} MB). Try a smaller image.`);return{data:m,mimeType:o}}async function o(e){let t=n(e);if(!t.valid)throw Error(t.error);return i(await new Promise((t,s)=>{let a=new FileReader;a.onload=()=>{let e=new Uint8Array(a.result),s="";for(let t=0;t<e.length;t++)s+=String.fromCharCode(e[t]);t(btoa(s))},a.onerror=()=>s(Error("Failed to read image file")),a.readAsArrayBuffer(e)}),e.type)}function l(){return`img-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}},15727:(e,t,s)=>{s.d(t,{d:()=>i});var a=s(12115);let r="gsd-editor-font-size",n="editor-font-size-changed";function i(){let[e,t]=(0,a.useState)(()=>{try{let e=localStorage.getItem(r);if(e){let t=Number(e);if(Number.isFinite(t)&&t>=8&&t<=24)return t}}catch{}return 14}),s=(0,a.useCallback)(e=>{let s=Math.max(8,Math.min(24,Math.round(e)));t(s);try{localStorage.setItem(r,String(s))}catch{}window.dispatchEvent(new CustomEvent(n,{detail:s}))},[]);return(0,a.useEffect)(()=>{let e=e=>{if(e.key!==r)return;let s=Number(e.newValue);Number.isFinite(s)&&s>=8&&s<=24&&t(s)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]),(0,a.useEffect)(()=>{let e=e=>{let s=e.detail;Number.isFinite(s)&&s>=8&&s<=24&&t(s)};return window.addEventListener(n,e),()=>window.removeEventListener(n,e)},[]),[e,s]}},22112:(e,t,s)=>{s.d(t,{Q8:()=>A,Qx:()=>R,Yc:()=>P,c0:()=>_,iE:()=>f,ll:()=>a,nU:()=>T,yC:()=>E});let a=["off","minimal","low","medium","high","xhigh"];function r(){return{phase:"idle",data:null,error:null,lastLoadedAt:null}}function n(){return{forensics:r(),doctor:{phase:"idle",data:null,error:null,lastLoadedAt:null,fixPending:!1,lastFixResult:null,lastFixError:null},skillHealth:r()}}function i(){return{knowledge:r(),captures:r(),resolveRequest:{pending:!1,lastError:null,lastResult:null}}}function o(){return{history:r(),inspect:r(),hooks:r(),exportData:r(),undo:r(),cleanup:r(),steer:r()}}let l=new Set(["settings","login","logout"]),d={set_steering_mode:"steeringMode",set_follow_up_mode:"followUpMode",set_auto_compaction:"autoCompaction",set_auto_retry:"autoRetry",abort_retry:"abortRetry"};function c(e={}){return{scope:null,projectCwd:null,projectSessionsDir:null,activeSessionPath:null,query:"",sortMode:"threaded",nameFilter:"all",totalSessions:0,returnedSessions:0,sessions:[],loaded:!1,error:null,...e}}function u(){return{pending:!1,sessionPath:null,result:null,error:null}}function m(){return{pending:!1,result:null,error:null}}function h(){return{steeringMode:m(),followUpMode:m(),autoCompaction:m(),autoRetry:m(),abortRetry:m()}}function x(){return{pending:!1,loaded:!1,result:null,error:null}}function p(){return{phase:"idle",pending:!1,loaded:!1,stale:!1,diagnostics:null,error:null,lastLoadedAt:null,lastInvalidatedAt:null,lastFailureAt:null}}function g(e){return a.includes(e??"")}function f(){return{open:!1,activeSurface:null,source:null,section:null,args:"",pendingAction:null,selectedTarget:null,lastError:null,lastResult:null,availableModels:[],forkMessages:[],sessionStats:null,lastCompaction:null,gitSummary:x(),recovery:p(),diagnostics:n(),knowledgeCaptures:i(),settingsData:r(),remainingCommands:o(),sessionBrowser:c(),resumeRequest:u(),renameRequest:u(),settingsRequests:h()}}function b(e){switch(e.surface){case"model":return"model";case"thinking":return"thinking";case"settings":return e.onboardingLocked?"auth":"general";case"git":return"git";case"login":case"logout":return"auth";case"resume":return"resume";case"name":return"name";case"fork":return"fork";case"session":case"export":return"session";case"compact":return"compact";case"gsd-status":return"gsd-status";case"gsd-visualize":return"gsd-visualize";case"gsd-forensics":return"gsd-forensics";case"gsd-doctor":return"gsd-doctor";case"gsd-skill-health":return"gsd-skill-health";case"gsd-knowledge":return"gsd-knowledge";case"gsd-capture":return"gsd-capture";case"gsd-triage":return"gsd-triage";case"gsd-quick":return"gsd-quick";case"gsd-history":return"gsd-history";case"gsd-undo":return"gsd-undo";case"gsd-inspect":return"gsd-inspect";case"gsd-prefs":return"gsd-prefs";case"gsd-config":return"gsd-config";case"gsd-hooks":return"gsd-hooks";case"gsd-mode":return"gsd-mode";case"gsd-steer":return"gsd-steer";case"gsd-export":return"gsd-export";case"gsd-cleanup":return"gsd-cleanup";case"gsd-queue":return"gsd-queue";default:return null}}function v(e){return{kind:"settings",section:e}}function j(e){let t=e.args?.trim()||void 0;return{kind:"model",provider:e.currentModel?.provider,modelId:e.currentModel?.modelId,query:t}}function y(e){let t=e.args?.trim().toLowerCase()||"";return{kind:"thinking",level:g(t)?t:g(e.currentThinkingLevel)?e.currentThinkingLevel:"off"}}function w(e){return{kind:"auth",providerId:(e.args?.trim()||void 0)??e.preferredProviderId??void 0,intent:"login"===e.surface?"login":"logout"===e.surface?"logout":"manage"}}function N(e){return{kind:"resume",sessionPath:function(e,t){if(!e?.length)return;let s=t?.trim().toLowerCase();if(!s)return e.find(e=>!e.isActive)?.path??e[0]?.path;let a=e.find(e=>[e.id,e.name,e.path].filter(Boolean).map(e=>e.toLowerCase()).includes(s));return a?a.path:e.find(e=>[e.id,e.name,e.path].filter(Boolean).map(e=>e.toLowerCase()).some(e=>e.includes(s)))?.path}(e.resumableSessions,e.args)}}function S(e){return{kind:"fork",entryId:e.args?.trim()||void 0}}function k(e){return{kind:"session",outputPath:e.args?.trim()||void 0}}function C(e){return{kind:"compact",customInstructions:e.args?.trim()??""}}function A(e,t){let s,a=b(t);return{...e,open:!0,activeSurface:t.surface,source:t.source,section:a,args:t.args?.trim()??"",pendingAction:null,selectedTarget:function(e){if(void 0!==e.selectedTarget)return e.selectedTarget;let t=b(e);if(!t)return null;if("settings"===e.surface)return v(t);if("model"===e.surface)return j(e);if("thinking"===e.surface)return y(e);if(l.has(e.surface))return w(e);if("resume"===e.surface)return N(e);if("name"===e.surface){let t;return t=e.args?.trim(),{kind:"name",sessionPath:e.currentSessionPath??void 0,name:void 0!==t&&t.length>0?t:e.currentSessionName?.trim()??""}}if("fork"===e.surface)return S(e);if("session"===e.surface||"export"===e.surface)return k(e);if("compact"===e.surface)return C(e);if(e.surface?.startsWith("gsd-")){let t=e.surface.slice(4);return{kind:"gsd",surface:e.surface,subcommand:t,args:e.args??""}}return v(t)}(t),lastError:null,lastResult:null,sessionStats:null,forkMessages:[],lastCompaction:null,gitSummary:x(),recovery:p(),diagnostics:n(),knowledgeCaptures:i(),settingsData:r(),remainingCommands:o(),sessionBrowser:(s="resume"===t.surface?t.args?.trim()??"":"",c({activeSessionPath:t.currentSessionPath??null,projectCwd:t.projectCwd??null,projectSessionsDir:t.projectSessionsDir??null,query:s,sortMode:s?"relevance":"threaded"})),resumeRequest:u(),renameRequest:u(),settingsRequests:h()}}function R(e){return{...e,open:!1,pendingAction:null}}function _(e,t,s={}){let a={surface:e.activeSurface??"settings",source:e.source??"surface",args:e.args,...s},r=e.selectedTarget?.kind==="resume"||e.selectedTarget?.kind==="name"?e.selectedTarget.sessionPath:void 0,n=e.selectedTarget?.kind==="name"?e.selectedTarget.name:void 0,i=e.selectedTarget;return"model"===t?i=j(a):"thinking"===t?i=y(a):"general"===t||"session-behavior"===t||"queue"===t||"compaction"===t||"retry"===t||"recovery"===t||"git"===t||"admin"===t?i=v(t):"auth"===t?i=w({...a,surface:"logout"===e.activeSurface?"logout":"login"===e.activeSurface?"login":"settings"}):"resume"===t?i={kind:"resume",sessionPath:r??N(a).sessionPath}:"name"===t?i={kind:"name",sessionPath:r??a.currentSessionPath??void 0,name:n??a.currentSessionName?.trim()??""}:"fork"===t?i=S(a):"session"===t?i=k(a):"compact"===t&&(i=C(a)),{...e,section:t,selectedTarget:i}}function T(e,t){let s="settings"===t.kind?t.section:"model"===t.kind?"model":"thinking"===t.kind?"thinking":"auth"===t.kind?"auth":"resume"===t.kind?"resume":"name"===t.kind?"name":"fork"===t.kind?"fork":"session"===t.kind?"session":"compact";return{...e,section:s,selectedTarget:t,lastError:null,lastResult:null}}function P(e,t,s=e.selectedTarget){let a="switch_session"===t?{pending:!0,sessionPath:s?.kind==="resume"?s.sessionPath??null:null,result:null,error:null}:e.resumeRequest,r="rename_session"===t?{pending:!0,sessionPath:s?.kind==="name"?s.sessionPath??null:null,result:null,error:null}:e.renameRequest,n=d[t],i=n?{...e.settingsRequests,[n]:{pending:!0,result:null,error:null}}:e.settingsRequests;return{...e,pendingAction:t,selectedTarget:s,lastError:null,lastResult:null,gitSummary:"load_git_summary"===t?{...e.gitSummary,pending:!0,error:null}:e.gitSummary,recovery:"load_recovery_diagnostics"===t?{...e.recovery,pending:!0,error:null,phase:e.recovery.loaded?e.recovery.phase:"loading"}:e.recovery,sessionBrowser:"load_session_browser"===t?{...e.sessionBrowser,error:null}:e.sessionBrowser,resumeRequest:a,renameRequest:r,settingsRequests:i}}function E(e,t){let s=void 0===t.selectedTarget?e.selectedTarget:t.selectedTarget,a=(s?.kind==="resume"?s.sessionPath:void 0)??e.resumeRequest.sessionPath,r=(s?.kind==="name"?s.sessionPath:void 0)??e.renameRequest.sessionPath,n=d[t.action],i=n?{...e.settingsRequests,[n]:{pending:!1,result:t.success?t.message:null,error:t.success?null:t.message}}:e.settingsRequests;return{...e,pendingAction:null,selectedTarget:s,availableModels:t.availableModels??e.availableModels,forkMessages:t.forkMessages??e.forkMessages,sessionStats:void 0===t.sessionStats?e.sessionStats:t.sessionStats,lastCompaction:void 0===t.lastCompaction?e.lastCompaction:t.lastCompaction,gitSummary:void 0===t.gitSummary?e.gitSummary:{...t.gitSummary,pending:!1,loaded:t.gitSummary.loaded||t.success},recovery:t.recovery??e.recovery,sessionBrowser:t.sessionBrowser??e.sessionBrowser,resumeRequest:"switch_session"===t.action?{pending:!1,sessionPath:a??null,result:t.success?t.message:null,error:t.success?null:t.message}:e.resumeRequest,renameRequest:"rename_session"===t.action?{pending:!1,sessionPath:r??null,result:t.success?t.message:null,error:t.success?null:t.message}:e.renameRequest,settingsRequests:i,lastError:t.success?null:t.message,lastResult:t.success?t.message:null}}},23217:(e,t,s)=>{s.d(t,{WT:()=>n,fl:()=>i,k8:()=>r});var a=s(33439);function r(e){window.dispatchEvent(new CustomEvent("gsd:navigate-view",{detail:{view:e}}))}function n({dispatch:e}){e().catch(e=>{console.error("[workflow-action] dispatch failed:",e)}),r("vibe-coder"===(0,a.B3)()?"chat":"power")}function i({commandInFlight:e,terminalLines:t}){if(!e)return null;for(let e=t.length-1;e>=0;e-=1){let s=t[e];if("input"!==s.type)continue;let a=s.content.trim();if(a)return a}return"prompt"===e?"Sending command":`/${e}`}},33439:(e,t,s)=>{s.d(t,{B3:()=>c,s1:()=>u});var a=s(12115);let r="gsd-user-mode",n="expert",i=new Set;function o(e){return i.add(e),()=>{i.delete(e)}}function l(){let e=localStorage.getItem(r);return"expert"===e||"vibe-coder"===e?e:n}function d(){return n}function c(){return l()}function u(){return[(0,a.useSyncExternalStore)(o,l,d),(0,a.useCallback)(e=>{localStorage.setItem(r,e),i.forEach(e=>e())},[])]}},35082:(e,t,s)=>{s.d(t,{QT:()=>o,c4:()=>n,tm:()=>i});let a="gsd-auth-token",r=null;function n(){if(null!==r)return r;let e=window.location.hash;if(e){let t=e.match(/token=([a-fA-F0-9]+)/);if(t){r=t[1];try{localStorage.setItem(a,r)}catch{}return window.history.replaceState(null,"",window.location.pathname+window.location.search),r}}try{let e=localStorage.getItem(a);if(e)return r=e}catch{}return null}async function i(e,t){let s=n();if(!s)return new Response(JSON.stringify({error:"No auth token available"}),{status:401,headers:{"Content-Type":"application/json"}});let a=new Headers(t?.headers);return a.has("Authorization")||a.set("Authorization",`Bearer ${s}`),fetch(e,{...t,headers:a})}function o(e){let t=n();if(!t)return e;let s=e.includes("?")?"&":"?";return`${e}${s}_token=${t}`}window.addEventListener("storage",e=>{e.key===a&&e.newValue&&(r=e.newValue)})},36371:(e,t,s)=>{s.d(t,{x:()=>C});var a=s(95155),r=s(12115),n=s(70460),i=s(6296),o=s(30234),l=s(13545),d=s(51914),c=s(42804),u=s(33210),m=s(91337),h=s(12774);let x=/Get Shit Done v\d+\.\d+\.\d+/i;function p(e,t){if(0===t)return 0;let s=0;for(let a=0;a<e.length;a+=1)if("\n"===e[a]&&(s+=1)===t)return a+1;return null}function g(e){return!e||0===e.trim().length}function f(e){return!!e&&/[█╔╗╚╝║═]/.test(e)}var b=s(43205),v=s(35082),j=s(96062);function y(e,t){if(!e||!t)return null;let s=e.getBoundingClientRect();return s.width<180||s.height<120||t.cols<20||t.rows<8?null:{cols:t.cols,rows:t.rows}}async function w(e,t,s,a){if("u">typeof document&&"fonts"in document)try{await Promise.race([document.fonts.ready,new Promise(e=>setTimeout(e,1e3))])}catch{}for(let r=0;r<12;r++){if(a()||(await new Promise(e=>{requestAnimationFrame(()=>e())}),a()))return null;try{s?.fit()}catch{}let r=y(e,t);if(r)return r;await new Promise(e=>setTimeout(e,50))}return y(e,t)}function N({sessionId:e,visible:t,command:n,commandArgs:o,isDark:l,fontSize:d,hideInitialGsdHeader:c=!1,projectCwd:u,onConnectionChange:h}){let y=(0,r.useRef)(null),S=(0,r.useRef)(null),k=(0,r.useRef)(null),C=(0,r.useRef)(null),A=(0,r.useRef)([]),R=(0,r.useRef)(!1),_=(0,r.useRef)(null),T=(0,r.useRef)(h),P=(0,r.useRef)(!c),E=(0,r.useRef)(""),I=(o??[]).join("\0"),[F,$]=(0,r.useState)(!1),L=(0,r.useCallback)((t,s)=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{(0,v.tm)((0,b.$)("/api/terminal/resize",u),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,cols:t,rows:s})})},100)},[u,e]),D=(0,r.useCallback)(async()=>{if(!R.current){for(R.current=!0;A.current.length>0;){let t=A.current.shift();try{let s=await (0,v.tm)((0,b.$)("/api/terminal/input",u),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,data:t})});if(!s.ok){s.status>=500&&A.current.unshift(t),T.current(!1),S.current?.writeln(`\r
2
+ Input failed (${s.status}). Reconnect the terminal and retry.`);break}}catch{A.current.unshift(t),T.current(!1);break}}R.current=!1}},[u,e]),M=(0,r.useCallback)(e=>{A.current.push(e),D()},[D]);(0,r.useEffect)(()=>{T.current=h},[h]),(0,r.useEffect)(()=>{P.current=!c,E.current=""},[c,e]),(0,r.useEffect)(()=>{S.current&&(S.current.options.theme=(0,j.E)(l))},[l]),(0,r.useEffect)(()=>{if(S.current){S.current.options.fontSize=d??13;try{k.current?.fit(),S.current&&L(S.current.cols,S.current.rows)}catch{}}},[d,L]),(0,r.useEffect)(()=>{if(t&&k.current&&S.current){let e=setTimeout(()=>{try{k.current?.fit(),S.current&&L(S.current.cols,S.current.rows)}catch{}},50);return()=>clearTimeout(e)}},[t,L]),(0,r.useEffect)(()=>{if(!y.current)return;let t=!1,a=null,r=null,i=null;return(async()=>{let[{Terminal:m},{FitAddon:h}]=await Promise.all([s.e(3888).then(s.bind(s,8422)),s.e(3606).then(s.bind(s,63606))]);if(t||(a=new m((0,j.d)(l,d)),r=new h,a.loadAddon(r),a.open(y.current),S.current=a,k.current=r,await w(y.current,a,r,()=>t),t))return;a.onData(e=>M(e)),a.onBinary(e=>M(e));let N=(0,b.Y)("/api/terminal/stream",window.location.origin,u);for(let t of(N.searchParams.set("id",e),n&&N.searchParams.set("command",n),o??[]))N.searchParams.append("arg",t);let A=new EventSource((0,v.QT)(N.toString()));C.current=A,A.onmessage=e=>{try{let s=JSON.parse(e.data);if("connected"===s.type)T.current(!0),w(y.current,a,r,()=>t).then(e=>{e&&L(e.cols,e.rows)});else if("output"===s.type&&s.data){let e=s.data;if(c&&!P.current){E.current+=e;let t=function(e){let{plainText:t,rawOffsetsByPlainIndex:s}=function(e){let t="",s=[0];for(let a=0;a<e.length;){let r=e[a];if("\x1b"===r){let t=e[a+1];if("["===t){for(a+=2;a<e.length&&!/[A-~]/.test(e[a]);)a+=1;a<e.length&&(a+=1);continue}if("]"===t){for(a+=2;a<e.length;){if("\x07"===e[a]){a+=1;break}if("\x1b"===e[a]&&"\\"===e[a+1]){a+=2;break}a+=1}continue}if("P"===t||"^"===t||"_"===t||"X"===t){for(a+=2;a<e.length;){if("\x1b"===e[a]&&"\\"===e[a+1]){a+=2;break}a+=1}continue}a+=t?2:1;continue}if("\r"===r){a+=1;continue}a+=1,s[(t+=r).length]=a}return{plainText:t,rawOffsetsByPlainIndex:s}}(e);if(!t)return{status:"needs-more",text:""};let a=t.split("\n"),r=a.find(e=>!g(e));if(r&&!f(r))return{status:"passthrough",text:e};let n=a.findIndex(e=>x.test(e));if(-1===n)return a.length>=16||t.length>=4096?{status:"passthrough",text:e}:{status:"needs-more",text:""};if(n<6)return{status:"passthrough",text:e};let i=a.slice(n-6,n);if(6!==i.length||!i.every(f))return{status:"passthrough",text:e};let o=p(t,n+1);if(null===o)return{status:"needs-more",text:""};let l=o,d=n+1;for(;g(a[d]);){let e=p(t,d+1);if(null===e)break;l=e,d+=1}let c=s[l]??e.length;return{status:"matched",text:e.slice(c)}}(E.current);if("needs-more"===t.status)return;P.current=!0,E.current="",e=t.text}e&&(a?.write(e),$(!0))}}catch{}},A.onerror=()=>T.current(!1),(i=new ResizeObserver(()=>{if(!t)try{r?.fit(),a&&L(a.cols,a.rows)}catch{}})).observe(y.current)})(),()=>{t=!0,_.current&&clearTimeout(_.current),C.current?.close(),C.current=null,i?.disconnect(),a?.dispose(),S.current=null,k.current=null}},[e,n,o,I,d,c,l,u,M,L]);let q=(0,r.useRef)(null),B=(0,r.useCallback)(()=>{S.current?.focus()},[]);return(0,r.useEffect)(()=>{let e=q.current;if(!e)return;let t=e=>{"Enter"!==e.key||!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey||(e.preventDefault(),e.stopPropagation(),M("\n"))};return e.addEventListener("keydown",t,!0),()=>e.removeEventListener("keydown",t,!0)},[M]),(0,r.useEffect)(()=>{if(t){let e=setTimeout(()=>S.current?.focus(),80);return()=>clearTimeout(e)}},[t]),(0,a.jsxs)("div",{ref:q,className:(0,m.cn)("relative h-full w-full bg-terminal",!t&&"hidden"),onClick:B,children:[!F&&(0,a.jsxs)("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 bg-terminal",children:[(0,a.jsx)(i.A,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:n?"Starting GSD…":"Connecting…"})]}),(0,a.jsx)("div",{ref:y,className:"h-full w-full",style:{padding:"8px 4px 4px 8px"}})]})}s(82407);let S=new Set(["image/jpeg","image/png","image/gif","image/webp"]);async function k(e,t,s){let a,r=(0,h.Wl)(e);if(!r.valid)return void console.warn("[terminal-upload] validation failed:",r.error);let n=new FormData;n.append("file",e);try{let e=await (0,v.tm)((0,b.$)("/api/terminal/upload",s),{method:"POST",body:n}),t=await e.json();if(!e.ok||!t.path)return void console.error("[terminal-upload] upload failed:",t.error??`HTTP ${e.status}`);a=t.path}catch(e){console.error("[terminal-upload] upload request failed:",e);return}try{let e=await (0,v.tm)((0,b.$)("/api/terminal/input",s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,data:`@${a} `})});if(!e.ok){let t=await e.json().catch(()=>({}));console.error("[terminal-upload] inject failed:",t.error??`HTTP ${e.status}`)}}catch(e){console.error("[terminal-upload] inject request failed:",e)}}function C({className:e,command:t,commandArgs:s,sessionPrefix:i,hideSidebar:h=!1,fontSize:x,hideInitialGsdHeader:p=!1,projectCwd:g}){let f,{resolvedTheme:j}=(0,n.D)(),y="light"!==j,w=(f=i??(t?"gsd-default":"default"),g?`${f}:${g}`:f),A=function(e){if(!e?.trim())return"zsh";let t=e.trim().split(/\s+/)[0]||e,s=t.replace(/\\/g,"/").split("/");return s[s.length-1]||t}(t),[R,_]=(0,r.useState)([{id:w,label:A,connected:!1}]),[T,P]=(0,r.useState)(w),[E,I]=(0,r.useState)(!1),[F,$]=(0,r.useState)(null),L=(0,r.useRef)(null),D=(0,r.useRef)(w);(0,r.useEffect)(()=>{D.current!==w&&(D.current=w,_([{id:w,label:A,connected:!1}]),P(w),$(null))},[w,A]),(0,r.useEffect)(()=>{let e=L.current;if(!e)return;let t=0,s=e=>{e.preventDefault(),e.stopPropagation(),1===(t+=1)&&I(!0)},a=e=>{e.preventDefault(),e.stopPropagation()},r=e=>{e.preventDefault(),e.stopPropagation(),(t-=1)<=0&&(t=0,I(!1))},n=e=>{if(e.preventDefault(),e.stopPropagation(),t=0,I(!1),!T)return;let s=Array.from(e.dataTransfer?.files??[]).find(e=>S.has(e.type));s&&k(s,T,g)};return e.addEventListener("dragenter",s,!0),e.addEventListener("dragover",a,!0),e.addEventListener("dragleave",r,!0),e.addEventListener("drop",n,!0),()=>{e.removeEventListener("dragenter",s,!0),e.removeEventListener("dragover",a,!0),e.removeEventListener("dragleave",r,!0),e.removeEventListener("drop",n,!0)}},[T,g]),(0,r.useEffect)(()=>{let e=L.current;if(!e)return;let t=e=>{if(!e.clipboardData)return;let t=Array.from(e.clipboardData.files).find(e=>S.has(e.type));t&&(e.preventDefault(),e.stopPropagation(),T&&k(t,T,g))};return e.addEventListener("paste",t,!0),()=>e.removeEventListener("paste",t,!0)},[T,g]);let M=(0,r.useCallback)(async()=>{try{let e=await (0,v.tm)((0,b.$)("/api/terminal/sessions",g),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{command:t}:{})});if(!e.ok)return void $(`Could not create terminal (${e.status}).`);let s=await e.json();if("string"!=typeof s.id||0===s.id.length)return void $("Could not create terminal: invalid server response.");let a={id:s.id,label:A,connected:!1};$(null),_(e=>[...e,a]),P(s.id)}catch(e){$(`Could not create terminal: ${e instanceof Error?e.message:String(e)}`)}},[t,A,g]),q=(0,r.useCallback)(e=>{if(R.length<=1)return;let t=(0,b.Y)("/api/terminal/sessions",window.location.origin,g);t.searchParams.set("id",e),(0,v.tm)(t.toString(),{method:"DELETE"});let s=R.filter(t=>t.id!==e);_(s),T===e&&P(s[s.length-1]?.id??w)},[R,T,w,g]),B=(0,r.useCallback)((e,t)=>{_(s=>s.map(s=>s.id===e?{...s,connected:t}:s))},[]);return(0,a.jsxs)("div",{className:(0,m.cn)("flex bg-terminal",e),children:[(0,a.jsxs)("div",{ref:L,className:"relative flex-1 min-w-0",children:[R.map(e=>(0,a.jsx)(N,{sessionId:e.id,visible:e.id===T,command:t,commandArgs:e.id===w?s:void 0,isDark:y,fontSize:x,hideInitialGsdHeader:p,projectCwd:g,onConnectionChange:t=>B(e.id,t)},e.id)),E&&(0,a.jsxs)("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 bg-background backdrop-blur-sm border-2 border-dashed border-primary rounded-md pointer-events-none",children:[(0,a.jsx)(o.A,{className:"h-8 w-8 text-primary"}),(0,a.jsx)("span",{className:"text-sm font-medium text-primary",children:"Drop image here"})]}),F&&(0,a.jsxs)("div",{className:"absolute left-2 right-2 top-2 z-30 flex items-center gap-2 rounded border border-destructive/40 bg-background px-2 py-1 text-xs text-destructive shadow-sm",children:[(0,a.jsx)(l.A,{className:"h-3.5 w-3.5 flex-shrink-0"}),(0,a.jsx)("span",{className:"min-w-0 truncate",children:F})]})]}),!h&&(0,a.jsxs)("div",{className:"flex w-[34px] flex-shrink-0 flex-col border-l border-border/50 bg-terminal",children:[(0,a.jsx)("button",{onClick:M,className:"flex h-[30px] w-full items-center justify-center text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",title:"New terminal",children:(0,a.jsx)(d.A,{className:"h-3 w-3"})}),(0,a.jsx)("div",{className:"h-px bg-border/50"}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:R.map((e,t)=>(0,a.jsxs)("button",{onClick:()=>P(e.id),className:(0,m.cn)("group relative flex h-[30px] w-full items-center justify-center transition-colors",e.id===T?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground"),title:`${e.label} ${t+1}`,children:[e.id===T&&(0,a.jsx)("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-muted-foreground"}),(0,a.jsxs)("div",{className:"relative flex items-center",children:[(0,a.jsx)(c.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:(0,m.cn)("absolute -bottom-0.5 -right-0.5 h-1.5 w-1.5 rounded-full border border-terminal",e.connected?"bg-success":"bg-muted-foreground/40")})]}),R.length>1&&(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),q(e.id)},className:"absolute -right-0.5 -top-0.5 z-10 hidden h-3.5 w-3.5 items-center justify-center rounded-full bg-accent text-muted-foreground hover:bg-destructive/20 hover:text-destructive group-hover:flex",title:"Kill terminal",children:(0,a.jsx)(u.A,{className:"h-2 w-2"})})]},e.id))})]})]})}},39658:(e,t,s)=>{s.d(t,{p:()=>n});var a=s(95155);s(12115);var r=s(91337);function n({className:e,type:t,...s}){return(0,a.jsx)("input",{type:t,"data-slot":"input",className:(0,r.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...s})}},43205:(e,t,s)=>{function a(e,t){if(!t)return e;let s=new URL(e,"http://localhost");return s.searchParams.set("project",t),s.pathname+s.search}function r(e,t,s){return new URL(a(e,s),t)}s.d(t,{$:()=>a,Y:()=>r})},44004:(e,t,s)=>{function a(e){let t=Number(e)||0;return t<.01?`$${t.toFixed(4)}`:t<1?`$${t.toFixed(3)}`:`$${t.toFixed(2)}`}function r(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}K`:`${(e/1e6).toFixed(2)}M`}function n(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60),a=t%60;if(s<60)return a>0?`${s}m ${a}s`:`${s}m`;let r=Math.floor(s/60),n=s%60;return n>0?`${r}h ${n}m`:`${r}h`}s.d(t,{BD:()=>a,a3:()=>n,ap:()=>r})},64834:(e,t,s)=>{s.d(t,{A:()=>i});var a=s(12115);let r="gsd-terminal-font-size",n="terminal-font-size-changed";function i(){let[e,t]=(0,a.useState)(()=>{try{let e=localStorage.getItem(r);if(e){let t=Number(e);if(Number.isFinite(t)&&t>=8&&t<=24)return t}}catch{}return 13}),s=(0,a.useCallback)(e=>{let s=Math.max(8,Math.min(24,Math.round(e)));t(s);try{localStorage.setItem(r,String(s))}catch{}window.dispatchEvent(new CustomEvent(n,{detail:s}))},[]);return(0,a.useEffect)(()=>{let e=e=>{if(e.key!==r)return;let s=Number(e.newValue);Number.isFinite(s)&&s>=8&&s<=24&&t(s)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]),(0,a.useEffect)(()=>{let e=e=>{let s=e.detail;Number.isFinite(s)&&s>=8&&s<=24&&t(s)};return window.addEventListener(n,e),()=>window.removeEventListener(n,e)},[]),[e,s]}},78336:(e,t,s)=>{s.r(t),s.d(t,{GSDAppShell:()=>rf});var a=s(95155),r=s(5772),n=s(37206),i=s(12115),o=s(33210),l=s(29857),d=s(12651),c=s(20232),u=s(30125),m=s(16950),h=s(51900),x=s(36999),p=s(92972),g=s(98401),f=s(8434),b=s(1806),v=s(56572),j=s(38798),y=s(93219),w=s(89123),N=s(79270),S=s(31025),k=s(89363),C=s(41313),A=s(89626),R=s(66088),_=s(21362),T=s(48368),P=s(2318),E=s(6296),I=s(33e3),F=s(50070),$=s(29483),L=s(91337);function D({...e}){return(0,a.jsx)($.bL,{"data-slot":"dialog",...e})}function M({...e}){return(0,a.jsx)($.ZL,{"data-slot":"dialog-portal",...e})}function q({className:e,...t}){return(0,a.jsx)($.hJ,{"data-slot":"dialog-overlay",className:(0,L.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function B({className:e,children:t,showCloseButton:s=!0,...r}){return(0,a.jsxs)(M,{"data-slot":"dialog-portal",children:[(0,a.jsx)(q,{}),(0,a.jsxs)($.UC,{"data-slot":"dialog-content",className:(0,L.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,s&&(0,a.jsxs)($.bm,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,a.jsx)(o.A,{}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function U({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"dialog-header",className:(0,L.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function O({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"dialog-footer",className:(0,L.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function z({className:e,...t}){return(0,a.jsx)($.hE,{"data-slot":"dialog-title",className:(0,L.cn)("text-lg leading-none font-semibold",e),...t})}function G({className:e,...t}){return(0,a.jsx)($.VY,{"data-slot":"dialog-description",className:(0,L.cn)("text-muted-foreground text-sm",e),...t})}var W=s(42442),K=s(18460);let V=(0,K.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function H({className:e,variant:t,size:s,asChild:r=!1,...n}){let i=r?W.DX:"button";return(0,a.jsx)(i,{"data-slot":"button",className:(0,L.cn)(V({variant:t,size:s,className:e})),...n})}var Y=s(70460),J=s(98234),Q=s(10654),Z=s(93591),X=s(23217);class ee{getActiveStore(){return this.activeProjectCwd?this.stores.get(this.activeProjectCwd)??null:null}getActiveProjectCwd(){return this.activeProjectCwd}switchProject(e){if(this.activeProjectCwd&&this.activeProjectCwd!==e){let e=this.stores.get(this.activeProjectCwd);e&&e.disconnectSSE()}let t=this.stores.get(e);return t?t.reconnectSSE():(t=new J.Hu(e),this.stores.set(e,t),t.start()),this.activeProjectCwd=e,this.notify(),t}disposeAll(){for(let e of this.stores.values())e.dispose();this.stores.clear(),this.activeProjectCwd=null,this.notify()}closeProject(e){let t=this.stores.get(e);if(t){if(t.dispose(),this.stores.delete(e),this.activeProjectCwd===e){let e=Array.from(this.stores.keys());if(e.length>0){let t=this.stores.get(e[0]);this.activeProjectCwd=e[0],t.reconnectSSE()}else this.activeProjectCwd=null}this.notify()}}getProjectCount(){return this.stores.size}getActiveProjectPaths(){return Array.from(this.stores.keys())}notify(){for(let e of this.listeners)e()}constructor(){this.stores=new Map,this.activeProjectCwd=null,this.listeners=new Set,this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.getSnapshot=()=>this.activeProjectCwd}}let et=(0,i.createContext)(null);function es({children:e}){let[t]=(0,i.useState)(()=>new ee);return(0,i.useEffect)(()=>()=>t.disposeAll(),[t]),(0,a.jsx)(et.Provider,{value:t,children:e})}function ea(){let e=(0,i.useContext)(et);if(!e)throw Error("useProjectStoreManager must be used within ProjectStoreManagerProvider");return e}function er({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"skeleton",className:(0,L.cn)("bg-accent animate-pulse rounded-md",e),...t})}var en=s(35082);let ei=({status:e})=>"done"===e?(0,a.jsx)(d.A,{className:"h-4 w-4 shrink-0 text-success"}):"in-progress"===e?(0,a.jsx)(c.A,{className:"h-4 w-4 shrink-0 text-warning"}):"parked"===e?(0,a.jsx)(u.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,a.jsx)(m.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"});function eo({activeView:e,onViewChange:t,isConnecting:s=!1}){let{openCommandSurface:r}=(0,J._l)(),n=ea(),o=(0,i.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot),[l,d]=(0,i.useState)(!1),{theme:c,setTheme:u}=(0,Y.D)(),m="light"===c?h.A:"dark"===c?x.A:p.A,A=[{id:"dashboard",label:"Dashboard",icon:g.A},{id:"power",label:"Power Mode",icon:f.A},{id:"chat",label:"Chat",icon:b.A},{id:"roadmap",label:"Roadmap",icon:v.A},{id:"files",label:"Files",icon:j.A},{id:"activity",label:"Activity",icon:y.A},{id:"visualize",label:"Visualize",icon:w.A}];return(0,a.jsxs)("div",{className:"flex w-12 flex-col items-center gap-1 border-r border-border bg-sidebar py-3",children:[A.map(r=>(0,a.jsx)("button",{onClick:()=>t(r.id),disabled:s,className:(0,L.cn)("flex h-10 w-10 items-center justify-center rounded-md transition-colors",s?"cursor-not-allowed text-muted-foreground/50":e===r.id?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),title:s?"Connecting…":r.label,children:(0,a.jsx)(r.icon,{className:"h-5 w-5"})},r.id)),(0,a.jsxs)("div",{className:"mt-auto flex flex-col gap-1",children:[(0,a.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("gsd:open-projects")),disabled:s,className:(0,L.cn)("flex h-10 w-10 items-center justify-center rounded-md transition-colors",s?"cursor-not-allowed text-muted-foreground/50":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),title:s?"Connecting…":"Projects",children:(0,a.jsx)(N.A,{className:"h-5 w-5"})}),(0,a.jsx)("button",{className:(0,L.cn)("flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground transition-colors",s?"cursor-not-allowed opacity-30":"hover:bg-accent/50 hover:text-foreground"),title:"Git",disabled:s,onClick:()=>!s&&r("git",{source:"sidebar"}),"data-testid":"sidebar-git-button",children:(0,a.jsx)(S.A,{className:"h-5 w-5"})}),(0,a.jsx)("button",{className:(0,L.cn)("flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground transition-colors",s?"cursor-not-allowed opacity-30":"hover:bg-accent/50 hover:text-foreground"),title:"Settings",disabled:s,onClick:()=>!s&&r("settings",{source:"sidebar"}),"data-testid":"sidebar-settings-button",children:(0,a.jsx)(k.A,{className:"h-5 w-5"})}),(0,a.jsx)("button",{className:(0,L.cn)("flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground transition-colors",s?"cursor-not-allowed opacity-30":"hover:bg-accent/50 hover:text-foreground"),title:`Theme: ${"light"===c?"Light":"dark"===c?"Dark":"System"}`,disabled:s,onClick:()=>!s&&void("system"===c?u("light"):"light"===c?u("dark"):u("system")),"data-testid":"sidebar-theme-toggle",children:(0,a.jsx)(m,{className:"h-5 w-5"})}),(0,a.jsx)("button",{className:(0,L.cn)("flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground transition-colors",s?"cursor-not-allowed opacity-30":"hover:bg-destructive/15 hover:text-destructive"),title:"Exit",disabled:s,onClick:()=>!s&&d(!0),"data-testid":"sidebar-signoff-button",children:(0,a.jsx)(C.A,{className:"h-5 w-5"})}),(0,a.jsx)(el,{open:l,onOpenChange:d,projectCount:n.getProjectCount(),activeProjectCwd:o,onCloseProject:e=>{n.closeProject(e),t("dashboard"),d(!1)},onStopServer:async()=>{await (0,en.tm)("/api/shutdown",{method:"POST"}).catch(()=>{}),setTimeout(()=>{try{window.close()}catch{}setTimeout(()=>{window.location.href="about:blank"},300)},400)}})]})]})}function el({open:e,onOpenChange:t,projectCount:s,activeProjectCwd:r,onCloseProject:n,onStopServer:i}){let o=s>1,l=r?r.split("/").pop()??r:null;return o?(0,a.jsx)(D,{open:e,onOpenChange:t,children:(0,a.jsxs)(B,{className:"sm:max-w-md",children:[(0,a.jsxs)(U,{children:[(0,a.jsx)(z,{children:"Close project or stop server?"}),(0,a.jsxs)(G,{children:["You have ",s," projects open. You can close just the current project or stop the entire server."]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 py-2",children:[r&&(0,a.jsxs)(H,{variant:"outline",className:"h-auto justify-start gap-3 px-4 py-3 text-left",onClick:()=>n(r),children:[(0,a.jsx)(N.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"text-sm font-medium",children:["Close ",l]}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:"Disconnect this project and switch to another"})]})]}),(0,a.jsxs)(H,{variant:"outline",className:"h-auto justify-start gap-3 px-4 py-3 text-left border-destructive/30 hover:bg-destructive/10 hover:text-destructive",onClick:i,children:[(0,a.jsx)(C.A,{className:"h-4 w-4 shrink-0"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("div",{className:"text-sm font-medium",children:"Stop server"}),(0,a.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Shut down all ",s," projects and close the tab"]})]})]})]}),(0,a.jsx)(O,{children:(0,a.jsx)(H,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"})})]})}):(0,a.jsx)(D,{open:e,onOpenChange:t,children:(0,a.jsxs)(B,{className:"sm:max-w-md",children:[(0,a.jsxs)(U,{children:[(0,a.jsx)(z,{children:"Stop the GSD web server?"}),(0,a.jsxs)(G,{children:["This will shut down the server process and close this tab. Run"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs",children:"gsd --web"})," again to restart."]})]}),(0,a.jsxs)(O,{children:[(0,a.jsx)(H,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),(0,a.jsx)(H,{variant:"destructive",onClick:i,children:"Stop server"})]})]})})}function ed({isConnecting:e=!1,width:t,onCollapse:s}){let r,n=(0,J.gF)(),{openCommandSurface:o,setCommandSurfaceSection:l,sendCommand:d}=(0,J._l)(),[m,h]=(0,i.useState)([]),[x,p]=(0,i.useState)([]),g=(0,J.Gr)(n),f=(0,i.useMemo)(()=>g?.milestones??[],[g?.milestones]),b=g?.active,v=(0,J.CL)(n),j=n.live.recoverySummary,y=g?.validationIssues.length??0,w=(0,J.U4)(g),N=n.boot?.project.cwd??null,S=n.boot?.bridge??null,k=(0,Z.L)({phase:g?.active.phase??"pre-planning",autoActive:v?.active??!1,autoPaused:v?.paused??!1,onboardingLocked:n.boot?.onboarding.locked??!1,commandInFlight:n.commandInFlight,bootStatus:n.bootStatus,hasMilestones:f.length>0,projectDetectionKind:n.boot?.projectDetection?.kind??null}),C=e=>{(0,X.WT)({dispatch:()=>d((0,J.Sf)(e,S))})},F=b?.milestoneId&&!m.includes(b.milestoneId)?[...m,b.milestoneId]:m,$=b?.milestoneId&&b.sliceId?(r=`${b.milestoneId}-${b.sliceId}`,x.includes(r)?x:[...x,r]):x,D=new Map(f.map(e=>[e.id,(0,Q.Jq)(e,b??{})]));return(0,a.jsxs)("div",{className:"flex flex-col bg-sidebar",style:{width:t??256,flexShrink:0},children:[e&&(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-1.5 py-1",children:[(0,a.jsx)("div",{className:"px-2 py-1.5",children:(0,a.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Milestones"})}),(0,a.jsx)("div",{className:"space-y-0.5 px-1",children:[1,2].map(e=>(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1.5",children:[(0,a.jsx)(er,{className:"h-4 w-4 shrink-0 rounded"}),(0,a.jsx)(er,{className:"h-4 w-4 shrink-0 rounded-full"}),(0,a.jsx)(er,{className:(0,L.cn)("h-4",1===e?"w-40":"w-32")})]}),1===e&&(0,a.jsx)("div",{className:"ml-4 space-y-0.5",children:[1,2,3].map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1.5",children:[(0,a.jsx)(er,{className:"h-4 w-4 shrink-0 rounded"}),(0,a.jsx)(er,{className:"h-4 w-4 shrink-0 rounded-full"}),(0,a.jsx)(er,{className:(0,L.cn)("h-3.5",1===e?"w-32":2===e?"w-28":"w-24")})]},e))})]},e))})]}),!e&&(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-1.5 py-1",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between px-2 py-1.5",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Milestones"}),(0,a.jsx)("div",{className:"mt-1 text-xs text-foreground","data-testid":"sidebar-current-scope",children:w})]}),s&&(0,a.jsx)("button",{onClick:s,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",title:"Collapse sidebar",children:(0,a.jsx)(A.A,{className:"h-3.5 w-3.5"})})]}),"error"===n.bootStatus&&0===f.length&&(0,a.jsx)("div",{className:"px-3 py-2 text-xs text-destructive",children:"Workspace boot failed before the explorer could load."}),"ready"===n.bootStatus&&0===f.length&&(0,a.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No milestones found for this project."}),f.map(e=>{let t=F.includes(e.id),s=b?.milestoneId===e.id,r=D.get(e.id)??"pending";return(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{onClick:()=>{var t;return t=e.id,void h(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:(0,L.cn)("flex w-full items-center gap-1.5 px-2 py-1.5 text-sm transition-colors hover:bg-accent/50",s&&"bg-accent/30"),children:[t?(0,a.jsx)(R.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,a.jsx)(_.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,a.jsx)(ei,{status:r}),(0,a.jsxs)("span",{className:(0,L.cn)("truncate",("pending"===r||"parked"===r)&&"text-muted-foreground"),children:[e.id,": ",e.title]})]}),t&&(0,a.jsx)("div",{className:"ml-4",children:e.slices.map(t=>{let s=`${e.id}-${t.id}`,r=$.includes(s),n=(0,Q.z3)(e.id,t,b??{}),i=b?.milestoneId===e.id&&b.sliceId===t.id;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{onClick:()=>{p(e=>e.includes(s)?e.filter(e=>e!==s):[...e,s])},className:(0,L.cn)("flex w-full items-center gap-1.5 px-2 py-1.5 text-sm transition-colors hover:bg-accent/50",i&&"bg-accent/20"),children:[r?(0,a.jsx)(R.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,a.jsx)(_.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,a.jsx)(ei,{status:n}),(0,a.jsxs)("span",{className:(0,L.cn)("truncate text-[13px]","pending"===n&&"text-muted-foreground"),children:[t.id,": ",t.title]})]}),r&&(0,a.jsxs)("div",{className:"ml-5",children:[t.branch&&(0,a.jsx)("div",{className:"px-2 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground",children:t.branch}),t.tasks.map(r=>{let n=(0,Q.g$)(e.id,t.id,r,b??{}),o=!!(r.planPath||r.summaryPath);return(0,a.jsxs)("button",{type:"button",onClick:()=>(e=>{if(!e||!N)return;let t=`${N}/.gsd/`;if(!e.startsWith(t))return;let s=e.slice(t.length);window.dispatchEvent(new CustomEvent("gsd:open-file",{detail:{root:"gsd",path:s}}))})(r.summaryPath??r.planPath),disabled:!o,className:(0,L.cn)("flex w-full items-center gap-1.5 px-2 py-1 text-xs transition-colors",o?"cursor-pointer hover:bg-accent/50":"cursor-default opacity-70",b?.taskId===r.id&&i&&"bg-accent/10"),children:[(0,a.jsx)(T.A,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,a.jsx)(ei,{status:n}),(0,a.jsxs)("span",{className:(0,L.cn)("truncate text-left","pending"===n&&"text-muted-foreground"),children:[r.id,": ",r.title]})]},`${s}-${r.id}`)})]})]},s)})})]},e.id)})]}),!e&&(0,a.jsx)("div",{className:"border-t border-border px-3 py-2.5",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"font-medium text-foreground","data-testid":"sidebar-validation-count",children:[y," validation issue",1===y?"":"s"]}),(0,a.jsx)("div",{className:"truncate text-muted-foreground",children:j.label})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{o("settings",{source:"sidebar"}),l("recovery")},className:"inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-[11px] font-medium text-foreground transition-colors hover:bg-accent","data-testid":"sidebar-recovery-summary-entrypoint",children:[(0,a.jsx)(P.A,{className:"h-3.5 w-3.5"}),"Recovery"]})]})}),!e&&k.primary&&(0,a.jsx)("div",{className:"border-t border-border px-3 py-2.5",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>{k.primary&&C(k.primary.command)},disabled:k.disabled,className:(0,L.cn)("inline-flex h-9 flex-1 items-center justify-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","destructive"===k.primary.variant?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90",k.disabled&&"cursor-not-allowed opacity-50"),title:k.disabledReason,children:[n.commandInFlight?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):k.isNewMilestone?(0,a.jsx)(I.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(c.A,{className:"h-3.5 w-3.5"}),k.primary.label]}),k.secondaries.map(e=>(0,a.jsx)("button",{onClick:()=>C(e.command),disabled:k.disabled,className:(0,L.cn)("inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-border bg-background transition-colors hover:bg-accent",k.disabled&&"cursor-not-allowed opacity-50"),title:e.label,children:(0,a.jsx)(u.A,{className:"h-3.5 w-3.5"})},e.command))]})})]})}function ec({onExpand:e}){let t=(0,J.gF)(),{sendCommand:s}=(0,J._l)(),r=(0,J.Gr)(t),n=r?.milestones??[],i=(0,J.CL)(t),o=t.boot?.bridge??null,l=(0,Z.L)({phase:r?.active.phase??"pre-planning",autoActive:i?.active??!1,autoPaused:i?.paused??!1,onboardingLocked:t.boot?.onboarding.locked??!1,commandInFlight:t.commandInFlight,bootStatus:t.bootStatus,hasMilestones:n.length>0,projectDetectionKind:t.boot?.projectDetection?.kind??null});return(0,a.jsxs)("div",{className:"flex h-full w-10 flex-col items-center border-l border-border bg-sidebar py-3",children:[(0,a.jsx)("button",{onClick:e,className:"flex h-8 w-8 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",title:"Expand milestone sidebar",children:(0,a.jsx)(F.A,{className:"h-4 w-4"})}),l.primary&&(0,a.jsx)("div",{className:"mt-auto pb-0.5",children:(0,a.jsx)("button",{onClick:()=>{if(l.primary){var e;e=l.primary.command,(0,X.WT)({dispatch:()=>s((0,J.Sf)(e,o))})}},disabled:l.disabled,className:(0,L.cn)("flex h-8 w-8 items-center justify-center rounded-md transition-colors","destructive"===l.primary.variant?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90",l.disabled&&"cursor-not-allowed opacity-50"),title:l.disabledReason??l.primary.label,children:t.commandInFlight?(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}):l.isNewMilestone?(0,a.jsx)(I.A,{className:"h-4 w-4"}):(0,a.jsx)(c.A,{className:"h-4 w-4"})})})]})}function eu({activeView:e,onViewChange:t,isConnecting:s=!1,mobile:r=!1}){return r?(0,a.jsx)(em,{activeView:e,onViewChange:t,isConnecting:s}):(0,a.jsx)("div",{className:"flex h-full",children:(0,a.jsx)(eo,{activeView:e,onViewChange:t,isConnecting:s})})}function em({activeView:e,onViewChange:t,isConnecting:s=!1}){let{openCommandSurface:r}=(0,J._l)(),{theme:n,setTheme:i}=(0,Y.D)(),o="light"===n?h.A:"dark"===n?x.A:p.A,l=[{id:"dashboard",label:"Dashboard",icon:g.A},{id:"power",label:"Power Mode",icon:f.A},{id:"chat",label:"Chat",icon:b.A},{id:"roadmap",label:"Roadmap",icon:v.A},{id:"files",label:"Files",icon:j.A},{id:"activity",label:"Activity",icon:y.A},{id:"visualize",label:"Visualize",icon:w.A}];return(0,a.jsxs)("div",{className:"flex h-full flex-col bg-sidebar pt-14","data-testid":"mobile-nav-panel",children:[(0,a.jsx)("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:l.map(r=>(0,a.jsxs)("button",{onClick:()=>t(r.id),disabled:s,className:(0,L.cn)("flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm font-medium transition-colors min-h-[44px]",s?"cursor-not-allowed text-muted-foreground/50":e===r.id?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[(0,a.jsx)(r.icon,{className:"h-5 w-5 shrink-0"}),r.label]},r.id))}),(0,a.jsxs)("div",{className:"border-t border-border px-2 py-2 space-y-1",children:[(0,a.jsxs)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("gsd:open-projects")),disabled:s,className:"flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors min-h-[44px]",children:[(0,a.jsx)(N.A,{className:"h-5 w-5 shrink-0"}),"Projects"]}),(0,a.jsxs)("button",{onClick:()=>!s&&r("git",{source:"sidebar"}),disabled:s,className:"flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors min-h-[44px]",children:[(0,a.jsx)(S.A,{className:"h-5 w-5 shrink-0"}),"Git"]}),(0,a.jsxs)("button",{onClick:()=>!s&&r("settings",{source:"sidebar"}),disabled:s,className:"flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors min-h-[44px]",children:[(0,a.jsx)(k.A,{className:"h-5 w-5 shrink-0"}),"Settings"]}),(0,a.jsxs)("button",{onClick:()=>!s&&void("system"===n?i("light"):"light"===n?i("dark"):i("system")),disabled:s,className:"flex w-full items-center gap-3 rounded-md px-3 py-3 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors min-h-[44px]",children:[(0,a.jsx)(o,{className:"h-5 w-5 shrink-0"}),"Theme: ","light"===n?"Light":"dark"===n?"Dark":"System"]})]})]})}var eh=s(36371),ex=s(84980),ep=s(76498),eg=s(53961),ef=s(67514);function eb(){return(0,a.jsxs)("div",{className:"rounded-md border border-border bg-card",children:[(0,a.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Current Slice"})}),(0,a.jsx)("div",{className:"space-y-3 p-4",children:[1,2,3].map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(er,{className:"h-4 w-4 shrink-0 rounded-full"}),(0,a.jsx)(er,{className:(0,L.cn)("h-4",1===e?"w-48":2===e?"w-40":"w-36")})]},e))})]})}function ev(){return(0,a.jsxs)("div",{className:"rounded-md border border-border bg-card",children:[(0,a.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Recent Activity"})}),(0,a.jsx)("div",{className:"divide-y divide-border",children:[1,2,3,4].map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,a.jsx)(er,{className:"h-3 w-16 shrink-0"}),(0,a.jsx)(er,{className:"h-1.5 w-1.5 shrink-0 rounded-full"}),(0,a.jsx)(er,{className:(0,L.cn)("h-4 flex-1",e%3==0?"max-w-xs":e%3==1?"max-w-sm":"max-w-md")})]},e))})]})}function ej(e){switch(e){case"complete":case"completed":return{label:"Complete",tone:"success"};case"executing":return{label:"Executing",tone:"active"};case"in-progress":return{label:"In Progress",tone:"active"};case"planning":return{label:"Planning",tone:"info"};case"pre-planning":return{label:"Pre-planning",tone:"muted"};case"researching":return{label:"Researching",tone:"info"};case"refining":return{label:"Refining",tone:"info"};case"summarizing":return{label:"Summarizing",tone:"info"};case"verifying":return{label:"Verifying",tone:"info"};case"blocked":return{label:"Blocked",tone:"warning"};case"paused":return{label:"Paused",tone:"warning"};case"needs-discussion":return{label:"Discussion",tone:"warning"};case"validating-milestone":return{label:"Validating",tone:"info"};case"replanning-slice":return{label:"Replanning",tone:"info"};case"escalating-task":return{label:"Escalating",tone:"warning"};case"completing-milestone":return{label:"Completing",tone:"info"};case"evaluating-gates":return{label:"Evaluating Gates",tone:"info"};default:return{label:e,tone:"muted"}}}let ey={success:"bg-success/15 text-success",active:"bg-primary/15 text-primary",warning:"bg-warning/15 text-warning",info:"bg-info/15 text-info",muted:"bg-muted text-muted-foreground"},ew={success:"bg-success",active:"bg-primary",warning:"bg-warning",info:"bg-info",muted:"bg-muted-foreground/50"};function eN(e){return e.replace(/([MST])0*(\d+)/g,"$1$2")}function eS(e){let t=e.match(/^(.+?)\s*—\s*(.+)$/);return t?{scopeId:eN(t[1].trim()),phase:t[2].trim()}:{scopeId:eN(e.trim()),phase:null}}function ek({label:e,size:t="md",className:s}){let{scopeId:r,phase:n}=eS(e);if("Project scope pending"===r)return(0,a.jsx)("span",{className:(0,L.cn)("text-muted-foreground",eC(t),s),children:"Scope pending…"});let i=n?ej(n):null;return(0,a.jsxs)("span",{className:(0,L.cn)("inline-flex items-center gap-2",s),children:[(0,a.jsx)("span",{className:(0,L.cn)("font-semibold tracking-tight","sm"===t?"text-sm":"text-lg"),children:r}),i&&(0,a.jsx)("span",{className:(0,L.cn)("inline-flex shrink-0 items-center rounded-full px-2 font-medium leading-snug",ey[i.tone],eC(t),"sm"===t?"py-px":"py-0.5"),children:i.label})]})}function eC(e){return"sm"===e?"text-[10px]":"text-[11px]"}function eA({label:e,className:t}){let{scopeId:s,phase:r}=eS(e);if("Project scope pending"===s)return(0,a.jsx)("span",{className:(0,L.cn)("text-muted-foreground",t),children:"Scope pending…"});let n=r?ej(r):null,i=n?ew[n.tone]:"bg-muted-foreground/50";return(0,a.jsxs)("span",{className:(0,L.cn)("inline-flex items-center gap-1.5",t),children:[(0,a.jsx)("span",{className:(0,L.cn)("h-1.5 w-1.5 shrink-0 rounded-full",i)}),(0,a.jsx)("span",{children:s}),n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-border",children:"\xb7"}),(0,a.jsx)("span",{children:n.label})]})]})}var eR=s(42129),e_=s(25344),eT=s(86901),eP=s(24642),eE=s(48274),eI=s(21628);function eF({icon:e,label:t}){return(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card px-2.5 py-1 text-xs text-muted-foreground",children:[e,t]})}function e$({signals:e}){let t=[];return(e.hasGitRepo&&t.push({icon:(0,a.jsx)(S.A,{className:"h-3 w-3"}),label:"Git repository"}),e.hasPackageJson&&t.push({icon:(0,a.jsx)(eP.A,{className:"h-3 w-3"}),label:"Node.js project"}),e.fileCount>0&&t.push({icon:(0,a.jsx)(eE.A,{className:"h-3 w-3"}),label:`${e.fileCount} file${1===e.fileCount?"":"s"}`}),0===t.length)?null:(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:t.map(e=>(0,a.jsx)(eF,{icon:e.icon,label:e.label},e.label))})}function eL({detection:e,onCommand:t,onSwitchView:s,disabled:r=!1}){let n=function(e){switch(e.kind){case"brownfield":return{icon:(0,a.jsx)(eR.A,{className:"h-8 w-8 text-foreground",strokeWidth:1.5}),headline:"Existing project detected",body:"GSD will map your codebase and ask a few questions about what you want to build. From there it generates structured milestones and deliverable slices.",primaryLabel:"Map & Initialize",primaryCommand:"/gsd",secondary:{label:"Browse files first",action:"files-view"}};case"v1-legacy":return{icon:(0,a.jsx)(e_.A,{className:"h-8 w-8 text-foreground",strokeWidth:1.5}),headline:"GSD v1 project found",body:"This project has a .planning/ folder from an earlier GSD version. Migration converts your existing planning data into the new .gsd/ format.",detail:"Your original files will be preserved — migration creates the new structure alongside them.",primaryLabel:"Migrate to v2",primaryCommand:"/gsd migrate",secondary:{label:"Start fresh instead",action:"command",command:"/gsd"}};case"blank":return{icon:(0,a.jsx)(eT.A,{className:"h-8 w-8 text-foreground",strokeWidth:1.5}),headline:"Start a new project",body:"This folder is empty. GSD will ask what you want to build, then generate a structured plan — milestones broken into deliverable slices with risk-ordered execution.",primaryLabel:"Start Project Setup",primaryCommand:"/gsd"};default:return{icon:(0,a.jsx)(j.A,{className:"h-8 w-8 text-foreground",strokeWidth:1.5}),headline:"Set up your project",body:"Run the GSD wizard to get started.",primaryLabel:"Get Started",primaryCommand:"/gsd"}}}(e),i="brownfield"===e.kind||"v1-legacy"===e.kind;return(0,a.jsx)("div",{className:"flex h-full items-center justify-center p-8",children:(0,a.jsxs)("div",{className:"w-full max-w-lg",children:[(0,a.jsx)("div",{className:"mb-6 flex h-16 w-16 items-center justify-center rounded-xl border border-border bg-card",children:n.icon}),(0,a.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground",children:n.headline}),(0,a.jsx)("p",{className:"mt-3 text-sm leading-relaxed text-muted-foreground",children:n.body}),n.detail&&(0,a.jsx)("p",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:n.detail}),i&&(0,a.jsx)("div",{className:"mt-5",children:(0,a.jsx)(e$,{signals:e.signals})}),(0,a.jsxs)("div",{className:"mt-8 flex items-center gap-3",children:[(0,a.jsxs)("button",{onClick:()=>t(n.primaryCommand),disabled:r,className:(0,L.cn)("inline-flex items-center gap-2 rounded-md bg-foreground px-5 py-2.5 text-sm font-medium text-background transition-colors hover:bg-foreground/90",r&&"cursor-not-allowed opacity-50"),children:[n.primaryLabel,(0,a.jsx)(eI.A,{className:"h-3.5 w-3.5"})]}),n.secondary&&(0,a.jsx)("button",{onClick:()=>{"files-view"===n.secondary.action?s("files"):n.secondary.command&&t(n.secondary.command)},disabled:r,className:(0,L.cn)("inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-4 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-accent",r&&"cursor-not-allowed opacity-50"),children:n.secondary.label})]}),"blank"===e.kind&&(0,a.jsxs)("div",{className:"mt-8 rounded-lg border border-border/50 bg-card/50 p-4",children:[(0,a.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"What happens next"}),(0,a.jsx)("ul",{className:"mt-2.5 space-y-2",children:["A few questions about what you're building","Codebase analysis and context gathering","Structured milestone and slice generation"].map((e,t)=>(0,a.jsxs)("li",{className:"flex items-start gap-2.5 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-border text-[10px] font-medium text-muted-foreground",children:t+1}),e]},t))})]}),"brownfield"===e.kind&&(0,a.jsxs)("div",{className:"mt-8 rounded-lg border border-border/50 bg-card/50 p-4",children:[(0,a.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"What happens next"}),(0,a.jsx)("ul",{className:"mt-2.5 space-y-2",children:["GSD scans your codebase and asks about your goals","You discuss scope, constraints, and priorities","A milestone with risk-ordered slices is generated"].map((e,t)=>(0,a.jsxs)("li",{className:"flex items-start gap-2.5 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-border text-[10px] font-medium text-muted-foreground",children:t+1}),e]},t))})]})]})})}function eD({label:e,value:t,subtext:s,icon:r}){return(0,a.jsx)("div",{className:"rounded-md border border-border bg-card p-4",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:e}),null===t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(er,{className:"mt-2 h-7 w-20"}),(0,a.jsx)(er,{className:"mt-1.5 h-3 w-16"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"mt-1 truncate text-2xl font-semibold tracking-tight",children:t}),s&&(0,a.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:s})]})]}),(0,a.jsx)("div",{className:"shrink-0 rounded-md bg-accent p-2 text-muted-foreground",children:r})]})})}function eM({onSwitchView:e,onExpandTerminal:t}={}){let s,r=(0,J.gF)(),{sendCommand:n}=(0,J._l)(),o=r.boot,l=(0,J.Gr)(r),h=(0,J.CL)(r),x=o?.bridge??null,p=r.live.freshness,g=o?.project.cwd,[f,b]=(0,i.useState)(null),v=(0,i.useCallback)(async()=>{try{let e=await (0,en.tm)((0,J.fL)("/api/visualizer",g));if(!e.ok)return;let t=await e.json();t.totals&&b(t.totals)}catch{}},[g]);(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{v()},0),t=window.setInterval(()=>{v()},3e4);return()=>{window.clearTimeout(e),window.clearInterval(t)}},[v]);let j=f?.duration??h?.elapsed??0,w=f?.cost??h?.totalCost??0,N=f?.tokens.total??h?.totalTokens??0,k=h?.rtkSavings??null,C=h?.rtkEnabled===!0,A=(0,J.Ct)(l),R=A?.tasks.filter(e=>e.done).length??0,_=A?.tasks.length??0,T=_>0?Math.round(R/_*100):0,P=(0,J.U4)(l),E=(0,J.E3)(l),I=h?.active??!1,F=h?.currentUnit?.id??P,$=p.auto.stale?"stale":p.auto.status;(0,Z.L)({phase:l?.active.phase??"pre-planning",autoActive:h?.active??!1,autoPaused:h?.paused??!1,onboardingLocked:o?.onboarding.locked??!1,commandInFlight:r.commandInFlight,bootStatus:r.bootStatus,hasMilestones:(l?.milestones.length??0)>0,projectDetectionKind:o?.projectDetection?.kind??null});let D=(r.terminalLines??[]).slice(-6),M="idle"===r.bootStatus||"loading"===r.bootStatus,q=M?null:(0,J._y)(k?.savedTokens??0),B=M?null:k&&k.commands>0?`${Math.round(k.savingsPct)}% saved • ${k.commands} cmd${1===k.commands?"":"s"}`:"Waiting for shell usage",U=o?.projectDetection;return!M&&U&&"active-gsd"!==U.kind&&"empty-gsd"!==U.kind?(0,a.jsx)("div",{className:"flex h-full flex-col overflow-hidden",children:(0,a.jsx)(eL,{detection:U,onCommand:e=>{(0,X.WT)({dispatch:()=>n((0,J.Sf)(e,x))})},onSwitchView:t=>e?.(t),disabled:!!r.commandInFlight||o?.onboarding.locked})}):(0,a.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-2 md:px-6 md:py-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("h1",{className:"text-base md:text-lg font-semibold shrink-0",children:"Dashboard"}),!M&&P&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"hidden sm:inline text-lg font-thin text-muted-foreground select-none",children:"/"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:(0,a.jsx)(ek,{label:P,size:"sm"})})]}),M&&(0,a.jsx)(er,{className:"h-4 w-40"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 md:gap-3","data-testid":"dashboard-action-bar",children:[M?(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(er,{className:"h-8 w-40 rounded-md"})}):null,!M&&(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm",children:[(0,a.jsx)("span",{className:(0,L.cn)("h-2 w-2 rounded-full",I?"animate-pulse bg-success":"bg-muted-foreground/50")}),(0,a.jsx)("span",{className:"font-medium",children:I?"Auto Mode Active":"Auto Mode Inactive"})]}),!M&&E&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,a.jsx)(S.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"font-mono",children:E})]})]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto p-3 md:p-6",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-2 xl:grid-cols-4 2xl:grid-cols-5",children:[(0,a.jsx)("div",{className:"rounded-md border border-border bg-card p-4","data-testid":"dashboard-current-unit",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Current Unit"}),M?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(er,{className:"mt-2 h-7 w-20"}),(0,a.jsx)(er,{className:"mt-1.5 h-3 w-16"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(ek,{label:F})}),(0,a.jsxs)("p",{className:"mt-1.5 text-xs text-muted-foreground","data-testid":"dashboard-current-unit-freshness",children:["Auto freshness: ",$]})]})]}),(0,a.jsx)("div",{className:"shrink-0 rounded-md bg-accent p-2 text-muted-foreground",children:(0,a.jsx)(y.A,{className:"h-5 w-5"})})]})}),(0,a.jsx)(eD,{label:"Elapsed Time",value:M?null:(0,J.a3)(j),icon:(0,a.jsx)(ex.A,{className:"h-5 w-5"})}),(0,a.jsx)(eD,{label:"Total Cost",value:M?null:(0,J.BD)(w),icon:(0,a.jsx)(ep.A,{className:"h-5 w-5"})}),(0,a.jsx)(eD,{label:"Tokens Used",value:M?null:(0,J._y)(N),icon:(0,a.jsx)(eg.A,{className:"h-5 w-5"})}),C&&(0,a.jsx)(eD,{label:"RTK Saved",value:q,subtext:B,icon:(0,a.jsx)(ef.A,{className:"h-5 w-5"})})]}),(0,a.jsx)("div",{className:"mt-6",children:M?(0,a.jsx)(eb,{}):(0,a.jsxs)("div",{className:"flex flex-col rounded-md border border-border bg-card",children:[(0,a.jsxs)("div",{className:"border-b border-border px-4 py-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Current Slice"}),A?(0,a.jsxs)("p",{className:"mt-0.5 truncate text-sm font-medium text-foreground",children:[A.id," — ",A.title]}):(0,a.jsx)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"No active slice"})]}),A&&_>0&&(0,a.jsxs)("div",{className:"shrink-0 text-right",children:[(0,a.jsx)("span",{className:"text-2xl font-bold tabular-nums leading-none",children:T}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"%"})]})]}),A&&_>0&&(0,a.jsxs)("div",{className:"mt-3",children:[(0,a.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full bg-accent",children:(0,a.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${T}%`,backgroundColor:(s=Math.max(0,Math.min(100,T)),`oklch(0.65 0.16 ${(25+s/100*120).toFixed(1)})`)}})}),(0,a.jsxs)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:[R," of ",_," tasks complete"]})]})]}),(0,a.jsx)("div",{className:"flex-1 p-3",children:A&&A.tasks.length>0?(0,a.jsx)("div",{className:"space-y-0.5",children:A.tasks.map(e=>{let t=(0,Q.g$)(l.active.milestoneId,A.id,e,l.active);return(0,a.jsxs)("div",{className:(0,L.cn)("flex items-center gap-2.5 rounded px-2 py-1.5 transition-colors","in-progress"===t&&"bg-accent"),children:[function(e){switch(e){case"done":return(0,a.jsx)(d.A,{className:"h-4 w-4 text-muted-foreground"});case"in-progress":return(0,a.jsx)(c.A,{className:"h-4 w-4 text-foreground"});case"pending":return(0,a.jsx)(m.A,{className:"h-4 w-4 text-muted-foreground"});case"parked":return(0,a.jsx)(u.A,{className:"h-4 w-4 text-muted-foreground"})}}(t),(0,a.jsxs)("span",{className:(0,L.cn)("min-w-0 flex-1 truncate text-xs","done"===t&&"text-muted-foreground line-through decoration-muted-foreground/40","pending"===t&&"text-muted-foreground","in-progress"===t&&"font-medium text-foreground"),children:[(0,a.jsx)("span",{className:"font-mono text-muted-foreground",children:e.id}),(0,a.jsx)("span",{className:"mx-1.5 text-border",children:"\xb7"}),e.title]}),"in-progress"===t&&(0,a.jsx)("span",{className:"shrink-0 rounded-sm bg-foreground/10 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:"active"})]},e.id)})}):(0,a.jsx)("p",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No active slice or no tasks defined yet."})})]})}),M?(0,a.jsx)("div",{className:"mt-6",children:(0,a.jsx)(ev,{})}):(0,a.jsxs)("div",{className:"mt-6 rounded-md border border-border bg-card",children:[(0,a.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Recent Activity"})}),D.length>0?(0,a.jsx)("div",{className:"divide-y divide-border",children:D.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,a.jsx)("span",{className:"w-16 flex-shrink-0 font-mono text-xs text-muted-foreground",children:e.timestamp}),(0,a.jsx)("span",{className:(0,L.cn)("h-1.5 w-1.5 flex-shrink-0 rounded-full",function(e){switch(e){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-foreground/50"}}(e.type))}),(0,a.jsx)("span",{className:"truncate text-sm",children:e.content})]},e.id))}):(0,a.jsx)("div",{className:"px-4 py-4 text-sm text-muted-foreground",children:"No activity yet."})]})]})]})}var eq=s(73035),eB=s(65576),eU=s(41585),eO=s(68822),ez=s(44004);function eG(){let e=(0,J.gF)(),t=(0,J.tM)(e),s=(0,J.Gr)(e),r=(0,J.CL)(e),n=(0,J.E3)(s)??"project scope",o=(0,J.iT)(e.boot?.bridge),l=r?.currentUnit?.id??(0,J.U4)(s),d=(0,J.QC)(e),c=e.titleOverride?.trim()||null,u=e.statusTexts,m=e.live.recoverySummary,h=(0,J.Gr)(e)?.validationIssues.length??0,x=Object.entries(u),p=x.length>0?x[x.length-1][1]:null,g="idle"===e.bootStatus||"loading"===e.bootStatus,f=e.boot?.project.cwd,[b,v]=(0,i.useState)(null),j=(0,i.useCallback)(async()=>{try{let e=await (0,en.tm)((0,J.fL)("/api/visualizer",f));if(!e.ok)return;let t=await e.json();t.totals&&v(t.totals)}catch{}},[f]);return(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{j()},0),t=window.setInterval(()=>{j()},3e4);return()=>{window.clearTimeout(e),window.clearInterval(t)}},[j]),(0,a.jsxs)("div",{className:"flex h-7 items-center justify-between border-t border-border bg-card px-2 md:px-3 text-[10px] md:text-xs",children:[(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2 md:gap-4",children:[(0,a.jsxs)("div",{className:`flex items-center gap-1.5 ${function(e){switch(e){case"success":return"text-success";case"warning":return"text-warning";case"danger":return"text-destructive";default:return"text-muted-foreground"}}(t.tone)}`,children:[(0,a.jsx)(eq.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:t.label})]}),(0,a.jsxs)("div",{className:"hidden sm:flex items-center gap-1.5 text-muted-foreground",children:[(0,a.jsx)(S.A,{className:"h-3 w-3"}),g?(0,a.jsx)(er,{className:"h-3 w-20"}):(0,a.jsx)("span",{className:"font-mono",children:n})]}),(0,a.jsxs)("div",{className:"hidden lg:flex items-center gap-1.5 text-muted-foreground",children:[(0,a.jsx)(eB.A,{className:"h-3 w-3"}),g?(0,a.jsx)(er,{className:"h-3 w-24"}):(0,a.jsx)("span",{className:"font-mono",children:o})]}),!g&&(0,a.jsxs)("div",{className:"hidden max-w-xs items-center gap-1.5 truncate text-muted-foreground xl:flex","data-testid":"status-bar-retry-compaction",children:[(0,a.jsx)(P.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:m.retryInProgress?`Retry ${Math.max(1,m.retryAttempt)}`:m.isCompacting?"Compacting":m.freshness})]}),!g&&(0,a.jsxs)("div",{className:(0,L.cn)("hidden items-center gap-1.5 xl:flex",h>0?"text-warning":"text-muted-foreground"),"data-testid":"status-bar-validation-count",children:[(0,a.jsx)(eU.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsxs)("span",{children:[h," issue",1===h?"":"s"]})]}),!g&&d&&(0,a.jsxs)("div",{className:"hidden max-w-sm items-center gap-1.5 truncate text-destructive lg:flex","data-testid":"status-bar-error",children:[(0,a.jsx)(eU.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:d})]}),!g&&c&&(0,a.jsxs)("div",{className:"hidden max-w-xs items-center gap-1.5 truncate text-foreground/80 xl:flex","data-testid":"status-bar-title-override",children:[(0,a.jsx)(eO.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",title:c,children:c})]}),!g&&p&&!d&&(0,a.jsxs)("div",{className:"hidden max-w-xs items-center gap-1.5 truncate text-muted-foreground lg:flex","data-testid":"status-bar-extension-status",children:[(0,a.jsx)(eO.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:p})]})]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-2 md:gap-4",children:[(0,a.jsxs)("div",{className:"hidden sm:flex items-center gap-1.5 text-muted-foreground",children:[(0,a.jsx)(ex.A,{className:"h-3 w-3"}),g?(0,a.jsx)(er,{className:"h-3 w-8"}):(0,a.jsx)("span",{children:(0,ez.a3)(b?.duration??r?.elapsed??0)})]}),(0,a.jsxs)("div",{className:"hidden sm:flex items-center gap-1.5 text-muted-foreground",children:[(0,a.jsx)(eg.A,{className:"h-3 w-3"}),g?(0,a.jsx)(er,{className:"h-3 w-6"}):(0,a.jsx)("span",{children:(0,ez.ap)(b?.tokens.total??r?.totalTokens??0)})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,a.jsx)(ep.A,{className:"h-3 w-3"}),g?(0,a.jsx)(er,{className:"h-3 w-10"}):(0,a.jsx)("span",{children:(0,ez.BD)(b?.cost??r?.totalCost??0)})]}),(0,a.jsx)("span",{className:"hidden sm:inline max-w-[20rem] truncate text-muted-foreground","data-testid":"status-bar-unit",children:g?(0,a.jsx)(er,{className:"inline-block h-3 w-28 align-middle"}):(0,a.jsx)(eA,{label:l})})]})]})}var eW=s(58515),eK=s(96035),eV=s(36351),eH=s(24338),eY=s(56204),eJ=s(47279),eQ=s(94514);function eZ({className:e,...t}){return(0,a.jsx)(eJ.bL,{"data-slot":"checkbox",className:(0,L.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:(0,a.jsx)(eJ.C1,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:(0,a.jsx)(eQ.A,{className:"size-3.5"})})})}var eX=s(39658),e0=s(91760);function e1({className:e,...t}){return(0,a.jsx)(e0.b,{"data-slot":"label",className:(0,L.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}var e5=s(86033);function e2({className:e,...t}){return(0,a.jsx)(e5.bL,{"data-slot":"radio-group",className:(0,L.cn)("grid gap-3",e),...t})}function e3({className:e,...t}){return(0,a.jsx)(e5.q7,{"data-slot":"radio-group-item",className:(0,L.cn)("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:(0,a.jsx)(e5.C1,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:(0,a.jsx)(m.A,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}function e4({...e}){return(0,a.jsx)($.bL,{"data-slot":"sheet",...e})}function e8({...e}){return(0,a.jsx)($.ZL,{"data-slot":"sheet-portal",...e})}function e6({className:e,...t}){return(0,a.jsx)($.hJ,{"data-slot":"sheet-overlay",className:(0,L.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function e7({className:e,children:t,side:s="right",...r}){return(0,a.jsxs)(e8,{children:[(0,a.jsx)(e6,{}),(0,a.jsx)($.UC,{"data-slot":"sheet-content",className:(0,L.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===s&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===s&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===s&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===s&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...r,children:t})]})}function e9({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"sheet-header",className:(0,L.cn)("flex flex-col gap-1.5 p-4",e),...t})}function te({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"sheet-footer",className:(0,L.cn)("mt-auto flex flex-col gap-2 p-4",e),...t})}function tt({className:e,...t}){return(0,a.jsx)($.hE,{"data-slot":"sheet-title",className:(0,L.cn)("text-foreground font-semibold",e),...t})}function ts({className:e,...t}){return(0,a.jsx)($.VY,{"data-slot":"sheet-description",className:(0,L.cn)("text-muted-foreground text-sm",e),...t})}function ta({className:e,...t}){return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,L.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}function tr(e){switch(e){case"select":return"Selection";case"confirm":return"Confirmation";case"input":return"Input";case"editor":return"Editor"}}function tn({request:e,onSubmit:t,disabled:s}){let r=!!e.allowMultiple,[n,o]=(0,i.useState)(""),[l,d]=(0,i.useState)(new Set),c=()=>{r?t({value:Array.from(l)}):t({value:n})},u=r?l.size>0:""!==n;return r?(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"space-y-2",children:e.options.map(e=>(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5 transition-colors hover:bg-accent/40",children:[(0,a.jsx)(eZ,{checked:l.has(e),onCheckedChange:t=>{let s=new Set(l);t?s.add(e):s.delete(e),d(s)},disabled:s}),(0,a.jsx)("span",{className:"text-sm",children:e})]},e))}),(0,a.jsxs)(H,{onClick:c,disabled:s||!u,className:"w-full",children:[(0,a.jsx)(eY.A,{className:"h-4 w-4"}),"Submit selection (",l.size,")"]})]}):(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(e2,{value:n,onValueChange:o,disabled:s,children:e.options.map(e=>(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5 transition-colors hover:bg-accent/40",children:[(0,a.jsx)(e3,{value:e,id:`select-${e}`}),(0,a.jsx)(e1,{htmlFor:`select-${e}`,className:"cursor-pointer text-sm font-normal",children:e})]},e))}),(0,a.jsxs)(H,{onClick:c,disabled:s||!u,className:"w-full",children:[(0,a.jsx)(eY.A,{className:"h-4 w-4"}),"Submit"]})]})}function ti({request:e,onSubmit:t,onCancel:s,disabled:r}){return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"rounded-lg border border-border bg-background px-4 py-3 text-sm leading-relaxed",children:e.message}),(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsx)(H,{onClick:()=>t({value:!0}),disabled:r,className:"flex-1",children:"Confirm"}),(0,a.jsx)(H,{onClick:s,disabled:r,variant:"outline",className:"flex-1",children:"Cancel"})]})]})}function to({request:e,onSubmit:t,disabled:s}){let[r,n]=(0,i.useState)("");return(0,a.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),r.trim()&&t({value:r})},children:[(0,a.jsx)(eX.p,{value:r,onChange:e=>n(e.target.value),placeholder:e.placeholder||"Enter a value",disabled:s,autoFocus:!0}),(0,a.jsxs)(H,{type:"submit",disabled:s||!r.trim(),className:"w-full",children:[(0,a.jsx)(eY.A,{className:"h-4 w-4"}),"Submit"]})]})}function tl({request:e,onSubmit:t,disabled:s}){let[r,n]=(0,i.useState)(e.prefill||"");return(0,a.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),t({value:r})},children:[(0,a.jsx)(ta,{value:r,onChange:e=>n(e.target.value),disabled:s,className:"min-h-[200px] font-mono text-sm",autoFocus:!0}),(0,a.jsxs)(H,{type:"submit",disabled:s,className:"w-full",children:[(0,a.jsx)(eY.A,{className:"h-4 w-4"}),"Submit"]})]})}function td({request:e,onSubmit:t,onCancel:s,disabled:r}){switch(e.method){case"select":return(0,a.jsx)(tn,{request:e,onSubmit:t,disabled:r});case"confirm":return(0,a.jsx)(ti,{request:e,onSubmit:t,onCancel:s,disabled:r});case"input":return(0,a.jsx)(to,{request:e,onSubmit:t,disabled:r});case"editor":return(0,a.jsx)(tl,{request:e,onSubmit:t,disabled:r})}}function tc(){let e=(0,J.gF)(),{respondToUiRequest:t,dismissUiRequest:s}=(0,J._l)(),r=e.pendingUiRequests,n=r.length>0,i=r[0]??null,o="extension_ui_response"===e.commandInFlight,l=()=>{i&&s(i.id)};return(0,a.jsx)(e4,{open:n,onOpenChange:e=>{e||o||!i||l()},children:(0,a.jsx)(e7,{side:"right",className:"flex flex-col sm:max-w-md","data-testid":"focused-panel",children:i&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(e9,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[function(e){switch(e){case"select":return(0,a.jsx)(eW.A,{className:"h-4 w-4"});case"confirm":return(0,a.jsx)(eK.A,{className:"h-4 w-4"});case"input":return(0,a.jsx)(eV.A,{className:"h-4 w-4"});case"editor":return(0,a.jsx)(eH.A,{className:"h-4 w-4"})}}(i.method),(0,a.jsx)(tt,{children:i.title||tr(i.method)})]}),(0,a.jsx)(ts,{children:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{children:[tr(i.method)," requested by the agent"]}),r.length>1&&(0,a.jsxs)("span",{className:(0,L.cn)("inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-foreground px-1.5 text-[11px] font-semibold text-background"),"data-testid":"focused-panel-queue-badge",children:["+",r.length-1]})]})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-2",children:(0,a.jsx)(td,{request:i,onSubmit:e=>{i&&t(i.id,e)},onCancel:l,disabled:o})}),(0,a.jsx)(te,{children:(0,a.jsx)(H,{variant:"ghost",size:"sm",onClick:l,disabled:o,className:"text-muted-foreground",children:"Dismiss"})})]})})})}var tu=s(80642),tm=s(84286);let th="1"===s(41463).env.NEXT_PUBLIC_GSD_DEV,tx=[{key:"forceOnboarding",label:"Onboarding wizard",description:"Force the onboarding gate to render even when credentials are valid",shortcutLabel:"Ctrl+Shift+1"}],tp={forceOnboarding:!1},tg=(0,i.createContext)(null);function tf({children:e}){let[t,s]=(0,i.useState)(!1),[r,n]=(0,i.useState)(tp),[o,l]=(0,i.useState)(th);(0,i.useEffect)(()=>{(0,en.tm)("/api/dev-mode",{cache:"no-store"}).then(e=>e.json()).then(e=>{e.isDevMode&&l(!0)}).catch(()=>{})},[]);let d=(0,i.useCallback)(e=>{n(t=>({...t,[e]:!t[e]}))},[]),c=(0,i.useCallback)(e=>t&&r[e],[t,r]);(0,i.useEffect)(()=>{if(o)return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e);function e(e){t&&e.ctrlKey&&e.shiftKey&&"1"===e.key&&(e.preventDefault(),n(e=>({...e,forceOnboarding:!e.forceOnboarding})))}},[t,o]);let u=(0,i.useMemo)(()=>o?{isDevMode:o,enabled:t,setEnabled:s,overrides:r,toggle:d,isActive:c}:{isDevMode:!1,enabled:!1,setEnabled:()=>{},overrides:tp,toggle:()=>{},isActive:()=>!1},[o,t,s,r,d,c]);return(0,a.jsx)(tg.Provider,{value:u,children:e})}function tb(){let e=(0,i.useContext)(tg);if(!e)throw Error("useDevOverrides must be used within <DevOverridesProvider>");return e}var tv=s(33439);function tj({onNext:e}){return(0,a.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,a.jsxs)(tm.P.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.6,bounce:0},className:"relative",children:[(0,a.jsx)("div",{className:"absolute inset-0 rounded-2xl bg-foreground/5 blur-2xl"}),(0,a.jsxs)("div",{className:"relative mb-4 flex h-18 items-center justify-center",children:[(0,a.jsx)(r.default,{src:"/logo-white.svg",alt:"GSD",height:70,width:200,className:"hidden dark:block"}),(0,a.jsx)(r.default,{src:"/logo-black.svg",alt:"GSD",height:70,width:200,className:"dark:hidden"})]})]}),(0,a.jsx)(tm.P.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.16,duration:.4},className:"max-w-sm text-[15px] leading-relaxed text-muted-foreground",children:"Let's get your workspace ready. This takes about a minute."}),(0,a.jsx)(tm.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.24,duration:.4},className:"mt-10 flex items-center gap-3 text-xs text-muted-foreground",children:["Mode","Provider","Auth","Workspace"].map((e,t)=>(0,a.jsxs)("span",{className:"flex items-center gap-3",children:[t>0&&(0,a.jsx)("span",{className:"h-px w-5 bg-border"}),(0,a.jsx)("span",{className:"font-medium",children:e})]},e))}),(0,a.jsx)(tm.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.35,duration:.4},className:"mt-10",children:(0,a.jsxs)(H,{size:"lg",className:"group gap-2.5 px-8 text-[15px] transition-transform active:scale-[0.96]",onClick:e,"data-testid":"onboarding-start",children:["Get started",(0,a.jsx)(eI.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})})]})}var ty=s(33591),tw=s(92564);let tN=[{id:"expert",label:"Expert",icon:ty.A,tagline:"Full control",description:"Dashboard metrics, dual-pane power mode, and direct /gsd command access. Built for people who want visibility into every milestone and task."},{id:"vibe-coder",label:"Vibe Coder",icon:tw.A,tagline:"Just chat",description:"Conversational interface with the AI agent. Describe what you want and let GSD handle the structure. Same engine, friendlier surface."}];function tS({selected:e,onSelect:t,onNext:s,onBack:r}){return(0,a.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,a.jsx)(tm.P.h2,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",style:{textWrap:"balance"},children:"How do you want to work?"}),(0,a.jsx)(tm.P.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.06,duration:.4},className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:"You can switch anytime from settings."}),(0,a.jsx)(tm.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.12,duration:.45},className:"mt-8 grid w-full max-w-lg gap-3 sm:grid-cols-2",children:tN.map(s=>{let r=e===s.id,n=s.icon;return(0,a.jsxs)("button",{type:"button",onClick:()=>t(s.id),className:(0,L.cn)("group relative flex flex-col rounded-xl border px-5 py-5 text-left transition-all duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.98]",r?"border-foreground/30 bg-foreground/[0.06] shadow-[0_0_0_1px_rgba(255,255,255,0.06)]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50"),"data-testid":`onboarding-mode-${s.id}`,children:[(0,a.jsx)("div",{className:"absolute right-3.5 top-3.5",children:(0,a.jsx)("div",{className:(0,L.cn)("flex h-5 w-5 items-center justify-center rounded-full border-[1.5px] transition-all duration-200",r?"border-foreground bg-foreground":"border-foreground/20"),children:r&&(0,a.jsx)(tm.P.svg,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",duration:.3,bounce:0},viewBox:"0 0 12 12",className:"h-2.5 w-2.5 text-background",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("polyline",{points:"2.5 6 5 8.5 9.5 3.5"})})})}),(0,a.jsx)("div",{className:(0,L.cn)("mb-4 flex h-10 w-10 items-center justify-center rounded-lg transition-colors duration-200",r?"bg-foreground/10":"bg-foreground/[0.04]"),children:(0,a.jsx)(n,{className:(0,L.cn)("h-5 w-5 transition-colors duration-200",r?"text-foreground":"text-muted-foreground"),strokeWidth:1.5})}),(0,a.jsxs)("div",{className:"pr-7",children:[(0,a.jsx)("span",{className:"text-[15px] font-semibold text-foreground",children:s.label}),(0,a.jsx)("span",{className:(0,L.cn)("ml-2 text-xs font-medium transition-colors duration-200","text-muted-foreground"),children:s.tagline})]}),(0,a.jsx)("p",{className:"mt-2 text-[13px] leading-relaxed text-muted-foreground",children:s.description})]},s.id)})}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2,duration:.3},className:"mt-8 flex w-full max-w-lg items-center justify-between",children:[(0,a.jsx)(H,{variant:"ghost",onClick:r,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,a.jsxs)(H,{onClick:s,disabled:!e,className:"group gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-mode-continue",children:["Continue",(0,a.jsx)(eI.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})}var tk=s(44478);let tC=(0,K.F)("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function tA({className:e,variant:t,asChild:s=!1,...r}){let n=s?W.DX:"span";return(0,a.jsx)(n,{"data-slot":"badge",className:(0,L.cn)(tC({variant:t}),e),...r})}var tR=s(91459);function t_({providers:e,selectedId:t,onSelect:s,onNext:r,onBack:n}){let o=(0,i.useMemo)(()=>{let t,s,a,r;return t=e.filter(e=>e.configured),s=e.filter(e=>!e.configured&&e.recommended),a=e.filter(e=>!e.configured&&!e.recommended),r=[],t.length>0&&r.push({label:"Configured",items:t}),s.length>0&&r.push({label:"Recommended",items:s}),a.length>0&&r.push({label:"Other Providers",items:a}),r},[e]),l=e.some(e=>e.configured);return(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Choose a provider"}),(0,a.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground",children:"Click a provider to configure it. Set up as many as you want, then continue."})]}),(0,a.jsx)(tm.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.08,duration:.45},className:"mt-8 w-full space-y-5",children:o.map(e=>(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-2 px-0.5 text-[11px] font-medium uppercase tracking-widest text-muted-foreground",children:e.label}),(0,a.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:e.items.map(e=>{let r,n=e.id===t;return(0,a.jsxs)("button",{type:"button",onClick:()=>s(e.id),className:(0,L.cn)("group relative rounded-xl border px-4 py-3.5 text-left transition-all duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.98]",n?"border-foreground/30 bg-foreground/[0.06]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50"),"data-testid":`onboarding-provider-${e.id}`,children:[(0,a.jsx)("div",{className:"absolute right-3 top-3",children:(0,a.jsx)("div",{className:(0,L.cn)("flex h-5 w-5 items-center justify-center rounded-full border-[1.5px] transition-all duration-200",n?"border-foreground bg-foreground":"border-foreground/15"),children:n&&(0,a.jsx)(eQ.A,{className:"h-2.5 w-2.5 text-background",strokeWidth:3})})}),(0,a.jsxs)("div",{className:"pr-8",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground",children:e.label}),e.recommended&&(0,a.jsx)(tA,{variant:"outline",className:"border-foreground/10 bg-foreground/[0.03] text-[9px] text-muted-foreground",children:"Recommended"})]}),(0,a.jsx)("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-muted-foreground",children:e.configured?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tk.A,{className:"h-3 w-3 text-success/80"}),(0,a.jsx)("span",{children:function(e){switch(e){case"auth_file":return"Saved auth";case"environment":return"Environment variable";case"runtime":return"Runtime";case"external_cli":return"CLI";default:return"Not configured"}}(e.configuredVia)})]}):(0,a.jsx)("span",{className:"text-muted-foreground",children:"Not configured"})})]}),(0,a.jsx)("div",{className:"mt-2.5 flex flex-wrap gap-1",children:(r=[],e.supports.apiKey&&r.push("API key"),e.supports.oauth&&r.push(e.supports.oauthAvailable?"Browser sign-in":"OAuth unavailable"),e.supports.externalCli&&r.push("CLI auth"),r).map(e=>(0,a.jsxs)(tR.m_,{children:[(0,a.jsx)(tR.k$,{asChild:!0,children:(0,a.jsx)(tA,{variant:"outline",className:"border-border/50 text-[10px] text-muted-foreground",children:e})}),(0,a.jsx)(tR.ZI,{side:"bottom",children:"API key"===e?"Enter an API key to authenticate":"Browser sign-in"===e?"Authenticate through your browser":"CLI auth"===e?"Authenticated via local CLI — no API key needed":"This auth method is not available"})]},e))})]},e.id)})})]},e.label))}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.15,duration:.3},className:"mt-8 flex w-full items-center justify-between",children:[(0,a.jsx)(H,{variant:"ghost",onClick:n,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,a.jsxs)(H,{onClick:r,disabled:!l,className:"group gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-provider-continue",children:["Continue",(0,a.jsx)(eI.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})}var tT=s(62032),tP=s(35756),tE=s(42268),tI=s(13986),tF=s(22164),t$=s(62791),tL=s(9199),tD=s(14897);function tM({className:e,value:t,...s}){return(0,a.jsx)(tD.bL,{"data-slot":"progress",className:(0,L.cn)("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",e),...s,children:(0,a.jsx)(tD.C1,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})})}function tq({provider:e,activeFlow:t,lastValidation:s,requestState:r,requestProviderId:n,onSaveApiKey:o,onStartFlow:l,onSubmitFlowInput:c,onCancelFlow:u,onBack:m,onNext:h,bridgeRefreshPhase:x,bridgeRefreshError:p}){let[g,f]=(0,i.useState)(""),[b,v]=(0,i.useState)(""),[j,y]=(0,i.useState)(!1),w="idle"!==r,N=n===e.id&&w,S=e.supports.externalCli,k=s?.status==="succeeded"&&s.providerId===e.id,C=S&&e.configured||k&&("succeeded"===x||"idle"===x),A=s?.status==="failed"&&s.providerId===e.id,R=A?function(e){if(!e)return{title:"Validation failed",detail:null};let t=e.match(/^\d{3}\s+[^:]+:\s*(.+)$/s),s=t?.[1]??e;try{let e=JSON.parse(s);if("object"==typeof e&&null!==e){let t=e.error_details?.message??e.error?.message??e.message??e.error??null;if("string"==typeof t&&t.length>0){if(/subscription.*(ended|expired|cancelled)/i.test(t))return{title:"Subscription expired",detail:t.replace(/\.$/,"")+". Check your plan status with this provider."};if(/rate.limit/i.test(t))return{title:"Rate limited",detail:"Too many requests. Wait a moment and try again."};if(/invalid.*key|invalid.*token|incorrect.*key/i.test(t))return{title:"Invalid credentials",detail:"The API key was rejected. Double-check and try again."};if(/quota|billing|payment/i.test(t))return{title:"Billing issue",detail:t};return{title:"Provider error",detail:t}}}}catch{}return/^401\b/i.test(e)?{title:"Unauthorized",detail:"The credentials were rejected. Double-check your API key."}:/^403\b/i.test(e)?{title:"Access denied",detail:"Your account doesn't have access. Check your subscription or permissions."}:/^429\b/i.test(e)?{title:"Rate limited",detail:"Too many requests. Wait a moment and try again."}:/^5\d{2}\b/i.test(e)?{title:"Server error",detail:"The provider returned an error. Try again in a minute."}:{title:"Validation failed",detail:e.length>200?e.slice(0,200)+"…":e}}(s.message):null;e.supports.apiKey||e.supports.oauth;let _=e.supports.oauth&&e.supports.oauthAvailable,T=e.supports.apiKey,P=t&&t.providerId===e.id&&!C,I=P&&"failed"===t.status,F=P&&("running"===t.status||"awaiting_browser_auth"===t.status),$=P&&"awaiting_input"===t.status,L=P?function(e){for(let t of[e.prompt?.message,e.auth?.instructions].filter(Boolean)){let e=t?.match(/(?:code|Code)[:\s]+([A-Z0-9]{4}[-–][A-Z0-9]{4})/i);if(e)return e[1]}return null}(t):null;return(0,i.useEffect)(()=>{if(s?.status!=="succeeded")return;let e=window.setTimeout(()=>f(""),0);return()=>window.clearTimeout(e)},[s?.checkedAt,s?.status]),(0,i.useEffect)(()=>{let e=window.setTimeout(()=>v(""),0);return()=>window.clearTimeout(e)},[t?.flowId]),(0,i.useEffect)(()=>{if(!j)return;let e=window.setTimeout(()=>y(!1),2e3);return()=>window.clearTimeout(e)},[j]),(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[(0,a.jsxs)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:["Connect ",e.label]}),(0,a.jsx)("p",{className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:C?"Authenticated and ready to go.":S?"Authentication is handled by the Claude CLI. Make sure it is installed and signed in.":T&&_?"Paste an API key or sign in through your browser.":T?"Paste your API key to authenticate.":"Sign in through your browser to authenticate."})]}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.08,duration:.45},className:"mt-8 w-full max-w-md space-y-4",children:[(0,a.jsx)(tu.N,{children:C&&(0,a.jsxs)(tm.P.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.4,bounce:0},className:"flex flex-col items-center gap-3 rounded-xl border border-success/15 bg-success/[0.04] px-6 py-6 text-center",children:[(0,a.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-success/15",children:(0,a.jsx)(tk.A,{className:"h-5 w-5 text-success"})}),(0,a.jsxs)("div",{className:"text-sm font-medium text-foreground",children:[e.label," authenticated"]})]})}),A&&R&&(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm",children:[(0,a.jsx)(tT.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"font-medium text-destructive",children:R.title}),R.detail&&(0,a.jsx)("div",{className:"mt-0.5 text-muted-foreground",children:R.detail})]})]}),"pending"===x&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border border-foreground/10 bg-foreground/[0.03] px-4 py-3 text-sm text-foreground/80",children:[(0,a.jsx)(E.A,{className:"h-4 w-4 shrink-0 animate-spin"}),"Connecting to provider…"]}),(0,a.jsx)(tM,{value:66,className:"h-1"})]}),"failed"===x&&p&&(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm",children:[(0,a.jsx)(tT.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"font-medium text-destructive",children:"Connection failed"}),(0,a.jsx)("div",{className:"mt-0.5 text-muted-foreground",children:p})]})]}),T&&!C&&(0,a.jsxs)("div",{className:"space-y-3 rounded-xl border border-border/50 bg-card/50 p-4",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:"API key"}),(0,a.jsxs)("form",{className:"space-y-3",onSubmit:async t=>{if(t.preventDefault(),!g.trim())return;let s=await o(e.id,g);s&&!s.locked&&("succeeded"===s.bridgeAuthRefresh.phase||"idle"===s.bridgeAuthRefresh.phase)&&h()},children:[(0,a.jsx)(eX.p,{"data-testid":"onboarding-api-key-input",type:"password",autoComplete:"off",value:g,onChange:e=>f(e.target.value),placeholder:`Paste your ${e.label} API key`,disabled:w,className:"font-mono text-sm"}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsxs)(H,{type:"submit",disabled:!g.trim()||w,className:"gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-save-api-key",children:[N&&"saving_api_key"===r?(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(tP.A,{className:"h-4 w-4"}),"Validate & save"]})})]})]}),_&&!C&&(0,a.jsxs)("div",{className:"space-y-3",children:[T&&(0,a.jsxs)("div",{className:"flex items-center gap-3 py-1",children:[(0,a.jsx)("div",{className:"h-px flex-1 bg-border/50"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"or"}),(0,a.jsx)("div",{className:"h-px flex-1 bg-border/50"})]}),!P&&(0,a.jsx)("div",{className:"rounded-xl border border-border/50 bg-card/50 p-4",children:(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Browser sign-in"}),(0,a.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Opens a new tab to authenticate with ",e.label]})]}),(0,a.jsxs)(H,{variant:"outline",disabled:w,onClick:()=>l(e.id),className:"shrink-0 gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-start-provider-flow",children:[N&&"starting_provider_flow"===r?(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(tE.A,{className:"h-4 w-4"}),"Sign in"]})]})}),P&&(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"rounded-xl border border-border/50 bg-card/50 p-4 space-y-4","data-testid":"onboarding-active-flow",children:[L&&(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3 py-2",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:"Enter this code on the sign-in page"}),(0,a.jsxs)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(L).then(()=>y(!0)).catch(()=>{})},className:"group flex items-center gap-3 rounded-lg border border-border bg-background/50 px-5 py-3 transition-colors hover:border-foreground/20 active:scale-[0.98]",children:[(0,a.jsx)("span",{className:"font-mono text-2xl font-bold tracking-[0.15em] text-foreground",children:L}),(0,a.jsx)("span",{className:"text-muted-foreground transition-colors group-hover:text-muted-foreground",children:j?(0,a.jsx)(d.A,{className:"h-4 w-4 text-success"}):(0,a.jsx)(tI.A,{className:"h-4 w-4"})})]}),(0,a.jsx)("div",{className:"text-[11px] text-muted-foreground",children:j?"Copied!":"Click to copy"})]}),!L&&t.auth?.instructions&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t.auth.instructions}),t.auth?.url&&(0,a.jsx)(H,{asChild:!0,className:"w-full gap-2 transition-transform active:scale-[0.96]",children:(0,a.jsxs)("a",{href:t.auth.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)(tF.A,{className:"h-4 w-4"}),"Open sign-in page"]})}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[F&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}),(0,a.jsx)("span",{children:"Waiting for authentication…"})]}),I&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t$.A,{className:"h-3 w-3 text-destructive"}),(0,a.jsx)("span",{className:"text-destructive",children:"Sign-in failed or timed out"})]}),$&&!L&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}),(0,a.jsx)("span",{children:"Waiting for input…"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[I&&(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>l(e.id),disabled:w,className:"h-7 gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(tL.A,{className:"h-3 w-3"}),"Retry"]}),(0,a.jsx)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(t.flowId),disabled:w,className:"h-7 text-xs text-muted-foreground",children:"Cancel"})]})]}),t.prompt&&!L&&(0,a.jsxs)("form",{className:"space-y-2 border-t border-border/50 pt-3",onSubmit:e=>{e.preventDefault(),(t.prompt?.allowEmpty||b.trim())&&c(t.flowId,b)},children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:t.prompt.message}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(eX.p,{"data-testid":"onboarding-flow-input",value:b,onChange:e=>v(e.target.value),placeholder:t.prompt.placeholder||"Enter value",disabled:w,className:"text-sm"}),(0,a.jsx)(H,{type:"submit",disabled:w||!t.prompt.allowEmpty&&!b.trim(),className:"shrink-0 transition-transform active:scale-[0.96]",children:"submitting_provider_flow_input"===r?(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}):"Submit"})]})]}),t.progress.length>0&&(0,a.jsx)("div",{className:"space-y-1 border-t border-border/50 pt-3",children:t.progress.map((e,s)=>(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:e},`${t.flowId}-${s}`))})]})]}),e.supports.oauth&&!e.supports.oauthAvailable&&!T&&(0,a.jsx)("div",{className:"rounded-xl border border-border/50 bg-card/50 px-4 py-3.5 text-sm text-muted-foreground",children:"Browser sign-in is not available in this runtime. Go back and choose a provider with API-key support."})]}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.15,duration:.3},className:"mt-8 flex w-full max-w-md items-center justify-between",children:[(0,a.jsx)(H,{variant:"ghost",onClick:m,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,a.jsxs)(H,{onClick:h,disabled:!C,className:"group gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-auth-continue",children:["Configure another provider",(0,a.jsx)(eI.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})}var tB=s(21167),tU=s(16561),tO=s(68990);function tz({className:e,children:t,viewportRef:s,...r}){return(0,a.jsxs)(tO.bL,{"data-slot":"scroll-area",className:(0,L.cn)("relative",e),...r,children:[(0,a.jsx)(tO.LM,{ref:s,"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),(0,a.jsx)(tG,{}),(0,a.jsx)(tO.OK,{})]})}function tG({className:e,orientation:t="vertical",...s}){return(0,a.jsx)(tO.VM,{"data-slot":"scroll-area-scrollbar",orientation:t,className:(0,L.cn)("flex touch-none p-px transition-colors select-none","vertical"===t&&"h-full w-2.5 border-l border-l-transparent","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:(0,a.jsx)(tO.lr,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}let tW=["~/Projects","~/Developer","~/Code","~/dev"];function tK({onSelect:e,onCancel:t}){let[s,r]=(0,i.useState)(""),[n,o]=(0,i.useState)(null),[l,d]=(0,i.useState)([]),[c,u]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),x=(0,i.useCallback)(async e=>{u(!0),h(null);try{let t=e?`?path=${encodeURIComponent(e)}`:"",s=await (0,en.tm)(`/api/browse-directories${t}`);if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`${s.status}`)}let a=await s.json();r(a.current),o(a.parent),d(a.entries)}catch(e){h(e instanceof Error?e.message:"Failed to browse")}finally{u(!1)}},[]);return(0,i.useEffect)(()=>{x()},[x]),(0,a.jsxs)("div",{className:"rounded-xl border border-border/50 bg-card/50 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-border/50 px-4 py-2.5",children:[(0,a.jsx)("p",{className:"min-w-0 truncate font-mono text-xs text-muted-foreground",title:s,children:s}),(0,a.jsx)(H,{type:"button",size:"sm",onClick:()=>e(s),className:"shrink-0 h-7 gap-1.5 text-xs transition-transform active:scale-[0.96]",children:"Select this folder"})]}),(0,a.jsx)(tz,{className:"h-[240px]",children:(0,a.jsxs)("div",{className:"px-1.5 py-1",children:[c&&(0,a.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),m&&(0,a.jsx)("div",{className:"px-3 py-4 text-center text-xs text-destructive",children:m}),!c&&!m&&(0,a.jsxs)(a.Fragment,{children:[n&&(0,a.jsxs)("button",{type:"button",onClick:()=>void x(n),className:"flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-accent/50",children:[(0,a.jsx)(tB.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:".."})]}),l.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>void x(e.path),className:"group flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-accent/50",children:[(0,a.jsx)(j.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:e.name}),(0,a.jsx)(_.A,{className:"h-3 w-3 shrink-0 text-muted-foreground/50 opacity-0 transition-opacity group-hover:opacity-100"})]},e.path)),0===l.length&&!n&&(0,a.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"No subdirectories"})]})]})}),(0,a.jsx)("div",{className:"border-t border-border/50 px-4 py-2",children:(0,a.jsx)(H,{type:"button",variant:"ghost",size:"sm",onClick:t,className:"h-7 text-xs text-muted-foreground",children:"Cancel"})})]})}function tV({onNext:e,onBack:t}){let[s,r]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[l,d]=(0,i.useState)(null),[c,m]=(0,i.useState)(!1),h=(0,i.useCallback)(e=>{r(e),d(null)},[]),x=(0,i.useCallback)(async()=>{let t=s.trim();if(!t)return void d("Enter a path or skip this step");o(!0),d(null);try{let s=await (0,en.tm)("/api/preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:t})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`Request failed (${s.status})`)}e()}catch(e){d(e instanceof Error?e.message:"Failed to save preference")}finally{o(!1)}},[s,e]);return(0,a.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,a.jsx)(tm.P.div,{initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.5,bounce:0},className:"mb-8",children:(0,a.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-xl border border-border/50 bg-card/50",children:(0,a.jsx)(tU.A,{className:"h-7 w-7 text-foreground/80",strokeWidth:1.5})})}),(0,a.jsx)(tm.P.h2,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.06,duration:.4},className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Dev root"}),(0,a.jsx)(tm.P.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.12,duration:.4},className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:"The folder that contains your projects. GSD discovers and manages workspaces inside it."}),(0,a.jsx)(tm.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.18,duration:.45},className:"mt-8 w-full max-w-md space-y-4",children:(0,a.jsx)(tu.N,{mode:"wait",children:c?(0,a.jsx)(tm.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},children:(0,a.jsx)(tK,{onSelect:e=>{r(e),m(!1),d(null)},onCancel:()=>m(!1)})},"browser"):(0,a.jsxs)(tm.P.div,{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(eX.p,{value:s,onChange:e=>{r(e.target.value),l&&d(null)},placeholder:"/Users/you/Projects",className:(0,L.cn)("h-11 flex-1 font-mono text-sm",l&&"border-destructive/50 focus-visible:ring-destructive/30"),"data-testid":"onboarding-devroot-input",autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&s.trim()&&x()}}),(0,a.jsxs)(H,{type:"button",variant:"outline",onClick:()=>m(!0),className:"h-11 gap-2 shrink-0 transition-transform active:scale-[0.96]",children:[(0,a.jsx)(eR.A,{className:"h-4 w-4"}),"Browse"]})]}),l&&(0,a.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:l}),(0,a.jsx)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:tW.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>h(e),className:(0,L.cn)("rounded-full border px-3 py-1 font-mono text-xs transition-all duration-150","active:scale-[0.96]",s===e?"border-foreground/25 bg-foreground/10 text-foreground":"border-border/50 text-muted-foreground hover:border-foreground/15 hover:text-foreground"),children:e},e))})]},"input")})}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.25,duration:.3},className:"mt-8 flex w-full max-w-md items-center justify-between",children:[(0,a.jsx)(H,{variant:"ghost",onClick:t,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(H,{variant:"ghost",onClick:e,className:"gap-1.5 text-muted-foreground transition-transform active:scale-[0.96]","data-testid":"onboarding-devroot-skip",children:["Skip",(0,a.jsx)(u.A,{className:"h-3.5 w-3.5"})]}),(0,a.jsx)(H,{onClick:()=>void x(),className:"group gap-2 transition-transform active:scale-[0.96]",disabled:n||c,"data-testid":"onboarding-devroot-continue",children:n?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}),"Saving…"]}):(0,a.jsxs)(a.Fragment,{children:["Continue",(0,a.jsx)(eI.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})})]})]})]})}var tH=s(3636);function tY({sections:e,onBack:t,onNext:s}){let r=e.filter(e=>"remote_questions"!==e.id),n=r.filter(e=>e.configured).length;return(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Integrations"}),(0,a.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground",children:"Optional tools. Nothing here blocks the workspace — configure later from settings."})]}),n>0&&(0,a.jsx)(tm.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.08,duration:.3},className:"mt-4",children:(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"font-medium text-success",children:n})," of ",r.length," configured"]})}),(0,a.jsx)(tm.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.1,duration:.45},className:"mt-8 w-full space-y-2",children:r.map(e=>(0,a.jsxs)("div",{className:(0,L.cn)("flex items-start gap-3.5 rounded-xl border px-4 py-3.5 transition-colors",e.configured?"border-success/15 bg-success/[0.03]":"border-border/50 bg-card/50"),"data-testid":`onboarding-optional-${e.id}`,children:[(0,a.jsx)("div",{className:(0,L.cn)("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full",e.configured?"bg-success/15 text-success":"bg-foreground/[0.05] text-muted-foreground"),children:e.configured?(0,a.jsx)(eQ.A,{className:"h-3 w-3",strokeWidth:3}):(0,a.jsx)(tH.A,{className:"h-3 w-3"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,a.jsxs)(tR.m_,{children:[(0,a.jsx)(tR.k$,{asChild:!0,children:(0,a.jsx)(tA,{variant:"outline",className:(0,L.cn)("text-[10px]",e.configured?"border-success/15 text-success/70":"border-border/50 text-muted-foreground"),children:e.configured?"Ready":"Skipped"})}),(0,a.jsx)(tR.ZI,{children:e.configured?"This integration is configured and active":"You can set this up later from workspace settings"})]})]}),e.configuredItems.length>0&&(0,a.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1",children:e.configuredItems.map(e=>(0,a.jsx)(tA,{variant:"outline",className:"border-border/50 text-[10px] text-muted-foreground",children:e},e))}),0===e.configuredItems.length&&(0,a.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Not configured — add later from settings."})]})]},e.id))}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.18,duration:.3},className:"mt-8 flex w-full items-center justify-between",children:[(0,a.jsx)(H,{variant:"ghost",onClick:t,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,a.jsxs)(H,{onClick:s,className:"group gap-2 transition-transform active:scale-[0.96]","data-testid":"onboarding-optional-continue",children:["Continue",(0,a.jsx)(eI.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})}var tJ=s(15411),tQ=s(7915);let tZ=[{value:"slack",label:"Slack",description:"Get notified in a Slack channel"},{value:"discord",label:"Discord",description:"Get notified in a Discord channel"},{value:"telegram",label:"Telegram",description:"Get notified via Telegram bot"}],tX={slack:"Channel ID (e.g. C01ABCD2EFG)",discord:"Channel ID (17–20 digit number)",telegram:"Chat ID (numeric, may start with -)"},t0={slack:/^[A-Z0-9]{9,12}$/,discord:/^\d{17,20}$/,telegram:/^-?\d{5,20}$/},t1={slack:"SLACK_BOT_TOKEN",discord:"DISCORD_BOT_TOKEN",telegram:"TELEGRAM_BOT_TOKEN"};function t5({onBack:e,onNext:t}){let[s,r]=(0,i.useState)(null),[n,o]=(0,i.useState)(""),[l,c]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[x,p]=(0,i.useState)(!1),[g,f]=(0,i.useState)(!1),[b,v]=(0,i.useState)(!0),[j,y]=(0,i.useState)(""),[w,N]=(0,i.useState)(!1),[S,k]=(0,i.useState)(!1),[C,A]=(0,i.useState)(!1),[R,_]=(0,i.useState)(null);(0,i.useEffect)(()=>{(0,en.tm)("/api/remote-questions",{cache:"no-store"}).then(e=>e.json()).then(e=>{e.tokenSet&&A(!0),"configured"===e.status&&e.config&&(f(!0),r(e.config.channel),o(e.config.channelId),p(!0))}).catch(()=>{}).finally(()=>v(!1))},[]);let T=null!==s&&n.trim().length>0&&t0[s].test(n.trim()),P=(0,i.useCallback)(async()=>{if(s&&T){c(!0),h(null);try{let e=await (0,en.tm)("/api/remote-questions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:s,channelId:n.trim(),timeoutMinutes:5,pollIntervalSeconds:5})}),t=await e.json();if(!e.ok)return void h(t.error??`Save failed (${e.status})`);p(!0),f(!0)}catch(e){h(e instanceof Error?e.message:"Failed to save")}finally{c(!1)}}},[s,n,T]),I=(0,i.useCallback)(async()=>{if(s&&j.trim()){k(!0),h(null),_(null);try{let e=await (0,en.tm)("/api/remote-questions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:s,token:j.trim()})}),t=await e.json();if(!e.ok)return void h(t.error??`Token save failed (${e.status})`);_(`Token saved (${t.masked})`),A(!0),y(""),N(!1)}catch(e){h(e instanceof Error?e.message:"Failed to save token")}finally{k(!1)}}},[s,j]);return(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsx)(tm.P.div,{initial:{opacity:0,scale:.85},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.5,bounce:0},className:"mb-8",children:(0,a.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-xl border border-border/50 bg-card/50",children:(0,a.jsx)(eK.A,{className:"h-7 w-7 text-foreground/80",strokeWidth:1.5})})}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.06,duration:.4},className:"text-center",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Remote notifications"}),(0,a.jsx)("p",{className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:"Get notified when GSD needs your input. Connect a chat channel and the agent pings you instead of waiting silently."})]}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.12,duration:.45},className:"mt-8 w-full max-w-md space-y-5",children:[x&&(0,a.jsxs)("div",{className:"flex items-center gap-3 rounded-xl border border-success/15 bg-success/[0.04] px-4 py-3 text-sm",children:[(0,a.jsx)(d.A,{className:"h-4 w-4 shrink-0 text-success"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:g&&!l?`Connected to ${s??"channel"}`:"Configuration saved"})]}),!b&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Channel"}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2",children:tZ.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{r(e.value),h(null),x&&!g&&p(!1)},disabled:l,className:(0,L.cn)("rounded-xl border px-3 py-3 text-left transition-all duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.97]",s===e.value?"border-foreground/30 bg-foreground/[0.06]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50"),children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label}),(0,a.jsx)("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:e.description})]},e.value))})]}),s&&!b&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Channel ID"}),(0,a.jsx)(eX.p,{value:n,onChange:e=>{o(e.target.value),m&&h(null)},placeholder:tX[s],disabled:l,className:"font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&T&&P()}}),n.trim().length>0&&!t0[s].test(n.trim())&&(0,a.jsxs)("p",{className:"text-xs text-destructive/70",children:["Doesn't match the expected format for ",s]})]}),s&&!b&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"text-xs font-medium text-muted-foreground",children:["Bot token",C&&(0,a.jsx)("span",{className:"ml-2 text-success",children:"✓ configured"})]}),R&&(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-xl border border-success/15 bg-success/[0.04] px-3 py-2 text-xs text-muted-foreground",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 shrink-0 text-success"}),R]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)(eX.p,{type:w?"text":"password",value:j,onChange:e=>y(e.target.value),placeholder:`Paste your ${t1[s]}`,disabled:S,className:"pr-9 font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&j.trim()&&I()}}),(0,a.jsx)("button",{type:"button",onClick:()=>N(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-muted-foreground transition-colors",children:w?(0,a.jsx)(tJ.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(tQ.A,{className:"h-3.5 w-3.5"})})]}),(0,a.jsxs)(H,{type:"button",variant:"outline",onClick:()=>void I(),disabled:!j.trim()||S,className:"gap-1.5 transition-transform active:scale-[0.96]",children:[S?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(tP.A,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),m&&(0,a.jsx)("div",{className:"rounded-xl border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive",children:m}),s&&n.trim().length>0&&!x&&(0,a.jsxs)(H,{onClick:()=>void P(),disabled:!T||l,className:"gap-2 transition-transform active:scale-[0.96]",children:[l?(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(d.A,{className:"h-4 w-4"}),"Save & connect"]}),b&&(0,a.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),"Checking existing configuration…"]})]}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2,duration:.3},className:"mt-8 flex w-full max-w-md items-center justify-between",children:[(0,a.jsx)(H,{variant:"ghost",onClick:e,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[!x&&(0,a.jsxs)(H,{variant:"ghost",onClick:t,className:"gap-1.5 text-muted-foreground transition-transform active:scale-[0.96]",children:["Skip",(0,a.jsx)(u.A,{className:"h-3.5 w-3.5"})]}),(0,a.jsxs)(H,{onClick:t,className:"group gap-2 transition-transform active:scale-[0.96]",children:["Continue",(0,a.jsx)(eI.A,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})]})}function t2({providerLabel:e,onFinish:t}){return(0,a.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,a.jsxs)(tm.P.div,{initial:{opacity:0,scale:.7},animate:{opacity:1,scale:1},transition:{type:"spring",duration:.6,bounce:.15},className:"relative mb-8",children:[(0,a.jsx)("div",{className:"absolute inset-0 rounded-full bg-success/10 blur-2xl"}),(0,a.jsx)("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-2xl border border-success/20 bg-success/10",children:(0,a.jsx)(d.A,{className:"h-8 w-8 text-success",strokeWidth:1.5})})]}),(0,a.jsx)(tm.P.h2,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"text-3xl font-bold tracking-tight text-foreground sm:text-4xl",children:"You're all set"}),(0,a.jsxs)(tm.P.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.18,duration:.4},className:"mt-3 max-w-sm text-[15px] leading-relaxed text-muted-foreground",children:[(0,a.jsx)("span",{className:"font-medium text-foreground",children:e})," is validated. The workspace is live."]}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{delay:.26,duration:.4},className:"mt-8 flex items-center gap-4 rounded-xl border border-border/50 bg-card/50 px-5 py-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(r.default,{src:"/logo-icon-white.svg",alt:"",width:14,height:14,className:"hidden opacity-40 dark:block"}),(0,a.jsx)(r.default,{src:"/logo-icon-black.svg",alt:"",width:14,height:14,className:"opacity-40 dark:hidden"}),(0,a.jsx)("span",{children:"Shell unlocked"})]}),(0,a.jsx)("div",{className:"h-3 w-px bg-border"}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-success"}),(0,a.jsx)("span",{children:e})]})]}),(0,a.jsx)(tm.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.35,duration:.4},className:"mt-8",children:(0,a.jsxs)(H,{size:"lg",className:"group gap-2.5 px-8 text-[15px] transition-transform active:scale-[0.96]",onClick:t,"data-testid":"onboarding-finish",children:["Launch workspace",(0,a.jsx)(eg.A,{className:"h-4 w-4 transition-transform group-hover:scale-110"})]})})]})}var t3=s(33024),t4=s(51914);let t8={"active-gsd":{label:"Active",color:"text-success",icon:t3.A},"empty-gsd":{label:"Initialized",color:"text-info",icon:eR.A},brownfield:{label:"Existing",color:"text-warning",icon:S.A},"v1-legacy":{label:"Legacy",color:"text-warning",icon:S.A},blank:{label:"New",color:"text-muted-foreground",icon:eT.A}};function t6({onFinish:e,onBack:t,onBeforeSwitch:s}){let r=ea(),[n,o]=(0,i.useState)(null),[l,d]=(0,i.useState)([]),[c,u]=(0,i.useState)(!0),[m,h]=(0,i.useState)(null),[x,p]=(0,i.useState)(!1),[g,f]=(0,i.useState)(""),[b,v]=(0,i.useState)(!1),[j,y]=(0,i.useState)(null),w=(0,i.useRef)(null),[N,S]=(0,i.useState)(null),k=(0,i.useRef)(null);(0,i.useEffect)(()=>{let e=!1;return async function(){u(!0),h(null);try{let t=await (0,en.tm)("/api/preferences");if(!t.ok)throw Error("Failed to load preferences");let s=await t.json();if(!s.devRoot){o(null),d([]),u(!1);return}o(s.devRoot);let a=await (0,en.tm)(`/api/projects?root=${encodeURIComponent(s.devRoot)}&detail=true`);if(!a.ok)throw Error("Failed to discover projects");let r=await a.json();e||d(r)}catch(t){e||h(t instanceof Error?t.message:"Unknown error")}finally{e||u(!1)}}(),()=>{e=!0}},[]),(0,i.useEffect)(()=>()=>{k.current&&clearInterval(k.current)},[]),(0,i.useEffect)(()=>{if(x){let e=setTimeout(()=>w.current?.focus(),50);return()=>clearTimeout(e)}},[x]);let C=l.map(e=>e.name),A=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(g),R=C.includes(g),_=g.length>0&&A&&!R&&!b,T=(0,i.useCallback)(t=>{s?.(),S(t.path);let a=r.switchProject(t.path);k.current&&clearInterval(k.current);let n=Date.now();k.current=setInterval(()=>{let s=a.getSnapshot(),r=Date.now()-n;("ready"===s.bootStatus||"error"===s.bootStatus||r>3e4)&&(k.current&&clearInterval(k.current),k.current=null,S(null),e(t.path))},150)},[r,e,s]),P=(0,i.useCallback)(async()=>{if(_&&n){v(!0),y(null);try{let e=await (0,en.tm)("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:n,name:g})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Failed (${e.status})`)}let t=await e.json();d(e=>[...e,t].sort((e,t)=>e.name.localeCompare(t.name))),f(""),p(!1),T(t)}catch(e){y(e instanceof Error?e.message:"Failed to create project"),v(!1)}}},[_,n,g,T]),I=!c&&!n,F=[...l].sort((e,t)=>{let s={"active-gsd":0,"empty-gsd":1,brownfield:2,"v1-legacy":3,blank:4},a=s[e.kind]??5,r=s[t.kind]??5;return a!==r?a-r:e.name.localeCompare(t.name)});return(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold tracking-tight text-foreground sm:text-3xl",children:"Open a project"}),(0,a.jsx)("p",{className:"mt-2 max-w-sm text-sm leading-relaxed text-muted-foreground",children:I?"Set a dev root first to discover your projects.":"Pick a project to start working in, or create a new one."})]}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{delay:.08,duration:.45},className:"mt-8 w-full max-w-lg space-y-2",children:[c&&(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 py-10 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}),"Discovering projects…"]}),m&&(0,a.jsx)("div",{className:"rounded-xl border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive",children:m}),I&&(0,a.jsx)("div",{className:"rounded-xl border border-border/50 bg-card/50 px-4 py-6 text-center text-sm text-muted-foreground",children:"No dev root configured. Go back and set one, or finish setup to configure later."}),!c&&F.length>0&&(0,a.jsx)("div",{className:"space-y-2",children:F.map(e=>{var t;let s,r=N===e.path,n=t8[e.kind],i=n.icon,o=(t=e.signals,s=[],t.isMonorepo&&s.push("Monorepo"),t.hasGitRepo&&s.push("Git"),t.hasPackageJson&&s.push("Node.js"),t.hasCargo&&s.push("Rust"),t.hasGoMod&&s.push("Go"),t.hasPyproject&&s.push("Python"),s),l=e.progress?function(e){if(0===e.milestonesTotal)return null;let t=[];return e.activeMilestone&&t.push(e.activeMilestone),e.activeSlice&&t.push(e.activeSlice),e.phase&&t.push(e.phase),t.join(" \xb7 ")||null}(e.progress):null,d=e.progress?`${e.progress.milestonesCompleted}/${e.progress.milestonesTotal}`:null;return(0,a.jsxs)("button",{type:"button",onClick:()=>T(e),disabled:!!N,className:(0,L.cn)("group flex w-full items-start gap-3.5 rounded-xl border px-4 py-3.5 text-left transition-all duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.98]",r?"border-foreground/30 bg-foreground/[0.06]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50",N&&!r&&"opacity-40 pointer-events-none"),children:[(0,a.jsx)("div",{className:(0,L.cn)("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg mt-0.5","active-gsd"===e.kind?"bg-success/10":"bg-foreground/[0.04]"),children:r?(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin text-muted-foreground"}):(0,a.jsx)(i,{className:(0,L.cn)("h-4 w-4",n.color)})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground truncate",children:e.name}),(0,a.jsx)("span",{className:(0,L.cn)("text-[10px] font-medium shrink-0",n.color),children:n.label})]}),o.length>0&&(0,a.jsx)("div",{className:"mt-1 flex items-center gap-1.5",children:o.map(e=>(0,a.jsx)("span",{className:"rounded bg-foreground/[0.04] px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e},e))}),l&&(0,a.jsx)("div",{className:"mt-1.5 text-[11px] text-muted-foreground",children:l}),e.progress&&e.progress.milestonesTotal>0&&(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-foreground/[0.06]",children:(0,a.jsx)("div",{className:"h-full rounded-full bg-success/60 transition-all",style:{width:`${Math.round(e.progress.milestonesCompleted/e.progress.milestonesTotal*100)}%`}})}),(0,a.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground",children:d})]})]}),(0,a.jsx)(eI.A,{className:"mt-1 h-4 w-4 shrink-0 text-muted-foreground/50 transition-all group-hover:text-muted-foreground group-hover:translate-x-0.5"})]},e.path)})}),!c&&n&&0===l.length&&!m&&(0,a.jsxs)("div",{className:"rounded-xl border border-border/50 bg-card/50 px-4 py-6 text-center text-sm text-muted-foreground",children:["No projects found in ",n]}),!c&&n&&(0,a.jsx)(a.Fragment,{children:x?(0,a.jsxs)(tm.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},transition:{duration:.2},className:"rounded-xl border border-border/50 bg-card/50 p-4 space-y-3",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:"New project"}),(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),P()},className:"space-y-2",children:[(0,a.jsx)(eX.p,{ref:w,value:g,onChange:e=>{f(e.target.value),y(null)},placeholder:"my-project",autoComplete:"off",className:"text-sm",disabled:b}),g&&!A&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:"Letters, numbers, hyphens, underscores, dots. Must start with a letter or number."}),R&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:"A project with this name already exists"}),j&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:j}),g&&A&&!R&&(0,a.jsxs)("p",{className:"font-mono text-xs text-muted-foreground",children:[n,"/",g]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,a.jsxs)(H,{type:"submit",size:"sm",disabled:!_,className:"gap-1.5 transition-transform active:scale-[0.96]",children:[b?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(t4.A,{className:"h-3.5 w-3.5"}),"Create & open"]}),(0,a.jsx)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>{p(!1),f(""),y(null)},disabled:b,className:"text-muted-foreground",children:"Cancel"})]})]})]}):(0,a.jsxs)("button",{type:"button",onClick:()=>p(!0),disabled:!!N,className:(0,L.cn)("flex w-full items-center gap-3.5 rounded-xl border border-dashed px-4 py-3.5 text-left transition-all duration-200","border-border/50 text-muted-foreground hover:border-foreground/15 hover:text-foreground","active:scale-[0.98]",N&&"opacity-40 pointer-events-none"),children:[(0,a.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-foreground/[0.04]",children:(0,a.jsx)(t4.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Create new project"}),(0,a.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Initialize a new directory with Git"})]})]})})]}),(0,a.jsxs)(tm.P.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.15,duration:.3},className:"mt-8 flex w-full max-w-lg items-center justify-between",children:[(0,a.jsx)(H,{variant:"ghost",onClick:t,className:"text-muted-foreground transition-transform active:scale-[0.96]",children:"Back"}),(0,a.jsxs)(H,{onClick:()=>{s?.(),e("")},className:"group gap-2 transition-transform active:scale-[0.96]",children:["Finish setup",(0,a.jsx)(eg.A,{className:"h-4 w-4 transition-transform group-hover:scale-110"})]})]})]})}let t7=[{id:"welcome",label:"Welcome"},{id:"mode",label:"Mode"},{id:"provider",label:"Provider"},{id:"authenticate",label:"Auth"},{id:"devRoot",label:"Root"},{id:"optional",label:"Extras"},{id:"remote",label:"Remote"},{id:"ready",label:"Ready"},{id:"project",label:"Project"}],t9=t7.length,se=[],st={enter:e=>({x:e>0?50:-50,opacity:0}),center:{x:0,opacity:1},exit:e=>({x:e<0?50:-50,opacity:0})};function ss({current:e,total:t}){return(0,a.jsx)("div",{className:"flex items-center gap-1",children:Array.from({length:t},(t,s)=>(0,a.jsx)("div",{className:(0,L.cn)("rounded-full transition-all duration-300",s===e?"h-1.5 w-5 bg-foreground":s<e?"h-1.5 w-1.5 bg-foreground/40":"h-1.5 w-1.5 bg-foreground/10")},s))})}function sa(){let e=(0,J.gF)(),{refreshOnboarding:t,saveApiKey:s,startProviderFlow:n,submitProviderFlowInput:o,cancelProviderFlow:l,refreshBoot:d}=(0,J._l)(),c=tb(),u=e.boot?.onboarding,m=c.isActive("forceOnboarding"),h="idle"!==e.onboardingRequestState,[x,p]=(0,i.useState)(0),[g,f]=(0,i.useState)(0),[b,v]=(0,i.useState)(null),[j,y]=(0,i.useState)(!1),[w,N]=(0,tv.s1)(),[S,k]=(0,i.useState)(w),C=u?.required.providers??se,A=(0,i.useMemo)(()=>{if(u?.activeFlow?.providerId)return u.activeFlow.providerId;if(b&&C.some(e=>e.id===b))return b;let e=C.find(e=>!e.configured&&e.recommended);if(e)return e.id;let t=C.find(e=>!e.configured);return t?t.id:C[0]?.id??null},[u?.activeFlow?.providerId,C,b]),R=j&&!u?.locked&&!h,[_,T]=(0,i.useState)(!1),P=(0,i.useCallback)(e=>{3===e&&u?.locked?T(!0):3!==e||u?.locked||T(!1),f(e>x?1:-1),p(e)},[x,u?.locked]);(0,i.useEffect)(()=>{if(!u||3!==x||!_)return;let e=!u.locked,t="succeeded"===u.bridgeAuthRefresh.phase||"idle"===u.bridgeAuthRefresh.phase;if(!e||!t)return;let s=window.setTimeout(()=>P(4),0);return()=>window.clearTimeout(s)},[u,P,x,_]);let E=(0,i.useMemo)(()=>C.find(e=>e.id===A)??null,[A,C]);if(!u)return null;let I=!u.locked||u.lastValidation?.status==="succeeded"&&("succeeded"===u.bridgeAuthRefresh.phase||"idle"===u.bridgeAuthRefresh.phase);if(!m&&(I||R))return null;let F=t7[x]?.label??"";return(0,a.jsxs)("div",{className:"pointer-events-auto absolute inset-0 z-30 flex flex-col bg-background","data-testid":"onboarding-gate",children:[(0,a.jsxs)("header",{className:"relative z-10 flex h-12 shrink-0 items-center justify-between px-5 md:px-8",children:[(0,a.jsxs)("div",{className:"flex w-24 items-center gap-2",children:[(0,a.jsx)(r.default,{src:"/logo-white.svg",alt:"GSD",width:57,height:16,className:"hidden h-4 w-auto dark:block"}),(0,a.jsx)(r.default,{src:"/logo-black.svg",alt:"GSD",width:57,height:16,className:"h-4 w-auto dark:hidden"})]}),(0,a.jsx)("div",{className:"absolute inset-x-0 flex justify-center pointer-events-none",children:(0,a.jsx)("div",{className:"pointer-events-auto",children:(0,a.jsx)(ss,{current:x,total:t9})})}),(0,a.jsx)("div",{className:"flex w-24 justify-end",children:(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:F})})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,a.jsx)("div",{className:"mx-auto flex min-h-full w-full max-w-2xl flex-col justify-center px-5 py-10 md:px-8 md:py-16",children:(0,a.jsx)(tu.N,{mode:"wait",custom:g,children:(0,a.jsxs)(tm.P.div,{custom:g,variants:st,initial:"enter",animate:"center",exit:"exit",transition:{type:"spring",stiffness:400,damping:35,opacity:{duration:.15}},children:[0===x&&(0,a.jsx)(tj,{onNext:()=>P(1)}),1===x&&(0,a.jsx)(tS,{selected:S,onSelect:e=>{k(e),N(e)},onNext:()=>P(2),onBack:()=>P(0)}),2===x&&(0,a.jsx)(t_,{providers:u.required.providers,selectedId:A,onSelect:e=>{v(e),P(3)},onNext:()=>P(4),onBack:()=>P(1)}),3===x&&E&&(0,a.jsx)(tq,{provider:E,activeFlow:u.activeFlow,lastValidation:u.lastValidation,requestState:e.onboardingRequestState,requestProviderId:e.onboardingRequestProviderId,onSaveApiKey:async(e,t)=>{let a=await s(e,t);return a&&!a.locked&&("succeeded"===a.bridgeAuthRefresh.phase||"idle"===a.bridgeAuthRefresh.phase)&&(y(!0),d()),a},onStartFlow:e=>void n(e),onSubmitFlowInput:(e,t)=>void o(e,t),onCancelFlow:e=>void l(e),onBack:()=>P(2),onNext:()=>P(2),bridgeRefreshPhase:u.bridgeAuthRefresh.phase,bridgeRefreshError:u.bridgeAuthRefresh.error}),4===x&&(0,a.jsx)(tV,{onBack:()=>P(2),onNext:()=>P(5)}),5===x&&(0,a.jsx)(tY,{sections:u.optional.sections,onBack:()=>P(4),onNext:()=>P(6)}),6===x&&(0,a.jsx)(t5,{onBack:()=>P(5),onNext:()=>P(7)}),7===x&&(0,a.jsx)(t2,{providerLabel:u.lastValidation?.providerId?u.required.providers.find(e=>e.id===u.lastValidation?.providerId)?.label??"Provider":"Provider",onFinish:()=>P(8)}),8===x&&(0,a.jsx)(t6,{onBack:()=>P(7),onBeforeSwitch:()=>{c.isActive("forceOnboarding")&&c.toggle("forceOnboarding"),y(!0)},onFinish:()=>{(0,X.k8)("dashboard"),d()}})]},x)})})})]})}var sr=s(64479),sn=s(90718),si=s(48334),so=s(24332),sl=s(91958),sd=s(42804),sc=s(43728),su=s(46029),sm=s(25221),sh=s(61878),sx=s(6962),sp=s(54452),sg=s(66609),sf=s(8678);function sb({className:e,...t}){return(0,a.jsx)(sf.bL,{"data-slot":"switch",className:(0,L.cn)("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:(0,a.jsx)(sf.zi,{"data-slot":"switch-thumb",className:"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"})})}var sv=s(22112),sj=s(32967);function sy({severity:e,className:t}){let s=(0,L.cn)("h-3.5 w-3.5 shrink-0",t);switch(e){case"error":case"critical":return(0,a.jsx)(t$.A,{className:(0,L.cn)(s,"text-destructive")});case"warning":return(0,a.jsx)(eU.A,{className:(0,L.cn)(s,"text-warning")});default:return(0,a.jsx)(eO.A,{className:(0,L.cn)(s,"text-info")})}}function sw(e){return"error"===e||"critical"===e?"destructive":"warning"===e?"secondary":"outline"}function sN({title:e,subtitle:t,status:s,onRefresh:r,refreshing:n}){return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),s,t&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t})]}),(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:r,disabled:n,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3 w-3",n&&"animate-spin")}),"Refresh"]})]})}function sS({message:e}){return(0,a.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:e})}function sk({label:e}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),e]})}function sC({message:e}){return(0,a.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-5 text-center text-xs text-muted-foreground",children:e})}function sA({label:e,value:t,variant:s}){return(0,a.jsxs)("div",{className:(0,L.cn)("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","error"===s&&"border-destructive/20 bg-destructive/5 text-destructive","warning"===s&&"border-warning/20 bg-warning/5 text-warning","info"===s&&"border-info/20 bg-info/5 text-info",(!s||"default"===s)&&"border-border/50 bg-card/50 text-foreground/80"),children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e}),(0,a.jsx)("span",{className:"font-medium tabular-nums",children:t})]})}function sR({anomaly:e}){return(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(sy,{severity:e.severity}),(0,a.jsx)(tA,{variant:sw(e.severity),className:"text-[10px] px-1.5 py-0",children:e.severity}),(0,a.jsx)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.type}),e.unitId&&(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground font-mono truncate",children:[e.unitType,"/",e.unitId]})]}),(0,a.jsx)("p",{className:"text-xs text-foreground",children:e.summary}),e.details&&e.details!==e.summary&&(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:e.details})]})}function s_(){let e=(0,J.gF)(),{loadForensicsDiagnostics:t}=(0,J._l)(),s=e.commandSurface.diagnostics.forensics,r=s.data,n="loading"===s.phase;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"diagnostics-forensics",children:[(0,a.jsx)(sN,{title:"Forensic Analysis",subtitle:r?new Date(r.timestamp).toLocaleString():null,status:r?(0,a.jsx)("span",{className:(0,L.cn)("inline-block h-1.5 w-1.5 rounded-full",r.anomalies.length>0?"bg-warning":"bg-success")}):null,onRefresh:()=>void t(),refreshing:n}),s.error&&(0,a.jsx)(sS,{message:s.error}),n&&!r&&(0,a.jsx)(sk,{label:"Running forensic analysis…"}),r&&(0,a.jsxs)(a.Fragment,{children:[r.metrics&&(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(sA,{label:"Units",value:r.metrics.totalUnits}),(0,a.jsx)(sA,{label:"Cost",value:(0,J.BD)(r.metrics.totalCost)}),(0,a.jsx)(sA,{label:"Duration",value:`${Math.round(r.metrics.totalDuration/1e3)}s`}),(0,a.jsx)(sA,{label:"Traces",value:r.unitTraceCount})]}),r.crashLock?(0,a.jsxs)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(tT.A,{className:"h-3.5 w-3.5 text-destructive"}),(0,a.jsx)("span",{className:"text-xs font-medium text-destructive",children:"Crash Lock Active"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-[11px]",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"PID"}),(0,a.jsx)("span",{className:"font-mono text-foreground/80",children:r.crashLock.pid}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"Started"}),(0,a.jsx)("span",{className:"text-foreground/80",children:new Date(r.crashLock.startedAt).toLocaleString()}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"Unit"}),(0,a.jsxs)("span",{className:"font-mono text-foreground/80",children:[r.crashLock.unitType,"/",r.crashLock.unitId]})]})]}):(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-border/50 bg-card/50 px-3 py-2 text-xs text-muted-foreground",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 text-success"}),"No crash lock"]}),r.anomalies.length>0?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Anomalies (",r.anomalies.length,")"]}),r.anomalies.map((e,t)=>(0,a.jsx)(sR,{anomaly:e},t))]}):(0,a.jsx)(sC,{message:"No anomalies detected"}),r.recentUnits.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Recent Units (",r.recentUnits.length,")"]}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Type"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"ID"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Model"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Duration"})]})}),(0,a.jsx)("tbody",{children:r.recentUnits.map((e,t)=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.type}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[120px]",children:e.id}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-muted-foreground",children:e.model}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,J.BD)(e.cost)}),(0,a.jsxs)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:[Math.round(e.duration/1e3),"s"]})]},t))})]})})]})]})]})}function sT({issue:e}){return(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(sy,{severity:e.severity}),(0,a.jsx)(tA,{variant:sw(e.severity),className:"text-[10px] px-1.5 py-0",children:e.severity}),(0,a.jsx)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.code.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}),e.scope&&(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.scope}),e.fixable&&(0,a.jsxs)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0 border-success/30 text-success",children:[(0,a.jsx)(sj.A,{className:"h-2.5 w-2.5 mr-0.5"}),"fixable"]})]}),(0,a.jsx)("p",{className:"text-xs text-foreground",children:e.message}),e.file&&(0,a.jsx)("p",{className:"text-[10px] font-mono text-muted-foreground truncate",children:e.file})]})}function sP(){let e=(0,J.gF)(),{loadDoctorDiagnostics:t,applyDoctorFixes:s}=(0,J._l)(),r=e.commandSurface.diagnostics.doctor,n=r.data,i="loading"===r.phase,o=n?.summary.fixable??0;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"diagnostics-doctor",children:[(0,a.jsx)(sN,{title:"Doctor Health Check",status:n?(0,a.jsx)("span",{className:(0,L.cn)("inline-block h-1.5 w-1.5 rounded-full",n.ok?"bg-success":"bg-destructive")}):null,onRefresh:()=>void t(),refreshing:i}),r.error&&(0,a.jsx)(sS,{message:r.error}),i&&!n&&(0,a.jsx)(sk,{label:"Running health check…"}),n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(sA,{label:"Total",value:n.summary.total}),n.summary.errors>0&&(0,a.jsx)(sA,{label:"Errors",value:n.summary.errors,variant:"error"}),n.summary.warnings>0&&(0,a.jsx)(sA,{label:"Warnings",value:n.summary.warnings,variant:"warning"}),n.summary.infos>0&&(0,a.jsx)(sA,{label:"Info",value:n.summary.infos,variant:"info"}),o>0&&(0,a.jsx)(sA,{label:"Fixable",value:o,variant:"info"})]}),o>0&&(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)(H,{type:"button",variant:"default",size:"sm",onClick:()=>void s(),disabled:r.fixPending,className:"h-7 gap-1.5 text-xs","data-testid":"doctor-apply-fixes",children:[r.fixPending?(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(sj.A,{className:"h-3 w-3"}),"Apply Fixes (",o,")"]}),r.lastFixError&&(0,a.jsx)("span",{className:"text-[11px] text-destructive",children:r.lastFixError})]}),r.lastFixResult&&r.lastFixResult.fixesApplied.length>0&&(0,a.jsxs)("div",{className:"rounded-lg border border-success/20 bg-success/5 px-3 py-2.5 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 text-success"}),(0,a.jsx)("span",{className:"text-xs font-medium text-success",children:"Fixes Applied"})]}),(0,a.jsx)("ul",{className:"space-y-0.5 pl-5",children:r.lastFixResult.fixesApplied.map((e,t)=>(0,a.jsx)("li",{className:"text-[11px] text-foreground/80 list-disc",children:e},t))})]}),n.issues.length>0?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Issues (",n.issues.length,")"]}),n.issues.map((e,t)=>(0,a.jsx)(sT,{issue:e},t))]}):(0,a.jsx)(sC,{message:"No issues found — workspace is healthy"})]})]})}function sE({suggestion:e}){return(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(sy,{severity:e.severity}),(0,a.jsx)(tA,{variant:sw(e.severity),className:"text-[10px] px-1.5 py-0",children:e.severity}),(0,a.jsx)("span",{className:"text-[11px] font-medium text-foreground/80",children:e.skillName}),(0,a.jsx)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.trigger.replace(/_/g," ")})]}),(0,a.jsx)("p",{className:"text-xs text-foreground",children:e.message})]})}function sI(){let e=(0,J.gF)(),{loadSkillHealthDiagnostics:t}=(0,J._l)(),s=e.commandSurface.diagnostics.skillHealth,r=s.data,n="loading"===s.phase;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"diagnostics-skill-health",children:[(0,a.jsx)(sN,{title:"Skill Health",subtitle:r?new Date(r.generatedAt).toLocaleString():null,status:r?(0,a.jsx)("span",{className:(0,L.cn)("inline-block h-1.5 w-1.5 rounded-full",r.decliningSkills.length>0?"bg-warning":"bg-success")}):null,onRefresh:()=>void t(),refreshing:n}),s.error&&(0,a.jsx)(sS,{message:s.error}),n&&!r&&(0,a.jsx)(sk,{label:"Analyzing skill health…"}),r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(sA,{label:"Skills",value:r.skills.length}),r.staleSkills.length>0&&(0,a.jsx)(sA,{label:"Stale",value:r.staleSkills.length,variant:"warning"}),r.decliningSkills.length>0&&(0,a.jsx)(sA,{label:"Declining",value:r.decliningSkills.length,variant:"error"}),(0,a.jsx)(sA,{label:"Total units",value:r.totalUnitsWithSkills})]}),r.skills.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Skills (",r.skills.length,")"]}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Skill"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Uses"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Success"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Tokens"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-center font-medium text-muted-foreground",children:"Trend"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Stale"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"})]})}),(0,a.jsx)("tbody",{children:r.skills.map(e=>{var t,s;return(0,a.jsxs)("tr",{className:(0,L.cn)("border-b border-border/50 last:border-0",e.flagged&&"bg-destructive/3"),children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[e.name,e.flagged&&(0,a.jsx)(eU.A,{className:"h-3 w-3 text-warning shrink-0"})]})}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:e.totalUses}),(0,a.jsxs)("td",{className:(0,L.cn)("px-2.5 py-1.5 text-right tabular-nums",e.successRate>=.9?"text-success":e.successRate>=.7?"text-warning":"text-destructive"),children:[(100*e.successRate).toFixed(0),"%"]}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:Math.round(e.avgTokens)}),(0,a.jsx)("td",{className:(0,L.cn)("px-2.5 py-1.5 text-center","rising"===(t=e.tokenTrend)?"text-warning":"declining"===t?"text-destructive":"text-muted-foreground"),children:"rising"===(s=e.tokenTrend)?"↑":"declining"===s?"↓":"→"}),(0,a.jsx)("td",{className:(0,L.cn)("px-2.5 py-1.5 text-right tabular-nums",e.staleDays>30?"text-warning":"text-foreground/80"),children:e.staleDays>0?`${e.staleDays}d`:"—"}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,J.BD)(e.avgCost)})]},e.name)})})]})})]}),r.staleSkills.length>0&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:"Stale Skills"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.staleSkills.map(e=>(0,a.jsx)(tA,{variant:"secondary",className:"text-[10px] font-mono",children:e},e))})]}),r.decliningSkills.length>0&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:"Declining Skills"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:r.decliningSkills.map(e=>(0,a.jsx)(tA,{variant:"destructive",className:"text-[10px] font-mono",children:e},e))})]}),r.suggestions.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Suggestions (",r.suggestions.length,")"]}),r.suggestions.map((e,t)=>(0,a.jsx)(sE,{suggestion:e},t))]}),0===r.skills.length&&0===r.suggestions.length&&(0,a.jsx)(sC,{message:"No skill usage data available"})]})]})}var sF=s(52530),s$=s(29262),sL=s(31885),sD=s(28063),sM=s(15161),sq=s(88444),sB=s(97810),sU=s(15282);function sO({title:e,subtitle:t,status:s,onRefresh:r,refreshing:n}){return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),s,t&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t})]}),(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:r,disabled:n,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3 w-3",n&&"animate-spin")}),"Refresh"]})]})}function sz({message:e}){return(0,a.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:e})}function sG({label:e}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),e]})}function sW({message:e}){return(0,a.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-5 text-center text-xs text-muted-foreground",children:e})}function sK({label:e,value:t,variant:s}){return(0,a.jsxs)("div",{className:(0,L.cn)("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","error"===s&&"border-destructive/20 bg-destructive/5 text-destructive","warning"===s&&"border-warning/20 bg-warning/5 text-warning","info"===s&&"border-info/20 bg-info/5 text-info",(!s||"default"===s)&&"border-border/50 bg-card/50 text-foreground/80"),children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e}),(0,a.jsx)("span",{className:"font-medium tabular-nums",children:t})]})}function sV({type:e,className:t}){let s=(0,L.cn)("h-3.5 w-3.5 shrink-0",t);switch(e){case"rule":return(0,a.jsx)(sF.A,{className:(0,L.cn)(s,"text-violet-400")});case"pattern":return(0,a.jsx)(s$.A,{className:(0,L.cn)(s,"text-info")});case"lesson":return(0,a.jsx)(sL.A,{className:(0,L.cn)(s,"text-warning")});case"freeform":return(0,a.jsx)(T.A,{className:(0,L.cn)(s,"text-success")})}}function sH(e){switch(e){case"quick-task":return"Quick Task";case"inject":return"Inject";case"defer":return"Defer";case"replan":return"Replan";case"note":return"Note"}}function sY({classification:e,className:t}){let s=(0,L.cn)("h-3 w-3 shrink-0",t);switch(e){case"quick-task":return(0,a.jsx)(eg.A,{className:s});case"inject":return(0,a.jsx)(si.A,{className:s});case"defer":return(0,a.jsx)(sD.A,{className:s});case"replan":return(0,a.jsx)(sM.A,{className:s});case"note":return(0,a.jsx)(sq.A,{className:s})}}let sJ=["quick-task","inject","defer","replan","note"];function sQ({entry:e}){let t=function(e){switch(e){case"rule":return{label:"Rule",className:"border-violet-500/30 bg-violet-500/10 text-violet-400"};case"pattern":return{label:"Pattern",className:"border-info/30 bg-info/10 text-info"};case"lesson":return{label:"Lesson",className:"border-warning/30 bg-warning/10 text-warning"};case"freeform":return{label:"Freeform",className:"border-success/30 bg-success/10 text-success"}}}(e.type);return(0,a.jsx)("div",{className:"group rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 transition-colors hover:bg-card/50",children:(0,a.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,a.jsx)(sV,{type:e.type,className:"mt-0.5"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-foreground truncate",children:e.title}),(0,a.jsx)(tA,{variant:"outline",className:(0,L.cn)("text-[10px] px-1.5 py-0 h-4 shrink-0",t.className),children:t.label})]}),e.content&&(0,a.jsx)("p",{className:"mt-1 text-[11px] text-muted-foreground line-clamp-2 leading-relaxed",children:e.content})]})]})})}function sZ({data:e,phase:t,error:s,onRefresh:r}){return"loading"===t?(0,a.jsx)(sG,{label:"Loading knowledge base…"}):"error"===t&&s?(0,a.jsx)(sz,{message:s}):e&&0!==e.entries.length?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(sO,{title:"Knowledge Base",subtitle:`${e.entries.length} entries`,onRefresh:r,refreshing:"loading"===t}),(0,a.jsx)("div",{className:"space-y-1.5",children:e.entries.map(e=>(0,a.jsx)(sQ,{entry:e},e.id))}),e.lastModified&&(0,a.jsxs)("p",{className:"pt-2 text-[10px] text-muted-foreground",children:["Last modified: ",new Date(e.lastModified).toLocaleString()]})]}):(0,a.jsx)(sW,{message:"No knowledge entries found"})}function sX({entry:e,onResolve:t,resolvePending:s}){let r=function(e){switch(e){case"pending":return{label:"Pending",className:"border-warning/30 bg-warning/10 text-warning"};case"triaged":return{label:"Triaged",className:"border-info/30 bg-info/10 text-info"};case"resolved":return{label:"Resolved",className:"border-success/30 bg-success/10 text-success"}}}(e.status);return(0,a.jsx)("div",{className:"group rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 transition-colors hover:bg-card/50",children:(0,a.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,a.jsx)("div",{className:(0,L.cn)("mt-1 h-2 w-2 shrink-0 rounded-full","pending"===e.status&&"bg-warning","triaged"===e.status&&"bg-info","resolved"===e.status&&"bg-success")}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"text-xs text-foreground",children:e.text}),(0,a.jsx)(tA,{variant:"outline",className:(0,L.cn)("text-[10px] px-1.5 py-0 h-4 shrink-0",r.className),children:r.label}),e.classification&&(0,a.jsx)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 shrink-0 border-border/50 text-muted-foreground",children:sH(e.classification)})]}),e.timestamp&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,a.jsx)(ex.A,{className:"h-2.5 w-2.5"}),e.timestamp]}),e.resolution&&(0,a.jsx)("p",{className:"mt-1 text-[10px] text-muted-foreground italic",children:e.resolution}),"pending"===e.status&&(0,a.jsx)("div",{className:"mt-2 flex flex-wrap gap-1",children:sJ.map(r=>(0,a.jsxs)(H,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:()=>t(e.id,r),className:"h-6 gap-1 px-2 text-[10px] font-normal border-border/50 hover:bg-foreground/5",children:[(0,a.jsx)(sY,{classification:r}),sH(r)]},r))})]})]})})}function s0({data:e,phase:t,error:s,resolvePending:r,resolveError:n,onRefresh:i,onResolve:o}){return"loading"===t?(0,a.jsx)(sG,{label:"Loading captures…"}):"error"===t&&s?(0,a.jsx)(sz,{message:s}):e&&0!==e.entries.length?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)(sO,{title:"Captures",subtitle:`${e.entries.length} total`,status:(0,a.jsxs)("div",{className:"flex gap-1.5",children:[(0,a.jsx)(sK,{label:"Pending",value:e.pendingCount,variant:e.pendingCount>0?"warning":"default"}),(0,a.jsx)(sK,{label:"Actionable",value:e.actionableCount,variant:e.actionableCount>0?"info":"default"})]}),onRefresh:i,refreshing:"loading"===t}),n&&(0,a.jsxs)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:["Resolve error: ",n]}),(0,a.jsx)("div",{className:"space-y-1.5",children:e.entries.map(e=>(0,a.jsx)(sX,{entry:e,onResolve:o,resolvePending:r},e.id))})]}):(0,a.jsx)(sW,{message:"No captures found"})}function s1({initialTab:e}){let[t,s]=(0,i.useState)(e),r=(0,J.gF)(),{loadKnowledgeData:n,loadCapturesData:o,resolveCaptureAction:l}=(0,J._l)(),d=r.commandSurface.knowledgeCaptures,c=d.knowledge,u=d.captures,m=d.resolveRequest,h=u.data,x=h?.pendingCount??0;return(0,a.jsxs)("div",{className:"space-y-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5 border-b border-border/50 px-1",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s("knowledge"),className:(0,L.cn)("flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-all border-b-2 -mb-px","knowledge"===t?"border-foreground/60 text-foreground":"border-transparent text-muted-foreground hover:text-muted-foreground"),children:[(0,a.jsx)(sB.A,{className:"h-3.5 w-3.5"}),"Knowledge"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>s("captures"),className:(0,L.cn)("flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-all border-b-2 -mb-px","captures"===t?"border-foreground/60 text-foreground":"border-transparent text-muted-foreground hover:text-muted-foreground"),children:[(0,a.jsx)(sU.A,{className:"h-3.5 w-3.5"}),"Captures",x>0&&(0,a.jsxs)(tA,{variant:"outline",className:"ml-1 h-4 px-1.5 py-0 text-[10px] border-warning/30 bg-warning/10 text-warning",children:[x," pending"]})]})]}),(0,a.jsx)("div",{className:"p-4",children:"knowledge"===t?(0,a.jsx)(sZ,{data:c.data,phase:c.phase,error:c.error,onRefresh:()=>void n()}):(0,a.jsx)(s0,{data:h,phase:u.phase,error:u.error,resolvePending:m.pending,resolveError:m.lastError,onRefresh:()=>void o(),onResolve:(e,t)=>{l({captureId:e,classification:t,resolution:"Manual browser triage",rationale:"Triaged via web UI"})}})})]})}var s5=s(34220),s2=s(64834),s3=s(15727);function s4({title:e,icon:t,subtitle:s,onRefresh:r,refreshing:n}){return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:t}),(0,a.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),s&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:s})]}),(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:r,disabled:n,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3 w-3",n&&"animate-spin")}),"Refresh"]})]})}function s8({message:e}){return(0,a.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:e})}function s6({label:e}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),e]})}function s7({message:e}){return(0,a.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-5 text-center text-xs text-muted-foreground",children:e})}function s9({label:e,value:t,variant:s}){return(0,a.jsxs)("div",{className:(0,L.cn)("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","info"===s&&"border-info/20 bg-info/5 text-info","warning"===s&&"border-warning/20 bg-warning/5 text-warning","success"===s&&"border-success/20 bg-success/5 text-success",(!s||"default"===s)&&"border-border/50 bg-card/50 text-foreground/80"),children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e}),(0,a.jsx)("span",{className:"font-medium tabular-nums",children:t})]})}function ae({label:e,enabled:t}){return(0,a.jsxs)(tA,{variant:t?"secondary":"outline",className:(0,L.cn)("text-[10px] px-1.5 py-0 font-mono",t?"border-success/30 text-success":"text-muted-foreground"),children:[e,": ",t?"on":"off"]})}function at({label:e,skills:t}){return t?.length?(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:e}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:t.map(e=>(0,a.jsx)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e},e))})]}):null}function as({models:e}){return e&&0!==Object.keys(e).length?(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"Phase Models"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>(0,a.jsxs)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:[e,": ",t]},e))})]}):null}function aa({label:e,children:t}){return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground shrink-0",children:e}),(0,a.jsx)("span",{className:"text-foreground/80 text-right truncate",children:t})]})}function ar(){let e=(0,J.gF)(),{loadSettingsData:t}=(0,J._l)(),s=e.commandSurface.settingsData;return{state:s,data:s.data,busy:"loading"===s.phase,refresh:()=>void t()}}function an(e){return"budget"===e||"burn-max"===e?"warning":"quality"===e?"success":"info"}function ai(){let{state:e,data:t,busy:s,refresh:r}=ar(),n=t?.preferences??null;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"settings-prefs",children:[(0,a.jsx)(s4,{title:"Effective Preferences",icon:(0,a.jsx)(k.A,{className:"h-3.5 w-3.5"}),subtitle:n?`${n.scope} scope`:null,onRefresh:r,refreshing:s}),e.error&&(0,a.jsx)(s8,{message:e.error}),s&&!t&&(0,a.jsx)(s6,{label:"Loading preferences…"}),t&&!n&&(0,a.jsx)(s7,{message:"No preferences file found"}),n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(s9,{label:"Mode",value:n.mode??"solo",variant:"info"}),(0,a.jsx)(s9,{label:"Token Profile",value:n.tokenProfile??"balanced",variant:an(n.tokenProfile)}),n.customInstructions?.length?(0,a.jsx)(s9,{label:"Custom Instructions",value:n.customInstructions.length}):null]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(as,{models:n.models}),(0,a.jsx)(at,{label:"Always use",skills:n.alwaysUseSkills}),(0,a.jsx)(at,{label:"Prefer",skills:n.preferSkills}),(0,a.jsx)(at,{label:"Avoid",skills:n.avoidSkills}),n.models&&0!==Object.keys(n.models).length?!n.alwaysUseSkills?.length&&!n.preferSkills?.length&&!n.avoidSkills?.length&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"No skill preferences configured"}):!n.alwaysUseSkills?.length&&!n.preferSkills?.length&&!n.avoidSkills?.length&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:"No model or skill preferences configured"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-x-6 gap-y-1.5 rounded-lg border border-border/50 bg-card/50 px-3 py-2.5",children:[(0,a.jsx)(aa,{label:"Auto-Supervisor",children:n.autoSupervisor?.enabled?(0,a.jsxs)("span",{className:"text-success",children:["on",null!=n.autoSupervisor.softTimeoutMinutes&&` (${n.autoSupervisor.softTimeoutMinutes}m)`]}):(0,a.jsx)("span",{className:"text-muted-foreground",children:"off"})}),(0,a.jsx)(aa,{label:"UAT Dispatch",children:(0,a.jsx)("span",{className:n.uatDispatch?"text-success":"text-muted-foreground",children:n.uatDispatch?"on":"off"})}),(0,a.jsx)(aa,{label:"Auto-Visualize",children:(0,a.jsx)("span",{className:n.autoVisualize?"text-success":"text-muted-foreground",children:n.autoVisualize?"on":"off"})}),(0,a.jsx)(aa,{label:"Service Tier",children:(0,a.jsx)("span",{className:"font-mono text-[10px]",children:n.serviceTier??"default"})}),(0,a.jsx)(aa,{label:"Show Token Cost",children:(0,a.jsx)("span",{className:n.showTokenCost?"text-success":"text-muted-foreground",children:n.showTokenCost?"on":"off"})}),(0,a.jsx)(aa,{label:"Context Selection",children:(0,a.jsx)("span",{className:"font-mono text-[10px]",children:n.contextSelection??"full"})}),(0,a.jsx)(aa,{label:"Context Window",children:(0,a.jsx)("span",{className:"font-mono text-[10px]",children:"number"==typeof n.contextWindowOverride?n.contextWindowOverride:"auto"})}),(0,a.jsx)(aa,{label:"Language",children:(0,a.jsx)("span",{className:"font-mono text-[10px]",children:n.language??"default"})}),(0,a.jsx)(aa,{label:"Reactive Exec",children:(0,a.jsx)("span",{className:n.reactiveExecution?.enabled?"text-success":"text-muted-foreground",children:n.reactiveExecution?.enabled?"on":"off"})}),(0,a.jsx)(aa,{label:"Gate Eval",children:(0,a.jsx)("span",{className:n.gateEvaluation?.enabled?"text-success":"text-muted-foreground",children:n.gateEvaluation?.enabled?"on":"off"})}),(0,a.jsx)(aa,{label:"Slice Parallel",children:(0,a.jsx)("span",{className:n.sliceParallel?.enabled?"text-success":"text-muted-foreground",children:n.sliceParallel?.enabled?"on":"off"})}),(0,a.jsx)(aa,{label:"Phase Controls",children:(0,a.jsxs)("span",{className:"font-mono text-[10px]",children:[n.phases?Object.values(n.phases).filter(e=>!0===e).length:0," enabled"]})}),(0,a.jsx)(aa,{label:"Preference Scope",children:(0,a.jsx)("span",{className:"font-mono text-[10px]",children:n.scope})})]}),(0,a.jsxs)("div",{className:"text-[11px] text-muted-foreground truncate font-mono",children:["Source: ",n.path]}),n.warnings&&n.warnings.length>0&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-warning",children:[(0,a.jsx)(eU.A,{className:"h-3 w-3"}),(0,a.jsxs)("span",{className:"font-medium",children:["Warnings (",n.warnings.length,")"]})]}),n.warnings.map((e,t)=>(0,a.jsx)("div",{className:"rounded border border-warning/20 bg-warning/5 px-2.5 py-1.5 text-[11px] text-warning",children:e},t))]})]})]})}function ao({tier:e,modelId:t}){return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground capitalize",children:e}),(0,a.jsx)("span",{className:"font-mono text-[11px] text-foreground/80 truncate max-w-[200px]",children:t??(0,a.jsx)("span",{className:"text-muted-foreground italic",children:"default"})})]})}function al({tier:e,success:t,fail:s}){return 0===t+s?null:(0,a.jsxs)(tA,{variant:"outline",className:(0,L.cn)("text-[10px] px-1.5 py-0 font-mono",s>0?"border-destructive/20 text-destructive":"text-muted-foreground"),children:[e,": ",t,"✓",s>0&&(0,a.jsxs)("span",{children:[" ",s,"✗"]})]})}function ad(){let{state:e,data:t,busy:s,refresh:r}=ar(),n=t?.routingConfig??null,i=t?.routingHistory??null;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"settings-model-routing",children:[(0,a.jsx)(s4,{title:"Model Routing",icon:(0,a.jsx)(eB.A,{className:"h-3.5 w-3.5"}),onRefresh:r,refreshing:s}),e.error&&(0,a.jsx)(s8,{message:e.error}),s&&!t&&(0,a.jsx)(s6,{label:"Loading routing config…"}),t&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsxs)(tA,{variant:n?.enabled?"secondary":"outline",className:(0,L.cn)("text-[10px] px-2 py-0.5",n?.enabled?"border-success/30 text-success":"text-muted-foreground"),children:["Dynamic Routing: ",n?.enabled?"enabled":"disabled"]})}),n?.tier_models&&(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1.5",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Tier Assignments"}),(0,a.jsx)(ao,{tier:"light",modelId:n.tier_models.light}),(0,a.jsx)(ao,{tier:"standard",modelId:n.tier_models.standard}),(0,a.jsx)(ao,{tier:"heavy",modelId:n.tier_models.heavy})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,a.jsx)(ae,{label:"escalate_on_failure",enabled:n?.escalate_on_failure}),(0,a.jsx)(ae,{label:"budget_pressure",enabled:n?.budget_pressure}),(0,a.jsx)(ae,{label:"cross_provider",enabled:n?.cross_provider}),(0,a.jsx)(ae,{label:"hooks",enabled:n?.hooks})]}),i?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(s9,{label:"Patterns",value:Object.keys(i.patterns).length}),(0,a.jsx)(s9,{label:"Feedback",value:i.feedback.length})]}),Object.keys(i.patterns).length>0&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground",children:"Top Patterns"}),(0,a.jsx)("div",{className:"space-y-2",children:(function(e,t=5){return Object.entries(e.patterns).map(([e,t])=>({name:e,total:t.light.success+t.light.fail+t.standard.success+t.standard.fail+t.heavy.success+t.heavy.fail,pattern:t})).sort((e,t)=>t.total-e.total).slice(0,t)})(i).map(({name:e,total:t,pattern:s})=>(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-mono text-foreground/80 truncate",children:e}),(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums shrink-0",children:[t," attempts"]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1",children:[(0,a.jsx)(al,{tier:"L",success:s.light.success,fail:s.light.fail}),(0,a.jsx)(al,{tier:"S",success:s.standard.success,fail:s.standard.fail}),(0,a.jsx)(al,{tier:"H",success:s.heavy.success,fail:s.heavy.fail})]})]},e))})]})]}):(0,a.jsx)(s7,{message:"No routing history yet"})]})]})}function ac(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function au(){var e;let{state:t,data:s,busy:r,refresh:n}=ar(),i=s?.preferences??null,o=s?.budgetAllocation??null,l=s?.projectTotals??null;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"settings-budget",children:[(0,a.jsx)(s4,{title:"Budget & Costs",icon:(0,a.jsx)(ep.A,{className:"h-3.5 w-3.5"}),onRefresh:n,refreshing:r}),t.error&&(0,a.jsx)(s8,{message:t.error}),r&&!s&&(0,a.jsx)(s6,{label:"Loading budget data…"}),s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(s9,{label:"Ceiling",value:i?.budgetCeiling!=null?(0,J.BD)(i.budgetCeiling):"Not set",variant:i?.budgetCeiling!=null?"warning":"default"}),(0,a.jsx)(s9,{label:"Enforcement",value:i?.budgetEnforcement??"Not set",variant:i?.budgetEnforcement?"halt"===(e=i.budgetEnforcement)?"warning":"pause"===e?"info":"success":"default"}),(0,a.jsx)(s9,{label:"Token Profile",value:i?.tokenProfile??"balanced",variant:an(i?.tokenProfile)}),(0,a.jsx)(s9,{label:"Service Tier",value:i?.serviceTier??"default"}),(0,a.jsx)(s9,{label:"Token Cost",value:i?.showTokenCost?"shown":"hidden"})]}),o&&(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1.5",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Context Budget Allocations"}),(0,a.jsxs)(aa,{label:"Summary Budget",children:[ac(o.summaryBudgetChars)," chars"]}),(0,a.jsxs)(aa,{label:"Inline Context",children:[ac(o.inlineContextBudgetChars)," chars"]}),(0,a.jsxs)(aa,{label:"Verification",children:[ac(o.verificationBudgetChars)," chars"]}),(0,a.jsxs)(aa,{label:"Task Count Range",children:[o.taskCountRange.min,"–",o.taskCountRange.max]}),(0,a.jsxs)(aa,{label:"Continue Threshold",children:[o.continueThresholdPercent,"%"]})]}),l?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Project Cost Totals"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(s9,{label:"Units",value:l.units}),(0,a.jsx)(s9,{label:"Total Cost",value:(0,J.BD)(l.cost),variant:"warning"}),(0,a.jsx)(s9,{label:"Duration",value:`${Math.round(l.duration/1e3)}s`})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1.5",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Token Breakdown"}),(0,a.jsx)(aa,{label:"Input",children:(0,J._y)(l.tokens.input)}),(0,a.jsx)(aa,{label:"Output",children:(0,J._y)(l.tokens.output)}),(0,a.jsx)(aa,{label:"Cache Read",children:(0,J._y)(l.tokens.cacheRead)}),(0,a.jsx)(aa,{label:"Cache Write",children:(0,J._y)(l.tokens.cacheWrite)}),(0,a.jsx)(aa,{label:"Total",children:(0,J._y)(l.tokens.total)})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(s9,{label:"Tool Calls",value:l.toolCalls}),(0,a.jsx)(s9,{label:"Assistant Msgs",value:l.assistantMessages}),(0,a.jsx)(s9,{label:"User Msgs",value:l.userMessages})]})]}):(0,a.jsx)(s7,{message:"No execution metrics yet"})]})]})}let am=[{value:"slack",label:"Slack",description:"Get pinged in a Slack channel",idPlaceholder:"Channel ID (e.g. C01ABCD2EFG)"},{value:"discord",label:"Discord",description:"Get pinged in a Discord channel",idPlaceholder:"Channel ID (17–20 digit number)"},{value:"telegram",label:"Telegram",description:"Get pinged via Telegram bot",idPlaceholder:"Chat ID (numeric, may start with -)"}],ah={slack:/^[A-Z0-9]{9,12}$/,discord:/^\d{17,20}$/,telegram:/^-?\d{5,20}$/};function ax(){let{data:e,busy:t,refresh:s}=ar(),r=e?.preferences?.remoteQuestions??null,[n,o]=(0,i.useState)(!1),[l,c]=(0,i.useState)(null),[u,m]=(0,i.useState)(!0),[h,x]=(0,i.useState)(!1),[p,g]=(0,i.useState)("slack"),[f,b]=(0,i.useState)(""),[v,j]=(0,i.useState)(5),[y,w]=(0,i.useState)(5),[N,S]=(0,i.useState)(""),[k,C]=(0,i.useState)(!1),[A,R]=(0,i.useState)(!1),[_,T]=(0,i.useState)(null),[P,I]=(0,i.useState)(!1),[F,$]=(0,i.useState)(!1),[D,M]=(0,i.useState)(null),[q,B]=(0,i.useState)(null),[U,O]=(0,i.useState)(!1),[z,G]=(0,i.useState)(!1),W=(0,i.useCallback)(async()=>{try{m(!0);let e=await (0,en.tm)("/api/remote-questions",{cache:"no-store"});if(!e.ok){let t=await e.json().catch(()=>({error:"Unknown error"}));M(t.error??`API error ${e.status}`);return}let t=await e.json();o(t.envVarSet),c(t.envVarName),x(t.tokenSet),O("configured"===t.status&&null!==t.config),t.config&&(g(t.config.channel),b(t.config.channelId),j(t.config.timeoutMinutes),w(t.config.pollIntervalSeconds))}catch(e){M(e instanceof Error?e.message:"Failed to fetch remote questions status")}finally{m(!1)}},[]);(0,i.useEffect)(()=>{W()},[W]),(0,i.useEffect)(()=>{r?.channel&&(g(r.channel),b(r.channelId??""),j(r.timeoutMinutes??5),w(r.pollIntervalSeconds??5))},[r]);let K=f.trim().length>0&&ah[p].test(f.trim())&&!P&&!F;(0,i.useEffect)(()=>{if(!q)return;let e=setTimeout(()=>B(null),3e3);return()=>clearTimeout(e)},[q]);let V=async()=>{I(!0),M(null),B(null);try{let e=await (0,en.tm)("/api/remote-questions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:p,channelId:f.trim(),timeoutMinutes:v,pollIntervalSeconds:y})}),t=await e.json();if(!e.ok)return void M(t.error??`Save failed (${e.status})`);B("Configuration saved"),O(!0),s(),W()}catch(e){M(e instanceof Error?e.message:"Failed to save configuration")}finally{I(!1)}},Y=async()=>{$(!0),M(null),B(null);try{let e=await (0,en.tm)("/api/remote-questions",{method:"DELETE"}),t=await e.json();if(!e.ok)return void M(t.error??`Disconnect failed (${e.status})`);B("Channel disconnected"),O(!1),b(""),j(5),w(5),g("slack"),x(!1),s(),W()}catch(e){M(e instanceof Error?e.message:"Failed to disconnect channel")}finally{$(!1)}},J=async()=>{if(N.trim()){R(!0),M(null),T(null);try{let e=await (0,en.tm)("/api/remote-questions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:p,token:N.trim()})}),t=await e.json();if(!e.ok)return void M(t.error??`Token save failed (${e.status})`);T(`Token saved (${t.masked})`),x(!0),S(""),C(!1),W()}catch(e){M(e instanceof Error?e.message:"Failed to save token")}finally{R(!1)}}};(0,i.useEffect)(()=>{if(!_)return;let e=setTimeout(()=>T(null),3e3);return()=>clearTimeout(e)},[_]);let Q=l??`${p.toUpperCase()}_BOT_TOKEN`,Z=am.find(e=>e.value===p);return(t||u)&&!e&&!U?(0,a.jsxs)("div",{className:"space-y-5","data-testid":"settings-remote-questions",children:[(0,a.jsx)(s4,{title:"Integrations",icon:(0,a.jsx)(su.A,{className:"h-3.5 w-3.5"}),subtitle:"Remote notifications",onRefresh:()=>{s(),W()},refreshing:!0}),(0,a.jsx)(s6,{label:"Loading integration status…"})]}):(0,a.jsxs)("div",{className:"space-y-5","data-testid":"settings-remote-questions",children:[(0,a.jsx)(s4,{title:"Integrations",icon:(0,a.jsx)(su.A,{className:"h-3.5 w-3.5"}),subtitle:"Remote notifications",onRefresh:()=>{s(),W()},refreshing:t||u}),(0,a.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Connect a chat channel so the agent pings you when it needs input instead of waiting silently."}),D&&(0,a.jsx)(s8,{message:D}),q&&(0,a.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-success/15 bg-success/[0.04] px-4 py-3 text-sm text-muted-foreground",children:[(0,a.jsx)(d.A,{className:"h-4 w-4 shrink-0 text-success"}),q]}),U&&(0,a.jsxs)("div",{className:"rounded-xl border border-success/15 bg-success/[0.04] px-4 py-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg border border-success/20 bg-success/10",children:(0,a.jsx)(d.A,{className:"h-4.5 w-4.5 text-success"})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-sm font-medium text-foreground",children:["Connected to ",Z.label]}),(0,a.jsx)("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:f})]})]}),(0,a.jsx)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>void Y(),disabled:F,className:"h-7 text-xs text-destructive/70 hover:text-destructive",children:F?(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}):"Disconnect"})]}),(0,a.jsxs)("div",{className:"mt-3 flex gap-4 border-t border-success/10 pt-3 text-[11px] text-muted-foreground",children:[(0,a.jsxs)("span",{children:["Timeout: ",v,"m"]}),(0,a.jsxs)("span",{children:["Poll: ",y,"s"]})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:U?"Switch channel":"Choose a channel"}),(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2",children:am.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>{g(e.value),M(null)},disabled:P,className:(0,L.cn)("rounded-xl border px-3 py-3 text-left transition-all duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.97]",p===e.value?"border-foreground/30 bg-foreground/[0.06]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50"),children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label}),(0,a.jsx)("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:e.description})]},e.value))})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Channel ID"}),(0,a.jsx)("input",{type:"text",value:f,onChange:e=>{b(e.target.value),D&&M(null)},placeholder:Z.idPlaceholder,disabled:P,className:(0,L.cn)("w-full rounded-xl border bg-card/50 px-4 py-2.5 font-mono text-sm text-foreground","placeholder:text-muted-foreground","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","transition-colors",f.trim().length>0&&!ah[p].test(f.trim())?"border-destructive/40":"border-border/50"),onKeyDown:e=>{"Enter"===e.key&&K&&V()}}),f.trim().length>0&&!ah[p].test(f.trim())&&(0,a.jsxs)("p",{className:"text-[11px] text-destructive/70",children:["Doesn't match the expected format for ",Z.label]})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>G(e=>!e),className:"flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-muted-foreground transition-colors",children:[(0,a.jsx)("svg",{className:(0,L.cn)("h-3 w-3 transition-transform",z&&"rotate-90"),viewBox:"0 0 16 16",fill:"currentColor",children:(0,a.jsx)("path",{d:"M6 4l4 4-4 4"})}),"Advanced settings"]}),z&&(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3 pl-4",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("label",{className:"text-[11px] text-muted-foreground",htmlFor:"rq-timeout",children:"Timeout (min)"}),(0,a.jsx)("input",{id:"rq-timeout",type:"number",min:1,max:30,value:v,onChange:e=>j(Math.max(1,Math.min(30,Number(e.target.value)||1))),className:"w-full rounded-lg border border-border/50 bg-card/50 px-3 py-2 text-xs text-foreground tabular-nums focus:outline-none focus:ring-2 focus:ring-ring"})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("label",{className:"text-[11px] text-muted-foreground",htmlFor:"rq-poll",children:"Poll interval (sec)"}),(0,a.jsx)("input",{id:"rq-poll",type:"number",min:2,max:30,value:y,onChange:e=>w(Math.max(2,Math.min(30,Number(e.target.value)||2))),className:"w-full rounded-lg border border-border/50 bg-card/50 px-3 py-2 text-xs text-foreground tabular-nums focus:outline-none focus:ring-2 focus:ring-ring"})]})]}),f.trim().length>0&&(0,a.jsxs)(H,{type:"button",onClick:()=>void V(),disabled:!K,className:"gap-2 transition-transform active:scale-[0.96]",children:[P?(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(d.A,{className:"h-4 w-4"}),U?"Update connection":"Save & connect"]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Bot token"}),_&&(0,a.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-success/15 bg-success/[0.04] px-4 py-2.5 text-xs text-muted-foreground",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 shrink-0 text-success"}),_]}),h&&!_&&(0,a.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-success/15 bg-success/[0.04] px-4 py-2.5 text-xs text-muted-foreground",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 shrink-0 text-success"}),(0,a.jsx)("span",{className:"font-mono text-[11px]",children:Q})," is configured"]}),!h&&(0,a.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-warning/15 bg-warning/[0.04] px-4 py-2.5 text-xs text-muted-foreground",children:[(0,a.jsx)(eU.A,{className:"h-3.5 w-3.5 shrink-0 text-warning"}),(0,a.jsxs)("span",{children:[(0,a.jsx)("span",{className:"font-mono text-[11px]",children:Q})," not configured"]})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)("input",{type:k?"text":"password",value:N,onChange:e=>S(e.target.value),placeholder:`Paste your ${Z.label} bot token`,disabled:A,className:(0,L.cn)("w-full rounded-xl border border-border/50 bg-card/50 pl-4 pr-10 py-2.5 font-mono text-sm text-foreground","placeholder:text-muted-foreground","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","transition-colors"),onKeyDown:e=>{"Enter"===e.key&&N.trim()&&J()}}),(0,a.jsx)("button",{type:"button",onClick:()=>C(e=>!e),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-muted-foreground transition-colors",children:k?(0,a.jsx)(tJ.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(tQ.A,{className:"h-3.5 w-3.5"})})]}),(0,a.jsxs)(H,{type:"button",size:"sm",onClick:()=>void J(),disabled:!N.trim()||A,className:"h-[42px] gap-1.5 px-4",children:[A?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(tP.A,{className:"h-3.5 w-3.5"}),"Save"]})]})]})]})}let ap=[11,12,13,14,15,16],ag=[11,12,13,14,15,16];function af({label:e,description:t,presets:s,defaultSize:r,currentSize:n,onChange:i,previewFont:o}){return(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-3 space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-xs font-medium text-foreground",children:e}),(0,a.jsx)("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:t})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>i(e),className:(0,L.cn)("rounded-md border px-3 py-1.5 text-xs font-medium tabular-nums transition-colors",n===e?"border-foreground/30 bg-foreground/10 text-foreground shadow-sm":"border-border/50 bg-card/50 text-muted-foreground hover:border-foreground/20 hover:text-foreground"),children:[e,"px",e===r&&(0,a.jsx)("span",{className:"ml-1 text-[10px] text-muted-foreground",children:"(default)"})]},e))}),(0,a.jsx)("div",{className:(0,L.cn)("mt-2 rounded-md border border-border/50 bg-terminal px-3 py-2 text-foreground/80","mono"===o?"font-mono":"font-sans"),style:{fontSize:`${n}px`,lineHeight:1.35},children:"The quick brown fox jumps over the lazy dog"})]})}let ab={llm:"LLM provider & auth",model:"Default model",search:"Web search provider",remote:"Remote questions","tool-keys":"Tool API keys",prefs:"Global preferences",skills:"Skills install",doctor:"Validate setup",project:"Project init"},av=["llm","model","search","remote","tool-keys","prefs","skills","doctor","project"];function aj(){let e=(0,J.gF)(),t=tb(),s=e.boot?.onboarding,r=s?.completionRecord??null;if(void 0===r)return null;let n=new Set(r?.completedSteps??[]),i=new Set(r?.skippedSteps??[]),o=r?.completedAt??null,l=r?.lastResumePoint??null,c=t.isDevMode;return(0,a.jsxs)("div",{className:"space-y-3 rounded-md border border-border/50 bg-muted/20 p-4","data-testid":"settings-onboarding-status",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,a.jsx)(s5.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,a.jsx)("span",{children:"Onboarding setup"}),o?(0,a.jsx)(tA,{variant:"outline",className:"h-5 border-success/40 bg-success/10 text-[10px] text-success",children:"Complete"}):(0,a.jsx)(tA,{variant:"outline",className:"h-5 border-warning/40 bg-warning/10 text-[10px] text-warning",children:"Incomplete"})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:o?`Last completed ${function(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return e}}(o)}.`:l?`Paused at "${ab[l]??l}". Re-run /gsd onboarding --resume to continue.`:"You haven't completed the onboarding wizard yet."})]}),(0,a.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[(0,a.jsxs)(H,{size:"sm",variant:"outline",onClick:()=>{c&&t.toggle("forceOnboarding")},disabled:!c,"data-testid":"settings-onboarding-rerun",children:[(0,a.jsx)(tL.A,{className:"mr-1.5 h-3 w-3"}),"Re-run setup"]}),!c&&(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["Run ",(0,a.jsx)("code",{className:"rounded bg-muted px-1 font-mono",children:"/gsd onboarding"})," in your terminal"]})]})]}),(0,a.jsx)("ul",{className:"grid grid-cols-1 gap-1 sm:grid-cols-2",children:av.map(e=>{let t=n.has(e),s=i.has(e),r=t?d.A:s?u.A:tH.A;return(0,a.jsxs)("li",{className:"flex items-center gap-2 text-[11px]","data-testid":`settings-onboarding-step-${e}`,children:[(0,a.jsx)(r,{className:(0,L.cn)("h-3 w-3 shrink-0",t?"text-success":s?"text-muted-foreground/70":"text-muted-foreground/50")}),(0,a.jsx)("span",{className:(0,L.cn)("truncate",t?"text-foreground":"text-muted-foreground"),children:ab[e]??e})]},e)})})]})}function ay(){let[e,t]=(0,s2.A)(),[s,r]=(0,s3.d)();return(0,a.jsxs)("div",{className:"space-y-5","data-testid":"settings-general",children:[(0,a.jsx)(s4,{title:"General",icon:(0,a.jsx)(sr.A,{className:"h-3.5 w-3.5"}),subtitle:"Appearance & behavior",onRefresh:()=>{},refreshing:!1}),(0,a.jsx)(aj,{}),(0,a.jsx)(af,{label:"Terminal font size",description:"Applies to all terminals and the chat mode interface",presets:ap,defaultSize:13,currentSize:e,onChange:t,previewFont:"mono"}),(0,a.jsx)(af,{label:"Code font size",description:"Applies to the file viewer and code editor",presets:ag,defaultSize:14,currentSize:s,onChange:r,previewFont:"mono"})]})}let aw=[{key:"rtk",label:"RTK Shell Compression",description:"Wraps shell commands through the RTK binary to reduce token usage during command execution. RTK is downloaded automatically on first use.",warning:"Experimental — may change or be removed without notice."}];function aN(){let{state:e,data:t,busy:s,refresh:r}=ar(),n=t?.preferences??null,[o,l]=(0,i.useState)({}),[d,c]=(0,i.useState)({}),[u,m]=(0,i.useState)(null);async function h(e,t){c(t=>({...t,[e]:!0})),m(null);try{let s=await (0,en.tm)("/api/experimental",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({flag:e,enabled:t})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`HTTP ${s.status}`)}l(s=>({...s,[e]:t})),r()}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(t=>({...t,[e]:!1}))}}return(0,i.useEffect)(()=>{t||s||"idle"!==e.phase||r()},[]),(0,i.useEffect)(()=>{n&&l({rtk:n.experimental?.rtk===!0})},[n]),(0,a.jsxs)("div",{className:"space-y-4","data-testid":"settings-experimental",children:[(0,a.jsx)(s4,{title:"Experimental",icon:(0,a.jsx)(sm.A,{className:"h-3.5 w-3.5"}),subtitle:"Opt-in features — may change without notice",onRefresh:r,refreshing:s}),e.error&&(0,a.jsx)(s8,{message:e.error}),u&&(0,a.jsx)(s8,{message:u}),s&&!t&&(0,a.jsx)(s6,{label:"Loading preferences…"}),(0,a.jsx)("div",{className:"space-y-3",children:aw.map(e=>{let r=o[e.key]??!1,n=d[e.key]??!1;return(0,a.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-3 space-y-2",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:e.label}),(0,a.jsx)("span",{className:(0,L.cn)("rounded-full px-1.5 py-0.5 text-[10px] font-medium",r?"bg-success/10 text-success":"bg-muted text-muted-foreground"),children:r?"on":"off"})]}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:e.description}),e.warning&&(0,a.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-warning",children:[(0,a.jsx)(eU.A,{className:"h-3 w-3 shrink-0"}),(0,a.jsx)("span",{children:e.warning})]})]}),(0,a.jsxs)("button",{onClick:()=>h(e.key,!r),disabled:n||s||!t,className:(0,L.cn)("shrink-0 relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",r?"bg-success":"bg-muted-foreground/30"),role:"switch","aria-checked":r,"aria-label":`Toggle ${e.label}`,children:[(0,a.jsx)("span",{className:(0,L.cn)("inline-block h-3.5 w-3.5 rounded-full bg-white shadow-sm transition-transform",r?"translate-x-4":"translate-x-0.5")}),n&&(0,a.jsx)("span",{className:"absolute inset-0 flex items-center justify-center",children:(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin text-white"})})]})]})},e.key)})}),t&&(0,a.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Changes are written to"," ",(0,a.jsx)("span",{className:"font-mono",children:n?.path??"~/.gsd/PREFERENCES.md"})," ","and take effect on the next session."]})]})}var aS=s(13545);let ak={"active-gsd":{label:"Active",color:"text-success",bgClass:"bg-success/10",icon:t3.A},"empty-gsd":{label:"Initialized",color:"text-info",bgClass:"bg-info/10",icon:eR.A},brownfield:{label:"Existing",color:"text-warning",bgClass:"bg-warning/10",icon:S.A},"v1-legacy":{label:"Legacy",color:"text-warning",bgClass:"bg-warning/10",icon:e_.A},blank:{label:"New",color:"text-muted-foreground",bgClass:"bg-foreground/[0.04]",icon:eT.A}};function aC(e){let t=[];return e.isMonorepo&&t.push("Monorepo"),e.hasGitRepo&&t.push("Git"),e.hasPackageJson&&t.push("Node.js"),e.hasCargo&&t.push("Rust"),e.hasGoMod&&t.push("Go"),e.hasPyproject&&t.push("Python"),t}function aA(e){if(0===e.milestonesTotal)return null;let t=[];return e.activeMilestone&&t.push(e.activeMilestone),e.activeSlice&&t.push(e.activeSlice),e.phase&&t.push(e.phase),t.join(" \xb7 ")||null}function aR({project:e,isActive:t=!1,onClick:s,disabled:r=!1}){let n=ak[e.kind],i=n.icon,o=aC(e.signals),l=e.progress?aA(e.progress):null,c=e.progress?`${e.progress.milestonesCompleted}/${e.progress.milestonesTotal}`:null;return(0,a.jsxs)("button",{type:"button",onClick:s,disabled:r,className:(0,L.cn)("group flex w-full items-start gap-3.5 rounded-xl border px-4 py-3.5 text-left transition-all duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","active:scale-[0.98]",t?"border-primary/30 bg-primary/[0.08]":"border-border/50 bg-card/50 hover:border-foreground/15 hover:bg-card/50",r&&"opacity-40 pointer-events-none"),children:[(0,a.jsx)("div",{className:(0,L.cn)("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg mt-0.5",t?"bg-primary/15":n.bgClass),children:t?(0,a.jsx)(d.A,{className:"h-4 w-4 text-primary"}):(0,a.jsx)(i,{className:(0,L.cn)("h-4 w-4",n.color)})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground truncate",children:e.name}),(0,a.jsx)("span",{className:(0,L.cn)("text-[10px] font-medium shrink-0",t?"text-primary":n.color),children:t?"Current":n.label})]}),o.length>0&&(0,a.jsx)("div",{className:"mt-1 flex items-center gap-1.5",children:o.map(e=>(0,a.jsx)("span",{className:"rounded bg-foreground/[0.06] px-1.5 py-0.5 text-[10px] text-muted-foreground",children:e},e))}),l&&(0,a.jsx)("div",{className:"mt-1.5 text-[11px] text-muted-foreground",children:l}),e.progress&&e.progress.milestonesTotal>0&&(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-foreground/[0.08]",children:(0,a.jsx)("div",{className:"h-full rounded-full bg-success/70 transition-all",style:{width:`${Math.round(e.progress.milestonesCompleted/e.progress.milestonesTotal*100)}%`}})}),(0,a.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground",children:c})]})]}),(0,a.jsx)(eI.A,{className:"mt-1 h-4 w-4 shrink-0 text-muted-foreground/50 transition-all group-hover:text-muted-foreground group-hover:translate-x-0.5"})]})}function a_({open:e,onOpenChange:t}){let s,r=ea(),n=(0,i.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot),[l,d]=(0,i.useState)([]),[c,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!0),[x,p]=(0,i.useState)(null),g=(0,i.useCallback)(async e=>{let t=await (0,en.tm)(`/api/projects?root=${encodeURIComponent(e)}&detail=true`);if(!t.ok)throw Error(`Failed to discover projects: ${t.status}`);return await t.json()},[]);(0,i.useEffect)(()=>{if(!e)return;let t=!1;return async function(){h(!0),p(null);try{let e=await (0,en.tm)("/api/preferences");if(!e.ok)throw Error(`Failed to load preferences: ${e.status}`);let s=await e.json();if(!s.devRoot){u(null),d([]),h(!1);return}u(s.devRoot);let a=await g(s.devRoot);t||d(a)}catch(e){t||p(e instanceof Error?e.message:"Unknown error")}finally{t||h(!1)}}(),()=>{t=!0}},[e,g]);let f=(0,i.useCallback)(async e=>{h(!0),p(null);try{let t=await (0,en.tm)("/api/switch-root",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Request failed (${t.status})`)}let s=await t.json();u(s.devRoot),d(s.projects)}catch(e){p(e instanceof Error?e.message:"Failed to switch project root")}finally{h(!1)}},[]),[b,v]=(0,i.useState)(!1),[j,y]=(0,i.useState)(!1);(0,J.gF)();let w=(0,i.useCallback)(e=>{d(t=>[...t,e].sort((e,t)=>e.name.localeCompare(t.name))),v(!1),N(e)},[]);function N(e){n===e.path?t(!1):(t(!1),r.switchProject(e.path))}let S=[...l].sort((e,t)=>{let s={"active-gsd":0,"empty-gsd":1,brownfield:2,"v1-legacy":3,blank:4},a=s[e.kind]??5,r=s[t.kind]??5;return a!==r?a-r:e.name.localeCompare(t.name)});return s=m?(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 py-16 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}),"Discovering projects…"]}):x?(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3 px-5 py-16 text-center",children:[(0,a.jsx)(aS.A,{className:"h-8 w-8 text-destructive"}),(0,a.jsx)("p",{className:"text-sm text-destructive",children:x})]}):c?0===S.length?(0,a.jsxs)("div",{className:"flex flex-col items-center gap-4 px-5 py-16 text-center",children:[(0,a.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl bg-muted",children:(0,a.jsx)(eR.A,{className:"h-7 w-7 text-muted-foreground"})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h3",{className:"text-base font-semibold text-foreground",children:"No projects found"}),(0,a.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["No project directories discovered in"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs font-mono text-foreground",children:c})]})]})]}):(0,a.jsxs)("div",{className:"space-y-2",children:[S.map(e=>(0,a.jsx)(aR,{project:e,isActive:n===e.path,onClick:()=>N(e)},e.path)),(0,a.jsxs)("button",{type:"button",onClick:()=>v(!0),className:(0,L.cn)("flex w-full items-center gap-3.5 rounded-xl border border-dashed px-4 py-3.5 text-left transition-all duration-200","border-border/50 text-muted-foreground hover:border-foreground/15 hover:text-foreground","active:scale-[0.98]"),children:[(0,a.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-foreground/[0.04]",children:(0,a.jsx)(t4.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Create new project"}),(0,a.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Initialize a new directory with Git"})]})]}),(0,a.jsx)(aT,{open:b,onOpenChange:v,devRoot:c,existingNames:l.map(e=>e.name),onCreated:w})]}):(0,a.jsx)(aE,{onSaved:f}),(0,a.jsx)(e4,{open:e,onOpenChange:t,children:(0,a.jsxs)(e7,{side:"left",className:"flex h-full w-full flex-col p-0 sm:max-w-[420px]","data-testid":"projects-panel",children:[(0,a.jsxs)(e9,{className:"sr-only",children:[(0,a.jsx)(tt,{children:"Projects"}),(0,a.jsx)(ts,{children:"Switch between projects or create a new one"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-border/50 px-5 py-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-base font-semibold text-foreground",children:"Projects"}),c&&!m&&(0,a.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[10px] truncate max-w-[200px]",children:c}),(0,a.jsx)("button",{type:"button",onClick:()=>y(!0),className:"shrink-0 text-[10px] text-primary hover:text-primary/80 transition-colors font-medium","data-testid":"projects-panel-change-root",children:"Change"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"\xb7"}),(0,a.jsxs)("span",{children:[l.length," project",1!==l.length?"s":""]})]})]}),(0,a.jsx)(H,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>t(!1),children:(0,a.jsx)(o.A,{className:"h-4 w-4"})})]}),(0,a.jsx)(tz,{className:"min-h-0 flex-1",children:(0,a.jsx)("div",{className:"px-5 py-4",children:s})}),(0,a.jsx)(aP,{open:j,onOpenChange:y,onSelect:e=>void f(e),initialPath:c})]})})}function aT({open:e,onOpenChange:t,devRoot:s,existingNames:r,onCreated:n}){let[o,l]=(0,i.useState)(""),[d,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)(null),h=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(e){l(""),m(null),c(!1);let e=setTimeout(()=>h.current?.focus(),100);return()=>clearTimeout(e)}},[e]);let x=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(o),p=r.includes(o),g=o.length>0&&x&&!p&&!d,f=o?p?"A project with this name already exists":x?null:"Use letters, numbers, hyphens, underscores, dots. Must start with a letter or number.":null;async function b(){if(g){c(!0),m(null);try{let e=await (0,en.tm)("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:s,name:o})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Failed (${e.status})`)}let t=await e.json();n(t)}catch(e){m(e instanceof Error?e.message:"Failed to create project"),c(!1)}}}return(0,a.jsx)(D,{open:e,onOpenChange:t,children:(0,a.jsxs)(B,{className:"sm:max-w-md",children:[(0,a.jsxs)(U,{children:[(0,a.jsx)(z,{children:"New Project"}),(0,a.jsxs)(G,{children:["Create a new project directory in"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 text-xs font-mono",children:s})]})]}),(0,a.jsx)("form",{onSubmit:e=>{e.preventDefault(),b()},className:"space-y-4 py-2",children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(e1,{htmlFor:"project-name",children:"Project name"}),(0,a.jsx)(eX.p,{ref:h,id:"project-name",placeholder:"my-project",value:o,onChange:e=>{l(e.target.value),m(null)},autoComplete:"off","aria-invalid":!!f}),f&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:f}),u&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:u}),o&&x&&!p&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground font-mono",children:[s,"/",o]})]})}),(0,a.jsxs)(O,{children:[(0,a.jsx)(H,{variant:"ghost",size:"sm",onClick:()=>t(!1),disabled:d,children:"Cancel"}),(0,a.jsxs)(H,{size:"sm",onClick:()=>void b(),disabled:!g,className:"gap-1.5",children:[d?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(t4.A,{className:"h-3.5 w-3.5"}),"Create"]})]})]})})}function aP({open:e,onOpenChange:t,onSelect:s,initialPath:r}){let[n,o]=(0,i.useState)(""),[l,d]=(0,i.useState)(null),[c,u]=(0,i.useState)([]),[m,h]=(0,i.useState)(!1),[x,p]=(0,i.useState)(null),g=(0,i.useCallback)(async e=>{h(!0),p(null);try{let t=e?`?path=${encodeURIComponent(e)}`:"",s=await (0,en.tm)(`/api/browse-directories${t}`);if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`${s.status}`)}let a=await s.json();o(a.current),d(a.parent),u(a.entries)}catch(e){p(e instanceof Error?e.message:"Failed to browse")}finally{h(!1)}},[]);return(0,i.useEffect)(()=>{e&&g(r??void 0)},[e,r,g]),(0,a.jsx)(D,{open:e,onOpenChange:t,children:(0,a.jsxs)(B,{className:"sm:max-w-lg gap-0 p-0 overflow-hidden",children:[(0,a.jsxs)(U,{className:"px-5 pt-5 pb-3",children:[(0,a.jsx)(z,{className:"text-base",children:"Choose Folder"}),(0,a.jsx)(G,{className:"text-xs",children:"Navigate to the folder that contains your project directories."})]}),(0,a.jsx)("div",{className:"border-y border-border/50 bg-muted/50 px-5 py-2",children:(0,a.jsx)("p",{className:"font-mono text-xs text-muted-foreground truncate",title:n,children:n})}),(0,a.jsx)(tz,{className:"h-[320px]",children:(0,a.jsxs)("div",{className:"px-2 py-1",children:[m&&(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsx)(E.A,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),x&&(0,a.jsx)("div",{className:"px-3 py-4 text-center text-xs text-destructive",children:x}),!m&&!x&&(0,a.jsxs)(a.Fragment,{children:[l&&(0,a.jsxs)("button",{onClick:()=>void g(l),className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-accent/50",children:[(0,a.jsx)(tB.A,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:".."})]}),c.map(e=>(0,a.jsxs)("button",{onClick:()=>void g(e.path),className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-accent/50 group",children:[(0,a.jsx)(j.A,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:"text-foreground truncate flex-1",children:e.name}),(0,a.jsx)(_.A,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]},e.path)),!l&&0===c.length&&(0,a.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"No subdirectories"})]})]})}),(0,a.jsxs)(O,{className:"border-t border-border/50 px-5 py-3",children:[(0,a.jsx)(H,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),(0,a.jsxs)(H,{size:"sm",onClick:()=>{s(n),t(!1)},disabled:!n,className:"gap-1.5",children:[(0,a.jsx)(eR.A,{className:"h-3.5 w-3.5"}),"Select This Folder"]})]})]})})}function aE({onSaved:e,currentRoot:t}){let[s,r]=(0,i.useState)(!1),[n,o]=(0,i.useState)(null),[l,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),h=(0,i.useCallback)(async t=>{r(!0),o(null),c(!1);try{let s=await (0,en.tm)("/api/preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:t})});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error??`Request failed (${s.status})`)}c(!0),e(t)}catch(e){o(e instanceof Error?e.message:"Failed to save preference")}finally{r(!1)}},[e]);return t?(0,a.jsxs)("div",{className:"space-y-3","data-testid":"devroot-settings",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("code",{className:"flex-1 truncate rounded border border-border/50 bg-muted/50 px-3 py-2 font-mono text-xs text-foreground",children:t}),(0,a.jsx)(H,{size:"sm",variant:"outline",onClick:()=>m(!0),disabled:s,className:"h-9 gap-1.5 shrink-0",children:s?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):l?(0,a.jsx)(d.A,{className:"h-3.5 w-3.5 text-success"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eR.A,{className:"h-3.5 w-3.5"}),"Change"]})})]}),n&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:n}),l&&(0,a.jsx)("p",{className:"text-xs text-success",children:"Dev root updated"}),(0,a.jsx)(aP,{open:u,onOpenChange:m,onSelect:e=>void h(e),initialPath:t})]}):(0,a.jsxs)("div",{className:"rounded-md border border-border bg-card p-6",children:[(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[(0,a.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-border bg-accent",children:(0,a.jsx)(tU.A,{className:"h-5 w-5 text-muted-foreground"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:"Set your development root"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground leading-relaxed",children:"Point GSD at the folder that contains your project directories. It scans one level deep."}),(0,a.jsx)(H,{onClick:()=>m(!0),disabled:s,size:"sm",className:"mt-3 gap-2","data-testid":"projects-devroot-browse",children:s?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eR.A,{className:"h-3.5 w-3.5"}),"Browse"]})}),n&&(0,a.jsx)("p",{className:"mt-2 text-xs text-destructive",children:n})]})]}),(0,a.jsx)(aP,{open:u,onOpenChange:m,onSelect:e=>void h(e)})]})}function aI(){let[e,t]=(0,i.useState)(null),[s,r]=(0,i.useState)(!0);return((0,i.useEffect)(()=>{(0,en.tm)("/api/preferences").then(e=>e.json()).then(e=>t(e.devRoot??null)).catch(()=>t(null)).finally(()=>r(!1))},[]),s)?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-4 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading preferences…"]}):(0,a.jsxs)("div",{className:"space-y-3","data-testid":"settings-devroot",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)(tU.A,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,a.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:"Development Root"})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"The parent folder containing your project directories. GSD scans one level deep for projects."}),(0,a.jsx)(aE,{currentRoot:e??"",onSaved:e=>t(e)})]})}function aF(){let e=ea(),[t,s]=(0,i.useState)([]),[n,o]=(0,i.useState)(null),[l,d]=(0,i.useState)(!0),[c,u]=(0,i.useState)(null),[m,h]=(0,i.useState)(!1),[x,p]=(0,i.useState)(!1),[g,f]=(0,i.useState)(""),b=(0,i.useCallback)(async e=>{let t=await (0,en.tm)(`/api/projects?root=${encodeURIComponent(e)}&detail=true`);if(!t.ok)throw Error(`Failed to discover projects: ${t.status}`);return await t.json()},[]);(0,i.useEffect)(()=>{let e=!1;return async function(){d(!0),u(null);try{let t=await (0,en.tm)("/api/preferences");if(!t.ok)throw Error(`Failed to load preferences: ${t.status}`);let a=await t.json();if(!a.devRoot){o(null),s([]),d(!1);return}o(a.devRoot);let r=await b(a.devRoot);e||s(r)}catch(t){e||u(t instanceof Error?t.message:"Unknown error")}finally{e||d(!1)}}(),()=>{e=!0}},[b]);let v=(0,i.useCallback)(async e=>{d(!0),u(null);try{let t=await (0,en.tm)("/api/switch-root",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({devRoot:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Request failed (${t.status})`)}let a=await t.json();o(a.devRoot),s(a.projects)}catch(e){u(e instanceof Error?e.message:"Failed to switch project root")}finally{d(!1)}},[]),j=(0,i.useCallback)(t=>{s(e=>[...e,t].sort((e,t)=>e.name.localeCompare(t.name))),h(!1),e.switchProject(t.path)},[e]),y=[...t].sort((e,t)=>{let s={"active-gsd":0,"empty-gsd":1,brownfield:2,"v1-legacy":3,blank:4},a=s[e.kind]??5,r=s[t.kind]??5;return a!==r?a-r:e.name.localeCompare(t.name)}),w=g.trim()?y.filter(e=>e.name.toLowerCase().includes(g.toLowerCase())):y,N=!l&&y.length>0,S=y.length>5;return(0,a.jsxs)("div",{className:"flex h-screen flex-col bg-background text-foreground","data-testid":"project-selection-gate",children:[(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,a.jsxs)("div",{className:"mx-auto max-w-2xl px-6 pt-16 pb-10 md:px-10 lg:pt-24",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center text-center mb-10",children:[(0,a.jsx)(r.default,{src:"/logo-black.svg",alt:"GSD",width:100,height:28,className:"h-7 w-auto dark:hidden"}),(0,a.jsx)(r.default,{src:"/logo-white.svg",alt:"GSD",width:100,height:28,className:"h-7 w-auto hidden dark:block"}),(0,a.jsx)("p",{className:"mt-3 text-sm text-muted-foreground",children:"Select a project to get started"})]}),l&&(0,a.jsxs)("div",{className:"flex items-center gap-3 py-20 justify-center text-sm text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-4 w-4 animate-spin"}),"Scanning for projects…"]}),c&&!l&&(0,a.jsx)("div",{className:"rounded-md border border-destructive/20 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive",children:c}),!n&&!l&&!c&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold tracking-tight text-foreground",children:"Welcome to GSD"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Set a development root to get started. GSD will discover projects inside it."})]}),(0,a.jsx)(aE,{onSaved:v})]}),n&&!l&&0===y.length&&!c&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold tracking-tight text-foreground",children:"No projects found"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"No project directories were discovered. Create one to get started."})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 rounded-md border border-dashed border-border px-4 py-3 text-sm text-muted-foreground transition-colors hover:border-foreground/20 hover:text-foreground",children:[(0,a.jsx)(t4.A,{className:"h-4 w-4"}),"Create a new project"]})]}),N&&(0,a.jsxs)("div",{className:"space-y-5",children:[n&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(tU.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground truncate",children:n}),(0,a.jsx)("button",{type:"button",onClick:()=>p(!0),className:"shrink-0 text-[11px] text-primary hover:text-primary/80 transition-colors font-medium","data-testid":"gate-change-root",children:"Change"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,a.jsxs)("p",{className:"text-xs text-muted-foreground tabular-nums",children:[y.length," project",1!==y.length?"s":""]}),S&&(0,a.jsxs)("div",{className:"relative w-48",children:[(0,a.jsx)(sh.A,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),(0,a.jsx)("input",{type:"text",placeholder:"Filter…",value:g,onChange:e=>f(e.target.value),className:"h-8 w-full rounded-md border border-border bg-background pl-8 pr-3 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring"})]})]}),(0,a.jsxs)("div",{className:"rounded-md border border-border bg-card overflow-hidden divide-y divide-border",children:[w.map(t=>{let s=ak[t.kind],r=s.icon,n=aC(t.signals),i=t.progress?aA(t.progress):null,o=t.progress&&t.progress.milestonesTotal>0,l=o?Math.round(t.progress.milestonesCompleted/t.progress.milestonesTotal*100):0;return(0,a.jsxs)("button",{type:"button",onClick:()=>{e.switchProject(t.path)},className:"group flex w-full items-center gap-4 px-4 py-3 text-left transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:bg-accent/50",children:[(0,a.jsx)("div",{className:(0,L.cn)("flex h-8 w-8 shrink-0 items-center justify-center rounded-md",s.bgClass),children:(0,a.jsx)(r,{className:(0,L.cn)("h-3.5 w-3.5",s.color)})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:t.name}),(0,a.jsx)("span",{className:(0,L.cn)("text-[10px] font-medium shrink-0",s.color),children:s.label})]}),(0,a.jsxs)("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[n.length>0&&(0,a.jsx)("span",{children:n.join(" \xb7 ")}),n.length>0&&i&&(0,a.jsx)("span",{className:"text-muted-foreground/50",children:"—"}),i&&(0,a.jsx)("span",{className:"truncate",children:i})]})]}),o&&(0,a.jsxs)("div",{className:"hidden sm:flex items-center gap-2 shrink-0 w-24",children:[(0,a.jsx)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-foreground/[0.08]",children:(0,a.jsx)("div",{className:"h-full rounded-full bg-success/70 transition-all",style:{width:`${l}%`}})}),(0,a.jsxs)("span",{className:"text-[10px] tabular-nums text-muted-foreground w-6 text-right",children:[t.progress.milestonesCompleted,"/",t.progress.milestonesTotal]})]}),t.lastModified>0&&(0,a.jsx)("span",{className:"hidden lg:inline text-[10px] text-muted-foreground shrink-0 w-16 text-right tabular-nums",children:function(e){let t=Date.now()-e;if(t<6e4)return"just now";let s=Math.floor(t/6e4);if(s<60)return`${s}m ago`;let a=Math.floor(s/60);if(a<24)return`${a}h ago`;let r=Math.floor(a/24);return r<30?`${r}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}(t.lastModified)}),(0,a.jsx)(_.A,{className:"h-4 w-4 shrink-0 text-muted-foreground/50 transition-colors group-hover:text-muted-foreground"})]},t.path)}),0===w.length&&g.trim()&&(0,a.jsxs)("div",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:['No projects matching "',g,'"']})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 rounded-md border border-dashed border-border px-4 py-2.5 text-sm text-muted-foreground transition-colors hover:border-foreground/20 hover:text-foreground w-full",children:[(0,a.jsx)(t4.A,{className:"h-3.5 w-3.5"}),"New project"]}),n&&(0,a.jsx)(aT,{open:m,onOpenChange:h,devRoot:n,existingNames:t.map(e=>e.name),onCreated:j})]}),n&&!l&&0===y.length&&!c&&(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsxs)("button",{type:"button",onClick:()=>p(!0),className:"flex items-center gap-2 text-xs text-primary hover:text-primary/80 transition-colors font-medium","data-testid":"gate-change-root-empty",children:[(0,a.jsx)(eR.A,{className:"h-3.5 w-3.5"}),"Change project root"]})})]})}),(0,a.jsx)(aP,{open:x,onOpenChange:p,onSelect:e=>void v(e),initialPath:n})]})}var a$=s(55711),aL=s(48144),aD=s(8195),aM=s(68459),aq=s(1709),aB=s(484),aU=s(10762);function aO({title:e,icon:t,subtitle:s,status:r,onRefresh:n,refreshing:i}){return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:t}),(0,a.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),r,s&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:s})]}),n&&(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:n,disabled:i,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3 w-3",i&&"animate-spin")}),"Refresh"]})]})}function az({message:e}){return(0,a.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:e})}function aG({label:e}){return(0,a.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),e]})}function aW({message:e}){return(0,a.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-5 text-center text-xs text-muted-foreground",children:e})}function aK({label:e,value:t,variant:s}){return(0,a.jsxs)("div",{className:(0,L.cn)("flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","info"===s&&"border-info/20 bg-info/5 text-info","warning"===s&&"border-warning/20 bg-warning/5 text-warning","success"===s&&"border-success/20 bg-success/5 text-success","error"===s&&"border-destructive/20 bg-destructive/5 text-destructive",(!s||"default"===s)&&"border-border/50 bg-card/50 text-foreground/80"),children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e}),(0,a.jsx)("span",{className:"font-medium tabular-nums",children:t})]})}function aV(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60),a=t%60;if(s<60)return a>0?`${s}m ${a}s`:`${s}m`;let r=Math.floor(s/60),n=s%60;return n>0?`${r}h ${n}m`:`${r}h`}function aH(){return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-quick",children:[(0,a.jsx)(aO,{title:"Quick Task",icon:(0,a.jsx)(eg.A,{className:"h-3.5 w-3.5"})}),(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-4 py-4 space-y-3",children:[(0,a.jsx)("p",{className:"text-xs text-foreground",children:"Create a quick one-off task outside the current plan. Useful for small fixes, experiments, or ad-hoc work that doesn't fit into the milestone structure."}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Usage"}),(0,a.jsx)("div",{className:"rounded-md border border-border/50 bg-background/50 px-3 py-2 font-mono text-[11px] text-foreground/80",children:"/gsd quick <description>"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Examples"}),(0,a.jsx)("div",{className:"space-y-1.5",children:["Fix the typo in README.md header","Add .env.example with required keys","Update the LICENSE year to 2026","Run prettier on the whole project"].map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[11px]",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"$"}),(0,a.jsxs)("code",{className:"font-mono text-muted-foreground",children:["/gsd quick ",e]})]},e))})]}),(0,a.jsx)("div",{className:"rounded-md border border-info/15 bg-info/5 px-3 py-2 text-[11px] text-info/90",children:"Quick tasks run as standalone units — they don't affect milestone progress, slices, or the plan. Use them for work that should happen now without ceremony."})]})]})}function aY(){let e=(0,J.gF)(),{loadHistoryData:t}=(0,J._l)(),s=e.commandSurface.remainingCommands.history,r=s.data,n="loading"===s.phase,[o,l]=(0,i.useState)("phase");return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-history",children:[(0,a.jsx)(aO,{title:"History & Metrics",icon:(0,a.jsx)(ex.A,{className:"h-3.5 w-3.5"}),onRefresh:()=>void t(),refreshing:n}),s.error&&(0,a.jsx)(az,{message:s.error}),n&&!r&&(0,a.jsx)(aG,{label:"Loading history data…"}),r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(aK,{label:"Units",value:r.totals.units}),(0,a.jsx)(aK,{label:"Cost",value:(0,J.BD)(r.totals.cost),variant:"warning"}),(0,a.jsx)(aK,{label:"Duration",value:aV(r.totals.duration)}),(0,a.jsx)(aK,{label:"Tool Calls",value:r.totals.toolCalls})]}),(0,a.jsx)("div",{className:"flex gap-1 rounded-lg border border-border/50 bg-card/50 p-0.5",children:["phase","slice","model","units"].map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>l(e),className:(0,L.cn)("flex-1 rounded-md px-2.5 py-1 text-[11px] font-medium capitalize transition-colors",o===e?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-muted-foreground"),children:"units"===e?"Recent":`By ${e}`},e))}),"phase"===o&&r.byPhase.length>0&&(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Phase"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Units"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Duration"})]})}),(0,a.jsx)("tbody",{children:r.byPhase.map(e=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 capitalize",children:e.phase}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:e.units}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,J.BD)(e.cost)}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:aV(e.duration)})]},e.phase))})]})}),"slice"===o&&r.bySlice.length>0&&(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Slice"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Units"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Duration"})]})}),(0,a.jsx)("tbody",{children:r.bySlice.map(e=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.sliceId}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:e.units}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,J.BD)(e.cost)}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:aV(e.duration)})]},e.sliceId))})]})}),"model"===o&&r.byModel.length>0&&(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Model"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Units"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"})]})}),(0,a.jsx)("tbody",{children:r.byModel.map(e=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[180px]",children:e.model}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:e.units}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,J.BD)(e.cost)})]},e.model))})]})}),"units"===o&&(0,a.jsx)(a.Fragment,{children:r.units.length>0?(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Type"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"ID"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Model"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cost"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Duration"})]})}),(0,a.jsx)("tbody",{children:r.units.slice(0,20).map((e,t)=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.type}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[120px]",children:e.id}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-muted-foreground truncate max-w-[120px]",children:e.model}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:(0,J.BD)(e.cost)}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:aV(e.finishedAt-e.startedAt)})]},t))})]})}):(0,a.jsx)(aW,{message:"No unit history recorded yet"})}),"phase"===o&&0===r.byPhase.length&&(0,a.jsx)(aW,{message:"No phase breakdown available"}),"slice"===o&&0===r.bySlice.length&&(0,a.jsx)(aW,{message:"No slice breakdown available"}),"model"===o&&0===r.byModel.length&&(0,a.jsx)(aW,{message:"No model breakdown available"})]})]})}function aJ(){let e=(0,J.gF)(),{loadUndoInfo:t,executeUndoAction:s}=(0,J._l)(),r=e.commandSurface.remainingCommands.undo,n=r.data,o="loading"===r.phase,[l,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(null),p=async()=>{m(!0),x(null);try{let e=await s();x(e),c(!1)}finally{m(!1)}};return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-undo",children:[(0,a.jsx)(aO,{title:"Undo Last Unit",icon:(0,a.jsx)(a$.A,{className:"h-3.5 w-3.5"}),onRefresh:()=>{x(null),c(!1),t()},refreshing:o}),r.error&&(0,a.jsx)(az,{message:r.error}),o&&!n&&(0,a.jsx)(aG,{label:"Loading undo info…"}),h&&(0,a.jsxs)("div",{className:(0,L.cn)("rounded-lg border px-3 py-2.5 text-xs",h.success?"border-success/20 bg-success/5 text-success":"border-destructive/20 bg-destructive/5 text-destructive"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[h.success?(0,a.jsx)(d.A,{className:"h-3.5 w-3.5"}):(0,a.jsx)(t$.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"font-medium",children:h.success?"Undo Successful":"Undo Failed"})]}),(0,a.jsx)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:h.message})]}),n&&(0,a.jsx)(a.Fragment,{children:n.lastUnitType?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 space-y-1.5",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Last Completed Unit"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-[11px]",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"Type"}),(0,a.jsx)("span",{className:"font-mono text-foreground/80",children:n.lastUnitType}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"ID"}),(0,a.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:n.lastUnitId??"—"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"Key"}),(0,a.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:n.lastUnitKey??"—"})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(aK,{label:"Completed Units",value:n.completedCount}),n.commits.length>0&&(0,a.jsx)(aK,{label:"Commits",value:n.commits.length,variant:"info"})]}),n.commits.length>0&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground",children:"Associated Commits"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:n.commits.map(e=>(0,a.jsx)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-mono",children:e.slice(0,8)},e))})]}),l?(0,a.jsxs)("div",{className:"rounded-lg border border-warning/20 bg-warning/5 px-3 py-2.5 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-warning",children:[(0,a.jsx)(eU.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"font-medium",children:"This will revert the last unit and its git commits."})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(H,{type:"button",variant:"destructive",size:"sm",onClick:()=>void p(),disabled:u,className:"h-7 gap-1.5 text-xs",children:[u?(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(tL.A,{className:"h-3 w-3"}),"Confirm Undo"]}),(0,a.jsx)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),disabled:u,className:"h-7 text-xs",children:"Cancel"})]})]}):(0,a.jsxs)(H,{type:"button",variant:"destructive",size:"sm",onClick:()=>c(!0),disabled:u||!!h?.success,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(tL.A,{className:"h-3 w-3"}),"Undo Last Unit"]})]}):(0,a.jsx)(aW,{message:"No completed units to undo"})})]})}function aQ(){let e=(0,J.gF)(),{loadSteerData:t,sendSteer:s}=(0,J._l)(),r=e.commandSurface.remainingCommands.steer,n=r.data,o="loading"===r.phase,[l,c]=(0,i.useState)(""),[u,m]=(0,i.useState)(!1),[h,x]=(0,i.useState)(!1),p=async()=>{if(l.trim()){m(!0),x(!1);try{await s(l.trim()),x(!0),c(""),t()}finally{m(!1)}}};return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-steer",children:[(0,a.jsx)(aO,{title:"Steer",icon:(0,a.jsx)(aL.A,{className:"h-3.5 w-3.5"}),onRefresh:()=>{x(!1),t()},refreshing:o}),r.error&&(0,a.jsx)(az,{message:r.error}),o&&!n&&(0,a.jsx)(aG,{label:"Loading steer data…"}),h&&(0,a.jsxs)("div",{className:"rounded-lg border border-success/20 bg-success/5 px-3 py-2.5 text-xs text-success flex items-center gap-2",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5"}),"Steering message sent successfully."]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Current Overrides"}),n?.overridesContent?(0,a.jsx)("div",{className:"rounded-lg border border-border/50 bg-background/50 px-3 py-2.5 text-[11px] font-mono text-foreground/80 whitespace-pre-wrap max-h-[200px] overflow-y-auto leading-relaxed",children:n.overridesContent}):(0,a.jsx)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 text-[11px] text-muted-foreground italic",children:"No active overrides"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Send Steering Message"}),(0,a.jsx)(ta,{value:l,onChange:e=>c(e.target.value),placeholder:"Enter steering instructions for the agent…",className:"min-h-[80px] text-xs resize-none"}),(0,a.jsxs)(H,{type:"button",variant:"default",size:"sm",onClick:()=>void p(),disabled:u||!l.trim(),className:"h-7 gap-1.5 text-xs",children:[u?(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(aL.A,{className:"h-3 w-3"}),"Send"]})]})]})}function aZ(){let e=(0,J.gF)(),{loadHooksData:t}=(0,J._l)(),s=e.commandSurface.remainingCommands.hooks,r=s.data,n="loading"===s.phase;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-hooks",children:[(0,a.jsx)(aO,{title:"Hooks",icon:(0,a.jsx)(t3.A,{className:"h-3.5 w-3.5"}),status:r?(0,a.jsxs)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[r.entries.length," ",1===r.entries.length?"hook":"hooks"]}):null,onRefresh:()=>void t(),refreshing:n}),s.error&&(0,a.jsx)(az,{message:s.error}),n&&!r&&(0,a.jsx)(aG,{label:"Loading hooks…"}),r&&(0,a.jsxs)(a.Fragment,{children:[r.entries.length>0?(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Name"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Type"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-center font-medium text-muted-foreground",children:"Status"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Targets"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Cycles"})]})}),(0,a.jsx)("tbody",{children:r.entries.map(e=>{let t=Object.values(e.activeCycles).reduce((e,t)=>e+t,0);return(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.name}),(0,a.jsx)("td",{className:"px-2.5 py-1.5",children:(0,a.jsx)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:e.type})}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-center",children:(0,a.jsx)(tA,{variant:e.enabled?"secondary":"outline",className:(0,L.cn)("text-[10px] px-1.5 py-0",e.enabled?"border-success/30 text-success":"text-muted-foreground"),children:e.enabled?"enabled":"disabled"})}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-muted-foreground",children:e.targets.length>0?e.targets.join(", "):"all"}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right tabular-nums text-foreground/80",children:t})]},e.name)})})]})}):(0,a.jsx)(aW,{message:"No hooks configured"}),r.formattedStatus&&(0,a.jsx)("div",{className:"rounded-lg border border-border/50 bg-background/50 px-3 py-2.5 text-[11px] font-mono text-muted-foreground whitespace-pre-wrap leading-relaxed",children:r.formattedStatus})]})]})}function aX(){let e=(0,J.gF)(),{loadInspectData:t}=(0,J._l)(),s=e.commandSurface.remainingCommands.inspect,r=s.data,n="loading"===s.phase;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-inspect",children:[(0,a.jsx)(aO,{title:"Inspect Database",icon:(0,a.jsx)(aD.A,{className:"h-3.5 w-3.5"}),subtitle:r?.schemaVersion!=null?`v${r.schemaVersion}`:null,onRefresh:()=>void t(),refreshing:n}),s.error&&(0,a.jsx)(az,{message:s.error}),n&&!r&&(0,a.jsx)(aG,{label:"Loading database…"}),r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(aK,{label:"Decisions",value:r.counts.decisions,variant:"info"}),(0,a.jsx)(aK,{label:"Requirements",value:r.counts.requirements,variant:"info"}),(0,a.jsx)(aK,{label:"Artifacts",value:r.counts.artifacts})]}),r.recentDecisions.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Recent Decisions (",r.recentDecisions.length,")"]}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"ID"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Decision"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Choice"})]})}),(0,a.jsx)("tbody",{children:r.recentDecisions.map(e=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.id}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-foreground/80 max-w-[200px] truncate",children:e.decision}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-muted-foreground max-w-[150px] truncate",children:e.choice})]},e.id))})]})})]}),r.recentRequirements.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Recent Requirements (",r.recentRequirements.length,")"]}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"ID"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Status"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Description"})]})}),(0,a.jsx)("tbody",{children:r.recentRequirements.map(e=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80",children:e.id}),(0,a.jsx)("td",{className:"px-2.5 py-1.5",children:(0,a.jsx)(tA,{variant:"active"===e.status?"secondary":"outline",className:(0,L.cn)("text-[10px] px-1.5 py-0","active"===e.status&&"border-success/30 text-success","validated"===e.status&&"border-info/30 text-info","deferred"===e.status&&"text-muted-foreground"),children:e.status})}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-foreground/80 max-w-[220px] truncate",children:e.description})]},e.id))})]})})]}),0===r.recentDecisions.length&&0===r.recentRequirements.length&&(0,a.jsx)(aW,{message:"Database is empty — no decisions or requirements recorded"})]})]})}function a0(){let e=(0,J.gF)(),{loadExportData:t}=(0,J._l)(),s=e.commandSurface.remainingCommands.exportData,r=s.data,n="loading"===s.phase,[o,l]=(0,i.useState)("markdown"),c=e=>{let t="json"===e.format?"application/json":"text/markdown",s=new Blob([e.content],{type:t}),a=URL.createObjectURL(s),r=document.createElement("a");r.href=a,r.download=e.filename,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)},u=async()=>{let e=await t(o);e&&c(e)};return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-export",children:[(0,a.jsx)(aO,{title:"Export",icon:(0,a.jsx)(sx.A,{className:"h-3.5 w-3.5"})}),s.error&&(0,a.jsx)(az,{message:s.error}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Format"}),(0,a.jsx)("div",{className:"flex gap-1 rounded-lg border border-border/50 bg-card/50 p-0.5",children:["markdown","json"].map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>l(e),className:(0,L.cn)("flex-1 rounded-md px-3 py-1.5 text-[11px] font-medium capitalize transition-colors",o===e?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-muted-foreground"),children:"markdown"===e?"Markdown":"JSON"},e))})]}),(0,a.jsxs)(H,{type:"button",variant:"default",size:"sm",onClick:()=>void u(),disabled:n,className:"h-7 gap-1.5 text-xs",children:[n?(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(sx.A,{className:"h-3 w-3"}),"Generate Export"]}),r&&(0,a.jsxs)("div",{className:"rounded-lg border border-success/20 bg-success/5 px-3 py-2.5 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-success",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"font-medium",children:"Export Ready"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("span",{className:"text-[11px] font-mono text-muted-foreground",children:r.filename}),(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(r),className:"h-6 gap-1 text-[10px]",children:[(0,a.jsx)(sx.A,{className:"h-2.5 w-2.5"}),"Download Again"]})]})]})]})}function a1(){let e=(0,J.gF)(),{loadCleanupData:t,executeCleanupAction:s}=(0,J._l)(),r=e.commandSurface.remainingCommands.cleanup,n=r.data,o="loading"===r.phase,[l,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)(null),h=n?.branches.filter(e=>e.merged)??[],x=n?.snapshots??[],p=async e=>{c(!0),m(null);try{let a="branches"===e?h.map(e=>e.name):[],r="snapshots"===e?x.map(e=>e.ref):[],n=await s(a,r);m(n),t()}finally{c(!1)}};return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-cleanup",children:[(0,a.jsx)(aO,{title:"Cleanup",icon:(0,a.jsx)(aM.A,{className:"h-3.5 w-3.5"}),onRefresh:()=>{m(null),t()},refreshing:o}),r.error&&(0,a.jsx)(az,{message:r.error}),o&&!n&&(0,a.jsx)(aG,{label:"Scanning for cleanup targets…"}),u&&(0,a.jsxs)("div",{className:"rounded-lg border border-success/20 bg-success/5 px-3 py-2.5 text-xs text-success",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(d.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"font-medium",children:"Cleanup Complete"})]}),(0,a.jsx)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:u.message})]}),n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Branches (",n.branches.length,")"]}),h.length>0&&(0,a.jsxs)(H,{type:"button",variant:"destructive",size:"sm",onClick:()=>void p("branches"),disabled:l,className:"h-6 gap-1 text-[10px]",children:[l?(0,a.jsx)(E.A,{className:"h-2.5 w-2.5 animate-spin"}):(0,a.jsx)(aq.A,{className:"h-2.5 w-2.5"}),"Delete Merged (",h.length,")"]})]}),n.branches.length>0?(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Branch"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-center font-medium text-muted-foreground",children:"Status"})]})}),(0,a.jsx)("tbody",{children:n.branches.map(e=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[250px]",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(S.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.name]})}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-center",children:(0,a.jsx)(tA,{variant:e.merged?"secondary":"outline",className:(0,L.cn)("text-[10px] px-1.5 py-0",e.merged?"border-success/30 text-success":"text-muted-foreground"),children:e.merged?"merged":"active"})})]},e.name))})]})}):(0,a.jsx)(aW,{message:"No branches to clean up"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("h4",{className:"text-xs font-medium text-muted-foreground",children:["Snapshots (",n.snapshots.length,")"]}),x.length>0&&(0,a.jsxs)(H,{type:"button",variant:"destructive",size:"sm",onClick:()=>void p("snapshots"),disabled:l,className:"h-6 gap-1 text-[10px]",children:[l?(0,a.jsx)(E.A,{className:"h-2.5 w-2.5 animate-spin"}):(0,a.jsx)(so.A,{className:"h-2.5 w-2.5"}),"Prune Snapshots (",x.length,")"]})]}),n.snapshots.length>0?(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:(0,a.jsxs)("table",{className:"w-full text-[11px]",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-border/50 bg-card/50",children:[(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-left font-medium text-muted-foreground",children:"Ref"}),(0,a.jsx)("th",{className:"px-2.5 py-1.5 text-right font-medium text-muted-foreground",children:"Date"})]})}),(0,a.jsx)("tbody",{children:n.snapshots.map(e=>(0,a.jsxs)("tr",{className:"border-b border-border/50 last:border-0",children:[(0,a.jsx)("td",{className:"px-2.5 py-1.5 font-mono text-foreground/80 truncate max-w-[200px]",children:e.ref}),(0,a.jsx)("td",{className:"px-2.5 py-1.5 text-right text-muted-foreground",children:e.date})]},e.ref))})]})}):(0,a.jsx)(aW,{message:"No snapshots to prune"})]})]})]})}function a5(){let e=(0,J.gF)(),t=(0,J.Gr)(e),s=t?.milestones??[],r=t?.active;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-queue",children:[(0,a.jsx)(aO,{title:"Queue",icon:(0,a.jsx)(aB.A,{className:"h-3.5 w-3.5"}),status:(0,a.jsxs)(tA,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[s.length," ",1===s.length?"milestone":"milestones"]})}),s.length>0?(0,a.jsx)("div",{className:"space-y-2",children:s.map(e=>{var t;let s=r?.milestoneId===e.id,n={done:(t=e.slices).filter(e=>e.done).length,total:t.length};return(0,a.jsxs)("div",{className:(0,L.cn)("rounded-lg border px-3 py-2.5 space-y-1.5",s?"border-info/25 bg-info/5":"border-border/50 bg-card/50"),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-mono font-medium text-foreground/80",children:e.id}),(0,a.jsx)("span",{className:"text-xs text-foreground truncate",children:e.title}),s&&(0,a.jsx)(tA,{variant:"secondary",className:"text-[10px] px-1.5 py-0 border-info/30 text-info",children:"active"})]}),(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums shrink-0",children:[n.done,"/",n.total," slices"]})]}),n.total>0&&(0,a.jsx)("div",{className:"h-1 rounded-full bg-border/50 overflow-hidden",children:(0,a.jsx)("div",{className:(0,L.cn)("h-full rounded-full transition-all",n.done===n.total?"bg-success":"bg-info"),style:{width:`${n.done/n.total*100}%`}})}),s&&e.slices.length>0&&(0,a.jsx)("div",{className:"space-y-0.5 pt-1",children:e.slices.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[11px]",children:[e.done?(0,a.jsx)(d.A,{className:"h-3 w-3 text-success shrink-0"}):(0,a.jsx)("span",{className:(0,L.cn)("inline-block h-1.5 w-1.5 rounded-full shrink-0",r?.sliceId===e.id?"bg-info":"bg-border/50")}),(0,a.jsx)("span",{className:"font-mono text-muted-foreground",children:e.id}),(0,a.jsx)("span",{className:(0,L.cn)("truncate",e.done?"text-muted-foreground line-through":"text-foreground/80"),children:e.title}),r?.sliceId===e.id&&!e.done&&(0,a.jsx)(tA,{variant:"outline",className:"text-[9px] px-1 py-0 text-info",children:"current"})]},e.id))})]},e.id)})}):(0,a.jsx)(aW,{message:"No milestones in the plan"})]})}function a2(){let e=(0,J.gF)(),t=(0,J.Gr)(e),s=t?.active,r=t?.milestones??[],n=r.find(e=>e.id===s?.milestoneId),i=n?.slices.find(e=>e.id===s?.sliceId),o=r.reduce((e,t)=>e+t.slices.length,0),l=r.reduce((e,t)=>e+t.slices.filter(e=>e.done).length,0);return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"gsd-surface-gsd-status",children:[(0,a.jsx)(aO,{title:"Status",icon:(0,a.jsx)(aU.A,{className:"h-3.5 w-3.5"})}),(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-3 space-y-2",children:[(0,a.jsx)("h4",{className:"text-[11px] font-medium text-muted-foreground uppercase tracking-wide",children:"Active Context"}),(0,a.jsxs)("div",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-[11px]",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"Phase"}),(0,a.jsx)("span",{className:"font-mono text-foreground/80",children:s?.phase?(0,a.jsx)(tA,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:s.phase}):(0,a.jsx)("span",{className:"text-muted-foreground italic",children:"idle"})}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"Milestone"}),(0,a.jsx)("span",{className:"font-mono text-foreground/80",children:n?(0,a.jsxs)("span",{children:[n.id," — ",n.title]}):(0,a.jsx)("span",{className:"text-muted-foreground italic",children:"none"})}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"Slice"}),(0,a.jsx)("span",{className:"font-mono text-foreground/80",children:i?(0,a.jsxs)("span",{children:[i.id," — ",i.title]}):(0,a.jsx)("span",{className:"text-muted-foreground italic",children:"none"})}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"Task"}),(0,a.jsx)("span",{className:"font-mono text-foreground/80",children:s?.taskId??(0,a.jsx)("span",{className:"text-muted-foreground italic",children:"none"})})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(aK,{label:"Milestones",value:r.length}),(0,a.jsx)(aK,{label:"Slices",value:`${l}/${o}`,variant:l===o&&o>0?"success":"info"})]}),o>0&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[(0,a.jsx)("span",{children:"Overall Progress"}),(0,a.jsxs)("span",{className:"tabular-nums",children:[Math.round(l/o*100),"%"]})]}),(0,a.jsx)("div",{className:"h-1.5 rounded-full bg-border/50 overflow-hidden",children:(0,a.jsx)("div",{className:(0,L.cn)("h-full rounded-full transition-all",l===o?"bg-success":"bg-info"),style:{width:`${l/o*100}%`}})})]}),0===r.length&&(0,a.jsx)(aW,{message:"No plan loaded — run /gsd to initialize"})]})}let a3=["general","model","session-behavior","recovery","auth","integrations","workspace","experimental"],a4=["git"],a8=["resume","name","fork","session","compact"];function a6(e){return({model:"Model",thinking:"Thinking",git:"Git",login:"Login",logout:"Logout",settings:"Settings",resume:"Resume",name:"Name",fork:"Fork",session:"Session",export:"Export",compact:"Compact"})[e??""]??"Settings"}function a7(e){let t=Date.now()-new Date(e).getTime();if(t<6e4)return"just now";let s=Math.floor(t/6e4);if(s<60)return`${s}m ago`;let a=Math.floor(s/60);if(a<24)return`${a}h ago`;let r=Math.floor(a/24);return`${r}d ago`}function a9({status:e}){return(0,a.jsx)("span",{className:(0,L.cn)("inline-block h-1.5 w-1.5 rounded-full","ok"===e&&"bg-success","warning"===e&&"bg-warning","error"===e&&"bg-destructive","idle"===e&&"bg-foreground/20")})}function re({title:e,action:t,status:s}){return(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 pb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("h3",{className:"text-[13px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:e}),s]}),t]})}function rt({label:e,children:t,mono:s}){return(0,a.jsxs)("div",{className:"flex items-baseline justify-between gap-4 py-1.5 text-sm",children:[(0,a.jsx)("span",{className:"shrink-0 text-muted-foreground",children:e}),(0,a.jsx)("span",{className:(0,L.cn)("text-right text-foreground",s&&"font-mono text-xs"),children:t})]})}function rs({label:e,description:t,checked:s,onCheckedChange:r,disabled:n,busy:i,testId:o}){return(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4 rounded-lg border border-border/50 bg-card/50 px-4 py-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e,i&&(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),t&&(0,a.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:t})]}),(0,a.jsx)(sb,{checked:s,onCheckedChange:r,disabled:n||i,"data-testid":o})]})}function ra({options:e,value:t,onChange:s,disabled:r}){return(0,a.jsx)("div",{className:"inline-flex rounded-lg border border-border bg-card/50 p-0.5",children:e.map(e=>(0,a.jsx)("button",{type:"button",className:(0,L.cn)("rounded-md px-3 py-1.5 text-xs font-medium transition-all",t===e.value?"bg-foreground/10 text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:()=>s(e.value),disabled:r||t===e.value,children:e.label},e.value))})}function rr(){var e,t;let s,r,n,l,d=(0,J.gF)(),{closeCommandSurface:c,openCommandSurface:u,refreshBoot:m,setCommandSurfaceSection:h,selectCommandSurfaceTarget:x,loadGitSummary:p,loadRecoveryDiagnostics:g,loadForensicsDiagnostics:f,loadDoctorDiagnostics:b,loadSkillHealthDiagnostics:v,loadKnowledgeData:j,loadCapturesData:y,loadSettingsData:w,updateSessionBrowserState:N,loadSessionBrowser:k,renameSessionFromSurface:A,loadAvailableModels:R,applyModelSelection:I,applyThinkingLevel:F,setSteeringModeFromSurface:$,setFollowUpModeFromSurface:D,setAutoCompactionFromSurface:M,setAutoRetryFromSurface:q,abortRetryFromSurface:B,switchSessionFromSurface:U,loadSessionStats:O,exportSessionFromSurface:z,loadForkMessages:G,forkSessionFromSurface:W,compactSessionFromSurface:K,saveApiKeyFromSurface:V,startProviderFlowFromSurface:Y,submitProviderFlowInputFromSurface:Q,cancelProviderFlowFromSurface:Z,logoutProviderFromSurface:X,loadHistoryData:ee,loadInspectData:et,loadHooksData:es,loadUndoInfo:ea,loadCleanupData:er,loadSteerData:en}=(0,J._l)(),{commandSurface:ei}=d,eo=d.boot?.onboarding??null,el=eo?.activeFlow??null,ed=ei.gitSummary,ec=ei.recovery,eu=ei.sessionBrowser,em=d.boot?.bridge.sessionState??null,eh=ei.settingsRequests,ex=(0,J.iT)(d.boot?.bridge),ep=(0,J._0)(d.boot?.bridge),[eg,ef]=(0,i.useState)({}),[eb,ev]=(0,i.useState)(""),ej=(0,i.useRef)(null);(0,i.useEffect)(()=>{!ei.open||"model"!==ei.section||ei.availableModels.length>0||"loading_models"!==ei.pendingAction&&R()},[ei.open,ei.section,ei.availableModels.length,ei.pendingAction,R]),(0,i.useEffect)(()=>{!ei.open||"git"!==ei.section||"load_git_summary"===ei.pendingAction||ei.gitSummary.loaded||ei.gitSummary.error||p()},[ei.open,ei.section,ei.pendingAction,ei.gitSummary.loaded,ei.gitSummary.error,p]),(0,i.useEffect)(()=>{!ei.open||"recovery"!==ei.section||"load_recovery_diagnostics"===ei.pendingAction||ei.recovery.pending||(!ei.recovery.loaded||ei.recovery.stale||ei.recovery.error)&&g()},[ei.open,ei.section,ei.pendingAction,ei.recovery.pending,ei.recovery.loaded,ei.recovery.stale,ei.recovery.error,g]);let ey=ei.diagnostics,ew=ei.knowledgeCaptures,eN=ei.settingsData,eS=ei.remainingCommands;(0,i.useEffect)(()=>{ei.open&&("gsd-forensics"===ei.section&&"idle"===ey.forensics.phase?f():"gsd-doctor"===ei.section&&"idle"===ey.doctor.phase?b():"gsd-skill-health"===ei.section&&"idle"===ey.skillHealth.phase?v():"gsd-knowledge"===ei.section&&"idle"===ew.knowledge.phase?(j(),y()):("gsd-capture"===ei.section||"gsd-triage"===ei.section)&&"idle"===ew.captures.phase?(y(),j()):("gsd-prefs"===ei.section||"gsd-mode"===ei.section||"gsd-config"===ei.section||"experimental"===ei.section)&&"idle"===eN.phase?w():"gsd-history"===ei.section&&"idle"===eS.history.phase?ee():"gsd-inspect"===ei.section&&"idle"===eS.inspect.phase?et():"gsd-hooks"===ei.section&&"idle"===eS.hooks.phase?es():"gsd-undo"===ei.section&&"idle"===eS.undo.phase?ea():"gsd-cleanup"===ei.section&&"idle"===eS.cleanup.phase?er():"gsd-steer"===ei.section&&"idle"===eS.steer.phase&&en())},[ei.open,ei.section,ey.forensics.phase,ey.doctor.phase,ey.skillHealth.phase,ew.knowledge.phase,ew.captures.phase,eN.phase,eS.history.phase,eS.inspect.phase,eS.hooks.phase,eS.undo.phase,eS.cleanup.phase,eS.steer.phase,f,b,v,j,y,w,ee,et,es,ea,er,en]),(0,i.useEffect)(()=>{!ei.open||"resume"!==ei.section&&"name"!==ei.section||"load_session_browser"===ei.pendingAction||ei.sessionBrowser.loaded||k()},[ei.open,ei.section,ei.pendingAction,ei.sessionBrowser.loaded,k]),(0,i.useEffect)(()=>{if(!ei.open)return;let e=ej.current;e&&(e.scrollTop=0)},[ei.open,ei.activeSurface,ei.section]),(0,i.useEffect)(()=>{!ei.open||"session"!==ei.section||ei.sessionStats||"load_session_stats"!==ei.pendingAction&&O()},[ei.open,ei.section,ei.sessionStats,ei.pendingAction,O]),(0,i.useEffect)(()=>{!ei.open||"fork"!==ei.section||ei.forkMessages.length>0||"load_fork_messages"!==ei.pendingAction&&G()},[ei.open,ei.section,ei.forkMessages.length,ei.pendingAction,G]),(0,i.useEffect)(()=>{if(!ei.open||"resume"!==ei.section)return;let e=ei.selectedTarget?.kind==="resume"?ei.selectedTarget:null;if(e?.sessionPath)return;let t=eu.sessions.find(e=>!e.isActive)??eu.sessions[0];t&&x({kind:"resume",sessionPath:t.path})},[ei.open,ei.section,ei.selectedTarget,eu.sessions,x]),(0,i.useEffect)(()=>{if(!ei.open||"name"!==ei.section)return;let e=ei.selectedTarget?.kind==="name"?ei.selectedTarget:null;if(e?.sessionPath)return;let t=eu.sessions.find(e=>e.isActive)??eu.sessions[0];t&&x({kind:"name",sessionPath:t.path,name:t.name??""})},[ei.open,ei.section,ei.selectedTarget,eu.sessions,x]),(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{ev("")},0);return()=>window.clearTimeout(e)},[el?.flowId]),(0,i.useEffect)(()=>{ei.lastError&&sg.oR.error(ei.lastError)},[ei.lastError]),(0,i.useEffect)(()=>{ei.lastResult&&sg.oR.success(ei.lastResult)},[ei.lastResult]);let ek=ei.selectedTarget?.kind==="model"?ei.selectedTarget:null,eC=ei.selectedTarget?.kind==="thinking"?ei.selectedTarget:null,eA=ei.selectedTarget?.kind==="auth"?ei.selectedTarget:null,eR=ei.selectedTarget?.kind==="resume"?ei.selectedTarget:null,e_=ei.selectedTarget?.kind==="name"?ei.selectedTarget:null,eT=ei.selectedTarget?.kind==="fork"?ei.selectedTarget:null,eP=ei.selectedTarget?.kind==="session"?ei.selectedTarget:null,eE=ei.selectedTarget?.kind==="compact"?ei.selectedTarget:null,eI=(e=ei.activeSurface,t=ei.selectedTarget,t?.kind==="auth"?t.intent:"login"===e?"login":"logout"===e?"logout":"manage"),eF=eo?.required.providers.find(e=>e.id===eA?.providerId)??null,e$=(ek?.query??ei.args).trim().toLowerCase(),eL=(0,i.useMemo)(()=>e$?ei.availableModels.filter(e=>`${e.provider} ${e.modelId} ${e.name??""}`.toLowerCase().includes(e$)):ei.availableModels,[ei.availableModels,e$]),eD=(0,i.useMemo)(()=>{let e=new Map;for(let t of eL){let s=t.provider,a=e.get(s);a?a.push(t):e.set(s,[t])}return e},[eL]),eM="idle"!==d.onboardingRequestState,eq="loading_models"===ei.pendingAction||"get_available_models"===d.commandInFlight,eU="load_git_summary"===ei.pendingAction,eO="load_recovery_diagnostics"===ei.pendingAction||ec.pending,ez=ec.diagnostics,eG="load_session_browser"===ei.pendingAction,eW="load_fork_messages"===ei.pendingAction||"fork_session"===ei.pendingAction,eK="load_session_stats"===ei.pendingAction||"export_html"===ei.pendingAction,eV="switch_session"===ei.pendingAction,eH="rename_session"===ei.pendingAction,eY="compact_session"===ei.pendingAction||em?.isCompacting===!0,eJ=eh.steeringMode.pending||eh.followUpMode.pending,eZ=eh.autoCompaction.pending,e0=eh.autoRetry.pending,e1=eh.abortRetry.pending,e5=eF?eg[eF.id]??"":"",e2=tb(),e3=function(e,t=!1){switch(e){case"git":return[...a4];case"resume":case"name":case"fork":case"session":case"export":case"compact":return[...a8];default:return t?[...a3,"admin"]:[...a3]}}(ei.activeSurface,e2.isDevMode),e8=`/${ei.activeSurface??"settings"}`,e6=e=>{let t="name"===e,s=t?e_?.sessionPath:eR?.sessionPath;return(0,a.jsxs)("div",{className:"space-y-4","data-testid":t?"command-surface-name":"command-surface-resume",children:[(0,a.jsx)(re,{title:t?"Rename":"Resume",status:t?null:(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:ep??"pending"})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)(sh.A,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),(0,a.jsx)(eX.p,{value:eu.query,onChange:e=>N({query:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),k())},placeholder:"Search sessions…",className:"h-8 pl-9 text-xs",disabled:eG,"data-testid":"command-surface-session-browser-query"})]}),(0,a.jsx)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>void k(),disabled:eG,className:"h-8 w-8 p-0",children:(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3.5 w-3.5",eG&&"animate-spin")})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ra,{options:[{value:"threaded",label:"Threaded"},{value:"recent",label:"Recent"},{value:"relevance",label:"Relevance"}],value:eu.sortMode,onChange:e=>{N({sortMode:e}),k({sortMode:e})},disabled:eG}),(0,a.jsx)("button",{type:"button",className:(0,L.cn)("rounded-md border border-border px-2.5 py-1.5 text-[11px] font-medium transition-colors","named"===eu.nameFilter?"bg-foreground/10 text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>{let e="named"===eu.nameFilter?"all":"named";N({nameFilter:e}),k({nameFilter:e})},disabled:eG,children:"Named"})]}),eu.error&&(0,a.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive",children:eu.error}),eG&&0===eu.sessions.length?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading sessions…"]}):eu.sessions.length>0?(0,a.jsx)("div",{className:"space-y-1","data-testid":"command-surface-session-browser-results",children:eu.sessions.map(e=>{let r=e.path===s;return(0,a.jsxs)("button",{type:"button",className:(0,L.cn)("flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors",r?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),style:{paddingLeft:`${.75+.6*e.depth}rem`},onClick:()=>t?x({kind:"name",sessionPath:e.path,name:e_?.sessionPath===e.path?e_?.name??e.name??"":e.name??""}):x({kind:"resume",sessionPath:e.path}),"data-testid":`command-surface-session-browser-item-${e.id}`,children:[(0,a.jsx)("div",{className:(0,L.cn)("mt-1 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",r?"border-foreground bg-foreground":"border-foreground/25"),children:r&&(0,a.jsx)(eQ.A,{className:"h-2.5 w-2.5 text-background"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:e.name||e.firstMessage||e.id}),e.isActive&&(0,a.jsx)(a9,{status:"ok"})]}),e.name&&e.firstMessage&&(0,a.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.firstMessage}),(0,a.jsxs)("div",{className:"mt-0.5 flex gap-3 text-[11px] text-muted-foreground",children:[(0,a.jsxs)("span",{children:[e.messageCount," msgs"]}),(0,a.jsx)("span",{children:a7(e.modifiedAt)})]})]})]},e.path)})}):(0,a.jsx)("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No sessions matched."}),eu.loaded&&(0,a.jsxs)("p",{className:"text-[11px] text-muted-foreground","data-testid":"command-surface-session-browser-meta",children:["Current-project sessions \xb7 ",eu.returnedSessions," of ",eu.totalSessions," \xb7 ",eu.sortMode," \xb7 ",eu.nameFilter]}),t&&(0,a.jsxs)("div",{className:"space-y-3 border-t border-border/50 pt-3",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(eX.p,{value:e_?.name??"",onChange:e=>x({kind:"name",sessionPath:e_?.sessionPath,name:e.target.value}),placeholder:"Session name",className:"h-8 flex-1 text-xs",disabled:!e_?.sessionPath||eH,"data-testid":"command-surface-rename-input"}),(0,a.jsxs)(H,{type:"button",size:"sm",onClick:()=>e_?.sessionPath&&void A(e_.sessionPath,e_.name),disabled:!e_?.sessionPath||!e_.name.trim()||eH,"data-testid":"command-surface-apply-rename",className:"h-8 gap-1.5",children:[eH?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(sc.A,{className:"h-3.5 w-3.5"}),"Rename"]})]}),ei.renameRequest.error&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:ei.renameRequest.error}),ei.renameRequest.result&&(0,a.jsx)("p",{className:"text-xs text-success",children:ei.renameRequest.result})]}),!t&&(0,a.jsxs)("div",{className:"flex items-center justify-between border-t border-border/50 pt-3",children:[(0,a.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"command-surface-resume-state",children:eV?"Switching…":ei.resumeRequest.error??ei.resumeRequest.result??"Select a session"}),(0,a.jsxs)(H,{type:"button",size:"sm",onClick:()=>eR?.sessionPath&&void U(eR.sessionPath),disabled:!eR?.sessionPath||eV,"data-testid":"command-surface-apply-resume",className:"h-8 gap-1.5",children:[eV?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(si.A,{className:"h-3.5 w-3.5"}),"Switch"]})]})]})},te=e3.length<=1,tr="git"===ei.activeSurface,tn=ed.result;return(0,a.jsx)(e4,{open:ei.open,onOpenChange:e=>!e&&c(),children:(0,a.jsxs)(e7,{side:"right",className:"flex h-full w-full flex-col p-0 sm:max-w-[540px]","data-testid":"command-surface",children:[(0,a.jsxs)(e9,{className:"sr-only",children:[(0,a.jsx)(tt,{children:a6(ei.activeSurface)}),(0,a.jsx)(ts,{children:"Settings and controls"})]}),(0,a.jsxs)("div",{className:"flex h-full min-h-0",children:[!te&&(0,a.jsx)("nav",{className:"flex w-12 shrink-0 flex-col items-center gap-0.5 border-r border-border/50 bg-card/50 py-3","data-testid":"command-surface-sections",children:e3.map(e=>{let t=ei.section===e;return(0,a.jsxs)(tR.m_,{children:[(0,a.jsx)(tR.k$,{asChild:!0,children:(0,a.jsx)("button",{type:"button",className:(0,L.cn)("flex h-9 w-9 items-center justify-center rounded-lg transition-colors",t?"bg-foreground/10 text-foreground":"text-muted-foreground hover:bg-foreground/[0.04] hover:text-foreground"),onClick:()=>h(e),"data-testid":`command-surface-section-${e}`,children:{general:(0,a.jsx)(sr.A,{className:"h-4 w-4"}),model:(0,a.jsx)(eB.A,{className:"h-4 w-4"}),thinking:(0,a.jsx)(sn.A,{className:"h-4 w-4"}),queue:(0,a.jsx)(si.A,{className:"h-4 w-4"}),compaction:(0,a.jsx)(so.A,{className:"h-4 w-4"}),retry:(0,a.jsx)(sl.A,{className:"h-4 w-4"}),"session-behavior":(0,a.jsx)(si.A,{className:"h-4 w-4"}),recovery:(0,a.jsx)(P.A,{className:"h-4 w-4"}),auth:(0,a.jsx)(tk.A,{className:"h-4 w-4"}),admin:(0,a.jsx)(sd.A,{className:"h-4 w-4"}),git:(0,a.jsx)(S.A,{className:"h-4 w-4"}),resume:(0,a.jsx)(si.A,{className:"h-4 w-4"}),name:(0,a.jsx)(sc.A,{className:"h-4 w-4"}),fork:(0,a.jsx)(S.A,{className:"h-4 w-4"}),session:(0,a.jsx)(T.A,{className:"h-4 w-4"}),compact:(0,a.jsx)(so.A,{className:"h-4 w-4"}),workspace:(0,a.jsx)(tU.A,{className:"h-4 w-4"}),integrations:(0,a.jsx)(su.A,{className:"h-4 w-4"}),experimental:(0,a.jsx)(sm.A,{className:"h-4 w-4"})}[e]??null})}),(0,a.jsx)(tR.ZI,{side:"right",sideOffset:6,children:{general:"General",model:"Model",thinking:"Thinking",queue:"Queue",compaction:"Compaction",retry:"Retry","session-behavior":"Session",recovery:"Recovery",auth:"Auth",admin:"Admin",git:"Git",resume:"Resume",name:"Name",fork:"Fork",session:"Session",compact:"Compact",workspace:"Workspace",integrations:"Integrations",experimental:"Experimental"}[e]??e})]},e)})}),(0,a.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[tr?(s=tn?.kind==="repo"?tn.branch??"detached":null,r=tn?.kind==="repo"?tn.mainBranch:null,n=tn?.kind==="repo"&&tn.hasChanges,l=tn?.kind==="repo"&&!n,(0,a.jsx)("div",{className:"border-b border-border/50 px-5 py-4",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:(0,L.cn)("flex h-8 w-8 items-center justify-center rounded-lg",l?"bg-success/10":n?"bg-warning/10":"bg-card/50"),children:(0,a.jsx)(S.A,{className:(0,L.cn)("h-4 w-4",l?"text-success":n?"text-warning":"text-muted-foreground")})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground","data-testid":"command-surface-title",children:s??"Git"}),s&&r&&s!==r&&(0,a.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["from ",r]})]}),tn?.kind==="repo"&&(0,a.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5",children:[(0,a.jsx)(a9,{status:l?"ok":n?"warning":"idle"}),(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l?"Clean":n?"Changes detected":"Loading…"})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(H,{type:"button",variant:"ghost",size:"icon",onClick:()=>void p(),disabled:eU,"aria-label":"Refresh",className:"h-7 w-7",children:(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3.5 w-3.5",eU&&"animate-spin")})}),(0,a.jsx)(H,{type:"button",variant:"ghost",size:"icon",onClick:c,"aria-label":"Close",className:"h-7 w-7",children:(0,a.jsx)(o.A,{className:"h-3.5 w-3.5"})})]})]})})):(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-border/50 px-5 py-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:"Command surface"}),(0,a.jsx)("div",{className:"text-lg font-semibold text-foreground","data-testid":"command-surface-title",children:a6(ei.activeSurface)})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"rounded-full border border-border bg-card px-2.5 py-1 text-xs font-medium text-muted-foreground","data-testid":"command-surface-kind",children:e8}),(0,a.jsx)(H,{type:"button",variant:"ghost",size:"icon",onClick:c,"aria-label":"Close",className:"h-8 w-8",children:(0,a.jsx)(o.A,{className:"h-4 w-4"})})]})]}),(ei.lastResult||ei.lastError)&&(0,a.jsx)("div",{className:(0,L.cn)("border-b border-border/50 px-5 py-3 text-xs",ei.lastError?"bg-destructive/5 text-destructive":"bg-success/5 text-success"),"data-testid":"command-surface-result",children:ei.lastError??ei.lastResult}),(0,a.jsx)(tz,{className:"min-h-0 flex-1",viewportRef:ej,children:(0,a.jsx)("div",{className:"px-5 py-5",children:(()=>{switch(ei.section){case"general":return(0,a.jsx)(ay,{});case"experimental":return(0,a.jsx)(aN,{});case"model":case"thinking":return(0,a.jsxs)("div",{className:"space-y-8",children:[(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-models",children:[(0,a.jsx)(re,{title:"Model",status:(0,a.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:ex}),action:(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>void R(),disabled:eq,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3 w-3",eq&&"animate-spin")}),"Refresh"]})}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(sh.A,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),(0,a.jsx)(eX.p,{value:ek?.query??ei.args,onChange:e=>x({kind:"model",provider:ek?.provider,modelId:ek?.modelId,query:e.target.value}),placeholder:"Filter models…",className:"h-8 pl-9 text-xs"})]}),eq&&0===ei.availableModels.length?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-8 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading models…"]}):eL.length>0?(0,a.jsx)("div",{className:"space-y-4",children:Array.from(eD.entries()).map(([e,t])=>(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground",children:e}),(0,a.jsx)("div",{className:"space-y-0.5",children:t.map(e=>{let t=ek?.provider===e.provider&&ek?.modelId===e.modelId;return(0,a.jsxs)("button",{type:"button",className:(0,L.cn)("group flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left transition-colors",t?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),onClick:()=>x({kind:"model",provider:e.provider,modelId:e.modelId,query:ek?.query}),children:[(0,a.jsx)("div",{className:(0,L.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",t?"border-foreground bg-foreground":"border-foreground/25"),children:t&&(0,a.jsx)(eQ.A,{className:"h-2.5 w-2.5 text-background"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.name||e.modelId}),e.isCurrent&&(0,a.jsx)(a9,{status:"ok"})]}),(0,a.jsx)("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:e.modelId})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.isCurrent&&(0,a.jsx)("span",{className:"rounded bg-foreground/10 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Active"}),e.reasoning&&(0,a.jsx)("span",{className:"rounded bg-foreground/10 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Thinking"})]})]},`${e.provider}/${e.modelId}`)})})]},e))}):(0,a.jsx)("p",{className:"py-6 text-center text-xs text-muted-foreground",children:"No models matched."}),(0,a.jsx)("div",{className:"flex justify-end border-t border-border/50 pt-3",children:(0,a.jsxs)(H,{type:"button",size:"sm",onClick:()=>ek?.provider&&ek?.modelId&&void I(ek.provider,ek.modelId),disabled:!ek?.provider||!ek.modelId||"set_model"===ei.pendingAction,"data-testid":"command-surface-apply-model",className:"h-8 gap-1.5",children:["set_model"===ei.pendingAction?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(eQ.A,{className:"h-3.5 w-3.5"}),"Apply model"]})})]}),(0,a.jsx)("div",{className:"border-t border-border/50 pt-6",children:(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-thinking",children:[(0,a.jsx)(re,{title:"Thinking level",status:(0,a.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:d.boot?.bridge.sessionState?.thinkingLevel??"off"})}),(0,a.jsx)("div",{className:"space-y-1",children:sv.ll.map(e=>{let t=eC?.level===e,s=d.boot?.bridge.sessionState?.thinkingLevel===e,r="off"===e?"No reasoning overhead":"minimal"===e?"Light reasoning":"low"===e?"Basic analysis":"medium"===e?"Balanced reasoning":"high"===e?"Deep analysis":"Maximum deliberation";return(0,a.jsxs)("button",{type:"button",className:(0,L.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors",t?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),onClick:()=>x({kind:"thinking",level:e}),children:[(0,a.jsx)("div",{className:(0,L.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",t?"border-foreground bg-foreground":"border-foreground/25"),children:t&&(0,a.jsx)(eQ.A,{className:"h-2.5 w-2.5 text-background"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium capitalize text-foreground",children:e}),s&&(0,a.jsx)(a9,{status:"ok"})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:r})]})]},e)})}),(0,a.jsx)("div",{className:"flex justify-end border-t border-border/50 pt-3",children:(0,a.jsxs)(H,{type:"button",size:"sm",onClick:()=>eC&&void F(eC.level),disabled:!eC||"set_thinking_level"===ei.pendingAction,"data-testid":"command-surface-apply-thinking",className:"h-8 gap-1.5",children:["set_thinking_level"===ei.pendingAction?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(eQ.A,{className:"h-3.5 w-3.5"}),"Apply"]})})]})})]});case"session-behavior":case"queue":case"compaction":case"retry":return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-5","data-testid":"command-surface-queue-settings",children:[(0,a.jsx)(re,{title:"Queue modes"}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Steering mode"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"How steering messages queue during streaming"})]}),eh.steeringMode.pending&&(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),(0,a.jsx)(ra,{options:[{value:"all",label:"Queue all"},{value:"one-at-a-time",label:"One at a time"}],value:em?.steeringMode??null,onChange:e=>void $(e),disabled:!em||eJ}),eh.steeringMode.error&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:eh.steeringMode.error})]}),(0,a.jsx)("div",{className:"border-t border-border/50"}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Follow-up mode"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"How follow-up prompts sequence during a live turn"})]}),eh.followUpMode.pending&&(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),(0,a.jsx)(ra,{options:[{value:"all",label:"Queue all"},{value:"one-at-a-time",label:"One at a time"}],value:em?.followUpMode??null,onChange:e=>void D(e),disabled:!em||eJ}),eh.followUpMode.error&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:eh.followUpMode.error})]})]}),(0,a.jsx)("div",{className:"border-t border-border/50 pt-4",children:(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-auto-compaction-settings",children:[(0,a.jsx)(re,{title:"Auto-compaction",status:em?.isCompacting?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-warning",children:[(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"})," Compacting"]}):null}),(0,a.jsx)(rs,{label:"Auto-compact",description:"Automatically compact when context thresholds are crossed",checked:em?.autoCompactionEnabled??!1,onCheckedChange:e=>void M(e),disabled:!em||eZ,busy:eZ,testId:"command-surface-toggle-auto-compaction"}),eh.autoCompaction.error&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:eh.autoCompaction.error}),eh.autoCompaction.result&&(0,a.jsx)("p",{className:"text-xs text-success",children:eh.autoCompaction.result})]})}),(0,a.jsx)("div",{className:"border-t border-border/50 pt-4",children:(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-retry-settings",children:[(0,a.jsx)(re,{title:"Retry",status:em?.retryInProgress?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-warning",children:[(0,a.jsx)(su.A,{className:"h-3 w-3"})," Attempt ",Math.max(1,em.retryAttempt)]}):null}),(0,a.jsx)(rs,{label:"Auto-retry",description:"Automatically retry on transient failures",checked:em?.autoRetryEnabled??!1,onCheckedChange:e=>void q(e),disabled:!em||e0,busy:e0,testId:"command-surface-toggle-auto-retry"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"command-surface-auto-retry-state",children:e0?"Updating auto-retry…":eh.autoRetry.error?eh.autoRetry.error:eh.autoRetry.result?eh.autoRetry.result:em?.autoRetryEnabled?"Auto-retry enabled":"Auto-retry disabled"}),em?.retryInProgress&&(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-warning/20 bg-warning/5 px-4 py-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Retry in progress"}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Attempt ",Math.max(1,em.retryAttempt)," is active"]})]}),(0,a.jsxs)(H,{type:"button",variant:"destructive",size:"sm",onClick:()=>void B(),disabled:e1,"data-testid":"command-surface-abort-retry",className:"h-7 gap-1.5 text-xs",children:[e1?(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(o.A,{className:"h-3 w-3"}),"Abort"]})]}),eh.autoRetry.error&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:eh.autoRetry.error}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"command-surface-abort-retry-state",children:e1?"Aborting retry…":eh.abortRetry.error?eh.abortRetry.error:eh.abortRetry.result?eh.abortRetry.result:em?.retryInProgress?"Retry can be aborted":"No retry in progress"}),eh.abortRetry.error&&(0,a.jsx)("p",{className:"text-xs text-destructive",children:eh.abortRetry.error})]})})]});case"recovery":return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-recovery",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground","data-testid":"command-surface-recovery-state",children:eO?"Loading recovery diagnostics…":ec.error?"Recovery diagnostics failed":ec.stale?"Recovery diagnostics stale":ec.loaded?"Recovery diagnostics loaded":"Recovery diagnostics idle"}),(0,a.jsx)(re,{title:"Recovery",status:ez?(0,a.jsx)(a9,{status:"healthy"===ez.summary.tone?"ok":"warning"===ez.summary.tone?"warning":"error"}):null,action:(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>void g(),disabled:eO,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3 w-3",eO&&"animate-spin")}),"Refresh"]})}),ec.error&&(0,a.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive","data-testid":"command-surface-recovery-error",children:ec.error}),eO&&!ez&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading diagnostics…"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 border-t border-border/50 pt-3","data-testid":"command-surface-recovery-actions",children:(0,a.jsx)(H,{type:"button",variant:"default",size:"sm",onClick:()=>void g(),"data-testid":"command-surface-recovery-action-refresh_diagnostics",className:"h-7 text-xs",children:"Refresh diagnostics"})})]}),ez?.status==="unavailable"&&!ec.error&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-1 rounded-lg border border-border/50 bg-card/50 px-4 py-3","data-testid":"command-surface-recovery-summary",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:ez.summary.label}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:ez.summary.detail})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 border-t border-border/50 pt-3","data-testid":"command-surface-recovery-actions",children:(0,a.jsx)(H,{type:"button",variant:"default",size:"sm",onClick:()=>void g(),"data-testid":"command-surface-recovery-action-refresh_diagnostics",className:"h-7 text-xs",children:"Refresh diagnostics"})})]}),ez&&"unavailable"!==ez.status&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-1","data-testid":"command-surface-recovery-summary",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:ez.summary.label}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:ez.summary.detail})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5",children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Validation"}),(0,a.jsx)("div",{className:"mt-1 text-lg font-semibold tabular-nums text-foreground",children:ez.summary.validationCount})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5",children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Doctor"}),(0,a.jsx)("div",{className:"mt-1 text-lg font-semibold tabular-nums text-foreground",children:ez.summary.doctorIssueCount})]})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[ez.summary.retryInProgress&&(0,a.jsxs)(tA,{variant:"default",className:"text-[10px]",children:["Retry ",Math.max(1,ez.summary.retryAttempt)]}),ez.summary.compactionActive&&(0,a.jsx)(tA,{variant:"default",className:"text-[10px]",children:"Compacting"}),ez.summary.lastFailurePhase&&(0,a.jsxs)(tA,{variant:"destructive",className:"text-[10px]",children:["Phase ",ez.summary.lastFailurePhase]}),ec.stale&&(0,a.jsx)(tA,{variant:"outline",className:"text-[10px]",children:"Stale"})]}),ez.bridge.lastFailure&&(0,a.jsxs)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-2.5","data-testid":"command-surface-recovery-last-failure",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-destructive",children:"Last failure"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-destructive/80",children:ez.bridge.lastFailure.message}),(0,a.jsxs)("div",{className:"mt-1.5 flex gap-3 text-[10px] text-destructive/60",children:[(0,a.jsxs)("span",{children:["Phase: ",ez.bridge.lastFailure.phase]}),(0,a.jsx)("span",{children:a7(ez.bridge.lastFailure.at)})]})]}),ez.validation.topIssues.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Validation issues"}),ez.validation.topIssues.map(e=>(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2",children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)(tA,{variant:"error"===e.severity?"destructive":"outline",className:"text-[10px]",children:e.code})}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.message}),e.suggestion&&(0,a.jsxs)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["→ ",e.suggestion]})]},`${e.code}:${e.file??e.message}`))]}),ez.doctor.topIssues.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Doctor issues"}),ez.doctor.topIssues.map(e=>(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2",children:[(0,a.jsx)(tA,{variant:"outline",className:"text-[10px]",children:e.code}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.message})]},`${e.code}:${e.unitId??e.message}`))]}),ez.interruptedRun.detected&&(0,a.jsxs)("div",{className:"rounded-lg border border-warning/20 bg-warning/5 px-3 py-2.5","data-testid":"command-surface-recovery-interrupted-run",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-warning",children:"Interrupted run detected"}),(0,a.jsxs)("div",{className:"mt-1 space-y-1 text-xs text-warning/80",children:[(0,a.jsx)("p",{children:"Available: yes"}),(0,a.jsx)("p",{children:"Detected: yes"}),(0,a.jsx)("p",{children:ez.interruptedRun.detail})]}),(0,a.jsxs)("div",{className:"mt-1.5 grid gap-1 text-[10px] text-warning/60",children:[(0,a.jsxs)("span",{children:["Tool calls: ",ez.interruptedRun.counts.toolCalls]}),(0,a.jsxs)("span",{children:["Files written: ",ez.interruptedRun.counts.filesWritten]}),(0,a.jsxs)("span",{children:["Commands: ",ez.interruptedRun.counts.commandsRun]}),(0,a.jsxs)("span",{children:["Errors: ",ez.interruptedRun.counts.errors]}),(0,a.jsxs)("span",{children:["Last forensic error: ",ez.interruptedRun.lastError??"[redacted]"]})]})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 border-t border-border/50 pt-3","data-testid":"command-surface-recovery-actions",children:ez.actions.browser.length>0?ez.actions.browser.map(e=>(0,a.jsx)(H,{type:"button",variant:"danger"===e.emphasis?"destructive":"primary"===e.emphasis?"default":"outline",size:"sm",onClick:()=>(e=>{switch(e){case"refresh_diagnostics":g();return;case"refresh_workspace":m({soft:!0});return;case"open_retry_controls":h("retry");return;case"open_resume_controls":u("resume",{source:"surface"});return;case"open_auth_controls":h("auth");return;default:return}})(e.id),"data-testid":`command-surface-recovery-action-${e.id}`,className:"h-7 text-xs",children:e.label},e.id)):(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:eO?"Loading recovery actions…":"No browser recovery actions available."})}),ez.actions.commands.length>0&&(0,a.jsxs)("div",{className:"space-y-2 border-t border-border/50 pt-3","data-testid":"command-surface-recovery-commands",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Suggested commands"}),ez.actions.commands.map(e=>(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2 text-xs",children:[(0,a.jsx)("div",{className:"font-mono text-foreground",children:e.command}),(0,a.jsx)("p",{className:"mt-1 text-muted-foreground",children:e.label})]},e.command))]})]})]});case"auth":return eo?(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-auth",children:[(0,a.jsx)(re,{title:"Auth",status:(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"login"===eI?"Login":"logout"===eI?"Logout":"Manage"})}),(0,a.jsx)("div",{className:"space-y-1",children:eo.required.providers.map(e=>{let t=e.id===eF?.id;return(0,a.jsxs)("button",{type:"button",className:(0,L.cn)("flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors",t?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),onClick:()=>x({kind:"auth",providerId:e.id,intent:eI}),children:[(0,a.jsx)("div",{className:(0,L.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",t?"border-foreground bg-foreground":"border-foreground/25"),children:t&&(0,a.jsx)(eQ.A,{className:"h-2.5 w-2.5 text-background"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),e.configured&&(0,a.jsx)(a9,{status:"ok"})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e.configured?`via ${e.configuredVia}`:"Not configured"})]}),e.recommended&&(0,a.jsx)("span",{className:"rounded bg-foreground/10 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:"Recommended"})]},e.id)})}),eF&&(0,a.jsxs)("div",{className:"space-y-4 border-t border-border/50 pt-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:eF.label}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:eF.configuredVia??"Not configured"})]})}),eF.supports.apiKey&&(0,a.jsx)("form",{className:"space-y-3",onSubmit:e=>{e.preventDefault(),e5.trim()&&V(eF.id,e5)},children:(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(eX.p,{type:"password",autoComplete:"off",value:e5,onChange:e=>ef(t=>({...t,[eF.id]:e.target.value})),placeholder:"Paste API key",className:"h-8 flex-1 text-xs",disabled:eM,"data-testid":"command-surface-api-key-input"}),(0,a.jsxs)(H,{type:"submit",size:"sm",disabled:!e5.trim()||eM,"data-testid":"command-surface-save-api-key",className:"h-8 gap-1.5",children:["save_api_key"===ei.pendingAction?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(tP.A,{className:"h-3.5 w-3.5"}),"Save"]})]})}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[eF.supports.oauth&&eF.supports.oauthAvailable&&(0,a.jsxs)(H,{type:"button",variant:"outline",size:"sm",disabled:eM,onClick:()=>void Y(eF.id),"data-testid":"command-surface-start-provider-flow",className:"h-8 gap-1.5 text-xs",children:["start_provider_flow"===ei.pendingAction?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(sp.A,{className:"h-3.5 w-3.5"}),"Browser sign-in"]}),(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",disabled:eM,onClick:()=>void X(eF.id),"data-testid":"command-surface-logout-provider",className:"h-8 gap-1.5 text-xs text-destructive hover:text-destructive",children:["logout_provider"===ei.pendingAction?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(C.A,{className:"h-3.5 w-3.5"}),"Logout"]})]}),el&&el.providerId===eF.id&&(0,a.jsxs)("div",{className:"space-y-3 rounded-lg border border-foreground/10 bg-foreground/[0.03] px-4 py-3","data-testid":"command-surface-active-flow",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,a.jsx)(tA,{variant:"outline",className:"text-[10px]",children:el.status.replaceAll("_"," ")}),(0,a.jsx)("span",{className:"text-muted-foreground",children:new Date(el.updatedAt).toLocaleTimeString()})]}),el.auth?.instructions&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:el.auth.instructions}),el.auth?.url&&(0,a.jsx)(H,{asChild:!0,variant:"outline",size:"sm",className:"h-7 gap-1.5 text-xs","data-testid":"command-surface-open-auth-url",children:(0,a.jsxs)("a",{href:el.auth.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)(tF.A,{className:"h-3 w-3"}),"Open sign-in page"]})}),el.progress.length>0&&(0,a.jsx)("div",{className:"space-y-1",children:el.progress.map((e,t)=>(0,a.jsx)("div",{className:"rounded-md border border-border/50 bg-card/50 px-2.5 py-1.5 text-xs text-muted-foreground",children:e},`${el.flowId}-${t}`))}),el.prompt&&(0,a.jsxs)("form",{className:"space-y-2",onSubmit:e=>{e.preventDefault(),(el.prompt?.allowEmpty||eb.trim())&&Q(el.flowId,eb)},children:[(0,a.jsx)(eX.p,{value:eb,onChange:e=>ev(e.target.value),placeholder:el.prompt.placeholder||"Enter value",className:"h-8 text-xs",disabled:eM,"data-testid":"command-surface-flow-input"}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground",children:el.prompt.message}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(H,{type:"submit",size:"sm",disabled:eM||!el.prompt.allowEmpty&&!eb.trim(),className:"h-7 gap-1.5 text-xs",children:["submit_provider_flow_input"===ei.pendingAction?(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"}):(0,a.jsx)(tk.A,{className:"h-3 w-3"}),"Continue"]}),(0,a.jsx)(H,{type:"button",variant:"ghost",size:"sm",disabled:eM,onClick:()=>void Z(el.flowId),className:"h-7 text-xs",children:"Cancel"})]})]})]}),"idle"!==eo.bridgeAuthRefresh.phase&&(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 text-xs",children:[(0,a.jsx)("span",{className:"font-medium text-foreground",children:"Auth refresh"}),(0,a.jsx)("span",{className:"ml-2 text-muted-foreground",children:"pending"===eo.bridgeAuthRefresh.phase?"Refreshing…":"failed"===eo.bridgeAuthRefresh.phase?eo.bridgeAuthRefresh.error||"Failed.":"Complete."})]})]})]}):null;case"admin":return(0,a.jsxs)("div",{className:"space-y-5","data-testid":"command-surface-admin",children:[(0,a.jsx)(re,{title:"Admin",status:(0,a.jsx)(tA,{variant:"outline",className:"border-warning/20 bg-warning/[0.06] text-[10px] text-warning",children:"Dev only"})}),(0,a.jsx)(rs,{label:"UI overrides",description:"Enable keyboard shortcuts and forced UI states for development",checked:e2.enabled,onCheckedChange:e2.setEnabled,testId:"admin-ui-overrides-master"}),e2.enabled&&(0,a.jsxs)("div",{className:"space-y-2 rounded-lg border border-border/50 bg-card/50 p-3",children:[(0,a.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Override shortcuts"}),tx.map(e=>(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-md px-3 py-2.5 transition-colors hover:bg-foreground/[0.03]",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:e.label}),(0,a.jsx)(tA,{variant:"outline",className:"border-border font-mono text-[10px] text-muted-foreground",children:e.shortcutLabel})]}),(0,a.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:e.description})]}),(0,a.jsx)(sb,{checked:e2.overrides[e.key],onCheckedChange:()=>e2.toggle(e.key),"data-testid":`admin-override-${e.key}`})]},e.key))]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 p-3 space-y-3",children:[(0,a.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Onboarding"}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Run setup wizard"}),(0,a.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Opens the full onboarding flow as a new user would see it."})]}),(0,a.jsx)(H,{type:"button",size:"sm",className:"h-8 shrink-0 gap-1.5 text-xs",onClick:()=>{c(),window.setTimeout(()=>{e2.enabled||e2.setEnabled(!0),e2.overrides.forceOnboarding||e2.toggle("forceOnboarding")},150)},"data-testid":"admin-trigger-onboarding",children:"Launch"})]})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 text-xs text-muted-foreground",children:["This tab is only visible when running via"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px]",children:"npm run gsd:web"}),". Overrides reset on page refresh."]})]});case"git":let e;return e=ed.result,(0,a.jsxs)("div",{className:"space-y-5","data-testid":"command-surface-git-summary",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground","data-testid":"command-surface-git-state",children:eU?"Loading git summary…":ed.error?"Git summary failed":e?.kind==="not_repo"?"No git repository":e?.kind==="repo"?`Repo ready${e.hasChanges?" — changes detected":" — clean"}`:"Git summary idle"}),eU&&!e&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 py-16",children:[(0,a.jsx)(E.A,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading repo state…"})]}),ed.error&&(0,a.jsx)("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-xs text-destructive","data-testid":"command-surface-git-error",children:ed.error}),!ed.error&&e?.kind==="not_repo"&&(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3 py-16 text-center","data-testid":"command-surface-git-not-repo",children:[(0,a.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border border-border/50 bg-card/50",children:(0,a.jsx)(S.A,{className:"h-4.5 w-4.5 text-muted-foreground"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-foreground",children:"No Git repository"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.message})]})]}),!ed.error&&e?.kind==="repo"&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"font-mono",children:(0,J.nf)(e.project.repoRoot,3)}),e.project.repoRelativePath&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(_.A,{className:"h-3 w-3 text-muted-foreground"}),(0,a.jsx)("span",{className:"font-mono",children:e.project.repoRelativePath})]})]}),(0,a.jsx)("div",{className:"grid grid-cols-4 gap-1.5","data-testid":"command-surface-git-counts",children:[{label:"Staged",count:e.counts.staged,active:e.counts.staged>0,color:"text-success"},{label:"Modified",count:e.counts.dirty,active:e.counts.dirty>0,color:"text-warning"},{label:"Untracked",count:e.counts.untracked,active:e.counts.untracked>0,color:"text-muted-foreground"},{label:"Conflicts",count:e.counts.conflicts,active:e.counts.conflicts>0,color:"text-destructive"}].map(({label:e,count:t,active:s,color:r})=>(0,a.jsxs)("div",{className:(0,L.cn)("rounded-md border px-2 py-2 text-center transition-colors",s?"border-border bg-card":"border-border/50 bg-card/50"),children:[(0,a.jsx)("div",{className:(0,L.cn)("text-base font-semibold tabular-nums leading-none",s?r:"text-muted-foreground"),children:t}),(0,a.jsx)("div",{className:(0,L.cn)("mt-1.5 text-[10px] leading-none","text-muted-foreground"),children:e})]},e))}),e.changedFiles.length>0&&(0,a.jsxs)("div",{"data-testid":"command-surface-git-files",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:"Changes"}),(0,a.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[e.changedFiles.length,e.truncatedFileCount>0?`+${e.truncatedFileCount}`:""," files"]})]}),(0,a.jsx)("div",{className:"space-y-px rounded-lg border border-border/50 bg-card/50 overflow-hidden",children:e.changedFiles.map(e=>(0,a.jsxs)("div",{className:"group flex items-center gap-2.5 px-3 py-2 transition-colors hover:bg-foreground/[0.03]",children:[(0,a.jsx)("span",{className:(0,L.cn)("flex h-5 w-5 shrink-0 items-center justify-center rounded text-[10px] font-semibold",(e=>{switch(e){case"M":return"text-warning bg-warning/10";case"A":return"text-success bg-success/10";case"D":case"U":return"text-destructive bg-destructive/10";case"R":case"C":return"text-info bg-info/10";default:return"text-muted-foreground bg-foreground/5"}})(e.status)),children:e.status}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground/80",children:e.path}),e.conflict&&(0,a.jsx)("span",{className:"shrink-0 rounded bg-destructive/15 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-destructive",children:"conflict"})]},`${e.status}:${e.repoPath}`))}),e.truncatedFileCount>0&&(0,a.jsxs)("p",{className:"mt-1.5 text-center text-[11px] text-muted-foreground",children:["+",e.truncatedFileCount," more files not shown"]})]}),0===e.changedFiles.length&&(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2 py-8 text-center",children:[(0,a.jsx)(eQ.A,{className:"h-4 w-4 text-success/60"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Working tree clean"})]})]})]});case"resume":return e6("resume");case"name":return e6("name");case"fork":return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-fork",children:[(0,a.jsx)(re,{title:"Fork",action:(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>void G(),disabled:eW,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3 w-3","load_fork_messages"===ei.pendingAction&&"animate-spin")}),"Refresh"]})}),eW&&0===ei.forkMessages.length?(0,a.jsxs)("div",{className:"flex items-center gap-2 py-6 text-xs text-muted-foreground",children:[(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading fork points…"]}):ei.forkMessages.length>0?(0,a.jsx)("div",{className:"space-y-1",children:ei.forkMessages.map(e=>{let t=eT?.entryId===e.entryId;return(0,a.jsxs)("button",{type:"button",className:(0,L.cn)("flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors",t?"bg-foreground/[0.07]":"hover:bg-foreground/[0.03]"),onClick:()=>x({kind:"fork",entryId:e.entryId}),children:[(0,a.jsx)("div",{className:(0,L.cn)("mt-1 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",t?"border-foreground bg-foreground":"border-foreground/25"),children:t&&(0,a.jsx)(eQ.A,{className:"h-2.5 w-2.5 text-background"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"font-mono text-[10px] text-muted-foreground",children:e.entryId}),(0,a.jsx)("p",{className:"mt-0.5 text-sm text-foreground",children:e.text})]})]},e.entryId)})}):(0,a.jsx)("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No fork points available yet."}),(0,a.jsx)("div",{className:"flex justify-end border-t border-border/50 pt-3",children:(0,a.jsxs)(H,{type:"button",size:"sm",onClick:()=>eT?.entryId&&void W(eT.entryId),disabled:!eT?.entryId||"fork_session"===ei.pendingAction,"data-testid":"command-surface-apply-fork",className:"h-8 gap-1.5",children:["fork_session"===ei.pendingAction?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(S.A,{className:"h-3.5 w-3.5"}),"Create fork"]})})]});case"session":return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-session",children:[(0,a.jsx)(re,{title:"Session",status:(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:ep??"pending"}),action:(0,a.jsxs)(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>void O(),disabled:eK,className:"h-7 gap-1.5 text-xs",children:[(0,a.jsx)(sl.A,{className:(0,L.cn)("h-3 w-3","load_session_stats"===ei.pendingAction&&"animate-spin")}),"Refresh"]})}),ei.sessionStats?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{label:"Input",value:(0,J._y)(ei.sessionStats.tokens.input)},{label:"Output",value:(0,J._y)(ei.sessionStats.tokens.output)},{label:"Total",value:(0,J._y)(ei.sessionStats.tokens.total)}].map(({label:e,value:t})=>(0,a.jsxs)("div",{className:"rounded-lg border border-border/50 bg-card/50 px-3 py-2.5 text-center",children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:e}),(0,a.jsx)("div",{className:"mt-1 text-sm font-semibold tabular-nums text-foreground",children:t})]},e))}),(0,a.jsxs)("div",{className:"divide-y divide-border/30 rounded-lg border border-border/50 bg-card/50",children:[(0,a.jsxs)("div",{className:"px-4 py-2",children:[(0,a.jsx)(rt,{label:"User messages",children:ei.sessionStats.userMessages}),(0,a.jsx)(rt,{label:"Assistant messages",children:ei.sessionStats.assistantMessages}),(0,a.jsx)(rt,{label:"Tool calls",children:ei.sessionStats.toolCalls}),(0,a.jsx)(rt,{label:"Tool results",children:ei.sessionStats.toolResults})]}),(0,a.jsxs)("div",{className:"px-4 py-2",children:[(0,a.jsx)(rt,{label:"Total messages",children:ei.sessionStats.totalMessages}),(0,a.jsx)(rt,{label:"Cost",children:(0,J.BD)(ei.sessionStats.cost)}),ei.sessionStats.tokens.cacheRead>0&&(0,a.jsx)(rt,{label:"Cache read",children:(0,J._y)(ei.sessionStats.tokens.cacheRead)})]})]})]}):(0,a.jsx)("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"Refresh to load session stats."}),(0,a.jsxs)("div",{className:"space-y-3 border-t border-border/50 pt-3",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Export"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(eX.p,{value:eP?.outputPath??"",onChange:e=>x({kind:"session",outputPath:e.target.value}),placeholder:"Output path (optional)",className:"h-8 flex-1 text-xs",disabled:"export_html"===ei.pendingAction,"data-testid":"command-surface-export-path"}),(0,a.jsxs)(H,{type:"button",size:"sm",onClick:()=>void z(eP?.outputPath),disabled:"export_html"===ei.pendingAction,"data-testid":"command-surface-export-session",className:"h-8 gap-1.5",children:["export_html"===ei.pendingAction?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(sx.A,{className:"h-3.5 w-3.5"}),"Export HTML"]})]})]})]});case"compact":return(0,a.jsxs)("div",{className:"space-y-4","data-testid":"command-surface-compact",children:[(0,a.jsx)(re,{title:"Manual compact",status:eY?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-warning",children:[(0,a.jsx)(E.A,{className:"h-3 w-3 animate-spin"})," Working"]}):null}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"text-xs font-medium text-muted-foreground",htmlFor:"command-surface-compact-instructions",children:"Custom instructions"}),(0,a.jsx)(ta,{id:"command-surface-compact-instructions","data-testid":"command-surface-compact-instructions",value:eE?.customInstructions??"",onChange:e=>x({kind:"compact",customInstructions:e.target.value}),placeholder:"Tell compaction what to preserve or emphasize…",rows:4,disabled:eY,className:"text-xs"})]}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsxs)(H,{type:"button",size:"sm",onClick:()=>void K(eE?.customInstructions),disabled:eY,"data-testid":"command-surface-apply-compact",className:"h-8 gap-1.5",children:[eY?(0,a.jsx)(E.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(so.A,{className:"h-3.5 w-3.5"}),"Compact now"]})}),ei.lastCompaction&&(0,a.jsxs)("div",{className:"space-y-2 rounded-lg border border-border/50 bg-card/50 px-4 py-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Last compaction"}),(0,a.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[(0,J._y)(ei.lastCompaction.tokensBefore)," before"]})]}),(0,a.jsx)("p",{className:"whitespace-pre-wrap text-xs text-foreground",children:ei.lastCompaction.summary}),(0,a.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["First kept: ",ei.lastCompaction.firstKeptEntryId]})]})]});case"workspace":return(0,a.jsx)(aI,{});case"integrations":return(0,a.jsx)(ax,{});case"gsd-forensics":return(0,a.jsx)(s_,{});case"gsd-doctor":return(0,a.jsx)(sP,{});case"gsd-skill-health":return(0,a.jsx)(sI,{});case"gsd-knowledge":return(0,a.jsx)(s1,{initialTab:"knowledge"});case"gsd-capture":case"gsd-triage":return(0,a.jsx)(s1,{initialTab:"captures"});case"gsd-prefs":return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)(aI,{}),(0,a.jsx)(ai,{}),(0,a.jsx)(ad,{}),(0,a.jsx)(au,{}),(0,a.jsx)(ax,{}),(0,a.jsx)(ay,{}),(0,a.jsx)(aN,{})]});case"gsd-mode":return(0,a.jsx)(ad,{});case"gsd-config":return(0,a.jsx)(au,{});case"gsd-quick":return(0,a.jsx)(aH,{});case"gsd-history":return(0,a.jsx)(aY,{});case"gsd-undo":return(0,a.jsx)(aJ,{});case"gsd-steer":return(0,a.jsx)(aQ,{});case"gsd-hooks":return(0,a.jsx)(aZ,{});case"gsd-inspect":return(0,a.jsx)(aX,{});case"gsd-export":return(0,a.jsx)(a0,{});case"gsd-cleanup":return(0,a.jsx)(a1,{});case"gsd-queue":return(0,a.jsx)(a5,{});case"gsd-status":return(0,a.jsx)(a2,{});default:if(ei.section?.startsWith("gsd-"))return(0,a.jsxs)("div",{className:"p-4 text-sm text-muted-foreground","data-testid":`gsd-surface-${ei.section}`,children:[(0,a.jsxs)("p",{className:"font-medium text-foreground",children:["/gsd ",ei.section.slice(4)]}),(0,a.jsx)("p",{className:"mt-1",children:"Unknown GSD surface."})]});return null}})()})})]})]})]})})}function rn(){let[e,t]=(0,i.useState)(null),[s,r]=(0,i.useState)(!1),[n,o]=(0,i.useState)(!1),l=(0,i.useRef)(null),d=(0,i.useCallback)(async()=>{try{let e=await (0,en.tm)("/api/update");if(!e.ok)return;let s=await e.json();t(s)}catch{}},[]);(0,i.useEffect)(()=>{d()},[d]),(0,i.useEffect)(()=>(e?.updateStatus==="running"&&(l.current=setInterval(()=>void d(),3e3)),()=>{l.current&&(clearInterval(l.current),l.current=null)}),[e?.updateStatus,d]);let c=async()=>{r(!0);try{let e=await (0,en.tm)("/api/update",{method:"POST"});e.ok||202===e.status?await d():409===e.status&&await d()}catch{}finally{r(!1)}};if(!e||!e.updateAvailable&&"idle"===e.updateStatus||n)return null;let u="running"===e.updateStatus,m="success"===e.updateStatus,h="error"===e.updateStatus,x=e.targetVersion??e.latestVersion;return(0,a.jsxs)("div",{"data-testid":"update-banner",className:(0,L.cn)("flex items-center gap-3 border-b px-4 py-2 text-xs",m&&"border-success/20 bg-success/10 text-success",h&&"border-destructive/20 bg-destructive/10 text-destructive",!m&&!h&&"border-warning/20 bg-warning/10 text-warning"),children:[m?(0,a.jsxs)("span",{className:"flex-1","data-testid":"update-banner-message",children:["Update complete — restart GSD to use v",x]}):h?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"flex-1","data-testid":"update-banner-message",children:["Update failed",e.error?`: ${e.error}`:""]}),(0,a.jsx)("button",{onClick:()=>void c(),disabled:s,className:(0,L.cn)("flex-shrink-0 rounded border border-destructive/30 bg-background px-2 py-0.5 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",s&&"cursor-not-allowed opacity-50"),"data-testid":"update-banner-retry",children:"Retry"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"flex-1","data-testid":"update-banner-message",children:u?(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(ri,{}),"Updating to v",x,"…"]}):(0,a.jsxs)(a.Fragment,{children:["Update available: v",e.currentVersion," → v",e.latestVersion]})}),!u&&(0,a.jsx)("button",{onClick:()=>void c(),disabled:s,className:(0,L.cn)("flex-shrink-0 rounded border border-warning/30 bg-background px-2 py-0.5 text-xs font-medium text-warning transition-colors hover:bg-warning/10",s&&"cursor-not-allowed opacity-50"),"data-testid":"update-banner-action",children:"Update"})]}),(0,a.jsx)("button",{onClick:()=>o(!0),"aria-label":"Dismiss update banner",className:"flex-shrink-0 rounded p-0.5 opacity-50 transition-opacity hover:opacity-100","data-testid":"update-banner-dismiss",children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,a.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function ri(){return(0,a.jsxs)("svg",{className:"h-3 w-3 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}let ro=new Set(["dashboard","power","chat","roadmap","files","activity","visualize"]),rl=()=>(0,a.jsx)("div",{className:"h-full w-full p-4",children:(0,a.jsx)(er,{className:"h-full w-full"})}),rd=(0,n.default)(()=>s.e(5516).then(s.bind(s,45516)).then(e=>e.Roadmap),{loadableGenerated:{webpack:()=>[45516]},loading:rl,ssr:!1}),rc=(0,n.default)(()=>Promise.all([s.e(6079),s.e(3497),s.e(2824),s.e(9441),s.e(3026)]).then(s.bind(s,13026)).then(e=>e.FilesView),{loadableGenerated:{webpack:()=>[13026]},loading:rl,ssr:!1}),ru=(0,n.default)(()=>s.e(315).then(s.bind(s,80315)).then(e=>e.ActivityView),{loadableGenerated:{webpack:()=>[80315]},loading:rl,ssr:!1}),rm=(0,n.default)(()=>s.e(2556).then(s.bind(s,42556)).then(e=>e.VisualizerView),{loadableGenerated:{webpack:()=>[42556]},loading:rl,ssr:!1}),rh=(0,n.default)(()=>s.e(8845).then(s.bind(s,71226)).then(e=>e.DualTerminal),{loadableGenerated:{webpack:()=>[71226]},loading:rl,ssr:!1}),rx=(0,n.default)(()=>Promise.all([s.e(3497),s.e(9441)]).then(s.bind(s,79441)).then(e=>e.ChatMode),{loadableGenerated:{webpack:()=>[79441]},loading:rl,ssr:!1});function rp(e){return`gsd-active-view:${e}`}function rg(){let[e,t]=(0,i.useState)("dashboard"),[s,n]=(0,i.useState)(!1),[d,c]=(0,i.useState)(300),[u,m]=(0,i.useState)(!1),h=(0,i.useRef)(!1),x=(0,i.useRef)(!1),p=(0,i.useRef)(0),g=(0,i.useRef)(0),[f,b]=(0,i.useState)(256),v=(0,i.useRef)(!1),j=(0,i.useRef)(0),y=(0,i.useRef)(0),[w,N]=(0,i.useState)(!1),[S,k]=(0,i.useState)(!1),[C,A]=(0,i.useState)(!1),[R,_]=(0,i.useState)(!1),[T,P]=(0,i.useState)(!1),E=(0,J.gF)(),{refreshBoot:I}=(0,J._l)(),F=(0,J.tM)(E),$=E.boot?.project.cwd,D=(0,J.$9)($),M=E.titleOverride?.trim()||null,q=(0,J.U4)(E.boot?.workspace),B=(0,J.QC)(E);(0,i.useEffect)(()=>{if(S||!$)return;let e=window.setTimeout(()=>{try{let e=sessionStorage.getItem(rp($));e&&ro.has(e)&&t(e)}catch{}k(!0)},0);return()=>window.clearTimeout(e)},[$,S]);let U=(0,i.useRef)($);(0,i.useEffect)(()=>{U.current!==$&&(U.current=$,k(!1))},[$]),(0,i.useEffect)(()=>{if($)try{sessionStorage.setItem(rp($),e)}catch{}},[e,$]),(0,i.useEffect)(()=>{let e=window.setTimeout(()=>{try{let e=localStorage.getItem("gsd-sidebar-collapsed");"true"===e&&N(!0)}catch{}},0);return()=>window.clearTimeout(e)},[]),(0,i.useEffect)(()=>{try{localStorage.setItem("gsd-sidebar-collapsed",String(w))}catch{}},[w]),(0,i.useEffect)(()=>{if("u"<typeof document)return;let e=D?`GSD - ${D}`:"GSD";document.title=M?`${M} \xb7 ${e}`:e},[M,D]);let O=(0,i.useCallback)(e=>{t(e),_(!1)},[]);(0,i.useEffect)(()=>{let e=()=>{t("files")};return window.addEventListener("gsd:open-file",e),()=>window.removeEventListener("gsd:open-file",e)},[]),(0,i.useEffect)(()=>{let e=e=>{ro.has(e.detail.view)&&O(e.detail.view)};return window.addEventListener("gsd:navigate-view",e),()=>window.removeEventListener("gsd:navigate-view",e)},[O]),(0,i.useEffect)(()=>{let e=()=>A(!0);return window.addEventListener("gsd:open-projects",e),()=>window.removeEventListener("gsd:open-projects",e)},[]),(0,i.useEffect)(()=>{let e=e=>{if(h.current){x.current=!0;let t=p.current-e.clientY;c(Math.max(150,Math.min(600,g.current+t)))}if(v.current){let t=j.current-e.clientX;b(Math.max(180,Math.min(480,y.current+t)))}},t=()=>{h.current=!1,v.current=!1,m(!1),document.body.style.cursor="",document.body.style.userSelect=""};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[]);let z=(0,i.useCallback)(e=>{h.current=!0,m(!0),p.current=e.clientY,g.current=d,document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[d]),G=(0,i.useCallback)(e=>{v.current=!0,j.current=e.clientX,y.current=f,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[f]),W=!!E.commandInFlight||"idle"!==E.onboardingRequestState,K="idle"===E.bootStatus||"loading"===E.bootStatus;(0,i.useEffect)(()=>{if(!K)return;let e=sg.oR.loading("Connecting to workspace…",{description:"Establishing the live bridge session",duration:1/0});return()=>{sg.oR.dismiss(e)}},[K]);let V=E.boot?.projectDetection,H=!K&&"dashboard"===e&&null!=V&&"active-gsd"!==V.kind&&"empty-gsd"!==V.kind;return"unauthenticated"===E.bootStatus?(0,a.jsxs)("div",{className:"flex h-dvh flex-col items-center justify-center gap-6 bg-background p-8 text-center",children:[(0,a.jsx)(r.default,{src:"/logo-black.svg",alt:"GSD",width:57,height:16,className:"shrink-0 h-4 w-auto dark:hidden"}),(0,a.jsx)(r.default,{src:"/logo-white.svg",alt:"GSD",width:57,height:16,className:"shrink-0 h-4 w-auto hidden dark:block"}),(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,a.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Authentication Required"}),(0,a.jsxs)("p",{className:"max-w-sm text-sm text-muted-foreground",children:["This workspace requires an auth token. Copy the full URL from your terminal (including the"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs",children:"#token=…"})," ","part) or restart with"," ",(0,a.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-xs",children:"gsd --web"}),"."]})]})]}):(0,a.jsxs)("div",{className:"relative flex h-screen flex-col overflow-hidden bg-background text-foreground",children:[(0,a.jsxs)("header",{className:"flex h-12 flex-shrink-0 items-center justify-between border-b border-border bg-card px-2 md:px-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 md:gap-3 min-w-0",children:[(0,a.jsx)("button",{className:"flex md:hidden h-10 w-10 items-center justify-center rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",onClick:()=>_(!R),"aria-label":R?"Close navigation":"Open navigation","data-testid":"mobile-nav-toggle",children:R?(0,a.jsx)(o.A,{className:"h-5 w-5"}):(0,a.jsx)(l.A,{className:"h-5 w-5"})}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(r.default,{src:"/logo-black.svg",alt:"GSD",width:57,height:16,className:"shrink-0 h-4 w-auto dark:hidden"}),(0,a.jsx)(r.default,{src:"/logo-white.svg",alt:"GSD",width:57,height:16,className:"shrink-0 h-4 w-auto hidden dark:block"}),(0,a.jsx)(tA,{variant:"outline",className:"hidden sm:inline-flex text-[10px] rounded-full border-foreground/15 bg-accent/40 text-muted-foreground font-normal",children:"beta"})]}),(0,a.jsx)("span",{className:"hidden sm:inline text-2xl font-thin text-muted-foreground leading-none select-none",children:"/"}),(0,a.jsx)("span",{className:"hidden sm:inline text-sm text-muted-foreground truncate","data-testid":"workspace-project-cwd",title:$??void 0,children:K?(0,a.jsx)(er,{className:"inline-block h-4 w-28 align-middle"}):(0,a.jsxs)(a.Fragment,{children:[D,M&&(0,a.jsx)("span",{className:"ml-2 inline-flex items-center rounded-full border border-foreground/15 bg-accent/60 px-2 py-0.5 text-[10px] font-medium text-foreground","data-testid":"workspace-title-override",title:M,children:M})]})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 md:gap-3",children:[(0,a.jsx)("span",{className:"sr-only","data-testid":"workspace-connection-status",children:F.label}),(0,a.jsx)("span",{className:"hidden sm:inline text-xs text-muted-foreground","data-testid":"workspace-scope-label",children:K?(0,a.jsx)(er,{className:"inline-block h-3.5 w-40 align-middle"}):(0,a.jsx)(ek,{label:q,size:"sm"})})]})]}),(0,a.jsx)(rn,{}),!K&&B&&(0,a.jsxs)("div",{className:"flex items-center gap-3 border-b border-destructive/20 bg-destructive/10 px-4 py-2 text-xs text-destructive","data-testid":"workspace-error-banner",children:[(0,a.jsx)("span",{className:"flex-1",children:B}),(0,a.jsx)("button",{onClick:()=>void I(),disabled:W,className:(0,L.cn)("flex-shrink-0 rounded border border-destructive/30 bg-background px-2 py-0.5 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",W&&"cursor-not-allowed opacity-50"),children:"Retry"})]}),R&&(0,a.jsx)("div",{className:"fixed inset-0 z-40 bg-black/50 md:hidden",onClick:()=>_(!1),"data-testid":"mobile-nav-overlay"}),(0,a.jsx)("div",{className:(0,L.cn)("fixed inset-y-0 left-0 z-50 w-64 transform bg-sidebar border-r border-border transition-transform duration-200 ease-out md:hidden",R?"translate-x-0":"-translate-x-full"),"data-testid":"mobile-nav-drawer",children:(0,a.jsx)(eu,{activeView:e,onViewChange:K?()=>{}:O,isConnecting:K,mobile:!0})}),T&&(0,a.jsx)("div",{className:"fixed inset-0 z-40 bg-black/50 md:hidden",onClick:()=>P(!1),"data-testid":"mobile-milestone-overlay"}),!H&&(0,a.jsx)("div",{className:(0,L.cn)("fixed inset-y-0 right-0 z-50 w-72 transform bg-sidebar border-l border-border transition-transform duration-200 ease-out md:hidden",T?"translate-x-0":"translate-x-full"),"data-testid":"mobile-milestone-drawer",children:(0,a.jsx)(ed,{isConnecting:K,width:288,onCollapse:()=>P(!1)})}),(0,a.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,a.jsx)("div",{className:"hidden md:flex",children:(0,a.jsx)(eu,{activeView:e,onViewChange:K?()=>{}:O,isConnecting:K})}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,a.jsx)("div",{className:(0,L.cn)("flex-1 overflow-hidden transition-all",s&&"h-1/3"),children:K?(0,a.jsx)(eM,{}):(0,a.jsxs)(a.Fragment,{children:["dashboard"===e&&(0,a.jsx)(eM,{onSwitchView:O,onExpandTerminal:()=>n(!0)}),"power"===e&&(0,a.jsx)(rh,{}),"roadmap"===e&&(0,a.jsx)(rd,{}),"files"===e&&(0,a.jsx)(rc,{}),"activity"===e&&(0,a.jsx)(ru,{}),"visualize"===e&&(0,a.jsx)(rm,{}),"chat"===e&&(0,a.jsx)(rx,{})]})}),"power"!==e&&"chat"!==e&&(0,a.jsxs)("div",{className:"border-t border-border flex flex-col",style:{flexShrink:0},children:[(0,a.jsx)("div",{role:"button",tabIndex:0,onClick:()=>{if(x.current){x.current=!1;return}K||n(!s)},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),K||n(!s))},className:(0,L.cn)("flex h-8 w-full items-center justify-between bg-card px-3 text-xs select-none transition-colors",s&&"cursor-row-resize",!s&&!K&&"cursor-pointer hover:bg-muted/50",K&&"cursor-default"),onMouseDown:e=>{s&&z(e)},children:(0,a.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,a.jsx)("span",{className:"font-medium text-foreground",children:"Terminal"}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground",children:s?"▼":"▲"})]})}),(0,a.jsx)("div",{className:"overflow-hidden",style:{height:s?d:0,transition:u?"none":"height 200ms"},children:s&&(0,a.jsx)(eh.x,{className:"h-full",projectCwd:E.boot?.project.cwd})})]})]}),!H&&!w&&(0,a.jsxs)("div",{className:"relative hidden md:flex h-full items-stretch",style:{flexShrink:0},children:[(0,a.jsx)("div",{className:"w-px bg-border"}),(0,a.jsx)("div",{className:"absolute left-[-3px] top-0 bottom-0 w-[7px] cursor-col-resize z-10 hover:bg-muted-foreground/20 transition-colors",onMouseDown:G})]}),(0,a.jsx)("div",{className:"hidden md:flex",children:!H&&(w?(0,a.jsx)(ec,{onExpand:()=>N(!1)}):(0,a.jsx)(ed,{isConnecting:K,width:f,onCollapse:()=>N(!0)}))})]}),(0,a.jsx)("div",{className:"hidden md:block",children:(0,a.jsx)(eG,{})}),!H&&(0,a.jsxs)("div",{className:"flex md:hidden h-12 items-center justify-between border-t border-border bg-card px-3","data-testid":"mobile-bottom-bar",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground truncate",children:[(0,a.jsx)("span",{className:"sr-only","data-testid":"workspace-connection-status-mobile",children:F.label}),(0,a.jsx)("span",{className:(0,L.cn)("h-2 w-2 rounded-full shrink-0","success"===F.tone?"bg-success":"warning"===F.tone?"bg-warning":"danger"===F.tone?"bg-destructive":"bg-muted-foreground")}),(0,a.jsx)("span",{className:"truncate",children:q})]}),(0,a.jsx)("button",{onClick:()=>P(!T),className:"flex h-10 items-center gap-2 rounded-md px-3 text-xs font-medium text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors","data-testid":"mobile-milestone-toggle",children:"Milestones"})]}),(0,a.jsx)(a_,{open:C,onOpenChange:A}),(0,a.jsx)(rr,{}),(0,a.jsx)(tc,{}),(0,a.jsx)(sa,{})]})}function rf(){return(0,en.c4)(),(0,a.jsx)(es,{children:(0,a.jsx)(rb,{})})}function rb(){let e=ea(),t=(0,i.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot),s=t?e.getActiveStore():null;return((0,i.useEffect)(()=>{let e=e=>{if(e.persisted)return;let t=(0,en.c4)(),s=t?`/api/shutdown?_token=${t}`:"/api/shutdown";navigator.sendBeacon(s,"")};return window.addEventListener("pagehide",e),()=>{window.removeEventListener("pagehide",e)}},[]),t&&s)?(0,a.jsx)(J.jg,{store:s,children:(0,a.jsx)(tf,{children:(0,a.jsx)(rg,{})})}):(0,a.jsx)(aF,{})}},91337:(e,t,s)=>{s.d(t,{cn:()=>n});var a=s(29722),r=s(622);function n(...e){return(0,r.QP)((0,a.$)(e))}},91459:(e,t,s)=>{s.d(t,{Bc:()=>i,ZI:()=>d,k$:()=>l,m_:()=>o});var a=s(95155);s(12115);var r=s(45828),n=s(91337);function i({delayDuration:e=0,...t}){return(0,a.jsx)(r.Kq,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function o({...e}){return(0,a.jsx)(i,{children:(0,a.jsx)(r.bL,{"data-slot":"tooltip",...e})})}function l({...e}){return(0,a.jsx)(r.l9,{"data-slot":"tooltip-trigger",...e})}function d({className:e,sideOffset:t=0,children:s,...i}){return(0,a.jsx)(r.ZL,{children:(0,a.jsxs)(r.UC,{"data-slot":"tooltip-content",sideOffset:t,className:(0,n.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...i,children:[s,(0,a.jsx)(r.i3,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}},93591:(e,t,s)=>{s.d(t,{L:()=>a});function a(e){let t,{phase:s,autoActive:a,autoPaused:r,onboardingLocked:n,commandInFlight:i,bootStatus:o,hasMilestones:l,projectDetectionKind:d}=e;if(d&&"active-gsd"!==d&&"empty-gsd"!==d)return{primary:null,secondaries:[],disabled:!0,disabledReason:"Project setup pending",isNewMilestone:!1};let c=!1;null!==i?(c=!0,t="Command in progress"):"ready"!==o?(c=!0,t="Workspace not ready"):n&&(c=!0,t="Setup required");let u=null,m=[],h=!1;return a&&!r?u={label:"Stop Auto",command:"/gsd stop",variant:"destructive"}:r?u={label:"Resume Auto",command:"/gsd auto",variant:"default"}:("complete"===s?(u={label:"New Milestone",command:"/gsd",variant:"default"},h=!0):"planning"===s?u={label:"Plan",command:"/gsd",variant:"default"}:"executing"===s||"summarizing"===s?u={label:"Start Auto",command:"/gsd auto",variant:"default"}:"pre-planning"!==s||l?"blocked"===s?(u={label:"Blocked",command:"/gsd",variant:"default"},c=!0,t="Project is blocked — check blockers"):u="paused"===s?{label:"Resume",command:"/gsd auto",variant:"default"}:"validating-milestone"===s?{label:"Validate",command:"/gsd",variant:"default"}:"completing-milestone"===s?{label:"Complete Milestone",command:"/gsd",variant:"default"}:"needs-discussion"===s?{label:"Discuss",command:"/gsd",variant:"default"}:"replanning-slice"===s?{label:"Replan",command:"/gsd",variant:"default"}:{label:"Continue",command:"/gsd",variant:"default"}:u={label:"Initialize Project",command:"/gsd",variant:"default"},"/gsd next"===u.command||h||m.push({label:"Step",command:"/gsd next"})),{primary:u,secondaries:m,disabled:c,disabledReason:t,isNewMilestone:h}}},96062:(e,t,s)=>{s.d(t,{E:()=>o,d:()=>l});let a={background:"#18181e",foreground:"#e4e4e7",cursor:"#e4e4e7",cursorAccent:"#18181e",selectionBackground:"#2a2f3f",selectionForeground:"#e4e4e7",black:"#1e1e24",red:"#cc6666",green:"#b5bd68",yellow:"#e6b800",blue:"#5f87ff",magenta:"#9575cd",cyan:"#00d7ff",white:"#e4e4e7",brightBlack:"#666666",brightRed:"#e07b7b",brightGreen:"#c3cf79",brightYellow:"#f0c95a",brightBlue:"#81a2ff",brightMagenta:"#b294bb",brightCyan:"#53e5ff",brightWhite:"#fafafa"},r={background:"#05070f",foreground:"#e6edf3",cursor:"#e6edf3",cursorAccent:"#05070f",selectionBackground:"#1b2440",selectionForeground:"#e6edf3",black:"#111827",red:"#ff6b8a",green:"#34d399",yellow:"#ffd166",blue:"#4f8cff",magenta:"#d266ff",cyan:"#22d3ee",white:"#e6edf3",brightBlack:"#64748b",brightRed:"#ff8fab",brightGreen:"#4ade80",brightYellow:"#ffe08a",brightBlue:"#82b1ff",brightMagenta:"#e29bff",brightCyan:"#67e8f9",brightWhite:"#ffffff"},n={background:"#f5f5f5",foreground:"#18181b",cursor:"#18181b",cursorAccent:"#f5f5f5",selectionBackground:"#d4d4d8",selectionForeground:"#18181b",black:"#18181b",red:"#b91c1c",green:"#166534",yellow:"#854d0e",blue:"#1d4ed8",magenta:"#7e22ce",cyan:"#0f766e",white:"#52525b",brightBlack:"#71717a",brightRed:"#dc2626",brightGreen:"#15803d",brightYellow:"#713f12",brightBlue:"#2563eb",brightMagenta:"#9333ea",brightCyan:"#0f766e",brightWhite:"#27272a"},i={background:"#f8fafc",foreground:"#0f172a",cursor:"#0f172a",cursorAccent:"#f8fafc",selectionBackground:"#cbd5e1",selectionForeground:"#0f172a",black:"#0f172a",red:"#be123c",green:"#166534",yellow:"#92400e",blue:"#1d4ed8",magenta:"#7e22ce",cyan:"#0f766e",white:"#334155",brightBlack:"#475569",brightRed:"#e11d48",brightGreen:"#15803d",brightYellow:"#854d0e",brightBlue:"#2563eb",brightMagenta:"#9333ea",brightCyan:"#0e7490",brightWhite:"#1e293b"};function o(e,t="classic"){return"vivid"===t?e?r:i:e?a:n}function l(e,t,s="classic"){return{cursorBlink:!0,cursorStyle:"bar",fontSize:t??13,fontFamily:"'SF Mono', 'Cascadia Code', 'Fira Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.35,letterSpacing:0,theme:o(e,s),allowProposedApi:!0,scrollback:1e4,convertEol:!1}}},98234:(e,t,s)=>{s.d(t,{jg:()=>eh,Hu:()=>eu,fL:()=>ec,Sf:()=>ef,BD:()=>M,a3:()=>L,_y:()=>D,E3:()=>B,U4:()=>q,Ct:()=>U,CL:()=>eo,Gr:()=>ei,iT:()=>z,$9:()=>$,_0:()=>O,tM:()=>X,QC:()=>Z,nf:()=>F,_l:()=>eg,gF:()=>ep});var a=s(95155),r=s(12115);let n=new Map([{name:"settings",description:"Open settings menu"},{name:"model",description:"Select model (opens selector UI)"},{name:"scoped-models",description:"Enable/disable models for Ctrl+P cycling"},{name:"export",description:"Export session to HTML file"},{name:"share",description:"Share session as a secret GitHub gist"},{name:"copy",description:"Copy last agent message to clipboard"},{name:"name",description:"Set session display name"},{name:"session",description:"Show session info and stats"},{name:"changelog",description:"Show changelog entries"},{name:"hotkeys",description:"Show all keyboard shortcuts"},{name:"fork",description:"Create a new fork from a previous message"},{name:"tree",description:"Navigate session tree (switch branches)"},{name:"provider",description:"Manage provider configuration"},{name:"login",description:"Login with OAuth provider"},{name:"logout",description:"Logout from OAuth provider"},{name:"new",description:"Start a new session"},{name:"compact",description:"Manually compact the session context"},{name:"resume",description:"Resume a different session"},{name:"reload",description:"Reload extensions, skills, prompts, and themes"},{name:"thinking",description:"Set thinking level (off/minimal/low/medium/high/xhigh)"},{name:"edit-mode",description:"Toggle edit mode (standard/hashline)"},{name:"terminal",description:"Run a shell command directly (e.g. /terminal ping -c3 1.1.1.1)"},{name:"quit",description:"Quit pi"}].map(e=>[e.name,e.description])),i=new Set(n.keys()),o=new Map([["settings","settings"],["model","model"],["thinking","thinking"],["git","git"],["resume","resume"],["name","name"],["fork","fork"],["compact","compact"],["login","login"],["logout","logout"],["session","session"],["export","export"]]),l=new Map([["status","gsd-status"],["visualize","gsd-visualize"],["forensics","gsd-forensics"],["doctor","gsd-doctor"],["skill-health","gsd-skill-health"],["knowledge","gsd-knowledge"],["capture","gsd-capture"],["triage","gsd-triage"],["quick","gsd-quick"],["history","gsd-history"],["undo","gsd-undo"],["inspect","gsd-inspect"],["model","model"],["prefs","gsd-prefs"],["config","gsd-config"],["hooks","gsd-hooks"],["mode","gsd-mode"],["steer","gsd-steer"],["export","gsd-export"],["cleanup","gsd-cleanup"],["queue","gsd-queue"]]),d=new Set(["auto","next","stop","pause","skip","discuss","run-hook","migrate","remote"]),c=`Available /gsd subcommands:
3
+
4
+ Workflow: next \xb7 auto \xb7 stop \xb7 pause \xb7 skip \xb7 queue \xb7 quick \xb7 capture \xb7 triage
5
+ Diagnostics: status \xb7 visualize \xb7 forensics \xb7 doctor \xb7 skill-health \xb7 inspect
6
+ Context: knowledge \xb7 history \xb7 undo \xb7 discuss
7
+ Settings: model \xb7 prefs \xb7 config \xb7 hooks \xb7 mode \xb7 steer
8
+ Advanced: export \xb7 cleanup \xb7 run-hook \xb7 migrate \xb7 remote
9
+
10
+ Type /gsd <subcommand> to run. Use /gsd help for this message.`;function u(e){return e.isStreaming?"follow_up":"prompt"}function m(e,t={}){let s=e.trim(),a=function(e){if(!e.startsWith("/"))return null;let t=e.slice(1).trim();if(!t)return null;let s=t.search(/\s/);return -1===s?{name:t,args:""}:{name:t.slice(0,s),args:t.slice(s+1).trim()}}(s);if("/clear"===s)return{kind:"local",input:s,commandName:"clear",action:"clear_terminal"};if("/refresh"===s)return{kind:"local",input:s,commandName:"refresh",action:"refresh_workspace"};if("/state"===s)return{kind:"rpc",input:s,commandName:"state",command:{type:"get_state"}};if("/new-session"===s)return{kind:"rpc",input:s,commandName:"new",command:{type:"new_session"}};if(!a)return{kind:"prompt",input:s,slashCommandName:null,command:{type:u(t),message:s}};if("new"===a.name)return{kind:"rpc",input:s,commandName:"new",command:{type:"new_session"}};if("gsd"===a.name)return function(e,t,s){let a=t.trim(),r=a.search(/\s/),n=-1===r?a:a.slice(0,r),i=-1===r?"":a.slice(r+1).trim();if(!n)return{kind:"prompt",input:e,slashCommandName:"gsd",command:{type:u(s),message:e}};if("help"===n)return{kind:"local",input:e,commandName:"gsd",action:"gsd_help"};if("visualize"===n)return{kind:"view-navigate",input:e,commandName:"gsd",view:"visualize"};let o=l.get(n);return o?{kind:"surface",input:e,commandName:"gsd",surface:o,args:i}:(d.has(n),{kind:"prompt",input:e,slashCommandName:"gsd",command:{type:u(s),message:e}})}(s,a.args,t);let r=o.get(a.name);if(r)return{kind:"surface",input:s,commandName:a.name,surface:r,args:a.args};if(i.has(a.name)){var c,h;let e;return h=c=a.name,e=n.get(h)??"Browser handling is reserved for this built-in command.",{kind:"reject",input:s,commandName:c,reason:`/${c} is a built-in pi command (${e}) that is not available in the browser yet.`,guidance:"It was blocked instead of falling through to the model."}}return{kind:"prompt",input:s,slashCommandName:a.name,command:{type:u(t),message:s}}}function h(e){switch(e.kind){case"surface":return{type:"system",message:`/${e.commandName} is reserved for browser-native handling and was not sent to the model.`};case"reject":return{type:"error",message:`${e.reason} ${e.guidance}`.trim()};default:return null}}var x=s(22112),p=s(35082);let g=new Set(["ls","ll","la","pwd","cd","dir","cat","head","tail","wc","file","which","whoami","echo","date","tree","find","grep","rg","clear","env","df","du","uname","hostname","mkdir","rm","cp","mv","touch","chmod","less","more","sort","uniq","sed","awk","curl","wget","tar","zip","unzip","git","docker","npm","npx","yarn","pnpm","node","python","python3","pip","pip3","make","cargo","go","ruby","brew"]);function f(e){let t=e.trimStart(),s=t.search(/\s/);return(-1===s?t:t.slice(0,s)).toLowerCase()}let b=[{id:"shell-command-prefix",maxShows:2,evaluate(e){let t;if(!(!((t=e.input.trimStart()).startsWith("!")||t.startsWith("/")||t.includes("\n")||t.length>120)&&g.has(f(t))))return null;let s=f(e.input);return`Tip: "${s}" looks like a shell command. Prefix with ! to run locally, or !! to run without using tokens.`}},{id:"large-paste",maxShows:2,evaluate:e=>e.input.length<2e3||e.input.trimStart().startsWith("/")||e.input.trimStart().startsWith("!")?null:"Tip: Large inputs consume many tokens. Consider saving to a file and asking the agent to read it."},{id:"thinking-level-high",maxShows:1,evaluate(e){let t=e.thinkingLevel?.toLowerCase();if("high"!==t&&"xhigh"!==t)return null;let s=e.input.trim();return s.length>80||s.includes("\n")||s.startsWith("/")||s.startsWith("!")?null:`Tip: Thinking is set to ${t}. Use Ctrl+T to lower it for simple questions — saves tokens.`}},{id:"double-bang-reminder",maxShows:2,evaluate(e){if(e.bashIncludedCount<3)return null;let t=e.input.trimStart();return!t.startsWith("!")||t.startsWith("!!")?null:"Tip: Use !! instead of ! to keep command output out of agent context and save tokens."}},{id:"compaction-nudge",maxShows:1,evaluate(e){if(void 0===e.contextPercent||e.contextPercent<70)return null;let t=e.input.trimStart();return t.startsWith("/")||t.startsWith("!")?null:"Tip: Context is getting full. Use /compact to summarize the conversation and free up space."}}];class v{recordBashIncluded(){this._bashIncludedCount++}get bashIncludedCount(){return this._bashIncludedCount}evaluate(e){let t={...e,bashIncludedCount:this._bashIncludedCount};for(let e of b){let s=this.showCounts.get(e.id)??0;if(s>=e.maxShows)continue;let a=e.evaluate(t);if(a)return this.showCounts.set(e.id,s+1),a}return null}reset(){this.showCounts.clear(),this._bashIncludedCount=0}constructor(){this.showCounts=new Map,this._bashIncludedCount=0}}let j=new Set(["settings","model","thinking","git","resume","name","fork","compact","login","logout","session","export","gsd-status","gsd-visualize","gsd-forensics","gsd-doctor","gsd-skill-health","gsd-knowledge","gsd-capture","gsd-triage","gsd-quick","gsd-history","gsd-undo","gsd-inspect","gsd-prefs","gsd-config","gsd-hooks","gsd-mode","gsd-steer","gsd-export","gsd-cleanup","gsd-queue"]);function y(e,t){return{id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,type:e,content:t,timestamp:function(e=new Date){return e.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}()}}function w(e,t){return[...e,t].slice(-250)}function N(e){return!!(e?.activeSessionId||e?.sessionState?.sessionId)}function S(e){return e instanceof Error?e.message:String(e)}function k(e){if("failed"===e.phase)return{type:"error",message:`Bridge failed${e.lastError?.message?` — ${e.lastError.message}`:""}`};if("starting"===e.phase)return{type:"system",message:"Bridge starting for the current project…"};if("ready"===e.phase){let t=O(e);return{type:"success",message:t?`Live bridge ready — attached to ${t}`:"Live bridge ready — session attachment pending"}}return{type:"system",message:"Bridge idle"}}let C=new Set(["running","awaiting_browser_auth","awaiting_input"]),A=new Set(["succeeded","failed","cancelled"]);function R(e,t){return e.required.providers.find(e=>e.id===t)?.label??t}function _(e,t){if(!e)return null;let s={...e,bridge:t};return{...s,resumableSessions:Y(s.resumableSessions,s)}}function T(e,t){return e?.bridge.sessionState?_(e,{...e.bridge,sessionState:{...e.bridge.sessionState,...t}}):e}function P(e,t){return e?{...e,onboarding:t,onboardingNeeded:t.locked}:null}function E(e){return"failed"===e.bridgeAuthRefresh.phase?{type:"error",message:e.bridgeAuthRefresh.error?`Bridge auth refresh failed — ${e.bridgeAuthRefresh.error}`:"Bridge auth refresh failed after setup"}:"pending"===e.bridgeAuthRefresh.phase?{type:"system",message:"Credentials saved — refreshing bridge auth before the workspace unlocks…"}:e.lastValidation?.status==="failed"?{type:"error",message:`Credential validation failed — ${e.lastValidation.message}`}:e.locked||e.lastValidation?.status!=="succeeded"?e.activeFlow?.status==="awaiting_browser_auth"?{type:"system",message:`${e.activeFlow.providerLabel} sign-in is waiting for browser confirmation`}:e.activeFlow?.status==="awaiting_input"?{type:"system",message:`${e.activeFlow.providerLabel} sign-in needs one more input step`}:e.activeFlow?.status==="cancelled"?{type:"system",message:`${e.activeFlow.providerLabel} sign-in was cancelled`}:e.activeFlow?.status==="failed"?{type:"error",message:e.activeFlow.error?`${e.activeFlow.providerLabel} sign-in failed — ${e.activeFlow.error}`:`${e.activeFlow.providerLabel} sign-in failed`}:"required_setup"===e.lockReason?{type:"system",message:"Onboarding is still required before model-backed prompts will run"}:null:{type:"success",message:`${R(e,e.lastValidation.providerId)} is ready — workspace unlocked`}}function I(e){let t=[y("system",`GSD web workspace attached to ${e.project.cwd}`),y("system",`Workspace scope: ${q(e.workspace)}`)],s=k(e.bridge);t.push(y(s.type,s.message)),e.bridge.lastError&&t.push(y("error",`Bridge error: ${e.bridge.lastError.message}`));let a=E(e.onboarding);return a&&t.push(y(a.type,a.message)),t}function F(e,t=3){if(!e)return"—";let s=e.split(/[\\/]/).filter(Boolean);if(s.length<=t)return e.startsWith("/")?`/${s.join("/")}`:s.join("/");let a=s.slice(-t).join("/");return`…/${a}`}function $(e){return e?e.split(/[\\/]/).filter(Boolean).at(-1)||e:"Current project"}function L(e){if(!e||e<1e3)return"0m";let t=Math.floor(e/6e4),s=Math.floor(t/60),a=t%60;return s>0?`${s}h ${a}m`:`${a}m`}function D(e){return!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(Math.round(e))}function M(e){return!Number.isFinite(e)||e<=0?"$0.00":`$${e.toFixed(2)}`}function q(e){if(!e)return"Project scope pending";let t=[e.active.milestoneId,e.active.sliceId,e.active.taskId].filter(Boolean).join("/");return t?`${t} — ${e.active.phase}`:`project — ${e.active.phase}`}function B(e){if(!e?.active.milestoneId||!e.active.sliceId)return null;let t=e.milestones.find(t=>t.id===e.active.milestoneId),s=t?.slices.find(t=>t.id===e.active.sliceId);return s?.branch??null}function U(e){if(!e?.active.milestoneId||!e.active.sliceId)return null;let t=e.milestones.find(t=>t.id===e.active.milestoneId);return t?.slices.find(t=>t.id===e.active.sliceId)??null}function O(e){if(!e?.sessionState&&!e?.activeSessionId)return null;let t=e.sessionState?.sessionName?.trim();return t||(e.activeSessionId?`session ${e.activeSessionId}`:e.sessionState?.sessionId??null)}function z(e){let t=e?.sessionState?.model;return t&&(t.id||t.providerId||t.provider)||"model pending"}function G(e){let t=e?.sessionState?.model;return t?{provider:t.provider??t.providerId,modelId:t.id}:null}function W(e){if(!e)return null;if(e.required.satisfiedBy?.providerId)return e.required.satisfiedBy.providerId;let t=e.required.providers.find(e=>!e.configured&&e.recommended);if(t)return t.id;let s=e.required.providers.find(e=>!e.configured);return s?s.id:e.required.providers[0]?.id??null}function K(e,t){return{...e,pending:!1,loaded:!1,error:t}}function V(e,t){return{...e,phase:"error",pending:!1,stale:!0,error:t,lastFailureAt:new Date().toISOString()}}function H(e){return e?.bridge.activeSessionFile??e?.bridge.sessionState?.sessionFile??null}function Y(e,t){let s=H(t),a=t?.bridge.sessionState?.sessionName?.trim()||void 0;return e.map(e=>{let t=s?e.path===s:e.isActive;return{...e,isActive:t,...t&&a?{name:a}:{}}})}function J(e,t){return{...e,activeSessionPath:H(t),sessions:Y(e.sessions,t)}}function Q(e,t,s){return{...e,activeSessionPath:s.isActive?t:e.activeSessionPath,sessions:e.sessions.map(e=>e.path===t?{...e,...s}:s.isActive?{...e,isActive:!1}:e)}}function Z(e){let t=e.boot?.onboarding;return t?.bridgeAuthRefresh.phase==="failed"&&t.bridgeAuthRefresh.error?t.bridgeAuthRefresh.error:t?.lastValidation?.status==="failed"?t.lastValidation.message:e.lastBridgeError?.message??e.lastClientError}function X(e){if("loading"===e.bootStatus)return{label:"Loading workspace",tone:"info"};if("error"===e.bootStatus)return{label:"Boot failed",tone:"danger"};let t=function(e){if("loading"===e.bootStatus||!e.boot)return{phase:"loading",label:"Loading setup state",detail:"Resolving the current project, bridge, and onboarding contract…",tone:"info"};let t=e.boot.onboarding;return t.activeFlow?.status==="awaiting_browser_auth"?{phase:"awaiting_browser_auth",label:"Continue sign-in in your browser",detail:`${t.activeFlow.providerLabel} is waiting for browser confirmation before the workspace can unlock.`,tone:"info"}:t.activeFlow?.status==="awaiting_input"?{phase:"awaiting_input",label:"One more sign-in step is required",detail:t.activeFlow.prompt?.message??`${t.activeFlow.providerLabel} needs one more input step.`,tone:"info"}:"bridge_refresh_pending"===t.lockReason?{phase:"refreshing",label:"Refreshing bridge auth",detail:"Credentials validated. The live bridge is restarting onto the new auth view before the shell unlocks.",tone:"info"}:"bridge_refresh_failed"===t.lockReason?{phase:"failure",label:"Setup completed, but the shell is still locked",detail:t.bridgeAuthRefresh.error??"The bridge could not reload auth after setup.",tone:"danger"}:t.lastValidation?.status==="failed"?{phase:"failure",label:"Credential validation failed",detail:t.lastValidation.message,tone:"danger"}:"saving_api_key"===e.onboardingRequestState?{phase:"validating",label:"Validating credentials",detail:"Checking the provider key and saving it only if validation succeeds.",tone:"info"}:"starting_provider_flow"===e.onboardingRequestState||"submitting_provider_flow_input"===e.onboardingRequestState?{phase:"running_flow",label:"Advancing provider sign-in",detail:"The onboarding flow is running and will update here as soon as the next step is ready.",tone:"info"}:t.locked?{phase:"locked",label:"Required setup needed",detail:"Choose a required provider, validate it here, and the workspace will unlock without restarting the host.",tone:"warning"}:{phase:"ready",label:"Workspace unlocked",detail:t.lastValidation?.status==="succeeded"?`${R(t,t.lastValidation.providerId)} is ready and the workspace is live.`:"Required setup is satisfied and the shell is ready for live commands.",tone:"success"}}(e);if("ready"!==t.phase)return{label:t.label,tone:t.tone};if(e.boot?.bridge.phase==="failed")return{label:"Bridge failed",tone:"danger"};switch(e.connectionState){case"connected":return{label:"Bridge connected",tone:"success"};case"connecting":return{label:"Connecting stream",tone:"info"};case"reconnecting":return{label:"Reconnecting stream",tone:"warning"};case"disconnected":return{label:"Stream disconnected",tone:"warning"};case"error":return{label:"Stream error",tone:"danger"};default:return{label:"Workspace idle",tone:"muted"}}}function ee(){return{status:"idle",stale:!1,reloadCount:0,lastRequestedAt:null,lastSuccessAt:null,lastFailureAt:null,lastFailure:null,invalidatedAt:null,invalidationReason:null,invalidationSource:null}}function et(){return{visible:!1,tone:"healthy",label:"Recovery summary pending",detail:"Waiting for the first live workspace snapshot.",validationCount:0,retryInProgress:!1,retryAttempt:0,autoRetryEnabled:!1,isCompacting:!1,currentUnitId:null,freshness:"idle",entrypointLabel:"Inspect recovery",lastError:null}}function es(e){return{...e,status:"refreshing",lastRequestedAt:new Date().toISOString(),lastFailure:null}}function ea(e,t,s){return{...e,status:e.lastSuccessAt?"stale":e.status,stale:!0,invalidatedAt:new Date().toISOString(),invalidationReason:t,invalidationSource:s}}function er(e){return{...e,status:"fresh",stale:!1,reloadCount:e.reloadCount+1,lastSuccessAt:new Date().toISOString(),lastFailureAt:null,lastFailure:null}}function en(e,t){return{...e,status:"error",stale:!0,lastFailureAt:new Date().toISOString(),lastFailure:t}}function ei(e){return e.live.workspace??e.boot?.workspace??null}function eo(e){return e.live.auto??e.boot?.auto??null}function el(e){return e.live.resumableSessions.length>0?e.live.resumableSessions:e.boot?.resumableSessions??[]}function ed(e){let t=e.boot?.bridge??null,s=ei(e),a=eo(e),r=s?.validationIssues.length??0,n=!!t?.sessionState?.retryInProgress,i=t?.sessionState?.retryAttempt??0,o=!!t?.sessionState?.autoRetryEnabled,l=!!t?.sessionState?.isCompacting,d=e.live.freshness.recovery,c="error"===d.status?"error":d.stale?"stale":d.lastSuccessAt?"fresh":"idle",u=t?.lastError?{message:t.lastError.message,phase:t.lastError.phase,at:t.lastError.at}:null,m="healthy",h="Recovery summary healthy",x="No retry, compaction, bridge, or validation recovery signals are active.";return s||a||t?(u||"error"===c?(m="danger",h="Recovery attention required",x=u?.message??d.lastFailure??"A targeted live refresh failed."):r>0?(m="warning",h=`Recovery summary: ${r} validation issue${1===r?"":"s"}`,x="Workspace validation surfaced issues that may need doctor or audit follow-up."):n?(m="warning",h=`Recovery retry active (attempt ${Math.max(1,i)})`,x="The live bridge is retrying the current unit after a transient failure."):l?(m="warning",h="Recovery compaction active",x="The live session is compacting context before continuing."):"stale"===c&&(m="warning",h="Recovery summary stale",x=d.invalidationReason?`Waiting for a targeted refresh after ${d.invalidationReason.replaceAll("_"," ")}.`:"Waiting for the next targeted refresh."),{visible:!0,tone:m,label:h,detail:x,validationCount:r,retryInProgress:n,retryAttempt:i,autoRetryEnabled:o,isCompacting:l,currentUnitId:a?.currentUnit?.id??null,freshness:c,entrypointLabel:"danger"===m||"warning"===m?"Inspect recovery":"Review recovery",lastError:u}):et()}function ec(e,t){if(!t)return e;let s=new URL(e,"http://localhost");return s.searchParams.set("project",t),s.pathname+s.search}class eu{constructor(e){this.projectCwd=e,this.state={bootStatus:"idle",connectionState:"idle",boot:null,live:{auto:null,workspace:null,resumableSessions:[],recoverySummary:et(),freshness:{auto:ee(),workspace:ee(),recovery:ee(),resumableSessions:ee(),gitSummary:ee(),sessionBrowser:ee(),sessionStats:ee()},softBootRefreshCount:0,targetedRefreshCount:0},terminalLines:[y("system","Preparing the live GSD workspace…")],lastClientError:null,lastBridgeError:null,sessionAttached:!1,lastEventType:null,commandInFlight:null,lastSlashCommandOutcome:null,commandSurface:(0,x.iE)(),onboardingRequestState:"idle",onboardingRequestProviderId:null,pendingUiRequests:[],streamingAssistantText:"",streamingThinkingText:"",liveTranscript:[],liveThinkingTranscript:[],completedToolExecutions:[],activeToolExecution:null,currentTurnSegments:[],completedTurnSegments:[],chatUserMessages:[],statusTexts:{},widgetContents:{},titleOverride:null,editorTextBuffer:null},this.listeners=new Set,this.contextualTips=new v,this.bootPromise=null,this.eventSource=null,this.onboardingPollTimer=null,this.started=!1,this.disposed=!1,this.lastBridgeDigest=null,this.lastStreamState="idle",this.commandTimeoutTimer=null,this.lastBootRefreshAt=0,this.visibilityHandler=null,this.subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),this.getSnapshot=()=>this.state,this.start=()=>{this.started||this.disposed||(this.started=!0,"u">typeof document&&(this.visibilityHandler=()=>{"visible"===document.visibilityState&&Date.now()-this.lastBootRefreshAt>=3e4&&this.refreshBoot({soft:!0})},document.addEventListener("visibilitychange",this.visibilityHandler)),this.refreshBoot())},this.dispose=()=>{this.disposed=!0,this.started=!1,this.stopOnboardingPoller(),this.closeEventStream(),this.clearCommandTimeout(),this.visibilityHandler&&"u">typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)},this.disconnectSSE=()=>{this.closeEventStream()},this.reconnectSSE=()=>{this.disposed||(this.ensureEventStream(),this.refreshBoot({soft:!0}))},this.clearTerminalLines=()=>{let e=this.state.boot?I(this.state.boot):[y("system","Terminal cleared")];this.patchState({terminalLines:e})},this.consumeEditorTextBuffer=()=>{let e=this.state.editorTextBuffer;return null!==e&&this.patchState({editorTextBuffer:null}),e},this.openCommandSurface=(e,t={})=>{let s=el(this.state);this.patchState({commandSurface:(0,x.Q8)(this.state.commandSurface,{surface:e,source:t.source??"surface",args:t.args??"",selectedTarget:t.selectedTarget,onboardingLocked:this.state.boot?.onboarding.locked,currentModel:G(this.state.boot?.bridge),currentThinkingLevel:this.state.boot?.bridge.sessionState?.thinkingLevel??null,preferredProviderId:W(this.state.boot?.onboarding),resumableSessions:s.map(e=>({id:e.id,path:e.path,name:e.name,isActive:e.isActive})),currentSessionPath:this.state.boot?.bridge.activeSessionFile??this.state.boot?.bridge.sessionState?.sessionFile??null,currentSessionName:this.state.boot?.bridge.sessionState?.sessionName??null,projectCwd:this.state.boot?.project.cwd??null,projectSessionsDir:this.state.boot?.project.sessionsDir??null})})},this.closeCommandSurface=()=>{this.patchState({commandSurface:(0,x.Qx)(this.state.commandSurface)})},this.setCommandSurfaceSection=e=>{let t=el(this.state);this.patchState({commandSurface:(0,x.c0)(this.state.commandSurface,e,{onboardingLocked:this.state.boot?.onboarding.locked,currentModel:G(this.state.boot?.bridge),currentThinkingLevel:this.state.boot?.bridge.sessionState?.thinkingLevel??null,preferredProviderId:W(this.state.boot?.onboarding),resumableSessions:t.map(e=>({id:e.id,path:e.path,name:e.name,isActive:e.isActive})),currentSessionPath:this.state.boot?.bridge.activeSessionFile??this.state.boot?.bridge.sessionState?.sessionFile??null,currentSessionName:this.state.boot?.bridge.sessionState?.sessionName??null,projectCwd:this.state.boot?.project.cwd??null,projectSessionsDir:this.state.boot?.project.sessionsDir??null})})},this.selectCommandSurfaceTarget=e=>{this.patchState({commandSurface:(0,x.nU)(this.state.commandSurface,e)})},this.loadGitSummary=async()=>{let e={...this.state.commandSurface.gitSummary,pending:!0,error:null},t={...this.state.live,freshness:{...this.state.live.freshness,gitSummary:es(this.state.live.freshness.gitSummary)}};this.patchState({live:{...t,recoverySummary:ed({boot:this.state.boot,live:t})},commandSurface:(0,x.Yc)({...this.state.commandSurface,gitSummary:e},"load_git_summary")});try{let t=await (0,p.tm)(this.buildUrl("/api/git"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),s=await t.json().catch(()=>null),a=s&&"object"==typeof s&&("repo"===s.kind||"not_repo"===s.kind)&&s.project&&"object"==typeof s.project&&"current_project"===s.project.scope&&"string"==typeof s.project.cwd&&("not_repo"===s.kind?"string"==typeof s.message:"string"==typeof s.project?.repoRoot&&"boolean"==typeof s.hasChanges&&"boolean"==typeof s.hasConflicts&&!!s.counts&&"object"==typeof s.counts&&!!Array.isArray(s.changedFiles)&&"number"==typeof s.truncatedFileCount&&"number"==typeof s.counts.changed&&"number"==typeof s.counts.staged&&"number"==typeof s.counts.dirty&&"number"==typeof s.counts.untracked&&"number"==typeof s.counts.conflicts)?s:null;if(!t.ok||!a){let a=s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:`Current-project git summary failed with ${t.status}`,r=K(e,a),n={...this.state.live,freshness:{...this.state.live.freshness,gitSummary:en(this.state.live.freshness.gitSummary,a)}};return this.patchState({live:{...n,recoverySummary:ed({boot:this.state.boot,live:n})},commandSurface:(0,x.yC)({...this.state.commandSurface,gitSummary:r},{action:"load_git_summary",success:!1,message:a,gitSummary:r})}),null}let r={...this.state.live,freshness:{...this.state.live.freshness,gitSummary:er(this.state.live.freshness.gitSummary)}};return this.patchState({live:{...r,recoverySummary:ed({boot:this.state.boot,live:r})},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"load_git_summary",success:!0,message:"",gitSummary:{pending:!1,loaded:!0,result:a,error:null}})}),a}catch(r){let t=S(r),s=K(e,t),a={...this.state.live,freshness:{...this.state.live.freshness,gitSummary:en(this.state.live.freshness.gitSummary,t)}};return this.patchState({live:{...a,recoverySummary:ed({boot:this.state.boot,live:a})},commandSurface:(0,x.yC)({...this.state.commandSurface,gitSummary:s},{action:"load_git_summary",success:!1,message:t,gitSummary:s})}),null}},this.loadRecoveryDiagnostics=async()=>{var e;let t={...e=this.state.commandSurface.recovery,pending:!0,error:null,phase:e.loaded?e.phase:"loading"},s={...this.state.live,freshness:{...this.state.live.freshness,recovery:es(this.state.live.freshness.recovery)}};this.patchState({live:{...s,recoverySummary:ed({boot:this.state.boot,live:s})},commandSurface:(0,x.Yc)({...this.state.commandSurface,recovery:t},"load_recovery_diagnostics")});try{let e=await (0,p.tm)(this.buildUrl("/api/recovery"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),s=await e.json().catch(()=>null),a=s&&"object"==typeof s&&("ready"===s.status||"unavailable"===s.status)&&"string"==typeof s.loadedAt&&s.project&&"string"==typeof s.project.cwd&&s.summary&&"string"==typeof s.summary.label&&"string"==typeof s.summary.detail&&s.bridge&&"string"==typeof s.bridge.phase&&s.validation&&"number"==typeof s.validation.total&&s.doctor&&"number"==typeof s.doctor.total&&s.interruptedRun&&"boolean"==typeof s.interruptedRun.available&&s.actions&&Array.isArray(s.actions.browser)&&Array.isArray(s.actions.commands)?s:null;if(!e.ok||!a){let a=s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:`Recovery diagnostics failed with ${e.status}`,r=V(t,a),n={...this.state.live,freshness:{...this.state.live.freshness,recovery:en(this.state.live.freshness.recovery,a)}};return this.patchState({lastClientError:a,live:{...n,recoverySummary:ed({boot:this.state.boot,live:n})},commandSurface:(0,x.yC)({...this.state.commandSurface,recovery:r},{action:"load_recovery_diagnostics",success:!1,message:a,recovery:r})}),null}let r={...{phase:"ready"===a.status?"ready":"unavailable",pending:!1,loaded:!0,stale:!1,diagnostics:a,error:null,lastLoadedAt:a.loadedAt,lastInvalidatedAt:null,lastFailureAt:null},lastInvalidatedAt:this.state.commandSurface.recovery.lastInvalidatedAt},n={...this.state.live,freshness:{...this.state.live.freshness,recovery:er(this.state.live.freshness.recovery)}};return this.patchState({lastClientError:null,live:{...n,recoverySummary:ed({boot:this.state.boot,live:n})},commandSurface:(0,x.yC)({...this.state.commandSurface,recovery:r},{action:"load_recovery_diagnostics",success:!0,message:"ready"===a.status?"Recovery diagnostics refreshed":"Recovery diagnostics are currently unavailable",recovery:r})}),a}catch(r){let e=S(r),s=V(t,e),a={...this.state.live,freshness:{...this.state.live.freshness,recovery:en(this.state.live.freshness.recovery,e)}};return this.patchState({lastClientError:e,live:{...a,recoverySummary:ed({boot:this.state.boot,live:a})},commandSurface:(0,x.yC)({...this.state.commandSurface,recovery:s},{action:"load_recovery_diagnostics",success:!1,message:e,recovery:s})}),null}},this.loadForensicsDiagnostics=async()=>{this.patchDiagnosticsPhaseState("forensics",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/forensics"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Forensics request failed with ${e.status}`;return this.patchDiagnosticsPhaseState("forensics",{phase:"error",error:s}),null}return this.patchDiagnosticsPhaseState("forensics",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchDiagnosticsPhaseState("forensics",{phase:"error",error:e}),null}},this.loadDoctorDiagnostics=async e=>{this.patchDoctorState({phase:"loading",error:null});try{let t=e?`/api/doctor?scope=${encodeURIComponent(e)}`:"/api/doctor",s=await (0,p.tm)(t,{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),a=await s.json().catch(()=>null);if(!s.ok||!a){let e=a?.error??`Doctor request failed with ${s.status}`;return this.patchDoctorState({phase:"error",error:e}),null}return this.patchDoctorState({phase:"loaded",data:a,lastLoadedAt:new Date().toISOString()}),a}catch(t){let e=S(t);return this.patchDoctorState({phase:"error",error:e}),null}},this.applyDoctorFixes=async e=>{this.patchDoctorState({fixPending:!0,lastFixError:null,lastFixResult:null});try{let t=await (0,p.tm)(this.buildUrl("/api/doctor"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e?{scope:e}:{})}),s=await t.json().catch(()=>null);if(!t.ok||!s){let e=s?.error??`Doctor fix request failed with ${t.status}`;return this.patchDoctorState({fixPending:!1,lastFixError:e}),null}return this.patchDoctorState({fixPending:!1,lastFixResult:s}),this.loadDoctorDiagnostics(e),s}catch(t){let e=S(t);return this.patchDoctorState({fixPending:!1,lastFixError:e}),null}},this.loadSkillHealthDiagnostics=async()=>{this.patchDiagnosticsPhaseState("skillHealth",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/skill-health"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Skill health request failed with ${e.status}`;return this.patchDiagnosticsPhaseState("skillHealth",{phase:"error",error:s}),null}return this.patchDiagnosticsPhaseState("skillHealth",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchDiagnosticsPhaseState("skillHealth",{phase:"error",error:e}),null}},this.loadKnowledgeData=async()=>{this.patchKnowledgeCapturesPhaseState("knowledge",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/knowledge"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Knowledge request failed with ${e.status}`;return this.patchKnowledgeCapturesPhaseState("knowledge",{phase:"error",error:s}),null}return this.patchKnowledgeCapturesPhaseState("knowledge",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchKnowledgeCapturesPhaseState("knowledge",{phase:"error",error:e}),null}},this.loadCapturesData=async()=>{this.patchKnowledgeCapturesPhaseState("captures",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/captures"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Captures request failed with ${e.status}`;return this.patchKnowledgeCapturesPhaseState("captures",{phase:"error",error:s}),null}return this.patchKnowledgeCapturesPhaseState("captures",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchKnowledgeCapturesPhaseState("captures",{phase:"error",error:e}),null}},this.loadSettingsData=async()=>{this.patchSettingsPhaseState({phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/settings-data"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Settings request failed with ${e.status}`;return this.patchSettingsPhaseState({phase:"error",error:s}),null}return this.patchSettingsPhaseState({phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchSettingsPhaseState({phase:"error",error:e}),null}},this.loadHistoryData=async()=>{this.patchRemainingCommandsPhaseState("history",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/history"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`History request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("history",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("history",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchRemainingCommandsPhaseState("history",{phase:"error",error:e}),null}},this.loadInspectData=async()=>{this.patchRemainingCommandsPhaseState("inspect",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/inspect"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Inspect request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("inspect",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("inspect",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchRemainingCommandsPhaseState("inspect",{phase:"error",error:e}),null}},this.loadHooksData=async()=>{this.patchRemainingCommandsPhaseState("hooks",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/hooks"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Hooks request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("hooks",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("hooks",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchRemainingCommandsPhaseState("hooks",{phase:"error",error:e}),null}},this.loadExportData=async e=>{this.patchRemainingCommandsPhaseState("exportData",{phase:"loading",error:null});try{let t=e?`/api/export-data?format=${encodeURIComponent(e)}`:"/api/export-data",s=await (0,p.tm)(t,{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),a=await s.json().catch(()=>null);if(!s.ok||!a){let e=a?.error??`Export request failed with ${s.status}`;return this.patchRemainingCommandsPhaseState("exportData",{phase:"error",error:e}),null}return this.patchRemainingCommandsPhaseState("exportData",{phase:"loaded",data:a,lastLoadedAt:new Date().toISOString()}),a}catch(t){let e=S(t);return this.patchRemainingCommandsPhaseState("exportData",{phase:"error",error:e}),null}},this.loadUndoInfo=async()=>{this.patchRemainingCommandsPhaseState("undo",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/undo"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Undo info request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("undo",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("undo",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchRemainingCommandsPhaseState("undo",{phase:"error",error:e}),null}},this.loadCleanupData=async()=>{this.patchRemainingCommandsPhaseState("cleanup",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/cleanup"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Cleanup data request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("cleanup",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("cleanup",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchRemainingCommandsPhaseState("cleanup",{phase:"error",error:e}),null}},this.loadSteerData=async()=>{this.patchRemainingCommandsPhaseState("steer",{phase:"loading",error:null});try{let e=await (0,p.tm)(this.buildUrl("/api/steer"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Steer data request failed with ${e.status}`;return this.patchRemainingCommandsPhaseState("steer",{phase:"error",error:s}),null}return this.patchRemainingCommandsPhaseState("steer",{phase:"loaded",data:t,lastLoadedAt:new Date().toISOString()}),t}catch(t){let e=S(t);return this.patchRemainingCommandsPhaseState("steer",{phase:"error",error:e}),null}},this.executeUndoAction=async()=>{try{let e=await (0,p.tm)(this.buildUrl("/api/undo"),{method:"POST",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t){let s=t?.error??`Undo action failed with ${e.status}`;return{success:!1,message:s}}return this.loadUndoInfo(),t}catch(e){return{success:!1,message:S(e)}}},this.executeCleanupAction=async(e,t)=>{try{let s=await (0,p.tm)(this.buildUrl("/api/cleanup"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({branches:e,snapshots:t})}),a=await s.json().catch(()=>null);if(!s.ok||!a){let e=a?.error??`Cleanup action failed with ${s.status}`;return{deletedBranches:0,prunedSnapshots:0,message:e}}return this.loadCleanupData(),a}catch(e){return{deletedBranches:0,prunedSnapshots:0,message:S(e)}}},this.resolveCaptureAction=async e=>{this.patchKnowledgeCapturesState({resolveRequest:{pending:!0,lastError:null,lastResult:null}});try{let t=await (0,p.tm)(this.buildUrl("/api/captures"),{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),s=await t.json().catch(()=>null);if(!t.ok||!s){let e=s?.error??`Capture resolve failed with ${t.status}`;return this.patchKnowledgeCapturesState({resolveRequest:{pending:!1,lastError:e,lastResult:null}}),null}return this.patchKnowledgeCapturesState({resolveRequest:{pending:!1,lastError:null,lastResult:s}}),this.loadCapturesData(),s}catch(t){let e=S(t);return this.patchKnowledgeCapturesState({resolveRequest:{pending:!1,lastError:e,lastResult:null}}),null}},this.updateSessionBrowserState=e=>{this.patchState({commandSurface:{...this.state.commandSurface,sessionBrowser:{...this.state.commandSurface.sessionBrowser,...e,error:null},lastError:null,lastResult:null}})},this.loadSessionBrowser=async(e={})=>{let t={...this.state.commandSurface.sessionBrowser,...e,error:null},s={...this.state.live,freshness:{...this.state.live.freshness,sessionBrowser:es(this.state.live.freshness.sessionBrowser)}};this.patchState({live:{...s,recoverySummary:ed({boot:this.state.boot,live:s})},commandSurface:(0,x.Yc)({...this.state.commandSurface,sessionBrowser:t},"load_session_browser")});let a=new URLSearchParams;t.query.trim()&&a.set("query",t.query.trim()),a.set("sortMode",t.sortMode),a.set("nameFilter",t.nameFilter);try{let e=await (0,p.tm)(this.buildUrl(`/api/session/browser?${a.toString()}`),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),s=await e.json().catch(()=>null),r=function(e){if(!e||"object"!=typeof e)return null;let t=e.project,s=e.query;if(!t||!s||!Array.isArray(e.sessions)||"current_project"!==t.scope||"string"!=typeof t.cwd||"string"!=typeof t.sessionsDir||"string"!=typeof s.query||"string"!=typeof s.sortMode||"string"!=typeof s.nameFilter)return null;let a=e.sessions.filter(e=>"string"==typeof e?.id&&"string"==typeof e?.path&&"string"==typeof e?.cwd&&"string"==typeof e?.createdAt&&"string"==typeof e?.modifiedAt&&"number"==typeof e?.messageCount&&"string"==typeof e?.firstMessage&&"boolean"==typeof e?.isActive&&"number"==typeof e?.depth&&"boolean"==typeof e?.isLastInThread&&Array.isArray(e?.ancestorHasNextSibling));return{scope:t.scope,projectCwd:t.cwd,projectSessionsDir:t.sessionsDir,activeSessionPath:"string"==typeof t.activeSessionPath?t.activeSessionPath:null,query:s.query,sortMode:s.sortMode,nameFilter:s.nameFilter,totalSessions:Number(e.totalSessions??a.length),returnedSessions:Number(e.returnedSessions??a.length),sessions:a,loaded:!0,error:null}}(s);if(!e.ok||!r){let a=s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:`Current-project session browser failed with ${e.status}`,r={...t,error:a},n={...this.state.live,freshness:{...this.state.live.freshness,sessionBrowser:en(this.state.live.freshness.sessionBrowser,a)}};return this.patchState({live:{...n,recoverySummary:ed({boot:this.state.boot,live:n})},commandSurface:(0,x.yC)({...this.state.commandSurface,sessionBrowser:r},{action:"load_session_browser",success:!1,message:a,sessionBrowser:r})}),null}let n=J(r,this.state.boot),i=this.state.commandSurface.selectedTarget,o=n.sessions.find(e=>!e.isActive)?.path??n.sessions[0]?.path,l=n.sessions.find(e=>e.path===n.activeSessionPath)??n.sessions[0],d=i;if(i?.kind==="resume"||"resume"===this.state.commandSurface.section){let e=i?.kind==="resume"&&i.sessionPath&&n.sessions.some(e=>e.path===i.sessionPath)?i.sessionPath:o;d={kind:"resume",sessionPath:e}}else if(i?.kind==="name"||"name"===this.state.commandSurface.section){let e=i?.kind==="name"&&i.sessionPath?n.sessions.find(e=>e.path===i.sessionPath)??l:l;d={kind:"name",sessionPath:e?.path,name:i?.kind==="name"&&i.sessionPath===e?.path?i.name:e?.name??""}}let c={...this.state.live,freshness:{...this.state.live.freshness,sessionBrowser:er(this.state.live.freshness.sessionBrowser)}};return this.patchState({live:{...c,recoverySummary:ed({boot:this.state.boot,live:c})},commandSurface:(0,x.yC)({...this.state.commandSurface,sessionBrowser:n},{action:"load_session_browser",success:!0,message:"",selectedTarget:d,sessionBrowser:n})}),n}catch(r){let e=S(r),s={...t,error:e},a={...this.state.live,freshness:{...this.state.live.freshness,sessionBrowser:en(this.state.live.freshness.sessionBrowser,e)}};return this.patchState({live:{...a,recoverySummary:ed({boot:this.state.boot,live:a})},commandSurface:(0,x.yC)({...this.state.commandSurface,sessionBrowser:s},{action:"load_session_browser",success:!1,message:e,sessionBrowser:s})}),null}},this.renameSessionFromSurface=async(e,t)=>{let s=this.state.commandSurface.selectedTarget,a=t??(s?.kind==="name"?s.name:""),r=a.trim(),n={kind:"name",sessionPath:e,name:a};if(!r)return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"rename_session",success:!1,message:"Session name cannot be empty",selectedTarget:n})}),null;this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"rename_session",n)});try{let t=await (0,p.tm)(this.buildUrl("/api/session/manage"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({action:"rename",sessionPath:e,name:r})}),s=await t.json().catch(()=>null);if(!t.ok||!s||"object"!=typeof s||!0!==s.success){let e=s&&"object"==typeof s&&"error"in s&&"string"==typeof s.error?s.error:`Session rename failed with ${t.status}`;return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"rename_session",success:!1,message:e,selectedTarget:n})}),null}let a=function(e,t,s){if(!e)return null;let a=H(e)===t&&e.bridge.sessionState?{...e.bridge,sessionState:{...e.bridge.sessionState,sessionName:s}}:e.bridge,r={...e,bridge:a};return{...r,resumableSessions:Y(r.resumableSessions.map(e=>e.path===t?{...e,name:s}:e),r)}}(this.state.boot,s.sessionPath,s.name),i=J(Q(this.state.commandSurface.sessionBrowser,s.sessionPath,{name:s.name,...s.isActiveSession?{isActive:!0}:{}}),a),o={kind:"name",sessionPath:s.sessionPath,name:s.name},l={...this.state.live,resumableSessions:Y(el(this.state).map(e=>e.path===s.sessionPath?{...e,name:s.name}:e),a)};return this.patchState({...a?{boot:a}:{},live:{...l,recoverySummary:ed({boot:a,live:l})},commandSurface:(0,x.yC)({...this.state.commandSurface,sessionBrowser:i},{action:"rename_session",success:!0,message:`Session name set: ${s.name}`,selectedTarget:o,sessionBrowser:i})}),s}catch(t){let e=S(t);return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"rename_session",success:!1,message:e,selectedTarget:n})}),null}},this.loadAvailableModels=async()=>{this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"loading_models")});let e=await this.sendCommand({type:"get_available_models"},{appendInputLine:!1,appendResponseLine:!1});if(!e||!1===e.success){let t=e?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"loading_models",success:!1,message:`Couldn't load models — ${t}`})}),[]}let t=function(e,t){let s=e&&"object"==typeof e&&"models"in e&&Array.isArray(e.models)?e.models:[],a=[];for(let e of s){let s="string"==typeof e.provider?e.provider:"string"==typeof e.providerId?e.providerId:void 0,r="string"==typeof e.id?e.id:void 0;s&&r&&a.push({provider:s,modelId:r,name:"string"==typeof e.name?e.name:void 0,reasoning:!!e.reasoning,isCurrent:s===t?.provider&&r===t?.modelId})}return a.sort((e,t)=>Number(t.isCurrent)-Number(e.isCurrent)||e.provider.localeCompare(t.provider)||e.modelId.localeCompare(t.modelId))}(e.data,G(this.state.boot?.bridge)),s=this.state.commandSurface.selectedTarget,a=s?.kind==="model"?s:t[0]?{kind:"model",provider:t[0].provider,modelId:t[0].modelId}:s;return this.patchState({commandSurface:{...this.state.commandSurface,pendingAction:null,lastError:null,availableModels:t,selectedTarget:a??null}}),t},this.applyModelSelection=async(e,t)=>{let s={kind:"model",provider:e,modelId:t};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"set_model",s)});let a=await this.sendCommand({type:"set_model",provider:e,modelId:t},{appendInputLine:!1,appendResponseLine:!1});if(!a||!1===a.success){let e=a?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_model",success:!1,message:e,selectedTarget:s})}),a}let r=this.state.boot?.bridge.sessionState?{...this.state.boot.bridge,sessionState:{...this.state.boot.bridge.sessionState,model:a.data}}:null,n=this.state.commandSurface.availableModels.map(s=>({...s,isCurrent:s.provider===e&&s.modelId===t}));return this.patchState({...r&&this.state.boot?{boot:_(this.state.boot,r)}:{},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_model",success:!0,message:`Model set to ${e}/${t}`,selectedTarget:s,availableModels:n})}),a},this.applyThinkingLevel=async e=>{let t={kind:"thinking",level:e};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"set_thinking_level",t)});let s=await this.sendCommand({type:"set_thinking_level",level:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_thinking_level",success:!1,message:e,selectedTarget:t})}),s}let a=this.state.boot?.bridge.sessionState?{...this.state.boot.bridge,sessionState:{...this.state.boot.bridge.sessionState,thinkingLevel:e}}:null;return this.patchState({...a&&this.state.boot?{boot:_(this.state.boot,a)}:{},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_thinking_level",success:!0,message:`Thinking level set to ${e}`,selectedTarget:t})}),s},this.setSteeringModeFromSurface=async e=>{let t=this.state.commandSurface.selectedTarget;this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"set_steering_mode",t)});let s=await this.sendCommand({type:"set_steering_mode",mode:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_steering_mode",success:!1,message:e,selectedTarget:t})}),s}let a=T(this.state.boot,{steeringMode:e});return this.patchState({...a?{boot:a}:{},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_steering_mode",success:!0,message:`Steering mode set to ${e}`,selectedTarget:t})}),s},this.setFollowUpModeFromSurface=async e=>{let t=this.state.commandSurface.selectedTarget;this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"set_follow_up_mode",t)});let s=await this.sendCommand({type:"set_follow_up_mode",mode:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_follow_up_mode",success:!1,message:e,selectedTarget:t})}),s}let a=T(this.state.boot,{followUpMode:e});return this.patchState({...a?{boot:a}:{},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_follow_up_mode",success:!0,message:`Follow-up mode set to ${e}`,selectedTarget:t})}),s},this.setAutoCompactionFromSurface=async e=>{let t=this.state.commandSurface.selectedTarget;this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"set_auto_compaction",t)});let s=await this.sendCommand({type:"set_auto_compaction",enabled:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_auto_compaction",success:!1,message:e,selectedTarget:t})}),s}let a=T(this.state.boot,{autoCompactionEnabled:e});return this.patchState({...a?{boot:a}:{},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_auto_compaction",success:!0,message:`Auto-compaction ${e?"enabled":"disabled"}`,selectedTarget:t})}),s},this.setAutoRetryFromSurface=async e=>{let t=this.state.commandSurface.selectedTarget;this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"set_auto_retry",t)});let s=await this.sendCommand({type:"set_auto_retry",enabled:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_auto_retry",success:!1,message:e,selectedTarget:t})}),s}let a=T(this.state.boot,{autoRetryEnabled:e});return this.patchState({...a?{boot:a}:{},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"set_auto_retry",success:!0,message:`Auto-retry ${e?"enabled":"disabled"}`,selectedTarget:t})}),s},this.abortRetryFromSurface=async()=>{let e=this.state.commandSurface.selectedTarget;this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"abort_retry",e)});let t=await this.sendCommand({type:"abort_retry"},{appendInputLine:!1,appendResponseLine:!1});if(!t||!1===t.success){let s=t?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"abort_retry",success:!1,message:s,selectedTarget:e})}),t}return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"abort_retry",success:!0,message:"Retry cancellation requested. Live retry state will update when the bridge confirms the abort.",selectedTarget:e})}),t},this.switchSessionFromSurface=async e=>{var t;let s,a={kind:"resume",sessionPath:e};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"switch_session",a)});let r=await this.sendCommand({type:"switch_session",sessionPath:e},{appendInputLine:!1,appendResponseLine:!1});if(!r||!1===r.success){let e=r?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"switch_session",success:!1,message:e,selectedTarget:a})}),r}if(r.data&&"object"==typeof r.data&&"cancelled"in r.data&&r.data.cancelled)return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"switch_session",success:!1,message:"Session switch was cancelled before the browser changed sessions.",selectedTarget:a})}),r;let n=this.state.commandSurface.sessionBrowser.sessions.find(t=>t.path===e)?.name??this.state.boot?.resumableSessions.find(t=>t.path===e)?.name,i=function(e,t,s){if(!e)return null;let a=e.resumableSessions.find(e=>e.path===t),r={...e.bridge,activeSessionFile:t,activeSessionId:a?.id??e.bridge.activeSessionId,sessionState:e.bridge.sessionState?{...e.bridge.sessionState,sessionFile:t,sessionId:a?.id??e.bridge.sessionState.sessionId,sessionName:s??a?.name??e.bridge.sessionState.sessionName}:e.bridge.sessionState},n={...e,bridge:r};return{...n,resumableSessions:Y(n.resumableSessions.map(e=>({...e,isActive:e.path===t})),n)}}(this.state.boot,e,n),o=J(Q(this.state.commandSurface.sessionBrowser,e,{isActive:!0,...n?{name:n}:{}}),i),l={...this.state.live,resumableSessions:Y(el(this.state).map(t=>({...t,isActive:t.path===e,...t.path===e&&n?{name:n}:{}})),i)};return this.patchState({...i?{boot:i}:{},live:{...l,recoverySummary:ed({boot:i,live:l})},commandSurface:(0,x.yC)({...this.state.commandSurface,sessionBrowser:o},{action:"switch_session",success:!0,message:`Switched to ${(t=i??this.state.boot,s=t?.resumableSessions.find(t=>t.path===e),s?.name?.trim()?s.name.trim():s?.id?s.id:F(e))}`,selectedTarget:a,sessionBrowser:o})}),r},this.loadSessionStats=async()=>{var e;let t={...this.state.live,freshness:{...this.state.live.freshness,sessionStats:es(this.state.live.freshness.sessionStats)}};this.patchState({live:{...t,recoverySummary:ed({boot:this.state.boot,live:t})},commandSurface:(0,x.Yc)(this.state.commandSurface,"load_session_stats")});let s=await this.sendCommand({type:"get_session_stats"},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.state.lastClientError??"Unknown error",t={...this.state.live,freshness:{...this.state.live.freshness,sessionStats:en(this.state.live.freshness.sessionStats,e)}};return this.patchState({live:{...t,recoverySummary:ed({boot:this.state.boot,live:t})},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"load_session_stats",success:!1,message:`Couldn't load session details — ${e}`,sessionStats:null})}),null}let a=(e=s.data)&&"object"==typeof e?"string"!=typeof e.sessionId?null:{sessionFile:"string"==typeof e.sessionFile?e.sessionFile:void 0,sessionId:e.sessionId,userMessages:Number(e.userMessages??0),assistantMessages:Number(e.assistantMessages??0),toolCalls:Number(e.toolCalls??0),toolResults:Number(e.toolResults??0),totalMessages:Number(e.totalMessages??0),tokens:{input:Number(e.tokens?.input??0),output:Number(e.tokens?.output??0),cacheRead:Number(e.tokens?.cacheRead??0),cacheWrite:Number(e.tokens?.cacheWrite??0),total:Number(e.tokens?.total??0)},cost:Number(e.cost??0)}:null;if(!a){let e="Session details response was missing the expected fields.",t={...this.state.live,freshness:{...this.state.live.freshness,sessionStats:en(this.state.live.freshness.sessionStats,e)}};return this.patchState({live:{...t,recoverySummary:ed({boot:this.state.boot,live:t})},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"load_session_stats",success:!1,message:e,sessionStats:null})}),null}let r={...this.state.live,freshness:{...this.state.live.freshness,sessionStats:er(this.state.live.freshness.sessionStats)}};return this.patchState({live:{...r,recoverySummary:ed({boot:this.state.boot,live:r})},commandSurface:(0,x.yC)(this.state.commandSurface,{action:"load_session_stats",success:!0,message:`Loaded session details for ${a.sessionId}`,sessionStats:a})}),a},this.exportSessionFromSurface=async e=>{let t=e?.trim()||void 0,s={kind:"session",outputPath:t};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"export_html",s)});let a=await this.sendCommand(t?{type:"export_html",outputPath:t}:{type:"export_html"},{appendInputLine:!1,appendResponseLine:!1});if(!a||!1===a.success){let e=a?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"export_html",success:!1,message:`Couldn't export this session — ${e}`,selectedTarget:s})}),a}let r=a.data&&"object"==typeof a.data&&"path"in a.data&&"string"==typeof a.data.path?a.data.path:"the generated file";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"export_html",success:!0,message:`Session exported to ${r}`,selectedTarget:s})}),a},this.loadForkMessages=async()=>{var e;this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"load_fork_messages")});let t=await this.sendCommand({type:"get_fork_messages"},{appendInputLine:!1,appendResponseLine:!1});if(!t||!1===t.success){let e=t?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"load_fork_messages",success:!1,message:`Couldn't load fork points — ${e}`,forkMessages:[]})}),[]}let s=((e=t.data)&&"object"==typeof e&&"messages"in e&&Array.isArray(e.messages)?e.messages:[]).map(e=>{let t="string"==typeof e.entryId?e.entryId:void 0,s="string"==typeof e.text?e.text:void 0;return t&&s?{entryId:t,text:s}:null}).filter(e=>null!==e),a=this.state.commandSurface.selectedTarget,r=a?.kind==="fork"&&a.entryId?a:s[0]?{kind:"fork",entryId:s[0].entryId}:a;return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"load_fork_messages",success:!0,message:s.length>0?`Loaded ${s.length} fork points.`:"No fork points are available yet.",selectedTarget:r??null,forkMessages:s})}),s},this.forkSessionFromSurface=async e=>{let t={kind:"fork",entryId:e};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"fork_session",t)});let s=await this.sendCommand({type:"fork",entryId:e},{appendInputLine:!1,appendResponseLine:!1});if(!s||!1===s.success){let e=s?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"fork_session",success:!1,message:`Couldn't create a fork — ${e}`,selectedTarget:t})}),s}if(s.data&&"object"==typeof s.data&&"cancelled"in s.data&&s.data.cancelled)return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"fork_session",success:!1,message:"Fork creation was cancelled before a new session was created.",selectedTarget:t})}),s;let a=s.data&&"object"==typeof s.data&&"text"in s.data&&"string"==typeof s.data.text?s.data.text.trim():"";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"fork_session",success:!0,message:a?`Forked from “${a.slice(0,120)}${a.length>120?"…":""}”`:"Created a forked session.",selectedTarget:t})}),s},this.compactSessionFromSurface=async e=>{var t;let s=e?.trim()??"",a={kind:"compact",customInstructions:s};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"compact_session",a)});let r=await this.sendCommand(s?{type:"compact",customInstructions:s}:{type:"compact"},{appendInputLine:!1,appendResponseLine:!1});if(!r||!1===r.success){let e=r?.error??this.state.lastClientError??"Unknown error";return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"compact_session",success:!1,message:`Couldn't compact the session — ${e}`,selectedTarget:a,lastCompaction:null})}),r}let n=(t=r.data)&&"object"==typeof t?"string"!=typeof t.summary||"string"!=typeof t.firstKeptEntryId?null:{summary:t.summary,firstKeptEntryId:t.firstKeptEntryId,tokensBefore:Number(t.tokensBefore??0),details:t.details}:null;return n?this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"compact_session",success:!0,message:`Compacted ${n.tokensBefore.toLocaleString()} tokens into a fresh summary${s?" with custom instructions":""}.`,selectedTarget:a,lastCompaction:n})}):this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"compact_session",success:!1,message:"Compaction finished but the browser could not read the compaction result.",selectedTarget:a,lastCompaction:null})}),r},this.saveApiKeyFromSurface=async(e,t)=>{let s={kind:"auth",providerId:e,intent:"manage"};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"save_api_key",s)});let a=await this.saveApiKey(e,t),r=a?R(a,e):e;return a?(a.lastValidation?.status==="failed"?this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"save_api_key",success:!1,message:a.lastValidation.message,selectedTarget:s})}):"failed"===a.bridgeAuthRefresh.phase?this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"save_api_key",success:!1,message:a.bridgeAuthRefresh.error??`${r} credentials validated but bridge auth refresh failed`,selectedTarget:s})}):this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"save_api_key",success:!0,message:`${r} credentials validated and saved.`,selectedTarget:s})}),a):(this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"save_api_key",success:!1,message:this.state.lastClientError??`${r} setup failed`,selectedTarget:s})}),null)},this.startProviderFlowFromSurface=async e=>{let t={kind:"auth",providerId:e,intent:"login"};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"start_provider_flow",t)});let s=await this.startProviderFlow(e),a=s?R(s,e):e;return s?(this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"start_provider_flow",success:!0,message:`${a} sign-in started. Continue in the auth section.`,selectedTarget:t})}),s):(this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"start_provider_flow",success:!1,message:this.state.lastClientError??`${a} sign-in failed to start`,selectedTarget:t})}),null)},this.submitProviderFlowInputFromSurface=async(e,t)=>{let s=this.state.boot?.onboarding.activeFlow?.providerId??void 0,a={kind:"auth",providerId:s,intent:"login"};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"submit_provider_flow_input",a)});let r=await this.submitProviderFlowInput(e,t),n=r?.activeFlow?.providerLabel??(s&&r?R(r,s):s)??"Provider";if(!r)return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"submit_provider_flow_input",success:!1,message:this.state.lastClientError??`${n} sign-in failed`,selectedTarget:a})}),null;if(r.activeFlow?.status==="failed")return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"submit_provider_flow_input",success:!1,message:r.activeFlow.error??`${n} sign-in failed`,selectedTarget:a})}),r;if("failed"===r.bridgeAuthRefresh.phase)return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"submit_provider_flow_input",success:!1,message:r.bridgeAuthRefresh.error??`${n} sign-in completed but bridge auth refresh failed`,selectedTarget:a})}),r;let i=r.activeFlow&&["running","awaiting_browser_auth","awaiting_input"].includes(r.activeFlow.status)?`${n} sign-in advanced. Complete the remaining step in this panel.`:`${n} sign-in complete.`;return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"submit_provider_flow_input",success:!0,message:i,selectedTarget:a})}),r},this.cancelProviderFlowFromSurface=async e=>{let t=this.state.boot?.onboarding.activeFlow?.providerId??void 0,s={kind:"auth",providerId:t,intent:"login"};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"cancel_provider_flow",s)});let a=await this.cancelProviderFlow(e),r=a?.activeFlow?.providerLabel??(t&&a?R(a,t):t)??"Provider";return a?(this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"cancel_provider_flow",success:!0,message:`${r} sign-in cancelled.`,selectedTarget:s})}),a):(this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"cancel_provider_flow",success:!1,message:this.state.lastClientError??`${r} sign-in cancellation failed`,selectedTarget:s})}),null)},this.logoutProviderFromSurface=async e=>{let t={kind:"auth",providerId:e,intent:"logout"};this.patchState({commandSurface:(0,x.Yc)(this.state.commandSurface,"logout_provider",t)});let s=await this.logoutProvider(e),a=s?R(s,e):e;if(!s)return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"logout_provider",success:!1,message:this.state.lastClientError??`${a} logout failed`,selectedTarget:t})}),null;if("failed"===s.bridgeAuthRefresh.phase)return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"logout_provider",success:!1,message:s.bridgeAuthRefresh.error??`${a} logout completed but bridge auth refresh failed`,selectedTarget:t})}),s;let r=s.required.providers.find(t=>t.id===e),n=r?.configured?`${a} saved credentials were removed, but ${r.configuredVia} auth still keeps the provider available.`:s.locked?`${a} logged out — required setup is needed again.`:`${a} logged out.`;return this.patchState({commandSurface:(0,x.yC)(this.state.commandSurface,{action:"logout_provider",success:!0,message:n,selectedTarget:t})}),s},this.respondToUiRequest=async(e,t)=>{this.patchState({commandInFlight:"extension_ui_response"});try{let s=await (0,p.tm)(this.buildUrl("/api/session/command"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e,...t})});if(!s.ok){let e=await s.json().catch(()=>({error:`HTTP ${s.status}`}));throw Error(e.error??`extension_ui_response failed with ${s.status}`)}this.patchState({pendingUiRequests:this.state.pendingUiRequests.filter(t=>t.id!==e)})}catch(t){let e=S(t);this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`UI response failed — ${e}`))})}finally{this.patchState({commandInFlight:null})}},this.dismissUiRequest=async e=>{this.patchState({commandInFlight:"extension_ui_response"});try{let t=await (0,p.tm)(this.buildUrl("/api/session/command"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e,cancelled:!0})});if(!t.ok){let e=await t.json().catch(()=>({error:`HTTP ${t.status}`}));throw Error(e.error??`extension_ui_response cancel failed with ${t.status}`)}this.patchState({pendingUiRequests:this.state.pendingUiRequests.filter(t=>t.id!==e)})}catch(t){let e=S(t);this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`UI dismiss failed — ${e}`))})}finally{this.patchState({commandInFlight:null})}},this.sendSteer=async e=>{await this.sendCommand({type:"steer",message:e})},this.sendAbort=async()=>{await this.sendCommand({type:"abort"})},this.pushChatUserMessage=e=>{this.patchState({chatUserMessages:[...this.state.chatUserMessages,e]})},this.submitInput=async(e,t)=>{let s=e.trim();if(!s)return null;let a=m(s,{isStreaming:this.state.boot?.bridge.sessionState?.isStreaming});if(this.patchState({lastSlashCommandOutcome:s.startsWith("/")?a:null}),"prompt"===a.kind){let e=this.state.boot?.bridge.sessionState,t=this.contextualTips.evaluate({input:s,isStreaming:!!e?.isStreaming,thinkingLevel:e?.thinkingLevel,contextPercent:void 0});t&&this.patchState({terminalLines:w(this.state.terminalLines,y("system",`💡 ${t}`))})}switch(a.kind){case"prompt":case"rpc":{let e=t?.map(e=>({type:"image",data:e.data,mimeType:e.mimeType})),r=e&&e.length>0?{...a.command,images:e}:a.command;return await this.sendCommand(r,{displayInput:s}),a}case"local":if("clear_terminal"===a.action)return this.clearTerminalLines(),a;if("refresh_workspace"===a.action)return await this.refreshBoot(),a;return"gsd_help"===a.action&&this.patchState({terminalLines:w(w(this.state.terminalLines,y("input",s)),y("system",c))}),a;case"surface":{if(j.has(a.surface))return this.patchState({terminalLines:w(this.state.terminalLines,y("input",s))}),this.openCommandSurface(a.surface,{source:"slash",args:a.args}),a;let e=h(a),t=w(this.state.terminalLines,y("input",s));return e&&(t=w(t,y(e.type,e.message))),this.patchState({terminalLines:t}),a}case"reject":{let e=h(a),t=w(this.state.terminalLines,y("input",s));return e&&(t=w(t,y(e.type,e.message))),this.patchState({terminalLines:t}),a}case"view-navigate":return this.patchState({terminalLines:w(this.state.terminalLines,y("system",`Navigating to ${a.view} view`))}),window.dispatchEvent(new CustomEvent("gsd:navigate-view",{detail:{view:a.view}})),a}},this.refreshBoot=async(e={})=>{if(this.bootPromise)return await this.bootPromise;this.lastBootRefreshAt=Date.now();let t=!!(e.soft&&this.state.boot);this.bootPromise=(async()=>{t?this.patchState({lastClientError:null}):this.patchState({bootStatus:"loading",connectionState:"connected"===this.state.connectionState?"connected":"connecting",lastClientError:null});try{let e=await (0,p.tm)(this.buildUrl("/api/boot"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}});if(!e.ok){if(401===e.status)return void this.patchState({bootStatus:"unauthenticated",connectionState:"error"});throw Error(`Boot request failed with ${e.status}`)}let s=await e.json(),a=_(s,s.bridge)??s,r=function(e,t,s={}){let a={...e,auto:t.auto,workspace:t.workspace,resumableSessions:t.resumableSessions,freshness:{...e.freshness,auto:er(e.freshness.auto),workspace:er(e.freshness.workspace),recovery:er(e.freshness.recovery),resumableSessions:er(e.freshness.resumableSessions)},softBootRefreshCount:e.softBootRefreshCount+ +!!s.soft};return a.recoverySummary=ed({boot:t,live:a}),a}(this.state.live,a,{soft:t});this.lastBridgeDigest=null,this.lastBridgeDigest=[a.bridge.phase,a.bridge.activeSessionId,a.bridge.lastError?.at,a.bridge.lastError?.message].join("::"),this.patchState({bootStatus:"ready",boot:a,live:r,connectionState:a.onboarding.locked?"idle":this.eventSource?this.state.connectionState:"connecting",lastBridgeError:a.bridge.lastError,sessionAttached:N(a.bridge),lastClientError:null,...t?{}:{terminalLines:I(a)}}),a.onboarding.locked?this.closeEventStream():this.ensureEventStream()}catch(s){let e=S(s);if(t)return void this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Workspace refresh failed — ${e}`))});this.patchState({bootStatus:"error",connectionState:"error",lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Boot failed — ${e}`))})}})().finally(()=>{this.bootPromise=null}),await this.bootPromise},this.refreshOnboarding=async()=>{this.patchState({onboardingRequestState:"refreshing",onboardingRequestProviderId:null,lastClientError:null});try{return await this.fetchOnboardingState()}catch(t){let e=S(t);return this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Onboarding refresh failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.saveApiKey=async(e,t)=>{this.patchState({onboardingRequestState:"saving_api_key",onboardingRequestProviderId:e,lastClientError:null});try{let s=await this.postOnboardingAction({action:"save_api_key",providerId:e,apiKey:t});return await this.syncAfterOnboardingMutation(s),s}catch(t){let e=S(t);return this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Credential setup failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.startProviderFlow=async e=>{this.patchState({onboardingRequestState:"starting_provider_flow",onboardingRequestProviderId:e,lastClientError:null});try{let t=await this.postOnboardingAction({action:"start_provider_flow",providerId:e});return await this.syncAfterOnboardingMutation(t),t}catch(t){let e=S(t);return this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Provider sign-in failed to start — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.submitProviderFlowInput=async(e,t)=>{this.patchState({onboardingRequestState:"submitting_provider_flow_input",onboardingRequestProviderId:this.state.boot?.onboarding.activeFlow?.providerId??null,lastClientError:null});try{let s=await this.postOnboardingAction({action:"continue_provider_flow",flowId:e,input:t});return await this.syncAfterOnboardingMutation(s),s}catch(t){let e=S(t);return this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Provider sign-in input failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.cancelProviderFlow=async e=>{this.patchState({onboardingRequestState:"cancelling_provider_flow",onboardingRequestProviderId:this.state.boot?.onboarding.activeFlow?.providerId??null,lastClientError:null});try{let t=await this.postOnboardingAction({action:"cancel_provider_flow",flowId:e});return await this.syncAfterOnboardingMutation(t),t}catch(t){let e=S(t);return this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Provider sign-in cancellation failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.logoutProvider=async e=>{this.patchState({onboardingRequestState:"logging_out_provider",onboardingRequestProviderId:e,lastClientError:null});try{let t=await this.postOnboardingAction({action:"logout_provider",providerId:e});return await this.syncAfterOnboardingMutation(t),t}catch(t){let e=S(t);return this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Provider logout failed — ${e}`))}),null}finally{this.patchState({onboardingRequestState:"idle",onboardingRequestProviderId:null})}},this.sendCommand=async(e,t={})=>{this.clearCommandTimeout();let s={commandInFlight:e.type};!1!==t.appendInputLine&&(s.terminalLines=w(this.state.terminalLines,y("input",t.displayInput??("string"==typeof e.message?e.message:`/${e.type}`)))),this.patchState(s),this.commandTimeoutTimer=setTimeout(()=>{this.state.commandInFlight&&this.patchState({commandInFlight:null,lastClientError:"Command timed out — controls re-enabled",terminalLines:w(this.state.terminalLines,y("error","Command timed out — controls re-enabled"))})},9e4);try{let s=await (0,p.tm)(this.buildUrl("/api/session/command"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),a=await s.json();if("ok"in a)return null;if("get_state"===a.command&&a.success&&this.state.boot){let e={...this.state.boot.bridge,sessionState:a.data,activeSessionId:a.data.sessionId,activeSessionFile:a.data.sessionFile??this.state.boot.bridge.activeSessionFile,lastCommandType:"get_state",updatedAt:new Date().toISOString()};this.patchState({boot:_(this.state.boot,e),lastBridgeError:e.lastError,sessionAttached:N(e)})}return"new_session"===a.command&&a.success&&this.contextualTips.reset(),"onboarding_locked"===a.code&&a.details?.onboarding&&this.state.boot&&this.patchState({boot:function(e,t){var s;return e?P(e,(s=e.onboarding,{...s,...t,required:{...s.required,...t.required??{},providers:t.required?.providers??s.required.providers},optional:{...s.optional,...t.optional??{},sections:t.optional?.sections??s.optional.sections},bridgeAuthRefresh:{...s.bridgeAuthRefresh,...t.bridgeAuthRefresh??{}}})):null}(this.state.boot,a.details.onboarding)}),this.patchState({...!1===t.appendResponseLine?{}:{terminalLines:w(this.state.terminalLines,function(e){if(!e.success)return y("error",`Command failed (${e.command}) — ${e.error??"unknown error"}`);switch(e.command){case"get_state":return y("success","Session state refreshed");case"new_session":return y("success","Started a new session");case"prompt":return y("success","Prompt accepted by the live bridge");case"follow_up":return y("success","Follow-up queued on the live bridge");default:return y("success",`Command accepted (${e.command})`)}}(a))},lastBridgeError:a.success?this.state.lastBridgeError:this.state.boot?.bridge.lastError??this.state.lastBridgeError}),a}catch(s){let t=S(s);return this.patchState({lastClientError:t,terminalLines:w(this.state.terminalLines,y("error",`Command failed (${e.type}) — ${t}`))}),{type:"response",command:e.type,success:!1,error:t}}finally{this.clearCommandTimeout(),this.patchState({commandInFlight:null})}}}buildUrl(e){return ec(e,this.projectCwd)}patchDiagnosticsPhaseState(e,t){this.patchState({commandSurface:{...this.state.commandSurface,diagnostics:{...this.state.commandSurface.diagnostics,[e]:{...this.state.commandSurface.diagnostics[e],...t}}}})}patchDoctorState(e){this.patchState({commandSurface:{...this.state.commandSurface,diagnostics:{...this.state.commandSurface.diagnostics,doctor:{...this.state.commandSurface.diagnostics.doctor,...e}}}})}patchKnowledgeCapturesState(e){this.patchState({commandSurface:{...this.state.commandSurface,knowledgeCaptures:{...this.state.commandSurface.knowledgeCaptures,...e}}})}patchKnowledgeCapturesPhaseState(e,t){this.patchState({commandSurface:{...this.state.commandSurface,knowledgeCaptures:{...this.state.commandSurface.knowledgeCaptures,[e]:{...this.state.commandSurface.knowledgeCaptures[e],...t}}}})}patchSettingsPhaseState(e){this.patchState({commandSurface:{...this.state.commandSurface,settingsData:{...this.state.commandSurface.settingsData,...e}}})}patchRemainingCommandsPhaseState(e,t){this.patchState({commandSurface:{...this.state.commandSurface,remainingCommands:{...this.state.commandSurface.remainingCommands,[e]:{...this.state.commandSurface.remainingCommands[e],...t}}}})}async refreshBootAfterCurrentSettles(e={}){if(this.bootPromise)try{await this.bootPromise}catch{}await this.refreshBoot(e)}invalidateLiveFreshness(e,t,s){let a={...this.state.live.freshness};e.includes("auto")&&(a.auto=ea(a.auto,t,s)),e.includes("workspace")&&(a.workspace=ea(a.workspace,t,s),a.gitSummary=ea(a.gitSummary,t,s)),e.includes("recovery")&&(a.recovery=ea(a.recovery,t,s),a.sessionStats=ea(a.sessionStats,t,s)),e.includes("resumable_sessions")&&(a.resumableSessions=ea(a.resumableSessions,t,s),a.sessionBrowser=ea(a.sessionBrowser,t,s),a.sessionStats=ea(a.sessionStats,t,s));let r={...this.state.live,freshness:a};return{...r,recoverySummary:ed({boot:this.state.boot,live:r})}}refreshOpenCommandSurfacesForInvalidation(e){if(e.domains.includes("workspace")&&this.state.commandSurface.open&&"git"===this.state.commandSurface.section&&"load_git_summary"!==this.state.commandSurface.pendingAction&&this.loadGitSummary(),e.domains.includes("recovery")&&this.state.commandSurface.open&&"recovery"===this.state.commandSurface.section&&"load_recovery_diagnostics"!==this.state.commandSurface.pendingAction&&this.loadRecoveryDiagnostics(),e.domains.includes("resumable_sessions")&&(this.state.commandSurface.open&&("resume"===this.state.commandSurface.section||"name"===this.state.commandSurface.section)&&"load_session_browser"!==this.state.commandSurface.pendingAction&&this.loadSessionBrowser(),this.state.commandSurface.open&&"session"===this.state.commandSurface.section)){let e=this.state.boot?.bridge.activeSessionFile??this.state.boot?.bridge.sessionState?.sessionFile??null;this.patchState({commandSurface:{...this.state.commandSurface,sessionStats:this.state.commandSurface.sessionStats&&this.state.commandSurface.sessionStats.sessionFile===e?this.state.commandSurface.sessionStats:null}}),"load_session_stats"!==this.state.commandSurface.pendingAction&&this.loadSessionStats()}}async reloadLiveState(e,t){let s=e.filter(e=>"auto"===e||"workspace"===e||"resumable_sessions"===e);if(0===s.length){let e={...this.state.live,freshness:{...this.state.live.freshness,recovery:er(this.state.live.freshness.recovery)}};this.patchState({live:{...e,recoverySummary:ed({boot:this.state.boot,live:e})}});return}let a={...this.state.live.freshness};s.includes("auto")&&(a.auto=es(a.auto)),s.includes("workspace")&&(a.workspace=es(a.workspace)),s.includes("resumable_sessions")&&(a.resumableSessions=es(a.resumableSessions)),a.recovery=es(a.recovery);let r={...this.state.live,freshness:a,targetedRefreshCount:this.state.live.targetedRefreshCount+1};this.patchState({live:{...r,recoverySummary:ed({boot:this.state.boot,live:r})}});let n=new URLSearchParams;for(let e of s)n.append("domain",e);try{let e=await (0,p.tm)(this.buildUrl(`/api/live-state?${n.toString()}`),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),t=await e.json().catch(()=>null);if(!e.ok||!t)throw Error(t?.error??`Live state request failed with ${e.status}`);let a=this.state.boot,r={...this.state.live,freshness:{...this.state.live.freshness}};if(s.includes("auto")&&t.auto&&(r.auto=t.auto,r.freshness.auto=er(r.freshness.auto),a=a?{...a,auto:t.auto}:a),s.includes("workspace")&&t.workspace&&(r.workspace=t.workspace,r.freshness.workspace=er(r.freshness.workspace),a=a?{...a,workspace:t.workspace}:a),s.includes("resumable_sessions")&&t.resumableSessions){let e=Y(t.resumableSessions,a);r.resumableSessions=e,r.freshness.resumableSessions=er(r.freshness.resumableSessions),a=a?{...a,resumableSessions:e}:a}r.freshness.recovery=er(r.freshness.recovery),r.recoverySummary=ed({boot:a,live:r}),this.patchState({...a?{boot:a}:{},live:r})}catch(r){let e=S(r),a={...this.state.live,freshness:{...this.state.live.freshness,auto:s.includes("auto")?en(this.state.live.freshness.auto,e):this.state.live.freshness.auto,workspace:s.includes("workspace")?en(this.state.live.freshness.workspace,e):this.state.live.freshness.workspace,resumableSessions:s.includes("resumable_sessions")?en(this.state.live.freshness.resumableSessions,e):this.state.live.freshness.resumableSessions,recovery:en(this.state.live.freshness.recovery,e)}};this.patchState({lastClientError:e,live:{...a,recoverySummary:ed({boot:this.state.boot,live:a})},terminalLines:w(this.state.terminalLines,y("error",`Live refresh failed (${t}) — ${e}`))})}}handleLiveStateInvalidation(e){var t;this.patchState({live:this.invalidateLiveFreshness(e.domains,e.reason,e.source),commandSurface:e.domains.includes("recovery")?{...this.state.commandSurface,recovery:(t=this.state.commandSurface.recovery).loaded||t.error?{...t,stale:!0,lastInvalidatedAt:new Date().toISOString()}:t}:this.state.commandSurface}),this.refreshOpenCommandSurfacesForInvalidation(e),this.reloadLiveState(e.domains,e.reason)}clearCommandTimeout(){this.commandTimeoutTimer&&(clearTimeout(this.commandTimeoutTimer),this.commandTimeoutTimer=null)}async fetchOnboardingState(e=!1){let t=this.state.boot?.onboarding.activeFlow?.status??null,s=await (0,p.tm)(this.buildUrl("/api/onboarding"),{method:"GET",cache:"no-store",headers:{Accept:"application/json"}}),a=await s.json();if(!s.ok||!a.onboarding)throw Error(a.error??`Onboarding request failed with ${s.status}`);return this.applyOnboardingState(a.onboarding),t&&C.has(t)&&a.onboarding.activeFlow&&A.has(a.onboarding.activeFlow.status)?await this.syncAfterOnboardingMutation(a.onboarding):e||this.appendOnboardingSummaryLine(a.onboarding),a.onboarding}async postOnboardingAction(e){let t=await (0,p.tm)(this.buildUrl("/api/onboarding"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),s=await t.json();if(!t.ok)throw s.onboarding&&this.applyOnboardingState(s.onboarding),Error(s.error??`Onboarding action failed with ${t.status}`);if(!s.onboarding)throw Error(`Onboarding action returned no state (${t.status})`);return this.applyOnboardingState(s.onboarding),s.onboarding}applyOnboardingState(e){this.state.boot&&this.patchState({boot:P(this.state.boot,e)})}async syncAfterOnboardingMutation(e){this.applyOnboardingState(e),this.appendOnboardingSummaryLine(e),(e.lastValidation?.status==="succeeded"||"idle"!==e.bridgeAuthRefresh.phase)&&this.refreshBootAfterCurrentSettles({soft:!0})}appendOnboardingSummaryLine(e){let t=E(e);if(!t)return;let s=this.state.terminalLines.at(-1);(s?.type!==t.type||s.content!==t.message)&&this.patchState({terminalLines:w(this.state.terminalLines,y(t.type,t.message))})}emit(){for(let e of this.listeners)e()}patchState(e){this.state={...this.state,...e},this.syncOnboardingPoller(),this.emit()}syncOnboardingPoller(){if(this.disposed)return void this.stopOnboardingPoller();let e=this.state.boot?.onboarding.activeFlow?.status,t=!!(e&&C.has(e));if(t&&!this.onboardingPollTimer){this.onboardingPollTimer=setInterval(()=>{"idle"===this.state.onboardingRequestState&&this.fetchOnboardingState(!0).catch(e=>{let t=S(e);this.patchState({lastClientError:t})})},1500);return}t||this.stopOnboardingPoller()}stopOnboardingPoller(){this.onboardingPollTimer&&(clearInterval(this.onboardingPollTimer),this.onboardingPollTimer=null)}ensureEventStream(){if(this.eventSource||this.disposed||this.state.boot?.onboarding.locked)return;let e=new EventSource((0,p.QT)(this.buildUrl("/api/session/events")));this.eventSource=e,e.onopen=()=>{let e=this.lastStreamState,t="reconnecting"===e||"disconnected"===e||"error"===e;t&&this.patchState({terminalLines:w(this.state.terminalLines,y("success","Live event stream reconnected"))}),this.lastStreamState="connected",this.patchState({connectionState:"connected",lastClientError:null}),t&&this.refreshBoot({soft:!0})},e.onmessage=e=>{try{let t=JSON.parse(e.data);if(null===t||"object"!=typeof t||"string"!=typeof t.type)return void this.patchState({lastClientError:"Malformed event received from stream",terminalLines:w(this.state.terminalLines,y("error","Malformed event received from stream"))});this.handleEvent(t)}catch(t){let e=S(t);this.patchState({lastClientError:e,terminalLines:w(this.state.terminalLines,y("error",`Failed to parse stream event — ${e}`))})}},e.onerror=()=>{let e="connected"===this.lastStreamState?"reconnecting":"error";e!==this.lastStreamState?this.patchState({connectionState:e,terminalLines:w(this.state.terminalLines,y("reconnecting"===e?"system":"error","reconnecting"===e?"Live event stream disconnected — retrying…":"Live event stream failed before connection was established"))}):this.patchState({connectionState:e}),this.lastStreamState=e}}closeEventStream(){this.eventSource?.close(),this.eventSource=null}handleEvent(e){if(this.patchState({lastEventType:e.type}),"bridge_status"===e.type)return void this.recordBridgeStatus(e.bridge);"live_state_invalidation"===e.type&&this.handleLiveStateInvalidation(e),this.routeLiveInteractionEvent(e);let t=function(e){switch(e.type){case"bridge_status":return k(e.bridge);case"live_state_invalidation":return{type:"system",message:`[Live] Refreshing ${Array.isArray(e.domains)?e.domains.join(", "):"state"} after ${String(e.reason).replaceAll("_"," ")}`};case"agent_start":return{type:"system",message:"[Agent] Run started"};case"agent_end":return{type:"success",message:"[Agent] Run finished"};case"turn_start":return{type:"system",message:"[Agent] Turn started"};case"turn_end":return{type:"success",message:"[Agent] Turn complete"};case"tool_execution_start":return{type:"output",message:`[Tool] ${"string"==typeof e.toolName?e.toolName:"tool"} started`};case"tool_execution_update":default:return null;case"tool_execution_end":return{type:e.isError?"error":"success",message:`[Tool] ${"string"==typeof e.toolName?e.toolName:"tool"} ${e.isError?"failed":"completed"}`};case"auto_compaction_start":return{type:"system",message:"[Auto] Compaction started"};case"auto_compaction_end":return{type:e.aborted?"error":"success",message:e.aborted?"[Auto] Compaction aborted":"[Auto] Compaction finished"};case"auto_retry_start":return{type:"system",message:`[Auto] Retry ${String(e.attempt)}/${String(e.maxAttempts)} scheduled`};case"auto_retry_end":return{type:e.success?"success":"error",message:e.success?"[Auto] Retry recovered the run":"[Auto] Retry exhausted"};case"extension_ui_request":{let t="title"in e&&"string"==typeof e.title&&e.title.trim().length>0?e.title:"message"in e&&"string"==typeof e.message&&e.message.trim().length>0?e.message:e.method;return{type:"notifyType"in e&&"error"===e.notifyType?"error":"system",message:`[UI] ${t}`}}case"extension_error":return{type:"error",message:`[Extension] ${e.error}`}}}(e);t&&this.patchState({terminalLines:w(this.state.terminalLines,y(t.type,t.message))})}routeLiveInteractionEvent(e){switch(e.type){case"extension_ui_request":this.handleExtensionUiRequest(e);break;case"message_update":this.handleMessageUpdate(e);break;case"agent_end":case"turn_end":this.handleTurnBoundary();break;case"tool_execution_start":this.handleToolExecutionStart(e);break;case"tool_execution_update":this.handleToolExecutionUpdate(e);break;case"tool_execution_end":this.handleToolExecutionEnd(e)}}handleExtensionUiRequest(e){switch(e.method){case"select":case"confirm":case"input":case"editor":this.patchState({pendingUiRequests:[...this.state.pendingUiRequests,e]});break;case"notify":break;case"setStatus":if("setStatus"===e.method){let t={...this.state.statusTexts};void 0===e.statusText?delete t[e.statusKey]:t[e.statusKey]=e.statusText,this.patchState({statusTexts:t})}break;case"setWidget":if("setWidget"===e.method){let t={...this.state.widgetContents};void 0===e.widgetLines?delete t[e.widgetKey]:t[e.widgetKey]={lines:e.widgetLines,placement:e.widgetPlacement},this.patchState({widgetContents:t})}break;case"setTitle":if("setTitle"===e.method){let t=e.title.trim();this.patchState({titleOverride:t||null})}break;case"set_editor_text":"set_editor_text"===e.method&&this.patchState({editorTextBuffer:e.text})}}handleMessageUpdate(e){let t=e.assistantMessageEvent;t&&("text_delta"===t.type&&"string"==typeof t.delta?(this.state.streamingThinkingText.length>0&&this.patchState({currentTurnSegments:[...this.state.currentTurnSegments,{kind:"thinking",content:this.state.streamingThinkingText}],streamingThinkingText:""}),this.patchState({streamingAssistantText:this.state.streamingAssistantText+t.delta})):"thinking_delta"===t.type&&"string"==typeof t.delta?(this.state.streamingAssistantText.length>0&&this.patchState({currentTurnSegments:[...this.state.currentTurnSegments,{kind:"text",content:this.state.streamingAssistantText}],streamingAssistantText:""}),this.patchState({streamingThinkingText:this.state.streamingThinkingText+t.delta})):"thinking_end"===t.type&&this.state.streamingThinkingText.length>0&&this.patchState({currentTurnSegments:[...this.state.currentTurnSegments,{kind:"thinking",content:this.state.streamingThinkingText}],streamingThinkingText:""}))}handleTurnBoundary(){let e=[];this.state.streamingThinkingText.length>0&&e.push({kind:"thinking",content:this.state.streamingThinkingText}),this.state.streamingAssistantText.length>0&&e.push({kind:"text",content:this.state.streamingAssistantText});let t=e.length>0?[...this.state.currentTurnSegments,...e]:this.state.currentTurnSegments,s=t.filter(e=>"text"===e.kind).map(e=>e.content).join("");if(s.length>0||t.length>0){let e=[...this.state.liveTranscript,s],a=[...this.state.liveThinkingTranscript,""],r=[...this.state.completedTurnSegments,t],n=e.length>100?e.length-100:0,i=n>0?this.state.chatUserMessages.slice(n):void 0;this.patchState({liveTranscript:n>0?e.slice(n):e,liveThinkingTranscript:n>0?a.slice(n):a,completedTurnSegments:n>0?r.slice(n):r,...void 0!==i?{chatUserMessages:i}:{},streamingAssistantText:"",streamingThinkingText:"",currentTurnSegments:[],completedToolExecutions:[]})}else this.state.streamingThinkingText.length>0?this.patchState({streamingThinkingText:"",currentTurnSegments:[],completedToolExecutions:[]}):this.patchState({currentTurnSegments:[],completedToolExecutions:[]})}handleToolExecutionStart(e){this.patchState({activeToolExecution:{id:e.toolCallId,name:e.toolName,args:e.args},streamingAssistantText:"",streamingThinkingText:""})}handleToolExecutionUpdate(e){let t=this.state.activeToolExecution;t&&t.id===e.toolCallId&&this.patchState({activeToolExecution:{...t,result:e.partialResult?{content:e.partialResult.content,details:e.partialResult.details,isError:!!e.partialResult.isError}:t.result}})}handleToolExecutionEnd(e){let t=this.state.activeToolExecution;if(t){let s={id:t.id,name:t.name,args:t.args??{},result:{content:e.result?.content,details:e.result?.details,isError:e.isError}},a=[...this.state.completedToolExecutions,s];this.patchState({activeToolExecution:null,completedToolExecutions:a.length>50?a.slice(a.length-50):a,currentTurnSegments:[...this.state.currentTurnSegments,{kind:"tool",tool:s}]})}else this.patchState({activeToolExecution:null})}recordBridgeStatus(e){let t=[e.phase,e.activeSessionId,e.lastError?.at,e.lastError?.message].join("::"),s=t!==this.lastBridgeDigest;this.lastBridgeDigest=t;let a=_(this.state.boot,e),r={...this.state.live,resumableSessions:Y(this.state.live.resumableSessions,a)},n={...r,recoverySummary:ed({boot:a,live:r})},i={boot:a,live:n,lastBridgeError:e.lastError,sessionAttached:N(e),commandSurface:{...this.state.commandSurface,sessionBrowser:J(this.state.commandSurface.sessionBrowser,a)}};if(s){let t=k(e);i.terminalLines=w(this.state.terminalLines,y(t.type,t.message))}this.patchState(i)}}let em=(0,r.createContext)(null);function eh({children:e,store:t}){let[s]=(0,r.useState)(()=>new eu),n=t??s;return(0,r.useEffect)(()=>{if(!t)return n.start(),()=>n.dispose()},[n,t]),(0,a.jsx)(em.Provider,{value:n,children:e})}function ex(){let e=(0,r.useContext)(em);if(!e)throw Error("useWorkspaceStore must be used within GSDWorkspaceProvider");return e}function ep(){let e=ex();return(0,r.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}function eg(){let e=ex();return{sendCommand:e.sendCommand,submitInput:e.submitInput,clearTerminalLines:e.clearTerminalLines,consumeEditorTextBuffer:e.consumeEditorTextBuffer,refreshBoot:e.refreshBoot,refreshOnboarding:e.refreshOnboarding,openCommandSurface:e.openCommandSurface,closeCommandSurface:e.closeCommandSurface,setCommandSurfaceSection:e.setCommandSurfaceSection,selectCommandSurfaceTarget:e.selectCommandSurfaceTarget,loadGitSummary:e.loadGitSummary,loadRecoveryDiagnostics:e.loadRecoveryDiagnostics,loadForensicsDiagnostics:e.loadForensicsDiagnostics,loadDoctorDiagnostics:e.loadDoctorDiagnostics,applyDoctorFixes:e.applyDoctorFixes,loadSkillHealthDiagnostics:e.loadSkillHealthDiagnostics,loadKnowledgeData:e.loadKnowledgeData,loadCapturesData:e.loadCapturesData,loadSettingsData:e.loadSettingsData,loadHistoryData:e.loadHistoryData,loadInspectData:e.loadInspectData,loadHooksData:e.loadHooksData,loadExportData:e.loadExportData,loadUndoInfo:e.loadUndoInfo,loadCleanupData:e.loadCleanupData,loadSteerData:e.loadSteerData,executeUndoAction:e.executeUndoAction,executeCleanupAction:e.executeCleanupAction,resolveCaptureAction:e.resolveCaptureAction,updateSessionBrowserState:e.updateSessionBrowserState,loadSessionBrowser:e.loadSessionBrowser,renameSessionFromSurface:e.renameSessionFromSurface,loadAvailableModels:e.loadAvailableModels,applyModelSelection:e.applyModelSelection,applyThinkingLevel:e.applyThinkingLevel,setSteeringModeFromSurface:e.setSteeringModeFromSurface,setFollowUpModeFromSurface:e.setFollowUpModeFromSurface,setAutoCompactionFromSurface:e.setAutoCompactionFromSurface,setAutoRetryFromSurface:e.setAutoRetryFromSurface,abortRetryFromSurface:e.abortRetryFromSurface,switchSessionFromSurface:e.switchSessionFromSurface,loadSessionStats:e.loadSessionStats,exportSessionFromSurface:e.exportSessionFromSurface,loadForkMessages:e.loadForkMessages,forkSessionFromSurface:e.forkSessionFromSurface,compactSessionFromSurface:e.compactSessionFromSurface,saveApiKey:e.saveApiKey,saveApiKeyFromSurface:e.saveApiKeyFromSurface,startProviderFlow:e.startProviderFlow,startProviderFlowFromSurface:e.startProviderFlowFromSurface,submitProviderFlowInput:e.submitProviderFlowInput,submitProviderFlowInputFromSurface:e.submitProviderFlowInputFromSurface,cancelProviderFlow:e.cancelProviderFlow,cancelProviderFlowFromSurface:e.cancelProviderFlowFromSurface,logoutProvider:e.logoutProvider,logoutProviderFromSurface:e.logoutProviderFromSurface,respondToUiRequest:e.respondToUiRequest,dismissUiRequest:e.dismissUiRequest,sendSteer:e.sendSteer,sendAbort:e.sendAbort,pushChatUserMessage:e.pushChatUserMessage}}function ef(e,t){let s=m(e,{isStreaming:t?.sessionState?.isStreaming});if("prompt"===s.kind||"rpc"===s.kind)return s.command;throw Error(`buildPromptCommand cannot serialize ${s.input||e} because browser dispatch resolved it to ${s.kind}; use submitInput() instead.`)}}}]);