orbital-command 0.1.4 → 0.3.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 (380) hide show
  1. package/bin/orbital.js +676 -53
  2. package/dist/assets/PrimitivesConfig-CrmQXYh4.js +32 -0
  3. package/dist/assets/QualityGates-BbasOsF3.js +21 -0
  4. package/dist/assets/SessionTimeline-CGeJsVvy.js +1 -0
  5. package/dist/assets/Settings-oiM496mc.js +12 -0
  6. package/dist/assets/SourceControl-B1fP2nJL.js +41 -0
  7. package/dist/assets/WorkflowVisualizer-CWLYf-f0.js +74 -0
  8. package/dist/assets/arrow-down-CPy85_J6.js +6 -0
  9. package/dist/assets/charts-DbDg0Psc.js +68 -0
  10. package/dist/assets/circle-x-Cwz6ZQDV.js +6 -0
  11. package/dist/assets/file-text-C46Xr65c.js +6 -0
  12. package/dist/assets/formatDistanceToNow-BMqsSP44.js +1 -0
  13. package/dist/assets/globe-Cn2yNZUD.js +6 -0
  14. package/dist/assets/index-Aj4sV8Al.css +1 -0
  15. package/dist/assets/index-Bc9dK3MW.js +354 -0
  16. package/dist/assets/key-OPaNTWJ5.js +6 -0
  17. package/dist/assets/minus-GMsbpKym.js +6 -0
  18. package/dist/assets/shield-DwAFkDYI.js +6 -0
  19. package/dist/assets/ui-BmsSg9jU.js +53 -0
  20. package/dist/assets/useWorkflowEditor-BJkTX_NR.js +16 -0
  21. package/dist/assets/{vendor-Dzv9lrRc.js → vendor-Bqt8AJn2.js} +1 -1
  22. package/dist/assets/zap-DfbUoOty.js +11 -0
  23. package/dist/favicon.svg +1 -0
  24. package/dist/index.html +6 -5
  25. package/dist/server/server/__tests__/data-routes.test.js +124 -0
  26. package/dist/server/server/__tests__/helpers/db.js +17 -0
  27. package/dist/server/server/__tests__/helpers/mock-emitter.js +8 -0
  28. package/dist/server/server/__tests__/scope-routes.test.js +137 -0
  29. package/dist/server/server/__tests__/sprint-routes.test.js +102 -0
  30. package/dist/server/server/__tests__/workflow-routes.test.js +107 -0
  31. package/dist/server/server/config-migrator.js +138 -0
  32. package/dist/server/server/config.js +17 -2
  33. package/dist/server/server/database.js +27 -12
  34. package/dist/server/server/global-config.js +143 -0
  35. package/dist/server/server/index.js +882 -252
  36. package/dist/server/server/init.js +579 -194
  37. package/dist/server/server/launch.js +29 -0
  38. package/dist/server/server/manifest-types.js +8 -0
  39. package/dist/server/server/manifest.js +454 -0
  40. package/dist/server/server/migrate-legacy.js +229 -0
  41. package/dist/server/server/parsers/event-parser.test.js +117 -0
  42. package/dist/server/server/parsers/scope-parser.js +74 -28
  43. package/dist/server/server/parsers/scope-parser.test.js +230 -0
  44. package/dist/server/server/project-context.js +255 -0
  45. package/dist/server/server/project-emitter.js +41 -0
  46. package/dist/server/server/project-manager.js +297 -0
  47. package/dist/server/server/routes/config-routes.js +1 -3
  48. package/dist/server/server/routes/data-routes.js +22 -110
  49. package/dist/server/server/routes/dispatch-routes.js +15 -9
  50. package/dist/server/server/routes/git-routes.js +74 -0
  51. package/dist/server/server/routes/manifest-routes.js +319 -0
  52. package/dist/server/server/routes/scope-routes.js +37 -23
  53. package/dist/server/server/routes/sync-routes.js +134 -0
  54. package/dist/server/server/routes/version-routes.js +1 -15
  55. package/dist/server/server/routes/workflow-routes.js +9 -3
  56. package/dist/server/server/schema.js +2 -0
  57. package/dist/server/server/services/batch-orchestrator.js +26 -16
  58. package/dist/server/server/services/claude-session-service.js +17 -14
  59. package/dist/server/server/services/deploy-service.test.js +119 -0
  60. package/dist/server/server/services/event-service.js +64 -1
  61. package/dist/server/server/services/event-service.test.js +191 -0
  62. package/dist/server/server/services/gate-service.test.js +105 -0
  63. package/dist/server/server/services/git-service.js +108 -4
  64. package/dist/server/server/services/github-service.js +110 -2
  65. package/dist/server/server/services/readiness-service.test.js +190 -0
  66. package/dist/server/server/services/scope-cache.js +5 -1
  67. package/dist/server/server/services/scope-cache.test.js +142 -0
  68. package/dist/server/server/services/scope-service.js +217 -126
  69. package/dist/server/server/services/scope-service.test.js +137 -0
  70. package/dist/server/server/services/sprint-orchestrator.js +7 -6
  71. package/dist/server/server/services/sprint-service.js +21 -1
  72. package/dist/server/server/services/sprint-service.test.js +238 -0
  73. package/dist/server/server/services/sync-service.js +434 -0
  74. package/dist/server/server/services/sync-types.js +2 -0
  75. package/dist/server/server/services/telemetry-service.js +143 -0
  76. package/dist/server/server/services/workflow-service.js +26 -5
  77. package/dist/server/server/services/workflow-service.test.js +159 -0
  78. package/dist/server/server/settings-sync.js +284 -0
  79. package/dist/server/server/update-planner.js +279 -0
  80. package/dist/server/server/utils/cc-hooks-parser.js +3 -0
  81. package/dist/server/server/utils/cc-hooks-parser.test.js +86 -0
  82. package/dist/server/server/utils/dispatch-utils.js +77 -20
  83. package/dist/server/server/utils/dispatch-utils.test.js +182 -0
  84. package/dist/server/server/utils/logger.js +37 -3
  85. package/dist/server/server/utils/package-info.js +30 -0
  86. package/dist/server/server/utils/route-helpers.js +10 -0
  87. package/dist/server/server/utils/terminal-launcher.js +79 -25
  88. package/dist/server/server/utils/worktree-manager.js +13 -4
  89. package/dist/server/server/validator.js +230 -0
  90. package/dist/server/server/watchers/global-watcher.js +63 -0
  91. package/dist/server/server/watchers/scope-watcher.js +27 -12
  92. package/dist/server/server/wizard/config-editor.js +237 -0
  93. package/dist/server/server/wizard/detect.js +96 -0
  94. package/dist/server/server/wizard/doctor.js +115 -0
  95. package/dist/server/server/wizard/index.js +155 -0
  96. package/dist/server/server/wizard/phases/confirm.js +39 -0
  97. package/dist/server/server/wizard/phases/project-setup.js +90 -0
  98. package/dist/server/server/wizard/phases/setup-wizard.js +66 -0
  99. package/dist/server/server/wizard/phases/welcome.js +35 -0
  100. package/dist/server/server/wizard/phases/workflow-setup.js +22 -0
  101. package/dist/server/server/wizard/types.js +29 -0
  102. package/dist/server/server/wizard/ui.js +74 -0
  103. package/dist/server/shared/__fixtures__/workflow-configs.js +75 -0
  104. package/dist/server/shared/default-workflow.json +65 -0
  105. package/dist/server/shared/onboarding-tour.test.js +81 -0
  106. package/dist/server/shared/project-colors.js +24 -0
  107. package/dist/server/shared/workflow-config.test.js +84 -0
  108. package/dist/server/shared/workflow-engine.test.js +302 -0
  109. package/dist/server/shared/workflow-normalizer.js +101 -0
  110. package/dist/server/shared/workflow-normalizer.test.js +100 -0
  111. package/dist/server/src/components/onboarding/tour-steps.js +84 -0
  112. package/package.json +20 -15
  113. package/schemas/orbital.config.schema.json +16 -1
  114. package/scripts/postinstall.js +55 -7
  115. package/server/__tests__/data-routes.test.ts +149 -0
  116. package/server/__tests__/helpers/db.ts +19 -0
  117. package/server/__tests__/helpers/mock-emitter.ts +10 -0
  118. package/server/__tests__/scope-routes.test.ts +157 -0
  119. package/server/__tests__/sprint-routes.test.ts +118 -0
  120. package/server/__tests__/workflow-routes.test.ts +120 -0
  121. package/server/config-migrator.ts +163 -0
  122. package/server/config.ts +26 -2
  123. package/server/database.ts +35 -18
  124. package/server/global-config.ts +200 -0
  125. package/server/index.ts +975 -287
  126. package/server/init.ts +625 -182
  127. package/server/launch.ts +32 -0
  128. package/server/manifest-types.ts +145 -0
  129. package/server/manifest.ts +494 -0
  130. package/server/migrate-legacy.ts +290 -0
  131. package/server/parsers/event-parser.test.ts +135 -0
  132. package/server/parsers/scope-parser.test.ts +270 -0
  133. package/server/parsers/scope-parser.ts +79 -31
  134. package/server/project-context.ts +309 -0
  135. package/server/project-emitter.ts +50 -0
  136. package/server/project-manager.ts +369 -0
  137. package/server/routes/config-routes.ts +3 -5
  138. package/server/routes/data-routes.ts +28 -141
  139. package/server/routes/dispatch-routes.ts +19 -11
  140. package/server/routes/git-routes.ts +77 -0
  141. package/server/routes/manifest-routes.ts +388 -0
  142. package/server/routes/scope-routes.ts +29 -25
  143. package/server/routes/sync-routes.ts +175 -0
  144. package/server/routes/version-routes.ts +1 -16
  145. package/server/routes/workflow-routes.ts +9 -3
  146. package/server/schema.ts +2 -0
  147. package/server/services/batch-orchestrator.ts +24 -16
  148. package/server/services/claude-session-service.ts +16 -14
  149. package/server/services/deploy-service.test.ts +145 -0
  150. package/server/services/deploy-service.ts +2 -2
  151. package/server/services/event-service.test.ts +242 -0
  152. package/server/services/event-service.ts +92 -3
  153. package/server/services/gate-service.test.ts +131 -0
  154. package/server/services/gate-service.ts +2 -2
  155. package/server/services/git-service.ts +137 -4
  156. package/server/services/github-service.ts +120 -2
  157. package/server/services/readiness-service.test.ts +217 -0
  158. package/server/services/scope-cache.test.ts +167 -0
  159. package/server/services/scope-cache.ts +4 -1
  160. package/server/services/scope-service.test.ts +169 -0
  161. package/server/services/scope-service.ts +220 -126
  162. package/server/services/sprint-orchestrator.ts +7 -7
  163. package/server/services/sprint-service.test.ts +271 -0
  164. package/server/services/sprint-service.ts +27 -3
  165. package/server/services/sync-service.ts +482 -0
  166. package/server/services/sync-types.ts +77 -0
  167. package/server/services/telemetry-service.ts +195 -0
  168. package/server/services/workflow-service.test.ts +190 -0
  169. package/server/services/workflow-service.ts +29 -9
  170. package/server/settings-sync.ts +359 -0
  171. package/server/update-planner.ts +346 -0
  172. package/server/utils/cc-hooks-parser.test.ts +96 -0
  173. package/server/utils/cc-hooks-parser.ts +4 -0
  174. package/server/utils/dispatch-utils.test.ts +245 -0
  175. package/server/utils/dispatch-utils.ts +97 -27
  176. package/server/utils/logger.ts +40 -3
  177. package/server/utils/package-info.ts +32 -0
  178. package/server/utils/route-helpers.ts +12 -0
  179. package/server/utils/terminal-launcher.ts +85 -25
  180. package/server/utils/worktree-manager.ts +9 -4
  181. package/server/validator.ts +270 -0
  182. package/server/watchers/global-watcher.ts +77 -0
  183. package/server/watchers/scope-watcher.ts +21 -9
  184. package/server/wizard/config-editor.ts +248 -0
  185. package/server/wizard/detect.ts +104 -0
  186. package/server/wizard/doctor.ts +114 -0
  187. package/server/wizard/index.ts +187 -0
  188. package/server/wizard/phases/confirm.ts +45 -0
  189. package/server/wizard/phases/project-setup.ts +106 -0
  190. package/server/wizard/phases/setup-wizard.ts +78 -0
  191. package/server/wizard/phases/welcome.ts +43 -0
  192. package/server/wizard/phases/workflow-setup.ts +28 -0
  193. package/server/wizard/types.ts +56 -0
  194. package/server/wizard/ui.ts +93 -0
  195. package/shared/__fixtures__/workflow-configs.ts +80 -0
  196. package/shared/default-workflow.json +65 -0
  197. package/shared/onboarding-tour.test.ts +94 -0
  198. package/shared/project-colors.ts +24 -0
  199. package/shared/workflow-config.test.ts +111 -0
  200. package/shared/workflow-config.ts +7 -0
  201. package/shared/workflow-engine.test.ts +388 -0
  202. package/shared/workflow-normalizer.test.ts +119 -0
  203. package/shared/workflow-normalizer.ts +118 -0
  204. package/templates/hooks/end-session.sh +3 -1
  205. package/templates/hooks/orbital-emit.sh +2 -2
  206. package/templates/hooks/orbital-report-deploy.sh +4 -4
  207. package/templates/hooks/orbital-report-gates.sh +4 -4
  208. package/templates/hooks/orbital-scope-update.sh +1 -1
  209. package/templates/hooks/scope-create-cleanup.sh +2 -2
  210. package/templates/hooks/scope-create-gate.sh +0 -1
  211. package/templates/hooks/scope-helpers.sh +18 -0
  212. package/templates/hooks/scope-prepare.sh +66 -11
  213. package/templates/migrations/renames.json +1 -0
  214. package/templates/orbital.config.json +7 -2
  215. package/templates/settings-hooks.json +1 -1
  216. package/templates/skills/git-commit/SKILL.md +9 -4
  217. package/templates/skills/git-dev/SKILL.md +8 -3
  218. package/templates/skills/git-main/SKILL.md +8 -2
  219. package/templates/skills/git-production/SKILL.md +6 -2
  220. package/templates/skills/git-staging/SKILL.md +8 -3
  221. package/templates/skills/scope-create/SKILL.md +17 -3
  222. package/templates/skills/scope-fix-review/SKILL.md +6 -3
  223. package/templates/skills/scope-implement/SKILL.md +4 -1
  224. package/templates/skills/scope-post-review/SKILL.md +63 -5
  225. package/templates/skills/scope-pre-review/SKILL.md +5 -2
  226. package/templates/skills/scope-verify/SKILL.md +5 -3
  227. package/templates/skills/test-code-review/SKILL.md +41 -33
  228. package/templates/skills/test-scaffold/SKILL.md +222 -0
  229. package/dist/assets/WorkflowVisualizer-BZ21PIIF.js +0 -84
  230. package/dist/assets/charts-D__PA1zp.js +0 -72
  231. package/dist/assets/index-D1G6i0nS.css +0 -1
  232. package/dist/assets/index-DpItvKpf.js +0 -419
  233. package/dist/assets/ui-BvF022GT.js +0 -53
  234. package/index.html +0 -15
  235. package/postcss.config.js +0 -6
  236. package/src/App.tsx +0 -33
  237. package/src/components/AgentBadge.tsx +0 -40
  238. package/src/components/BatchPreflightModal.tsx +0 -115
  239. package/src/components/CardDisplayToggle.tsx +0 -74
  240. package/src/components/ColumnHeaderActions.tsx +0 -55
  241. package/src/components/ColumnMenu.tsx +0 -99
  242. package/src/components/DeployHistory.tsx +0 -141
  243. package/src/components/DispatchModal.tsx +0 -164
  244. package/src/components/DispatchPopover.tsx +0 -139
  245. package/src/components/DragOverlay.tsx +0 -25
  246. package/src/components/DriftSidebar.tsx +0 -140
  247. package/src/components/EnvironmentStrip.tsx +0 -88
  248. package/src/components/ErrorBoundary.tsx +0 -62
  249. package/src/components/FilterChip.tsx +0 -105
  250. package/src/components/GateIndicator.tsx +0 -33
  251. package/src/components/IdeaDetailModal.tsx +0 -190
  252. package/src/components/IdeaFormDialog.tsx +0 -113
  253. package/src/components/KanbanColumn.tsx +0 -201
  254. package/src/components/MarkdownRenderer.tsx +0 -114
  255. package/src/components/NeonGrid.tsx +0 -128
  256. package/src/components/PromotionQueue.tsx +0 -89
  257. package/src/components/ScopeCard.tsx +0 -234
  258. package/src/components/ScopeDetailModal.tsx +0 -255
  259. package/src/components/ScopeFilterBar.tsx +0 -152
  260. package/src/components/SearchInput.tsx +0 -102
  261. package/src/components/SessionPanel.tsx +0 -335
  262. package/src/components/SprintContainer.tsx +0 -303
  263. package/src/components/SprintDependencyDialog.tsx +0 -78
  264. package/src/components/SprintPreflightModal.tsx +0 -138
  265. package/src/components/StatusBar.tsx +0 -168
  266. package/src/components/SwimCell.tsx +0 -67
  267. package/src/components/SwimLaneRow.tsx +0 -94
  268. package/src/components/SwimlaneBoardView.tsx +0 -108
  269. package/src/components/VersionBadge.tsx +0 -139
  270. package/src/components/ViewModeSelector.tsx +0 -114
  271. package/src/components/config/AgentChip.tsx +0 -53
  272. package/src/components/config/AgentCreateDialog.tsx +0 -321
  273. package/src/components/config/AgentEditor.tsx +0 -175
  274. package/src/components/config/DirectoryTree.tsx +0 -582
  275. package/src/components/config/FileEditor.tsx +0 -550
  276. package/src/components/config/HookChip.tsx +0 -50
  277. package/src/components/config/StageCard.tsx +0 -198
  278. package/src/components/config/TransitionZone.tsx +0 -173
  279. package/src/components/config/UnifiedWorkflowPipeline.tsx +0 -216
  280. package/src/components/config/WorkflowPipeline.tsx +0 -161
  281. package/src/components/source-control/BranchList.tsx +0 -93
  282. package/src/components/source-control/BranchPanel.tsx +0 -105
  283. package/src/components/source-control/CommitLog.tsx +0 -100
  284. package/src/components/source-control/CommitRow.tsx +0 -47
  285. package/src/components/source-control/GitHubPanel.tsx +0 -110
  286. package/src/components/source-control/GitHubSetupGuide.tsx +0 -52
  287. package/src/components/source-control/GitOverviewBar.tsx +0 -101
  288. package/src/components/source-control/PullRequestList.tsx +0 -69
  289. package/src/components/source-control/WorktreeList.tsx +0 -80
  290. package/src/components/ui/badge.tsx +0 -41
  291. package/src/components/ui/button.tsx +0 -55
  292. package/src/components/ui/card.tsx +0 -78
  293. package/src/components/ui/dialog.tsx +0 -94
  294. package/src/components/ui/popover.tsx +0 -33
  295. package/src/components/ui/scroll-area.tsx +0 -54
  296. package/src/components/ui/separator.tsx +0 -28
  297. package/src/components/ui/tabs.tsx +0 -52
  298. package/src/components/ui/toggle-switch.tsx +0 -35
  299. package/src/components/ui/tooltip.tsx +0 -27
  300. package/src/components/workflow/AddEdgeDialog.tsx +0 -217
  301. package/src/components/workflow/AddListDialog.tsx +0 -201
  302. package/src/components/workflow/ChecklistEditor.tsx +0 -239
  303. package/src/components/workflow/CommandPrefixManager.tsx +0 -118
  304. package/src/components/workflow/ConfigSettingsPanel.tsx +0 -189
  305. package/src/components/workflow/DirectionSelector.tsx +0 -133
  306. package/src/components/workflow/DispatchConfigPanel.tsx +0 -180
  307. package/src/components/workflow/EdgeDetailPanel.tsx +0 -236
  308. package/src/components/workflow/EdgePropertyEditor.tsx +0 -251
  309. package/src/components/workflow/EditToolbar.tsx +0 -138
  310. package/src/components/workflow/HookDetailPanel.tsx +0 -250
  311. package/src/components/workflow/HookExecutionLog.tsx +0 -24
  312. package/src/components/workflow/HookSourceModal.tsx +0 -129
  313. package/src/components/workflow/HooksDashboard.tsx +0 -363
  314. package/src/components/workflow/ListPropertyEditor.tsx +0 -251
  315. package/src/components/workflow/MigrationPreviewDialog.tsx +0 -237
  316. package/src/components/workflow/MovementRulesPanel.tsx +0 -188
  317. package/src/components/workflow/NodeDetailPanel.tsx +0 -245
  318. package/src/components/workflow/PresetSelector.tsx +0 -414
  319. package/src/components/workflow/SkillCommandBuilder.tsx +0 -174
  320. package/src/components/workflow/WorkflowEdgeComponent.tsx +0 -145
  321. package/src/components/workflow/WorkflowNode.tsx +0 -147
  322. package/src/components/workflow/graphLayout.ts +0 -186
  323. package/src/components/workflow/mergeHooks.ts +0 -85
  324. package/src/components/workflow/useEditHistory.ts +0 -88
  325. package/src/components/workflow/useWorkflowEditor.ts +0 -262
  326. package/src/components/workflow/validateConfig.ts +0 -70
  327. package/src/hooks/useActiveDispatches.ts +0 -198
  328. package/src/hooks/useBoardSettings.ts +0 -170
  329. package/src/hooks/useCardDisplay.ts +0 -57
  330. package/src/hooks/useCcHooks.ts +0 -24
  331. package/src/hooks/useConfigTree.ts +0 -51
  332. package/src/hooks/useEnforcementRules.ts +0 -46
  333. package/src/hooks/useEvents.ts +0 -59
  334. package/src/hooks/useFileEditor.ts +0 -165
  335. package/src/hooks/useGates.ts +0 -57
  336. package/src/hooks/useIdeaActions.ts +0 -53
  337. package/src/hooks/useKanbanDnd.ts +0 -410
  338. package/src/hooks/useOrbitalConfig.ts +0 -54
  339. package/src/hooks/usePipeline.ts +0 -47
  340. package/src/hooks/usePipelineData.ts +0 -338
  341. package/src/hooks/useReconnect.ts +0 -25
  342. package/src/hooks/useScopeFilters.ts +0 -125
  343. package/src/hooks/useScopeSessions.ts +0 -44
  344. package/src/hooks/useScopes.ts +0 -67
  345. package/src/hooks/useSearch.ts +0 -67
  346. package/src/hooks/useSettings.tsx +0 -187
  347. package/src/hooks/useSocket.ts +0 -25
  348. package/src/hooks/useSourceControl.ts +0 -105
  349. package/src/hooks/useSprintPreflight.ts +0 -55
  350. package/src/hooks/useSprints.ts +0 -154
  351. package/src/hooks/useStatusBarHighlight.ts +0 -18
  352. package/src/hooks/useSwimlaneBoardSettings.ts +0 -104
  353. package/src/hooks/useTheme.ts +0 -9
  354. package/src/hooks/useTransitionReadiness.ts +0 -53
  355. package/src/hooks/useVersion.ts +0 -155
  356. package/src/hooks/useViolations.ts +0 -65
  357. package/src/hooks/useWorkflow.tsx +0 -125
  358. package/src/hooks/useZoomModifier.ts +0 -19
  359. package/src/index.css +0 -797
  360. package/src/layouts/DashboardLayout.tsx +0 -113
  361. package/src/lib/collisionDetection.ts +0 -20
  362. package/src/lib/scope-fields.ts +0 -61
  363. package/src/lib/swimlane.ts +0 -146
  364. package/src/lib/utils.ts +0 -15
  365. package/src/main.tsx +0 -19
  366. package/src/socket.ts +0 -11
  367. package/src/types/index.ts +0 -497
  368. package/src/views/AgentFeed.tsx +0 -339
  369. package/src/views/DeployPipeline.tsx +0 -59
  370. package/src/views/EnforcementView.tsx +0 -378
  371. package/src/views/PrimitivesConfig.tsx +0 -500
  372. package/src/views/QualityGates.tsx +0 -1012
  373. package/src/views/ScopeBoard.tsx +0 -454
  374. package/src/views/SessionTimeline.tsx +0 -516
  375. package/src/views/Settings.tsx +0 -183
  376. package/src/views/SourceControl.tsx +0 -95
  377. package/src/views/WorkflowVisualizer.tsx +0 -382
  378. package/tailwind.config.js +0 -161
  379. package/tsconfig.json +0 -25
  380. package/vite.config.ts +0 -49
@@ -0,0 +1,32 @@
1
+ import{E as Ct,j as e,L as et,G as tt,H as st}from"./ui-BmsSg9jU.js";import{a as c,b as St}from"./vendor-Bqt8AJn2.js";import{c as be,s as ee,a as R,E as Et,T as Mt,S as Pt,X as rt,u as Ce,b as De,P as ot,d as nt,e as Le,f as Se,C as ke,g as ye,B as se,h as ge,i as Tt,j as $t,k as at,W as Ht,l as Rt,A as Ft,m as Ot,n as Ne,o as lt,p as At,G as Dt,L as Lt,q as It,r as Bt,t as _t,v as Wt,D as zt,w as Gt,x as ze,y as Ut,z as Vt}from"./index-Bc9dK3MW.js";import{C as Jt,Z as Ee}from"./zap-DfbUoOty.js";import{B as Me,P as it,S as Kt,u as Yt}from"./useWorkflowEditor-BJkTX_NR.js";import{F as Ge}from"./file-text-C46Xr65c.js";import{A as Ue}from"./arrow-down-CPy85_J6.js";import{G as qt}from"./globe-Cn2yNZUD.js";import"./charts-DbDg0Psc.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Zt=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],Ve=be("corner-down-left",Zt);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Xt=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],ct=be("file",Xt);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Qt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],dt=be("folder-open",Qt);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const es=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ft=be("folder",es);/**
22
+ * @license lucide-react v0.577.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const ts=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],ss=be("timer",ts);function rs(t){const[o,r]=c.useState(null),[s,l]=c.useState(!1),[n,a]=c.useState(null),i=c.useCallback(async()=>{if(!t){r(null),a(null),l(!1);return}l(!0),a(null);try{const f=await fetch(`/api/orbital/sync/state/${t}`);f.ok?r(await f.json()):a(`Sync state fetch failed (HTTP ${f.status})`)}catch(f){a(f instanceof Error?f.message:"Sync state fetch failed")}finally{l(!1)}},[t]);return c.useEffect(()=>{i()},[i]),c.useEffect(()=>{const f=()=>i();return ee.on("sync:file:updated",f),ee.on("sync:file:created",f),ee.on("sync:file:deleted",f),()=>{ee.off("sync:file:updated",f),ee.off("sync:file:created",f),ee.off("sync:file:deleted",f)}},[i]),{report:o,loading:s,error:n,refetch:i}}function os(){const[t,o]=c.useState(null),[r,s]=c.useState(!1),[l,n]=c.useState(null),a=c.useCallback(async()=>{s(!0),n(null);try{const i=await fetch("/api/orbital/sync/global-state");i.ok?o(await i.json()):n(`Global sync state fetch failed (HTTP ${i.status})`)}catch(i){n(i instanceof Error?i.message:"Global sync state fetch failed")}finally{s(!1)}},[]);return c.useEffect(()=>{a()},[a]),c.useEffect(()=>{const i=()=>a();return ee.on("sync:file:updated",i),ee.on("sync:file:created",i),ee.on("sync:file:deleted",i),()=>{ee.off("sync:file:updated",i),ee.off("sync:file:created",i),ee.off("sync:file:deleted",i)}},[a]),{report:t,loading:r,error:l,refetch:a}}async function ns(t,o,r){return(await fetch("/api/orbital/sync/resolve-drift",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:t,relativePath:o,resolution:r})})).ok}const as=Ct,ut=c.forwardRef(({className:t,...o},r)=>e.jsx(et,{ref:r,className:R("card-glass inline-flex h-8 items-center justify-center rounded bg-surface p-0.5 border border-border text-muted-foreground",t),...o}));ut.displayName=et.displayName;const ht=c.forwardRef(({className:t,...o},r)=>e.jsx(tt,{ref:r,className:R("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-2.5 py-1 text-xxs uppercase tracking-wider font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-surface-light data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...o}));ht.displayName=tt.displayName;const ls=c.forwardRef(({className:t,...o},r)=>e.jsx(st,{ref:r,className:R("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...o}));ls.displayName=st.displayName;const mt={guard:{icon:Pt,bg:"bg-red-500/10",border:"border-red-500/30",text:"text-red-400",hex:"#ef4444"},gate:{icon:Mt,bg:"bg-amber-500/10",border:"border-amber-500/30",text:"text-amber-400",hex:"#f59e0b"},lifecycle:{icon:Jt,bg:"bg-cyan-500/10",border:"border-cyan-500/30",text:"text-cyan-400",hex:"#06b6d4"},observer:{icon:Et,bg:"bg-zinc-500/10",border:"border-zinc-500/30",text:"text-zinc-400",hex:"#71717a"}};function Ie({hook:t,selected:o,onClick:r,onRemove:s}){const l=mt[t.category],n=l.icon;return e.jsxs("button",{type:"button",onClick:r,"data-pipeline-path":t.filePath??void 0,className:R("inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",l.bg,l.border,l.text,"hover:brightness-125 cursor-pointer",o&&"glow-selected-pulse"),style:o?{"--glow-color":`${l.hex}A0`,"--glow-color-wide":`${l.hex}40`}:void 0,children:[e.jsx(n,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[120px]",children:t.id}),s&&e.jsx("span",{role:"button",onClick:a=>{a.stopPropagation(),s()},className:"ml-0.5 rounded-full p-0.5 hover:bg-red-500/20",children:e.jsx(rt,{className:"h-2.5 w-2.5"})})]})}function Re({node:t,depth:o,selectedPath:r,expandedPaths:s,primitiveType:l,onSelect:n,onToggle:a,onContextAction:i,hookCategoryMap:f,agentTeamMap:g,dimmed:P}){var V,Y;const x=t.type==="folder",N=s.has(t.path),j=t.path===r,h=(V=t.frontmatter)!=null&&V.name?String(t.frontmatter.name):t.name,p=x?"":`tree::${l}::${t.path}`,{attributes:k,listeners:D,setNodeRef:K,isDragging:w}=Se({id:p,disabled:x,data:{type:l,path:t.path,name:h}}),H=()=>{x?a(t.path):n(t)},B=x||f==null?void 0:f.get(t.path),z=B?mt[B]:void 0,le=z==null?void 0:z.icon,y=x||g==null?void 0:g.get(t.path),_=j&&!x?B?{guard:"#ef4444",gate:"#f59e0b",lifecycle:"#06b6d4",observer:"#71717a"}[B]:y?y.color:l==="skills"?"#22c55e":"#00bcd4":void 0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:x?void 0:K,"data-tree-path":x?void 0:t.path,className:R("group flex w-full items-center rounded text-left text-xs transition-colors",j&&_?"glow-selected":j?"bg-[#00bcd4]/15 text-[#00bcd4]":"text-muted-foreground hover:bg-surface-light hover:text-foreground",w&&"opacity-40",P&&!j&&"opacity-50"),style:_?{"--glow-color":`${_}50`,backgroundColor:`${_}18`,color:_}:void 0,...x?{}:{...D,...k},children:[e.jsxs("button",{onClick:H,className:"flex flex-1 min-w-0 items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${o*12+8}px`},children:[x?e.jsxs(e.Fragment,{children:[N?e.jsx(ke,{className:"h-3 w-3 shrink-0 opacity-60"}):e.jsx(ye,{className:"h-3 w-3 shrink-0 opacity-60"}),N?e.jsx(dt,{className:"h-3.5 w-3.5 shrink-0 text-warning-amber/70"}):e.jsx(ft,{className:"h-3.5 w-3.5 shrink-0 text-warning-amber/70"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-3"}),e.jsx(ct,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]}),e.jsx("span",{className:"min-w-0 truncate",children:h}),z&&le&&e.jsxs("span",{className:R("inline-flex shrink-0 items-center gap-0.5 rounded border px-1 py-0 text-[9px] font-medium",z.bg,z.border,z.text),children:[e.jsx(le,{className:"h-2.5 w-2.5"}),B]}),y&&e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded border px-1 py-0 text-[9px] font-medium",style:{color:y.color,borderColor:`${y.color}4D`,backgroundColor:`${y.color}1A`},children:[e.jsx(Me,{className:"h-2.5 w-2.5"}),y.team]})]}),e.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:W=>{W.stopPropagation(),i("rename",t)},className:"rounded p-0.5 hover:bg-surface-light",title:"Rename",children:e.jsx(it,{className:"h-3 w-3"})}),t.type==="file"&&e.jsx("button",{onClick:W=>{W.stopPropagation(),i("delete",t)},className:"rounded p-0.5 hover:bg-ask-red/20 text-muted-foreground hover:text-ask-red",title:"Delete",children:e.jsx(Le,{className:"h-3 w-3"})}),t.type==="folder"&&e.jsx("button",{onClick:W=>{W.stopPropagation(),i("new-file",t)},className:"rounded p-0.5 hover:bg-surface-light",title:"New file",children:e.jsx(ot,{className:"h-3 w-3"})})]})]}),x&&N&&((Y=t.children)==null?void 0:Y.map(W=>e.jsx(Re,{node:W,depth:o+1,selectedPath:r,expandedPaths:s,primitiveType:l,onSelect:n,onToggle:a,onContextAction:i,hookCategoryMap:f,agentTeamMap:g,dimmed:P},W.path)))]})}const is=[{value:"agents",icon:Me,label:"Agents"},{value:"skills",icon:De,label:"Skills"},{value:"hooks",icon:Ee,label:"Hooks"}];function Je(t){const o=[];function r(s){for(const l of s)l.type==="file"&&o.push(l),l.children&&r(l.children)}return r(t),o.sort((s,l)=>{var i,f;const n=(i=s.frontmatter)!=null&&i.name?String(s.frontmatter.name):s.name,a=(f=l.frontmatter)!=null&&f.name?String(l.frontmatter.name):l.name;return n.localeCompare(a)})}function cs({tree:t,loading:o,selectedPath:r,type:s,onSelect:l,onRefresh:n,onTabChange:a,activePaths:i,hookCategoryMap:f,agentTeamMap:g}){const[P,x]=c.useState(new Set),N=Ce(),[j,h]=c.useState(null),[p,k]=c.useState(null),[D,K]=c.useState(""),[w,H]=c.useState(null),[B,z]=c.useState("");c.useEffect(()=>{r&&requestAnimationFrame(()=>{const u=document.querySelector(`[data-tree-path="${CSS.escape(r)}"]`);u==null||u.scrollIntoView({behavior:"smooth",block:"nearest"})})},[r]);const le=s==="skills"?Je(t):t,{activeFiles:y,inactiveFiles:T}=c.useMemo(()=>{if(!i)return{activeFiles:null,inactiveFiles:null};const u=Je(t),d=[],m=[];for(const F of u)i.has(F.path)?d.push(F):m.push(F);return{activeFiles:d,inactiveFiles:m}},[t,i]),_=c.useCallback(u=>{x(d=>{const m=new Set(d);return m.has(u)?m.delete(u):m.add(u),m})},[]),V=c.useCallback((u,d)=>{u.preventDefault(),h({node:d,x:u.clientX,y:u.clientY})},[]),Y=c.useCallback(()=>{h(null)},[]),W=c.useCallback(u=>{k(u),K(u.name),h(null)},[]),fe=c.useCallback(async()=>{if(!p||!D.trim()||D===p.name){k(null);return}const u=p.path.includes("/")?p.path.slice(0,p.path.lastIndexOf("/")):"",d=u?`${u}/${D}`:D;try{if(!(await fetch(N(`/config/${s}/rename`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:p.path,newPath:d})})).ok)throw new Error("Rename failed");n()}catch{}k(null)},[p,D,s,n,N]),ue=c.useCallback(async u=>{h(null);try{if(!(await fetch(N(`/config/${s}/file?path=${encodeURIComponent(u.path)}`),{method:"DELETE"})).ok)throw new Error("Delete failed");n()}catch{}},[s,n,N]),G=c.useCallback((u,d)=>{H({kind:u,parent:d}),z(""),h(null)},[]),ne=c.useCallback((u,d)=>{u==="rename"?W(d):u==="delete"?ue(d):u==="new-file"?G("file",d.path):u==="new-folder"&&G("folder",d.path)},[W,ue,G]),b=c.useCallback(async()=>{if(!w||!B.trim()){H(null);return}const u=w.parent?`${w.parent}/${B}`:B;try{if(w.kind==="folder"){if(!(await fetch(N(`/config/${s}/folder`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:u})})).ok)throw new Error("Create folder failed")}else if(!(await fetch(N(`/config/${s}/file`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:u,content:""})})).ok)throw new Error("Create file failed");n()}catch{}H(null)},[w,B,s,n,N]),xe=(u,d)=>e.jsx("div",{onContextMenu:m=>V(m,u),children:e.jsx(Re,{node:u,depth:0,selectedPath:r,expandedPaths:P,primitiveType:s,onSelect:l,onToggle:_,onContextAction:ne,hookCategoryMap:f,agentTeamMap:g,dimmed:d})},u.path);return e.jsxs("div",{className:"flex h-full flex-col",onClick:Y,children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1.5",children:[e.jsx(as,{value:s,onValueChange:u=>a(u),children:e.jsx(ut,{children:is.map(({value:u,icon:d,label:m})=>e.jsxs(ht,{value:u,className:"gap-1.5",children:[e.jsx(d,{className:"h-3 w-3"}),m]},u))})}),e.jsx("button",{onClick:()=>G("file",""),className:"rounded p-1 text-muted-foreground hover:bg-surface-light hover:text-foreground transition-colors",title:"New file",children:e.jsx(ot,{className:"h-3.5 w-3.5"})})]}),e.jsx(nt,{className:"flex-1",children:e.jsxs("div",{className:"py-1",children:[o?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):t.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground/60",children:"No files found"}):y&&T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2 pb-1",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500/70"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-emerald-400/80",children:"Active"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/30",children:["(",y.length,")"]}),e.jsx("div",{className:"flex-1 border-t border-emerald-500/15"})]}),y.length===0?e.jsxs("div",{className:"px-3 py-2 text-[10px] text-muted-foreground/40 italic",children:["No active ",s]}):y.map(u=>xe(u)),e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-3 pb-1",children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-muted-foreground/30"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/40",children:"Inactive"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/20",children:["(",T.length,")"]}),e.jsx("div",{className:"flex-1 border-t border-border/20"})]}),T.length===0?e.jsxs("div",{className:"px-3 py-2 text-[10px] text-muted-foreground/40 italic",children:["All ",s," are active"]}):T.map(u=>xe(u,!0))]}):le.map(u=>e.jsx("div",{onContextMenu:d=>V(d,u),children:e.jsx(Re,{node:u,depth:0,selectedPath:r,expandedPaths:P,primitiveType:s,onSelect:l,onToggle:_,onContextAction:ne,hookCategoryMap:f,agentTeamMap:g})},u.path)),p&&e.jsx("div",{className:"px-3 py-1",children:e.jsx("input",{autoFocus:!0,value:D,onChange:u=>K(u.target.value),onKeyDown:u=>{u.key==="Enter"&&fe(),u.key==="Escape"&&k(null)},onBlur:fe,className:"w-full rounded border border-accent-blue/40 bg-surface px-2 py-0.5 text-xs text-foreground outline-none",placeholder:"New name"})}),w&&e.jsx("div",{className:"px-3 py-1",children:e.jsx("input",{autoFocus:!0,value:B,onChange:u=>z(u.target.value),onKeyDown:u=>{u.key==="Enter"&&b(),u.key==="Escape"&&H(null)},onBlur:b,className:"w-full rounded border border-accent-blue/40 bg-surface px-2 py-0.5 text-xs text-foreground outline-none",placeholder:w.kind==="folder"?"Folder name":"File name"})})]})}),j&&St.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:Y}),e.jsxs("div",{className:"fixed z-50 min-w-[140px] rounded border border-border bg-surface shadow-lg",style:{top:j.y,left:j.x},onClick:u=>u.stopPropagation(),children:[e.jsxs("button",{onClick:()=>W(j.node),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(it,{className:"h-3 w-3"}),"Rename"]}),j.node.type==="folder"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>G("file",j.node.path),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(ct,{className:"h-3 w-3"}),"New File"]}),e.jsxs("button",{onClick:()=>G("folder",j.node.path),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-surface-light transition-colors",children:[e.jsx(ft,{className:"h-3 w-3"}),"New Folder"]})]}),e.jsx("div",{className:"border-t border-border"}),j.node.type==="file"&&e.jsxs("button",{onClick:()=>ue(j.node),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-ask-red hover:bg-surface-light transition-colors",children:[e.jsx(Le,{className:"h-3 w-3"}),"Delete"]})]})]}),document.body)]})}function ds({filePath:t,content:o,setContent:r,frontmatter:s,setFrontmatterField:l,body:n,setBody:a,dirty:i,saving:f,loading:g,error:P,onSave:x}){const N=c.useCallback(p=>{(p.metaKey||p.ctrlKey)&&p.key==="s"&&(p.preventDefault(),i&&!f&&x())},[i,f,x]);if(c.useEffect(()=>(window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)),[N]),!t)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx(Ge,{className:"h-10 w-10 text-muted-foreground/30"}),e.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Select a file to edit"})]})});if(g)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})});const j=Object.keys(s),h=j.length>0;return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ge,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-xs text-foreground",children:t}),i&&e.jsx(se,{variant:"warning",className:"shrink-0 text-[10px] px-1 py-0",children:"unsaved"})]}),e.jsxs(ge,{variant:"default",size:"sm",disabled:!i||f,onClick:x,className:"shrink-0",children:[e.jsx(Kt,{className:"mr-1.5 h-3.5 w-3.5"}),f?"Saving...":"Save"]})]}),P&&e.jsxs("div",{className:"flex items-center gap-2 border-b border-red-500/20 bg-red-500/10 px-3 py-1.5 text-xs text-ask-red",children:[e.jsx(Tt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:P})]}),h&&e.jsxs("div",{className:"space-y-2 border-b border-border px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Frontmatter"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx("div",{className:"grid gap-2",children:j.map(p=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"w-28 shrink-0 text-right text-xxs text-muted-foreground",children:p}),e.jsx("input",{value:s[p]??"",onChange:k=>l(p,k.target.value),className:R("flex-1 rounded border border-border bg-surface px-2 py-1 text-xs text-foreground","outline-none focus:border-accent-blue/50 transition-colors")})]},p))})]}),e.jsxs("div",{className:"flex flex-1 flex-col min-h-0 p-3",children:[h&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Content"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx(bs,{value:n,onChange:a,filePath:t})]})]})}const Ke="'JetBrains Mono', 'SF Mono', 'Fira Code', monospace";function fs(t){return t?t.endsWith(".sh")?"shell":t.endsWith(".md")?"markdown":t.endsWith(".yml")||t.endsWith(".yaml")?"yaml":t.endsWith(".json")||t.endsWith(".jsonc")?"json":"text":"text"}const C={comment:"#6B7280",keyword:"#e91e63",string:"#00c853",number:"#ffab00",variable:"#40c4ff",heading:"#00bcd4",bold:"#e0e0e0",operator:"#e91e63",key:"#40c4ff",builtin:"#536dfe",link:"#8B5CF6",punctuation:"#6B7280"};function us(t,o){return o==="text"?[{text:t}]:o==="shell"?ms(t):o==="markdown"?xs(t):o==="yaml"?ps(t):o==="json"?gs(t):[{text:t}]}const hs=new Set(["if","then","else","elif","fi","for","in","do","done","while","until","case","esac","function","return","exit","local","export","readonly","source","set","unset","shift","break","continue","true","false"]);function ms(t){const o=[];if(t.trimStart().startsWith("#"))return[{text:t,color:C.comment,italic:!0}];let s=0;for(;s<t.length;){if(t[s]==="#"&&(s===0||/\s/.test(t[s-1]))){o.push({text:t.slice(s),color:C.comment,italic:!0});break}if(t[s]==='"'){const a=Fe(t,s,'"');o.push({text:t.slice(s,a),color:C.string}),s=a;continue}if(t[s]==="'"){const a=Fe(t,s,"'");o.push({text:t.slice(s,a),color:C.string}),s=a;continue}if(t[s]==="$"){if(t[s+1]==="{"){const a=t.indexOf("}",s+2),i=a===-1?t.length:a+1;o.push({text:t.slice(s,i),color:C.variable}),s=i}else if(t[s+1]==="(")o.push({text:"$(",color:C.variable}),s+=2;else{const a=t.slice(s).match(/^\$[A-Za-z_]\w*/);a?(o.push({text:a[0],color:C.variable}),s+=a[0].length):(o.push({text:"$",color:C.variable}),s++)}continue}if("|&;><".includes(t[s])){let a=t[s];s+1<t.length&&(t.slice(s,s+2)==="||"||t.slice(s,s+2)==="&&"||t.slice(s,s+2)===">>"||t.slice(s,s+2)==="<<")&&(a=t.slice(s,s+2)),o.push({text:a,color:C.operator}),s+=a.length;continue}const l=t.slice(s).match(/^[A-Za-z_]\w*/);if(l){const a=l[0];hs.has(a)?o.push({text:a,color:C.keyword,bold:!0}):o.push({text:a}),s+=a.length;continue}const n=t.slice(s).match(/^\d+/);if(n){o.push({text:n[0],color:C.number}),s+=n[0].length;continue}o.push({text:t[s]}),s++}return o}function xs(t){const o=t.trimStart();if(o.match(/^(#{1,6})\s/))return[{text:t,color:C.heading,bold:!0}];if(o.startsWith("```"))return[{text:t,color:C.builtin}];if(o.startsWith("<!--"))return[{text:t,color:C.comment,italic:!0}];if(/^(\s*[-*+]|\s*\d+\.)\s/.test(t)){const s=t.match(/^(\s*[-*+\d.]+\s)(.*)$/);if(s)return[{text:s[1],color:C.operator},...Ye(s[2])]}return Ye(t)}function Ye(t){const o=[];let r=0;for(;r<t.length;){if(t[r]==="`"){const s=t.indexOf("`",r+1);if(s!==-1){o.push({text:t.slice(r,s+1),color:C.builtin}),r=s+1;continue}}if(t.slice(r,r+2)==="**"){const s=t.indexOf("**",r+2);if(s!==-1){o.push({text:t.slice(r,s+2),color:C.bold,bold:!0}),r=s+2;continue}}if(t[r]==="["){const s=t.slice(r).match(/^\[([^\]]*)\]\(([^)]*)\)/);if(s){o.push({text:`[${s[1]}]`,color:C.heading}),o.push({text:`(${s[2]})`,color:C.link}),r+=s[0].length;continue}}o.push({text:t[r]}),r++}return o}function ps(t){if(t.trimStart().startsWith("#"))return[{text:t,color:C.comment,italic:!0}];const r=t.match(/^(\s*)([\w.-]+)(:)(.*)/);if(r){const s=[{text:r[1]},{text:r[2],color:C.key},{text:r[3],color:C.punctuation}],l=r[4];return l&&s.push(...qe(l)),s}if(/^\s*-\s/.test(t)){const s=t.match(/^(\s*-\s)(.*)/);if(s)return[{text:s[1],color:C.operator},...qe(s[2])]}return[{text:t}]}function qe(t){const o=t.trim();if(!o)return[{text:t}];if(/^["']/.test(o))return[{text:t,color:C.string}];if(/^(true|false|null|yes|no)$/i.test(o))return[{text:t,color:C.keyword}];if(/^-?\d+(\.\d+)?$/.test(o))return[{text:t,color:C.number}];if(o.startsWith("#"))return[{text:t,color:C.comment,italic:!0}];const r=t.indexOf(" #");return r!==-1?[{text:t.slice(0,r)},{text:t.slice(r),color:C.comment,italic:!0}]:[{text:t,color:C.string}]}function gs(t){const o=[];let r=0;for(;r<t.length;){if(t[r]==='"'){const n=Fe(t,r,'"'),a=t.slice(r,n),f=t.slice(n).trimStart().startsWith(":")?C.key:C.string;o.push({text:a,color:f}),r=n;continue}const s=t.slice(r).match(/^-?\d+(\.\d+)?([eE][+-]?\d+)?/);if(s){o.push({text:s[0],color:C.number}),r+=s[0].length;continue}const l=t.slice(r).match(/^(true|false|null)\b/);if(l){o.push({text:l[0],color:C.keyword}),r+=l[0].length;continue}if("{}[]:,".includes(t[r])){o.push({text:t[r],color:C.punctuation}),r++;continue}o.push({text:t[r]}),r++}return o}function Fe(t,o,r){let s=o+1;for(;s<t.length;){if(t[s]==="\\"){s+=2;continue}if(t[s]===r)return s+1;s++}return t.length}function bs({value:t,onChange:o,filePath:r}){const s=c.useRef(null),l=c.useRef(null),n=c.useRef(null),a=c.useMemo(()=>fs(r),[r]),i=c.useMemo(()=>t.split(`
27
+ `),[t]),f=c.useMemo(()=>i.map(x=>us(x,a)),[i,a]),g=c.useCallback(()=>{const x=s.current;l.current&&(l.current.scrollTop=(x==null?void 0:x.scrollTop)??0),n.current&&(n.current.scrollTop=(x==null?void 0:x.scrollTop)??0,n.current.scrollLeft=(x==null?void 0:x.scrollLeft)??0)},[]),P={fontFamily:Ke,fontSize:"12px",lineHeight:"1.625",padding:"12px",tabSize:2};return e.jsxs("div",{className:"flex flex-1 overflow-hidden rounded border border-border bg-surface transition-colors focus-within:border-accent-blue/50",style:{fontFamily:Ke},children:[e.jsx("div",{ref:l,"aria-hidden":!0,className:"select-none overflow-hidden border-r border-border py-3 pl-2 pr-3 text-right text-muted-foreground/40",style:{fontSize:"12px",lineHeight:"1.625"},children:i.map((x,N)=>e.jsx("div",{children:N+1},N))}),e.jsxs("div",{className:"relative flex-1 min-w-0 overflow-hidden",children:[e.jsx("pre",{ref:n,"aria-hidden":!0,className:"absolute inset-0 overflow-hidden whitespace-pre pointer-events-none m-0",style:P,children:f.map((x,N)=>e.jsx("div",{children:x.length===0?" ":x.map((j,h)=>e.jsx("span",{style:{color:j.color,fontWeight:j.bold?600:void 0,fontStyle:j.italic?"italic":void 0},children:j.text},h))},N))}),e.jsx("textarea",{ref:s,value:t,onChange:x=>o(x.target.value),onScroll:g,className:"relative z-10 w-full h-full resize-none bg-transparent outline-none",style:{...P,color:"transparent",caretColor:"hsl(0 0% 88%)",WebkitTextFillColor:"transparent"},spellCheck:!1})]})]})}const js={synced:{color:"bg-emerald-500",label:"Synced",title:"Synced with global"},override:{color:"bg-blue-500",label:"Override",title:"Project override — not tracking global"},drifted:{color:"bg-amber-500",label:"Drifted",title:"Modified outside dashboard — needs resolution"},absent:{color:"bg-muted-foreground/30",label:"Absent",title:"Not present in this project"}};function ws({state:t,className:o}){const r=js[t];return e.jsxs("span",{className:R("inline-flex items-center gap-1",o),title:r.title,children:[e.jsx("span",{className:R("h-2 w-2 rounded-full shrink-0",r.color)}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:r.label})]})}function vs(){const{report:t,loading:o}=os();return o||!t?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):t.projects.length===0?e.jsxs("div",{className:"text-sm text-muted-foreground p-4",children:["No projects registered. Use ",e.jsx("code",{children:"orbital register"})," to add projects."]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsx("th",{className:"text-left py-2 px-3 font-medium text-muted-foreground",children:"File"}),t.projects.map(r=>e.jsx("th",{className:"text-center py-2 px-3 font-medium text-muted-foreground",children:r.projectName},r.projectId))]})}),e.jsx("tbody",{children:t.files.map(r=>e.jsxs("tr",{className:"border-b border-border/20 hover:bg-muted/20",children:[e.jsx("td",{className:"py-1.5 px-3 font-mono text-[11px] text-foreground/80",children:r}),t.projects.map(s=>e.jsx("td",{className:"py-1.5 px-3 text-center",children:e.jsx(ws,{state:s.states[r]??"absent"})},s.projectId))]},r))})]})})}function ks({projectId:t,relativePath:o,onResolved:r,onCancel:s}){const[l,n]=c.useState(!1),[a,i]=c.useState(null);async function f(g){n(!0),i(null);try{await ns(t,o,g)?r():i("Failed to resolve drift. Please try again.")}catch{i("Failed to resolve drift. Please try again.")}finally{n(!1)}}return e.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-amber-400",children:"Drift Detected"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This file was synced with global but has been modified outside the dashboard."}),a&&e.jsx("p",{className:"text-xs text-destructive",children:a}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{onClick:()=>f("reset-global"),disabled:l,className:"rounded border border-border bg-muted px-3 py-1.5 text-xs hover:bg-muted/80 transition-colors disabled:opacity-50",children:l?"Resolving…":"Reset to Global"}),e.jsx("button",{onClick:()=>f("pin-override"),disabled:l,className:"rounded border border-blue-500/30 bg-blue-500/10 px-3 py-1.5 text-xs text-blue-400 hover:bg-blue-500/20 transition-colors disabled:opacity-50",children:l?"Resolving…":"Pin as Override"}),e.jsx("button",{onClick:s,disabled:l,className:"ml-auto rounded px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:"Later"})]})]})}function ve(t){const[o,r]=c.useState([]),[s,l]=c.useState(!0),n=Ce(),a=c.useCallback(async()=>{try{const i=await fetch(n(`/config/${t}/tree`));if(!i.ok)throw new Error(`HTTP ${i.status}`);const f=await i.json();r(f.data??[])}catch{r([])}finally{l(!1)}},[t,n]);return c.useEffect(()=>{l(!0),a()},[a]),$t(a),c.useEffect(()=>{const i=`config:${t}:changed`,f=()=>{a()},g=i;return ee.on(g,f),()=>{ee.off(g,f)}},[t,a]),{tree:o,loading:s,refresh:a}}function xt(t){const o=new Set;for(const r of t)if(r.type==="file"&&o.add(r.path),r.children)for(const s of xt(r.children))o.add(s);return o}function Oe(t){const o=new Map;for(const r of t){if(r.type==="file"){const s=r.path.split("/");if(s.length>=2){const n=s[s.length-2].toLowerCase();o.has(n)||o.set(n,r.path)}const l=r.name.replace(/\.(md|sh)$/,"").toLowerCase();o.has(l)||o.set(l,r.path)}if(r.children){const s=Oe(r.children);for(const[l,n]of s)o.has(l)||o.set(l,n)}}return o}function Ze(t){return t?t.replace(/^\//,"").replace(/\s+\{.*\}$/,"").toLowerCase():null}function He(t,o){return{id:t.id,label:t.label,category:t.category,enforcement:Rt(t),filePath:o.get(t.id)??null,timing:t.timing,blocking:t.blocking??!1,description:t.description}}function pt(t){const{engine:o}=at(),{tree:r}=ve("skills"),{tree:s}=ve("hooks"),{tree:l}=ve("agents");return c.useMemo(()=>{var xe,u;const n=t?new Ht(t):o,a=n.getLists(),i=n.getAllEdges(),f=n.getAllHooks(),g=Oe(r),P=Oe(l),x=xt(s),N=".claude/hooks/",j=new Map;for(const d of f){const m=d.target.startsWith(N)?d.target.slice(N.length):d.target;x.has(m)&&j.set(d.id,m)}const h=new Map(f.map(d=>[d.id,d])),p=a.map(d=>d.id),k=new Map;for(const d of a){const m=new Set(d.activeHooks??[]);for(const F of m)k.set(F,(k.get(F)??0)+1)}const D=new Map;for(const d of p)D.set(d,new Set);for(const d of i)for(const m of d.hooks??[])(xe=D.get(d.from))==null||xe.add(m),(u=D.get(d.to))==null||u.add(m);for(const[,d]of D)for(const m of d)k.set(m,(k.get(m)??0)+1);const K=Math.max(1,p.length-1),w=new Set;for(const[d,m]of k)m>=K&&w.add(d);const H=[];for(const d of w){const m=h.get(d);m&&H.push(He(m,j))}const B={guard:0,gate:1,lifecycle:2,observer:3};H.sort((d,m)=>B[d.category]-B[m.category]);const z=new Map,le=new Map;function y(d){var m,F;for(const $ of d){if($.type==="file"&&((m=$.frontmatter)!=null&&m["agent-mode"]&&z.set($.path,String($.frontmatter["agent-mode"])),Array.isArray((F=$.frontmatter)==null?void 0:F.orchestrates))){const te=$.frontmatter.orchestrates.filter(U=>typeof U=="string");te.length>0&&le.set($.path,te)}$.children&&y($.children)}}y(r);function T(d){const m=g.get(d);return m?z.get(m):void 0}const _=new Map;for(const[d,m]of g){const F=le.get(m);F&&_.set(d,F)}function V(d,m){var te;const F=m?m.path:P.get(d.toLowerCase())??null,$=(te=m==null?void 0:m.frontmatter)!=null&&te.name?String(m.frontmatter.name):d.split("-").map(U=>U.charAt(0).toUpperCase()+U.slice(1)).join(" ");return{id:d,label:$,emoji:Ot[d]??"",color:Ft[d]??"",filePath:F}}const Y={"red-team":"#ef4444","blue-team":"#3b82f6","green-team":"#22c55e"},W=new Set(["reference","workflows"]),fe=[];function ue(d,m){var F;for(const $ of d)if($.type==="folder")!W.has($.name.toLowerCase())&&$.children&&ue($.children,$.name);else if(m&&$.name.endsWith(".md")&&((F=$.frontmatter)!=null&&F.name)){const te=$.name.replace(/\.md$/,"").toLowerCase(),U=V(te,$);U.team=m,U.color=Y[m.toLowerCase()]??(U.color||"#8B5CF6"),fe.push(U)}}ue(l,null),fe.sort((d,m)=>d.team!==m.team?(d.team??"").localeCompare(m.team??""):d.label.localeCompare(m.label));const G=new Map,ne=new Map;for(const d of i)G.has(d.from)||G.set(d.from,[]),G.get(d.from).push(d),ne.has(d.to)||ne.set(d.to,[]),ne.get(d.to).push(d);const b=a.map(d=>{const m=new Set;for(const O of d.activeHooks??[])w.has(O)||m.add(O);for(const O of G.get(d.id)??[])for(const J of O.hooks??[])w.has(J)||m.add(J);const F=[];for(const O of m){const J=h.get(O);J&&F.push(He(J,j))}F.sort((O,J)=>B[O.category]-B[J.category]);const $=[],te=ne.get(d.id)??[],U=new Map;for(const O of te){const J=Ze(O.command);if(!J||T(J)!=="team-review")continue;const ie=O.command??O.label;U.has(ie)||U.set(ie,{skillCommand:ie,skillPath:g.get(J)??null,agents:[...fe]})}const je=[...U.values()],re=(G.get(d.id)??[]).filter(O=>O.direction==="forward"||O.direction==="shortcut").map(O=>{const J=Ze(O.command),ie=(O.hooks??[]).filter(ce=>!w.has(ce)).map(ce=>h.get(ce)).filter(ce=>ce!==void 0).map(ce=>He(ce,j));return{edge:O,skillPath:J?g.get(J)??null:null,edgeHooks:ie}}),we=(G.get(d.id)??[]).filter(O=>O.direction==="backward");return{list:d,stageHooks:F,alwaysOnAgents:$,reviewTeams:je,forwardEdges:re,backwardEdges:we}});return{globalHooks:H,stages:b,skillPathMap:g,hookPathMap:j,agentPathMap:P,orchestratesMap:_}},[t,o,r,s,l])}function Xe({agent:t,mode:o,selected:r,onClick:s,onRemove:l}){const n=t.color||"#8B5CF6";return e.jsxs("button",{type:"button",onClick:s,"data-pipeline-path":t.filePath??void 0,className:R("inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors","hover:brightness-125 cursor-pointer",r&&"glow-selected-pulse"),style:{color:n,borderColor:`${n}4D`,backgroundColor:`${n}1A`,...r?{"--glow-color":`${n}A0`,"--glow-color-wide":`${n}40`}:{}},children:[t.emoji?e.jsx("span",{className:"text-xs",children:t.emoji}):e.jsx(Me,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[100px]",children:t.label}),o==="always-on"&&e.jsx("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-green-500 shrink-0",title:"Auto-invoke"}),l&&e.jsx("span",{role:"button",onClick:a=>{a.stopPropagation(),l()},className:"ml-0.5 rounded-full p-0.5 hover:bg-red-500/20",children:e.jsx(rt,{className:"h-2.5 w-2.5"})})]})}function ys({hook:t,dragId:o,selected:r,onClick:s,onRemove:l,editable:n}){const{attributes:a,listeners:i,setNodeRef:f,isDragging:g}=Se({id:o,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:f,className:R("cursor-pointer",g&&"opacity-40"),onClick:s,...i,...a,children:e.jsx(Ie,{hook:t,selected:r,onRemove:l})})}function Ns({stage:t,selectedPath:o,onSelectItem:r,editable:s,onRemoveHook:l}){const{list:n,stageHooks:a,alwaysOnAgents:i,reviewTeams:f}=t,[g,P]=c.useState(!0),[x,N]=c.useState(!0),j=a.length>0,h=i.length>0||f.length>0,p=j||s,k=`drop::stage-hooks::${n.id}`,{setNodeRef:D,isOver:K}=Ne({id:k,disabled:!s});return e.jsxs(lt,{className:"overflow-hidden border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("div",{className:"h-3 w-3 shrink-0 rounded-full",style:{backgroundColor:n.hex}}),e.jsx("span",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:n.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40 font-mono",children:n.id}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[n.isEntryPoint&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-amber-500/30 text-amber-400",children:[e.jsx(At,{className:"h-2.5 w-2.5"})," entry"]}),n.gitBranch&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-green-500/30 text-green-400",children:[e.jsx(Dt,{className:"h-2.5 w-2.5"})," ",n.gitBranch]}),n.supportsBatch&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-cyan-500/30 text-cyan-400",children:[e.jsx(Lt,{className:"h-2.5 w-2.5"})," batch"]}),n.supportsSprint&&e.jsxs(se,{variant:"outline",className:"text-[9px] gap-0.5 px-1 py-0 border-indigo-500/30 text-indigo-400",children:[e.jsx(ss,{className:"h-2.5 w-2.5"})," sprint"]})]})]}),p&&e.jsxs("div",{className:"border-t border-border/40",children:[e.jsxs("button",{type:"button",onClick:()=>P(!g),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors",children:[g?e.jsx(ke,{className:"h-3 w-3"}):e.jsx(ye,{className:"h-3 w-3"}),e.jsx(Ee,{className:"h-3 w-3"}),"Stage Hooks",e.jsxs("span",{className:"text-muted-foreground/50",children:["(",a.length,")"]})]}),g&&e.jsxs("div",{ref:D,className:R("flex flex-wrap gap-1 px-3 pb-2 min-h-[28px]",s&&"border border-dashed border-transparent rounded-md mx-2 mb-1 p-1",K&&"border-accent-blue bg-accent-blue/10"),children:[a.map(w=>e.jsx(ys,{hook:w,dragId:`pipeline::stage-hook::${n.id}::${w.id}`,selected:w.filePath!=null&&w.filePath===o,onClick:()=>w.filePath&&r("hooks",w.filePath),onRemove:s&&l?()=>l(n.id,w.id):void 0,editable:s},w.id)),s&&a.length===0&&e.jsx("span",{className:"text-[9px] text-muted-foreground/40 italic py-0.5",children:"drop hooks here"})]})]}),h&&e.jsxs("div",{className:"border-t border-border/40",children:[e.jsxs("button",{type:"button",onClick:()=>N(!x),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground transition-colors",children:[x?e.jsx(ke,{className:"h-3 w-3"}):e.jsx(ye,{className:"h-3 w-3"}),e.jsx(Me,{className:"h-3 w-3"}),"Agents",e.jsxs("span",{className:"text-muted-foreground/50",children:["(",i.length+f.reduce((w,H)=>w+H.agents.length,0),")"]})]}),x&&e.jsxs("div",{className:"px-3 pb-2 space-y-2",children:[i.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[9px] uppercase tracking-wider text-muted-foreground/50 mb-1",children:"Always-On"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.map(w=>e.jsx(Xe,{agent:w,mode:"always-on",selected:w.filePath!=null&&w.filePath===o,onClick:()=>w.filePath&&r("agents",w.filePath)},w.id))})]}),f.map(w=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-1 text-[9px] uppercase tracking-wider text-muted-foreground/50 mb-1",children:e.jsxs("span",{children:[w.skillCommand," team:"]})}),e.jsx("div",{className:"flex flex-wrap gap-1",children:w.agents.map(H=>e.jsx(Xe,{agent:H,mode:"review",selected:H.filePath!=null&&H.filePath===o,onClick:()=>H.filePath&&r("agents",H.filePath)},H.id))})]},w.skillCommand))]})]}),!p&&!h&&e.jsx("div",{className:"border-t border-border/40 px-3 py-2",children:e.jsx("span",{className:"text-[10px] text-muted-foreground/40 italic",children:"No stage-specific hooks or agents"})})]})}function Cs({hook:t,dragId:o,selected:r,onClick:s,onRemove:l,editable:n}){const{attributes:a,listeners:i,setNodeRef:f,isDragging:g}=Se({id:o,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:f,className:R("cursor-pointer",g&&"opacity-40"),onClick:s,...i,...a,children:e.jsx(Ie,{hook:t,selected:r,onRemove:l})})}const Ae={forward:{arrow:"text-green-500",label:"text-green-400",border:"border-green-500/20",bg:"bg-green-500/5"},backward:{arrow:"text-amber-500",label:"text-amber-400",border:"border-amber-500/20",bg:"bg-amber-500/5"},shortcut:{arrow:"text-indigo-500",label:"text-indigo-400",border:"border-indigo-500/20",bg:"bg-indigo-500/5"}};function Ss({edgeData:t,selectedPath:o,onSelectItem:r,editable:s,onRemoveHook:l}){const{edge:n,skillPath:a,edgeHooks:i}=t,f=Ae[n.direction]??Ae.forward,g=`drop::edge-skill::${n.from}:${n.to}`,{setNodeRef:P,isOver:x}=Ne({id:g,disabled:!s}),N=`drop::edge-hooks::${n.from}:${n.to}`,{setNodeRef:j,isOver:h}=Ne({id:N,disabled:!s}),p=n.direction==="shortcut"?"SHORTCUT":"DEFAULT";return e.jsxs("div",{className:R("flex items-center rounded-lg border overflow-hidden",f.border,"bg-card"),children:[e.jsx("div",{className:R("shrink-0 self-stretch flex items-center px-2.5",f.bg),children:e.jsx("span",{className:R("text-[9px] font-semibold uppercase tracking-wider whitespace-nowrap",f.label),children:p})}),e.jsxs("div",{className:"flex items-center flex-1 min-w-0 border-l",style:{borderColor:"inherit"},children:[e.jsx("div",{ref:P,className:R("flex items-center gap-1.5 px-2 py-1 shrink-0",x&&"bg-green-500/10"),children:n.command?e.jsxs("button",{type:"button",onClick:()=>a&&r("skills",a),"data-pipeline-path":a??void 0,className:R("inline-flex items-center gap-1 text-[11px] font-semibold transition-colors whitespace-nowrap rounded-md px-1 -mx-1",f.label,a&&"hover:brightness-125 cursor-pointer",!a&&"cursor-default opacity-60",a!=null&&a===o&&"glow-selected-pulse"),style:a!=null&&a===o?{"--glow-color":"#22c55eA0","--glow-color-wide":"#22c55e40"}:void 0,children:[e.jsx(De,{className:"h-3 w-3 shrink-0"}),n.command.replace(/\s+\{.*\}$/,"")]}):e.jsx("span",{className:R("text-[10px] text-muted-foreground/40 italic whitespace-nowrap",s&&"border border-dashed border-muted-foreground/20 rounded px-1.5 py-0.5"),children:s?"drop skill":"no skill"})}),e.jsx("div",{className:R("w-px self-stretch",f.border.replace("border-","bg-"))}),e.jsxs("div",{ref:j,className:R("flex items-center gap-1 px-2 py-1 flex-1 min-w-0",h&&"bg-[#00bcd4]/10"),children:[e.jsx(Ee,{className:"h-3 w-3 shrink-0 text-muted-foreground/30"}),i.map(k=>e.jsx(Cs,{hook:k,dragId:`pipeline::edge-hook::${n.from}:${n.to}::${k.id}`,selected:k.filePath!=null&&k.filePath===o,onClick:()=>k.filePath&&r("hooks",k.filePath),onRemove:s&&l?()=>l(n.from,n.to,k.id):void 0,editable:s},k.id)),i.length===0&&e.jsx("span",{className:R("text-[10px] text-muted-foreground/40 italic",s&&"border border-dashed border-muted-foreground/20 rounded px-1.5 py-0.5"),children:s?"drop hooks":"none"})]})]})]})}function Es({edges:t,selectedPath:o,onSelectItem:r,editable:s,onRemoveHook:l}){if(t.length===0)return null;const n=Ae.forward.arrow;return e.jsxs("div",{className:"flex flex-col items-center py-1",children:[e.jsx(Ue,{className:R("h-7 w-4",n)}),e.jsx("div",{className:"flex w-full flex-wrap justify-center gap-1 px-1 my-0.5",children:t.map(a=>e.jsx(Ss,{edgeData:a,selectedPath:o,onSelectItem:r,editable:s,onRemoveHook:l},`${a.edge.from}:${a.edge.to}`))}),e.jsx(Ue,{className:R("h-7 w-4",n)})]})}function Ms({hook:t,dragId:o,selected:r,onClick:s,onRemove:l,editable:n}){const{attributes:a,listeners:i,setNodeRef:f,isDragging:g}=Se({id:o,disabled:!n,data:{hookId:t.id}});return e.jsx("div",{ref:f,className:R("cursor-pointer",g&&"opacity-40"),onClick:s,...i,...a,children:e.jsx(Ie,{hook:t,selected:r,onRemove:l})})}function Ps({selectedPath:t,onSelectItem:o,editConfig:r,editable:s,onRemoveEdgeHook:l,onRemoveStageHook:n,onRemoveGlobalHook:a}){const i=pt(r),[f,g]=c.useState(!1);c.useEffect(()=>{t&&requestAnimationFrame(()=>{const h=document.querySelector(`[data-pipeline-path="${CSS.escape(t)}"]`);h==null||h.scrollIntoView({behavior:"smooth",block:"nearest"})})},[t]);const P=i.stages.flatMap(h=>h.backwardEdges),x=new Set([...i.globalHooks.map(h=>h.id),...i.stages.flatMap(h=>h.stageHooks.map(p=>p.id))]).size,N=new Set(i.stages.flatMap(h=>h.forwardEdges.filter(p=>p.edge.command).map(p=>p.edge.command))).size,j=new Set([...i.stages.flatMap(h=>h.alwaysOnAgents.map(p=>p.id)),...i.stages.flatMap(h=>h.reviewTeams.flatMap(p=>p.agents.map(k=>k.id)))]).size;return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:"Workflow Pipeline"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[i.stages.length," stages"]}),N>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[N," skills"]}),x>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[x," hooks"]}),j>0&&e.jsxs(se,{variant:"secondary",className:"text-[10px]",children:[j," agents"]})]})]}),e.jsx(nt,{className:"flex-1",children:e.jsxs("div",{className:"p-3 space-y-0",children:[i.globalHooks.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(lt,{className:"overflow-hidden border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[e.jsx("span",{className:"text-sm",children:"🌐"}),e.jsx("span",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:"Global Hooks"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"active in all stages"})]}),e.jsx("div",{className:"border-t border-border/40",children:e.jsx("div",{className:"flex flex-wrap gap-1 px-3 py-2",children:i.globalHooks.map(h=>e.jsx(Ms,{hook:h,dragId:`pipeline::global-hook::${h.id}`,selected:h.filePath!=null&&h.filePath===t,onClick:()=>h.filePath&&o("hooks",h.filePath),onRemove:s&&a?()=>a(h.id):void 0,editable:s},h.id))})})]}),e.jsxs("div",{className:"flex items-center gap-2 py-2 px-4",children:[e.jsx("div",{className:"flex-1 border-t border-border/40"}),e.jsx("span",{className:"text-[9px] text-muted-foreground/30 uppercase tracking-wider",children:"stages"}),e.jsx("div",{className:"flex-1 border-t border-border/40"})]})]}),i.stages.map((h,p)=>e.jsxs("div",{children:[e.jsx(Ns,{stage:h,selectedPath:t,onSelectItem:o,editable:s,onRemoveHook:n}),h.forwardEdges.length>0&&e.jsx(Es,{edges:h.forwardEdges,selectedPath:t,onSelectItem:o,editable:s,onRemoveHook:l}),h.forwardEdges.length===0&&p<i.stages.length-1&&e.jsx("div",{className:"h-2"})]},h.list.id)),P.length>0&&e.jsxs("div",{className:"mt-3 border-t border-border/30 pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>g(!f),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-[10px] font-medium text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors",children:[f?e.jsx(ke,{className:"h-3 w-3"}):e.jsx(ye,{className:"h-3 w-3"}),e.jsx(Ve,{className:"h-3 w-3"}),P.length," rework paths"]}),f&&e.jsx("div",{className:"space-y-1 px-2 pt-1",children:P.map(h=>e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground/70 py-0.5",children:[e.jsx(Ve,{className:"h-2.5 w-2.5 text-amber-500/50"}),e.jsx("span",{className:"font-mono",children:h.from}),e.jsx("span",{className:"text-muted-foreground/30",children:"→"}),e.jsx("span",{className:"font-mono",children:h.to}),e.jsx("span",{className:"text-muted-foreground/40 truncate",children:h.label})]},`${h.from}:${h.to}`))})]}),e.jsx("div",{className:"mt-4 px-2 text-center",children:e.jsx("span",{className:"text-[9px] text-muted-foreground/30",children:s?"Drag items from the tree onto stages or edges":"Click any hook, agent, or skill to open in editor"})})]})})]})}function Qe(t){const o=t.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!o)return{fields:{},body:t};const r={};for(const s of o[1].split(`
28
+ `)){const l=s.indexOf(":");if(l>0){const n=s.slice(0,l).trim(),a=s.slice(l+1).trim();r[n]=a}}return{fields:r,body:o[2]}}function Ts(t,o){const r=Object.entries(t).filter(([,l])=>l!=="");return r.length===0?o:`---
29
+ ${r.map(([l,n])=>`${l}: ${n}`).join(`
30
+ `)}
31
+ ---
32
+ ${o}`}function $s(t,o){const[r,s]=c.useState(""),[l,n]=c.useState(""),[a,i]=c.useState({}),[f,g]=c.useState(""),[P,x]=c.useState(!1),[N,j]=c.useState(!1),[h,p]=c.useState(null),k=Ce(),D=c.useRef(0);c.useEffect(()=>{if(!t||!o){s(""),n(""),i({}),g(""),p(null);return}const y=++D.current;x(!0),p(null),fetch(k(`/config/${t}/file?path=${encodeURIComponent(o)}`)).then(async T=>{var W;if(!T.ok)throw new Error(`HTTP ${T.status}`);const _=await T.json();if(y!==D.current)return;const V=((W=_.data)==null?void 0:W.content)??"";s(V),n(V);const Y=Qe(V);i(Y.fields),g(Y.body)}).catch(T=>{y===D.current&&p(T instanceof Error?T.message:"Failed to load file")}).finally(()=>{y===D.current&&x(!1)})},[t,o,k]);const K=c.useCallback((y,T)=>{const _=Ts(y,T);s(_)},[]),w=c.useCallback((y,T)=>{i(_=>{const V={..._,[y]:T};return g(Y=>(K(V,Y),Y)),V})},[K]),H=c.useCallback(y=>{g(y),i(T=>(K(T,y),T))},[K]),B=c.useCallback(y=>{s(y);const T=Qe(y);i(T.fields),g(T.body)},[]),z=c.useCallback(async()=>{if(!(!t||!o)){j(!0),p(null);try{const y=await fetch(k(`/config/${t}/file`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:o,content:r})});if(!y.ok){const T=await y.json().catch(()=>({error:"Save failed"}));throw new Error(T.error??`HTTP ${y.status}`)}n(r)}catch(y){p(y instanceof Error?y.message:"Save failed")}finally{j(!1)}}},[t,o,r,k]);return{content:r,setContent:B,frontmatter:a,setFrontmatterField:w,body:f,setBody:H,dirty:r!==l,saving:N,loading:P,save:z,error:h}}function Hs(t){const o=t.split("/"),r=o[o.length-1];return o.length>=2&&/^(SKILL|AGENT)\.md$/i.test(r)?o[o.length-2].toLowerCase():r.replace(/\.(md|sh)$/,"").toLowerCase()}function Ws(){const[t,o]=c.useState("agents"),r=Ce(),[s,l]=c.useState(null),[n,a]=c.useState(null),[i,f]=c.useState(!1),[g,P]=c.useState(null),{activeProjectId:x,hasMultipleProjects:N}=It(),{report:j,refetch:h}=rs(N?x:null),p=(j==null?void 0:j.files.some(v=>v.state==="drifted"))??!1,{tree:k,loading:D,refresh:K}=ve(t),w=(s==null?void 0:s.type)??null,H=(s==null?void 0:s.path)??null,{content:B,setContent:z,frontmatter:le,setFrontmatterField:y,body:T,setBody:_,dirty:V,saving:Y,loading:W,save:fe,error:ue}=$s(w,H),{engine:G}=at(),ne=G.getConfig(),b=Yt(ne),xe=Bt(_t(Vt,{activationConstraint:{distance:8}})),u=Wt(),d=c.useCallback(v=>{o(v),l(null)},[]),m=c.useCallback(v=>{v.type==="file"&&l({type:t,path:v.path})},[t]),F=c.useCallback((v,M)=>{o(v),l({type:v,path:M})},[]),$=c.useCallback((v,M,S)=>{b.editMode||b.enterEditMode();const E=b.editConfig.edges.find(L=>L.from===v&&L.to===M);E&&b.updateEdge(E,{...E,hooks:(E.hooks??[]).filter(L=>L!==S)})},[b]),te=c.useCallback((v,M)=>{b.editMode||b.enterEditMode();const S=b.editConfig.lists.find(E=>E.id===v);S&&b.updateList(S,{...S,activeHooks:(S.activeHooks??[]).filter(E=>E!==M)})},[b]),U=c.useCallback(v=>{var S,E;b.editMode||b.enterEditMode();const M=structuredClone(b.editMode?b.editConfig:ne);for(const L of M.lists)(S=L.activeHooks)!=null&&S.includes(v)&&(L.activeHooks=L.activeHooks.filter(q=>q!==v));for(const L of M.edges)(E=L.hooks)!=null&&E.includes(v)&&(L.hooks=L.hooks.filter(q=>q!==v));b.updateConfig(M)},[b,ne]),je=b.editMode?b.editConfig:void 0,re=pt(je),we=c.useMemo(()=>{const v=new Map;for(const[M,S]of re.hookPathMap)v.set(S,M);return v},[re.hookPathMap]),O=c.useCallback(v=>{if(String(v.active.id).startsWith("pipeline::")){const E=v.active.data.current;a({type:"pipeline",name:(E==null?void 0:E.hookId)??"hook"});return}const S=v.active.data.current;S!=null&&S.type&&(S!=null&&S.name)&&a({type:S.type,name:S.name})},[]),J=c.useCallback(v=>{var he,Z;a(null);const{active:M,over:S}=v;if(!S)return;const E=String(M.id),L=String(S.id);if(L==="drop::remove"){const X=E.match(/^pipeline::edge-hook::(.+?):(.+?)::(.+)$/);if(X){const[,ae,$e,Nt]=X;$(ae,$e,Nt);return}const me=E.match(/^pipeline::stage-hook::(.+?)::(.+)$/);if(me){const[,ae,$e]=me;te(ae,$e);return}const oe=E.match(/^pipeline::global-hook::(.+)$/);if(oe){const[,ae]=oe;U(ae);return}return}const q=E.match(/^tree::(hooks|skills|agents)::(.+)$/),de=L.match(/^drop::(edge-hooks|stage-hooks|edge-skill)::(.+)$/);if(!q||!de)return;const[,pe,Te]=q,[,A,I]=de,Q=pe==="hooks"?we.get(Te):Hs(Te);if(Q){if(b.editMode||b.enterEditMode(),A==="edge-hooks"&&pe==="hooks"){const[X,me]=I.split(":"),oe=b.editConfig.edges.find(ae=>ae.from===X&&ae.to===me);if(!oe||(he=oe.hooks)!=null&&he.includes(Q))return;b.updateEdge(oe,{...oe,hooks:[...oe.hooks??[],Q]})}if(A==="stage-hooks"&&pe==="hooks"){const X=b.editConfig.lists.find(me=>me.id===I);if(!X||(Z=X.activeHooks)!=null&&Z.includes(Q))return;b.updateList(X,{...X,activeHooks:[...X.activeHooks??[],Q]})}if(A==="edge-skill"&&pe==="skills"){const[X,me]=I.split(":"),oe=b.editConfig.edges.find(ae=>ae.from===X&&ae.to===me);if(!oe)return;b.updateEdge(oe,{...oe,command:`/${Q} {id}`})}}},[b,$,te,U,we]),Pe=c.useCallback(()=>{a(null)},[]),[ie,ce]=c.useState(!1),[Be,_e]=c.useState(null),gt=c.useCallback(async()=>{if(!(!b.validation.valid||ie)){ce(!0),_e(null);try{const M=await(await fetch(r("/workflow"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(b.editConfig)})).json();if(!M.success)throw new Error(M.error??"Save failed");b.discard()}catch(v){const M=v instanceof Error?v.message:"Workflow save failed";console.error("Workflow save failed:",v),_e(M)}finally{ce(!1)}}},[b,ie,r]),{activePaths:bt,hookCategoryMap:jt}=c.useMemo(()=>{const v=new Set,M=new Set,S=new Set,E=new Map,L=[...re.globalHooks,...re.stages.flatMap(A=>A.stageHooks),...re.stages.flatMap(A=>A.forwardEdges.flatMap(I=>I.edgeHooks))];for(const A of L)A.filePath&&(v.add(A.filePath),E.set(A.filePath,A.category));const q=G.getAllHooks();for(const A of q){const I=re.hookPathMap.get(A.id);I&&!E.has(I)&&E.set(I,A.category)}for(const A of re.stages)for(const I of A.forwardEdges)I.skillPath&&M.add(I.skillPath);const{orchestratesMap:de,skillPathMap:pe}=re;if(de.size>0){const A=new Map;for(const[he,Z]of pe)A.set(Z,he);const I=new Set,Q=[];for(const he of M){const Z=A.get(he);Z&&de.has(Z)&&(Q.push(Z),I.add(Z))}for(;Q.length>0;){const he=Q.shift();for(const Z of de.get(he)??[]){const X=pe.get(Z);X&&M.add(X),!I.has(Z)&&de.has(Z)&&(I.add(Z),Q.push(Z))}}}for(const A of re.stages){for(const I of A.alwaysOnAgents)I.filePath&&S.add(I.filePath);for(const I of A.reviewTeams)for(const Q of I.agents)Q.filePath&&S.add(Q.filePath)}return{activePaths:{hooks:v,skills:M,agents:S}[t],hookCategoryMap:E}},[re,t,G]),wt=c.useMemo(()=>{if(t!=="agents")return;const v={"red-team":"#ef4444","blue-team":"#3b82f6","green-team":"#22c55e"},M=new Map;function S(E,L){for(const q of E)if(q.type==="folder"&&q.children)S(q.children,q.name);else if(q.type==="file"&&L){const de=v[L.toLowerCase()]??"#8B5CF6";M.set(q.path,{team:L,color:de})}}return S(k,null),M},[t,k]),{setNodeRef:vt,isOver:We}=Ne({id:"drop::remove"}),kt=(n==null?void 0:n.type)==="pipeline",yt=c.useMemo(()=>{let v=0;function M(S){for(const E of S)E.type==="file"&&v++,E.children&&M(E.children)}return M(k),v},[k]);return e.jsxs(zt,{sensors:xe,modifiers:u,onDragStart:O,onDragEnd:J,onDragCancel:Pe,children:[e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(Gt,{}),e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(ze,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Primitives"}),e.jsxs(se,{variant:"secondary",className:"ml-2",children:[yt," ",t]}),N&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[x?e.jsxs(se,{variant:"outline",className:"gap-1.5",children:[e.jsx(dt,{className:"h-3 w-3"}),"Project scope"]}):e.jsxs(se,{variant:"outline",className:"gap-1.5",children:[e.jsx(qt,{className:"h-3 w-3"}),"Global scope"]}),e.jsxs(ge,{variant:i?"default":"outline",size:"sm",onClick:()=>f(!i),children:["Sync Status",p&&e.jsx("span",{className:"ml-1.5 h-2 w-2 rounded-full bg-amber-500 animate-pulse"})]})]})})]}),i&&N&&e.jsx("div",{className:"mb-4 rounded border border-border bg-card p-2",children:e.jsx(vs,{})}),g&&x&&e.jsx("div",{className:"mb-4",children:e.jsx(ks,{projectId:x,relativePath:g.relativePath,onResolved:()=>{P(null),h()},onCancel:()=>P(null)})}),b.editMode&&b.changeCount>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2 rounded border border-border bg-card px-3 py-2",children:[e.jsxs(se,{variant:"outline",children:[b.changeCount," unsaved"]}),b.canUndo&&e.jsx(ge,{variant:"ghost",size:"sm",onClick:b.undo,children:"Undo"}),b.canRedo&&e.jsx(ge,{variant:"ghost",size:"sm",onClick:b.redo,children:"Redo"}),e.jsx("div",{className:"flex-1"}),e.jsx(ge,{variant:"ghost",size:"sm",onClick:b.discard,children:"Discard"}),e.jsx(ge,{size:"sm",onClick:gt,disabled:ie||!b.validation.valid,children:ie?"Saving...":"Save"}),Be&&e.jsx("span",{className:"text-xs text-destructive ml-2",children:Be})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 gap-2",children:[e.jsxs("div",{ref:vt,className:R("flex w-[20%] min-w-[180px] flex-col rounded border bg-card card-glass neon-border-blue transition-colors",We?"border-ask-red/60 bg-ask-red/5":"border-border"),children:[kt&&We&&e.jsxs("div",{className:"flex items-center justify-center gap-1.5 border-b border-ask-red/30 bg-ask-red/10 px-2 py-1.5 text-[10px] text-ask-red",children:[e.jsx(Le,{className:"h-3 w-3"})," Drop to remove"]}),e.jsx(cs,{tree:k,loading:D,selectedPath:H,type:t,onSelect:m,onRefresh:K,onTabChange:d,activePaths:bt,hookCategoryMap:t==="hooks"?jt:void 0,agentTeamMap:wt})]}),e.jsx("div",{className:"flex w-[35%] min-w-[220px] flex-col rounded border border-border bg-card card-glass neon-border-blue",children:e.jsx(Ps,{selectedPath:H,onSelectItem:F,editConfig:je,editable:!0,onRemoveEdgeHook:$,onRemoveStageHook:te,onRemoveGlobalHook:U})}),e.jsx("div",{className:"flex w-[45%] min-w-[280px] flex-col rounded border border-border bg-card card-glass neon-border-blue",children:e.jsx(ds,{type:w,filePath:H,content:B,setContent:z,frontmatter:le,setFrontmatterField:y,body:T,setBody:_,dirty:V,saving:Y,loading:W,error:ue,onSave:fe})})]})]}),e.jsx(Ut,{children:n&&e.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-[11px] font-medium bg-card shadow-lg border-accent-blue/50 text-foreground",children:[n.type==="hooks"&&e.jsx(Ee,{className:"h-3 w-3 text-amber-400"}),n.type==="skills"&&e.jsx(De,{className:"h-3 w-3 text-green-400"}),n.type==="agents"&&e.jsx(ze,{className:"h-3 w-3 text-purple-400"}),n.name]})})]})}export{Ws as PrimitivesConfig};
@@ -0,0 +1,21 @@
1
+ import{j as e}from"./ui-BmsSg9jU.js";import{a as i}from"./vendor-Bqt8AJn2.js";import{c as w,u as T,j as P,s as g,F as ne,H as oe,I as y,a as h,w as le,S as ie,J as ce,o as B,K as W,M as X,N as q,B as C,O as de,E as me,Q as Y,R as xe,U as J,V as ue,T as fe,h as he}from"./index-Bc9dK3MW.js";import{C as Q}from"./circle-x-Cwz6ZQDV.js";import{S as A}from"./shield-DwAFkDYI.js";import{f as G}from"./formatDistanceToNow-BMqsSP44.js";import{R as _,B as D,X as v,Y as k,T as R,a as O,C as I,A as pe,b as Z,d as ge}from"./charts-DbDg0Psc.js";import{C as be,Z as E}from"./zap-DfbUoOty.js";import{F as je}from"./file-text-C46Xr65c.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ye=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],Ne=w("check-check",ye);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Se=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],M=w("shield-alert",Se);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Ee=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],_e=w("square-terminal",Ee);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const ve=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ke=w("wrench",ve);function we(t){const s=T(),[r,n]=i.useState([]),[o,d]=i.useState([]),[m,a]=i.useState(!0),c=i.useCallback(async x=>{try{const u=t?`?scope_id=${t}`:"",[f,b]=await Promise.all([fetch(s(`/gates${u}`),{signal:x}),fetch(s("/gates/stats"),{signal:x})]);f.ok&&n(await f.json()),b.ok&&d(await b.json())}catch(u){if(u instanceof DOMException&&u.name==="AbortError")return;console.warn("[Orbital] Failed to fetch gates:",u)}finally{x!=null&&x.aborted||a(!1)}},[t,s]);return i.useEffect(()=>{const x=new AbortController;return c(x.signal),()=>x.abort()},[c]),P(c),i.useEffect(()=>{function x(u){n(f=>{const b=f.findIndex(j=>j.gate_name===u.gate_name&&j.scope_id===u.scope_id);if(b>=0){const j=[...f];return j[b]=u,j}return[...f,u]})}return g.on("gate:updated",x),()=>{g.off("gate:updated",x)}},[]),{gates:r,stats:o,loading:m,refetch:c}}function Te(){const t=T(),[s,r]=i.useState({byRule:[],byFile:[],overrides:[],totalViolations:0,totalOverrides:0}),[n,o]=i.useState(!0),d=i.useCallback(async()=>{try{const m=await fetch(t("/events/violations/summary"));m.ok&&r(await m.json())}catch(m){console.warn("[Orbital] Failed to fetch violations:",m)}finally{o(!1)}},[t]);return i.useEffect(()=>{d()},[d]),P(d),i.useEffect(()=>{function m(a){(a.type==="VIOLATION"||a.type==="OVERRIDE")&&d()}return g.on("event:new",m),()=>{g.off("event:new",m)}},[d]),{...s,loading:n,refetch:d}}function ee(){const t=T(),[s,r]=i.useState(null),[n,o]=i.useState([]),[d,m]=i.useState(!0),a=i.useCallback(async()=>{try{const[c,x]=await Promise.all([fetch(t("/enforcement/rules")),fetch(t("/events/violations/trend?days=30"))]);c.ok&&r(await c.json()),x.ok&&o(await x.json())}catch(c){console.warn("[Orbital] Failed to fetch enforcement rules:",c)}finally{m(!1)}},[t]);return i.useEffect(()=>{a()},[a]),P(a),i.useEffect(()=>{function c(x){(x.type==="VIOLATION"||x.type==="OVERRIDE")&&a()}return g.on("event:new",c),()=>{g.off("event:new",c)}},[a]),{data:s,trend:n,loading:d,refetch:a}}const Ce={pass:{icon:y,color:"text-bid-green",label:"Pass",glow:"gate-glow-pass glow-green"},fail:{icon:Q,color:"text-ask-red",label:"Fail",glow:"gate-glow-fail glow-red"},running:{icon:oe,color:"text-accent-blue",label:"Running",animate:"animate-spin",glow:"glow-blue"},skipped:{icon:ne,color:"text-muted-foreground",label:"Skipped",glow:""}};function Ae({status:t,className:s}){const r=Ce[t],n=r.icon;return e.jsxs("div",{className:h("flex items-center gap-1.5",s),children:[e.jsx(n,{className:h("h-4 w-4",r.color,r.animate,r.glow)}),e.jsx("span",{className:h("text-xs",r.color),children:r.label})]})}function se(t){return t.replace(/-/g," ").replace(/\b\w/g,s=>s.toUpperCase())}const K={blocker:"text-red-400 bg-red-500/10 border-red-500/20",advisor:"text-amber-400 bg-amber-500/10 border-amber-500/20",operator:"text-cyan-400 bg-cyan-500/10 border-cyan-500/20",silent:"text-zinc-400 bg-zinc-500/10 border-zinc-500/20"},Oe={guard:A,gate:M,lifecycle:be,observer:me},L={background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"6px",fontSize:"11px"},Ie={VIOLATION:{icon:fe,color:"text-red-400",label:"Violation"},OVERRIDE:{icon:M,color:"text-amber-400",label:"Override"},GATE_PASSED:{icon:y,color:"text-green-400",label:"Gate passed"},GATE_FAILED:{icon:Q,color:"text-red-400",label:"Gate failed"},ALL_GATES_PASSED:{icon:Ne,color:"text-green-400",label:"All gates passed"},SCOPE_STATUS_CHANGED:{icon:E,color:"text-cyan-400",label:"Status changed"},SCOPE_TRANSITION:{icon:Y,color:"text-cyan-400",label:"Transition"},SCOPE_GATE_LIFTED:{icon:A,color:"text-cyan-400",label:"Gate lifted"},COMMIT:{icon:ue,color:"text-foreground",label:"Commit"},SESSION_START:{icon:J,color:"text-green-400",label:"Session started"},SESSION_END:{icon:xe,color:"text-muted-foreground",label:"Session ended"},AGENT_STARTED:{icon:E,color:"text-purple-400",label:"Agent started"},AGENT_COMPLETED:{icon:y,color:"text-purple-400",label:"Agent completed"},SCOPE_CREATED:{icon:je,color:"text-cyan-400",label:"Scope created"},SCOPE_COMPLETED:{icon:y,color:"text-green-400",label:"Scope completed"},DISPATCH:{icon:_e,color:"text-cyan-400",label:"Dispatch"},REVIEW_FIXES_COMPLETED:{icon:ke,color:"text-purple-400",label:"Review fixes"},SKILL_INVOKED:{icon:E,color:"text-foreground",label:"Skill invoked"},SKILL_COMPLETED:{icon:y,color:"text-foreground",label:"Skill completed"}};function Ye(){return e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(le,{}),e.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[e.jsx(ie,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Guards"})]}),e.jsxs("div",{className:"flex flex-1 min-h-0 gap-4",children:[e.jsx("div",{className:"flex w-1/2 min-w-0 flex-col overflow-y-auto rounded-lg border border-border/50",children:e.jsx(De,{})}),e.jsxs("div",{className:"flex w-1/2 min-w-0 flex-col space-y-4",children:[e.jsx(Le,{}),e.jsx(Fe,{})]})]})]})}function De(){const{data:t,loading:s}=ee();return s?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):!t||t.rules.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No rules configured"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-10 border-b border-border/50 bg-surface-light/40 backdrop-blur-sm px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium",children:"Rules"}),e.jsxs("div",{className:"flex items-center gap-2.5 ml-auto",children:[e.jsx(S,{count:t.summary.guards,label:"guards",color:"text-red-400"}),e.jsx(S,{count:t.summary.gates,label:"gates",color:"text-amber-400"}),e.jsx(S,{count:t.summary.lifecycle,label:"lifecycle",color:"text-cyan-400"}),e.jsx(S,{count:t.summary.observers,label:"observers",color:"text-zinc-400"}),e.jsx("span",{className:"text-border",children:"|"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[t.totalEdges," edges"]})]})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left text-[10px] text-muted-foreground uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-1.5 font-medium",children:"Hook"}),e.jsx("th",{className:"px-3 py-1.5 font-medium",children:"Category"}),e.jsx("th",{className:"px-3 py-1.5 font-medium",children:"Level"}),e.jsx("th",{className:"px-3 py-1.5 font-medium",children:"Edges"}),e.jsx("th",{className:"px-3 py-1.5 font-medium text-right",children:"Vio"}),e.jsx("th",{className:"px-3 py-1.5 font-medium text-right",children:"Ovr"}),e.jsx("th",{className:"px-3 py-1.5 font-medium text-right",children:"Fired"})]})}),e.jsx("tbody",{children:t.rules.map(r=>e.jsx(Re,{rule:r},r.hook.id))})]})})]})}function Re({rule:t}){var r;const s=Oe[t.hook.category]??A;return e.jsxs("tr",{className:"border-b border-border/30 last:border-0 hover:bg-surface-light/30",children:[e.jsx("td",{className:"px-3 py-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s,{className:"h-3 w-3 text-muted-foreground/50 shrink-0"}),e.jsx("span",{className:"font-medium truncate",children:t.hook.label})]})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx(C,{variant:"outline",className:h("text-[9px] border",K[t.enforcement]),children:t.hook.category})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx("span",{className:h("text-[10px]",(r=K[t.enforcement])==null?void 0:r.split(" ")[0]),children:t.enforcement})}),e.jsx("td",{className:"px-3 py-1.5",children:t.edges.length>0?e.jsxs("div",{className:"flex flex-wrap gap-0.5",children:[t.edges.slice(0,2).map((n,o)=>e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] text-muted-foreground font-mono",children:[n.from,e.jsx(Y,{className:"h-2 w-2"}),n.to]},o)),t.edges.length>2&&e.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["+",t.edges.length-2]})]}):e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"-"})}),e.jsx("td",{className:"px-3 py-1.5 text-right font-mono",children:t.stats.violations>0?e.jsx("span",{className:"text-red-400",children:t.stats.violations}):e.jsx("span",{className:"text-muted-foreground/40",children:"0"})}),e.jsx("td",{className:"px-3 py-1.5 text-right font-mono",children:t.stats.overrides>0?e.jsx("span",{className:"text-amber-400",children:t.stats.overrides}):e.jsx("span",{className:"text-muted-foreground/40",children:"0"})}),e.jsx("td",{className:"px-3 py-1.5 text-right text-muted-foreground/60",children:t.stats.last_triggered?G(new Date(t.stats.last_triggered),{addSuffix:!0}):"-"})]})}const H=[{key:"all",label:"All"},{key:"workflow",label:"Workflow",types:new Set(["SCOPE_STATUS_CHANGED","SCOPE_TRANSITION","SCOPE_GATE_LIFTED","SCOPE_CREATED","SCOPE_COMPLETED","DISPATCH"])},{key:"enforcement",label:"Enforcement",types:new Set(["VIOLATION","OVERRIDE","GATE_PASSED","GATE_FAILED","ALL_GATES_PASSED","REVIEW_FIXES_COMPLETED"])},{key:"sessions",label:"Sessions",types:new Set(["SESSION_START","SESSION_END","AGENT_STARTED","AGENT_COMPLETED","COMMIT","SKILL_INVOKED","SKILL_COMPLETED"])}];function Le(){const t=T(),{scopes:s}=ce(),{totalViolations:r,totalOverrides:n,loading:o}=Te(),{trend:d,loading:m}=ee(),[a,c]=i.useState([]),[x,u]=i.useState(!0),[f,b]=i.useState("all"),[j,F]=i.useState(null),N=i.useCallback(async()=>{try{const l=await fetch(t("/events?limit=50"));l.ok&&c(await l.json())}catch{}finally{u(!1)}},[t]);i.useEffect(()=>{N()},[N]),i.useEffect(()=>{const l=()=>{N()};return g.on("event:new",l),()=>{g.off("event:new",l)}},[N]);const te=i.useMemo(()=>{const l=new Map;for(const p of s)l.set(p.id,p.title);return l},[s]),V=i.useMemo(()=>{const l=H.find(p=>p.key===f);return!l||f==="all"?a:a.filter(p=>l.types.has(p.type))},[a,f]),z=r+n>0?Math.round(n/(r+n)*100):0,re=o||m||x;async function ae(l){F(l);try{const p=await fetch(t(`/sessions/${l}/content`));if(!p.ok)return;const $=await p.json();if(!$.claude_session_id)return;await fetch(t(`/sessions/${l}/resume`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claude_session_id:$.claude_session_id})})}catch{}finally{setTimeout(()=>F(null),2e3)}}return e.jsxs(B,{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs(W,{className:"pb-2 pt-3 px-4 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(M,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx(X,{className:"text-sm font-medium",children:"Activity"}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto text-xs",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-red-400 font-medium",children:r})," ",e.jsx("span",{className:"text-muted-foreground",children:"violations"})]}),e.jsxs("span",{children:[e.jsx("span",{className:"text-amber-400 font-medium",children:n})," ",e.jsx("span",{className:"text-muted-foreground",children:"overrides"})]}),r+n>0&&e.jsxs("span",{className:h("font-medium",z>50?"text-amber-400":"text-muted-foreground"),children:[z,"%"]})]})]}),e.jsx("div",{className:"flex gap-1 mt-2",children:H.map(l=>e.jsx("button",{onClick:()=>b(l.key),className:h("rounded-full px-2.5 py-0.5 text-[10px] font-medium transition-colors",f===l.key?"bg-primary/15 text-primary border border-primary/30":"text-muted-foreground hover:text-foreground hover:bg-surface-light/50 border border-transparent"),children:l.label},l.key))})]}),e.jsx(q,{className:"px-4 pb-4 flex-1 min-h-0 overflow-y-auto space-y-3",children:re?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{trend:d}),V.length===0?e.jsx("p",{className:"text-xs text-muted-foreground py-4 text-center",children:"No events recorded yet"}):e.jsx("div",{className:"space-y-px",children:V.map(l=>e.jsx(Pe,{event:l,scopeTitle:l.scope_id?te.get(l.scope_id)??null:null,onResume:l.session_id?()=>ae(l.session_id):void 0,resuming:j===l.session_id},l.id))})]})})]})}function Pe({event:t,scopeTitle:s,onResume:r,resuming:n}){const o=Ie[t.type]??{icon:E,color:"text-muted-foreground",label:t.type},d=o.icon,m=t.data??{};return e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-1 hover:bg-surface-light/30 group border-l-2 border-transparent hover:border-primary/20",children:[e.jsx(d,{className:h("h-3.5 w-3.5 shrink-0",o.color)}),e.jsx("span",{className:h("text-[11px] font-medium shrink-0",o.color),children:o.label}),t.scope_id&&e.jsxs(C,{variant:"outline",className:"text-[9px] font-mono px-1.5 py-0 h-4 gap-1 border-border/50 shrink-0",children:["#",String(t.scope_id).padStart(3,"0"),s&&e.jsx("span",{className:"font-sans text-muted-foreground truncate max-w-[120px]",children:s})]}),e.jsx(Ge,{type:t.type,data:m}),e.jsx("span",{className:"flex-1 min-w-0",children:e.jsx(Me,{type:t.type,data:m})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r&&e.jsxs(he,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-[10px] gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:r,disabled:n,children:[e.jsx(J,{className:"h-2.5 w-2.5"}),n?"Opening...":"Resume"]}),e.jsx("span",{className:"text-[9px] text-muted-foreground/40 tabular-nums whitespace-nowrap",children:t.timestamp?G(new Date(t.timestamp),{addSuffix:!0}):""})]})]})}function Ge({type:t,data:s}){const r=[];return s.rule&&r.push({label:String(s.rule),color:"border-red-500/30 text-red-400"}),s.outcome==="blocked"&&r.push({label:"blocked",color:"border-red-500/30 text-red-400"}),s.outcome==="overridden"&&r.push({label:"overridden",color:"border-amber-500/30 text-amber-400"}),s.verdict==="PASS"&&r.push({label:"PASS",color:"border-green-500/30 text-green-400"}),s.verdict==="FAIL"&&r.push({label:"FAIL",color:"border-red-500/30 text-red-400"}),t==="COMMIT"&&s.hash&&r.push({label:String(s.hash).slice(0,7)}),t==="DISPATCH"&&s.command&&r.push({label:String(s.command)}),t==="SCOPE_GATE_LIFTED"&&s.mode&&r.push({label:String(s.mode)}),t==="AGENT_COMPLETED"&&s.action&&r.push({label:String(s.action)}),t==="SKILL_INVOKED"&&s.skill&&r.push({label:String(s.skill)}),r.length===0?null:e.jsx(e.Fragment,{children:r.map((n,o)=>e.jsx(C,{variant:"outline",className:h("text-[9px] px-1 py-0 h-3.5 font-mono",n.color??"border-border/50"),children:n.label},o))})}function Me({type:t,data:s}){let r=null;switch(t){case"VIOLATION":r=[s.details,s.file].filter(Boolean).join(" — ")||null;break;case"OVERRIDE":r=s.reason?String(s.reason):null;break;case"SCOPE_STATUS_CHANGED":case"SCOPE_TRANSITION":{const n=s.from?String(s.from):null,o=s.to?String(s.to):null,d=s.scope_name?String(s.scope_name):null,m=[];n&&o?m.push(`${n} → ${o}`):o&&m.push(`→ ${o}`),d&&m.push(d),r=m.join(" — ")||null;break}case"COMMIT":r=s.message?String(s.message).slice(0,100):null;break;case"AGENT_COMPLETED":{const n=[];s.outcome&&n.push(String(s.outcome)),s.commit_hash&&n.push(`commit ${String(s.commit_hash).slice(0,7)}`),r=n.join(" — ")||null;break}case"AGENT_STARTED":r=s.agents?String(s.agents):s.mode?String(s.mode):null;break;case"REVIEW_FIXES_COMPLETED":{const n=s.findings_total,o=s.findings_fixed,d=s.agents_used;r=n!=null?`${o}/${n} findings fixed${d?` by ${d} agents`:""}`:null;break}case"GATE_PASSED":case"GATE_FAILED":r=s.gate_name?se(String(s.gate_name)):null;break;case"DISPATCH":r=null;break;case"SESSION_START":r=s.source?`source: ${s.source}`:null;break;case"SCOPE_GATE_LIFTED":r=s.scope_file?String(s.scope_file).split("/").pop()??null:null;break;default:r=s.details||s.message?String(s.details||s.message).slice(0,100):null}return r?e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r}):null}function Fe(){const{gates:t,stats:s,loading:r}=we(),n=s.reduce((a,c)=>a+c.passed,0),o=s.reduce((a,c)=>a+c.total,0),d=o>0?Math.round(n/o*100):0,m=t.filter(a=>a.status==="pass").length;return e.jsxs(B,{className:"shrink-0 basis-2/5 min-h-0 flex flex-col",children:[e.jsx(W,{className:"pb-2 pt-3 px-4 shrink-0",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(y,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(X,{className:"text-sm font-medium",children:"CI Gates"}),t.length>0&&e.jsxs(C,{variant:"secondary",className:"text-[10px]",children:[m,"/",t.length," passing"]}),o>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Pass rate"}),e.jsxs("span",{className:"text-sm font-medium",children:[d,"%"]}),e.jsx("div",{className:"h-1.5 w-16 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-bid-green transition-all",style:{width:`${d}%`}})})]})]})}),e.jsx(q,{className:"px-4 pb-4 flex-1 min-h-0 overflow-y-auto",children:r?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):t.length===0?e.jsxs("p",{className:"text-xs text-muted-foreground text-center py-3",children:["No gate results yet. Run ",e.jsx("code",{className:"rounded bg-muted px-1",children:"/test-checks"})," to populate."]}):e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block",children:"Latest Run"}),e.jsx("div",{className:"space-y-0.5",children:t.map(a=>e.jsxs("div",{className:"flex items-center gap-2 rounded px-2 py-0.5 hover:bg-surface-light/50",children:[e.jsx(Ae,{status:a.status}),e.jsx("span",{className:"flex-1 text-[11px] truncate",children:se(a.gate_name)}),a.duration_ms!=null&&e.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground shrink-0",children:[(a.duration_ms/1e3).toFixed(1),"s"]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/50 shrink-0",children:[e.jsx(de,{className:"inline h-2.5 w-2.5 mr-0.5"}),G(new Date(a.run_at),{addSuffix:!0})]})]},a.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block",children:"Gate History"}),s.length===0?e.jsx(U,{height:100,message:"No history data"}):e.jsx(_,{width:"100%",height:Math.max(100,s.length*16),children:e.jsxs(D,{data:s.map(a=>({name:a.gate_name.replace(/-/g," ").slice(0,12),passed:a.passed,failed:a.failed})),layout:"vertical",margin:{left:0,right:8,top:0,bottom:0},children:[e.jsx(v,{type:"number",hide:!0}),e.jsx(k,{dataKey:"name",type:"category",width:80,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(R,{contentStyle:L}),e.jsx(O,{dataKey:"passed",stackId:"a",radius:[0,0,0,0],children:s.map((a,c)=>e.jsx(I,{fill:"#00c853"},c))}),e.jsx(O,{dataKey:"failed",stackId:"a",radius:[0,4,4,0],children:s.map((a,c)=>e.jsx(I,{fill:"#ff1744"},c))})]})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block",children:"Gate Duration"}),t.some(a=>a.duration_ms!=null)?e.jsx(_,{width:"100%",height:Math.max(100,t.filter(a=>a.duration_ms!=null).length*16),children:e.jsxs(D,{data:t.filter(a=>a.duration_ms!=null).map(a=>({name:a.gate_name.replace(/-/g," ").slice(0,12),seconds:Number((a.duration_ms/1e3).toFixed(1)),status:a.status})),layout:"vertical",margin:{left:0,right:8,top:0,bottom:0},children:[e.jsx(v,{type:"number",unit:"s",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(k,{dataKey:"name",type:"category",width:80,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(R,{formatter:a=>[`${a}s`,"Duration"],contentStyle:L}),e.jsx(O,{dataKey:"seconds",radius:[0,4,4,0],children:t.filter(a=>a.duration_ms!=null).map((a,c)=>e.jsx(I,{fill:a.status==="pass"?"#00c85340":a.status==="fail"?"#ff174440":"#06b6d440"},c))})]})}):e.jsx(U,{height:100,message:"No duration data"})]})]})]})})]})}function S({count:t,label:s,color:r}){return e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:h("text-xs font-medium",r),children:t}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:s})]})}function U({height:t,message:s}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{style:{height:t},className:"opacity-30",children:e.jsx(_,{width:"100%",height:t,children:e.jsxs(D,{data:[{name:"",value:0}],layout:"vertical",margin:{left:10,right:20,top:0,bottom:0},children:[e.jsx(Z,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.4}),e.jsx(v,{type:"number",domain:[0,10],tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(k,{dataKey:"name",type:"category",width:80,tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}})]})})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:s})})]})}function Ve({trend:t}){const s=new Map;for(const n of t)s.set(n.day,(s.get(n.day)??0)+n.count);const r=[...s.entries()].map(([n,o])=>({day:n.slice(5),count:o})).slice(-30);return r.length<2?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/50 mb-1.5 block",children:"Violation Trend (30d)"}),e.jsx(_,{width:"100%",height:100,children:e.jsxs(pe,{data:r,margin:{left:0,right:10,top:5,bottom:0},children:[e.jsx(Z,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3}),e.jsx(v,{dataKey:"day",tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"}}),e.jsx(k,{tick:{fontSize:9,fill:"hsl(var(--muted-foreground))"},width:30}),e.jsx(R,{contentStyle:L}),e.jsx(ge,{type:"monotone",dataKey:"count",stroke:"#EF4444",fill:"#EF444420",strokeWidth:1.5})]})})]})}export{Ye as QualityGates};
@@ -0,0 +1 @@
1
+ import{j as e}from"./ui-BmsSg9jU.js";import{a as d}from"./vendor-Bqt8AJn2.js";import{q,ai as J,s as B,w as K,O as D,B as y,d as F,a as T,a9 as b,aj as E,ak as U,a7 as V,h as W,b as Q}from"./index-Bc9dK3MW.js";import{F as X}from"./file-text-C46Xr65c.js";import"./charts-DbDg0Psc.js";const Y={createScope:"Created",reviewScope:"Reviewed",implementScope:"Implemented",verifyScope:"Verified",reviewGate:"Review Gate",fixReview:"Fix Review",commit:"Committed",pushToMain:"Pushed to Main",pushToDev:"Pushed to Dev",pushToStaging:"PR to Staging",pushToProduction:"PR to Production"};function z(s){return Y[s]??s}function ie(){const{activeProjectId:s,getApiBase:t}=q(),[n,o]=d.useState([]),[c,x]=d.useState(!0),[a,m]=d.useState(null),[r,j]=d.useState(null),[w,u]=d.useState(!1),[S,h]=d.useState(!1),v=d.useRef(),[R,_]=d.useState({}),{neonGlass:G}=J(),M=d.useCallback(async()=>{try{const l=await fetch("/api/orbital/aggregate/sessions");if(!l.ok)return;const p=await l.json(),g={};for(const A of p)A.project_id&&(g[A.project_id]=(g[A.project_id]??0)+1);_(g)}catch{}},[]);d.useEffect(()=>{M()},[M]);const k=d.useCallback(async()=>{try{const l=s?`${t(s)}/sessions`:"/api/orbital/aggregate/sessions",p=await fetch(l);p.ok&&o(await p.json())}catch{}finally{x(!1)}},[s,t]);d.useEffect(()=>{k()},[k]),d.useEffect(()=>{const l=()=>{k(),M()};return B.on("session:updated",l),()=>{B.off("session:updated",l)}},[k,M]);const f=n,$=d.useCallback(async l=>{m(l),j(null),u(!0);try{const p=t(l.project_id??s),g=await fetch(`${p}/sessions/${l.id}/content`);g.ok&&j(await g.json())}catch{}finally{u(!1)}},[t]);d.useEffect(()=>{a&&!f.some(l=>l.id===a.id)&&(m(null),j(null))},[f,a]),d.useEffect(()=>{!a&&f.length>0&&$(f[0])},[f,a,$]);const H=d.useCallback(async()=>{const l=r==null?void 0:r.claude_session_id;if(!(!a||!l)){h(!0);try{const p=t(a.project_id??s);await fetch(`${p}/sessions/${a.id}/resume`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claude_session_id:l})})}catch{}finally{v.current=setTimeout(()=>h(!1),2e3)}}},[a,r,t]);d.useEffect(()=>()=>{clearTimeout(v.current)},[]);const O=!c&&f.length>0;return e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(K,{countOverrides:R}),e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(D,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Sessions"}),!c&&e.jsxs(y,{variant:"secondary",children:[f.length," sessions"]})]}),e.jsxs("div",{className:"flex flex-1 gap-0 overflow-hidden rounded-lg border border-border/50",children:[e.jsx("div",{className:"w-[40%] border-r border-border/50 overflow-hidden",children:c?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):O?e.jsx(F,{className:"h-full",children:e.jsxs("div",{className:"relative p-3",children:[e.jsx("div",{className:"absolute left-6 top-[29px] bottom-3 w-px bg-border"}),e.jsx("div",{className:"space-y-1",children:f.map(l=>e.jsx(Z,{session:l,isSelected:(a==null?void 0:a.id)===l.id,neonGlass:G,onClick:()=>$(l)},l.id))})]})}):e.jsx("div",{className:"flex h-full items-center justify-center p-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx(D,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground/30"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No session history yet."})]})})}),e.jsx("div",{className:"w-[60%] overflow-hidden",children:a?e.jsx(ee,{session:a,detail:r,loading:w,resuming:S,onResume:H}):e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(D,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground/30"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c?"":O?"Select a session to view details":""})]})})})]})]})}function Z({session:s,isSelected:t,neonGlass:n,onClick:o}){var m;const c=s.scope_ids,x=Array.isArray(s.discoveries)?s.discoveries:[],a=Array.isArray(s.next_steps)?s.next_steps:[];return e.jsxs("div",{className:"relative pl-8 cursor-pointer",onClick:o,children:[e.jsx("div",{className:T("absolute left-[8px] top-3 h-2.5 w-2.5 rounded-full border-2",t?"border-primary bg-primary":"border-muted-foreground/40 bg-background",n&&"timeline-dot-glow glow-blue")}),e.jsxs("div",{className:T("rounded-md px-3 py-2 transition-colors",t?"bg-primary/10 border border-primary/30":"hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.started_at&&e.jsx("span",{className:"text-xxs text-muted-foreground",children:b(new Date(s.started_at),"MMM d")}),c.slice(0,3).map(r=>e.jsx(y,{variant:"outline",className:"font-mono text-xxs px-1 py-0",children:E(r)},r)),c.length>3&&e.jsxs("span",{className:"text-xxs text-muted-foreground",children:["+",c.length-3]}),(m=s.actions)==null?void 0:m.slice(0,2).map(r=>e.jsx(y,{variant:"secondary",className:"text-xxs px-1 py-0 font-light",children:z(r)},r))]}),e.jsx("p",{className:T("mt-0.5 text-xs font-normal truncate",t?"text-foreground":"text-foreground/80"),children:s.summary?P(s.summary,80):"Untitled Session"}),e.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xxs text-muted-foreground",children:[x.length>0&&e.jsxs("span",{className:"text-bid-green",children:[x.length," completed"]}),a.length>0&&e.jsxs("span",{className:"text-accent-blue",children:[a.length," next"]})]})]})]})}function ee({session:s,detail:t,loading:n,resuming:o,onResume:c}){var S;const x=s.scope_ids,a=Array.isArray(s.discoveries)?s.discoveries:[],m=Array.isArray(s.next_steps)?s.next_steps:[],r=(t==null?void 0:t.meta)??null,j=!!(t!=null&&t.claude_session_id),w=(r==null?void 0:r.summary)??s.summary??null,u=[];return x.length>0&&u.push(["Scopes",x.map(h=>E(h)).join(", ")]),((S=s.actions)==null?void 0:S.length)>0&&u.push(["Actions",s.actions.map(z).join(", ")]),s.summary&&u.push(["Summary",P(s.summary,200)]),u.push(["Started",s.started_at?b(new Date(s.started_at),"MMM d, h:mm a"):"—"]),u.push(["Ended",s.ended_at?b(new Date(s.ended_at),"MMM d, h:mm a"):"—"]),r!=null&&r.branch&&r.branch!=="unknown"&&u.push(["Branch",r.branch,"font-mono text-xxs"]),r&&r.fileSize>0&&u.push(["File size",te(r.fileSize)]),r&&u.push(["Plan",r.slug,"text-muted-foreground",`/api/orbital/open-file?path=scopes/${r.slug}.md`]),s.handoff_file&&u.push(["Handoff",s.handoff_file,"font-mono text-xxs"]),t!=null&&t.claude_session_id&&u.push(["Session ID",t.claude_session_id,"font-mono text-xxs text-muted-foreground"]),e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"px-5 pt-4 pb-3",children:[e.jsxs("p",{className:"text-xxs text-muted-foreground",children:[s.started_at&&b(new Date(s.started_at),"MMM d, yyyy — h:mm a"),x.length>0&&x.slice(0,4).map(h=>e.jsx("span",{className:"ml-1.5",children:e.jsx(y,{variant:"outline",className:"font-mono text-xxs",children:E(h)})},h)),x.length>4&&e.jsxs("span",{className:"ml-1 text-xxs",children:["+",x.length-4]})]}),e.jsx("h2",{className:"mt-1 text-sm font-light",children:w?P(w,120):"Untitled Session"})]}),e.jsx(U,{}),e.jsx(F,{className:"flex-1",children:e.jsx("div",{className:"px-5 py-4",children:n?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full table-fixed text-xs",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"w-28"}),e.jsx("col",{})]}),e.jsx("tbody",{className:"[&_td]:border-b [&_td]:border-border/30 [&_td]:py-2 [&_td]:align-top [&_td:first-child]:pr-3 [&_td:first-child]:text-muted-foreground [&_td:first-child]:whitespace-nowrap [&_td:last-child]:break-all",children:u.map(([h,v,R,_])=>e.jsxs("tr",{children:[e.jsx("td",{children:h}),e.jsx("td",{className:R,children:_?e.jsxs("button",{onClick:()=>{fetch(_,{method:"POST"})},className:"inline-flex items-center gap-1.5 hover:text-accent-blue transition-colors",title:"Open file",children:[v,e.jsx(V,{className:"h-3 w-3 opacity-50"})]}):v})]},h))})]}),e.jsx(I,{title:"Completed",items:a,color:"text-bid-green"}),e.jsx(I,{title:"Next Steps",items:m,color:"text-accent-blue"}),(t==null?void 0:t.stats)&&e.jsx(se,{stats:t.stats}),s.handoff_file&&e.jsxs("div",{className:"mt-4 flex items-center gap-1.5 text-xxs text-muted-foreground/60",children:[e.jsx(X,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:s.handoff_file})]})]})})}),!n&&e.jsxs("div",{className:"border-t border-border/50 px-5 py-3",children:[e.jsxs(W,{className:"w-full",disabled:!j||o,onClick:c,title:j?"Open in iTerm":"No Claude Code session found",children:[e.jsx(Q,{className:"mr-2 h-4 w-4"}),o?"Opening iTerm...":"Resume Session"]}),!j&&e.jsx("p",{className:"mt-1.5 text-center text-xxs text-muted-foreground",children:"No matching Claude Code session found"})]})]})}function se({stats:s}){const{user:t,assistant:n,system:o,timing:c}=s,x=Object.entries(n.toolsUsed).sort((a,m)=>m[1]-a[1]);return e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsx(U,{}),e.jsxs(N,{title:"Timing",children:[c.durationMs>0&&e.jsx(i,{label:"Duration",value:L(c.durationMs)}),c.firstTimestamp&&e.jsx(i,{label:"First event",value:b(new Date(c.firstTimestamp),"MMM d, h:mm:ss a")}),c.lastTimestamp&&e.jsx(i,{label:"Last event",value:b(new Date(c.lastTimestamp),"MMM d, h:mm:ss a")})]}),e.jsxs(N,{title:"User",children:[e.jsx(i,{label:"Messages",value:`${t.totalMessages-t.metaMessages-t.toolResults} direct, ${t.metaMessages} meta, ${t.toolResults} tool results`}),t.commands.length>0&&e.jsx(i,{label:"Commands",value:t.commands.join(", "),cls:"font-mono"}),t.permissionModes.length>0&&e.jsx(i,{label:"Permission modes",value:t.permissionModes.join(", ")}),t.version&&e.jsx(i,{label:"Claude Code version",value:t.version,cls:"font-mono"}),t.cwd&&e.jsx(i,{label:"Working directory",value:t.cwd,cls:"font-mono text-xxs"})]}),e.jsxs(N,{title:"Assistant",children:[e.jsx(i,{label:"Responses",value:String(n.totalMessages)}),n.models.length>0&&e.jsx(i,{label:"Models",value:n.models.join(", "),cls:"font-mono"}),e.jsx(i,{label:"Input tokens",value:C(n.totalInputTokens)}),e.jsx(i,{label:"Output tokens",value:C(n.totalOutputTokens)}),n.totalCacheReadTokens>0&&e.jsx(i,{label:"Cache read tokens",value:C(n.totalCacheReadTokens)}),n.totalCacheCreationTokens>0&&e.jsx(i,{label:"Cache creation tokens",value:C(n.totalCacheCreationTokens)}),x.length>0&&e.jsxs("tr",{children:[e.jsx("td",{className:"pr-3 text-muted-foreground whitespace-nowrap align-top",children:"Tools used"}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:x.map(([a,m])=>e.jsxs(y,{variant:"outline",className:"font-mono text-xxs px-1.5 py-0",children:[a," ",e.jsx("span",{className:"ml-1 text-muted-foreground",children:m})]},a))})})]})]}),o.totalMessages>0&&e.jsxs(N,{title:"System",children:[e.jsx(i,{label:"Events",value:String(o.totalMessages)}),o.subtypes.length>0&&e.jsx(i,{label:"Subtypes",value:o.subtypes.join(", ")}),o.stopReasons.length>0&&e.jsx(i,{label:"Stop reasons",value:o.stopReasons.join(", ")}),o.totalDurationMs>0&&e.jsx(i,{label:"Total processing",value:L(o.totalDurationMs)}),o.hookCount>0&&e.jsx(i,{label:"Hooks fired",value:`${o.hookCount}${o.hookErrors>0?` (${o.hookErrors} errors)`:""}`})]}),e.jsx(N,{title:"Raw Counts",children:Object.entries(s.typeCounts).sort((a,m)=>m[1]-a[1]).map(([a,m])=>e.jsx(i,{label:a,value:String(m)},a))})]})}function N({title:s,children:t}){return e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-xxs font-medium uppercase tracking-wider text-foreground",children:s}),e.jsxs("table",{className:"w-full table-fixed text-xs",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"w-40"}),e.jsx("col",{})]}),e.jsx("tbody",{className:"[&_td]:border-b [&_td]:border-border/20 [&_td]:py-1.5 [&_td]:align-top [&_td:first-child]:pr-3 [&_td:first-child]:text-muted-foreground [&_td:first-child]:whitespace-nowrap",children:t})]})]})}function i({label:s,value:t,cls:n}){return e.jsxs("tr",{children:[e.jsx("td",{children:s}),e.jsx("td",{className:n,children:t})]})}function I({title:s,items:t,color:n}){return t.length===0?null:e.jsxs("div",{className:"mt-5",children:[e.jsx("h4",{className:"mb-2 text-xxs font-medium uppercase tracking-wider text-foreground",children:s}),e.jsx("ul",{className:"space-y-1.5",children:t.map(o=>e.jsxs("li",{className:"flex items-start gap-2 text-xs",children:[e.jsx("span",{className:T("mt-0.5",n),children:"•"}),e.jsx("span",{children:o})]},o))})]})}function P(s,t){return s.length>t?s.slice(0,t)+"...":s}function te(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function L(s){if(s<1e3)return`${s}ms`;const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),o=t%60;if(n<60)return`${n}m ${o}s`;const c=Math.floor(n/60),x=n%60;return`${c}h ${x}m`}function C(s){return s.toLocaleString()}export{ie as SessionTimeline};
@@ -0,0 +1,12 @@
1
+ import{j as e}from"./ui-BmsSg9jU.js";import{a as x}from"./vendor-Bqt8AJn2.js";import{c as he,a as u,q as ve,j as ye,s as ce,C as ue,g as fe,H as C,h as w,al as V,B as le,am as we,I as xe,an as ke,ao as Ce,ak as S,T as Se,a1 as te,a3 as se,a4 as ae,a5 as ne,ap as ie,Q as Pe,aq as re,S as $e,ar as Oe,as as Fe,at as Re,au as Me,d as Ue,av as me,P as Ae}from"./index-Bc9dK3MW.js";import{M as ge}from"./minus-GMsbpKym.js";import"./charts-DbDg0Psc.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Te=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],pe=he("archive",Te);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const _e=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],Ie=he("skip-forward",_e);function H({checked:t,onCheckedChange:l,disabled:d}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:d,onClick:()=>l(!t),className:u("relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border transition-colors duration-200",t?"border-[rgba(0,188,212,0.4)] bg-[rgba(0,188,212,0.25)]":"border-[rgba(255,255,255,0.1)] bg-[rgba(255,255,255,0.05)]",d&&"cursor-not-allowed opacity-40"),children:e.jsx("span",{className:u("pointer-events-none block h-3.5 w-3.5 rounded-full transition-all duration-200",t?"translate-x-[18px] bg-[rgb(0,188,212)] shadow-[0_0_8px_rgba(0,188,212,0.5)]":"translate-x-[2px] bg-[rgba(255,255,255,0.4)]")})})}function De(){const{getApiBase:t}=ve(),[l,d]=x.useState(null),[o,n]=x.useState(null),[a,i]=x.useState([]),[f,g]=x.useState(null),[k,N]=x.useState(null),[$,b]=x.useState(null),[s,R]=x.useState(null),[U,A]=x.useState(null),[h,O]=x.useState(null),[E,G]=x.useState(null),[Y,z]=x.useState(!0),[T,m]=x.useState(null),v=x.useCallback(async()=>{try{const c=await fetch("/api/orbital/aggregate/manifest/status");if(c.ok){const p=await c.json();d(p)}}catch{}finally{z(!1)}},[]),j=x.useCallback(async c=>{try{const p=await fetch(`${t(c)}/manifest/files`);if(p.ok){const F=await p.json();i(F.data??[])}}catch{}},[t]);x.useEffect(()=>{v()},[v]),ye(()=>{v(),o&&j(o)}),x.useEffect(()=>{const c=()=>{v(),o&&j(o)};return ce.on("manifest:changed",c),()=>{ce.off("manifest:changed",c)}},[v,j,o]);const q=x.useCallback(c=>{if(o===c){n(null),i([]);return}n(c),i([]),j(c)},[o,j]),Q=x.useCallback(()=>{n(null),i([])},[]),W=x.useCallback(async()=>{m("update-all");try{await fetch("/api/orbital/aggregate/manifest/update-all",{method:"POST",headers:{"Content-Type":"application/json"}}),await v()}catch{}finally{m(null)}},[v]),K=x.useCallback(async c=>{m(`preview:${c}`);try{const p=await fetch(`${t(c)}/manifest/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!0})});if(p.ok){const F=await p.json();N(F.data),b(c)}}catch{}finally{m(null)}},[t]),_=x.useCallback(async c=>{m(`update:${c}`);try{(await fetch(`${t(c)}/manifest/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!1})})).ok&&(N(null),b(null),await v())}catch{}finally{m(null)}},[t,v]),X=x.useCallback(async c=>{m(`init:${c}`);try{await fetch(`${t(c)}/manifest/init`,{method:"POST",headers:{"Content-Type":"application/json"}}),await v()}catch{}finally{m(null)}},[t,v]),Z=x.useCallback(async c=>{m(`validate:${c}`);try{const p=await fetch(`${t(c)}/manifest/validate`);if(p.ok){const F=await p.json();g(F.data)}}catch{}finally{m(null)}},[t]),B=x.useCallback(async(c,p,F)=>{m(`pin:${p}`);try{await fetch(`${t(c)}/manifest/pin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:p,reason:F})})}catch{}finally{m(null)}},[t]),L=x.useCallback(async(c,p)=>{m(`unpin:${p}`);try{await fetch(`${t(c)}/manifest/unpin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:p})})}catch{}finally{m(null)}},[t]),J=x.useCallback(async(c,p)=>{m(`reset:${p}`);try{await fetch(`${t(c)}/manifest/reset`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:p})})}catch{}finally{m(null)}},[t]),r=x.useCallback(async(c,p)=>{m(`revert:${p}`);try{await fetch(`${t(c)}/manifest/revert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:p})})}catch{}finally{m(null)}},[t]),P=x.useCallback(async(c,p,F)=>{var de;m(`diff:${p}`),A(p),O(F??null),G(c);try{const oe=await fetch(`${t(c)}/manifest/diff?file=${encodeURIComponent(p)}`);if(oe.ok){const Ne=await oe.json();R(((de=Ne.data)==null?void 0:de.diff)??null)}}catch{}finally{m(null)}},[t]),ee=x.useCallback(()=>{R(null),A(null),O(null),G(null)},[]),je=x.useCallback(()=>{N(null),b(null)},[]),be=x.useCallback(()=>g(null),[]);return{summary:l,loading:Y,actionLoading:T,expandedProjectId:o,projectFiles:a,validation:f,updatePreview:k,updatePreviewProjectId:$,diffContent:s,diffFile:U,diffFileStatus:h,diffProjectId:E,expandProject:q,collapseProject:Q,fetchSummary:v,updateAll:W,previewProjectUpdate:K,applyProjectUpdate:_,clearUpdatePreview:je,initProject:X,validateProject:Z,clearValidation:be,pinFile:B,unpinFile:L,resetFile:J,revertFile:r,getDiff:P,clearDiff:ee}}function Ee({files:t,actionLoading:l,onPin:d,onUnpin:o,onReset:n,onRevert:a,onDiff:i}){const f=t.filter(s=>s.status==="missing"),g=t.filter(s=>s.status==="outdated"),k=t.filter(s=>s.status==="modified"),N=t.filter(s=>s.status==="pinned"),$=t.filter(s=>s.status==="synced"),b=t.filter(s=>s.status==="user-owned");return t.length===0?e.jsx("div",{className:"text-xs text-muted-foreground/40 py-2 pl-4",children:"No tracked files."}):e.jsxs("div",{className:"pl-4 pb-2",children:[e.jsx(I,{title:`Missing (${f.length})`,description:"expected but not found on disk",files:f,defaultOpen:!0,renderRow:s=>e.jsx(D,{file:s,children:e.jsx(y,{label:"Restore",variant:"cyan",onClick:()=>n(s.path),loading:l===`reset:${s.path}`})},s.path)}),e.jsx(I,{title:`Outdated (${g.length})`,description:"newer template version available",files:g,defaultOpen:!1,renderRow:s=>e.jsxs(D,{file:s,children:[e.jsx(y,{label:"View changes",onClick:()=>i(s.path,s.status),loading:l===`diff:${s.path}`}),e.jsx(y,{label:"Update",variant:"cyan",onClick:()=>n(s.path),loading:l===`reset:${s.path}`}),s.hasPrev&&e.jsx(y,{label:"Revert",onClick:()=>a(s.path),loading:l===`revert:${s.path}`})]},s.path)}),e.jsx(I,{title:`Modified (${k.length})`,description:"edited by you",files:k,defaultOpen:!1,renderRow:s=>e.jsxs(D,{file:s,children:[e.jsx(y,{label:"View changes",onClick:()=>i(s.path,s.status),loading:l===`diff:${s.path}`}),e.jsx(y,{label:"Reset",onClick:()=>n(s.path),loading:l===`reset:${s.path}`}),e.jsx(y,{label:"Pin",variant:"blue",onClick:()=>d(s.path),loading:l===`pin:${s.path}`}),s.hasPrev&&e.jsx(y,{label:"Revert",onClick:()=>a(s.path),loading:l===`revert:${s.path}`})]},s.path)}),e.jsx(I,{title:`Pinned (${N.length})`,description:"locked from updates",files:N,defaultOpen:!1,renderRow:s=>e.jsxs(D,{file:s,meta:s.pinnedReason?`"${s.pinnedReason}"`:void 0,children:[e.jsx(y,{label:"View changes",onClick:()=>i(s.path,s.status),loading:l===`diff:${s.path}`}),e.jsx(y,{label:"Unpin",onClick:()=>o(s.path),loading:l===`unpin:${s.path}`}),e.jsx(y,{label:"Reset",onClick:()=>n(s.path),loading:l===`reset:${s.path}`}),s.hasPrev&&e.jsx(y,{label:"Revert",onClick:()=>a(s.path),loading:l===`revert:${s.path}`})]},s.path)}),e.jsx(I,{title:`Synced (${$.length})`,description:"matches template",files:$,defaultOpen:!1,renderRow:s=>e.jsx(D,{file:s,children:s.hasPrev&&e.jsx(y,{label:"Revert",onClick:()=>a(s.path),loading:l===`revert:${s.path}`})},s.path)}),e.jsx(I,{title:`User (${b.length})`,description:"your files, not managed",files:b,defaultOpen:!1,renderRow:s=>e.jsx(D,{file:s},s.path)})]})}function I({title:t,description:l,files:d,defaultOpen:o,renderRow:n}){const[a,i]=x.useState(o);return d.length===0?null:e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{onClick:()=>i(!a),className:"flex items-center gap-1.5 text-xs text-muted-foreground/70 hover:text-muted-foreground transition-colors mb-1",children:[a?e.jsx(ue,{className:"h-3 w-3"}):e.jsx(fe,{className:"h-3 w-3"}),e.jsx("span",{children:t}),e.jsx("span",{className:"text-muted-foreground/40 font-normal",children:l})]}),a&&e.jsx("div",{className:"space-y-1.5 ml-4",children:d.map(n)})]})}function D({file:t,meta:l,children:d}){return e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs font-mono text-foreground/70",children:t.path}),l&&e.jsx("span",{className:"text-xs text-muted-foreground/40 italic",children:l}),d]})}function y({label:t,variant:l,onClick:d,loading:o}){const n="rounded border px-1.5 py-0 text-[10px] leading-5 transition-colors disabled:opacity-40",a={cyan:"border-cyan-500/30 bg-cyan-500/10 text-cyan-400 hover:bg-cyan-500/20",blue:"border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20",default:"border-border bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"};return e.jsxs("button",{onClick:d,disabled:o,className:`${n} ${a[l??"default"]}`,children:[o?e.jsx(C,{className:"h-3 w-3 animate-spin inline mr-1"}):null,t]})}function ze({project:t,expanded:l,files:d,actionLoading:o,onToggle:n,onUpdate:a,onInit:i,onPin:f,onUnpin:g,onReset:k,onRevert:N,onDiff:$}){const{projectId:b,projectName:s,projectColor:R,status:U,manifest:A}=t;if(U==="no-manifest")return e.jsx("div",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${R})`}}),e.jsx("span",{className:"text-sm text-foreground truncate",children:s}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"No manifest"})]}),e.jsxs(w,{size:"sm",variant:"outline",onClick:i,disabled:o===`init:${b}`,className:"h-6 px-2 text-xs border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10",children:[o===`init:${b}`?e.jsx(C,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),"Initialize"]})]})});if(U==="error")return e.jsx("div",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0 opacity-40",style:{backgroundColor:`hsl(${R})`}}),e.jsx("span",{className:"text-sm text-foreground/50 truncate",children:s}),e.jsx("span",{className:"text-xs text-red-400/60",children:"Offline"})]})});const h=A,O=h.files.outdated>0||h.files.missing>0||h.needsUpdate;return e.jsxs("div",{className:"py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer hover:opacity-80 transition-opacity",onClick:n,children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${R})`}}),e.jsx("span",{className:"text-sm text-foreground truncate w-[140px] shrink-0",children:s}),e.jsxs(le,{variant:"outline",className:u("text-[10px] px-1.5 py-0 shrink-0",h.needsUpdate?"border-amber-500/30 text-amber-400 bg-amber-500/10":"border-green-500/30 text-green-400 bg-green-500/10"),children:["v",h.installedVersion]}),h.needsUpdate&&e.jsxs("span",{className:"text-[10px] text-amber-400/60 shrink-0",children:["→ v",h.packageVersion]}),e.jsxs("span",{className:"flex items-center text-xs shrink-0 tabular-nums",children:[e.jsxs("span",{className:u("w-[80px] text-center",h.files.missing>0?"text-red-400":"text-red-400/25"),children:[h.files.missing," missing"]}),e.jsxs("span",{className:u("w-[80px] text-center",h.files.outdated>0?"text-amber-400":"text-amber-400/25"),children:[h.files.outdated," outdated"]}),e.jsxs("span",{className:u("w-[80px] text-center",h.files.modified>0?"text-orange-400":"text-orange-400/25"),children:[h.files.modified," modified"]}),e.jsxs("span",{className:u("w-[80px] text-center",h.files.pinned>0?"text-blue-400":"text-blue-400/25"),children:[h.files.pinned," pinned"]}),e.jsxs("span",{className:u("w-[80px] text-center",h.files.synced>0?"text-green-400/50":"text-green-400/20"),children:[h.files.synced," synced"]}),e.jsxs("span",{className:u("w-[80px] text-center",h.files.userOwned>0?"text-muted-foreground/40":"text-muted-foreground/20"),children:[h.files.userOwned," user"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs(w,{size:"sm",variant:"outline",onClick:O?a:void 0,disabled:!O||o===`preview:${b}`||o===`update:${b}`,className:u("h-6 px-2 text-xs w-[130px] justify-center",O?"border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10":"border-green-500/30 text-green-400/60"),children:[o===`preview:${b}`||o===`update:${b}`?e.jsx(C,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),O?"Update Project":"Up to Date"]}),e.jsx("button",{onClick:n,className:"flex items-center justify-center h-6 w-6 rounded text-muted-foreground/40 hover:text-muted-foreground hover:bg-white/5 transition-colors",children:l?e.jsx(ue,{className:"h-3.5 w-3.5"}):e.jsx(fe,{className:"h-3.5 w-3.5"})})]})]}),l&&e.jsx(Ee,{files:d,actionLoading:o,onPin:f,onUnpin:g,onReset:k,onRevert:N,onDiff:$})]})}function Be(){var J;const{summary:t,loading:l,actionLoading:d,expandedProjectId:o,projectFiles:n,updatePreview:a,updatePreviewProjectId:i,diffContent:f,diffFile:g,diffFileStatus:k,diffProjectId:N,expandProject:$,updateAll:b,previewProjectUpdate:s,applyProjectUpdate:R,clearUpdatePreview:U,initProject:A,pinFile:h,unpinFile:O,resetFile:E,revertFile:G,getDiff:Y,clearDiff:z}=De(),{version:T,updateAvailable:m,behindCount:v,updateStage:j,updateError:q,checkForUpdate:Q,performUpdate:W}=we(),K=x.useCallback(async()=>{await W(),await b()},[W,b]),_=j==="pulling"||j==="installing",X=j==="checking"||j==="checked",[Z,B]=x.useState(!1);if(l)return e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(C,{className:"h-4 w-4 animate-spin"}),"Loading configuration status..."]});if(!t||t.total===0)return e.jsx("div",{className:"text-sm text-muted-foreground/60",children:"No projects registered."});const L=t.projectsOutdated===0&&t.noManifest===0&&t.totalOutdated===0&&t.totalMissing===0&&t.totalModified===0&&t.totalPinned===0;return e.jsxs(e.Fragment,{children:[T&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 flex items-baseline gap-3",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground/70",children:"Package"}),e.jsx("span",{className:"text-[11px] text-muted-foreground/40",children:"Globally installed Orbital Command version"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm text-foreground",children:"Orbital Command"}),e.jsxs(le,{variant:"outline",className:u("text-[10px] px-1.5 py-0",m?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-green-500/30 text-green-400 bg-green-500/10"),children:["v",T.version]}),m&&e.jsxs("span",{className:"text-xs text-emerald-400/70",children:[v," update",v!==1?"s":""," available"]}),j==="checked"&&!m&&e.jsx("span",{className:"text-xs text-green-400",children:"Up to date"}),j==="done"&&e.jsx("span",{className:"text-xs text-green-400",children:"Updated — restart server to apply"}),j==="error"&&e.jsx("span",{className:"text-xs text-red-400 truncate",children:q}),_&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(C,{className:"h-3 w-3 animate-spin"}),j==="pulling"?"Pulling...":"Installing..."]})]}),e.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[e.jsxs(w,{size:"sm",variant:"ghost",onClick:Q,disabled:_||X,className:"h-7 px-2 text-xs",children:[j==="checked"&&!m?e.jsx(xe,{className:"h-3 w-3 mr-1 text-green-400"}):e.jsx(ke,{className:u("h-3 w-3 mr-1",j==="checking"&&"animate-spin")}),j==="checked"&&!m?"Latest":"Check"]}),m&&j!=="done"&&e.jsxs(w,{size:"sm",variant:"outline",onClick:K,disabled:_,className:"h-7 px-2.5 text-xs border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10",children:[_?e.jsx(C,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(Ce,{className:"h-3 w-3 mr-1"}),"Update"]})]})]}),e.jsx(S,{className:"mb-4"})]}),e.jsxs("div",{className:"mb-2 flex items-baseline gap-3",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground/70",children:"Project Sync"}),e.jsx("span",{className:"text-[11px] text-muted-foreground/40",children:"Sync templates and config to your installed version"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 pl-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[L?e.jsx(xe,{className:"h-2 w-2 text-green-400 shrink-0"}):e.jsx(Se,{className:"h-2 w-2 text-amber-400 shrink-0"}),e.jsx("span",{className:"text-sm text-foreground truncate w-[140px] shrink-0",children:"All Projects"}),T&&e.jsxs(le,{variant:"outline",className:"text-[10px] px-1.5 py-0 shrink-0 border-green-500/30 text-green-400 bg-green-500/10",children:["v",T.version]}),e.jsxs("span",{className:"flex items-center text-xs shrink-0 tabular-nums",children:[e.jsxs("span",{className:u("w-[80px] text-center",t.totalMissing>0?"text-red-400":"text-red-400/25"),children:[t.totalMissing," missing"]}),e.jsxs("span",{className:u("w-[80px] text-center",t.totalOutdated>0?"text-amber-400":"text-amber-400/25"),children:[t.totalOutdated," outdated"]}),e.jsxs("span",{className:u("w-[80px] text-center",t.totalModified>0?"text-orange-400":"text-orange-400/25"),children:[t.totalModified," modified"]}),e.jsxs("span",{className:u("w-[80px] text-center",t.totalPinned>0?"text-blue-400":"text-blue-400/25"),children:[t.totalPinned," pinned"]}),e.jsxs("span",{className:u("w-[80px] text-center",t.totalSynced>0?"text-green-400/50":"text-green-400/20"),children:[t.totalSynced," synced"]}),e.jsxs("span",{className:u("w-[80px] text-center",t.totalUserOwned>0?"text-muted-foreground/40":"text-muted-foreground/20"),children:[t.totalUserOwned," user"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:t.totalOutdated>0||t.totalMissing>0?e.jsxs(w,{size:"sm",variant:"outline",onClick:()=>B(!0),disabled:d==="update-all",className:"h-6 px-2 text-xs w-[130px] justify-center border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10",children:[d==="update-all"?e.jsx(C,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),"Update All"]}):e.jsxs(w,{size:"sm",variant:"outline",disabled:!0,className:"h-6 px-2 text-xs w-[130px] justify-center border-green-500/30 text-green-400/60",children:[e.jsx(V,{className:"h-3 w-3 mr-1"}),"Up to Date"]})})]}),e.jsx(S,{className:"mb-2"}),e.jsx("div",{className:"space-y-0.5 pl-3",children:t.projects.map(r=>e.jsx(ze,{project:r,expanded:o===r.projectId,files:o===r.projectId?n:[],actionLoading:d,onToggle:()=>$(r.projectId),onUpdate:()=>s(r.projectId),onInit:()=>A(r.projectId),onPin:P=>h(r.projectId,P),onUnpin:P=>O(r.projectId,P),onReset:P=>E(r.projectId,P),onRevert:P=>G(r.projectId,P),onDiff:(P,ee)=>Y(r.projectId,P,ee)},r.projectId))}),e.jsx(te,{open:a!==null,onOpenChange:r=>{r||U()},children:e.jsxs(se,{className:"max-w-md p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_1fr_auto_auto]",children:[e.jsxs(ae,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsxs(ne,{className:"text-sm",children:["Update ",(J=t.projects.find(r=>r.projectId===i))==null?void 0:J.projectName]}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"Review what will happen before applying"})]}),e.jsx(S,{}),a&&!a.isEmpty&&e.jsxs("div",{className:"px-5 py-4 space-y-3 overflow-auto min-h-0",children:[(a.toUpdate.length>0||a.toAdd.length>0)&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ie,{className:"h-4 w-4 text-cyan-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[a.toUpdate.length+a.toAdd.length," file",a.toUpdate.length+a.toAdd.length!==1?"s":""," will be updated"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Synced and outdated files replaced with the latest template version"}),e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[a.toUpdate.map(r=>e.jsx("div",{className:"text-xs font-mono text-cyan-400/70",children:r},r)),a.toAdd.map(r=>e.jsxs("div",{className:"text-xs font-mono text-green-400/70",children:[r," ",e.jsx("span",{className:"text-muted-foreground/40",children:"(new)"})]},r))]})]})]}),a.toRename.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Pe,{className:"h-4 w-4 text-purple-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[a.toRename.length," file",a.toRename.length!==1?"s":""," will be renamed"]}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:a.toRename.map(r=>e.jsxs("div",{className:"text-xs font-mono text-purple-400/70",children:[r.from," → ",r.to]},r.from))})]})]}),a.toRemove.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ge,{className:"h-4 w-4 text-red-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[a.toRemove.length," file",a.toRemove.length!==1?"s":""," will be removed"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"No longer part of the template"}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:a.toRemove.map(r=>e.jsx("div",{className:"text-xs font-mono text-red-400/70",children:r},r))})]})]}),a.toSkip.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground/50 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground/70",children:[a.toSkip.length," file",a.toSkip.length!==1?"s":""," will be skipped"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Modified or pinned files are never overwritten"}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:a.toSkip.map(r=>e.jsxs("div",{className:"text-xs font-mono text-muted-foreground/40",children:[r.file," ",e.jsxs("span",{className:"text-muted-foreground/30",children:["(",r.reason,")"]})]},r.file))})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pe,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-xs text-muted-foreground/50",children:"Previous versions will be backed up and can be reverted"})]})]}),a&&a.isEmpty&&e.jsx("div",{className:"px-5 py-8 text-center text-sm text-muted-foreground",children:"Everything is up to date. No changes needed."}),e.jsx(S,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(re,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"sm",children:"Cancel"})}),a&&!a.isEmpty&&i&&e.jsxs(w,{size:"sm",onClick:()=>R(i),disabled:d===`update:${i}`,className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[d===`update:${i}`&&e.jsx(C,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update Project"]})]})]})}),e.jsx(te,{open:Z,onOpenChange:B,children:e.jsxs(se,{className:"max-w-md p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_1fr_auto_auto]",children:[e.jsxs(ae,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsx(ne,{className:"text-sm",children:"Update All Projects"}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"Review what will happen across all projects"})]}),e.jsx(S,{}),e.jsxs("div",{className:"px-5 py-4 space-y-3 overflow-auto min-h-0",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ie,{className:"h-4 w-4 text-cyan-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[t.totalOutdated+t.totalMissing," file",t.totalOutdated+t.totalMissing!==1?"s":""," to sync across ",t.projectsOutdated||t.projects.filter(r=>r.manifest&&(r.manifest.files.outdated>0||r.manifest.files.missing>0)).length," project",t.projects.filter(r=>r.manifest&&(r.manifest.files.outdated>0||r.manifest.files.missing>0)).length!==1?"s":""]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Synced and outdated files will be replaced with the latest template version"})]})]}),(t.totalModified>0||t.totalPinned>0)&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx($e,{className:"h-4 w-4 text-green-400/60 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground/70",children:[t.totalModified+t.totalPinned," file",t.totalModified+t.totalPinned!==1?"s":""," will not be touched"]}),e.jsxs("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:[t.totalModified>0&&e.jsxs(e.Fragment,{children:[t.totalModified," modified"]}),t.totalModified>0&&t.totalPinned>0&&" and ",t.totalPinned>0&&e.jsxs(e.Fragment,{children:[t.totalPinned," pinned"]})," ","file",t.totalModified+t.totalPinned!==1?"s":""," are never overwritten"]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(pe,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-xs text-muted-foreground/50",children:"Previous versions will be backed up and can be reverted"})]})]}),e.jsx(S,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(re,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"sm",children:"Cancel"})}),e.jsxs(w,{size:"sm",onClick:()=>{B(!1),b()},disabled:d==="update-all",className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[d==="update-all"&&e.jsx(C,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update All Projects"]})]})]})}),e.jsx(te,{open:g!==null,onOpenChange:r=>{r||z()},children:e.jsxs(se,{className:"max-w-2xl p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_auto_1fr_auto_auto]",children:[e.jsxs(ae,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsx(ne,{className:"text-sm font-mono",children:g}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"Template → Your file"})]}),e.jsx(S,{}),e.jsxs("div",{className:"px-5 py-2 text-xs text-muted-foreground/50",children:[e.jsx("span",{className:"text-red-400/70",children:"−"})," template version",e.jsx("span",{className:"mx-2",children:"·"}),e.jsx("span",{className:"text-green-400/70",children:"+"})," your local file"]}),e.jsx("div",{className:"overflow-auto min-h-0",children:f?e.jsx(Ge,{diff:f}):e.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:[e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}),"Loading diff..."]})}),e.jsx(S,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(re,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"sm",children:"Close"})}),k==="outdated"&&N&&e.jsxs(w,{size:"sm",onClick:()=>{E(N,g),z()},disabled:d===`reset:${g}`,className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[d===`reset:${g}`&&e.jsx(C,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update to latest"]}),k==="modified"&&N&&e.jsxs(w,{size:"sm",onClick:()=>{E(N,g),z()},disabled:d===`reset:${g}`,variant:"outline",children:[d===`reset:${g}`&&e.jsx(C,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Reset to template"]})]})]})})]})}function Ve(t){const l=t.split(`
12
+ `),d=[];let o=0,n=0;for(const a of l){const i=a.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@(.*)/);if(i){o=parseInt(i[1],10),n=parseInt(i[2],10),d.push({type:"hunk",content:a});continue}if(a.startsWith("diff ")||a.startsWith("index ")||a.startsWith("--- ")||a.startsWith("+++ ")){d.push({type:"meta",content:a});continue}if(a.startsWith("-"))d.push({type:"remove",content:a.slice(1),oldNum:o}),o++;else if(a.startsWith("+"))d.push({type:"add",content:a.slice(1),newNum:n}),n++;else{const f=a.startsWith(" ")?a.slice(1):a;d.push({type:"context",content:f,oldNum:o,newNum:n}),o++,n++}}return d}function Ge({diff:t}){const l=Ve(t),d=l.reduce((n,a)=>Math.max(n,a.oldNum??0,a.newNum??0),0),o=String(d).length;return e.jsx("div",{className:"text-[11px] font-mono leading-[1.6] pb-1",children:l.map((n,a)=>{if(n.type==="meta")return null;if(n.type==="hunk")return e.jsx("div",{className:"px-3 py-1.5 mt-1 first:mt-0 text-cyan-400/60 bg-cyan-500/5 border-y border-cyan-500/10 select-none",children:n.content},a);const i=n.oldNum!=null?String(n.oldNum).padStart(o):"".padStart(o),f=n.newNum!=null?String(n.newNum).padStart(o):"".padStart(o),g=u("flex",n.type==="add"&&"bg-green-500/10",n.type==="remove"&&"bg-red-500/10"),k=u("select-none border-r border-border/40 px-2 text-right shrink-0",n.type==="add"&&"text-green-400/40",n.type==="remove"&&"text-red-400/40",n.type==="context"&&"text-muted-foreground/25"),N=u("px-3 whitespace-pre-wrap break-all flex-1 min-w-0",n.type==="add"&&"text-green-400",n.type==="remove"&&"text-red-400",n.type==="context"&&"text-foreground/50"),$=n.type==="add"?"+":n.type==="remove"?"-":" ";return e.jsxs("div",{className:g,children:[e.jsx("span",{className:k,children:i}),e.jsx("span",{className:k,children:f}),e.jsx("span",{className:u("w-4 text-center shrink-0 select-none",n.type==="add"&&"text-green-400/60",n.type==="remove"&&"text-red-400/60",n.type==="context"&&"text-transparent"),children:$}),e.jsx("span",{className:N,children:n.content||" "})]},a)})})}function We(){return e.jsxs("section",{className:"card-glass rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-muted-foreground mb-5",children:"Configuration"}),e.jsx(Be,{})]})}const Je={monospace:"Monospace","sans-serif":"Sans-Serif",display:"Display"},He=["monospace","sans-serif","display"];function Ze(){var a;const{settings:t,updateSetting:l}=Oe(),{restart:d}=Fe();x.useEffect(()=>{Re()},[]);const o=()=>{const i=Math.max(.8,Math.round((t.fontScale-.05)*100)/100);l("fontScale",i)},n=()=>{const i=Math.min(1.3,Math.round((t.fontScale+.05)*100)/100);l("fontScale",i)};return e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(Me,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Settings"})]}),e.jsx(Ue,{className:"flex-1",children:e.jsxs("div",{className:"flex flex-col gap-6 pr-4 pb-8",children:[e.jsx(We,{}),e.jsxs("section",{className:"card-glass rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-muted-foreground mb-5",children:"Appearance"}),e.jsx(M,{label:"Font Family",description:"Typeface used across the dashboard",children:e.jsx("select",{value:t.fontFamily,onChange:i=>l("fontFamily",i.target.value),style:{fontFamily:`'${t.fontFamily}', ${((a=me.find(i=>i.family===t.fontFamily))==null?void 0:a.category)==="monospace"?"monospace":"sans-serif"}`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center"},className:"h-8 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 pr-7 text-sm text-foreground outline-none transition-colors hover:border-[rgba(0,188,212,0.3)] focus:border-[rgba(0,188,212,0.5)] focus:shadow-[0_0_8px_rgba(0,188,212,0.15)] appearance-none cursor-pointer",children:He.map(i=>e.jsx("optgroup",{label:Je[i],children:me.filter(f=>f.category===i).map(f=>e.jsxs("option",{value:f.family,children:[f.label,f.family==="Space Grotesk"?" (default)":""]},f.family))},i))})}),e.jsx(S,{className:"my-4"}),e.jsx(M,{label:"Font Size",description:"Scale text across the dashboard",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:o,disabled:t.fontScale<=.8,className:"flex h-7 w-7 items-center justify-center rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(ge,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"w-12 text-center text-sm tabular-nums",children:[Math.round(t.fontScale*100),"%"]}),e.jsx("button",{onClick:n,disabled:t.fontScale>=1.3,className:"flex h-7 w-7 items-center justify-center rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(Ae,{className:"h-3.5 w-3.5"})})]})}),e.jsx(S,{className:"my-4"}),e.jsx(M,{label:"Reduce Motion",description:"Disable animations and transitions",children:e.jsx(H,{checked:t.reduceMotion,onCheckedChange:i=>l("reduceMotion",i)})}),e.jsx(S,{className:"my-4"}),e.jsx(M,{label:"Background Effects",description:"Animated orbs and grid overlay",children:e.jsx(H,{checked:t.showBackgroundEffects,onCheckedChange:i=>l("showBackgroundEffects",i)})})]}),e.jsxs("section",{className:"card-glass rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-muted-foreground mb-5",children:"Display"}),e.jsx(M,{label:"Status Bar",description:"Scope progress bar at bottom",children:e.jsx(H,{checked:t.showStatusBar,onCheckedChange:i=>l("showStatusBar",i)})}),e.jsx(S,{className:"my-4"}),e.jsx(M,{label:"Compact Mode",description:"Reduce spacing for denser layout",children:e.jsx(H,{checked:t.compactMode,onCheckedChange:i=>l("compactMode",i)})})]}),e.jsxs("section",{className:"card-glass rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-muted-foreground mb-5",children:"Onboarding"}),e.jsx(M,{label:"Guided Tour",description:"Interactive walkthrough of all pages",children:e.jsxs("button",{onClick:d,className:"flex items-center gap-1.5 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground",children:[e.jsx(ie,{className:"h-3 w-3"}),"Restart tour"]})})]})]})})]})}function M({label:t,description:l,children:d}){return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-foreground",children:t}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:l})]}),e.jsx("div",{className:"flex-shrink-0",children:d})]})}export{Ze as Settings};
@@ -0,0 +1,41 @@
1
+ import{j as e}from"./ui-BmsSg9jU.js";import{a as c}from"./vendor-Bqt8AJn2.js";import{c as P,u as O,j as me,s as _,o as v,N as B,G as A,Y as W,Z as z,_ as T,$ as Q,B as f,a0 as $,q as ue,H as G,K as D,M as R,V as oe,d as fe,a as k,Q as De,a1 as Re,a2 as Pe,h as V,a3 as Me,a4 as He,a5 as Ee,a6 as _e,a7 as ge,a8 as X,i as Te,C as Y,g as ee,X as $e,O as Ie,T as je,a9 as pe,I as Ge,w as le}from"./index-Bc9dK3MW.js";import{R as Oe,A as Ue,d as Le}from"./charts-DbDg0Psc.js";import{f as U}from"./formatDistanceToNow-BMqsSP44.js";import{A as Ne}from"./arrow-down-CPy85_J6.js";import{G as be}from"./globe-Cn2yNZUD.js";import{K as Fe}from"./key-OPaNTWJ5.js";import{C as de}from"./circle-x-Cwz6ZQDV.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const qe=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ve=P("activity",qe);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const We=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],ye=P("arrow-up-down",We);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ze=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],we=P("arrow-up",ze);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Qe=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],se=P("git-pull-request",Qe);/**
22
+ * @license lucide-react v0.577.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Ke=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],K=P("github",Ke);/**
27
+ * @license lucide-react v0.577.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Je=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Xe=P("lock",Je);/**
32
+ * @license lucide-react v0.577.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Ze=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ye=P("log-out",Ze);/**
37
+ * @license lucide-react v0.577.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const es=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],Z=P("rocket",es),F=50;function ss(){const s=O(),[t,a]=c.useState(null),[r,o]=c.useState([]),[i,h]=c.useState([]),[n,d]=c.useState([]),[x,u]=c.useState(null),[l,m]=c.useState([]),[g,b]=c.useState(null),[p,C]=c.useState([]),[M,H]=c.useState(!0),[E,w]=c.useState(!0),y=c.useRef(0),S=c.useCallback(async j=>{try{const[N,L,ae,re,ne,ce,ie]=await Promise.all([fetch(s("/git/overview"),{signal:j}),fetch(s(`/git/commits?limit=${F}&offset=0`),{signal:j}),fetch(s("/git/branches"),{signal:j}),fetch(s("/git/worktrees"),{signal:j}),fetch(s("/git/drift"),{signal:j}),fetch(s("/git/health"),{signal:j}),fetch(s("/git/activity?days=30"),{signal:j})]);if(N.ok&&a(await N.json()),L.ok){const J=await L.json();o(J),y.current=J.length,w(J.length>=F)}ae.ok&&h(await ae.json()),re.ok&&d(await re.json()),ne.ok&&m(await ne.json()),ce.ok&&b(await ce.json()),ie.ok&&C(await ie.json())}catch(N){if(N instanceof DOMException&&N.name==="AbortError")return}finally{j!=null&&j.aborted||H(!1)}},[s]),I=c.useCallback(async j=>{try{const N=await fetch(s("/github/status"),{signal:j});N.ok&&u(await N.json())}catch(N){if(N instanceof DOMException&&N.name==="AbortError")return}},[s]),te=c.useCallback(()=>{S(),I()},[S,I]),Ae=c.useCallback(async()=>{try{const j=await fetch(s(`/git/commits?limit=${F}&offset=${y.current}`));if(j.ok){const N=await j.json();o(L=>[...L,...N]),y.current+=N.length,w(N.length>=F)}}catch{}},[s]);return c.useEffect(()=>{const j=new AbortController;return S(j.signal),I(j.signal),()=>j.abort()},[S,I]),me(te),c.useEffect(()=>{function j(){S()}return _.on("git:status:changed",j),()=>{_.off("git:status:changed",j)}},[S]),{overview:t,commits:r,branches:i,worktrees:n,github:x,drift:l,health:g,activity:p,loading:M,refetch:te,loadMoreCommits:Ae,hasMoreCommits:E,buildUrl:s}}function ts(s){const[t,a]=c.useState([]),[r,o]=c.useState([]),[i,h]=c.useState([]),[n,d]=c.useState([]),[x,u]=c.useState(new Map),[l,m]=c.useState(!0),g=c.useCallback(async()=>{if(s)try{const[p,C,M,H,E]=await Promise.all([fetch("/api/orbital/aggregate/git/overview"),fetch("/api/orbital/aggregate/git/commits?limit=50"),fetch("/api/orbital/aggregate/github/prs"),fetch("/api/orbital/aggregate/git/health"),fetch("/api/orbital/aggregate/git/activity?days=30")]);if(p.ok&&a(await p.json()),C.ok&&o(await C.json()),M.ok&&h(await M.json()),H.ok&&d(await H.json()),E.ok){const w=await E.json(),y=new Map;for(const S of w)y.set(S.projectId,S.series);u(y)}}catch{}finally{m(!1)}},[s]),b=c.useCallback(()=>{g()},[g]);return c.useEffect(()=>{s&&(m(!0),g())},[s,g]),c.useEffect(()=>{if(!s)return;function p(){g()}return _.on("git:status:changed",p),()=>{_.off("git:status:changed",p)}},[s,g]),{projectOverviews:t,commits:r,prs:i,branchHealth:n,activitySeries:x,loading:l,refetch:b}}function as(){const s=O(),[t,a]=c.useState(null),[r,o]=c.useState([]),[i,h]=c.useState([]),[n,d]=c.useState(!0),x=c.useCallback(async()=>{try{const[u,l,m]=await Promise.all([fetch(s("/pipeline/drift")),fetch(s("/deployments/frequency")),fetch(s("/deployments"))]);u.ok&&a(await u.json()),l.ok&&o(await l.json()),m.ok&&h(await m.json())}catch{}finally{d(!1)}},[s]);return c.useEffect(()=>{x()},[x]),me(x),c.useEffect(()=>{function u(){x()}return _.on("deploy:updated",u),()=>{_.off("deploy:updated",u)}},[x]),{drift:t,frequency:r,deployments:i,loading:n,refetch:x}}function ke({data:s,color:t="210 80% 55%",height:a=28}){if(s.length===0)return null;const r=`hsl(${t})`;return e.jsx("div",{style:{width:"100%",height:a},children:e.jsx(Oe,{width:"100%",height:"100%",children:e.jsxs(Ue,{data:s,margin:{top:0,right:0,bottom:0,left:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`sparkFill-${t.replace(/\s/g,"")}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:r,stopOpacity:.25}),e.jsx("stop",{offset:"100%",stopColor:r,stopOpacity:.02})]})}),e.jsx(Le,{type:"monotone",dataKey:"count",stroke:r,strokeWidth:1.5,fill:`url(#sparkFill-${t.replace(/\s/g,"")})`,isAnimationActive:!1})]})})})}function rs({overview:s,github:t,activity:a}){var r;return e.jsx(v,{className:"mb-6",children:e.jsxs(B,{className:"flex flex-wrap items-center gap-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4 text-primary"}),e.jsx("code",{className:"font-mono text-sm",children:s.currentBranch}),s.dirty&&e.jsxs(W,{children:[e.jsx(z,{children:e.jsx(T,{className:"h-2.5 w-2.5 fill-warning-amber text-warning-amber"})}),e.jsx(Q,{children:"Uncommitted changes"})]})]}),e.jsx(f,{variant:"outline",className:"text-xs",children:s.branchingMode}),s.mainHead&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:"HEAD"}),e.jsx("code",{className:"font-mono text-xs",children:s.mainHead.sha.slice(0,7)}),e.jsx("span",{className:"max-w-[200px] truncate",children:s.mainHead.message})]}),s.aheadBehind&&(s.aheadBehind.ahead>0||s.aheadBehind.behind>0)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(ye,{className:"h-3 w-3 text-muted-foreground"}),s.aheadBehind.ahead>0&&e.jsxs("span",{className:"text-bid-green",children:[s.aheadBehind.ahead,"↑"]}),s.aheadBehind.behind>0&&e.jsxs("span",{className:"text-ask-red",children:[s.aheadBehind.behind,"↓"]})]}),s.branchingMode==="worktree"&&s.worktreeCount>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx($,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.worktreeCount," worktree",s.worktreeCount!==1?"s":""]})]}),s.branchingMode==="trunk"&&s.featureBranchCount>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(A,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.featureBranchCount," feature branch",s.featureBranchCount!==1?"es":""]})]}),a&&a.length>0&&e.jsx("div",{className:"w-20",children:e.jsx(ke,{data:a,height:22})}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[e.jsx(K,{className:"h-3.5 w-3.5 text-muted-foreground"}),t!=null&&t.connected?e.jsxs(W,{children:[e.jsx(z,{children:e.jsxs(f,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(T,{className:"h-1.5 w-1.5 fill-bid-green text-bid-green"}),((r=t.repo)==null?void 0:r.fullName)??"Connected"]})}),e.jsx(Q,{children:t.authUser?`Signed in as ${t.authUser}`:"Connected to GitHub"})]}):e.jsx(f,{variant:"outline",className:"text-xs text-muted-foreground",children:"Not connected"})]})]})})}function ve({projectId:s,className:t}){const{hasMultipleProjects:a,getProjectColor:r,getProjectName:o}=ue();if(!a||!s)return null;const i=r(s),h=o(s);return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0 text-[10px] ${t??""}`,style:{borderColor:`hsl(${i} / 0.4)`,color:`hsl(${i})`,borderWidth:"1px",borderStyle:"solid"},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:`hsl(${i})`}}),h]})}const xe=new Map,ns=6e4;function Ce({commitSha:s,pr:t}){const a=O(),[r,o]=c.useState(null),[i,h]=c.useState(!1),n=c.useRef(!1),d=s??(t==null?void 0:t.branch);if(!d)return null;const x=async()=>{if(n.current||i)return;const m=xe.get(d);if(m&&Date.now()-m.ts<ns){o(m.data),n.current=!0;return}h(!0);try{const g=await fetch(a(`/github/checks/${d}`));if(g.ok){const b=await g.json();xe.set(d,{data:b,ts:Date.now()}),o(b)}}catch{}h(!1),n.current=!0};let u="text-muted-foreground/30",l="CI";if(r&&r.length>0){const m=r.some(p=>p.conclusion==="failure"),g=r.some(p=>p.status==="in_progress"||p.status==="queued"),b=r.every(p=>p.conclusion==="success"||p.conclusion==="neutral");m?(u="text-ask-red",l=`${r.filter(p=>p.conclusion==="failure").length} failing`):g?(u="text-warning-amber",l="Running"):b&&(u="text-bid-green",l="Passed")}return e.jsxs(W,{children:[e.jsx(z,{className:"shrink-0",onMouseEnter:x,children:i?e.jsx(G,{className:"h-3 w-3 animate-spin text-muted-foreground/50"}):e.jsx(T,{className:`h-2.5 w-2.5 fill-current ${u}`})}),e.jsx(Q,{side:"top",className:"max-w-xs",children:r===null?e.jsx("span",{className:"text-xs",children:"Hover to load CI status"}):r.length===0?e.jsx("span",{className:"text-xs",children:"No CI checks"}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:l}),r.slice(0,5).map((m,g)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(T,{className:`h-1.5 w-1.5 fill-current ${m.conclusion==="success"?"text-bid-green":m.conclusion==="failure"?"text-ask-red":"text-warning-amber"}`}),e.jsx("span",{className:"truncate",children:m.name})]},g)),r.length>5&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["+",r.length-5," more"]})]})})]})}function cs({commit:s}){return e.jsxs("div",{className:"flex items-center gap-3 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",children:[e.jsx(Ce,{commitSha:s.sha}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-primary",children:s.shortSha}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:s.message}),e.jsx(ve,{projectId:s.project_id}),s.branch&&e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:s.branch}),s.scopeId&&e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",s.scopeId]}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:s.author}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:U(new Date(s.date),{addSuffix:!0})})]})}function Se({commits:s,branches:t,hasMore:a,onLoadMore:r}){const[o,i]=c.useState("all"),h=c.useMemo(()=>{const x=new Set(["main","master","dev","develop","staging","production"]);for(const u of t)!u.isRemote&&!u.name.startsWith("feat/")&&!u.name.startsWith("fix/")&&x.add(u.name);return x},[t]),n=c.useMemo(()=>o==="all"?s:o==="main"?s.filter(x=>!x.branch||h.has(x.branch)):s.filter(x=>x.branch&&!h.has(x.branch)),[s,o,h]),d=[{key:"all",label:"All"},{key:"main",label:"Main"},{key:"feature",label:"Feature"}];return e.jsxs(v,{className:"lg:col-span-2",children:[e.jsx(D,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(oe,{className:"h-4 w-4 text-primary"}),"Commits",e.jsx(f,{variant:"secondary",children:n.length})]}),e.jsx("div",{className:"flex gap-1",children:d.map(x=>e.jsx("button",{onClick:()=>i(x.key),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${o===x.key?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"}`,children:x.label},x.key))})]})}),e.jsx(B,{children:n.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(oe,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No commits found."})]}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"max-h-[600px]",children:e.jsx("div",{className:"space-y-0.5",children:n.map(x=>e.jsx(cs,{commit:x},x.sha))})}),a&&e.jsx("button",{onClick:r,className:"mt-3 w-full rounded border border-border py-2 text-xs text-muted-foreground transition-colors hover:bg-surface-light hover:text-foreground",children:"Load more commits"})]})})]})}function is({branches:s}){const t=[...s].filter(a=>!a.isRemote).sort((a,r)=>a.isCurrent?-1:r.isCurrent?1:a.isStale!==r.isStale?a.isStale?1:-1:new Date(r.headDate).getTime()-new Date(a.headDate).getTime());return t.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(A,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No branches found."})]}):e.jsx("div",{className:"space-y-0.5",children:t.map(a=>e.jsxs("div",{className:k("flex items-center gap-2 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",a.isStale&&"opacity-50"),children:[e.jsx(A,{className:k("h-3.5 w-3.5 shrink-0",a.isCurrent?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:k("min-w-0 flex-1 truncate font-mono text-xs",a.isCurrent&&"text-foreground font-medium"),children:a.name}),a.scopeId&&e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",a.scopeId]}),a.aheadBehind&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-xs",children:[a.aheadBehind.ahead>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-bid-green",children:[e.jsx(we,{className:"h-2.5 w-2.5"}),a.aheadBehind.ahead]}),a.aheadBehind.behind>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-ask-red",children:[e.jsx(Ne,{className:"h-2.5 w-2.5"}),a.aheadBehind.behind]})]}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:a.headSha}),a.headDate&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:U(new Date(a.headDate),{addSuffix:!0})})]},a.name))})}function os({worktrees:s}){return s.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx($,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No active worktrees."})]}):e.jsx("div",{className:"space-y-1",children:s.map(t=>e.jsxs("div",{className:"rounded border border-border/50 px-3 py-2 transition-colors hover:bg-surface-light",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t.branch}),t.dirty&&e.jsx(T,{className:"h-2 w-2 shrink-0 fill-warning-amber text-warning-amber"}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:t.head})]}),t.scopeId&&e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs(f,{variant:"secondary",className:"text-xs",children:["#",t.scopeId]}),t.scopeTitle&&e.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:t.scopeTitle}),t.scopeStatus&&e.jsx(f,{variant:"outline",className:k("shrink-0 text-xs capitalize"),children:t.scopeStatus})]}),t.aheadBehind&&(t.aheadBehind.ahead>0||t.aheadBehind.behind>0)&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs",children:[t.aheadBehind.ahead>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-bid-green",children:[e.jsx(we,{className:"h-2.5 w-2.5"}),t.aheadBehind.ahead," ahead"]}),t.aheadBehind.behind>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-ask-red",children:[e.jsx(Ne,{className:"h-2.5 w-2.5"}),t.aheadBehind.behind," behind"]})]})]},t.path))})}function ls(s){return s===0?"text-bid-green":s<=5?"text-accent-blue":s<=20?"text-warning-amber":"text-ask-red"}function ds({branches:s,worktrees:t,drift:a,branchingMode:r}){const o=r==="worktree",[i,h]=c.useState("branches");return e.jsxs(v,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(A,{className:"h-4 w-4 text-primary"}),o?i==="branches"?"Branches":"Worktrees":"Branches",e.jsx(f,{variant:"secondary",children:i==="branches"?s.filter(n=>!n.isRemote).length:t.length})]}),o&&e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("button",{onClick:()=>h("branches"),className:k("rounded-md px-2.5 py-1 text-xs transition-colors",i==="branches"?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(A,{className:"inline h-3 w-3 mr-1"}),"Branches"]}),e.jsxs("button",{onClick:()=>h("worktrees"),className:k("rounded-md px-2.5 py-1 text-xs transition-colors",i==="worktrees"?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx($,{className:"inline h-3 w-3 mr-1"}),"Worktrees"]})]})]})}),e.jsxs(B,{children:[e.jsx(fe,{className:"max-h-[400px]",children:i==="branches"?e.jsx(is,{branches:s}):e.jsx(os,{worktrees:t})}),a.length>0&&e.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[e.jsx("h4",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Branch Drift"}),e.jsx("div",{className:"space-y-1.5",children:a.map(n=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("code",{className:"font-mono text-muted-foreground",children:n.from}),e.jsx(De,{className:"h-3 w-3 text-muted-foreground/50"}),e.jsx("code",{className:"font-mono text-muted-foreground",children:n.to}),e.jsx(f,{variant:"outline",className:k("ml-auto text-xs",ls(n.count)),children:n.count===0?"in sync":`${n.count} commit${n.count!==1?"s":""}`})]},`${n.from}-${n.to}`))})]})]})]})}function xs({error:s,onConnected:t}){const a=O(),[r,o]=c.useState(!1),[i,h]=c.useState("oauth"),[n,d]=c.useState("idle"),[x,u]=c.useState(""),[l,m]=c.useState(""),g=c.useRef(),b=c.useRef(),p=s==null?void 0:s.includes("not installed"),C=c.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=void 0)},[]);c.useEffect(()=>()=>{C(),clearTimeout(b.current)},[C]);const M=async()=>{d("connecting"),m("");try{const y=await(await fetch(a("/github/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"oauth"})})).json();y.success?(d("polling"),g.current=setInterval(async()=>{try{(await(await fetch(a("/github/auth-status"))).json()).authenticated&&(C(),clearTimeout(b.current),d("success"),setTimeout(()=>{o(!1),t()},1e3))}catch{}},2e3),b.current=setTimeout(()=>{g.current&&(C(),d("error"),m("Authentication timed out. Please try again."))},12e4)):(d("error"),m(y.error??"Failed to start OAuth flow"))}catch{d("error"),m("Failed to connect to server")}},H=async()=>{if(x.trim()){d("connecting"),m("");try{const y=await(await fetch(a("/github/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"pat",token:x.trim()})})).json();y.success?(d("success"),u(""),setTimeout(()=>{o(!1),t()},1e3)):(d("error"),m(y.error??"Authentication failed"))}catch{d("error"),m("Failed to connect to server")}}},E=w=>{o(w),w||(C(),d("idle"),m(""),u(""))};return e.jsxs(Re,{open:r,onOpenChange:E,children:[e.jsx(Pe,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(K,{className:"h-4 w-4"}),"Connect GitHub"]})}),e.jsxs(Me,{className:"sm:max-w-md",children:[e.jsxs(He,{children:[e.jsxs(Ee,{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-5 w-5"}),"Connect to GitHub"]}),e.jsx(_e,{children:p?"The GitHub CLI (gh) is required. Install it first, then authenticate.":"Authenticate with GitHub to see PRs, CI status, and repo info."})]}),p?e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"rounded border border-border bg-surface-light p-3",children:[e.jsx("p",{className:"text-sm mb-2",children:"Install the GitHub CLI:"}),e.jsx("code",{className:"text-xs font-mono bg-background px-2 py-1 rounded",children:"brew install gh"}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Or visit"," ",e.jsxs("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 text-primary hover:underline",children:["cli.github.com ",e.jsx(ge,{className:"h-2.5 w-2.5"})]})]})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-1 rounded-md bg-surface-light p-1",children:[e.jsxs("button",{onClick:()=>h("oauth"),className:`flex-1 flex items-center justify-center gap-2 rounded px-3 py-2 text-sm transition-colors ${i==="oauth"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(be,{className:"h-4 w-4"}),"Browser OAuth"]}),e.jsxs("button",{onClick:()=>h("pat"),className:`flex-1 flex items-center justify-center gap-2 rounded px-3 py-2 text-sm transition-colors ${i==="pat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Fe,{className:"h-4 w-4"}),"Access Token"]})]}),i==="oauth"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opens your browser to authenticate with GitHub. This is the recommended method."}),e.jsxs(V,{onClick:M,disabled:n==="connecting"||n==="polling"||n==="success",className:"w-full gap-2",children:[n==="connecting"&&e.jsx(G,{className:"h-4 w-4 animate-spin"}),n==="polling"&&e.jsx(G,{className:"h-4 w-4 animate-spin"}),n==="success"&&e.jsx(X,{className:"h-4 w-4"}),n==="polling"?"Waiting for browser...":n==="success"?"Connected!":"Connect with GitHub"]})]}),i==="pat"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paste a GitHub Personal Access Token. Needs ",e.jsx("code",{className:"text-xs",children:"repo"})," and ",e.jsx("code",{className:"text-xs",children:"read:org"})," scopes."]}),e.jsx("input",{type:"password",placeholder:"ghp_xxxxxxxxxxxxxxxxxxxx",value:x,onChange:w=>u(w.target.value),disabled:n==="connecting"||n==="success",className:"flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50"}),e.jsxs(V,{onClick:H,disabled:!x.trim()||n==="connecting"||n==="success",className:"w-full gap-2",children:[n==="connecting"&&e.jsx(G,{className:"h-4 w-4 animate-spin"}),n==="success"&&e.jsx(X,{className:"h-4 w-4"}),n==="success"?"Connected!":"Authenticate"]})]}),n==="error"&&l&&e.jsxs("div",{className:"flex items-center gap-2 rounded bg-ask-red/10 px-3 py-2 text-xs text-ask-red",children:[e.jsx(Te,{className:"h-4 w-4 shrink-0"}),l]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60",children:"GitHub authentication is global — connecting here applies to all projects."})]})]})]})}function hs({github:s,onConnectionChange:t}){var n;const a=O(),[r,o]=c.useState(!0),i=c.useCallback(async()=>{try{await fetch(a("/github/disconnect"),{method:"POST"}),t==null||t()}catch{}},[a,t]),h=((n=s==null?void 0:s.repo)==null?void 0:n.visibility)==="public"?be:Xe;return e.jsxs(v,{className:"mt-6",children:[e.jsx(D,{className:"cursor-pointer select-none",onClick:()=>o(!r),children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[r?e.jsx(Y,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ee,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(K,{className:"h-4 w-4 text-primary"}),"GitHub",(s==null?void 0:s.connected)&&s.repo&&e.jsxs(f,{variant:"secondary",className:"ml-1 text-xs gap-1",children:[e.jsx(h,{className:"h-2.5 w-2.5"}),s.repo.fullName]}),s!=null&&s.openPRs?e.jsxs(f,{variant:"outline",className:"text-xs",children:[s.openPRs," open PR",s.openPRs!==1?"s":""]}):null]})}),r&&e.jsx(B,{children:!s||!s.connected?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect to GitHub to see repository info, pull requests, and CI status."}),e.jsx(xs,{error:(s==null?void 0:s.error)??null,onConnected:()=>t==null?void 0:t()})]}):e.jsxs("div",{className:"space-y-4",children:[s.repo&&e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Repository"}),e.jsx("a",{href:s.repo.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:s.repo.fullName}),e.jsx("span",{className:"text-muted-foreground",children:"Default branch"}),e.jsx("code",{className:"font-mono",children:s.repo.defaultBranch}),e.jsx("span",{className:"text-muted-foreground",children:"Visibility"}),e.jsxs("span",{className:"flex items-center gap-1 capitalize",children:[e.jsx(h,{className:"h-3 w-3"}),s.repo.visibility]}),s.authUser&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"Signed in as"}),e.jsx("span",{children:s.authUser})]})]}),e.jsx("div",{className:"border-t border-border pt-3",children:e.jsxs(V,{variant:"ghost",size:"sm",onClick:d=>{d.stopPropagation(),i()},className:"gap-2 text-xs text-muted-foreground hover:text-ask-red",children:[e.jsx(Ye,{className:"h-3 w-3"}),"Disconnect"]})})]})})]})}function ms({decision:s}){return s==="APPROVED"?e.jsx(X,{className:"h-3.5 w-3.5 text-bid-green"}):s==="CHANGES_REQUESTED"?e.jsx($e,{className:"h-3.5 w-3.5 text-ask-red"}):e.jsx(Ie,{className:"h-3.5 w-3.5 text-warning-amber"})}function Be(s){const[t,a]=c.useState(!0),[r,o]=c.useState("all"),[i,h]=c.useState([]),n=c.useCallback(async()=>{if(!(s.isAggregate||!s.buildUrl))try{const l=await fetch(s.buildUrl("/github/prs"));l.ok&&h(await l.json())}catch{}},[s.isAggregate,s.buildUrl]);c.useEffect(()=>{s.isAggregate||n()},[s.isAggregate,n]);const d=s.isAggregate?s.prs:i,x=d.filter(l=>r==="all"?!0:r==="pending"?!l.reviewDecision||l.reviewDecision==="REVIEW_REQUIRED":r==="approved"?l.reviewDecision==="APPROVED":r==="changes"?l.reviewDecision==="CHANGES_REQUESTED":!0);if(d.length===0)return null;const u=[{key:"all",label:"All"},{key:"pending",label:"Pending"},{key:"approved",label:"Approved"},{key:"changes",label:"Changes"}];return e.jsxs(v,{className:"mb-6",children:[e.jsx(D,{className:"cursor-pointer select-none pb-2",onClick:()=>a(!t),children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[t?e.jsx(Y,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ee,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(se,{className:"h-4 w-4 text-primary"}),"Pull Requests",e.jsx(f,{variant:"secondary",children:d.length})]})}),t&&e.jsxs(B,{children:[e.jsx("div",{className:"mb-3 flex gap-1",children:u.map(l=>e.jsx("button",{onClick:m=>{m.stopPropagation(),o(l.key)},className:`rounded-md px-2.5 py-1 text-xs transition-colors ${r===l.key?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"}`,children:l.label},l.key))}),e.jsx("div",{className:"space-y-0.5",children:x.map(l=>e.jsxs("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light group",children:[e.jsx(ms,{decision:l.reviewDecision}),e.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["#",l.number]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:l.title}),e.jsx(ve,{projectId:l.project_id}),e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:l.branch}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"→"}),e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:l.baseBranch}),l.scopeIds.map(m=>e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",m]},m)),e.jsx(Ce,{pr:l}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:l.author}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:U(new Date(l.lastActivityAt??l.createdAt),{addSuffix:!0})}),e.jsx(ge,{className:"h-3 w-3 shrink-0 text-muted-foreground/40 opacity-0 group-hover:opacity-100 transition-opacity"})]},`${l.project_id??""}-${l.number}`))}),x.length===0&&e.jsx("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No PRs match this filter."})]})]})}function us({overviews:s,activitySeries:t}){return s.length===0?null:e.jsx("div",{className:"mb-6 grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:s.map(a=>e.jsx(fs,{project:a,activity:t.get(a.projectId)??[]},a.projectId))})}function fs({project:s,activity:t}){const{projectName:a,projectColor:r,status:o,overview:i,error:h}=s;return e.jsx(v,{className:"overflow-hidden",children:e.jsxs(B,{className:"py-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:`hsl(${r})`}}),e.jsx("span",{className:"font-medium text-sm",style:{color:`hsl(${r})`},children:a}),o==="error"&&e.jsx(f,{variant:"destructive",className:"text-xs ml-auto",children:"Error"})]}),o==="error"?e.jsx("p",{className:"text-xs text-muted-foreground",children:h}):i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("code",{className:"font-mono text-xs",children:i.currentBranch}),i.dirty&&e.jsxs(W,{children:[e.jsx(z,{children:e.jsx(T,{className:"h-2 w-2 fill-warning-amber text-warning-amber"})}),e.jsx(Q,{children:"Uncommitted changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[i.aheadBehind&&(i.aheadBehind.ahead>0||i.aheadBehind.behind>0)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ye,{className:"h-3 w-3"}),i.aheadBehind.ahead>0&&e.jsxs("span",{className:"text-bid-green",children:[i.aheadBehind.ahead,"↑"]}),i.aheadBehind.behind>0&&e.jsxs("span",{className:"text-ask-red",children:[i.aheadBehind.behind,"↓"]})]}),i.featureBranchCount>0&&e.jsxs("span",{children:[i.featureBranchCount," branch",i.featureBranchCount!==1?"es":""]}),e.jsx(f,{variant:"outline",className:"text-[10px] py-0",children:i.branchingMode})]}),i.mainHead&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(se,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:i.mainHead.message}),e.jsx("span",{className:"shrink-0 text-muted-foreground/60",children:U(new Date(i.mainHead.date),{addSuffix:!0})})]}),t.length>0&&e.jsx(ke,{data:t,color:r})]}):null]})})}function gs(s){return s==="clean"?"text-bid-green":s==="low"?"text-accent-blue":s==="moderate"?"text-warning-amber":"text-ask-red"}function js({health:s}){return s.length===0?e.jsxs(v,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(A,{className:"h-4 w-4 text-primary"}),"Branch Health"]})}),e.jsx(B,{children:e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No branch data available."})})]}):e.jsxs(v,{children:[e.jsx(D,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(A,{className:"h-4 w-4 text-primary"}),"Branch Health"]})}),e.jsx(B,{children:e.jsx("div",{className:"space-y-2",children:s.map(t=>e.jsxs("div",{className:"flex items-center gap-3 rounded px-2.5 py-2 transition-colors hover:bg-surface-light",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${t.projectColor})`}}),e.jsx("span",{className:"text-sm font-medium min-w-[100px]",style:{color:`hsl(${t.projectColor})`},children:t.projectName}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.branchCount," branch",t.branchCount!==1?"es":""]}),t.staleBranchCount>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-warning-amber",children:[e.jsx(je,{className:"h-3 w-3"}),t.staleBranchCount," stale"]}),t.featureBranchCount>0&&e.jsxs(f,{variant:"secondary",className:"text-xs",children:[t.featureBranchCount," feature"]}),e.jsx(f,{variant:"outline",className:k("ml-auto text-xs",gs(t.maxDriftSeverity)),children:t.maxDriftSeverity==="clean"?"in sync":`${t.maxDriftSeverity} drift`})]},t.projectId))})})]})}function ps(s){return s==="A"?"text-bid-green":s==="B"?"text-accent-blue":s==="C"?"text-warning-amber":"text-ask-red"}function Ns(s){return s==="A"?"bg-bid-green/10":s==="B"?"bg-accent-blue/10":s==="C"?"bg-warning-amber/10":"bg-ask-red/10"}function bs({health:s}){return e.jsx(v,{className:"mb-6",children:e.jsxs(B,{className:"flex items-center gap-6 py-3",children:[e.jsx("div",{className:k("flex items-center justify-center h-12 w-12 rounded-lg text-2xl font-bold shrink-0",Ns(s.grade),ps(s.grade)),children:s.grade}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1",children:[e.jsx(q,{icon:e.jsx(Ve,{className:"h-3.5 w-3.5"}),label:"Commits/week",value:String(s.commitsPerWeek),warn:s.commitsPerWeek<5}),e.jsx(q,{icon:e.jsx(se,{className:"h-3.5 w-3.5"}),label:"Avg PR age",value:s.avgPrAgeDays>0?`${s.avgPrAgeDays}d`:"--",warn:s.avgPrAgeDays>3}),e.jsx(q,{icon:e.jsx(A,{className:"h-3.5 w-3.5"}),label:"Stale branches",value:String(s.staleBranchCount),warn:s.staleBranchCount>0}),e.jsx(q,{icon:e.jsx(je,{className:"h-3.5 w-3.5"}),label:"Drift",value:s.driftSeverity,warn:s.driftSeverity!=="clean"})]})]})})}function q({icon:s,label:t,value:a,warn:r}){return e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:r?"text-warning-amber":"text-muted-foreground",children:s}),e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("span",{className:k("font-medium",r?"text-warning-amber":"text-foreground"),children:a})]})}const ys={deploying:{icon:G,color:"text-accent-blue",label:"Deploying",animate:"animate-spin"},healthy:{icon:Ge,color:"text-bid-green",label:"Healthy"},failed:{icon:de,color:"text-ask-red",label:"Failed"},"rolled-back":{icon:de,color:"text-warning-amber",label:"Rolled Back"}},he=20;function ws(s){const t=new Map;for(const a of s){const r=a.started_at?pe(new Date(a.started_at),"yyyy-MM-dd"):"Unknown",o=t.get(r);o?o.push(a):t.set(r,[a])}return t}function ks(s){if(!s.started_at||!s.completed_at)return null;const t=new Date(s.completed_at).getTime()-new Date(s.started_at).getTime();return t<1e3?"<1s":t<6e4?`${Math.round(t/1e3)}s`:`${Math.round(t/6e4)}m`}function vs({deployments:s}){const[t,a]=c.useState(!1),r=t?s:s.slice(0,he),o=ws(r);return e.jsxs(v,{children:[e.jsx(D,{children:e.jsxs(R,{className:"text-base",children:["Deployment History",e.jsx(f,{variant:"secondary",className:"ml-2",children:s.length})]})}),e.jsx(B,{children:s.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(Z,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No deployments recorded yet."})]}):e.jsxs("div",{className:"space-y-4",children:[[...o.entries()].map(([i,h])=>e.jsxs("div",{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-card pb-1 pt-0.5",children:e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:i==="Unknown"?"Unknown date":pe(new Date(i),"EEEE, MMM d")})}),e.jsx("div",{className:"space-y-0.5",children:h.map(n=>{const d=ys[n.status],x=d.icon,u=ks(n);return e.jsxs("div",{className:"flex items-center gap-4 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",children:[e.jsx(x,{className:k("h-4 w-4 shrink-0",d.color,d.animate)}),e.jsx(f,{variant:"outline",className:"capitalize shrink-0",children:n.environment}),e.jsx("span",{className:"text-xs font-normal shrink-0",children:d.label}),n.commit_sha&&e.jsx("code",{className:"font-mono text-xs text-muted-foreground shrink-0",children:n.commit_sha.slice(0,7)}),n.branch&&e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.branch}),u&&e.jsx("span",{className:"font-mono text-xs text-muted-foreground/60 shrink-0",children:u}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground/60 shrink-0",children:n.started_at?U(new Date(n.started_at),{addSuffix:!0}):"—"})]},n.id)})})]},i)),!t&&s.length>he&&e.jsxs("button",{onClick:()=>a(!0),className:"w-full rounded border border-border py-2 text-xs text-muted-foreground transition-colors hover:bg-surface-light hover:text-foreground",children:["Show all ",s.length," deployments"]})]})})]})}function Ts(){const{activeProjectId:s,hasMultipleProjects:t}=ue(),a=t&&s===null,r=ss(),o=ts(a),{deployments:i}=as(),[h,n]=c.useState(!0);return(a?o.loading:r.loading)?e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(le,{}),e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"})})]}):e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(le,{}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:a?e.jsx(Ss,{aggregate:o}):e.jsx(Cs,{sourceControl:r,deployments:i,deployExpanded:h,setDeployExpanded:n})})]})}function Cs({sourceControl:s,deployments:t,deployExpanded:a,setDeployExpanded:r}){const{overview:o,commits:i,branches:h,worktrees:n,github:d,drift:x,loadMoreCommits:u,hasMoreCommits:l,health:m,activity:g,refetch:b}=s;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx($,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Repo"}),o&&e.jsx(f,{variant:"secondary",children:o.currentBranch})]}),o&&e.jsx(rs,{overview:o,github:d,activity:g}),m&&e.jsx(bs,{health:m}),(d==null?void 0:d.connected)&&e.jsx(Be,{buildUrl:s.buildUrl}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx(Se,{commits:i,branches:h,hasMore:l,onLoadMore:u}),e.jsx(ds,{branches:h,worktrees:n,drift:x,branchingMode:(o==null?void 0:o.branchingMode)??"trunk"})]}),e.jsx(hs,{github:d,onConnectionChange:b}),t.length>0&&e.jsx("div",{className:"mt-6",children:a?e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>r(!1),className:"mb-2 flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Y,{className:"h-4 w-4"}),e.jsx(Z,{className:"h-4 w-4"}),"Deploy History"]}),e.jsx(vs,{deployments:t})]}):e.jsx(v,{className:"cursor-pointer select-none",onClick:()=>r(!0),children:e.jsx(D,{children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Z,{className:"h-4 w-4 text-primary"}),"Deploy History",e.jsx(f,{variant:"secondary",children:t.length})]})})})})]})}function Ss({aggregate:s}){const{projectOverviews:t,commits:a,prs:r,branchHealth:o,activitySeries:i}=s;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx($,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Repo"}),e.jsx(f,{variant:"secondary",children:"All Projects"})]}),e.jsx(us,{overviews:t,activitySeries:i}),r.length>0&&e.jsx(Be,{prs:r,isAggregate:!0}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx(Se,{commits:a,branches:[],hasMore:!1,onLoadMore:()=>{}}),e.jsx(js,{health:o})]})]})}export{Ts as SourceControl};