@polderlabs/bizar 7.0.2 → 8.0.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.
- package/.claude/settings.local.json +8 -0
- package/bizar-dash/DESIGN.md +729 -969
- package/bizar-dash/GLYPH.md +418 -0
- package/bizar-dash/PLAN.md +1135 -0
- package/bizar-dash/dist/assets/ActivityFeed-BRBtQOHB.js +6 -0
- package/bizar-dash/dist/assets/ActivityFeed-BRBtQOHB.js.map +1 -0
- package/bizar-dash/dist/assets/ActivityView-CwqhxBfh.js +1 -0
- package/bizar-dash/dist/assets/ActivityView-CwqhxBfh.js.map +1 -0
- package/bizar-dash/dist/assets/AgentActivity-6MxU-a9F.js +1 -0
- package/bizar-dash/dist/assets/AgentActivity-6MxU-a9F.js.map +1 -0
- package/bizar-dash/dist/assets/AgentsView-BYrOFdwl.js +8 -0
- package/bizar-dash/dist/assets/AgentsView-BYrOFdwl.js.map +1 -0
- package/bizar-dash/dist/assets/Badge-Cd61wsBa.js +1 -0
- package/bizar-dash/dist/assets/Badge-Cd61wsBa.js.map +1 -0
- package/bizar-dash/dist/assets/Card-C_bvqXdQ.js +1 -0
- package/bizar-dash/dist/assets/Card-C_bvqXdQ.js.map +1 -0
- package/bizar-dash/dist/assets/EmptyState-BWQuKnk9.js +1 -0
- package/bizar-dash/dist/assets/EmptyState-BWQuKnk9.js.map +1 -0
- package/bizar-dash/dist/assets/GoalsView-Dok0yt9S.js +11 -0
- package/bizar-dash/dist/assets/GoalsView-Dok0yt9S.js.map +1 -0
- package/bizar-dash/dist/assets/Grid-C62gCPqt.js +1 -0
- package/bizar-dash/dist/assets/Grid-C62gCPqt.js.map +1 -0
- package/bizar-dash/dist/assets/KanbanCard-CtTKP6ZX.js +21 -0
- package/bizar-dash/dist/assets/KanbanCard-CtTKP6ZX.js.map +1 -0
- package/bizar-dash/dist/assets/LibrariesView-BcyBQXiY.js +67 -0
- package/bizar-dash/dist/assets/LibrariesView-BcyBQXiY.js.map +1 -0
- package/bizar-dash/dist/assets/MemoryView-49wR4u-y.js +13 -0
- package/bizar-dash/dist/assets/MemoryView-49wR4u-y.js.map +1 -0
- package/bizar-dash/dist/assets/OverviewView-BtQ_UWYj.js +1 -0
- package/bizar-dash/dist/assets/OverviewView-BtQ_UWYj.js.map +1 -0
- package/bizar-dash/dist/assets/ProgressBar-CpvDeq9F.js +1 -0
- package/bizar-dash/dist/assets/ProgressBar-CpvDeq9F.js.map +1 -0
- package/bizar-dash/dist/assets/SettingsRow-DmIe5OUu.js +30 -0
- package/bizar-dash/dist/assets/SettingsRow-DmIe5OUu.js.map +1 -0
- package/bizar-dash/dist/assets/SettingsView-D1KmGWbi.js +48 -0
- package/bizar-dash/dist/assets/SettingsView-D1KmGWbi.js.map +1 -0
- package/bizar-dash/dist/assets/StatTile-BkIP32gG.js +11 -0
- package/bizar-dash/dist/assets/StatTile-BkIP32gG.js.map +1 -0
- package/bizar-dash/dist/assets/TasksView-Cba3GJ42.js +1 -0
- package/bizar-dash/dist/assets/TasksView-Cba3GJ42.js.map +1 -0
- package/bizar-dash/dist/assets/ViewHeader-D6c2cw1b.js +6 -0
- package/bizar-dash/dist/assets/ViewHeader-D6c2cw1b.js.map +1 -0
- package/bizar-dash/dist/assets/brain-DeoXNDE2.js +6 -0
- package/bizar-dash/dist/assets/brain-DeoXNDE2.js.map +1 -0
- package/bizar-dash/dist/assets/calendar-DRlQkGJc.js +6 -0
- package/bizar-dash/dist/assets/calendar-DRlQkGJc.js.map +1 -0
- package/bizar-dash/dist/assets/circle-check-DmYQ3vGp.js +6 -0
- package/bizar-dash/dist/assets/circle-check-DmYQ3vGp.js.map +1 -0
- package/bizar-dash/dist/assets/cmdk-BwN8hcKQ.js +80 -0
- package/bizar-dash/dist/assets/cmdk-BwN8hcKQ.js.map +1 -0
- package/bizar-dash/dist/assets/dnd-kit-DR2Qzzxk.js +5 -0
- package/bizar-dash/dist/assets/dnd-kit-DR2Qzzxk.js.map +1 -0
- package/bizar-dash/dist/assets/git-merge-OoqBKQer.js +6 -0
- package/bizar-dash/dist/assets/git-merge-OoqBKQer.js.map +1 -0
- package/bizar-dash/dist/assets/git-pull-request-CXBQTR2f.js +6 -0
- package/bizar-dash/dist/assets/git-pull-request-CXBQTR2f.js.map +1 -0
- package/bizar-dash/dist/assets/main-COdgjqbZ.css +1 -0
- package/bizar-dash/dist/assets/main-Cw6gybzS.js +109 -0
- package/bizar-dash/dist/assets/main-Cw6gybzS.js.map +1 -0
- package/bizar-dash/dist/assets/message-square-DUTeIQAR.js +6 -0
- package/bizar-dash/dist/assets/message-square-DUTeIQAR.js.map +1 -0
- package/bizar-dash/dist/assets/minus-CrStJTZ7.js +6 -0
- package/bizar-dash/dist/assets/minus-CrStJTZ7.js.map +1 -0
- package/bizar-dash/dist/assets/wrench-BJ1WIC4u.js +6 -0
- package/bizar-dash/dist/assets/wrench-BJ1WIC4u.js.map +1 -0
- package/bizar-dash/dist/{mobile.html → v8.html} +6 -9
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/bizar-dash/src/server/server.mjs +1 -57
- package/bizar-dash/src/web/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/bizar-dash/src/web/v8/App.tsx +188 -0
- package/bizar-dash/src/web/v8/__tests__/App.test.tsx +102 -0
- package/bizar-dash/src/web/v8/__tests__/AppShell.test.tsx +79 -0
- package/bizar-dash/src/web/v8/__tests__/PageSkeleton.test.tsx +12 -0
- package/bizar-dash/src/web/v8/__tests__/SettingsView.test.tsx +84 -0
- package/bizar-dash/src/web/v8/__tests__/Sidebar.test.tsx +95 -0
- package/bizar-dash/src/web/v8/__tests__/activity.test.tsx +63 -0
- package/bizar-dash/src/web/v8/__tests__/agents.test.tsx +90 -0
- package/bizar-dash/src/web/v8/__tests__/controls.test.tsx +135 -0
- package/bizar-dash/src/web/v8/__tests__/cx.test.ts +25 -0
- package/bizar-dash/src/web/v8/__tests__/data.test.tsx +293 -0
- package/bizar-dash/src/web/v8/__tests__/feedback.test.tsx +213 -0
- package/bizar-dash/src/web/v8/__tests__/goals.test.tsx +105 -0
- package/bizar-dash/src/web/v8/__tests__/kanban.test.tsx +176 -0
- package/bizar-dash/src/web/v8/__tests__/libraries.test.tsx +70 -0
- package/bizar-dash/src/web/v8/__tests__/memory.test.tsx +60 -0
- package/bizar-dash/src/web/v8/__tests__/navigation.test.tsx +137 -0
- package/bizar-dash/src/web/v8/__tests__/settings.test.tsx +104 -0
- package/bizar-dash/src/web/v8/__tests__/theme.test.tsx +98 -0
- package/bizar-dash/src/web/v8/__tests__/views.test.tsx +112 -0
- package/bizar-dash/src/web/v8/main.tsx +28 -0
- package/bizar-dash/src/web/v8/shell/AppShell.tsx +90 -0
- package/bizar-dash/src/web/v8/shell/PageSkeleton.tsx +29 -0
- package/bizar-dash/src/web/v8/shell/Sidebar.tsx +361 -0
- package/bizar-dash/src/web/v8/shell/StatusBar.tsx +63 -0
- package/bizar-dash/src/web/v8/shell/Topbar.tsx +113 -0
- package/bizar-dash/src/web/v8/shell/index.ts +15 -0
- package/bizar-dash/src/web/v8/ui/activity/ActivityFeed.tsx +137 -0
- package/bizar-dash/src/web/v8/ui/agents/AgentActivity.tsx +101 -0
- package/bizar-dash/src/web/v8/ui/agents/AgentCard.tsx +158 -0
- package/bizar-dash/src/web/v8/ui/controls/Button.tsx +141 -0
- package/bizar-dash/src/web/v8/ui/controls/ButtonGroup.tsx +32 -0
- package/bizar-dash/src/web/v8/ui/controls/Checkbox.tsx +49 -0
- package/bizar-dash/src/web/v8/ui/controls/Field.tsx +78 -0
- package/bizar-dash/src/web/v8/ui/controls/Form.tsx +23 -0
- package/bizar-dash/src/web/v8/ui/controls/IconButton.tsx +112 -0
- package/bizar-dash/src/web/v8/ui/controls/Input.tsx +94 -0
- package/bizar-dash/src/web/v8/ui/controls/RadioGroup.tsx +74 -0
- package/bizar-dash/src/web/v8/ui/controls/Select.tsx +171 -0
- package/bizar-dash/src/web/v8/ui/controls/Slider.tsx +68 -0
- package/bizar-dash/src/web/v8/ui/controls/Switch.tsx +56 -0
- package/bizar-dash/src/web/v8/ui/controls/Textarea.tsx +64 -0
- package/bizar-dash/src/web/v8/ui/controls/Toggle.tsx +36 -0
- package/bizar-dash/src/web/v8/ui/controls/ToggleGroup.tsx +85 -0
- package/bizar-dash/src/web/v8/ui/data/Accordion.tsx +134 -0
- package/bizar-dash/src/web/v8/ui/data/Avatar.tsx +175 -0
- package/bizar-dash/src/web/v8/ui/data/Badge.tsx +93 -0
- package/bizar-dash/src/web/v8/ui/data/BarList.tsx +101 -0
- package/bizar-dash/src/web/v8/ui/data/Card.tsx +140 -0
- package/bizar-dash/src/web/v8/ui/data/Chip.tsx +96 -0
- package/bizar-dash/src/web/v8/ui/data/Kbd.tsx +42 -0
- package/bizar-dash/src/web/v8/ui/data/ProgressBar.tsx +93 -0
- package/bizar-dash/src/web/v8/ui/data/Sparkline.tsx +98 -0
- package/bizar-dash/src/web/v8/ui/data/StatTile.tsx +150 -0
- package/bizar-dash/src/web/v8/ui/data/Table.tsx +170 -0
- package/bizar-dash/src/web/v8/ui/data/Timeline.tsx +130 -0
- package/bizar-dash/src/web/v8/ui/data/ViewHeader.tsx +122 -0
- package/bizar-dash/src/web/v8/ui/feedback/Alert.tsx +95 -0
- package/bizar-dash/src/web/v8/ui/feedback/Banner.tsx +39 -0
- package/bizar-dash/src/web/v8/ui/feedback/ContextMenu.tsx +143 -0
- package/bizar-dash/src/web/v8/ui/feedback/Dialog.tsx +149 -0
- package/bizar-dash/src/web/v8/ui/feedback/Drawer.tsx +8 -0
- package/bizar-dash/src/web/v8/ui/feedback/DropdownMenu.tsx +231 -0
- package/bizar-dash/src/web/v8/ui/feedback/EmptyState.tsx +48 -0
- package/bizar-dash/src/web/v8/ui/feedback/Popover.tsx +56 -0
- package/bizar-dash/src/web/v8/ui/feedback/Sheet.tsx +103 -0
- package/bizar-dash/src/web/v8/ui/feedback/Skeleton.tsx +67 -0
- package/bizar-dash/src/web/v8/ui/feedback/Spinner.tsx +30 -0
- package/bizar-dash/src/web/v8/ui/feedback/Toast.tsx +66 -0
- package/bizar-dash/src/web/v8/ui/feedback/Tooltip.tsx +89 -0
- package/bizar-dash/src/web/v8/ui/goals/GoalCard.tsx +176 -0
- package/bizar-dash/src/web/v8/ui/goals/KeyResult.tsx +115 -0
- package/bizar-dash/src/web/v8/ui/index.ts +322 -0
- package/bizar-dash/src/web/v8/ui/kanban/KanbanBoard.tsx +80 -0
- package/bizar-dash/src/web/v8/ui/kanban/KanbanCard.tsx +247 -0
- package/bizar-dash/src/web/v8/ui/kanban/KanbanColumn.tsx +181 -0
- package/bizar-dash/src/web/v8/ui/kanban/KanbanContextMenu.tsx +122 -0
- package/bizar-dash/src/web/v8/ui/kanban/KanbanQuickAdd.tsx +141 -0
- package/bizar-dash/src/web/v8/ui/libraries/LibraryGrid.tsx +30 -0
- package/bizar-dash/src/web/v8/ui/libraries/LibraryItem.tsx +161 -0
- package/bizar-dash/src/web/v8/ui/memory/MemoryVault.tsx +144 -0
- package/bizar-dash/src/web/v8/ui/navigation/CommandPalette.tsx +224 -0
- package/bizar-dash/src/web/v8/ui/navigation/NavLink.tsx +81 -0
- package/bizar-dash/src/web/v8/ui/navigation/Pagination.tsx +164 -0
- package/bizar-dash/src/web/v8/ui/navigation/Tabs.tsx +128 -0
- package/bizar-dash/src/web/v8/ui/navigation/useCommandPaletteHotkey.test.ts +79 -0
- package/bizar-dash/src/web/v8/ui/primitives/Box.tsx +144 -0
- package/bizar-dash/src/web/v8/ui/primitives/Center.tsx +40 -0
- package/bizar-dash/src/web/v8/ui/primitives/Cluster.tsx +67 -0
- package/bizar-dash/src/web/v8/ui/primitives/Grid.tsx +104 -0
- package/bizar-dash/src/web/v8/ui/primitives/Inline.tsx +77 -0
- package/bizar-dash/src/web/v8/ui/primitives/Portal.tsx +33 -0
- package/bizar-dash/src/web/v8/ui/primitives/ScrollArea.tsx +62 -0
- package/bizar-dash/src/web/v8/ui/primitives/Separator.tsx +42 -0
- package/bizar-dash/src/web/v8/ui/primitives/Stack.tsx +73 -0
- package/bizar-dash/src/web/v8/ui/primitives/VisuallyHidden.tsx +49 -0
- package/bizar-dash/src/web/v8/ui/settings/SettingsNav.tsx +91 -0
- package/bizar-dash/src/web/v8/ui/settings/SettingsRow.tsx +88 -0
- package/bizar-dash/src/web/v8/ui/settings/SettingsSection.tsx +109 -0
- package/bizar-dash/src/web/v8/ui/styles/globals.css +220 -0
- package/bizar-dash/src/web/v8/ui/styles/reset.css +57 -0
- package/bizar-dash/src/web/v8/ui/styles/tokens.css +217 -0
- package/bizar-dash/src/web/v8/ui/theme/DensityProvider.test.tsx +74 -0
- package/bizar-dash/src/web/v8/ui/theme/DensityProvider.tsx +66 -0
- package/bizar-dash/src/web/v8/ui/theme/ThemeProvider.test.tsx +86 -0
- package/bizar-dash/src/web/v8/ui/theme/ThemeProvider.tsx +94 -0
- package/bizar-dash/src/web/v8/ui/theme/ThemeToggle.tsx +88 -0
- package/bizar-dash/src/web/v8/ui/theme/useDensity.ts +15 -0
- package/bizar-dash/src/web/v8/ui/theme/useTheme.ts +16 -0
- package/bizar-dash/src/web/v8/ui/utils/cx.ts +19 -0
- package/bizar-dash/src/web/v8/views/Activity/ActivityView.tsx +33 -0
- package/bizar-dash/src/web/v8/views/Agents/AgentsView.tsx +108 -0
- package/bizar-dash/src/web/v8/views/CommandPalette/AppCommandPalette.test.tsx +142 -0
- package/bizar-dash/src/web/v8/views/CommandPalette/AppCommandPalette.tsx +144 -0
- package/bizar-dash/src/web/v8/views/Goals/GoalsView.tsx +84 -0
- package/bizar-dash/src/web/v8/views/Libraries/LibrariesView.tsx +41 -0
- package/bizar-dash/src/web/v8/views/Memory/MemoryView.tsx +61 -0
- package/bizar-dash/src/web/v8/views/Overview/OverviewView.tsx +92 -0
- package/bizar-dash/src/web/v8/views/Router.tsx +96 -0
- package/bizar-dash/src/web/v8/views/Settings/SettingsView.tsx +305 -0
- package/bizar-dash/src/web/v8/views/Tasks/CommandPalettePlaceholder.tsx +106 -0
- package/bizar-dash/src/web/v8/views/Tasks/TasksKanbanPlaceholder.tsx +62 -0
- package/bizar-dash/src/web/v8/views/Tasks/TasksView.tsx +74 -0
- package/bizar-dash/src/web/v8/vite-env.d.ts +15 -0
- package/bizar-dash/src/web/{mobile.html → v8.html} +4 -7
- package/bizar-dash/tests/settings-layout.test.tsx +2 -2
- package/bizar-dash/tests/settings-nav.test.tsx +6 -6
- package/bizar-dash/tests/setup.ts +26 -0
- package/bizar-dash/vite.config.ts +26 -2
- package/bizar-dash/vitest.config.ts +5 -3
- package/cli/provision-claude.mjs +108 -5
- package/package.json +36 -3
- package/bizar-dash/dist/assets/EnvVarsSection-BfhAz3ax.js +0 -114
- package/bizar-dash/dist/assets/EnvVarsSection-BfhAz3ax.js.map +0 -1
- package/bizar-dash/dist/assets/MobileChat-DLWdv6tQ.js +0 -1
- package/bizar-dash/dist/assets/MobileChat-DLWdv6tQ.js.map +0 -1
- package/bizar-dash/dist/assets/MobileSettings-Bxv62uPY.js +0 -1
- package/bizar-dash/dist/assets/MobileSettings-Bxv62uPY.js.map +0 -1
- package/bizar-dash/dist/assets/Toast-ATSAmbdi.js +0 -26
- package/bizar-dash/dist/assets/Toast-ATSAmbdi.js.map +0 -1
- package/bizar-dash/dist/assets/__vite-browser-external-BIHI7g3E.js +0 -1
- package/bizar-dash/dist/assets/__vite-browser-external-BIHI7g3E.js.map +0 -1
- package/bizar-dash/dist/assets/main-306CZfn6.js +0 -430
- package/bizar-dash/dist/assets/main-306CZfn6.js.map +0 -1
- package/bizar-dash/dist/assets/main-G3bNDpY3.css +0 -1
- package/bizar-dash/dist/assets/mobile-C_naUN91.js +0 -1
- package/bizar-dash/dist/assets/mobile-C_naUN91.js.map +0 -1
- package/bizar-dash/dist/assets/mobile-layout-BWLtwtfQ.css +0 -1
- package/bizar-dash/dist/assets/mobile-layout-GZ3bE8L6.js +0 -211
- package/bizar-dash/dist/assets/mobile-layout-GZ3bE8L6.js.map +0 -1
- package/bizar-dash/dist/assets/useSlashCommands-BOwD7lNb.js +0 -65
- package/bizar-dash/dist/assets/useSlashCommands-BOwD7lNb.js.map +0 -1
- package/bizar-dash/dist/index.html +0 -43
- package/bizar-dash/src/web/App.tsx +0 -915
- package/bizar-dash/src/web/MobileApp.tsx +0 -414
- package/bizar-dash/src/web/components/ArtifactCreateDialog.tsx +0 -95
- package/bizar-dash/src/web/components/ArtifactListDialog.tsx +0 -55
- package/bizar-dash/src/web/components/ArtifactViewer.tsx +0 -144
- package/bizar-dash/src/web/components/AuditDialog.tsx +0 -79
- package/bizar-dash/src/web/components/AutosaveField.tsx +0 -50
- package/bizar-dash/src/web/components/BackupRestore.tsx +0 -330
- package/bizar-dash/src/web/components/BgStatusBadge.tsx +0 -32
- package/bizar-dash/src/web/components/Button.tsx +0 -56
- package/bizar-dash/src/web/components/CanvasContextMenu.tsx +0 -68
- package/bizar-dash/src/web/components/Card.tsx +0 -40
- package/bizar-dash/src/web/components/CollapsibleSection.tsx +0 -72
- package/bizar-dash/src/web/components/CommandDialog.tsx +0 -66
- package/bizar-dash/src/web/components/DoctorPanel.tsx +0 -160
- package/bizar-dash/src/web/components/EmptyState.tsx +0 -30
- package/bizar-dash/src/web/components/EnvVarManager.tsx +0 -430
- package/bizar-dash/src/web/components/EvalDiff.tsx +0 -157
- package/bizar-dash/src/web/components/EvalExportButton.tsx +0 -27
- package/bizar-dash/src/web/components/EvalRunCard.tsx +0 -78
- package/bizar-dash/src/web/components/FileBrowser.tsx +0 -633
- package/bizar-dash/src/web/components/HeadroomSettings.tsx +0 -418
- package/bizar-dash/src/web/components/HeadroomStatus.tsx +0 -158
- package/bizar-dash/src/web/components/HelpDialog.tsx +0 -55
- package/bizar-dash/src/web/components/InviteDialog.tsx +0 -205
- package/bizar-dash/src/web/components/KillConfirmDialog.tsx +0 -88
- package/bizar-dash/src/web/components/MobileBottomNav.tsx +0 -38
- package/bizar-dash/src/web/components/MobileDrawer.tsx +0 -68
- package/bizar-dash/src/web/components/MobileHeader.tsx +0 -50
- package/bizar-dash/src/web/components/MobileLayout.tsx +0 -63
- package/bizar-dash/src/web/components/Modal.tsx +0 -215
- package/bizar-dash/src/web/components/Notifications.tsx +0 -242
- package/bizar-dash/src/web/components/ScheduleTemplateCard.tsx +0 -72
- package/bizar-dash/src/web/components/ScreenshotCapture.tsx +0 -138
- package/bizar-dash/src/web/components/ScreenshotOCR.tsx +0 -42
- package/bizar-dash/src/web/components/SearchModal.tsx +0 -227
- package/bizar-dash/src/web/components/SettingsNav.tsx +0 -112
- package/bizar-dash/src/web/components/SettingsSearch.tsx +0 -328
- package/bizar-dash/src/web/components/Sidebar.tsx +0 -89
- package/bizar-dash/src/web/components/Spinner.tsx +0 -19
- package/bizar-dash/src/web/components/StatusBadge.tsx +0 -56
- package/bizar-dash/src/web/components/Tag.tsx +0 -41
- package/bizar-dash/src/web/components/TailscaleSettings.tsx +0 -161
- package/bizar-dash/src/web/components/TaskCard.tsx +0 -69
- package/bizar-dash/src/web/components/TaskCreateSheet.tsx +0 -76
- package/bizar-dash/src/web/components/Toast.tsx +0 -150
- package/bizar-dash/src/web/components/Toggle.tsx +0 -31
- package/bizar-dash/src/web/components/Topbar.tsx +0 -410
- package/bizar-dash/src/web/components/UsageChart.tsx +0 -250
- package/bizar-dash/src/web/components/UsageTable.tsx +0 -90
- package/bizar-dash/src/web/components/VirtualList.tsx +0 -53
- package/bizar-dash/src/web/components/VisualPlanDialog.tsx +0 -58
- package/bizar-dash/src/web/components/VoiceNotesPanel.tsx +0 -211
- package/bizar-dash/src/web/components/VoiceRecorder.tsx +0 -105
- package/bizar-dash/src/web/components/WorkspaceSelector.tsx +0 -158
- package/bizar-dash/src/web/components/agents/CommunicationLog.tsx +0 -126
- package/bizar-dash/src/web/components/agents/DependencyGraph.tsx +0 -163
- package/bizar-dash/src/web/components/agents/QualityGates.tsx +0 -123
- package/bizar-dash/src/web/components/agents/RealTimeEventLog.tsx +0 -127
- package/bizar-dash/src/web/components/agents/RoutingDecisions.test.tsx +0 -148
- package/bizar-dash/src/web/components/agents/RoutingDecisions.tsx +0 -160
- package/bizar-dash/src/web/components/background/AttachButton.tsx +0 -96
- package/bizar-dash/src/web/components/background/TmuxAttachCard.tsx +0 -122
- package/bizar-dash/src/web/components/chat/AgentChip.tsx +0 -68
- package/bizar-dash/src/web/components/chat/AgentNode.tsx +0 -127
- package/bizar-dash/src/web/components/chat/AgentTree.tsx +0 -80
- package/bizar-dash/src/web/components/chat/ChatBubble.tsx +0 -60
- package/bizar-dash/src/web/components/chat/ChatComposer.tsx +0 -72
- package/bizar-dash/src/web/components/chat/ChatInfoPanel.tsx +0 -370
- package/bizar-dash/src/web/components/chat/ChatRail.tsx +0 -387
- package/bizar-dash/src/web/components/chat/ChatThread.tsx +0 -127
- package/bizar-dash/src/web/components/chat/ChatTopBar.tsx +0 -50
- package/bizar-dash/src/web/components/chat/Composer.tsx +0 -166
- package/bizar-dash/src/web/components/chat/ConfirmModal.tsx +0 -54
- package/bizar-dash/src/web/components/chat/EmptyState.tsx +0 -21
- package/bizar-dash/src/web/components/chat/FirstRunGreeting.tsx +0 -18
- package/bizar-dash/src/web/components/chat/FloatingComposer.tsx +0 -38
- package/bizar-dash/src/web/components/chat/InfoPanel.tsx +0 -184
- package/bizar-dash/src/web/components/chat/JumpToLatest.tsx +0 -58
- package/bizar-dash/src/web/components/chat/LoadingSkeleton.tsx +0 -19
- package/bizar-dash/src/web/components/chat/MessageBlock.tsx +0 -260
- package/bizar-dash/src/web/components/chat/MessageBubble.tsx +0 -60
- package/bizar-dash/src/web/components/chat/SessionList.tsx +0 -163
- package/bizar-dash/src/web/components/chat/SessionRowMenu.tsx +0 -206
- package/bizar-dash/src/web/components/chat/StreamingIndicator.tsx +0 -37
- package/bizar-dash/src/web/components/chat/SuggestionCards.tsx +0 -55
- package/bizar-dash/src/web/components/chat/WelcomeScreen.tsx +0 -36
- package/bizar-dash/src/web/components/chat/_legacy.ts +0 -30
- package/bizar-dash/src/web/components/chat/index.ts +0 -31
- package/bizar-dash/src/web/components/chat/useAutoGrowTextarea.ts +0 -18
- package/bizar-dash/src/web/components/chat/useChat.ts +0 -1190
- package/bizar-dash/src/web/components/chat/useSlashCommands.ts +0 -47
- package/bizar-dash/src/web/components/goals/GoalInput.tsx +0 -86
- package/bizar-dash/src/web/components/goals/PlanVisualization.tsx +0 -111
- package/bizar-dash/src/web/components/tasks/BacklogPanel.css +0 -109
- package/bizar-dash/src/web/components/tasks/BacklogPanel.tsx +0 -209
- package/bizar-dash/src/web/hooks/useAutosave.ts +0 -107
- package/bizar-dash/src/web/hooks/useI18n.ts +0 -13
- package/bizar-dash/src/web/index.html +0 -37
- package/bizar-dash/src/web/lib/api.ts +0 -237
- package/bizar-dash/src/web/lib/goapPlanner.ts +0 -614
- package/bizar-dash/src/web/lib/i18n.ts +0 -25
- package/bizar-dash/src/web/lib/logger.ts +0 -30
- package/bizar-dash/src/web/lib/markdown.tsx +0 -59
- package/bizar-dash/src/web/lib/search.ts +0 -115
- package/bizar-dash/src/web/lib/types.ts +0 -894
- package/bizar-dash/src/web/lib/utils.ts +0 -114
- package/bizar-dash/src/web/lib/ws.ts +0 -177
- package/bizar-dash/src/web/locales/en.json +0 -52
- package/bizar-dash/src/web/main.tsx +0 -43
- package/bizar-dash/src/web/mobile/MobileApp.tsx +0 -309
- package/bizar-dash/src/web/mobile/MobileBottomNav.tsx +0 -38
- package/bizar-dash/src/web/mobile/MobileChat.tsx +0 -138
- package/bizar-dash/src/web/mobile/MobileDoctor.tsx +0 -80
- package/bizar-dash/src/web/mobile/MobileEval.tsx +0 -167
- package/bizar-dash/src/web/mobile/MobileMemory.tsx +0 -108
- package/bizar-dash/src/web/mobile/MobileOverview.tsx +0 -213
- package/bizar-dash/src/web/mobile/MobileSettings.tsx +0 -251
- package/bizar-dash/src/web/mobile/MobileTasks.tsx +0 -94
- package/bizar-dash/src/web/mobile/MobileTopbar.tsx +0 -115
- package/bizar-dash/src/web/mobile/components/MobileBottomSheet.tsx +0 -182
- package/bizar-dash/src/web/mobile/components/MobileListItem.tsx +0 -64
- package/bizar-dash/src/web/mobile/components/MobileModal.tsx +0 -123
- package/bizar-dash/src/web/mobile/views/MobileActivity.tsx +0 -273
- package/bizar-dash/src/web/mobile/views/MobileAgents.tsx +0 -374
- package/bizar-dash/src/web/mobile/views/MobileArtifactCanvas.tsx +0 -439
- package/bizar-dash/src/web/mobile/views/MobileArtifacts.tsx +0 -143
- package/bizar-dash/src/web/mobile/views/MobileChat.tsx +0 -257
- package/bizar-dash/src/web/mobile/views/MobileConfig.tsx +0 -175
- package/bizar-dash/src/web/mobile/views/MobileHistory.tsx +0 -191
- package/bizar-dash/src/web/mobile/views/MobileMods.tsx +0 -149
- package/bizar-dash/src/web/mobile/views/MobileMore.tsx +0 -121
- package/bizar-dash/src/web/mobile/views/MobileNotifications.tsx +0 -137
- package/bizar-dash/src/web/mobile/views/MobilePlans.tsx +0 -26
- package/bizar-dash/src/web/mobile/views/MobileSchedules.tsx +0 -685
- package/bizar-dash/src/web/mobile/views/MobileSearchModal.tsx +0 -172
- package/bizar-dash/src/web/mobile/views/MobileSettings.tsx +0 -363
- package/bizar-dash/src/web/mobile/views/MobileSkills.tsx +0 -153
- package/bizar-dash/src/web/mobile/views/MobileTasks.tsx +0 -564
- package/bizar-dash/src/web/mobile/views/QrCodePanel.tsx +0 -69
- package/bizar-dash/src/web/mobile.tsx +0 -14
- package/bizar-dash/src/web/styles/agents-redesign.css +0 -311
- package/bizar-dash/src/web/styles/chat.css +0 -1740
- package/bizar-dash/src/web/styles/glyphs.css +0 -960
- package/bizar-dash/src/web/styles/main.css +0 -10391
- package/bizar-dash/src/web/styles/memory.css +0 -1182
- package/bizar-dash/src/web/styles/minimax-usage.css +0 -842
- package/bizar-dash/src/web/styles/mobile-chat.css +0 -5
- package/bizar-dash/src/web/styles/mobile-layout.css +0 -233
- package/bizar-dash/src/web/styles/mobile.css +0 -2181
- package/bizar-dash/src/web/styles/settings.css +0 -795
- package/bizar-dash/src/web/styles/skills.css +0 -302
- package/bizar-dash/src/web/styles/tasks-redesign.css +0 -253
- package/bizar-dash/src/web/styles/tasks.css +0 -605
- package/bizar-dash/src/web/ui/controls/Button.tsx +0 -77
- package/bizar-dash/src/web/ui/controls/Checkbox.tsx +0 -95
- package/bizar-dash/src/web/ui/controls/IconButton.tsx +0 -66
- package/bizar-dash/src/web/ui/controls/Kbd.tsx +0 -24
- package/bizar-dash/src/web/ui/controls/NumberInput.tsx +0 -77
- package/bizar-dash/src/web/ui/controls/RadioGroup.tsx +0 -109
- package/bizar-dash/src/web/ui/controls/SearchInput.tsx +0 -91
- package/bizar-dash/src/web/ui/controls/Select.tsx +0 -92
- package/bizar-dash/src/web/ui/controls/Slider.tsx +0 -70
- package/bizar-dash/src/web/ui/controls/TextInput.tsx +0 -67
- package/bizar-dash/src/web/ui/controls/Textarea.tsx +0 -56
- package/bizar-dash/src/web/ui/controls/Toggle.tsx +0 -79
- package/bizar-dash/src/web/ui/controls/controls.css +0 -476
- package/bizar-dash/src/web/ui/controls/index.ts +0 -35
- package/bizar-dash/src/web/ui/data/BarChart.tsx +0 -60
- package/bizar-dash/src/web/ui/data/DataTable.tsx +0 -216
- package/bizar-dash/src/web/ui/data/EmptyState.tsx +0 -60
- package/bizar-dash/src/web/ui/data/ErrorState.tsx +0 -56
- package/bizar-dash/src/web/ui/data/KeyValueList.tsx +0 -106
- package/bizar-dash/src/web/ui/data/LoadingState.tsx +0 -65
- package/bizar-dash/src/web/ui/data/Sparkline.tsx +0 -87
- package/bizar-dash/src/web/ui/data/StatTile.tsx +0 -87
- package/bizar-dash/src/web/ui/data/data.css +0 -535
- package/bizar-dash/src/web/ui/data/index.ts +0 -31
- package/bizar-dash/src/web/ui/feedback/Badge.tsx +0 -49
- package/bizar-dash/src/web/ui/feedback/Dialog.tsx +0 -209
- package/bizar-dash/src/web/ui/feedback/ProgressBar.tsx +0 -69
- package/bizar-dash/src/web/ui/feedback/StatusDot.tsx +0 -50
- package/bizar-dash/src/web/ui/feedback/Toast.tsx +0 -200
- package/bizar-dash/src/web/ui/feedback/Tooltip.tsx +0 -126
- package/bizar-dash/src/web/ui/feedback/feedback.css +0 -314
- package/bizar-dash/src/web/ui/feedback/index.ts +0 -43
- package/bizar-dash/src/web/ui/index.ts +0 -56
- package/bizar-dash/src/web/ui/layout/AppShell.tsx +0 -51
- package/bizar-dash/src/web/ui/layout/Breadcrumbs.tsx +0 -97
- package/bizar-dash/src/web/ui/layout/Panel.tsx +0 -73
- package/bizar-dash/src/web/ui/layout/PanelHeader.tsx +0 -39
- package/bizar-dash/src/web/ui/layout/Sidebar.tsx +0 -131
- package/bizar-dash/src/web/ui/layout/Tabs.tsx +0 -133
- package/bizar-dash/src/web/ui/layout/Topbar.tsx +0 -42
- package/bizar-dash/src/web/ui/layout/ViewHeader.tsx +0 -48
- package/bizar-dash/src/web/ui/layout/index.ts +0 -34
- package/bizar-dash/src/web/ui/layout/layout.css +0 -464
- package/bizar-dash/src/web/ui/navigation/CommandPalette.tsx +0 -199
- package/bizar-dash/src/web/ui/navigation/NavGroup.tsx +0 -95
- package/bizar-dash/src/web/ui/navigation/NavLink.tsx +0 -93
- package/bizar-dash/src/web/ui/navigation/index.ts +0 -17
- package/bizar-dash/src/web/ui/navigation/navigation.css +0 -343
- package/bizar-dash/src/web/ui/primitives/Box.tsx +0 -91
- package/bizar-dash/src/web/ui/primitives/Grid.tsx +0 -49
- package/bizar-dash/src/web/ui/primitives/Inline.tsx +0 -55
- package/bizar-dash/src/web/ui/primitives/Separator.tsx +0 -46
- package/bizar-dash/src/web/ui/primitives/Stack.tsx +0 -54
- package/bizar-dash/src/web/ui/primitives/VisuallyHidden.tsx +0 -26
- package/bizar-dash/src/web/ui/primitives/index.ts +0 -23
- package/bizar-dash/src/web/ui/primitives/primitives.css +0 -183
- package/bizar-dash/src/web/ui/styles/globals.css +0 -86
- package/bizar-dash/src/web/ui/styles/reset.css +0 -125
- package/bizar-dash/src/web/ui/styles/tokens.css +0 -208
- package/bizar-dash/src/web/ui/theme/ThemeProvider.tsx +0 -142
- package/bizar-dash/src/web/ui/theme/tokens.ts +0 -131
- package/bizar-dash/src/web/ui/theme/useTheme.ts +0 -22
- package/bizar-dash/src/web/ui/utils/cx.ts +0 -42
- package/bizar-dash/src/web/views/Activity.tsx +0 -1221
- package/bizar-dash/src/web/views/Agents.tsx +0 -964
- package/bizar-dash/src/web/views/Artifacts.tsx +0 -1494
- package/bizar-dash/src/web/views/BackgroundAgents.tsx +0 -822
- package/bizar-dash/src/web/views/Chat.tsx +0 -532
- package/bizar-dash/src/web/views/Config.tsx +0 -3
- package/bizar-dash/src/web/views/Doctor.tsx +0 -317
- package/bizar-dash/src/web/views/Eval.tsx +0 -372
- package/bizar-dash/src/web/views/EvalReport.tsx +0 -353
- package/bizar-dash/src/web/views/GoalPlanner.tsx +0 -158
- package/bizar-dash/src/web/views/Harness.tsx +0 -306
- package/bizar-dash/src/web/views/History.tsx +0 -353
- package/bizar-dash/src/web/views/Memory.tsx +0 -161
- package/bizar-dash/src/web/views/MiniMaxUsage.tsx +0 -942
- package/bizar-dash/src/web/views/ModView.tsx +0 -207
- package/bizar-dash/src/web/views/Mods.tsx +0 -706
- package/bizar-dash/src/web/views/Overview.tsx +0 -1364
- package/bizar-dash/src/web/views/Providers.tsx +0 -302
- package/bizar-dash/src/web/views/Schedules.tsx +0 -902
- package/bizar-dash/src/web/views/Settings.tsx +0 -308
- package/bizar-dash/src/web/views/Skills.tsx +0 -383
- package/bizar-dash/src/web/views/SpawnAgentModal.tsx +0 -221
- package/bizar-dash/src/web/views/Tasks.tsx +0 -789
- package/bizar-dash/src/web/views/Workspace.tsx +0 -294
- package/bizar-dash/src/web/views/glyphs/GlyphRenderer.tsx +0 -844
- package/bizar-dash/src/web/views/glyphs/components.tsx +0 -1098
- package/bizar-dash/src/web/views/memory/ConfigPanel.tsx +0 -426
- package/bizar-dash/src/web/views/memory/FromScreenshotPanel.tsx +0 -23
- package/bizar-dash/src/web/views/memory/GitSyncPanel.tsx +0 -220
- package/bizar-dash/src/web/views/memory/LightragPanel.tsx +0 -310
- package/bizar-dash/src/web/views/memory/MemoryGraphLegend.tsx +0 -29
- package/bizar-dash/src/web/views/memory/MemoryGraphPanel.tsx +0 -192
- package/bizar-dash/src/web/views/memory/MemoryGraphView.tsx +0 -336
- package/bizar-dash/src/web/views/memory/MemoryOverview.tsx +0 -367
- package/bizar-dash/src/web/views/memory/MemoryStatusCard.tsx +0 -160
- package/bizar-dash/src/web/views/memory/ObsidianPanel.tsx +0 -650
- package/bizar-dash/src/web/views/memory/SemanticSearchPanel.tsx +0 -197
- package/bizar-dash/src/web/views/memory/VaultFromClipboardPanel.tsx +0 -101
- package/bizar-dash/src/web/views/settings/ActivitySection.tsx +0 -205
- package/bizar-dash/src/web/views/settings/AgentSection.tsx +0 -305
- package/bizar-dash/src/web/views/settings/AuthSection.tsx +0 -159
- package/bizar-dash/src/web/views/settings/EnvVarsSection.tsx +0 -15
- package/bizar-dash/src/web/views/settings/GeneralSection.tsx +0 -128
- package/bizar-dash/src/web/views/settings/HeadroomSection.tsx +0 -39
- package/bizar-dash/src/web/views/settings/MemorySection.tsx +0 -154
- package/bizar-dash/src/web/views/settings/NetworkSection.tsx +0 -87
- package/bizar-dash/src/web/views/settings/NotificationsSection.tsx +0 -34
- package/bizar-dash/src/web/views/settings/SystemLlmSection.tsx +0 -81
- package/bizar-dash/src/web/views/settings/ThemeSection.tsx +0 -168
- package/bizar-dash/src/web/views/settings/UpdatesSection.tsx +0 -256
- package/bizar-dash/src/web/views/settings/WorkspacesSection.tsx +0 -189
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
var tu=Object.defineProperty;var su=(t,s,n)=>s in t?tu(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Ps=(t,s,n)=>su(t,typeof s!="symbol"?s+"":s,n);import{c as re,r as f,j as e,a as Fo,X as Re,b as H,R as xe,F as lt,C as Ut,M as mn,B as pt,S as Qt,A as Be,d as vt,e as Jt,H as Zs,f as wi,g as Ae,h as se,P as qe,i as He,l as At,k as Ve,m as St,n as rt,o as Rt,T as Fe,p as da,q as fn,s as bs,t as Oo,u as ws,v as nu,w as au,x as ye,y as iu,z as ki,D as Bo,E as fs,G as Ys,I as Ho,_ as ru,J as ou,W as es,K as lu,L as cu,N as du,O as uu}from"./mobile-layout-GZ3bE8L6.js";import{C as Ni,a as ct,u as fe,T as Ue,b as Ke,I as Si,c as hu}from"./Toast-ATSAmbdi.js";import{B as xt,S as mu,a as U,C as Fn,b as Ht,c as pe,d as ne,e as de,E as Is,f as ue,G as gt,g as ti,h as ks,Z as Ci,D as ts,i as ls,P as si,K as zi,j as Qs,A as fu,U as pu,k as xu,l as gu,T as yu,m as vu,H as ju,n as bu,L as je,F as dr,o as wu,p as ku}from"./EnvVarsSection-BfhAz3ax.js";import{C as Vt,a as Nu,u as Su,b as Cu,c as zu,d as Mu,M as Vo,r as Uo,V as qo,B as Mi}from"./useSlashCommands-BOwD7lNb.js";/**
|
|
2
|
-
* @license lucide-react v0.460.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 Wo=re("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
|
|
7
|
-
* @license lucide-react v0.460.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 ua=re("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
|
|
12
|
-
* @license lucide-react v0.460.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 Go=re("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/**
|
|
17
|
-
* @license lucide-react v0.460.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 $i=re("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
22
|
-
* @license lucide-react v0.460.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 Yo=re("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
|
27
|
-
* @license lucide-react v0.460.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 pn=re("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
|
|
32
|
-
* @license lucide-react v0.460.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 Xo=re("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
|
|
37
|
-
* @license lucide-react v0.460.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 $u=re("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
|
|
42
|
-
* @license lucide-react v0.460.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const $a=re("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
|
|
47
|
-
* @license lucide-react v0.460.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const Ko=re("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/**
|
|
52
|
-
* @license lucide-react v0.460.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const Eu=re("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/**
|
|
57
|
-
* @license lucide-react v0.460.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const _u=re("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/**
|
|
62
|
-
* @license lucide-react v0.460.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const Tu=re("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
67
|
-
* @license lucide-react v0.460.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const Au=re("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
|
|
72
|
-
* @license lucide-react v0.460.0 - ISC
|
|
73
|
-
*
|
|
74
|
-
* This source code is licensed under the ISC license.
|
|
75
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const Yn=re("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
|
|
77
|
-
* @license lucide-react v0.460.0 - ISC
|
|
78
|
-
*
|
|
79
|
-
* This source code is licensed under the ISC license.
|
|
80
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const Ot=re("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
|
|
82
|
-
* @license lucide-react v0.460.0 - ISC
|
|
83
|
-
*
|
|
84
|
-
* This source code is licensed under the ISC license.
|
|
85
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const Zo=re("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
|
|
87
|
-
* @license lucide-react v0.460.0 - ISC
|
|
88
|
-
*
|
|
89
|
-
* This source code is licensed under the ISC license.
|
|
90
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const Ru=re("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
|
|
92
|
-
* @license lucide-react v0.460.0 - ISC
|
|
93
|
-
*
|
|
94
|
-
* This source code is licensed under the ISC license.
|
|
95
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const Ei=re("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/**
|
|
97
|
-
* @license lucide-react v0.460.0 - ISC
|
|
98
|
-
*
|
|
99
|
-
* This source code is licensed under the ISC license.
|
|
100
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const Iu=re("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
|
|
102
|
-
* @license lucide-react v0.460.0 - ISC
|
|
103
|
-
*
|
|
104
|
-
* This source code is licensed under the ISC license.
|
|
105
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const Xn=re("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
|
|
107
|
-
* @license lucide-react v0.460.0 - ISC
|
|
108
|
-
*
|
|
109
|
-
* This source code is licensed under the ISC license.
|
|
110
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const Lu=re("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/**
|
|
112
|
-
* @license lucide-react v0.460.0 - ISC
|
|
113
|
-
*
|
|
114
|
-
* This source code is licensed under the ISC license.
|
|
115
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const Pu=re("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
|
|
117
|
-
* @license lucide-react v0.460.0 - ISC
|
|
118
|
-
*
|
|
119
|
-
* This source code is licensed under the ISC license.
|
|
120
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const Du=re("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/**
|
|
122
|
-
* @license lucide-react v0.460.0 - ISC
|
|
123
|
-
*
|
|
124
|
-
* This source code is licensed under the ISC license.
|
|
125
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const Fu=re("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
|
|
127
|
-
* @license lucide-react v0.460.0 - ISC
|
|
128
|
-
*
|
|
129
|
-
* This source code is licensed under the ISC license.
|
|
130
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
-
*/const Ou=re("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/**
|
|
132
|
-
* @license lucide-react v0.460.0 - ISC
|
|
133
|
-
*
|
|
134
|
-
* This source code is licensed under the ISC license.
|
|
135
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const Bu=re("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/**
|
|
137
|
-
* @license lucide-react v0.460.0 - ISC
|
|
138
|
-
*
|
|
139
|
-
* This source code is licensed under the ISC license.
|
|
140
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const Hu=re("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
|
142
|
-
* @license lucide-react v0.460.0 - ISC
|
|
143
|
-
*
|
|
144
|
-
* This source code is licensed under the ISC license.
|
|
145
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const Vu=re("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
|
|
147
|
-
* @license lucide-react v0.460.0 - ISC
|
|
148
|
-
*
|
|
149
|
-
* This source code is licensed under the ISC license.
|
|
150
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const Uu=re("FolderGit2",[["path",{d:"M9 20H4a2 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.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);/**
|
|
152
|
-
* @license lucide-react v0.460.0 - ISC
|
|
153
|
-
*
|
|
154
|
-
* This source code is licensed under the ISC license.
|
|
155
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const qu=re("FolderOpen",[["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"}]]);/**
|
|
157
|
-
* @license lucide-react v0.460.0 - ISC
|
|
158
|
-
*
|
|
159
|
-
* This source code is licensed under the ISC license.
|
|
160
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const Wu=re("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]]);/**
|
|
162
|
-
* @license lucide-react v0.460.0 - ISC
|
|
163
|
-
*
|
|
164
|
-
* This source code is licensed under the ISC license.
|
|
165
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const Gu=re("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
|
|
167
|
-
* @license lucide-react v0.460.0 - ISC
|
|
168
|
-
*
|
|
169
|
-
* This source code is licensed under the ISC license.
|
|
170
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
-
*/const Qo=re("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/**
|
|
172
|
-
* @license lucide-react v0.460.0 - ISC
|
|
173
|
-
*
|
|
174
|
-
* This source code is licensed under the ISC license.
|
|
175
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
-
*/const Yu=re("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/**
|
|
177
|
-
* @license lucide-react v0.460.0 - ISC
|
|
178
|
-
*
|
|
179
|
-
* This source code is licensed under the ISC license.
|
|
180
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
-
*/const Xu=re("GitPullRequest",[["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"}]]);/**
|
|
182
|
-
* @license lucide-react v0.460.0 - ISC
|
|
183
|
-
*
|
|
184
|
-
* This source code is licensed under the ISC license.
|
|
185
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
-
*/const Ku=re("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/**
|
|
187
|
-
* @license lucide-react v0.460.0 - ISC
|
|
188
|
-
*
|
|
189
|
-
* This source code is licensed under the ISC license.
|
|
190
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const Kn=re("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
|
|
192
|
-
* @license lucide-react v0.460.0 - ISC
|
|
193
|
-
*
|
|
194
|
-
* This source code is licensed under the ISC license.
|
|
195
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
-
*/const Zu=re("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
|
|
197
|
-
* @license lucide-react v0.460.0 - ISC
|
|
198
|
-
*
|
|
199
|
-
* This source code is licensed under the ISC license.
|
|
200
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
-
*/const Jo=re("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
|
|
202
|
-
* @license lucide-react v0.460.0 - ISC
|
|
203
|
-
*
|
|
204
|
-
* This source code is licensed under the ISC license.
|
|
205
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
-
*/const Qu=re("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
207
|
-
* @license lucide-react v0.460.0 - ISC
|
|
208
|
-
*
|
|
209
|
-
* This source code is licensed under the ISC license.
|
|
210
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
-
*/const Js=re("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
|
|
212
|
-
* @license lucide-react v0.460.0 - ISC
|
|
213
|
-
*
|
|
214
|
-
* This source code is licensed under the ISC license.
|
|
215
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
-
*/const Ju=re("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
|
217
|
-
* @license lucide-react v0.460.0 - ISC
|
|
218
|
-
*
|
|
219
|
-
* This source code is licensed under the ISC license.
|
|
220
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
221
|
-
*/const eh=re("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
|
222
|
-
* @license lucide-react v0.460.0 - ISC
|
|
223
|
-
*
|
|
224
|
-
* This source code is licensed under the ISC license.
|
|
225
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
226
|
-
*/const ur=re("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
|
|
227
|
-
* @license lucide-react v0.460.0 - ISC
|
|
228
|
-
*
|
|
229
|
-
* This source code is licensed under the ISC license.
|
|
230
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
231
|
-
*/const Zn=re("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/**
|
|
232
|
-
* @license lucide-react v0.460.0 - ISC
|
|
233
|
-
*
|
|
234
|
-
* This source code is licensed under the ISC license.
|
|
235
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
236
|
-
*/const th=re("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
237
|
-
* @license lucide-react v0.460.0 - ISC
|
|
238
|
-
*
|
|
239
|
-
* This source code is licensed under the ISC license.
|
|
240
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
241
|
-
*/const _i=re("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
|
|
242
|
-
* @license lucide-react v0.460.0 - ISC
|
|
243
|
-
*
|
|
244
|
-
* This source code is licensed under the ISC license.
|
|
245
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
246
|
-
*/const el=re("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
247
|
-
* @license lucide-react v0.460.0 - ISC
|
|
248
|
-
*
|
|
249
|
-
* This source code is licensed under the ISC license.
|
|
250
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
251
|
-
*/const sh=re("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
|
|
252
|
-
* @license lucide-react v0.460.0 - ISC
|
|
253
|
-
*
|
|
254
|
-
* This source code is licensed under the ISC license.
|
|
255
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
256
|
-
*/const tl=re("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
257
|
-
* @license lucide-react v0.460.0 - ISC
|
|
258
|
-
*
|
|
259
|
-
* This source code is licensed under the ISC license.
|
|
260
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
261
|
-
*/const sl=re("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
|
|
262
|
-
* @license lucide-react v0.460.0 - ISC
|
|
263
|
-
*
|
|
264
|
-
* This source code is licensed under the ISC license.
|
|
265
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
266
|
-
*/const ys=re("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/**
|
|
267
|
-
* @license lucide-react v0.460.0 - ISC
|
|
268
|
-
*
|
|
269
|
-
* This source code is licensed under the ISC license.
|
|
270
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
271
|
-
*/const Ti=re("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/**
|
|
272
|
-
* @license lucide-react v0.460.0 - ISC
|
|
273
|
-
*
|
|
274
|
-
* This source code is licensed under the ISC license.
|
|
275
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
276
|
-
*/const nl=re("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
|
|
277
|
-
* @license lucide-react v0.460.0 - ISC
|
|
278
|
-
*
|
|
279
|
-
* This source code is licensed under the ISC license.
|
|
280
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
281
|
-
*/const nh=re("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
|
|
282
|
-
* @license lucide-react v0.460.0 - ISC
|
|
283
|
-
*
|
|
284
|
-
* This source code is licensed under the ISC license.
|
|
285
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
286
|
-
*/const ah=re("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/**
|
|
287
|
-
* @license lucide-react v0.460.0 - ISC
|
|
288
|
-
*
|
|
289
|
-
* This source code is licensed under the ISC license.
|
|
290
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
291
|
-
*/const ih=re("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/**
|
|
292
|
-
* @license lucide-react v0.460.0 - ISC
|
|
293
|
-
*
|
|
294
|
-
* This source code is licensed under the ISC license.
|
|
295
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
296
|
-
*/const rh=re("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
297
|
-
* @license lucide-react v0.460.0 - ISC
|
|
298
|
-
*
|
|
299
|
-
* This source code is licensed under the ISC license.
|
|
300
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
301
|
-
*/const Ns=re("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/**
|
|
302
|
-
* @license lucide-react v0.460.0 - ISC
|
|
303
|
-
*
|
|
304
|
-
* This source code is licensed under the ISC license.
|
|
305
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
306
|
-
*/const oh=re("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/**
|
|
307
|
-
* @license lucide-react v0.460.0 - ISC
|
|
308
|
-
*
|
|
309
|
-
* This source code is licensed under the ISC license.
|
|
310
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
311
|
-
*/const lh=re("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
|
|
312
|
-
* @license lucide-react v0.460.0 - ISC
|
|
313
|
-
*
|
|
314
|
-
* This source code is licensed under the ISC license.
|
|
315
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
316
|
-
*/const ch=re("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/**
|
|
317
|
-
* @license lucide-react v0.460.0 - ISC
|
|
318
|
-
*
|
|
319
|
-
* This source code is licensed under the ISC license.
|
|
320
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
321
|
-
*/const Ss=re("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
|
|
322
|
-
* @license lucide-react v0.460.0 - ISC
|
|
323
|
-
*
|
|
324
|
-
* This source code is licensed under the ISC license.
|
|
325
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
326
|
-
*/const dh=re("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/**
|
|
327
|
-
* @license lucide-react v0.460.0 - ISC
|
|
328
|
-
*
|
|
329
|
-
* This source code is licensed under the ISC license.
|
|
330
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
331
|
-
*/const en=re("ShieldCheck",[["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:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
332
|
-
* @license lucide-react v0.460.0 - ISC
|
|
333
|
-
*
|
|
334
|
-
* This source code is licensed under the ISC license.
|
|
335
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
336
|
-
*/const ss=re("Shield",[["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"}]]);/**
|
|
337
|
-
* @license lucide-react v0.460.0 - ISC
|
|
338
|
-
*
|
|
339
|
-
* This source code is licensed under the ISC license.
|
|
340
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
341
|
-
*/const uh=re("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
|
|
342
|
-
* @license lucide-react v0.460.0 - ISC
|
|
343
|
-
*
|
|
344
|
-
* This source code is licensed under the ISC license.
|
|
345
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
346
|
-
*/const al=re("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/**
|
|
347
|
-
* @license lucide-react v0.460.0 - ISC
|
|
348
|
-
*
|
|
349
|
-
* This source code is licensed under the ISC license.
|
|
350
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
351
|
-
*/const il=re("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
|
|
352
|
-
* @license lucide-react v0.460.0 - ISC
|
|
353
|
-
*
|
|
354
|
-
* This source code is licensed under the ISC license.
|
|
355
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
356
|
-
*/const hh=re("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
|
|
357
|
-
* @license lucide-react v0.460.0 - ISC
|
|
358
|
-
*
|
|
359
|
-
* This source code is licensed under the ISC license.
|
|
360
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
361
|
-
*/const Ai=re("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
362
|
-
* @license lucide-react v0.460.0 - ISC
|
|
363
|
-
*
|
|
364
|
-
* This source code is licensed under the ISC license.
|
|
365
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
366
|
-
*/const Cs=re("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
367
|
-
* @license lucide-react v0.460.0 - ISC
|
|
368
|
-
*
|
|
369
|
-
* This source code is licensed under the ISC license.
|
|
370
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
371
|
-
*/const mh=re("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
|
|
372
|
-
* @license lucide-react v0.460.0 - ISC
|
|
373
|
-
*
|
|
374
|
-
* This source code is licensed under the ISC license.
|
|
375
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
376
|
-
*/const fh=re("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
|
|
377
|
-
* @license lucide-react v0.460.0 - ISC
|
|
378
|
-
*
|
|
379
|
-
* This source code is licensed under the ISC license.
|
|
380
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
381
|
-
*/const tn=re("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
|
|
382
|
-
* @license lucide-react v0.460.0 - ISC
|
|
383
|
-
*
|
|
384
|
-
* This source code is licensed under the ISC license.
|
|
385
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
386
|
-
*/const ph=re("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/**
|
|
387
|
-
* @license lucide-react v0.460.0 - ISC
|
|
388
|
-
*
|
|
389
|
-
* This source code is licensed under the ISC license.
|
|
390
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
391
|
-
*/const xh=re("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]),rl=f.createContext(null),gh=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Ze(){const t=f.useContext(rl);return t||{open:()=>"",close:()=>{},isModalOpen:!1}}function yh({children:t}){const[s,n]=f.useState([]),a=f.useCallback(r=>{n(o=>{if(!r)return o.slice(0,-1);const l=o.findIndex(c=>c.id===r);return l===-1||l!==o.length-1?o:o.slice(0,-1)})},[]),i=f.useCallback(r=>{const o=`m${Math.random().toString(36).slice(2,9)}`;return n(l=>[...l,{...r,id:o}]),o},[]);return f.useEffect(()=>{if(s.length===0)return;const r=o=>{o.key==="Escape"&&(o.stopPropagation(),a())};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[s.length,a]),e.jsxs(rl.Provider,{value:{open:i,close:a,isModalOpen:s.length>0},children:[t,typeof document<"u"&&Fo.createPortal(e.jsx("div",{className:"modal-stack","aria-hidden":s.length===0,children:s.map((r,o)=>e.jsx(vh,{modal:r,onClose:()=>{var l;(l=r.onClose)==null||l.call(r),a(r.id)},depth:o},r.id))}),document.body)]})}function vh({modal:t,onClose:s,depth:n}){const a=f.useRef(null),i=f.useRef(null),r=f.useId(),o=()=>{const l=a.current;return l?Array.from(l.querySelectorAll(gh)).filter(c=>!c.hasAttribute("disabled")&&c.tabIndex!==-1):[]};return f.useEffect(()=>{var h;i.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(h=o()[0]??a.current)==null||h.focus();const c=m=>{var v,j,g;if(m.key!=="Tab")return;const d=o();if(d.length===0){m.preventDefault(),(v=a.current)==null||v.focus();return}const u=d[0],p=d[d.length-1],x=document.activeElement instanceof HTMLElement?document.activeElement:null;if(m.shiftKey){(!x||x===u||!((j=a.current)!=null&&j.contains(x)))&&(m.preventDefault(),p.focus());return}(!x||x===p||!((g=a.current)!=null&&g.contains(x)))&&(m.preventDefault(),u.focus())};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c);const m=i.current;m&&m.isConnected&&m.focus()}},[]),e.jsx("div",{className:"modal-backdrop",onClick:l=>{l.stopPropagation(),l.target===l.currentTarget&&s()},style:n>0?{background:"rgba(0,0,0,0.4)"}:void 0,children:e.jsxs("div",{ref:a,className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":t.title?r:void 0,tabIndex:-1,onClick:l=>l.stopPropagation(),style:t.width?{maxWidth:t.width}:void 0,children:[t.title&&e.jsxs("header",{className:"modal-header",children:[e.jsx("h2",{id:r,className:"modal-title",children:t.title}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:s,children:e.jsx(Re,{size:16})})]}),e.jsx("div",{className:"modal-body",children:t.children}),t.footer&&e.jsx("footer",{className:"modal-footer",children:t.footer})]})})}const jh=200,bh=5*60*1e3,Yt=new Map;function wh(t){const s=Yt.get(t);return s?Date.now()-s.ts>bh?(Yt.delete(t),null):s.data:null}function Ea(t,s){Yt.size>=jh&&[...Yt.entries()].sort((a,i)=>a[1].ts-i[1].ts).slice(0,50).map(([a])=>a).forEach(a=>Yt.delete(a)),Yt.set(t,{data:s,ts:Date.now()})}function kh(t){if(!t||t==="/")return[{label:"/",path:"/"}];const s=t.split("/").filter(Boolean),n=[];let a="";for(let i=0;i<s.length;i++)a+="/"+s[i],n.push({label:s[i],path:a});return n}function Nh(t){return[...t].sort((s,n)=>s.isDir!==n.isDir?s.isDir?-1:1:s.name.localeCompare(n.name,void 0,{sensitivity:"base"}))}function Sh(t){const s=t.trim();return s?s!==t?{ok:!1,reason:"Name cannot have leading or trailing whitespace."}:s==="."?{ok:!1,reason:"Name cannot be '.'."}:s===".."?{ok:!1,reason:"Name cannot be '..'."}:s.startsWith("-")?{ok:!1,reason:"Name cannot start with '-'."}:s.length>255?{ok:!1,reason:"Name cannot be longer than 255 characters."}:/[/\0:*?"<>|]/.test(s)?{ok:!1,reason:'Name cannot contain / \\ : * ? " < > |'}:{ok:!0}:{ok:!1,reason:"Name cannot be empty."}}function Ch({value:t,onChange:s,initialPath:n,projectsDirectory:a,rootLabel:i="Home",height:r=360}){const[o,l]=f.useState(n??a??""),[c,h]=f.useState(new Set),[m,d]=f.useState(-1),[u,p]=f.useState(null),[x,v]=f.useState({}),[j,g]=f.useState(!1),[b,y]=f.useState(null),[w,S]=f.useState(!1),[$,M]=f.useState(""),[z,A]=f.useState(null),[k,C]=f.useState(!1),_=f.useRef(null),L=f.useCallback(async O=>{try{const X=wh(O);if(X)return X;const Z=await H.get("/fs?path="+encodeURIComponent(O));return Ea(O,Z),Z}catch{return null}},[]),N=f.useCallback(async O=>{var X;g(!0),y(null);try{const Z=await H.get("/fs?path="+encodeURIComponent(O));Ea(O,Z),p(Z),d(-1)}catch(Z){const J=((X=Z.data)==null?void 0:X.message)??Z.message??"Failed to load directory";y(J)}finally{g(!1)}},[]);f.useEffect(()=>{o?N(o):H.get("/fs").then(O=>{Ea("",O),p(O),l(O.path),O.path!==t&&s(O.path)}).catch(()=>{y("Could not determine home directory."),g(!1)})},[o]),f.useEffect(()=>{t&&t!==o&&l(t)},[t]);const T=u?Nh(u.entries):[],I=T.filter(O=>O.isDir),R=T,B=O=>{O.isDir&&(l(O.path),s(O.path))},E=()=>{u!=null&&u.parent&&(l(u.parent),s(u.parent))},P=O=>{O!==o&&(l(O),s(O))},W=async()=>{const O=await L("");O&&(l(O.path),s(O.path))},V=async()=>{if(!a)return;const O=await L(a);O&&(l(O.path),s(O.path))},K=()=>{S(!0),M(""),A(null),setTimeout(()=>{var O;return(O=_.current)==null?void 0:O.focus()},0)},D=()=>{S(!1),M(""),A(null)},G=async()=>{var X;const O=Sh($);if(!O.ok){A(O.reason);return}C(!0),A(null);try{const Z=await H.post("/fs/mkdir",{parent:o,name:$.trim()});Yt.delete(o),await N(o),s(Z.path),S(!1),M("")}catch(Z){const J=Z;J.status===409?A(`A folder named "${$.trim()}" already exists.`):A(((X=J.data)==null?void 0:X.message)??Z.message??"Failed to create folder.")}finally{C(!1)}},ee=O=>{O.key==="Enter"?(O.preventDefault(),G()):O.key==="Escape"&&(O.preventDefault(),D())},te=O=>{h(X=>{const Z=new Set(X);return Z.has(O)?Z.delete(O):Z.add(O),Z}),x[O]||L(O).then(X=>{X&&v(Z=>({...Z,[O]:X.entries.filter(J=>J.isDir)}))})},F=O=>{if(!u)return;const X=R.filter(le=>le.isDir),Z=R.filter(le=>!le.isDir),J=[...X,...Z];if(O.key==="ArrowDown")O.preventDefault(),d(le=>Math.min(le+1,J.length-1));else if(O.key==="ArrowUp")O.preventDefault(),d(le=>Math.max(le-1,0));else if(O.key==="Enter"||O.key===" "){O.preventDefault();const le=J[m];le&&(O.key==="Enter"&&le.isDir?B(le):le.isDir&&s(le.path))}else O.key==="Backspace"&&(O.preventDefault(),E())},Y=kh((u==null?void 0:u.path)??o??"/"),Q=u==null?void 0:u.parent,ie=Q!=null,ae=o.split("/").filter(Boolean).at(-1)??"/";return e.jsxs("div",{className:"file-browser",onKeyDown:F,tabIndex:-1,children:[e.jsx("div",{className:"file-browser-breadcrumb",role:"navigation","aria-label":"Path breadcrumb",children:Y.map((O,X)=>e.jsxs("span",{className:"file-browser-breadcrumb-item",children:[X>0&&e.jsx("span",{className:"file-browser-breadcrumb-sep","aria-hidden":!0,children:"/"}),e.jsx("button",{type:"button",className:"file-browser-breadcrumb-btn",onClick:()=>P(O.path),title:O.path,children:X===0?O.path==="/"?"/":i:O.label})]},O.path))}),e.jsxs("div",{className:"file-browser-toolbar",children:[e.jsxs("div",{className:"file-browser-toolbar-left",children:[e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:E,disabled:!ie,title:"Go up (Backspace)","aria-label":"Go up one level",children:e.jsx($i,{size:13})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:()=>N(o),disabled:j,title:"Refresh","aria-label":"Refresh",children:e.jsx(xe,{size:13,className:j?"spin":""})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:K,title:"New folder","aria-label":"Create new folder",children:e.jsx(Wu,{size:13})}),e.jsxs("div",{className:"file-browser-chips",children:[e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:W,children:[e.jsx(Ku,{size:11})," ",i]}),a&&e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:V,title:a,children:[e.jsx(qu,{size:11})," ",a.split("/").filter(Boolean).at(-1)??"Projects"]})]})]}),w?e.jsxs("div",{className:"file-browser-mkdir",children:[e.jsx("input",{ref:_,type:"text",className:"file-browser-mkdir-input",placeholder:"Folder name",value:$,onChange:O=>{M(O.target.value),A(null)},onKeyDown:ee,"aria-label":"New folder name","aria-invalid":z?"true":void 0,"aria-describedby":z?"mkdir-error":void 0,disabled:k,maxLength:255}),z?e.jsx("span",{id:"mkdir-error",className:"file-browser-mkdir-error",role:"alert",children:z}):e.jsx("span",{className:"file-browser-mkdir-hint",children:"Enter to create, Esc to cancel"})]}):e.jsx("span",{className:"file-browser-count-hint",children:j?"…":`${T.length} in ${ae}`})]}),b&&e.jsxs("div",{className:"file-browser-error",children:[e.jsx(Ni,{size:13}),e.jsx("span",{children:b}),e.jsx("button",{type:"button",className:"file-browser-retry",onClick:()=>N(o),children:"Retry"})]}),e.jsxs("div",{className:"file-browser-body",style:{height:r},children:[e.jsx("div",{className:"file-browser-pane file-browser-tree","aria-label":"Folder tree",children:j&&!u?e.jsx(zh,{}):e.jsx(ol,{path:o,entries:I,expanded:c,childrenMap:x,onToggle:te,onNavigate:B,level:0})}),e.jsxs("div",{className:"file-browser-pane file-browser-flat","aria-label":"Directory contents",children:[e.jsxs("div",{className:"file-browser-flat-header",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"})]}),j&&!u?e.jsx(Mh,{}):e.jsxs(e.Fragment,{children:[(u==null?void 0:u.truncated)&&e.jsxs("div",{className:"file-browser-truncated-banner",role:"status",children:["Showing first 500 of ",u.totalEntries," entries. Navigate into a subfolder to see more."]}),R.length===0?e.jsx("div",{className:"file-browser-empty",children:"This folder is empty"}):e.jsx("div",{className:"file-browser-flat-list",children:R.map((O,X)=>{const Z=O.isDir,J=X===m,le=O.path===t;return e.jsxs("div",{role:"option","aria-selected":le,className:["file-browser-row",Z?"file-browser-row--dir":"file-browser-row--file",J&&"file-browser-row--selected",le&&Z&&"file-browser-row--active",!Z&&"file-browser-row--disabled"].filter(Boolean).join(" "),onClick:()=>{Z&&(d(X),s(O.path))},onDoubleClick:()=>{Z&&B(O)},title:O.path,children:[e.jsx("span",{className:"file-browser-row-icon",children:Z?e.jsx(lt,{size:13}):e.jsx(Hu,{size:13})}),e.jsx("span",{className:"file-browser-row-name",children:O.name}),e.jsx("span",{className:"file-browser-row-type",children:Z?"Folder":""})]},O.path)})})]})]})]}),e.jsxs("div",{className:"file-browser-footer-hint",children:["Select a folder, then click Add. Use ",e.jsx("kbd",{children:"↑"})," ",e.jsx("kbd",{children:"↓"})," to navigate, ",e.jsx("kbd",{children:"Enter"})," to confirm."]})]})}function ol({path:t,entries:s,expanded:n,childrenMap:a,onToggle:i,onNavigate:r,level:o}){return e.jsx("ul",{className:"file-browser-tree-list",role:"group",children:s.map(l=>{const c=n.has(l.path),h=a[l.path]??[];return e.jsxs("li",{className:"file-browser-tree-node",children:[e.jsxs("div",{className:["file-browser-tree-row",c&&"file-browser-tree-row--expanded"].filter(Boolean).join(" "),style:{paddingLeft:`${o*16+8}px`},children:[e.jsx("button",{type:"button",className:"file-browser-tree-toggle",onClick:m=>{m.stopPropagation(),i(l.path)},"aria-label":c?"Collapse":"Expand",children:(h.length>0,c?e.jsx(ct,{size:11}):e.jsx(Ut,{size:11}))}),e.jsxs("button",{type:"button",className:"file-browser-tree-name",onClick:()=>r(l),title:l.path,children:[e.jsx(lt,{size:12}),e.jsx("span",{children:l.name})]})]}),c&&h.length>0&&e.jsx(ol,{path:l.path,entries:h,expanded:n,childrenMap:a,onToggle:i,onNavigate:r,level:o+1})]},l.path)})})}function zh(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[80,60,90,55,70].map((t,s)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:t}},s))})}function Mh(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[60,90,70,50,80,65].map((t,s)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:t}},s))})}const ni=[{id:"overview",label:"Overview",icon:Jo},{id:"chat",label:"Chat",icon:mn},{id:"agents",label:"Agents",icon:pt},{id:"artifacts",label:"Glyphs",icon:Zn},{id:"tasks",label:"Tasks",icon:Qt},{id:"activity",label:"Activity",icon:Be},{id:"background",label:"Active",icon:oh},{id:"skills",label:"Skills",icon:vt},{id:"memory",label:"Memory",icon:xt},{id:"mods",label:"Mods",icon:Ns},{id:"schedules",label:"Schedules",icon:Jt},{id:"history",label:"History",icon:Zs},{id:"minimax",label:"Usage",icon:Ei},{id:"eval",label:"Eval",icon:Ot},{id:"doctor",label:"Doctor",icon:al},{id:"harness",label:"Harness",icon:ss},{id:"goal-planner",label:"Goals",icon:Ai},{id:"settings",label:"Settings",icon:wi}];function $h({activeTab:t,onTabChange:s,wsStatus:n,version:a,activeProject:i,projects:r,onProjectChange:o,onProjectsRefresh:l,onOpenSearch:c,settings:h,rightSlot:m,notificationsSlot:d,showTabs:u=!0,extraTabs:p,clineStatus:x=null}){return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"topbar-row",children:[e.jsxs("div",{className:"brand",children:[e.jsx("span",{className:"brand-logo","aria-hidden":"true",children:"ᛒ"}),e.jsx("span",{className:"brand-title",children:"Bizar"}),e.jsx("span",{className:"brand-version",children:a})]}),e.jsx(Eh,{activeProject:i,projects:r,onChange:o,onRefresh:l,settings:h??null}),e.jsxs("button",{type:"button",className:"topbar-search",onClick:c,title:"Search (Ctrl/Cmd+K)","aria-label":"Open search",children:[e.jsx(Ae,{size:14}),e.jsx("span",{className:"muted",children:"Search…"}),e.jsx("kbd",{children:"⌘K"})]}),e.jsx("div",{className:"topbar-spacer"}),e.jsxs("div",{className:"topbar-right",children:[d,m,x&&e.jsxs("div",{className:se("cline-status",`cline-${x.state}`),title:x.detail||`Cline ${x.label}`,"aria-label":`Cline runtime: ${x.label}`,children:[e.jsx("span",{className:"cline-dot"}),e.jsxs("span",{className:"cline-label",children:["Cline · ",x.label]})]}),e.jsxs("div",{className:se("ws-status",`ws-${n}`),title:`WebSocket: ${n}`,children:[e.jsx("span",{className:"ws-dot"}),e.jsx("span",{className:"ws-label",children:n})]})]})]}),u&&e.jsxs("nav",{className:"tabs-row",role:"tablist","aria-label":"Primary tabs",children:[ni.map(v=>{const j=v.icon,g=v.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":g,className:se("tab",g&&"tab-active"),onClick:()=>s(v.id),title:v.label,children:[e.jsx(j,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:v.label}),v.id==="settings"&&g&&e.jsx("span",{className:"settings-mode-indicator",title:"Settings mode active",children:e.jsx(mu,{size:12})})]},v.id)}),p&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tab-separator","aria-hidden":"true"}),p.map(v=>{const j=v.icon,g=v.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":g,className:se("tab","tab-mod",g&&"tab-active"),onClick:()=>s(v.id),title:`${v.label} (mod)`,children:[e.jsx(j,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:v.label}),e.jsx("span",{className:"tab-badge",children:"mod"})]},v.id)})]})]})]})}function Eh({activeProject:t,projects:s,onChange:n,onRefresh:a,settings:i}){const[r,o]=f.useState(!1),l=Ze();f.useEffect(()=>{if(!r)return;const h=()=>o(!1);return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[r]);const c=()=>{l.open({title:"Add project",children:e.jsx(_h,{settings:i,onAdd:async(h,m)=>{try{await H.post("/projects",{path:h,name:m}),a(),o(!1),l.close()}catch(d){alert(`Add failed: ${d.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(U,{variant:"ghost",onClick:()=>l.close(),children:"Cancel"})})})};return e.jsxs("div",{className:"project-selector",onClick:h=>h.stopPropagation(),children:[e.jsxs("button",{type:"button",className:"project-selector-btn",onClick:()=>o(h=>!h),title:"Switch active project","aria-haspopup":"menu","aria-expanded":r,children:[e.jsx(lt,{size:14}),e.jsx("span",{className:"project-selector-name",children:(t==null?void 0:t.name)||"(no project)"}),e.jsx(ct,{size:12})]}),r&&e.jsxs("div",{className:"project-selector-menu",children:[e.jsxs("div",{className:"project-selector-menu-head",children:[e.jsxs("span",{className:"muted",children:[s.length," project",s.length===1?"":"s"]}),e.jsxs("div",{className:"project-selector-menu-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:a,title:"Refresh","aria-label":"Refresh projects",children:e.jsx(xe,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:c,title:"Add project","aria-label":"Add project",children:e.jsx(qe,{size:12})})]})]}),e.jsxs("ul",{className:"project-selector-list",children:[s.length===0&&e.jsx("li",{className:"muted project-selector-empty",children:"No projects. Add one to start."}),s.map(h=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:se("project-selector-item",(t==null?void 0:t.id)===h.id&&"active"),onClick:()=>{n(h.id),o(!1)},children:[e.jsx("span",{className:"project-selector-item-name",children:h.name}),e.jsx("span",{className:"project-selector-item-status",children:h.status})]})},h.id))]})]})]})}function _h({settings:t,onAdd:s}){var d,u;const[n,a]=f.useState(((d=t==null?void 0:t.dashboard)==null?void 0:d.projectsDirectory)??""),[i,r]=f.useState(""),[o,l]=f.useState(!1),[c,h]=f.useState(null),m=async()=>{var p;if(n){l(!0),h(null);try{await H.get("/fs?path="+encodeURIComponent(n)),s(n,i||null)}catch(x){const v=x;v.status===404?h("That folder no longer exists. Pick another."):h(((p=v.data)==null?void 0:p.message)??x.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Ch,{value:n,onChange:p=>{a(p),h(null)},projectsDirectory:(u=t==null?void 0:t.dashboard)==null?void 0:u.projectsDirectory,height:320}),c&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:c}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"topbar-add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"topbar-add-project-name",className:"input",type:"text",placeholder:"My App",value:i,onChange:p=>r(p.target.value)})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(U,{variant:"primary",onClick:m,disabled:!n||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}const Th=[{label:"General",sections:[{id:"theme",label:"Theme",icon:nl},{id:"layout",label:"Layout",icon:Qu}]},{label:"Core",sections:[{id:"env-vars",label:"Env Vars",icon:Cs},{id:"network",label:"Network",icon:ph},{id:"notifications",label:"Notifications",icon:Xo},{id:"auth",label:"Auth",icon:ss},{id:"system-llm",label:"System LLM",icon:Fn}]},{label:"Agents",sections:[{id:"agents",label:"Agents",icon:tn}]},{label:"Experience",sections:[{id:"updates",label:"Updates",icon:xe},{id:"headroom",label:"Headroom",icon:Gu}]},{label:"Data",sections:[{id:"activity-log",label:"Activity",icon:Be},{id:"workspaces",label:"Workspaces",icon:Uu}]}];function Ah({activeSection:t,onSectionChange:s,onExitSettings:n}){return e.jsxs("div",{className:"settings-nav-root","aria-label":"Settings sections",children:[e.jsxs("button",{type:"button",className:"sidebar-tab",onClick:n,"aria-label":"Exit settings",children:[e.jsx($i,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:"Back"})]}),e.jsx("div",{className:"settings-nav-divider","aria-hidden":"true"}),Th.map(a=>e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"settings-nav-group-label",children:a.label}),a.sections.map(i=>{const r=i.icon,o=t===i.id;return e.jsxs("button",{type:"button",className:se("sidebar-tab",o&&"sidebar-tab-active"),onClick:()=>s(o?null:i.id),"aria-current":o?"page":void 0,children:[r&&e.jsx(r,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:i.label}),o&&e.jsx(Ut,{size:12,"aria-hidden":!0})]},i.id)})]},a.label))]})}function Rh({tabs:t,activeTab:s,onTabChange:n,settingsMode:a,settingsActiveSection:i,onSettingsSectionChange:r,onExitSettings:o}){if(a)return e.jsx("aside",{className:"sidebar sidebar-settings-mode","aria-label":"Settings navigation",children:e.jsx(Ah,{activeSection:i??null,onSectionChange:r??(()=>{}),onExitSettings:o??(()=>{})})});const l=t.filter(h=>!h.isMod),c=t.filter(h=>h.isMod);return e.jsx("aside",{className:"sidebar","aria-label":"Primary navigation",children:e.jsxs("nav",{className:"sidebar-nav",role:"tablist",children:[l.map(h=>{const m=h.icon,d=h.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:se("sidebar-tab",d&&"sidebar-tab-active"),onClick:()=>n(h.id),title:h.label,children:[e.jsx(m,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:h.label})]},h.id)}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sidebar-section-divider","aria-hidden":"true"}),e.jsx("div",{className:"sidebar-section-label",children:"Mods"}),c.map(h=>{const m=h.icon,d=h.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:se("sidebar-tab","sidebar-tab-mod",d&&"sidebar-tab-active"),onClick:()=>n(h.id),title:`${h.label} (mod)`,children:[e.jsx(m,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:h.label})]},h.id)})]})]})})}const _a=[{id:"all",label:"All"},{id:"projects",label:"Projects"},{id:"agents",label:"Agents"},{id:"tasks",label:"Tasks"},{id:"mods",label:"Mods"},{id:"schedules",label:"Schedules"},{id:"commands",label:"Commands"},{id:"settings",label:"Settings"}],hr={all:null,projects:"project",agents:"agent",tasks:"task",mods:"mod",schedules:"schedule",commands:"command",settings:"setting"};function Ih({open:t,onClose:s,onSelect:n}){const a=fe(),[i,r]=f.useState(""),[o,l]=f.useState("all"),[c,h]=f.useState([]),[m,d]=f.useState(!1),[u,p]=f.useState(0),x=f.useRef(null),v=f.useRef(null);if(f.useEffect(()=>{let y;return t&&(v.current=document.activeElement instanceof HTMLElement?document.activeElement:null,r(""),h([]),p(0),y=window.setTimeout(()=>{var w;return(w=x.current)==null?void 0:w.focus()},30)),()=>{if(y&&window.clearTimeout(y),!t)return;const w=v.current;w&&w.isConnected&&w.focus()}},[t]),f.useEffect(()=>{if(!t)return;if(!i.trim()){h([]),p(0);return}let y=!1;d(!0);const w=setTimeout(()=>{H.get(`/search?q=${encodeURIComponent(i)}&scope=${o}`).then(S=>{y||(h(S.results||[]),p(0))}).catch(S=>{y||a.error(`Search failed: ${S.message}`)}).finally(()=>!y&&d(!1))},150);return()=>{y=!0,clearTimeout(w)}},[i,o,t,a]),!t)return null;const j={};for(const y of c){const w=y.type.toLowerCase();j[w]=j[w]||[],j[w].push(y)}const g=[];for(const y of _a.map(w=>w.id)){const w=hr[y];w&&j[w]&&g.push(...j[w])}const b=y=>{if(y.key==="Escape")s();else if(y.key==="ArrowDown"){if(y.preventDefault(),g.length===0)return;p(w=>Math.min(w+1,g.length-1))}else if(y.key==="ArrowUp"){if(y.preventDefault(),g.length===0)return;p(w=>Math.max(w-1,0))}else y.key==="Enter"&&g[u]&&(y.preventDefault(),n(g[u]),s())};return e.jsx("div",{className:"search-modal-backdrop",onClick:s,children:e.jsxs("div",{className:"search-modal",role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{className:"search-modal-head",role:"search",children:[e.jsx(Ae,{size:14,"aria-hidden":!0}),e.jsx("span",{id:"search-modal-title",className:"sr-only",children:"Search"}),e.jsx("input",{ref:x,className:"search-modal-input",placeholder:"Search tasks, agents, settings, projects…",value:i,onChange:y=>r(y.target.value),onKeyDown:b,"aria-label":"Search"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:s,children:e.jsx(Re,{size:14})})]}),e.jsx("div",{className:"search-modal-scopes",role:"tablist","aria-label":"Search scope",children:_a.map(y=>e.jsx("button",{type:"button",role:"tab","aria-selected":o===y.id,className:se("search-scope",o===y.id&&"search-scope-active"),onClick:()=>l(y.id),children:y.label},y.id))}),e.jsxs("div",{className:"search-modal-body",children:[m&&e.jsx("div",{className:"muted",children:"Searching…"}),!m&&i&&g.length===0&&e.jsx("div",{className:"muted",children:"No results."}),!m&&!i&&e.jsx("div",{className:"muted",children:"Type to search…"}),_a.map(y=>{const w=hr[y.id];if(!w)return null;const S=j[w];return!S||S.length===0?null:e.jsxs("div",{className:"search-group",children:[e.jsx("div",{className:"search-group-head",children:y.label}),S.map($=>{const M=g.indexOf($);return e.jsxs("button",{type:"button",className:se("search-result",M===u&&"search-result-active"),onMouseEnter:()=>p(M),onClick:()=>{n($),s()},children:[e.jsx("span",{className:"search-result-type",children:$.type}),e.jsx("span",{className:"search-result-label",children:Lh($)})]},`${$.type}-${M}`)})]},y.id)})]}),e.jsx("div",{className:"search-modal-foot",children:e.jsx("span",{className:"muted",children:"↑↓ navigate · ↵ open · esc close"})})]})})}function Lh(t){const s=t.item||{};if(t.type==="project")return`${s.name} — ${s.path}`;if(t.type==="agent")return`${s.name} — ${s.description||s.model||""}`;if(t.type==="task")return`${s.title} — ${s.status||""}`;if(t.type==="mod")return`${s.name} v${s.version} — ${s.description||""}`;if(t.type==="schedule")return`${s.name} (${s.type}: ${s.schedule})`;if(t.type==="command")return`${s.name} — ${s.description||""}`;if(t.type==="setting"){const n=s.value===null||s.value===void 0?"":typeof s.value=="string"?` = ${s.value}`:` = ${JSON.stringify(s.value)}`;return`${s.label}${n} — ${s.desc||""}`.trim()}return JSON.stringify(s).slice(0,80)}const Ph={info:Si,success:Ke,warning:Ue,error:Ni};function Dh({onCountChange:t,wsSubscribe:s}){const n=fe(),[a,i]=f.useState(!1),[r,o]=f.useState([]),[l,c]=f.useState(null),[h,m]=f.useState(!1),d=f.useRef(null),u=f.useRef(0),p=async()=>{var b;try{m(!0);const y=await H.get("/notifications?limit=200");o(y.notifications||[]),c(y.stats||null),u.current=((b=y.stats)==null?void 0:b.unread)||0,t==null||t(u.current)}catch(y){At.warn("[notifications] reload failed:",y.message)}finally{m(!1)}};f.useEffect(()=>{p()},[]),f.useEffect(()=>s?s(y=>{if(y.type==="notification:new"){const w=y.notification;o(S=>[w,...S.filter($=>$.id!==w.id)]),w.read||(u.current+=1,c(S=>S?{...S,unread:(S.unread||0)+1}:{total:1,unread:1,lastTs:w.ts,counts:{[w.severity||"info"]:1}}),t==null||t(u.current))}else y.type==="notifications:change"&&p()}):void 0,[s]),f.useEffect(()=>{if(!a)return;const b=w=>{d.current&&(d.current.contains(w.target)||i(!1))},y=w=>{w.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",y)}},[a]);const x=async()=>{try{await H.post("/notifications/read-all",{}),o(b=>b.map(y=>({...y,read:!0}))),c(b=>b&&{...b,unread:0}),u.current=0,t==null||t(0),n.success("All notifications marked as read.",1500)}catch(b){n.error(`Failed: ${b.message}`)}},v=async b=>{try{await H.post(`/notifications/${encodeURIComponent(b)}/read`,{}),o(y=>y.map(w=>w.id===b?{...w,read:!0}:w)),c(y=>y&&{...y,unread:Math.max(0,(y.unread||1)-1)}),u.current=Math.max(0,u.current-1),t==null||t(u.current)}catch(y){n.error(`Failed: ${y.message}`)}},j=async b=>{try{await H.del(`/notifications/${encodeURIComponent(b)}`),o(y=>{const w=y.find(S=>S.id===b);return w&&!w.read&&(u.current=Math.max(0,u.current-1),c(S=>S&&{...S,unread:Math.max(0,S.unread-1)}),t==null||t(u.current)),y.filter(S=>S.id!==b)})}catch(y){n.error(`Failed: ${y.message}`)}},g=(l==null?void 0:l.unread)||0;return e.jsxs("div",{className:"notifications-root",ref:d,children:[e.jsxs("button",{type:"button",className:se("topbar-icon-btn notifications-bell",a&&"is-open"),onClick:()=>i(b=>!b),title:"Notifications","aria-label":"Notifications","aria-haspopup":"true","aria-expanded":a,children:[e.jsx(Xo,{size:16}),g>0&&e.jsx("span",{className:"notifications-badge",children:g>99?"99+":g})]}),a&&e.jsxs("div",{className:"notifications-panel",role:"dialog","aria-label":"Notifications",children:[e.jsxs("header",{className:"notifications-panel-head",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Notifications"}),g>0&&e.jsxs("span",{className:"muted text-sm",children:[" · ",g," unread"]})]}),e.jsxs("div",{className:"notifications-panel-head-actions",children:[e.jsxs(U,{size:"sm",variant:"ghost",onClick:x,disabled:g===0,children:[e.jsx(Ht,{size:12})," Mark all read"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>i(!1),"aria-label":"Close",title:"Close",children:e.jsx(Re,{size:14})})]})]}),e.jsx("div",{className:"notifications-list",children:h&&r.length===0?e.jsx("div",{className:"notifications-empty muted",children:"Loading…"}):r.length===0?e.jsx("div",{className:"notifications-empty muted",children:"No notifications yet."}):r.map(b=>{const y=Ph[b.severity]||Si;return e.jsxs("div",{className:se("notification-item",!b.read&&"is-unread",`severity-${b.severity}`),children:[e.jsx(y,{size:14,className:`notification-icon severity-${b.severity}`}),e.jsxs("div",{className:"notification-body",children:[b.title&&e.jsx("div",{className:"notification-title",children:b.title}),e.jsx("div",{className:"notification-msg",children:b.message}),e.jsxs("div",{className:"notification-meta muted",children:[e.jsx("span",{className:"mono",children:b.source}),e.jsx("span",{children:"·"}),e.jsx("span",{children:He(b.ts)})]})]}),e.jsxs("div",{className:"notification-actions",children:[!b.read&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>v(b.id),title:"Mark as read","aria-label":"Mark as read",children:e.jsx(Ht,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",onClick:()=>j(b.id),title:"Remove","aria-label":"Remove",children:e.jsx(Re,{size:12})})]})]},b.id)})}),e.jsx("footer",{className:"notifications-panel-foot",children:e.jsx("span",{className:"muted text-sm",children:l?`${l.total} total · last ${He(l.lastTs||new Date().toISOString())}`:""})})]})]})}function Fh({data:t,onClose:s}){const n=t==null?void 0:t.enabled;t==null||t.previousEnabled;const a=t==null?void 0:t.mode,i=t==null?void 0:t.defaultTemplate,r=t==null?void 0:t.lastUsedSlug,o=a==="toggle";return e.jsxs("div",{children:[o?e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Visual plan mode has been ",e.jsx("strong",{children:n?"enabled":"disabled"}),".",n?" The agent will create a plan and wait for your feedback on complex tasks.":" The agent will work without a visual plan canvas."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:8,fontWeight:600},children:["Visual Plan: ",e.jsx("span",{style:{color:n?"var(--color-success)":"var(--color-muted)"},children:n?"ON":"OFF"})]}),e.jsx("p",{style:{lineHeight:1.6,color:"var(--color-muted)",fontSize:13},children:"When enabled, the agent creates a visual plan and waits for your feedback before proceeding with complex tasks."}),i&&e.jsxs("p",{style:{marginTop:8,fontSize:13,color:"var(--color-muted)"},children:["Default template: ",e.jsx("code",{children:i})]}),r&&e.jsxs("p",{style:{fontSize:13,color:"var(--color-muted)"},children:["Last used plan: ",e.jsx("code",{children:r})]}),e.jsxs("p",{style:{marginTop:12,fontSize:13,color:"var(--color-muted)"},children:["Use ",e.jsx("code",{children:"/visual-plan on"})," or ",e.jsx("code",{children:"/visual-plan off"})," to toggle."]})]}),e.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:e.jsx(U,{variant:"ghost",onClick:s,children:"Close"})})]})}const Oh=["blank","feature-design","bug-investigation","decision-record","horizontal","vertical"];function Bh({data:t,onClose:s}){const n=(t==null?void 0:t.templates)??Oh,a=(t==null?void 0:t.defaultTemplate)??"blank",[i,r]=f.useState(""),[o,l]=f.useState(a),[c,h]=f.useState(!1),[m,d]=f.useState(null),u=async()=>{if(!i.trim()){d("Slug is required.");return}if(!/^[a-z0-9][a-z0-9-]{0,63}$/.test(i)){d("Invalid slug. Use lowercase letters, numbers, and hyphens. Must start with an alphanumeric character.");return}h(!0),d(null);try{await H.post("/artifacts",{slug:i,template:o}),s()}catch(p){d(p.message),h(!1)}};return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:["Create a new visual plan. Plans are stored in ",e.jsx("code",{children:"artifacts/"})," in your worktree."]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-slug",children:"Plan slug"}),e.jsx("input",{id:"plan-slug",className:"input",type:"text",placeholder:"e.g. my-feature",value:i,onChange:p=>{r(p.target.value),d(null)},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-template",children:"Template"}),e.jsx("select",{id:"plan-template",className:"select",value:o,onChange:p=>l(p.target.value),children:n.map(p=>e.jsx("option",{value:p,children:p},p))})]}),m&&e.jsx("p",{style:{marginBottom:12,color:"var(--color-danger)",fontSize:13},children:m}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"ghost",onClick:s,disabled:c,children:"Cancel"}),e.jsx(U,{variant:"primary",onClick:u,disabled:c||!i.trim(),children:c?"Creating…":"Create"})]})]})}function Hh({data:t,onClose:s}){const n=(t==null?void 0:t.plans)??[],a=(t==null?void 0:t.count)??n.length,i=r=>{window.open(`/artifacts/${r}/`,"_blank")};return e.jsxs("div",{children:[n.length===0?e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:["No plans found in this worktree. Use ",e.jsx("code",{children:"/artifact new <slug>"})," to create one."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:12,fontSize:13,color:"var(--color-muted)"},children:[a," plan",a!==1?"s":""," in this worktree:"]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:n.map(r=>e.jsxs("li",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 0",borderBottom:"1px solid var(--color-border)"},children:[e.jsx("code",{style:{fontSize:13},children:r}),e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>i(r),children:"Open"})]},r))})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(U,{variant:"ghost",onClick:s,children:"Close"})})]})}function Vh({data:t,onClose:s}){const n=(t==null?void 0:t.commands)??[],a=(t==null?void 0:t.templates)??[],i=(t==null?void 0:t.statuses)??[];return e.jsxs("div",{children:[n.length>0?e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:16,fontSize:13},children:e.jsx("tbody",{children:n.map(r=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e.jsx("td",{style:{padding:"5px 8px 5px 0",whiteSpace:"nowrap"},children:e.jsx("code",{style:{fontSize:12},children:r.cmd})}),e.jsx("td",{style:{padding:"5px 0",color:"var(--color-muted)"},children:r.desc})]},r.cmd))})}):e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:"No commands available."}),a.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available templates:"}),e.jsx("p",{style:{fontSize:13},children:a.join(", ")})]}),i.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available statuses:"}),e.jsx("p",{style:{fontSize:13},children:i.join(", ")})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(U,{variant:"ghost",onClick:s,children:"Close"})})]})}function Uh({data:t,onClose:s}){const[n,a]=f.useState(!1),[i,r]=f.useState(null),o=async()=>{a(!0),r(null);try{const l=await H.post("/chat/audit",{});r(l)}catch(l){r({ok:!1,findings:[],error:l.message})}finally{a(!1)}};return e.jsx("div",{children:i===null?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:"Run a security audit of your Bizar agent configuration. The audit checks for common misconfigurations, exposed secrets, and insecure defaults."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(U,{variant:"primary",onClick:o,disabled:n,children:n?"Running…":"Run Audit"})]})]}):e.jsxs(e.Fragment,{children:[i.ok?e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:12,fontWeight:600,color:"var(--color-success)"},children:"Audit passed — no issues found."}),i.findings.length>0&&e.jsx("ul",{style:{marginBottom:16,paddingLeft:20},children:i.findings.map((l,c)=>e.jsx("li",{style:{marginBottom:4,fontSize:13},children:l},c))})]}):e.jsxs("p",{style:{marginBottom:16,color:"var(--color-danger)"},children:["Audit failed: ",i.error??"unknown error"]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(U,{variant:"ghost",onClick:s,children:"Close"})})]})})}function qh({dialog:t,onClose:s}){if(!t.data)return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:`Command: ${t.command}`}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:s,children:"Close"})})]});const{message:n,detail:a,url:i}=t.data;return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:n??`Command: ${t.command}`}),a&&e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:a}),i&&e.jsx("p",{style:{marginBottom:16},children:e.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:s,children:"Close"})})]})}function Wh({dialog:t,onClose:s}){switch(t.component){case"visual-artifact":return e.jsx(Fh,{data:t.data,onClose:s});case"artifact-create":return e.jsx(Bh,{data:t.data,onClose:s});case"artifact-list":return e.jsx(Hh,{data:t.data,onClose:s});case"help":return e.jsx(Vh,{data:t.data,onClose:s});case"audit":return e.jsx(Uh,{data:t.data,onClose:s});default:return e.jsx(qh,{dialog:t,onClose:s})}}f.createContext(null);function Ie({as:t="div",p:s,px:n,py:a,m:i,mx:r,my:o,bg:l,border:c,rounded:h,shadow:m,display:d,position:u,className:p,children:x,...v}){return f.createElement(t,{...v,className:pe("box",s!==void 0&&`box-p-${s}`,n!==void 0&&`box-px-${n}`,a!==void 0&&`box-py-${a}`,i!==void 0&&`box-m-${i}`,r!==void 0&&`box-mx-${r}`,o!==void 0&&`box-my-${o}`,l&&`box-bg-${l}`,c&&`box-border-${c}`,h&&`box-rounded-${h}`,m&&`box-shadow-${m}`,d&&`box-d-${d}`,u&&`box-pos-${u}`,p)},x)}function st({direction:t="column",gap:s=3,align:n,justify:a,wrap:i,as:r="div",className:o,children:l,...c}){return f.createElement(r,{...c,className:pe("stack",t==="row"&&"stack-row",`gap-${s}`,n&&`align-${n}`,a&&`justify-${a}`,i===!0&&"wrap",o)},l)}function De({direction:t="row",gap:s=3,align:n,justify:a,wrap:i=!0,as:r="div",className:o,children:l,...c}){return f.createElement(r,{...c,className:pe("inline",t==="column"&&"inline-col",`gap-${s}`,n&&`align-${n}`,a&&`justify-${a}`,i?"wrap":"nowrap",o)},l)}function ai({cols:t=1,gap:s=3,autoFit:n=!1,className:a,children:i,style:r,...o}){return e.jsx("div",{...o,className:pe("grid",!n&&`cols-${t}`,n&&"grid-autofit",`gap-${s}`,a),style:r,children:i})}const nt=f.forwardRef(function({variant:s="secondary",size:n="md",loading:a=!1,fullWidth:i=!1,icon:r,iconRight:o,disabled:l,className:c,children:h,type:m="button",...d},u){return e.jsxs("button",{ref:u,type:m,disabled:l||a,"aria-busy":a||void 0,className:pe("btn",`btn-${s}`,`btn-size-${n}`,a&&"btn-loading",i&&"btn-full",c),...d,children:[a&&e.jsx("span",{className:"btn-spinner","aria-hidden":!0}),r,h,o]})}),ps=f.forwardRef(function({variant:s="secondary",size:n="md",icon:a,disabled:i,className:r,type:o="button",...l},c){return e.jsx("button",{ref:c,type:o,disabled:i,className:pe("icon-btn",`icon-btn-${s}`,`icon-btn-size-${n}`,r),...l,children:a})});f.forwardRef(function({checked:s,onChange:n,label:a,disabled:i,size:r="md",name:o,autoFocus:l,className:c,...h},m){return e.jsxs("label",{...h,className:pe("toggle",r==="sm"&&"toggle-sm",s&&"toggle-checked",c),children:[e.jsx("input",{ref:m,type:"checkbox",role:"switch",name:o,checked:s,disabled:i,autoFocus:l,onChange:d=>n(d.target.checked),className:"toggle-input"}),e.jsx("span",{className:"toggle-track","aria-hidden":!0,children:e.jsx("span",{className:"toggle-thumb"})}),a!==void 0&&e.jsx("span",{className:"toggle-label",children:a})]})});f.forwardRef(function({inputSize:s="md",error:n,leftIcon:a,rightIcon:i,disabled:r,className:o,...l},c){return e.jsxs("span",{className:pe("field",`field-size-${s}`,a&&"field-has-left",i&&"field-has-right",o),children:[a&&e.jsx("span",{className:"field-icon-left",children:a}),e.jsx("input",{ref:c,type:"text",disabled:r,"aria-invalid":n?!0:void 0,className:pe("field-input",n&&"field-error"),...l}),i&&e.jsx("span",{className:"field-icon-right",children:i})]})});const Gh=f.forwardRef(function({inputSize:s="md",error:n,hint:a,disabled:i,className:r,rows:o=4,...l},c){return e.jsxs("span",{className:pe("field","field-textarea",`field-size-${s}`,r),children:[e.jsx("textarea",{ref:c,rows:o,disabled:i,"aria-invalid":n?!0:void 0,className:pe("field-input","field-input-textarea",n&&"field-error"),...l}),a&&e.jsx("span",{className:"field-hint",children:a})]})});f.forwardRef(function({inputSize:s="md",error:n,value:a,onChange:i,min:r,max:o,step:l,disabled:c,className:h,...m},d){return e.jsx("span",{className:pe("field",`field-size-${s}`,h),children:e.jsx("input",{ref:d,type:"number",disabled:c,value:a,min:r,max:o,step:l,"aria-invalid":n?!0:void 0,className:pe("field-input",n&&"field-error"),onChange:u=>{const p=u.target.value;if(p===""){i("");return}const x=Number(p);i(Number.isFinite(x)?x:p)},...m})})});const Yh=f.forwardRef(function({inputSize:s="md",options:n,placeholder:a,error:i,value:r,defaultValue:o,disabled:l,name:c,required:h,onChange:m,className:d,...u},p){return e.jsxs("span",{...u,className:pe("select",`select-size-${s}`,d),children:[e.jsxs("select",{ref:p,disabled:l,name:c,required:h,value:r,defaultValue:o??(a!==void 0?"":void 0),onChange:m,"aria-invalid":i?!0:void 0,className:pe("select-native",i&&"select-error"),children:[a!==void 0&&e.jsx("option",{value:"",disabled:!0,children:a}),n.map(x=>e.jsx("option",{value:x.value,disabled:x.disabled,children:x.label},x.value))]}),e.jsx(ct,{className:"select-caret",size:14,"aria-hidden":!0})]})});f.forwardRef(function({checked:s,onChange:n,label:a,indeterminate:i=!1,disabled:r,name:o,autoFocus:l,required:c,className:h,...m},d){const u=f.useRef(null);f.useEffect(()=>{u.current&&(u.current.indeterminate=i)},[i]);const p=x=>{u.current=x,typeof d=="function"?d(x):d&&(d.current=x)};return e.jsxs("label",{...m,className:pe("checkbox",s&&"checkbox-checked",i&&"checkbox-indeterminate",h),children:[e.jsx("input",{ref:p,type:"checkbox",name:o,checked:s,disabled:r,required:c,autoFocus:l,onChange:x=>n(x.target.checked),className:"checkbox-input"}),e.jsx("span",{className:"checkbox-box","aria-hidden":!0,children:i?e.jsx(el,{strokeWidth:3}):s?e.jsx(Ht,{strokeWidth:3}):null}),a!==void 0&&e.jsx("span",{className:"checkbox-label",children:a})]})});f.forwardRef(function({name:s,value:n,onChange:a,options:i,orientation:r="vertical",legend:o,disabled:l,required:c,className:h,...m},d){return e.jsxs("div",{ref:d,role:"radiogroup",...m,className:pe("radio-group",r==="horizontal"&&"radio-group-horizontal",h),children:[o!==void 0&&e.jsx("p",{className:"radio-option-label",style:{marginBottom:4},children:o}),i.map(u=>{const p=u.value===n;return e.jsxs("label",{className:pe("radio-option",p&&"radio-option-checked"),children:[e.jsx("input",{type:"radio",name:s,value:u.value,checked:p,disabled:l||u.disabled,required:c,onChange:()=>a(u.value),className:"radio-option-input"}),e.jsx("span",{className:"radio-option-box","aria-hidden":!0,children:e.jsx("span",{className:"radio-option-dot"})}),e.jsxs("span",{className:"radio-option-content",children:[e.jsx("span",{className:"radio-option-label",children:u.label}),u.description!==void 0&&e.jsx("span",{className:"radio-option-desc",children:u.description})]})]},u.value)})]})});f.forwardRef(function({value:s,onChange:n,min:a=0,max:i=100,step:r=1,label:o,showValue:l=!1,disabled:c,className:h,...m},d){return e.jsxs("div",{className:pe("slider",h),children:[(o!==void 0||l)&&e.jsxs("div",{className:"slider-header",children:[o!==void 0&&e.jsx("span",{className:"slider-label",children:o}),l&&e.jsx("span",{className:"slider-value",children:String(s)})]}),e.jsx("input",{ref:d,type:"range",min:a,max:i,step:r,value:s,disabled:c,onChange:u=>n(Number(u.target.value)),className:"slider-input",...m})]})});const Xh=f.forwardRef(function({inputSize:s="md",value:n,onChange:a,onClear:i,placeholder:r="Search…",disabled:o,className:l,...c},h){const m=f.useCallback(()=>{a(""),i==null||i()},[a,i]),d=f.useCallback(u=>{a(u.target.value)},[a]);return e.jsxs("span",{className:pe("field",l),children:[e.jsx(Ae,{size:14,className:"field-icon-left","aria-hidden":!0}),e.jsx("input",{ref:h,type:"search",value:n,onChange:d,placeholder:r,disabled:o,className:"field-input field-has-left",...c}),n!==""&&!o&&e.jsx("button",{type:"button",onClick:m,className:"field-clear","aria-label":"Clear search",tabIndex:-1,children:e.jsx(Re,{size:12,"aria-hidden":!0})})]})});function Ds({label:t,value:s,unit:n,delta:a,icon:i,href:r,loading:o=!1,className:l,...c}){const h=r?"a":"div",m=r?{href:r,...c}:c;return e.jsxs(h,{...m,className:pe("bd-stat-tile",r&&"bd-stat-tile--clickable",l),children:[i&&e.jsx("div",{className:"bd-stat-tile__icon",children:i}),e.jsxs("div",{className:"bd-stat-tile__body",children:[e.jsx("div",{className:"bd-stat-tile__label",children:t}),e.jsx("div",{className:"bd-stat-tile__value-row",children:o?e.jsx("div",{className:"bd-stat-tile__skeleton","aria-hidden":"true"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bd-stat-tile__value",children:s}),n&&e.jsx("span",{className:"bd-stat-tile__unit",children:n})]})}),a&&!o&&e.jsxs("div",{className:pe("bd-stat-tile__delta",a.direction==="up"&&"bd-stat-tile__delta--up",a.direction==="down"&&"bd-stat-tile__delta--down"),"aria-label":`${a.direction==="up"?"up":"down"} ${a.value}`,children:[a.direction==="up"?e.jsx(pn,{size:12,"aria-hidden":"true"}):e.jsx(ua,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:a.value})]})]})]})}function Kh(t,s,n,a){if(t.length===0)return{line:"",area:"",min:0,max:0};const i=Math.min(...t),r=Math.max(...t),o=r-i||1,l=n-a*2,c=s,h=t.length>1?c/(t.length-1):0,m=t.map((v,j)=>{const g=j*h,b=a+l-(v-i)/o*l;return[g,b]}),d=m.map(([v,j],g)=>`${g===0?"M":"L"}${v.toFixed(2)},${j.toFixed(2)}`).join(" "),u=m[m.length-1],p=m[0],x=`${d} L${u[0].toFixed(2)},${(n-a).toFixed(2)} L${p[0].toFixed(2)},${(n-a).toFixed(2)} Z`;return{line:d,area:x,min:i,max:r}}function mr({data:t,width:s=80,height:n=24,stroke:a="var(--chart-1)",fill:i="var(--accent-subtle)",ariaLabel:r,className:o}){const{line:c,area:h}=Kh(t,s,n,2);return e.jsx("svg",{role:"img","aria-label":r??`Sparkline of ${t.length} values`,className:o,width:s,height:n,viewBox:`0 0 ${s} ${n}`,preserveAspectRatio:"none",children:t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("path",{className:"bd-sparkline__fill",d:h,fill:i}),e.jsx("path",{className:"bd-sparkline__line",d:c,stroke:a})]})})}function Zh({data:t,maxValue:s,showLabels:n=!0,className:a}){const i=s??Math.max(1,...t.map(r=>r.value));return e.jsx("div",{className:pe("bd-bar-chart",a),role:"list",children:t.map((r,o)=>{const l=Math.max(0,Math.min(100,r.value/i*100));return e.jsxs("div",{role:"listitem",className:"bd-bar-chart__row",children:[n&&e.jsxs("div",{className:"bd-bar-chart__header",children:[e.jsx("span",{className:"bd-bar-chart__label",children:r.label}),e.jsx("span",{className:"bd-bar-chart__value",children:r.value})]}),e.jsx("div",{className:"bd-bar-chart__track","aria-hidden":!n,children:e.jsx("div",{className:"bd-bar-chart__bar",style:{width:`${l}%`,background:r.color??"var(--chart-1)"}})})]},`${r.label}-${o}`)})})}function Qh(t){return t==null?"":typeof t=="string"||typeof t=="number"?t:String(t)}function Jh(t,s){return typeof t=="number"&&typeof s=="number"?t-s:String(t).localeCompare(String(s))}function em({columns:t,data:s,rowKey:n,onRowClick:a,sort:i,onSortChange:r,empty:o,loading:l=!1,compact:c=!1,className:h}){const[m,d]=f.useState(null),u=i??m,p=f.useMemo(()=>{if(!u)return s;const j=t.find(y=>y.key===u.key);if(!j)return s;const g=j.accessor??Qh,b=[...s];return b.sort((y,w)=>{const S=Jh(g(y),g(w));return u.direction==="asc"?S:-S}),b},[s,t,u]),x=j=>{const g=!u||u.key!==j?{key:j,direction:"asc"}:u.direction==="asc"?{key:j,direction:"desc"}:null;i===void 0&&d(g),r==null||r(g)},v=()=>{if(l){const j=t.length;return e.jsx(e.Fragment,{children:Array.from({length:3}).map((g,b)=>e.jsx("tr",{className:"bd-data-table__skeleton-row",children:Array.from({length:j}).map((y,w)=>e.jsx("td",{children:e.jsx("div",{className:"bd-data-table__skeleton"})},`skel-${b}-${w}`))},`skel-${b}`))})}return p.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"bd-data-table__empty",children:o??"No data"})}):p.map(j=>e.jsx("tr",{className:pe(a&&"bd-data-table__row--clickable"),onClick:a?()=>a(j):void 0,children:t.map(g=>e.jsx("td",{className:pe("bd-data-table__td",g.align==="right"&&"bd-data-table__td--right",g.align==="center"&&"bd-data-table__td--center"),children:g.render?g.render(j):String(g.accessor?g.accessor(j):"")},g.key))},n(j)))};return e.jsx("div",{className:pe("bd-data-table",c&&"bd-data-table--compact",h),children:e.jsx("div",{className:"bd-data-table__scroll",children:e.jsxs("table",{className:"bd-data-table__table",children:[e.jsx("thead",{className:"bd-data-table__thead",children:e.jsx("tr",{className:"bd-data-table__tr",children:t.map(j=>{const g=(u==null?void 0:u.key)===j.key,b=j.width!==void 0?{width:j.width}:void 0;return e.jsxs("th",{style:b,className:pe("bd-data-table__th",j.align==="right"&&"bd-data-table__th--right",j.align==="center"&&"bd-data-table__th--center",j.sortable&&"bd-data-table__th--sortable",g&&"bd-data-table__th--sorted"),onClick:j.sortable?()=>x(j.key):void 0,"aria-sort":g?u.direction==="asc"?"ascending":"descending":void 0,children:[j.header,j.sortable&&e.jsx("span",{className:"bd-data-table__sort-icon",children:g?u.direction==="asc"?e.jsx(pn,{size:12,"aria-hidden":"true"}):e.jsx(ua,{size:12,"aria-hidden":"true"}):e.jsx(Eu,{size:12,"aria-hidden":"true"})})]},j.key)})})}),e.jsx("tbody",{className:"bd-data-table__tbody",children:v()})]})})})}function tm({text:t}){const[s,n]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const i=f.useCallback(()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(t).then(()=>{n(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>n(!1),1500)}).catch(()=>{})},[t]);return e.jsx("button",{type:"button",className:pe("bd-kv-list__copy",s&&"bd-kv-list__copy--done"),"aria-label":s?"Copied":"Copy to clipboard",onClick:i,children:s?e.jsx(Ht,{size:12}):e.jsx(Vt,{size:12})})}function ll({items:t,orientation:s="horizontal",className:n}){return e.jsx("dl",{className:pe("bd-kv-list",s==="horizontal"?"bd-kv-list--horizontal":"bd-kv-list--vertical",n),children:t.map(a=>e.jsxs("div",{className:"bd-kv-list__row",children:[e.jsx("dt",{className:"bd-kv-list__label",children:a.label}),e.jsxs("dd",{className:pe("bd-kv-list__value",a.mono&&"bd-kv-list__value--mono"),children:[e.jsx("span",{children:a.value}),a.copyable&&e.jsx(tm,{text:String(a.value)})]})]},a.key))})}function On({title:t,description:s,icon:n,action:a,inline:i=!1,className:r}){return e.jsxs("div",{className:pe("bd-state",i&&"bd-state--inline",r),children:[n!==null&&e.jsx("div",{className:"bd-state__icon","aria-hidden":"true",children:n??e.jsx(Ru,{size:32})}),e.jsx("div",{className:"bd-state__title",children:t}),s&&e.jsx("div",{className:"bd-state__description",children:s}),a&&e.jsx("button",{type:"button",className:"bd-state__action bd-state__action--ghost",onClick:a.onClick,children:a.label})]})}function Ri({label:t,rows:s=3,inline:n=!1,className:a}){return s>0?e.jsxs("div",{className:pe("bd-state",n&&"bd-state--inline",a),role:"status","aria-live":"polite","aria-label":t??"Loading",children:[e.jsx("div",{className:"bd-skeleton-row","aria-hidden":"true",children:Array.from({length:s}).map((i,r)=>e.jsx("div",{className:"bd-skeleton-row__bar"},r))}),t&&e.jsx("div",{className:"bd-state__label",children:t})]}):e.jsxs("div",{className:pe("bd-state",n&&"bd-state--inline",a),role:"status","aria-live":"polite","aria-label":t??"Loading",children:[e.jsx("div",{className:pe("bd-spinner",n&&"bd-spinner--inline"),"aria-hidden":"true"}),t&&e.jsx("div",{className:"bd-state__label",children:t})]})}function wt({title:t,description:s,actions:n,children:a,padding:i=4,variant:r="outlined",className:o}){const l=t!==void 0||s!==void 0||n!==void 0;return e.jsxs("section",{className:pe("bizar-panel",r==="filled"&&"bizar-panel--filled",o),children:[l&&e.jsxs("div",{className:"bizar-panel__header",children:[(t||s)&&e.jsxs("div",{className:"bizar-panel__header-text",children:[t&&e.jsx("h3",{className:"bizar-panel__title",children:t}),s&&e.jsx("p",{className:"bizar-panel__description",children:s})]}),n&&e.jsx("div",{className:"bizar-panel__actions",children:n})]}),e.jsx("div",{className:pe("bizar-panel__body",`bizar-panel__padding--${i}`),children:a})]})}f.createContext(null);function ht({variant:t="neutral",size:s="md",children:n,className:a}){return e.jsx("span",{className:pe("bizar-badge",`bizar-badge--${t}`,`bizar-badge--${s}`,a),children:n})}function sn({variant:t="neutral",size:s="md",pulse:n=!1,className:a,label:i}){return e.jsx("span",{className:pe("bizar-status-dot",`bizar-status-dot--${t}`,`bizar-status-dot--${s}`,n&&"bizar-status-dot--pulse",a),role:i?"status":"presentation","aria-label":i})}function sm({setActiveTab:t,refreshKey:s=0}){var h;const[n,a]=f.useState(null),[i,r]=f.useState(!0),o=async()=>{r(!0);try{const[m,d,u]=await Promise.all([H.get("/memory/status").catch(()=>null),H.get("/memory/health").catch(()=>null),H.get("/memory/lightrag/stats").catch(()=>null)]);a({initialized:!!(m!=null&&m.initialized),mode:m==null?void 0:m.mode,projectId:m==null?void 0:m.projectId,vaultRoot:m==null?void 0:m.vaultRoot,branch:m==null?void 0:m.branch,gitClean:m==null?void 0:m.gitClean,noteCount:(m==null?void 0:m.noteCount)||0,healthScore:d==null?void 0:d.score,healthStatus:d==null?void 0:d.status,lightrag:u?{running:u.running,indexedApprox:u.indexedApprox}:void 0})}catch{a({initialized:!1})}finally{r(!1)}};f.useEffect(()=>{o()},[s]);const l=()=>t("memory"),c=(n==null?void 0:n.healthStatus)==="healthy"?"var(--success)":(n==null?void 0:n.healthStatus)==="degraded"?"var(--warning)":(n==null?void 0:n.healthStatus)==="unhealthy"?"var(--error)":"var(--text-dim)";return e.jsxs(ne,{className:"memory-overview-card",children:[e.jsxs(de,{children:[e.jsx(xt,{size:14})," Memory",e.jsxs(U,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:l,children:["Open Memory ",e.jsx(Is,{size:12})]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(xe,{size:12})})]}),e.jsx(ue,{children:"LightRAG + Obsidian vault + git sync — opens the dedicated Memory tab."}),n!=null&&n.initialized?e.jsxs("div",{className:"memory-status-card-grid",children:[e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Be,{size:11})," Health"]}),e.jsx("div",{className:"memory-status-card-value",style:{color:c},children:n.healthScore!==void 0?`${n.healthScore}/100`:"—"}),e.jsx("div",{className:"memory-status-card-sub muted",children:n.healthStatus||"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(xt,{size:11})," LightRAG"]}),e.jsx("div",{className:"memory-status-card-value",children:(h=n.lightrag)!=null&&h.running?"running":"stopped"}),e.jsx("div",{className:"memory-status-card-sub muted",children:n.lightrag?`${n.lightrag.indexedApprox} chunks`:"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Ve,{size:11})," Vault"]}),e.jsxs("div",{className:"memory-status-card-value",children:[n.noteCount," notes"]}),e.jsx("div",{className:"memory-status-card-sub muted ellipsis",title:n.vaultRoot||"",children:n.vaultRoot?n.vaultRoot.split("/").slice(-2).join("/"):"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(gt,{size:11})," Git"]}),e.jsx("div",{className:"memory-status-card-value",children:n.gitClean===null?n.mode==="local-only"?"local-only":"—":n.gitClean?"clean":"dirty"}),e.jsx("div",{className:"memory-status-card-sub muted",children:n.branch?`branch ${n.branch}`:St(n.branch||"")||"—"})]})]}):e.jsxs("div",{className:"muted",children:["Memory not initialised. Click ",e.jsx("strong",{children:"Open Memory"})," to set it up."]}),i&&!n&&e.jsx("div",{className:"muted text-sm",children:"Loading…"})]})}function nm({snapshot:t,settings:s,setActiveTab:n,refreshSnapshot:a}){var V,K;const i=fe();Ze();const r=f.useRef(null),[o,l]=f.useState(t.overview??null),[c,h]=f.useState(!t.overview),[m,d]=f.useState(t.projects||[]),[u,p]=f.useState(((V=t.activeProject)==null?void 0:V.id)||null),[x,v]=f.useState(t.mods||[]),[j,g]=f.useState(!1),[b,y]=f.useState(((K=t.overview)==null?void 0:K.recentActivity)??[]),[w,S]=f.useState(new Set),[$,M]=f.useState(()=>typeof document>"u"?!0:document.documentElement.getAttribute("data-theme")!=="light");f.useEffect(()=>{typeof document>"u"||($?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme","light"))},[$]),f.useEffect(()=>{let D=!1;return(async()=>{try{const G=await H.get("/activity/hidden");D||S(new Set(G.hidden||[]))}catch{}})(),()=>{D=!0}},[]);const z=(D,G)=>{const ee=`${D.kind||""}|${D.ts||""}|${D.slug||D.title||""}|${G}`;let te=0;for(let F=0;F<ee.length;F++)te=(te<<5)-te+ee.charCodeAt(F)|0;return Math.abs(te).toString(16).padStart(8,"0").slice(0,16)},A=async D=>{const G=w,ee=new Set(G);ee.add(D),S(ee);try{await H.post("/activity/hide",{keys:[D]})}catch(te){S(G),i.error(`Hide failed: ${te.message}`)}},k=async()=>{if(!window.confirm("Hide every recent activity item from the overview? The full log stays in Settings → Activity Log."))return;const D=b.map((ee,te)=>z(ee,te)),G=new Set(w);D.forEach(ee=>G.add(ee)),S(G);try{await H.post("/activity/hide",{keys:D}),i.success(`Hidden ${D.length} item(s).`)}catch(ee){i.error(`Clear failed: ${ee.message}`)}},C=async()=>{S(new Set);try{await H.del("/activity/hide"),i.success("All hidden activity restored.")}catch(D){i.error(`Restore failed: ${D.message}`)}};f.useEffect(()=>{var D;t.overview&&(l(t.overview),y(t.overview.recentActivity??[]),h(!1)),d(t.projects||[]),p(((D=t.activeProject)==null?void 0:D.id)||null),v(t.mods||[])},[t.overview,t.projects,t.activeProject,t.mods]),f.useEffect(()=>{let D=null;try{const G=H.getToken(),ee=G?`/api/activity/stream?token=${encodeURIComponent(G)}`:"/api/activity/stream";D=new EventSource(ee),D.addEventListener("snapshot",te=>{try{const F=JSON.parse(te.data);y(Array.isArray(F.events)?F.events.slice(0,50):[])}catch{}}),D.addEventListener("activity",te=>{try{const F=JSON.parse(te.data);y(Y=>[F,...Y].slice(0,50))}catch{}})}catch{}return()=>{try{D==null||D.close()}catch{}}},[]);const _=async()=>{i.info("Refreshing…",1500),await a();try{const D=await H.get("/projects");d(D.projects||[]),p(D.active||null)}catch{}},L=async()=>{var D;try{const G=await H.post("/projects/auto-detect");d(G.projects||[]),p(G.active||null);const ee=(D=G.projects)==null?void 0:D.find(te=>te.id===G.active);i.success(ee?`Active: ${ee.name}`:"Projects refreshed."),await a()}catch(G){i.error(`Auto-detect failed: ${G.message}`)}},N=async D=>{try{await H.post(`/projects/${encodeURIComponent(D)}/activate`),p(D),i.success("Project activated."),await a()}catch(G){i.error(`Activate failed: ${G.message}`)}},T=f.useMemo(()=>{const D={};(t.tasks||[]).forEach(ee=>{D[ee.status]=(D[ee.status]||0)+1});const G={queued:"var(--chart-3)",doing:"var(--info)",done:"var(--chart-1)",blocked:"var(--warning)",archived:"var(--text-tertiary)"};return Object.entries(D).map(([ee,te])=>({label:ee,value:te,color:G[ee]??"var(--chart-2)"}))},[t.tasks]),I=f.useMemo(()=>{const G=new Array(30).fill(0),ee=Date.now();(t.tasks||[]).forEach(F=>{const Y=Date.parse(F.createdAt||"");if(Number.isNaN(Y))return;const Q=Math.floor((ee-Y)/(24*3600*1e3));Q>=0&&Q<30&&(G[29-Q]+=1)});const te=G[G.length-1]||1;for(let F=0;F<29;F++)G[F]===0&&(G[F]=Math.max(1,Math.round(te*(.6+F/30*.4))));return G},[t.tasks]),R=f.useMemo(()=>{const G=new Array(30).fill(0),ee=Date.now();(t.tasks||[]).forEach(F=>{if(!F.assignee)return;const Y=Date.parse(F.updatedAt||F.createdAt||"");if(Number.isNaN(Y))return;const Q=Math.floor((ee-Y)/(24*3600*1e3));Q>=0&&Q<30&&(G[29-Q]+=1)});const te=G[G.length-1]||1;for(let F=0;F<29;F++)G[F]===0&&(G[F]=Math.max(1,Math.round(te*(.6+F/30*.4))));return G},[t.tasks]),B=f.useMemo(()=>(t.tasks||[]).filter(D=>!!D.assignee&&(D.status==="doing"||D.status==="queued")).length,[t.tasks]),E=(t.tasks||[]).length,P=f.useMemo(()=>t.activeProject?t.activeProject:u?m.find(D=>D.id===u)??null:m[0]??null,[t.activeProject,u,m]),W=f.useMemo(()=>b.slice(0,30).map((D,G)=>({it:D,idx:G,key:z(D,G)})).filter(({key:D})=>!w.has(D)),[b,w]);return c||!o?e.jsx(Ie,{as:"div",className:"view view-overview",bg:"0",p:7,children:e.jsx(st,{direction:"row",align:"center",justify:"center",children:e.jsx(Ri,{label:"Loading overview…"})})}):e.jsx(Ie,{as:"div",className:"view view-overview",bg:"0",p:7,children:e.jsxs(st,{gap:6,children:[e.jsxs(De,{justify:"between",align:"center",gap:3,wrap:!0,children:[e.jsxs(st,{gap:1,children:[e.jsx("h1",{className:"overview-title",style:{fontSize:"var(--text-2xl)",fontWeight:"var(--weight-semibold)",margin:0},children:"Overview"}),e.jsx("span",{className:"overview-subtitle muted",style:{fontSize:"var(--text-sm)",color:"var(--text-secondary)"},children:P?`Active: ${P.name}`:"No active project — pick one below."})]}),e.jsxs(De,{gap:2,align:"center",wrap:!0,children:[m.length>0&&e.jsxs("span",{className:"select select-size-sm overview-project-select","aria-label":"Switch active project",children:[e.jsx("select",{className:"select-native",value:u??"",onChange:async D=>{const G=D.target.value;!G||G===u||await N(G)},"aria-label":"Switch active project","data-testid":"overview-project-select",children:m.map(D=>e.jsx("option",{value:D.id,children:D.name},D.id))}),e.jsx("svg",{className:"select-caret",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),e.jsx(nt,{variant:"secondary",size:"sm",onClick:_,icon:e.jsx(xe,{size:12}),"data-testid":"overview-refresh",children:"Refresh"}),e.jsx(ps,{variant:"ghost",size:"md",onClick:()=>M(D=>!D),"aria-label":$?"Switch to light theme":"Switch to dark theme",icon:$?e.jsx(il,{size:14}):e.jsx(tl,{size:14})})]})]}),e.jsxs(ai,{cols:5,autoFit:!0,gap:3,style:{minHeight:"unset"},"data-testid":"overview-stat-row",children:[e.jsx(Ds,{label:"Agents",value:o.counts.agents,icon:e.jsx(pt,{size:18}),href:"#","data-testid":"overview-stat-agents"}),e.jsx(Ds,{label:"Tasks",value:E,icon:e.jsx(Qt,{size:18}),"data-testid":"overview-stat-tasks"}),e.jsx(Ds,{label:"Projects",value:m.length,icon:e.jsx(lt,{size:18}),"data-testid":"overview-stat-projects"}),e.jsx(Ds,{label:"Mods",value:x.length,icon:e.jsx(Ns,{size:18}),"data-testid":"overview-stat-mods"}),e.jsx(Ds,{label:"Background",value:B,icon:e.jsx(Yn,{size:18}),"data-testid":"overview-stat-background"})]}),e.jsxs(ai,{cols:3,autoFit:!0,gap:3,children:[e.jsx(wt,{title:"Tasks · last 30 days",description:"Bucketed from snapshot.tasks createdAt",padding:3,"data-testid":"overview-panel-tasks-spark",children:e.jsx(Ie,{p:3,children:e.jsxs(st,{direction:"row",justify:"between",align:"end",gap:3,children:[e.jsx(mr,{data:I,width:220,height:56,ariaLabel:"Tasks created per day, last 30"}),e.jsx(Ie,{as:"div",className:"overview-spark-meta",style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",fontSize:"var(--text-2xl)",fontWeight:"var(--weight-semibold)",color:"var(--text-primary)"},children:E})]})})}),e.jsx(wt,{title:"Agent activity · 30d",description:"Distinct assignees touching tasks per day",padding:3,"data-testid":"overview-panel-agents-spark",children:e.jsx(Ie,{p:3,children:e.jsxs(st,{direction:"row",justify:"between",align:"end",gap:3,children:[e.jsx(mr,{data:R,width:220,height:56,stroke:"var(--chart-2)",fill:"var(--info-subtle)",ariaLabel:"Agent touches per day, last 30"}),e.jsx(Ie,{as:"div",style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",fontSize:"var(--text-2xl)",fontWeight:"var(--weight-semibold)",color:"var(--text-primary)"},children:o.counts.agents})]})})}),e.jsx(wt,{title:"Tasks by status",description:"Live snapshot of the kanban buckets",padding:3,"data-testid":"overview-panel-tasks-by-status",children:e.jsx(Ie,{as:"div",p:3,children:e.jsx(Zh,{data:T})})}),e.jsx(wt,{title:"Memory",description:"Vault, LightRAG, git sync",padding:3,"data-testid":"overview-panel-memory",children:e.jsx(Ie,{as:"div",p:3,children:e.jsx(sm,{setActiveTab:n})})}),e.jsx(wt,{title:"Active project",description:P?`${P.path}`:"No active project selected",padding:3,"data-testid":"overview-panel-active-project",children:P?e.jsx(Ie,{p:3,children:e.jsxs(st,{gap:3,children:[e.jsx(ll,{items:[{key:"pname",label:"Name",value:P.name,mono:!0},{key:"ppath",label:"Path",value:hm(P.path,48),mono:!0,copyable:!0},{key:"pstatus",label:"Status",value:e.jsxs(ht,{variant:P.status==="active"?"success":P.status==="error"?"danger":"neutral",children:[e.jsx(sn,{variant:P.status==="active"?"success":P.status==="error"?"danger":"neutral",size:"sm",pulse:P.status==="active"}),P.status]})},{key:"pseen",label:"Last opened",value:P.lastAccessed&&He(P.lastAccessed)||"—"}]}),e.jsxs(De,{gap:2,wrap:!0,children:[e.jsx(nt,{variant:"primary",size:"sm",onClick:()=>n("tasks"),icon:e.jsx(Qt,{size:12}),children:"Open tasks"}),e.jsx(nt,{variant:"secondary",size:"sm",onClick:L,icon:e.jsx(lt,{size:12}),children:"Auto-detect"})]})]})}):e.jsx(Ie,{as:"div",p:3,children:e.jsx(On,{title:"No active project",description:"Add one or auto-detect from the current directory.",inline:!0,icon:e.jsx(lt,{size:20})})})}),e.jsx(wt,{title:"Recent mods",description:"Last few installed extensions",padding:3,"data-testid":"overview-panel-recent-mods",children:x.length===0?e.jsx(Ie,{as:"div",p:3,children:e.jsx(On,{title:"No mods installed",description:"Install from the Mods tab.",inline:!0,icon:e.jsx(Ns,{size:20})})}):e.jsx(Ie,{p:2,children:e.jsx(st,{gap:0,children:x.slice(0,6).map(D=>e.jsx(Ie,{py:2,px:3,style:{borderTop:"1px solid var(--border-subtle)"},children:e.jsxs(De,{justify:"between",align:"center",gap:3,children:[e.jsxs(st,{gap:0,style:{minWidth:0},children:[e.jsx("span",{style:{fontWeight:"var(--weight-medium)",fontSize:"var(--text-base)"},children:D.name}),e.jsxs("span",{className:"muted",style:{fontFamily:"var(--font-mono)",fontSize:"var(--text-xs)",color:"var(--text-tertiary)"},children:["v",D.version," · ",D.type]})]}),e.jsxs(ht,{variant:D.enabled?"success":"neutral",size:"sm",children:[e.jsx(sn,{variant:D.enabled?"success":"neutral",size:"sm"}),D.enabled?"on":"off"]})]})},D.id))})})})]}),e.jsxs(wt,{title:"Recent activity",description:`${W.length} item${W.length===1?"":"s"} · live via SSE`,actions:e.jsxs(De,{gap:2,align:"center",children:[w.size>0&&e.jsxs(nt,{variant:"ghost",size:"sm",onClick:C,icon:e.jsx(ks,{size:12}),"aria-label":`Restore ${w.size} hidden items`,children:["Restore (",w.size,")"]}),b.length>0&&e.jsx(nt,{variant:"ghost",size:"sm",onClick:k,icon:e.jsx(ti,{size:12}),"data-testid":"overview-hide-all","aria-label":"Hide all activity from overview",children:"Hide all"})]}),padding:0,"data-testid":"overview-panel-activity",children:[w.size>0&&e.jsxs(Ie,{as:"div",p:3,style:{background:"var(--surface-2)",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--space-3)"},role:"status",children:[e.jsxs(De,{gap:2,align:"center",children:[e.jsx(ti,{size:12}),e.jsxs("span",{style:{fontSize:"var(--text-sm)"},children:[w.size," item",w.size===1?"":"s"," ","hidden from the overview."]})]}),e.jsxs(nt,{variant:"ghost",size:"sm",onClick:C,children:[e.jsx(ks,{size:12})," Show them again"]})]}),W.length===0?e.jsx(Ie,{as:"div",p:5,children:e.jsx(On,{title:"No activity yet",description:"Use the prompt below or invoke a Bizar command to start a feed.",inline:!0,icon:e.jsx(Be,{size:20})})}):e.jsx(st,{as:"ul",gap:0,role:"list","aria-live":"polite","aria-relevant":"additions","data-testid":"overview-activity-list",children:W.map(({it:D,key:G})=>e.jsx(am,{item:D,activityKey:G,onNavigate:n,onHide:A},G))})]}),e.jsx(wt,{title:"What do you want to do?",description:"Describe what you want — Odin will split it into tasks, delegate to background agents, and track progress in real time.",padding:4,actions:e.jsxs(ht,{variant:"accent",size:"sm",children:[e.jsx(vt,{size:12}),e.jsx("span",{style:{marginLeft:4},children:"Odin + 12 specialists"})]}),"data-testid":"overview-panel-prompts",children:e.jsx("form",{onSubmit:async D=>{var ee,te;D.preventDefault();const G=(((ee=r.current)==null?void 0:ee.value)||"").trim();if(G){g(!0);try{const F=await H.post("/tasks/submit",{title:G});i.success(`Odin split it into ${((te=F.subtasks)==null?void 0:te.length)||1} task(s)`),r.current&&(r.current.value=""),await a()}catch(F){i.error(`Failed: ${F.message}`)}finally{g(!1)}}},children:e.jsxs(st,{gap:3,children:[e.jsx(Gh,{ref:r,disabled:j,"aria-label":"Describe what you want Odin to do",rows:4,placeholder:"e.g. Implement user authentication with email + password, including registration, login, password reset, and integration tests. Use Bcrypt, JWT tokens, and the existing API style.","data-testid":"overview-prompt-input"}),e.jsxs(De,{justify:"between",align:"center",gap:3,wrap:!0,children:[e.jsx(De,{gap:2,wrap:!0,children:["Implement feature","Fix bug","Refactor","Investigate","Add tests","Document","Optimize","Deploy"].map(D=>e.jsx("button",{type:"button",className:"overview-quick-chip",onClick:()=>{r.current&&(r.current.value=D,r.current.focus())},children:D},D))}),e.jsx(nt,{type:"submit",variant:"primary",size:"md",disabled:j,loading:j,icon:j?void 0:e.jsx(Rt,{size:12}),"data-testid":"overview-submit",children:j?"Submitting…":"Submit to Odin"})]})]})})})]})})}function am({item:t,activityKey:s,onNavigate:n,onHide:a}){const i=lm(t),r=cm(t.kind||""),o=rm(t.kind||"activity"),l=om(t),c=dm(t.kind||"");return e.jsxs("li",{className:`overview-activity-row overview-activity-row-${i}`,style:{borderTop:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",gap:"var(--space-3)",paddingInline:"var(--space-4)",paddingBlock:"var(--space-3)"},children:[e.jsxs("button",{type:"button",onClick:()=>{c&&n(c)},className:"overview-activity-row__main",title:c?`Open ${c}`:o,style:{flex:1,display:"flex",alignItems:"center",gap:"var(--space-3)",textAlign:"left",background:"transparent",color:"inherit",padding:0},children:[e.jsx("span",{style:{color:i==="error"?"var(--danger)":i==="warning"?"var(--warning)":i==="success"?"var(--success)":"var(--accent)",display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,flexShrink:0},children:e.jsx(r,{size:14})}),e.jsxs(st,{gap:0,style:{minWidth:0,flex:1},children:[e.jsxs(De,{justify:"between",align:"center",gap:3,wrap:!0,children:[e.jsx("span",{style:{fontSize:"var(--text-sm)",fontWeight:"var(--weight-medium)"},children:o}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",fontSize:"var(--text-xs)",color:"var(--text-tertiary)"},children:um(t.ts)})]}),e.jsx("span",{className:"muted",style:{fontSize:"var(--text-sm)",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block"},title:l,children:l})]})]}),e.jsx(ps,{variant:"ghost",size:"sm",onClick:()=>a(s),"aria-label":"Hide from overview",title:"Hide from overview (kept in Settings → Activity Log)",icon:e.jsx(Re,{size:12})})]})}function im(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function rm(t){const s=t.trim().toLowerCase().replace(/[:_]/g,"."),[n,a="updated"]=s.split("."),i={settings:"Settings",task:"Task",tasks:"Task",agent:"Agent",agents:"Agent",plan:"Plan",plans:"Plan",bg:"Background job",background:"Background job",session:"Session",mod:"Mod",mods:"Mod",provider:"Provider",providers:"Provider"},r={create:"created",created:"created",add:"added",added:"added",update:"updated",updated:"updated",delegate:"delegated",delegated:"delegated",invoke:"invoked",invoked:"invoked",restart:"restarted",restarted:"restarted",delete:"deleted",deleted:"deleted",remove:"removed",removed:"removed",archive:"archived",archived:"archived",restore:"restored",restored:"restored",complete:"completed",completed:"completed",fail:"failed",failed:"failed",error:"errored",stuck:"marked stuck"},o=i[n]||im(n.replace(/-/g," ")),l=r[a]||a.replace(/-/g," ");return`${o} ${l}`.trim()}function kn(t,s){for(const n of s){const a=t[n];if(typeof a=="string"&&a.trim())return a.trim()}return""}function om(t){const s=kn(t,["message","text","prompt","title","name"]);if(s)return s;const n=[],a=kn(t,["slug"]),i=kn(t,["agent","author"]),r=kn(t,["status"]);return a&&n.push(`Plan ${a}`),i&&n.push(i),r&&n.push(r),n.length?n.join(" · "):"No additional details."}function lm(t){const s=(t.kind||"").toLowerCase(),n=(t.status||"").toLowerCase();return s.includes("error")||n==="error"||n==="failure"?"error":s.includes("warn")||n==="blocked"?"warning":s.includes("done")||s.includes("success")||n==="done"?"success":"info"}function cm(t){const s=t.toLowerCase();return s==="task"?Qt:s==="agent"?pt:s==="plan"?Zn:s.includes("bg")||s.includes("background")||s.includes("job")?Ci:s==="mod"?Ns:s==="skill"?vt:s.includes("error")||s.includes("failure")?ys:s.includes("warn")?Ue:Be}function dm(t){const s=t.toLowerCase();return s==="task"?"tasks":s==="agent"?"agents":s==="plan"?"artifacts":s.includes("bg")||s.includes("background")?"activity":s==="mod"?"mods":s==="skill"?"skills":null}function um(t){return He(t)}function hm(t,s){if(!t||t.length<=s)return t;const n=Math.floor((s-1)/2);return`${t.slice(0,n)}…${t.slice(-n)}`}const mm=rt.memo(nm);function fm({icon:t,title:s,message:n,action:a}){return e.jsxs("div",{className:"chat-empty-state",children:[t&&e.jsx("div",{className:"chat-empty-state-icon",children:t}),e.jsx("h2",{className:"chat-empty-state-title",children:s}),e.jsx("p",{className:"chat-empty-state-message",children:n}),a&&e.jsx("div",{className:"chat-empty-state-action",children:a})]})}function pm({session:t,mode:s,anchor:n,renameDraft:a,setRenameDraft:i,onEdit:r,onDeleteRequest:o,onConfirmDelete:l,onConfirmRename:c,onClose:h}){const m=f.useRef(null),d=Math.round(n.rect.bottom+2),u=Math.max(8,Math.round(window.innerWidth-n.rect.right));f.useEffect(()=>{const x=g=>{const b=g.target;!m.current||!b||m.current.contains(b)||h()},v=g=>{g.key==="Escape"&&h()},j=window.setTimeout(()=>{document.addEventListener("mousedown",x),document.addEventListener("keydown",v)},0);return()=>{window.clearTimeout(j),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v)}},[h]),f.useEffect(()=>{if(s!=="rename")return;const x=window.setTimeout(()=>{var j;const v=(j=m.current)==null?void 0:j.querySelector("input.session-row-menu-input");v==null||v.focus(),v==null||v.select()},0);return()=>window.clearTimeout(x)},[s]);const p=e.jsxs("div",{ref:m,className:"session-row-menu",role:"menu","aria-label":`Options for ${t.title}`,style:{position:"fixed",top:d,right:u},onClick:x=>x.stopPropagation(),children:[s==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"session-row-menu-item",role:"menuitem",onClick:x=>{x.stopPropagation(),r()},children:[e.jsx(uh,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Rename"}),e.jsx("kbd",{children:"R"})]}),e.jsxs("button",{type:"button",className:"session-row-menu-item session-row-menu-item-danger",role:"menuitem",onClick:x=>{x.stopPropagation(),o()},children:[e.jsx(Fe,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Delete"}),e.jsx("kbd",{children:"⌫"})]})]}),s==="rename"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Rename session"}),e.jsx("input",{type:"text",className:"session-row-menu-input",value:a,onChange:x=>i(x.target.value),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),c()):x.key==="Escape"&&(x.preventDefault(),h())},onClick:x=>x.stopPropagation(),"aria-label":"New session name"}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:x=>{x.stopPropagation(),h()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:x=>{x.stopPropagation(),c()},children:"Save"})]})]}),s==="confirm-delete"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Delete this session?"}),e.jsxs("div",{className:"session-row-menu-inline-message",children:['"',t.title,'" and its sub-agents will be removed.']}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:x=>{x.stopPropagation(),h()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:x=>{x.stopPropagation(),l()},children:"Delete"})]})]})]});return Fo.createPortal(p,document.body)}function ii({node:t,depth:s=0,collapsible:n=!1,isLast:a=!0,open:i,onToggle:r}){var p;const[o,l]=f.useState(n),c=i!==void 0,h=c?i:o,m=x=>{c||l(x),r==null||r(x)},d=(((p=t.children)==null?void 0:p.length)??0)>0,u=e.jsxs(e.Fragment,{children:[n&&e.jsx("span",{className:`agent-node-chevron ${h?"open":""}`,"aria-hidden":!0,children:"›"}),e.jsx("span",{className:`agent-node-dot status-${t.status}`,"aria-hidden":!0}),e.jsx("span",{className:"agent-node-name",children:t.name}),t.role&&e.jsx("span",{className:"agent-node-role chat-mono",children:t.role}),e.jsx("span",{className:`agent-node-pill status-${t.status}`,children:t.status})]});return e.jsxs("div",{className:["agent-node",`depth-${s}`,`status-${t.status}`,h?"open":"closed",a?"last":""].filter(Boolean).join(" "),children:[n?e.jsx("button",{type:"button",className:`agent-node-head status-${t.status} collapsible`,onClick:x=>{x.stopPropagation(),m(!h)},"aria-expanded":h,children:u}):e.jsx("div",{className:`agent-node-head status-${t.status}`,children:u}),h&&e.jsxs(e.Fragment,{children:[t.summary&&e.jsx("div",{className:"agent-node-summary",children:t.summary}),d&&e.jsx("div",{className:"agent-node-children",children:t.children.map((x,v)=>e.jsx(ii,{node:x,depth:s+1,collapsible:!1,isLast:v===t.children.length-1},x.id))})]})]})}function xm(t){return t.tree!==void 0}function gm(t){const s=t.open??!0;if(xm(t))return e.jsx("div",{className:`agent-tree variant-${t.variant??"full"}`,children:e.jsx(ii,{node:t.tree.root,depth:0,open:s})});const n=t.children??[];return e.jsx("div",{className:`agent-tree variant-${t.variant} agent-tree-children-only`,children:e.jsx("div",{className:"agent-tree-children-body",children:n.map((a,i)=>e.jsx(f.Fragment,{children:e.jsx(ii,{node:a,depth:0,collapsible:!1,open:s,isLast:i===n.length-1})},a.id))})})}function ym({children:t,variant:s="rail",open:n=!0}){return n?e.jsx(gm,{variant:s,open:n,children:t}):null}const vm=["Today","Yesterday","This week","Earlier"];function fr(t,s){return t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}function jm(t,s){const n=t.getTime()-s.getTime();return Math.floor(n/(1e3*60*60*24))}function bm(t){const s=new Date,n=new Date(s);n.setDate(n.getDate()-1);const a=new Date(s);a.setDate(a.getDate()-7);const i={Today:[],Yesterday:[],"This week":[],Earlier:[]};for(const r of t){const o=new Date(Number(r.mtime)||Date.now());fr(o,s)?i.Today.push(r):fr(o,n)?i.Yesterday.push(r):jm(s,o)<7?i["This week"].push(r):i.Earlier.push(r)}return i}function wm(t){return new Date(Number(t)||Date.now()).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function km({state:t,agent:s}){return t==="streaming"?e.jsx("span",{className:"session-state session-state-streaming",title:`${s||"Odin"} is typing…`}):t==="awaiting"?e.jsx("span",{className:"session-state session-state-awaiting",title:"Awaiting your reply","aria-hidden":!0}):t==="idle"?e.jsx("span",{className:"session-state session-state-idle","aria-hidden":!0}):null}function Nm({sessions:t,clineSessions:s=[],activeSessionId:n,activeClineSessionId:a,activeProject:i,creating:r,onCreateSession:o,onSelectSession:l,onSelectClineSession:c,onRenameSession:h,onDeleteSession:m,groupBy:d}){var R;const u=f.useMemo(()=>[...t,...s],[t,s]),p=f.useMemo(()=>[...u].sort((B,E)=>Number(E.mtime??0)-Number(B.mtime??0)),[u]),x=f.useMemo(()=>d?d(p):bm(p),[d,p]),[v,j]=f.useState({}),g=B=>v[B]===!0,[b,y]=f.useState(null),[w,S]=f.useState("main"),[$,M]=f.useState(""),[z,A]=f.useState(null),k=f.useRef({}),C=(B,E="main")=>{const P=k.current[B];if(!P)return;const W=E==="main"?P:P.querySelector(".chat-rail-item-menu-trigger")??P;if(A({id:B,rect:W.getBoundingClientRect()}),y(B),S(E),E==="rename"){const V=[...t,...s].find(K=>K.id===B);M((V==null?void 0:V.title)??(V==null?void 0:V.id)??"")}},_=()=>{y(null),S("main"),M(""),A(null)},L=B=>{if(B.source==="cline"){c(B);return}l(B.id)},N=()=>{if(!z)return;const B=z.id,E=$.trim();if(!E){_();return}h==null||h(B,E),_()},T=()=>{z&&(m==null||m(z.id),_())},I=d?Object.entries(x):vm.filter(B=>{var E;return(E=x[B])==null?void 0:E.length}).map(B=>[B,x[B]]);return e.jsxs("aside",{className:"chat-rail",children:[e.jsx("div",{className:"chat-rail-head",children:e.jsxs("button",{type:"button",className:"chat-new-btn",onClick:o,disabled:r||!i,title:i?"Create new session":"Pick a project first","aria-label":"Create new session",children:[e.jsx(qe,{size:14,"aria-hidden":!0}),e.jsx("span",{children:r?"Creating…":"New session"})]})}),p.length===0?e.jsx("div",{className:"chat-sessions-empty",children:e.jsx(fm,{icon:e.jsx(qe,{size:20,"aria-hidden":!0}),title:i?"No sessions yet":"No project",message:i?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions."})}):e.jsx("div",{className:"chat-rail-list",children:I.map(([B,E])=>e.jsxs("div",{className:"chat-rail-group",children:[e.jsx("div",{className:"chat-rail-group-label",children:B}),E.map(P=>{var ee,te;const W=P.source==="cline",V=W?a===P.id:n===P.id,K=P.tree,D=!!((ee=K==null?void 0:K.root)!=null&&ee.children&&K.root.children.length>0),G=g(P.id);return e.jsxs(f.Fragment,{children:[e.jsxs("div",{ref:F=>{k.current[P.id]=F},role:"button",tabIndex:0,className:`chat-rail-item state-${P.state??"idle"}${V?" active":""}`,onClick:()=>L(P),onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),L(P))},"aria-current":V?"true":void 0,children:[e.jsx(km,{state:P.state??"idle",agent:P.agent}),e.jsxs("div",{className:"chat-rail-item-title",children:[P.pinned&&e.jsx("span",{className:"chat-rail-pin","aria-hidden":!0,children:"★"}),W&&e.jsx(Is,{size:11,style:{color:"var(--text-muted)",flexShrink:0},"aria-hidden":!0}),e.jsx("span",{className:"chat-ellipsis",children:P.title||P.id})]}),e.jsxs("div",{className:"chat-rail-item-meta",children:[e.jsx("span",{className:"chat-rail-item-meta-time",children:P.time??wm(P.mtime)}),(P.unread??0)>0&&e.jsx("span",{className:"chat-rail-badge",children:P.unread})]}),e.jsx("button",{type:"button",className:`chat-rail-item-menu-trigger${b===P.id?" open":""}`,"aria-label":`Session options for ${P.title||P.id}`,"aria-haspopup":"menu","aria-expanded":b===P.id,onClick:F=>{F.stopPropagation(),b===P.id?_():C(P.id,"main")},children:e.jsxs("svg",{viewBox:"0 0 14 14","aria-hidden":!0,children:[e.jsx("circle",{cx:"3",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"7",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"11",cy:"7",r:"1.2",fill:"currentColor"})]})}),V&&D&&e.jsx("button",{type:"button",className:`chat-rail-tree-chevron${G?" open":""}`,"aria-label":G?"Collapse sub-agents":"Expand sub-agents","aria-expanded":G,onClick:F=>{F.stopPropagation(),j(Y=>({...Y,[P.id]:!Y[P.id]}))},children:e.jsx("svg",{viewBox:"0 0 10 10","aria-hidden":!0,children:e.jsx("polyline",{points:"3,1.5 7,5 3,8.5"})})})]}),V&&D&&G&&((te=K==null?void 0:K.root)==null?void 0:te.children)&&e.jsx(ym,{children:K.root.children,variant:"rail",open:!0})]},W?`oc-${P.id}`:P.id)})]},B))}),b&&z&&e.jsx(pm,{session:{id:z.id,title:((R=[...t,...s].find(B=>B.id===z.id))==null?void 0:R.title)??z.id},mode:w,anchor:z,renameDraft:$,setRenameDraft:M,onEdit:()=>C(b,"rename"),onDeleteRequest:()=>C(b,"confirm-delete"),onConfirmDelete:T,onConfirmRename:N,onClose:_})]})}function Sm(t){const{text:s,sending:n,onSend:a,activeSource:i}=t,[r,o]=f.useState(!1),l=()=>{!s.trim()||n||(o(!0),a(),window.setTimeout(()=>o(!1),320))};return e.jsxs("div",{className:`chat-composer-wrap chat-composer-source-${i??"none"}`,children:[e.jsx("div",{className:`chat-composer-pill${r?" takeoff":""}`,children:e.jsx(Nu,{...t,onSend:l})}),e.jsxs("div",{className:"chat-composer-hint chat-muted",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"⏎"})," send"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"⇧⏎"})," newline"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"/"})," commands"]}),i==="cline"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ cline"}),i==="bizar"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ bizar chat"}),n&&e.jsx("span",{className:"chat-composer-source-hint",children:"sending…"})]})]})}function Ta(t){return t.toLocaleString()}function Cm(t){return!t||!t.includes("/")?"":t.split("/")[0]}function zm(t){if(!t)return 0;const s=t.toLowerCase();return s.includes("opus")?15:s.includes("sonnet")?3:s.includes("haiku")?.8:s.includes("gpt-4o")?5:s.includes("gpt-4")?10:s.includes("deepseek")?.27:s.includes("minimax")?.3:s.includes("llama-3.3-70b")?.59:1}function Mm({sessionId:t,messages:s,pinned:n,agent:a,model:i,agents:r,mcps:o,allCommands:l,activeSource:c="bizar",onRename:h,onDelete:m,onExport:d,busy:u,error:p,onRetry:x}){const[v,j]=f.useState(null);f.useEffect(()=>{let C=!1;return(async()=>{try{const _=await fetch("/api/usage?range=24h",{headers:{Accept:"application/json"}});if(!_.ok)return;const L=await _.json();C||j(L)}catch{}})(),()=>{C=!0}},[t]);const g=(s==null?void 0:s.length)??0,b=(n==null?void 0:n.size)??0,y=s.reduce((C,_)=>C+(_.content||_.message||"").length,0),w=Math.round(y/4),S=zm(i),$=w/1e6*S,M=(v==null?void 0:v.totalTokens)??w,z=(v==null?void 0:v.costUsd)??$,A=128e3,k=Cm(i);return e.jsxs("aside",{className:"chat-info",children:[p&&e.jsxs("div",{className:"chat-info-section chat-info-error",role:"alert","aria-live":"polite",children:[e.jsxs("h4",{children:[e.jsx(Ue,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Couldn't load session"]}),e.jsx("p",{className:"chat-info-value chat-ellipsis",title:p.message,children:p.message}),e.jsxs("div",{className:"chat-info-mono",children:["code · ",p.code]}),p.suggestion?e.jsx("p",{className:"chat-info-suggestion",children:p.suggestion}):null,p.canRetry!==!1&&x?e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm chat-info-retry",onClick:x,title:"Retry loading the session",children:[e.jsx(da,{size:12,"aria-hidden":!0})," Retry"]}):null]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("div",{className:"chat-info-section-head",children:[e.jsxs("h4",{children:[e.jsx(mn,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Session"]}),e.jsx("span",{className:`chat-source-badge chat-source-${c??"none"}`,style:{marginLeft:"auto"},children:c==="cline"?"cline":"bizar chat"})]}),e.jsx("div",{className:"chat-info-mono chat-ellipsis",title:t,children:t||"Live"}),e.jsxs("div",{className:"chat-info-mono",children:[Ta(g)," message",g===1?"":"s",b>0&&` · ${b} pinned`]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(pt,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Agent"]}),e.jsx("div",{className:"chat-info-value",children:a||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ss,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Model"]}),e.jsx("div",{className:"chat-mono chat-ellipsis",title:i,children:i||"—"}),k&&e.jsxs("div",{className:"chat-info-mono",children:["provider · ",k]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Tokens"}),e.jsxs("div",{className:"chat-mono",children:[Ta(M)," / ",Ta(A)]}),e.jsx("div",{className:"chat-info-bar","aria-hidden":!0,children:e.jsx("div",{className:"chat-info-bar-fill",style:{width:`${Math.min(100,M/Math.max(1,A)*100)}%`}})})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(_u,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Cost"]}),e.jsxs("div",{className:"chat-mono",children:["$",z.toFixed(4)]}),!v&&e.jsx("div",{className:"chat-info-mono",children:"approx · live from MiniMax"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(pt,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Attached agents"]}),r!=null&&r.length?e.jsx("div",{className:"chat-info-agents",children:r.map(C=>e.jsx("span",{className:"chat-info-agent",children:C.name},C.name))}):e.jsx("div",{className:"chat-info-mono",children:"None attached"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ss,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","MCPs"]}),o!=null&&o.length?e.jsx("div",{className:"chat-info-agents",children:o.map(C=>e.jsx("span",{className:"chat-info-agent",children:C.id},C.id))}):e.jsx("div",{className:"chat-info-mono",children:"No MCPs configured"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Cs,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Slash commands"]}),e.jsxs("div",{className:"chat-info-mono",children:[(l==null?void 0:l.length)??0," available"]})]}),(h||m||d)&&e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Actions"}),e.jsxs("div",{className:"chat-info-actions",children:[h&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:h,disabled:u==null?void 0:u.rename,title:"Rename session",children:[e.jsx(fn,{size:12,"aria-hidden":!0})," Rename"]}),d&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:d,title:"Export transcript",children:[e.jsx(ts,{size:12,"aria-hidden":!0})," Export"]}),m&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm btn-danger",onClick:m,disabled:u==null?void 0:u.delete,title:"Delete session",children:[e.jsx(Fe,{size:12,"aria-hidden":!0})," Delete"]})]})]})]})}function $m({streaming:t,newMessageCount:s,onClick:n,streamingLabel:a="Odin is replying"}){return e.jsx("button",{type:"button",className:`jump-to-latest${t?" is-streaming":""}`,onClick:n,"aria-label":"Jump to latest message",title:"Jump to latest (⌘/Ctrl+End)",children:t?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"jump-dots","aria-hidden":!0,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{children:a}),s>0&&e.jsx("span",{className:"jump-badge jump-badge-live",children:"live"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ua,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Jump to latest"}),s>0&&e.jsxs("span",{className:"jump-badge",children:[s," new"]})]})})}function Em({snapshot:t,settings:s,setActiveTab:n,initialTaskId:a,onClearTaskId:i}){const r=fe(),o=Ze(),l=Su(t,s,a??"");f.useEffect(()=>{l.setToast({error:R=>r.error(R),success:R=>r.success(R),info:R=>r.info(R),warning:R=>r.warning(R)})},[l,r]);const[c,h]=f.useState(""),[m,d]=f.useState(s.defaultAgent||"odin"),[u,p]=f.useState(s.defaultModel||""),[x,v]=f.useState([]),j=f.useRef(null),{allCommands:g,suggestions:b,setQuery:y}=Cu(t);f.useEffect(()=>{y(c)},[c,y]);const w=()=>{var R;return(R=j.current)==null?void 0:R.click()},S=R=>{const B=R.target.files;if(!B)return;const E=[];for(let P=0;P<B.length;P++)E.push(B[P].name);v(P=>{const W=E.filter(V=>!P.includes(V));return[...P,...W]}),j.current&&(j.current.value="")},$=async()=>{const R=c.trim();if(!R)return;h(""),y(""),(await l.onSend(R,m,u,x)).ok&&l.jumpToLatest()},M=async()=>{l.busy.create||await l.onCreateSession()},z=R=>{o.open({title:"Delete message?",children:e.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(U,{variant:"danger",size:"sm",onClick:()=>{o.close(),l.deleteMessage(R)},children:"Delete"})]})})},A=(R,B)=>{let E="";o.open({title:"Rename session",children:e.jsx("input",{id:"rename-session-input",autoFocus:!0,defaultValue:B,"aria-label":"Session title",onChange:P=>{E=P.target.value},onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),o.close(),l.renameSession(R,E).then(W=>{W&&r.success("Renamed.")}))},style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text)",font:"13px/1.4 var(--font-sans)",marginTop:6}}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(U,{variant:"primary",size:"sm",onClick:()=>{o.close(),l.renameSession(R,E)},children:"Save"})]})})},k=(R,B)=>{o.open({title:"Delete session?",children:e.jsxs("p",{style:{margin:0},children:["Delete ",e.jsx("strong",{children:B}),"? Messages on the cline serve will be removed. This cannot be undone."]}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(U,{variant:"danger",size:"sm",onClick:async()=>{o.close(),await l.deleteSession(R)},children:"Delete"})]})})},C=()=>{const R=l.activeSource==="cline"?l.activeClineSessionId:l.sessionId;if(!R)return;const E=(l.activeSource==="cline"?l.clineMessages:l.bizarMessages).map(K=>{const D=K.ts??"",G=(K.role||"unknown").toUpperCase(),ee=K.content||K.message||"";return`[${D}] ${G}: ${ee}`}).join(`
|
|
392
|
-
|
|
393
|
-
`),P=new Blob([E],{type:"text/plain;charset=utf-8"}),W=URL.createObjectURL(P),V=document.createElement("a");V.href=W,V.download=`${R}.txt`,document.body.appendChild(V),V.click(),document.body.removeChild(V),URL.revokeObjectURL(W)},_=f.useMemo(()=>l.sessions.map(R=>l.getSessionDisplay(R)),[l.sessions,l.getSessionDisplay]),L=f.useMemo(()=>l.clineSessions.map(R=>l.getSessionDisplay(R)),[l.clineSessions,l.getSessionDisplay]),N=f.useMemo(()=>{const R=l.activeSource==="cline"?l.activeClineSessionId??"":l.sessionId;return R?_.find(B=>B.id===R)??L.find(B=>B.id===R)??null:null},[l.activeSource,l.activeClineSessionId,l.sessionId,_,L]),T=(()=>{var E;const R=`${m||"Odin"} · ${((E=t.activeProject)==null?void 0:E.name)??"no project"}`,B=(N==null?void 0:N.state)??"idle";return B==="streaming"?`Replying · ${R}`:B==="awaiting"?`Your turn · ${R}`:`${R} · idle`})(),I=l.activeSource==="cline"?"cline":"bizar chat";return e.jsxs("div",{className:"chat-shell",children:[e.jsx(zu,{activeProject:t.activeProject,sessionCount:l.sessions.length,sessionsOpen:!0,infoOpen:!0,onToggleSessions:()=>{},onToggleInfo:()=>{},onOpenOverview:()=>n==null?void 0:n("overview")}),e.jsxs("div",{className:"chat-page",children:[e.jsx(Nm,{sessions:_,clineSessions:L,activeSessionId:l.sessionId,activeClineSessionId:l.activeClineSessionId,activeProject:t.activeProject,creating:l.busy.create,onCreateSession:M,onSelectSession:l.selectBizarSession,onSelectClineSession:R=>l.loadClineSession(R.id),onRenameSession:A,onDeleteSession:R=>{const B=l.sessions.find(E=>E.id===R)??l.clineSessions.find(E=>E.id===R);k(R,(B==null?void 0:B.title)??"")}}),e.jsxs("section",{className:"chat-thread-section",children:[e.jsxs("div",{className:"chat-thread-head",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"chat-thread-title-row",children:[e.jsx("div",{className:"chat-thread-title",children:(N==null?void 0:N.title)??l.sessionId??"New chat"}),e.jsx("span",{className:`chat-source-badge chat-source-${l.activeSource??"none"}`,title:l.activeSource==="cline"?"Messages go to the cline serve child":"Messages go to the local chat store",children:I})]}),e.jsxs("div",{className:`chat-thread-sub chat-muted state-${(N==null?void 0:N.state)??"idle"}`,children:[e.jsx("span",{className:"chat-thread-dot"}),T]}),l.clineError&&e.jsxs("div",{className:"chat-thread-error",role:"alert",children:[e.jsx("p",{className:"chat-error-message",children:l.clineError}),l.clineSuggestion&&e.jsx("p",{className:"chat-error-suggestion",children:l.clineSuggestion}),l.activeClineSessionId&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>l.loadClineSession(l.activeClineSessionId),children:"Retry"})]})]}),e.jsxs("div",{className:"chat-thread-actions",children:[N&&e.jsxs("button",{className:"btn btn-ghost",title:"Rename session",type:"button",disabled:l.busy.rename,onClick:()=>A(N.id,N.title??""),children:[e.jsx(fn,{size:12,"aria-hidden":!0})," ",e.jsx("span",{className:"mono",children:"rename"})]}),N&&e.jsxs("button",{className:"btn btn-ghost btn-danger",title:"Delete session",type:"button",disabled:l.busy.delete,onClick:()=>k(N.id,N.title??N.id),children:[e.jsx(Fe,{size:12,"aria-hidden":!0})," ",e.jsx("span",{className:"mono",children:"delete"})]}),e.jsx("button",{className:"btn btn-ghost",title:"Export transcript",type:"button",onClick:C,children:e.jsx("span",{className:"mono",children:"export"})})]})]}),e.jsx("div",{className:"chat-thread-scroll",ref:l.listRef,onScroll:l.handleScroll,role:"log","aria-live":"polite","aria-relevant":"additions","aria-label":"Chat message thread",children:e.jsx(Mu,{messages:l.activeSource==="cline"?l.clineMessages:l.bizarMessages,loading:l.loading,activeProject:t.activeProject,sessionId:l.activeSource==="cline"?l.activeClineSessionId??l.sessionId:l.sessionId,pinned:l.pinned,activeSource:l.activeSource,onPickSuggestion:R=>h(R),onCopy:R=>l.copyMessage(R),onDelete:z,onTogglePin:l.togglePin,onRegenerate:l.onRegenerate})}),!l.stickToBottom&&e.jsx($m,{streaming:(N==null?void 0:N.state)==="streaming",newMessageCount:l.newMessageCount,onClick:l.jumpToLatest}),e.jsx(Sm,{agent:m,setAgent:d,model:u,setModel:p,text:c,setText:h,sending:l.sending,activeSource:l.activeSource,onSend:$,attachments:x,setAttachments:v,suggestions:b,onPickSuggestion:R=>h(`${R.split(" ")[0]} `),agents:t.agents||[],onAttach:w}),e.jsx("input",{ref:j,type:"file",multiple:!0,style:{display:"none"},onChange:S,"aria-label":"Attach files to message",tabIndex:-1})]}),e.jsx(Mm,{sessionId:l.activeSource==="cline"?l.activeClineSessionId??l.sessionId:l.sessionId,messages:l.activeSource==="cline"?l.clineMessages:l.bizarMessages,pinned:l.pinned,agent:m,model:u,agents:t.agents||[],mcps:t.mcps||[],allCommands:g,activeSource:l.activeSource,onRename:()=>{N&&A(N.id,N.title??"")},onDelete:()=>{N&&k(N.id,N.title??N.id)},onExport:C,busy:l.busy})]})]})}const pr=["bash","read","edit","write","webfetch","websearch","task","glob","grep"],xr=["anthropic/claude-3-5-sonnet","anthropic/claude-3-5-haiku","openai/gpt-4o","openai/gpt-4o-mini","openrouter/minimax/minimax-m3","openrouter/minimax/minimax-m2.7"],gr="#8b5cf6",Bn=[{id:"reasoning",label:"Reasoning",variant:"accent"},{id:"code",label:"Code",variant:"info"},{id:"design",label:"Design",variant:"success"},{id:"planning",label:"Planning",variant:"warning"},{id:"gitops",label:"GitOps",variant:"danger"},{id:"analysis",label:"Analysis",variant:"neutral"}];function yr(t){if(!t)return{label:"—",variant:"neutral"};const s=Bn.find(n=>n.id===t);return s?{label:s.label,variant:s.variant}:{label:t,variant:"neutral"}}function Aa(t){if(t.isStuck)return"stuck";const s=t.status||"idle";return s==="working"?"working":s==="error"?"error":"idle"}function Nn(t){return t==="stuck"?"stuck":t}function vr(t){return t==="working"?"info":t==="error"||t==="stuck"?"danger":"neutral"}function Fs(t){return t.lastSeenAt??t.lastSeen}function _m(t,s=4){if(!t||t.length===0)return"—";const n=t.slice(0,s).join(", ");return t.length>s?`${n} +${t.length-s}`:n}function Tm({snapshot:t,refreshSnapshot:s}){const n=fe(),a=Ze(),[i,r]=f.useState(t.agents||[]),[o,l]=f.useState(!t.agents),[c,h]=f.useState(""),[m,d]=f.useState(""),[u,p]=f.useState(null);f.useEffect(()=>{r(t.agents||[]),l(!t.agents)},[t.agents]),f.useEffect(()=>{u&&!i.some(k=>k.name===u)&&p(null)},[i,u]);const x=async()=>{try{const k=await H.get("/agents");r(k.agents||[])}catch(k){n.error(`Agents load failed: ${k.message}`)}finally{l(!1)}},v=f.useMemo(()=>{let k=[...i];if(c&&(k=k.filter(C=>c==="__none__"?!C.category:(C.category||"")===c)),m){const C=m.toLowerCase();k=k.filter(_=>_.name.toLowerCase().includes(C)||(_.description||"").toLowerCase().includes(C)||(_.tags||[]).some(L=>L.toLowerCase().includes(C)))}return k.sort((C,_)=>C.name.localeCompare(_.name))},[i,c,m]),j=v.some(k=>typeof Fs(k)=="number"),g=f.useMemo(()=>v.find(k=>k.name===u)||null,[v,u]),b=()=>{let k=null,C=null,_=null,L=null,N=null,T=null,I=null,R=null,B=null;a.open({title:"New agent",width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-name",children:"Name (a-z, 0-9, dashes)"}),e.jsx("input",{id:"agent-new-name",ref:E=>k=E,className:"input",type:"text",placeholder:"my-agent",autoFocus:!0}),e.jsx("label",{className:"field-label",htmlFor:"agent-new-desc",children:"Description"}),e.jsx("input",{id:"agent-new-desc",ref:E=>{C=E},className:"input",type:"text",placeholder:"What does this agent do?"}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-model",children:"Model"}),e.jsxs("select",{id:"agent-new-model",ref:E=>_=E,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(provider default)"}),xr.map(E=>e.jsx("option",{value:E,children:E},E))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-mode",children:"Mode"}),e.jsxs("select",{id:"agent-new-mode",ref:E=>L=E,className:"select",defaultValue:"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-color",children:"Color"}),e.jsx("input",{id:"agent-new-color",ref:E=>N=E,className:"input",type:"color",defaultValue:gr})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-category",children:"Category"}),e.jsxs("select",{id:"agent-new-category",ref:E=>B=E,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(none)"}),Bn.map(E=>e.jsx("option",{value:E.id,children:E.label},E.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-tags",children:"Tags (comma-separated)"}),e.jsx("input",{id:"agent-new-tags",ref:E=>R=E,className:"input",type:"text",placeholder:"reasoning, code, planning"})]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"field-label",style:{padding:0},children:"Tools"}),e.jsx("div",{ref:E=>I=E,className:"agent-tools",children:pr.map(E=>e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:E,"aria-label":E}),e.jsx("span",{children:E})]},E))})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-new-prompt",children:"System prompt"}),e.jsx("textarea",{id:"agent-new-prompt",ref:E=>T=E,className:"textarea",rows:6,placeholder:"You are a..."})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:async()=>{const E=((k==null?void 0:k.value)||"").trim();if(!/^[a-z0-9][a-z0-9-]{0,63}$/i.test(E)){n.warning("Invalid name (a-z, 0-9, dashes).");return}const P=[];I&&I.querySelectorAll('input[type="checkbox"]:checked').forEach(V=>{P.push(V.value)});const W=((R==null?void 0:R.value)||"").split(",").map(V=>V.trim()).filter(Boolean);try{const V=await H.post("/agents",{name:E,description:((C==null?void 0:C.value)||"").trim(),model:(_==null?void 0:_.value)||"",mode:(L==null?void 0:L.value)||"subagent",color:(N==null?void 0:N.value)||"",tools:P,tags:W,category:(B==null?void 0:B.value)||"",prompt:(T==null?void 0:T.value)||""});r(K=>[...K,V]),p(V.name),n.success("Agent created."),a.close(),await s()}catch(V){n.error(`Create failed: ${V.message}`)}},children:[e.jsx(bs,{size:12})," Create"]})]})})},y=async k=>{let C=null,_=null,L=null,N=null,T=null,I=null,R=null,B=null;try{const E=await H.get(`/agents/${encodeURIComponent(k.name)}`);a.open({title:`Edit ${k.name}`,width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsxs("div",{className:"muted",children:["File: ",e.jsx("code",{children:E.path})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-edit-desc",children:"Description"}),e.jsx("input",{id:"agent-edit-desc",ref:P=>{C=P},className:"input",type:"text",defaultValue:E.description}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-model",children:"Model"}),e.jsxs("select",{id:"agent-edit-model",ref:P=>_=P,className:"select",defaultValue:E.model,children:[e.jsx("option",{value:"",children:"(provider default)"}),xr.map(P=>e.jsx("option",{value:P,children:P},P))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-mode",children:"Mode"}),e.jsxs("select",{id:"agent-edit-mode",ref:P=>L=P,className:"select",defaultValue:E.mode||"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-color",children:"Color"}),e.jsx("input",{id:"agent-edit-color",ref:P=>N=P,className:"input",type:"color",defaultValue:E.color||gr})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-category",children:"Category"}),e.jsxs("select",{id:"agent-edit-category",ref:P=>B=P,className:"select",defaultValue:E.category||"",children:[e.jsx("option",{value:"",children:"(none)"}),Bn.map(P=>e.jsx("option",{value:P.id,children:P.label},P.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-tags",children:"Tags (comma-separated)"}),e.jsx("input",{id:"agent-edit-tags",ref:P=>R=P,className:"input",type:"text",defaultValue:(E.tags||[]).join(", ")})]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"field-label",style:{padding:0},children:"Tools"}),e.jsx("div",{ref:P=>I=P,className:"agent-tools",children:pr.map(P=>{var W;return e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:P,"aria-label":P,defaultChecked:(W=E.tools)==null?void 0:W.includes(P)}),e.jsx("span",{children:P})]},P)})})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-edit-prompt",children:"System prompt"}),e.jsx("textarea",{id:"agent-edit-prompt",ref:P=>T=P,className:"textarea",rows:8,defaultValue:E.prompt||""})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:async()=>{const P=[];I&&I.querySelectorAll('input[type="checkbox"]:checked').forEach(V=>{P.push(V.value)});const W=((R==null?void 0:R.value)||"").split(",").map(V=>V.trim()).filter(Boolean);try{const V=await H.put(`/agents/${encodeURIComponent(k.name)}`,{description:((C==null?void 0:C.value)||"").trim(),model:(_==null?void 0:_.value)||"",mode:(L==null?void 0:L.value)||"subagent",color:(N==null?void 0:N.value)||"",tools:P,tags:W,category:(B==null?void 0:B.value)||"",prompt:(T==null?void 0:T.value)||""});r(K=>K.map(D=>D.name===k.name?V:D)),n.success("Agent saved."),a.close(),await s()}catch(V){n.error(`Save failed: ${V.message}`)}},children:[e.jsx(bs,{size:12})," Save"]})]})})}catch(E){n.error(`Load failed: ${E.message}`)}},w=async k=>{if(confirm(`Delete agent "${k.name}"? This removes ${k.path}.`))try{await H.del(`/agents/${encodeURIComponent(k.name)}`),r(C=>C.filter(_=>_.name!==k.name)),n.success("Agent deleted.")}catch(C){n.error(`Delete failed: ${C.message}`)}},S=k=>{let C=null;a.open({title:`Invoke ${k.name}`,children:e.jsxs("div",{className:"invoke-form",children:[e.jsxs("p",{className:"muted invoke-form-meta mono",children:[k.model||"—"," · ",k.path]}),e.jsx("p",{className:"invoke-form-desc",children:k.description}),e.jsx("label",{className:"field-label",htmlFor:"invoke-prompt",children:"Prompt"}),e.jsx("textarea",{ref:_=>C=_,id:"invoke-prompt",className:"textarea",rows:5,placeholder:"What should this agent do?",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:async()=>{const _=((C==null?void 0:C.value)||"").trim();if(!_){n.warning("Prompt is required.");return}try{await H.post(`/agents/${encodeURIComponent(k.name)}/invoke`,{prompt:_}),n.success(`Invoked ${k.name}.`),a.close()}catch(L){n.error(`Invoke failed: ${L.message}`)}},children:[e.jsx(ws,{size:14})," Invoke"]})]})})},$=async k=>{try{const C=await H.post(`/agents/${encodeURIComponent(k.name)}/restart`);r(_=>_.map(L=>L.name===k.name?C:L)),n.success(`${k.name} restarted.`)}catch(C){n.error(`Restart failed: ${C.message}`)}},M=[{key:"name",header:"Name",sortable:!0,accessor:k=>k.name,render:k=>e.jsxs("span",{className:"agents-name-cell",children:[e.jsx("span",{className:pe("agents-name-cell__swatch",!k.color&&"agents-name-cell__swatch--empty"),style:k.color?{background:k.color}:void 0,"aria-hidden":"true"}),k.name]})},{key:"status",header:"Status",sortable:!0,accessor:k=>Aa(k),render:k=>{const C=Aa(k);return e.jsxs("span",{className:"agents-status-cell",children:[e.jsx(sn,{variant:vr(C),size:"sm",pulse:C==="stuck",label:Nn(C)}),e.jsx("span",{className:pe("agents-status-cell__label",C==="stuck"&&"agents-status-cell__label--stuck"),children:Nn(C)})]})}},{key:"category",header:"Category",sortable:!0,accessor:k=>k.category||"",render:k=>{const C=yr(k.category);return k.category?e.jsx("span",{className:"agents-category-cell",children:e.jsx(ht,{variant:C.variant,size:"sm",children:C.label})}):e.jsx("span",{className:"muted",children:"—"})}},{key:"tags",header:"Tags",accessor:k=>(k.tags||[]).join(","),render:k=>e.jsx("span",{className:"agents-tags-cell",title:(k.tags||[]).join(", "),children:_m(k.tags)})}];j&&M.push({key:"lastSeen",header:"Last seen",sortable:!0,accessor:k=>Fs(k)||0,render:k=>{const C=Fs(k);return e.jsx("span",{className:"muted tabular-nums",children:C?He(C):"—"})}});function z(){var T;if(!g)return e.jsxs("div",{className:"agents-detail__placeholder",children:[e.jsx("span",{className:"agents-detail__placeholder-icon","aria-hidden":"true",children:e.jsx(pt,{size:28})}),e.jsx("span",{className:"agents-detail__placeholder-title",children:"No agent selected"}),e.jsx("span",{children:"Pick a row from the table to see its metadata, actions, and prompt."})]});const k=g,C=Aa(k),_=yr(k.category),L=k.isStuck||k.status==="working"||k.status==="error",N=[{key:"status",label:"Status",value:e.jsxs("span",{className:"agents-status-cell",children:[e.jsx(sn,{variant:vr(C),size:"sm",pulse:C==="stuck",label:Nn(C)}),e.jsx("span",{className:"agents-status-cell__label",children:Nn(C)})]})},{key:"category",label:"Category",value:k.category?e.jsx(ht,{variant:_.variant,size:"sm",children:_.label}):e.jsx("span",{className:"muted",children:"—"})},{key:"tags",label:"Tags",value:k.tags&&k.tags.length>0?e.jsx(De,{gap:1,className:"agents-detail__tags",children:k.tags.map(I=>e.jsx(ht,{variant:"neutral",size:"sm",children:I},I))}):e.jsx("span",{className:"muted",children:"—"})},{key:"tools",label:"Tools",value:k.tools&&k.tools.length>0?e.jsx(De,{gap:1,className:"agents-detail__tools",children:k.tools.map(I=>e.jsx(ht,{variant:"info",size:"sm",children:I},I))}):e.jsx("span",{className:"muted",children:"—"})},{key:"model",label:"Model",mono:!0,copyable:!0,value:k.model||"—"},{key:"mode",label:"Mode",value:k.mode||"subagent"},{key:"color",label:"Color",value:k.color?e.jsxs(De,{gap:2,align:"center",children:[e.jsx("span",{className:"agents-detail__name-swatch",style:{background:k.color},"aria-hidden":"true"}),e.jsx("code",{className:"mono",children:k.color})]}):e.jsx("span",{className:"muted",children:"—"})},{key:"description",label:"Description",value:k.description?e.jsx("div",{className:"agents-detail__description",children:Oo(k.description,600)}):e.jsx("span",{className:"muted",children:"—"})}];return typeof Fs(k)=="number"&&N.push({key:"lastSeen",label:"Last seen",mono:!0,value:He(Fs(k))}),(T=k.lastError)!=null&&T.message&&N.push({key:"lastError",label:"Last error",value:e.jsx("div",{className:"agents-detail__error",children:k.lastError.message})}),e.jsxs(st,{gap:4,className:"agents-detail__meta",children:[e.jsx(ll,{items:N,orientation:"horizontal"}),e.jsxs(Ie,{className:"agents-detail__prompt",children:[e.jsx("span",{className:"agents-detail__prompt-label",children:"System prompt"}),k.prompt?e.jsx("pre",{className:"agents-detail__prompt-body",children:k.prompt}):e.jsx("span",{className:"agents-detail__prompt-empty",children:"No prompt configured."})]}),e.jsxs(De,{gap:2,wrap:!0,className:"agents-detail__actions",children:[e.jsx(nt,{variant:"secondary",size:"sm",icon:e.jsx(fn,{size:12}),onClick:()=>y(k),"aria-label":`Edit ${k.name}`,"data-testid":`agents-detail-edit-${k.name}`,children:"Edit"}),e.jsx(nt,{variant:"secondary",size:"sm",icon:e.jsx(ws,{size:12}),onClick:()=>S(k),"aria-label":`Invoke ${k.name}`,"data-testid":`agents-detail-invoke-${k.name}`,children:"Invoke"}),L&&e.jsx(nt,{variant:"ghost",size:"sm",icon:e.jsx(da,{size:12}),onClick:()=>$(k),"aria-label":`Restart ${k.name}`,"data-testid":`agents-detail-restart-${k.name}`,children:"Restart"}),e.jsx(nt,{variant:"danger",size:"sm",icon:e.jsx(Fe,{size:12}),onClick:()=>w(k),"aria-label":`Delete ${k.name}`,"data-testid":`agents-detail-delete-${k.name}`,children:"Delete"})]}),k.isStuck&&e.jsxs(De,{gap:2,align:"center",className:"agents-detail__error",children:[e.jsx(Ni,{size:12}),e.jsx("span",{children:"Agent is stuck — restart to reset state."})]})]})}const A=[{value:"",label:"All categories"},...Bn.map(k=>({value:k.id,label:k.label})),{value:"__none__",label:"(no category)"}];return e.jsxs("div",{className:"agents-redesign","data-testid":"agents-view",children:[e.jsxs("header",{className:"agents-redesign__header",children:[e.jsxs("div",{className:"agents-redesign__header-text",children:[e.jsxs("h2",{className:"agents-redesign__title",children:[e.jsx(pt,{size:18,"aria-hidden":"true"}),e.jsx("span",{children:"Agents"}),e.jsxs("span",{className:"agents-redesign__title-count","data-testid":"agents-count",children:["(",v.length,")"]})]}),e.jsxs("p",{className:"agents-redesign__subtitle",children:["The Norse pantheon — pick a row to inspect, ",e.jsx("kbd",{children:"Edit"})," to modify, ",e.jsx("kbd",{children:"Invoke"})," to dispatch."]})]}),e.jsxs("div",{className:"agents-redesign__controls",children:[e.jsxs("span",{className:"agents-redesign__control",style:{minWidth:180},children:[e.jsx("label",{htmlFor:"agents-search",className:"vh",children:"Search agents"}),e.jsx("input",{id:"agents-search",className:"input",type:"search",placeholder:"Search name, description, tag…",value:m,onChange:k=>d(k.target.value),"aria-label":"Search agents","data-testid":"agents-search"})]}),e.jsxs("span",{className:"agents-redesign__control",style:{minWidth:180},children:[e.jsx("label",{htmlFor:"agents-category-filter",className:"vh",children:"Filter by category"}),e.jsx("select",{id:"agents-category-filter",className:"select",value:c,onChange:k=>h(k.target.value),"data-testid":"agents-category-filter",children:A.map(k=>e.jsx("option",{value:k.value,children:k.label},k.value||"__all__"))})]}),e.jsx(nt,{variant:"ghost",size:"sm",icon:e.jsx(xe,{size:12}),onClick:x,"aria-label":"Refresh","data-testid":"agents-refresh",children:"Refresh"}),e.jsx(nt,{variant:"primary",size:"sm",icon:e.jsx(qe,{size:12}),onClick:b,"aria-label":"New agent","data-testid":"agents-new",children:"New agent"})]})]}),e.jsxs("div",{className:"agents-redesign__body",children:[e.jsx(Ie,{className:"agents-roster",children:o?e.jsx(Ri,{label:"Loading agents…",rows:3}):v.length===0?e.jsx(On,{icon:e.jsx(pt,{size:32}),title:"No agents found",description:i.length===0?"Run bizar in the terminal to install Bizar.":"No agents match the current filters — try clearing the search or category.",action:i.length===0?void 0:{label:"Clear filters",onClick:()=>{d(""),h("")}}}):e.jsx("div",{className:"agents-roster__table","data-testid":"agents-table",children:e.jsx(em,{columns:M,data:v,rowKey:k=>k.name,compact:!0,onRowClick:k=>p(k.name)})})}),e.jsx(wt,{title:g?e.jsxs("span",{className:"agents-detail__name",children:[e.jsx("span",{className:pe("agents-detail__name-swatch",!g.color&&"agents-detail__name-swatch--empty"),style:g.color?{background:g.color}:void 0,"aria-hidden":"true"}),e.jsx("span",{children:g.name})]}):"Agent detail",description:g?g.path:"Select an agent from the roster to see its metadata.",padding:4,variant:"outlined",className:"agents-detail",children:z()})]})]})}function Am({id:t,children:s}){return e.jsx("div",{id:t,"data-block-id":t,className:se("glyph-richtext"),style:cl,children:e.jsx(Vo,{remarkPlugins:[Uo],children:s})})}const Rm={info:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",border:"var(--info)",fg:"var(--info)",icon:Si,label:"Note"},warn:{bg:"var(--warning-soft, rgba(251, 191, 36, 0.15))",border:"var(--warning)",fg:"var(--warning)",icon:Ue,label:"Warning"},success:{bg:"var(--success-soft, rgba(52, 211, 153, 0.15))",border:"var(--success)",fg:"var(--success)",icon:Ke,label:"Success"},danger:{bg:"var(--error-soft, rgba(248, 113, 113, 0.12))",border:"var(--error)",fg:"var(--error)",icon:ls,label:"Danger"}};function Im({id:t,tone:s="info",children:n}){const a=Rm[s],i=a.icon;return e.jsxs("div",{id:t,"data-block-id":t,className:se("glyph-callout",`glyph-callout-${s}`),style:{display:"flex",gap:12,padding:"12px 16px",margin:"12px 0",borderLeft:`3px solid ${a.border}`,background:a.bg,borderRadius:8,color:"var(--text)"},role:s==="danger"||s==="warn"?"alert":void 0,children:[e.jsx("div",{style:{flexShrink:0,color:a.fg,paddingTop:2},children:e.jsx(i,{size:18})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,color:a.fg,marginBottom:4},children:a.label}),e.jsx("div",{className:"glyph-richtext",style:{...cl,fontSize:14},children:e.jsx(Vo,{remarkPlugins:[Uo],children:n})})]})]})}function Lm({id:t,items:s}){return e.jsx("ul",{id:t,"data-block-id":t,className:"glyph-checklist",style:{listStyle:"none",padding:0,margin:"12px 0",display:"flex",flexDirection:"column",gap:6},children:s.map(n=>e.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"6px 10px",borderRadius:6,background:"var(--bg-elev)",border:"1px solid var(--border)",fontSize:14},children:[e.jsx("span",{"aria-hidden":!0,style:{flexShrink:0,marginTop:1,width:16,height:16,borderRadius:4,border:`1.5px solid ${n.checked?"var(--success)":"var(--border-strong)"}`,background:n.checked?"var(--success)":"transparent",color:"var(--bg)",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:n.checked?e.jsx(Ht,{size:12,strokeWidth:3}):null}),e.jsx("span",{style:{color:n.checked?"var(--text-dim)":"var(--text)",textDecoration:n.checked?"line-through":"none",wordBreak:"break-word"},children:n.label})]},n.id))})}function Pm({id:t,columns:s,rows:n}){return e.jsx("div",{id:t,"data-block-id":t,className:"glyph-table-wrap",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"auto",background:"var(--bg-elev)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{children:s.map((a,i)=>e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",borderBottom:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text-dim)",fontWeight:600,fontSize:12,textTransform:"uppercase",letterSpacing:.3,whiteSpace:"nowrap"},children:a},i))})}),e.jsx("tbody",{children:n.map((a,i)=>e.jsx("tr",{style:{borderTop:i===0?"none":"1px solid var(--border)"},children:a.map((r,o)=>e.jsx("td",{style:{padding:"8px 12px",color:"var(--text)",verticalAlign:"top",wordBreak:"break-word"},children:r},o))},i))})]})})}function Dm({id:t,tabs:s}){var r;const[n,a]=f.useState(((r=s[0])==null?void 0:r.id)??""),i=f.useMemo(()=>s.find(o=>o.id===n)??s[0],[s,n]);return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-codetabs",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[e.jsx("div",{role:"tablist",style:{display:"flex",gap:2,padding:4,background:"var(--bg)",borderBottom:"1px solid var(--border)",overflowX:"auto"},children:s.map(o=>{const l=o.id===(i==null?void 0:i.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>a(o.id),style:{padding:"6px 12px",fontSize:12,fontFamily:"var(--font-mono)",borderRadius:6,border:"none",cursor:"pointer",background:l?"var(--bg-elev)":"transparent",color:l?"var(--text-strong)":"var(--text-dim)",boxShadow:l?"0 0 0 1px var(--border)":"none",whiteSpace:"nowrap"},children:[e.jsx("span",{children:o.label}),o.language&&e.jsx("span",{style:{marginLeft:6,color:"var(--text-dim)",fontSize:11},children:o.language})]},o.id)})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:{margin:0,padding:14,overflowX:"auto",fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},children:e.jsx("code",{children:i.code})}),i.caption&&e.jsx("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",background:"var(--bg)"},children:i.caption})]})]})}function Fm({id:t,title:s,question:n,options:a}){return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-decision",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)"},children:[s&&e.jsx("h3",{style:{margin:0,marginBottom:4,fontSize:15,fontWeight:600,color:"var(--text-strong)"},children:s}),n&&e.jsx("p",{style:{margin:0,marginBottom:12,fontSize:13,color:"var(--text-dim)"},children:n}),e.jsx("div",{style:{display:"grid",gap:10,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:a.map(i=>{const r=!!i.recommended;return e.jsxs("div",{style:{position:"relative",padding:12,borderRadius:8,border:r?"2px solid var(--success)":"1px solid var(--border)",background:r?"var(--success-soft)":"var(--bg)"},children:[r&&e.jsx("span",{style:{position:"absolute",top:-10,right:10,padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--bg)",background:"var(--success)",borderRadius:999},children:"Recommended"}),e.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-strong)",marginBottom:4},children:i.label}),e.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:i.detail})]},i.id)})})]})}function Om({id:t,questions:s}){const[n,a]=f.useState({});function i(r,o){a(l=>({...l,[r]:o}))}return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-openquestions",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",display:"flex",flexDirection:"column",gap:14},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-strong)"},children:"Open questions"}),s.map(r=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{htmlFor:`oq-${r.id}`,style:{fontSize:13,color:"var(--text)",fontWeight:500},children:r.label}),r.kind==="choice"&&e.jsxs("select",{id:`oq-${r.id}`,value:n[r.id]??"",onChange:o=>i(r.id,o.target.value),style:jr,children:[e.jsx("option",{value:"",children:"— select —"}),(r.options??[]).map(o=>e.jsx("option",{value:o,children:o},o))]}),r.kind==="text"&&e.jsx("input",{id:`oq-${r.id}`,type:"text",value:n[r.id]??"",onChange:o=>i(r.id,o.target.value),style:jr}),r.kind==="multi"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(r.options??[]).map(o=>{const l=n[r.id]??[],c=l.includes(o);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:c,onChange:()=>{const h=c?l.filter(m=>m!==o):[...l,o];i(r.id,h)}}),e.jsx("span",{children:o})]},o)})})]},r.id))]})}const jr={padding:"6px 10px",fontSize:13,borderRadius:6,border:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text)",fontFamily:"inherit"},Bm={added:{bg:"var(--success-soft)",fg:"var(--success)",label:"A"},modified:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",fg:"var(--info)",label:"M"},removed:{bg:"var(--error-soft)",fg:"var(--error)",label:"D"},renamed:{bg:"rgba(139, 92, 246, 0.15)",fg:"var(--accent)",label:"R"}};function Hm({id:t,title:s,entries:n}){return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-filetree",style:{margin:"12px 0",padding:s?14:8,border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-elev)"},children:[s&&e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4,marginBottom:8},children:s}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:2},children:n.map(a=>{const i=Bm[a.change];return e.jsxs("li",{style:{display:"flex",alignItems:"center",gap:10,padding:"5px 8px",borderRadius:5,fontSize:13},children:[e.jsx("span",{"aria-label":a.change,title:a.change,style:{flexShrink:0,width:22,height:18,borderRadius:4,background:i.bg,color:i.fg,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,fontFamily:"var(--font-mono)"},children:i.label}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)",wordBreak:"break-all",flex:1},children:a.path}),a.note&&e.jsx("span",{style:{fontSize:12,color:"var(--text-dim)"},children:a.note})]},a.path)})})]})}function Vm({id:t,filename:s,language:n,mode:a="unified",before:i,after:r}){const o=i.split(`
|
|
394
|
-
`),l=r.split(`
|
|
395
|
-
`),c=e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--bg)",borderBottom:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:[e.jsx(Fu,{size:14}),e.jsx("span",{style:{color:"var(--text)"},children:s??"diff"}),n&&e.jsxs("span",{children:["· ",n]}),e.jsx("span",{style:{marginLeft:"auto",textTransform:"uppercase",letterSpacing:.3},children:a})]}),h={margin:0,padding:0,fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},m=(d,u,p)=>{const x={del:"var(--error-soft)",add:"var(--success-soft)",ctx:"transparent"},v={del:"var(--error)",add:"var(--success)",ctx:"var(--text-dim)"};return e.jsxs("div",{style:{display:"flex",padding:"0 12px",background:x[p]},children:[e.jsx("span",{style:{width:18,color:v[p],userSelect:"none",flexShrink:0},children:d}),e.jsx("span",{style:{whiteSpace:"pre",flex:1,overflowX:"auto"},children:u||" "})]})};return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-diff",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[c,a==="unified"?e.jsxs("pre",{style:h,children:[o.map((d,u)=>e.jsx("div",{children:m("-",d,"del")},`b${u}`)),l.map((d,u)=>e.jsx("div",{children:m("+",d,"add")},`a${u}`))]}):e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr"},children:[e.jsx("pre",{style:{...h,borderRight:"1px solid var(--border)"},children:o.map((d,u)=>e.jsx("div",{children:m("-",d,"del")},u))}),e.jsx("pre",{style:h,children:l.map((d,u)=>e.jsx("div",{children:m("+",d,"add")},u))})]})]})}const Um={up:{fg:"var(--success)",Icon:ct,label:"trending up"},down:{fg:"var(--error)",Icon:ct,label:"trending down"},flat:{fg:"var(--text-dim)",Icon:el,label:"flat"}};function qm({id:t,label:s,value:n,trend:a,hint:i}){const r=a?Um[a]:null;return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-stat",style:{padding:14,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",display:"flex",flexDirection:"column",gap:4,minWidth:140},children:[e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4},children:s}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[e.jsx("span",{style:{fontSize:24,fontWeight:700,color:"var(--text-strong)"},children:n}),r&&e.jsx("span",{"aria-label":r.label,style:{display:"inline-flex",alignItems:"center",color:r.fg,transform:r.Icon===ct&&a==="up"?"rotate(180deg)":void 0},children:e.jsx(r.Icon,{size:14})})]}),i&&e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)"},children:i})]})}const Wm={task:{stroke:"var(--info)",fill:"var(--bg-elev)",fg:"var(--text)"},decision:{stroke:"var(--warning)",fill:"var(--bg-elev)",fg:"var(--text)"},note:{stroke:"var(--border-strong)",fill:"var(--bg)",fg:"var(--text-dim)"}},et=160,ot=56,cs=60,ds=80;function Gm({id:t,steps:s,connections:n=[]}){if(s.length===0)return e.jsx("div",{id:t,"data-block-id":t,className:"glyph-workflow",children:e.jsx(Ym,{id:t})});const a=new Map(s.map(m=>[m.id,m])),i=Xm(s),r=Math.max(...i.map(m=>m.col))+1,o=Math.max(...i.map(m=>m.row))+1,l=r*(et+cs)+cs,c=o*(ot+ds)+ds;function h(m){if(!a.get(m))return null;const u=i.find(p=>p.id===m);return u?{x:cs+u.col*(et+cs)+et/2,y:ds+u.row*(ot+ds)+ot/2}:null}return e.jsx("div",{id:t,"data-block-id":t,className:"glyph-workflow",style:{margin:"12px 0",padding:12,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",overflow:"auto"},children:e.jsxs("svg",{role:"img","aria-label":"Workflow diagram",width:l,height:c,style:{display:"block",maxWidth:"100%"},children:[e.jsx("defs",{children:e.jsx("marker",{id:`arrow-${t}`,viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:e.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--text-dim)"})})}),n.map((m,d)=>{const u=h(m.from),p=h(m.to);if(!u||!p)return null;const x=p.x-u.x,v=p.y-u.y,j=x>=0?u.x+et/2:u.x-et/2,g=x>=0?p.x-et/2:p.x+et/2,b=v>=0?u.y+ot/2:u.y-ot/2,y=v>=0?p.y-ot/2:p.y+ot/2,w=(j+g)/2,S=(b+y)/2;return e.jsxs("g",{children:[e.jsx("line",{x1:j,y1:b,x2:g,y2:y,stroke:"var(--text-dim)",strokeWidth:1.5,markerEnd:`url(#arrow-${t})`}),m.label&&e.jsx("text",{x:w,y:S-4,fontSize:10,fill:"var(--text-dim)",textAnchor:"middle",fontFamily:"var(--font-mono)",children:m.label})]},d)}),s.map(m=>{const d=i.find(j=>j.id===m.id);if(!d)return null;const u=cs+d.col*(et+cs),p=ds+d.row*(ot+ds),x=Wm[m.type];if(m.type==="decision"){const j=u+et/2,g=p+ot/2,b=[[j,p],[u+et,g],[j,p+ot],[u,g]].map(y=>y.join(",")).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:b,fill:x.fill,stroke:x.stroke,strokeWidth:2}),e.jsx("foreignObject",{x:u+8,y:g-14,width:et-16,height:28,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,fontSize:12,color:x.fg,textAlign:"center",lineHeight:1.2,fontStyle:"italic",height:"100%"},children:[e.jsx(Lu,{size:11}),m.label]})})]},m.id)}const v=m.type==="note";return e.jsxs("g",{children:[e.jsx("rect",{x:u,y:p,width:et,height:ot,rx:8,fill:x.fill,stroke:x.stroke,strokeWidth:v?1:2,strokeDasharray:v?"4 3":void 0}),e.jsx("foreignObject",{x:u+6,y:p+6,width:et-12,height:ot-12,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:12,color:x.fg,textAlign:"center",lineHeight:1.25,fontStyle:v?"italic":"normal",height:"100%"},children:[v&&e.jsx(nu,{size:11}),m.label]})})]},m.id)})]})})}function Ym({id:t}){return e.jsx("div",{id:t,style:{padding:20,textAlign:"center",color:"var(--text-dim)",fontSize:13},children:"No workflow steps."})}function Xm(t){return t.length===0?[]:t.map((s,n)=>({id:s.id,col:n,row:0}))}const cl={fontSize:14,lineHeight:1.6,color:"var(--text)"};function Km({id:t,title:s,x:n,y:a,w:i,h:r,html:o}){return e.jsxs("figure",{id:t,"data-block-id":t,className:"glyph-mockup",style:{width:i,minHeight:r},children:[s&&e.jsx("figcaption",{className:"glyph-mockup-title",children:s}),e.jsxs("div",{className:"glyph-mockup-frame",children:[e.jsxs("div",{className:"glyph-mockup-chrome",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("div",{className:"glyph-mockup-body",dangerouslySetInnerHTML:{__html:o}})]})]})}class Zm extends rt.Component{constructor(){super(...arguments);Ps(this,"state",{err:null})}static getDerivedStateFromError(n){return{err:n}}componentDidCatch(n,a){try{this.props.onError(this.props.blockId,this.props.blockType,n,a)}catch{}}render(){return this.state.err?e.jsxs("div",{className:"glyph-block-error",role:"alert",style:{border:"1px solid var(--error, #f85149)",background:"rgba(248, 81, 73, 0.06)",borderRadius:8,padding:"12px 14px",margin:"12px 0",color:"var(--text)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,lineHeight:1.55},children:[e.jsxs("strong",{style:{color:"var(--error, #f85149)",fontFamily:"var(--font-sans, system-ui, sans-serif)",display:"block",marginBottom:4},children:[this.props.blockType," block crashed"]}),e.jsxs("div",{style:{color:"var(--text-muted)",marginBottom:6},children:["block id: ",e.jsx("code",{children:this.props.blockId})]}),e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word",color:"var(--text)"},children:this.state.err.message})]}):this.props.children}}function Qm(t){const s=t.data??{};switch(t.type){case"RichText":return{ok:!0};case"Callout":return{ok:!0};case"Checklist":return Array.isArray(s.items)?{ok:!0}:{ok:!1,error:"Checklist requires data.items to be an array"};case"Table":return Array.isArray(s.columns)?Array.isArray(s.rows)?s.rows.length>0&&!Array.isArray(s.rows[0])?{ok:!1,error:"Table.data.rows[0] must be an array (cell array)"}:{ok:!0}:{ok:!1,error:"Table requires data.rows to be an array"}:{ok:!1,error:"Table requires data.columns to be an array"};case"CodeTabs":return Array.isArray(s.tabs)?{ok:!0}:{ok:!1,error:"CodeTabs requires data.tabs to be an array"};case"Decision":return Array.isArray(s.options)?{ok:!0}:{ok:!1,error:"Decision requires data.options to be an array"};case"OpenQuestions":return Array.isArray(s.questions)?{ok:!0}:{ok:!1,error:"OpenQuestions requires data.questions to be an array"};case"FileTree":if(!Array.isArray(s.entries))return{ok:!1,error:"FileTree requires data.entries to be an array"};for(const n of s.entries)if(n===null||typeof n!="object"||Array.isArray(n))return{ok:!1,error:`FileTree contains a malformed entry: ${JSON.stringify(n)}`};return{ok:!0};case"Diff":return typeof s.before!="string"?{ok:!1,error:"Diff requires data.before to be a string"}:typeof s.after!="string"?{ok:!1,error:"Diff requires data.after to be a string"}:{ok:!0};case"Stat":return s.label===void 0||s.label===null?{ok:!1,error:"Stat requires data.label"}:s.value===void 0||s.value===null?{ok:!1,error:"Stat requires data.value"}:{ok:!0};case"Workflow":return Array.isArray(s.steps)?{ok:!0}:{ok:!1,error:"Workflow requires data.steps to be an array"};case"Mockup":return typeof s.html!="string"?{ok:!1,error:"Mockup requires data.html to be a string"}:{ok:!0};case"Diagram":return typeof s.dataHtml!="string"?{ok:!1,error:"Diagram requires data.dataHtml to be a string"}:{ok:!0};default:return{ok:!1,error:`Unknown block type: ${t.type}`}}}const Jm={overview:"Overview",implementation:"Implementation plan","implementation-plan":"Implementation plan",questions:"Open questions","open-questions":"Open questions","open-questions-for-you":"Open questions",comments:"Comments",handoff:"Handoff"};function ef(t){const s=[];let n={heading:null,blocks:[]};for(const a of t){const i=Jm[a.id]??null;i?((n.blocks.length>0||n.heading!==null)&&s.push(n),n={heading:i,blocks:[a]}):n.blocks.push(a)}return(n.blocks.length>0||n.heading!==null)&&s.push(n),s}function tf({slug:t,onClose:s,onCommentAdded:n}){var D,G,ee,te;const a=fe(),[i,r]=f.useState(null),[o,l]=f.useState([]),[c,h]=f.useState(!0),[m,d]=f.useState(null),[u,p]=f.useState(null),[x,v]=f.useState(!1),[j,g]=f.useState(!1),[b,y]=f.useState(null),[w,S]=f.useState(null),[$,M]=f.useState(""),[z,A]=f.useState(null),[k,C]=f.useState([]),_=rt.useCallback((F,Y,Q)=>{C(ie=>ie.some(ae=>ae.blockId===F)?ie:[...ie,{blockId:F,blockType:Y,message:Q.message||String(Q)}])},[]),L=f.useRef(null),N=f.useMemo(()=>i?ef(i.blocks):[],[i]);f.useEffect(()=>{let F=!1;const Y=5e3;return(async()=>{h(!0),d(null);try{const Q=new Promise((X,Z)=>setTimeout(()=>Z(new Error("Request timed out after 5s")),Y)),[ie,ae]=await Promise.race([Promise.all([H.get(`/artifacts/${encodeURIComponent(t)}/render`),H.get(`/artifacts/${encodeURIComponent(t)}`)]),Q]);if(F)return;r(ie);const O=(ae==null?void 0:ae.comments)??[];l(Array.isArray(O)?O:[])}catch(Q){if(!F){const ie=Q.message;d(ie),p(ie)}}finally{F||h(!1)}})(),()=>{F=!0}},[t]);function T(F){if(!L.current)return;F.preventDefault();const Y=L.current.getBoundingClientRect();y({x:F.clientX,y:F.clientY,worldX:F.clientX-Y.left,worldY:F.clientY-Y.top})}async function I(){if(!(!w||!$.trim()))try{const F=await H.post(`/artifacts/${encodeURIComponent(t)}/comments`,{x:w.worldX,y:w.worldY,text:$.trim(),author:"drb0rk"});l(Y=>[...Y,{id:F.id??`cmt_${Date.now()}`,x:w.worldX,y:w.worldY,text:$.trim(),author:"drb0rk",created:new Date().toISOString()}]),S(null),M(""),y(null),n==null||n(),a.success("Comment added")}catch(F){a.error(`Failed to add comment: ${F.message}`)}}async function R(){if(!x){v(!0);try{const F=await H.post(`/artifacts/${encodeURIComponent(t)}/submit`,{answers:[],submitter:"drb0rk"});F!=null&&F.ok?(a.success("Sent to agent — feedback.md written, status=review"),n==null||n()):a.error("Submit failed: server did not return ok=true")}catch(F){a.error(`Submit failed: ${F.message}`)}finally{v(!1)}}}function B(){g(F=>!F)}const E=F=>{const Y=F.id,Q=F.data??{},ie=Qm(F);return ie.ok?e.jsx(Zm,{blockId:Y,blockType:F.type,onError:_,children:P(F,Y,Q)},Y):e.jsxs("div",{id:Y,className:"glyph-block-error",role:"alert",style:{border:"1px solid var(--error, #f85149)",background:"rgba(248, 81, 73, 0.06)",borderRadius:8,padding:"12px 14px",margin:"12px 0",color:"var(--text)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,lineHeight:1.55},children:[e.jsxs("strong",{style:{color:"var(--error, #f85149)",fontFamily:"var(--font-sans, system-ui, sans-serif)",display:"block",marginBottom:4},children:[F.type," block invalid"]}),e.jsxs("div",{style:{color:"var(--text-muted)",marginBottom:6},children:["block id: ",e.jsx("code",{children:Y})]}),e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:ie.error})]},Y)},P=(F,Y,Q)=>{switch(F.type){case"RichText":return e.jsx(Am,{id:Y,children:F.childrenMarkdown??""},Y);case"Callout":return e.jsx(Im,{id:Y,tone:Q.tone??"info",children:F.childrenMarkdown??""},Y);case"Checklist":return e.jsx(Lm,{id:Y,items:Q.items??[]},Y);case"Table":return e.jsx(Pm,{id:Y,columns:Q.columns??[],rows:Q.rows??[]},Y);case"CodeTabs":return e.jsx(Dm,{id:Y,tabs:Q.tabs??[]},Y);case"Decision":return e.jsx(Fm,{id:Y,title:Q.title,question:Q.question,options:Q.options??[]},Y);case"OpenQuestions":return e.jsx(Om,{id:Y,questions:Q.questions??[]},Y);case"FileTree":return e.jsx(Hm,{id:Y,title:Q.title,entries:Q.entries??[]},Y);case"Diff":return e.jsx(Vm,{id:Y,filename:Q.filename,language:Q.language,mode:Q.mode??"unified",before:Q.before??"",after:Q.after??""},Y);case"Stat":return e.jsx(qm,{id:Y,label:Q.label??"",value:Q.value,trend:Q.trend,hint:Q.hint},Y);case"Workflow":return e.jsx(Gm,{id:Y,steps:Q.steps??[],connections:Q.connections},Y);case"Mockup":return e.jsx(Km,{id:Y,title:Q.title,x:Q.x,y:Q.y,w:Q.w,h:Q.h,html:Q.html??""},Y);case"Diagram":return e.jsx("div",{id:Y,className:"glyph-block-placeholder",children:e.jsxs("em",{children:["[Diagram] ",Y]})},Y)}};if(c)return e.jsx("div",{className:"glyph-renderer glyph-renderer--loading",children:u?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Failed to load glyph."}),e.jsx("pre",{children:u})]}):e.jsxs(e.Fragment,{children:[e.jsx(sf,{})," Loading glyph…"]})});if(m||!i)return e.jsxs("div",{className:"glyph-renderer glyph-renderer--error",children:[e.jsx("strong",{children:"Failed to load glyph."}),e.jsx("pre",{children:m??"unknown error"})]});const W=((D=i.frontmatter)==null?void 0:D.title)??t,V=((G=i.frontmatter)==null?void 0:G.status)??"draft",K=o.length;return e.jsxs("div",{className:`glyph-canvas ${j?"glyph-canvas--fullscreen":""}`,ref:L,onContextMenu:T,children:[e.jsxs("div",{className:"glyph-toolbar-floating",children:[e.jsxs("button",{className:"glyph-btn glyph-btn--primary glyph-btn--send",onClick:R,disabled:x,title:"Send comments + question answers to the agent — writes feedback.md, status=review",children:[e.jsx(Rt,{size:14}),e.jsx("span",{children:"Send to agent"}),e.jsx("span",{className:"glyph-btn-badge",children:K})]}),e.jsx("span",{className:"glyph-toolbar-divider"}),e.jsx("button",{className:"glyph-icon-btn",title:"Share",onClick:()=>{typeof window<"u"&&navigator.clipboard&&(navigator.clipboard.writeText(window.location.href).catch(()=>{}),a.success("Link copied"))},children:e.jsx(dh,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"Undo",disabled:!0,children:e.jsx(mh,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"Redo",disabled:!0,children:e.jsx(lh,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:j?"Exit fullscreen":"Fullscreen",onClick:B,children:e.jsx(th,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"More",children:e.jsx(Pu,{size:15})}),e.jsx("span",{className:"glyph-toolbar-divider"}),e.jsxs("button",{className:"glyph-icon-btn",title:"Comment count","aria-label":"Comment count",children:[e.jsx(mn,{size:15}),e.jsx("span",{className:"glyph-icon-btn-count",children:K})]}),s&&e.jsx("button",{className:"glyph-icon-btn glyph-icon-btn--close",title:"Close",onClick:s,"aria-label":"Close",children:e.jsx(Re,{size:15})})]}),e.jsxs("div",{className:"glyph-canvas-content",children:[e.jsxs("header",{className:"glyph-canvas-title",children:[e.jsx("h1",{className:"glyph-title",children:W}),e.jsxs("div",{className:"glyph-meta",children:[e.jsx("span",{className:`glyph-status glyph-status--${V}`,children:V}),e.jsx("span",{className:"glyph-slug",children:t})]})]}),(k.length>0||((ee=i.errors)==null?void 0:ee.length)>0)&&e.jsxs("div",{className:"glyph-render-errors",role:"alert",style:{border:"1px solid var(--error, #f85149)",background:"rgba(248, 81, 73, 0.08)",borderRadius:8,padding:"12px 16px",margin:"0 0 16px 0",color:"var(--text)"},children:[e.jsx("strong",{style:{color:"var(--error, #f85149)",display:"block",marginBottom:8},children:k.length>0?`${k.length} block${k.length===1?"":"s"} failed to render`:"Compiler warnings"}),e.jsxs("ul",{style:{margin:0,paddingLeft:20,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,lineHeight:1.6},children:[k.map((F,Y)=>e.jsxs("li",{children:[e.jsx("strong",{children:F.blockType})," (",e.jsx("code",{children:F.blockId}),"): ",F.message]},`be-${Y}`)),(te=i.errors)==null?void 0:te.map((F,Y)=>e.jsxs("li",{children:[F.line?`line ${F.line}: `:"",F.message]},`ce-${Y}`))]})]}),e.jsx("div",{className:"glyph-sections",children:N.map((F,Y)=>e.jsxs("section",{className:`glyph-section ${F.heading?"glyph-section--headed":"glyph-section--plain"}`,children:[F.heading&&e.jsx("h2",{className:"glyph-section-heading",children:F.heading}),e.jsx("div",{className:"glyph-section-blocks",children:F.blocks.map(E)})]},`sec-${Y}-${F.heading??"ungrouped"}`))})]}),o.map(F=>e.jsxs("button",{className:`glyph-pin ${z===F.id?"glyph-pin--active":""}`,style:{left:F.x,top:F.y},onClick:Y=>{Y.stopPropagation(),A(z===F.id?null:F.id)},title:F.text,children:[e.jsx(ur,{size:14}),z===F.id&&e.jsxs("div",{className:"glyph-pin-thread",children:[e.jsx("div",{className:"glyph-pin-text",children:F.text}),e.jsxs("div",{className:"glyph-pin-meta",children:[F.author??"anonymous"," · ",F.created?new Date(F.created).toLocaleString():""]})]})]},F.id)),b&&e.jsx("div",{className:"glyph-ctx-menu",style:{left:b.x,top:b.y},onClick:F=>F.stopPropagation(),children:e.jsxs("button",{className:"glyph-ctx-item",onClick:()=>{S({worldX:b.worldX,worldY:b.worldY}),y(null)},children:[e.jsx(ur,{size:14})," Add comment here"]})}),w&&e.jsx("div",{className:"glyph-modal-overlay",onClick:()=>S(null),children:e.jsxs("div",{className:"glyph-modal",onClick:F=>F.stopPropagation(),children:[e.jsxs("h3",{children:["Add comment at (",Math.round(w.worldX),", ",Math.round(w.worldY),")"]}),e.jsx("textarea",{autoFocus:!0,value:$,onChange:F=>M(F.target.value),placeholder:"What should the agent know about this area?",rows:4,className:"glyph-modal-textarea"}),e.jsxs("div",{className:"glyph-modal-actions",children:[e.jsx("button",{className:"glyph-btn glyph-btn--ghost",onClick:()=>S(null),children:"Cancel"}),e.jsx("button",{className:"glyph-btn glyph-btn--primary",onClick:I,disabled:!$.trim(),children:"Add comment"})]})]})})]})}function sf(){return e.jsx("span",{className:"glyph-spinner","aria-label":"loading",children:"…"})}function _e({icon:t,title:s,message:n,action:a,className:i}){return e.jsxs("div",{className:se("empty-state",i),children:[e.jsx("div",{className:"empty-icon",children:t??e.jsx(Kn,{size:32})}),e.jsx("div",{className:"empty-title",children:s}),n&&e.jsx("div",{className:"empty-message",children:n}),a&&e.jsx("div",{className:"empty-action",children:a})]})}function nf(t){return t==="ok"?"success":t==="warn"?"warning":t==="fail"?"error":t}function ha({kind:t="neutral",children:s,className:n,dot:a=!1}){const i=nf(t);return e.jsxs("span",{className:se("badge",`badge-${i}`,n),title:`status: ${t}`,children:[a&&e.jsx("span",{className:"badge-dot"}),s]})}function af(t){switch(t){case"approved":case"done":return"success";case"in-progress":case"doing":return"info";case"rejected":return"error";case"archived":return"warning";case"draft":default:return"neutral"}}function rf({snapshot:t,refreshSnapshot:s}){const n=fe(),[a,i]=f.useState(t.artifacts||[]),[r,o]=f.useState(!t.artifacts),[l,c]=f.useState(null),[h,m]=f.useState(""),[d,u]=f.useState(!1);f.useEffect(()=>{t.artifacts&&(i(t.artifacts),o(!1))},[t.artifacts]);const p=async()=>{try{const g=await H.get("/artifacts");i(g.artifacts||[]),o(!1)}catch(g){n.error(`Artifacts load failed: ${g.message}`),o(!1)}},x=f.useMemo(()=>{let g=a;if(h){const b=h.toLowerCase();g=g.filter(y=>(y.slug||"").toLowerCase().includes(b)||(y.title||"").toLowerCase().includes(b))}return d||(g=g.filter(b=>b.status!=="archived")),g},[a,h,d]),v=async(g,b)=>{try{const y=await H.post("/artifacts",{slug:g,title:b});n.success(`Artifact "${y.slug}" created.`),c(y.slug),await p()}catch(y){n.error(`Create failed: ${y.message}`)}},j=async g=>{if(confirm(`Delete artifact "${g}"? This removes the directory permanently.`))try{await H.del(`/artifacts/${encodeURIComponent(g)}`),n.success("Artifact deleted."),l===g&&c(null),await p()}catch(b){n.error(`Delete failed: ${b.message}`)}};return l?e.jsxs("div",{className:"artifact-glyph-overlay",children:[e.jsx("div",{className:"artifact-glyph-toolbar",children:e.jsxs(U,{variant:"ghost",onClick:()=>{c(null),p()},children:[e.jsx($i,{size:14})," Back to artifacts"]})}),e.jsx(tf,{slug:l,onClose:()=>{c(null),p()},onCommentAdded:()=>p()})]}):e.jsxs("div",{className:"view view-artifacts",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Zn,{size:18})," Glyphs (",a.length,")"]}),e.jsx("p",{className:"view-subtitle",children:"Visual artifacts with elements, connections, and threaded comments."})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Ae,{size:14,"aria-hidden":!0}),e.jsx("label",{htmlFor:"artifacts-search",className:"sr-only",children:"Search artifacts"}),e.jsx("input",{id:"artifacts-search",className:"input",type:"text",placeholder:"Search…",value:h,onChange:g=>m(g.target.value),"aria-label":"Search artifacts"})]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>u(g=>!g),title:d?"Hide archived":"Show archived",children:[d?e.jsx(Wo,{size:14}):e.jsx(au,{size:14}),d?"Hide archived":"Show archived"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:p,children:[e.jsx(xe,{size:14})," Refresh"]})]})]}),e.jsx(of,{onCreate:v}),r?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}):x.length===0?e.jsx(_e,{icon:e.jsx(Zn,{size:32}),title:d?"No artifacts":"No artifacts yet",message:d?"No artifacts match your filter (try Show archived off).":"Create one above to get started."}):e.jsx("div",{className:"artifacts-grid",children:x.map(g=>e.jsx(lf,{artifact:g,onOpen:()=>c(g.slug),onDelete:()=>j(g.slug)},g.slug))})]})}function of({onCreate:t}){const[s,n]=f.useState(""),[a,i]=f.useState("");return e.jsxs(ne,{className:"new-artifact",children:[e.jsxs(de,{children:[e.jsx(qe,{size:14})," New artifact"]}),e.jsx(ue,{children:"Slug must be lowercase, may contain hyphens, 1–64 chars."}),e.jsxs("form",{className:"new-artifact-form",onSubmit:r=>{r.preventDefault(),s.trim()&&(t(s.trim(),a.trim()||void 0),n(""),i(""))},children:[e.jsx("label",{htmlFor:"new-artifact-slug",className:"sr-only",children:"Artifact slug"}),e.jsx("input",{id:"new-artifact-slug",className:"input",type:"text",placeholder:"slug (e.g. dashboard-v3.1)",pattern:"[a-z0-9][a-z0-9-]{0,63}",required:!0,value:s,onChange:r=>n(r.target.value),"aria-label":"Artifact slug"}),e.jsx("label",{htmlFor:"new-artifact-title",className:"sr-only",children:"Artifact title"}),e.jsx("input",{id:"new-artifact-title",className:"input",type:"text",placeholder:"Title (optional)",value:a,onChange:r=>i(r.target.value)}),e.jsx(U,{variant:"primary",type:"submit",children:"Create"})]})]})}function lf({artifact:t,onOpen:s,onDelete:n}){const a=af(t.status||"draft");return e.jsxs(ne,{variant:"elevated",interactive:!0,className:"artifact-card",onClick:s,children:[e.jsxs("div",{className:"artifact-card-head",children:[e.jsx("div",{className:"artifact-card-title",children:t.title||t.slug}),e.jsx(ha,{kind:a,children:t.status||"draft"})]}),e.jsxs("div",{className:"artifact-card-slug mono",children:[t.slug," · ",t.source]}),e.jsxs("div",{className:"artifact-card-meta",children:[t.elementCount!=null&&e.jsxs("span",{children:[t.elementCount," elements"]}),t.commentCount!=null&&e.jsxs("span",{children:[" · ",t.commentCount," comments"]}),e.jsxs("span",{children:[" · edited ",He(t.mtime)]})]}),e.jsxs("div",{className:"artifact-card-actions",children:[e.jsxs(U,{variant:"primary",size:"sm",onClick:i=>{i.stopPropagation(),s()},children:["Open",e.jsx(Ut,{size:12})]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),n()},children:[e.jsx(Fe,{size:12})," Delete"]})]})]})}function cf({task:t,agents:s,onPromote:n,onDelete:a,onEdit:i,onRefresh:r}){var m;const o=fe(),l=async()=>{try{await H.post(`/tasks/${encodeURIComponent(t.id)}/promote`),o.success("Promoted to queued.",1500),n(t.id)}catch(d){o.error(`Promote failed: ${d.message}`)}},c=async()=>{if(confirm("Delete this task?"))try{await H.del(`/tasks/${encodeURIComponent(t.id)}`),o.success("Deleted.",1500),a(t.id)}catch(d){o.error(`Delete failed: ${d.message}`)}},h={high:"var(--warning)",normal:"var(--info)",low:"var(--muted)"};return e.jsxs("div",{className:"backlog-item","data-task-id":t.id,children:[e.jsxs("div",{className:"backlog-item-head",children:[e.jsx("span",{className:"priority-dot",style:{background:h[t.priority]||"var(--info)"}}),e.jsx("span",{className:"backlog-item-title",children:t.title}),t.assignee&&e.jsxs("span",{className:"backlog-item-badge",children:["@",t.assignee]}),((m=t.tags)==null?void 0:m.length)>0&&e.jsx("span",{className:"backlog-item-badge",children:t.tags.join(", ")})]}),t.description&&e.jsx("div",{className:"backlog-item-desc",children:t.description.slice(0,120)}),e.jsxs("div",{className:"backlog-item-footer",children:[e.jsx("span",{className:"muted text-sm tabular-nums",children:He(t.createdAt)}),e.jsxs("div",{className:"backlog-item-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",title:"Promote to queued",onClick:l,children:e.jsx(pn,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn",title:"Edit",onClick:()=>i(t),children:e.jsx(vt,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",title:"Delete",onClick:c,children:e.jsx(Fe,{size:13})})]})]})]})}function df({agents:t,onRefresh:s}){const n=fe(),[a,i]=f.useState([]),[r,o]=f.useState(!1),l=async()=>{try{o(!0);const u=await H.get("/tasks/backlog");i(Array.isArray(u.tasks)?u.tasks:[])}catch(u){n.error(`Backlog load failed: ${u.message}`)}finally{o(!1)}};f.useEffect(()=>{l()},[]);const c=async u=>{i(p=>p.filter(x=>x.id!==u)),await s()},h=async u=>{i(p=>p.filter(x=>x.id!==u)),await s()},m=u=>{},d=async()=>{var u;if(a.length!==0)try{const x=((u=(await H.post("/tasks/promote-batch",{ids:a.map(v=>v.id)})).affected)==null?void 0:u.filter(v=>v.ok).length)??0;n.success(`Promoted ${x} task(s).`,2e3),i([]),await s()}catch(p){n.error(`Promote all failed: ${p.message}`)}};return e.jsxs("div",{className:"backlog-panel",children:[e.jsxs("div",{className:"backlog-panel-header",children:[e.jsxs("span",{className:"backlog-panel-title",children:[e.jsx(Kn,{size:15}),"Backlog (",a.length,")"]}),e.jsxs("div",{className:"backlog-panel-header-actions",children:[a.length>0&&e.jsxs(U,{variant:"ghost",size:"sm",onClick:d,title:"Promote all to queued",children:[e.jsx(pn,{size:12})," Promote all"]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:l,title:"Refresh backlog","aria-label":"Refresh backlog",children:e.jsx(xe,{size:12,className:r?"animate-spin":""})})]})]}),r?e.jsx("div",{className:"backlog-empty",children:"Loading…"}):a.length===0?e.jsxs("div",{className:"backlog-empty",children:[e.jsx(Kn,{size:28}),e.jsx("span",{children:"Backlog is empty."})]}):e.jsx("div",{className:"backlog-list",children:a.map(u=>e.jsx(cf,{task:u,agents:t,onPromote:c,onDelete:h,onEdit:m,onRefresh:s},u.id))})]})}const uf=[{id:"queued",label:"Todo",kind:"info",dotVariant:"info"},{id:"doing",label:"In progress",kind:"accent",dotVariant:"info"},{id:"done",label:"Done",kind:"success",dotVariant:"success"},{id:"blocked",label:"Failed",kind:"error",dotVariant:"danger"}],ma=["low","normal","high"],hf=[{value:"",label:"All"},...ma.map(t=>({value:t,label:t}))],mf={info:"info",accent:"accent",success:"success",warning:"warning",error:"danger"},ff={high:"danger",normal:"info",low:"neutral"};function pf({snapshot:t,refreshSnapshot:s}){const n=fe(),a=Ze(),[i,r]=f.useState(t.tasks||[]),[o,l]=f.useState(!t.tasks),[c,h]=f.useState(""),[m,d]=f.useState(""),[u,p]=f.useState(!1),[x,v]=f.useState(0),[j,g]=f.useState(""),b=async()=>{try{const k=await H.get("/tasks");r(Array.isArray(k)?k:[])}catch(k){n.error(`Tasks load failed: ${k.message}`)}finally{l(!1)}};f.useEffect(()=>{t.tasks&&(r(t.tasks),l(!1))},[t.tasks]),f.useEffect(()=>{const k=setInterval(()=>v(C=>C+1),3e4);return()=>clearInterval(k)},[]);const y=f.useMemo(()=>{let k=i.filter(C=>C.status!=="backlog");if(m&&(k=k.filter(C=>(C.priority||"normal")===m)),c.trim()){const C=c.toLowerCase();k=k.filter(_=>(_.title||"").toLowerCase().includes(C)||(_.description||"").toLowerCase().includes(C))}return k},[i,c,m]),w=f.useMemo(()=>{const k={high:0,normal:1,low:2};return[...y].sort((C,_)=>{const L=k[C.priority]??1,N=k[_.priority]??1;return L!==N?L-N:new Date(_.createdAt).getTime()-new Date(C.createdAt).getTime()})},[y]),S=i.filter(k=>k.status==="backlog").length,$=async k=>{if(confirm("Delete this task?"))try{await H.del(`/tasks/${encodeURIComponent(k)}`),r(C=>C.filter(_=>_.id!==k)),n.success("Task deleted.",1200)}catch(C){n.error(`Delete failed: ${C.message}`)}},M=async k=>{try{const C=await H.post(`/tasks/${encodeURIComponent(k)}/start`);C&&C.task&&r(_=>_.map(L=>L.id===k?C.task:L)),n.success("Retry dispatched.",1200)}catch(C){n.error(`Retry failed: ${C.message}`)}},z=async k=>{const C=i.find(_=>_.id===k);if(C)try{const _=await H.post("/tasks/submit",{title:C.title,description:C.description,priority:C.priority,tags:C.tags}),L=(_.subtasks||[]).length;n.success(L>1?`Odin split it into ${L} subtasks.`:"Sent to Odin.",1500),_.subtasks&&_.subtasks.length>0&&r(N=>[_.main,..._.subtasks,...N.filter(T=>T.id!==C.id)]),await s()}catch(_){n.error(`Submit failed: ${_.message}`)}},A=k=>{br(a,n,k,r,b,s)};return e.jsxs("div",{className:"view view-tasks tasks-wave3",children:[e.jsx("div",{className:"sr-only",role:"status","aria-live":"polite",children:j}),e.jsx("header",{className:"tasks-wave3__header",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"tasks-wave3__title-row",children:[e.jsx(Qt,{size:18,"aria-hidden":!0})," Tasks (",w.length,")"]}),e.jsx("p",{className:"tasks-wave3__subtitle",children:"Add a task — title and description is all you need. Odin picks the agent and priority."})]})}),e.jsxs("div",{className:"tasks-wave3__toolbar",role:"toolbar","aria-label":"Task filters",children:[e.jsx("div",{className:"tasks-wave3__toolbar-group",children:e.jsx(Xh,{inputSize:"sm",value:c,onChange:k=>h(String(k)),placeholder:"Search…","aria-label":"Search tasks"})}),e.jsxs("div",{className:"tasks-wave3__toolbar-group",children:[e.jsx("span",{className:"tasks-wave3__toolbar-label",id:"tasks-priority-filter-label",children:"Priority"}),e.jsx(Yh,{inputSize:"sm","aria-labelledby":"tasks-priority-filter-label",options:hf,value:m,onChange:k=>d(k.target.value)})]}),e.jsx("div",{className:"tasks-wave3__toolbar-spacer"}),e.jsxs("div",{className:"tasks-wave3__toolbar-group",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:b,title:"Refresh","aria-label":"Refresh tasks",children:e.jsx(xe,{size:14,"aria-hidden":!0})}),S>0&&e.jsxs(U,{variant:u?"accent":"ghost",size:"sm",onClick:()=>p(k=>!k),title:u?"Hide backlog":"Show backlog",children:[e.jsx(Kn,{size:14,"aria-hidden":!0}),"Backlog",e.jsx("span",{className:"tasks-wave3__column-count","aria-label":`${S} items`,children:S})]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>gf(a,n,r,b,s),children:[e.jsx(qe,{size:14,"aria-hidden":!0})," New task"]})]})]}),u&&S>0&&e.jsx(df,{agents:t.agents||[],onRefresh:s}),o?e.jsx(Ri,{label:"Loading tasks…"}):e.jsx(ai,{cols:5,gap:3,className:"tasks-wave3__kanban",children:uf.map(k=>{const C=w.filter(_=>_.status===k.id);return e.jsx(wt,{padding:3,className:"tasks-wave3__column",title:e.jsxs("span",{className:"tasks-wave3__column-title",children:[e.jsx(sn,{variant:k.dotVariant,size:"sm",label:k.label}),k.label]}),actions:e.jsx("span",{className:"tasks-wave3__column-count","aria-label":`${C.length} tasks`,children:C.length}),children:e.jsx(st,{gap:2,className:"tasks-wave3__column-body",children:C.length===0?e.jsx("div",{className:"tasks-wave3__column-empty",children:"No tasks"}):C.map(_=>e.jsx(xf,{task:_,column:k,onTaskClick:A,onEdit:()=>br(a,n,_,r,b,s),onDelete:()=>$(_.id),onRetry:()=>M(_.id),onSubmitToOdin:()=>z(_.id),tick:x},_.id))})},k.id)})})]})}function xf({task:t,column:s,onTaskClick:n,onEdit:a,onDelete:i,onRetry:r,onSubmitToOdin:o,tick:l}){const c=t.workedBy||t.assignee||null,h=ma.includes(t.priority)?t.priority:"normal";return e.jsxs("div",{className:pe("tasks-wave3__row"),"data-task-id":t.id,"data-tick":l,role:"button",tabIndex:0,onClick:()=>n(t),onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),n(t))},children:[e.jsxs("div",{className:"tasks-wave3__row-title-row",children:[e.jsx("div",{className:"tasks-wave3__row-title",title:t.title,children:t.title}),e.jsx(ht,{variant:mf[s.kind],size:"sm","aria-label":`Status ${s.label}`,children:s.label})]}),e.jsxs(De,{gap:1,align:"center",className:"tasks-wave3__row-badges",children:[e.jsx(ht,{variant:ff[h],size:"sm",children:h}),c&&e.jsxs(ht,{variant:"neutral",size:"sm",children:[e.jsx(pt,{size:10,"aria-hidden":!0})," @",c]}),(t.tags||[]).slice(0,2).map(m=>e.jsxs(ht,{variant:"neutral",size:"sm",children:["#",m]},m))]}),e.jsxs("div",{className:"tasks-wave3__row-footer",children:[e.jsx("span",{className:"tasks-wave3__row-time",children:He(t.createdAt)}),e.jsxs(De,{gap:1,align:"center",className:"tasks-wave3__row-actions",onClick:m=>m.stopPropagation(),children:[e.jsx(ps,{variant:"ghost",size:"sm",icon:e.jsx(ih,{size:12,"aria-hidden":!0}),"aria-label":"Edit task",title:"Edit",onClick:a}),e.jsx(ps,{variant:"ghost",size:"sm",icon:e.jsx(Rt,{size:12,"aria-hidden":!0}),"aria-label":"Submit to Odin",title:"Re-delegate to Odin",onClick:o}),e.jsx(ps,{variant:"ghost",size:"sm",icon:e.jsx(da,{size:12,"aria-hidden":!0}),"aria-label":"Retry task",title:"Retry",onClick:r}),e.jsx(ps,{variant:"danger",size:"sm",icon:e.jsx(Fe,{size:12,"aria-hidden":!0}),"aria-label":"Delete task",title:"Delete",onClick:i})]})]})]})}function gf(t,s,n,a,i){let r=null,o=null,l=null,c=null;const h=async d=>{d&&typeof d.preventDefault=="function"&&d.preventDefault();const u=((r==null?void 0:r.value)||"").trim(),p=((o==null?void 0:o.value)||"").trim();if(!u){s.warning("Title is required."),r==null||r.focus();return}const x=(c==null?void 0:c.value)||"normal",v=((l==null?void 0:l.value)||"").split(",").map(j=>j.trim()).filter(Boolean);try{const j=await H.post("/tasks",{title:u,description:p,priority:x,tags:v});t.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),n(g=>[j,...g]),s.success("Task created.",1200),await i()}catch(j){s.error(`Create failed: ${j.message}`)}},m=d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),h(d))};t.open({title:"New task",width:520,children:e.jsxs("div",{className:"task-form",children:[e.jsx("label",{className:"field-label",htmlFor:"task-title",children:"Title *"}),e.jsx("input",{ref:d=>{r=d},id:"task-title",className:"input",type:"text",maxLength:200,placeholder:"What needs to be done?",autoFocus:!0,onKeyDown:m}),e.jsx("label",{className:"field-label",htmlFor:"task-desc",children:"Description"}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"flex-start"},children:[e.jsx("textarea",{ref:d=>{o=d},id:"task-desc",className:"textarea",rows:4,placeholder:"Add any context Odin might need (markdown ok)…",style:{flex:1}}),e.jsx("button",{type:"button",className:"btn btn-ghost btn-icon",title:"Enhance with AI",onClick:async()=>{var u;if(!((u=o==null?void 0:o.value)!=null&&u.trim()))return;const d=await iu(o.value);d!==o.value&&(o.value=d)},children:"✨"})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("label",{htmlFor:"task-priority",className:"task-form-field",children:["Priority hint",e.jsx("select",{ref:d=>{c=d},id:"task-priority",className:"select",defaultValue:"normal",children:ma.map(d=>e.jsx("option",{value:d,children:d},d))})]}),e.jsxs("label",{htmlFor:"task-tags",className:"task-form-field",style:{flex:2},children:["Tags ",e.jsx("span",{className:"field-hint",children:"(comma-separated)"}),e.jsx("input",{ref:d=>{l=d},id:"task-tags",className:"input",type:"text",placeholder:"bug, frontend, urgent"})]})]}),e.jsx("p",{className:"muted text-sm",style:{marginTop:8},children:"The agent and final priority are decided by Odin after you submit."})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>t.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",type:"button",onClick:d=>h(d),children:[e.jsx(qe,{size:14})," Create task"]})]})})}function br(t,s,n,a,i,r){let o=null,l=null,c=null,h=null;const m=async()=>{const d=((o==null?void 0:o.value)||"").trim(),u=((l==null?void 0:l.value)||"").trim();if(!d){s.warning("Title is required."),o==null||o.focus();return}const p=(h==null?void 0:h.value)||"normal",x=((c==null?void 0:c.value)||"").split(",").map(v=>v.trim()).filter(Boolean);try{const v=await H.put(`/tasks/${encodeURIComponent(n.id)}`,{title:d,description:u,priority:p,tags:x});t.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),a(j=>j.map(g=>g.id===n.id?v:g)),s.success("Task updated.",1200),await r()}catch(v){s.error(`Save failed: ${v.message}`)}};t.open({title:"Edit task",width:520,children:e.jsxs("div",{className:"task-form",children:[e.jsx("label",{className:"field-label",htmlFor:"edit-task-title",children:"Title *"}),e.jsx("input",{ref:d=>{o=d},id:"edit-task-title",className:"input",type:"text",maxLength:200,defaultValue:n.title,autoFocus:!0}),e.jsx("label",{className:"field-label",htmlFor:"edit-task-desc",children:"Description"}),e.jsx("textarea",{ref:d=>{l=d},id:"edit-task-desc",className:"textarea",rows:4,defaultValue:n.description||""}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("label",{htmlFor:"edit-task-priority",className:"task-form-field",children:["Priority hint",e.jsx("select",{ref:d=>{h=d},id:"edit-task-priority",className:"select",defaultValue:n.priority||"normal",children:ma.map(d=>e.jsx("option",{value:d,children:d},d))})]}),e.jsxs("label",{htmlFor:"edit-task-tags",className:"task-form-field",style:{flex:2},children:["Tags",e.jsx("input",{ref:d=>{c=d},id:"edit-task-tags",className:"input",type:"text",defaultValue:(n.tags||[]).join(", "),placeholder:"comma-separated"})]})]}),e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(hh,{size:12})," Status"]}),e.jsxs(ue,{children:["Current: ",e.jsx("strong",{children:n.status}),n.workedBy&&e.jsxs(e.Fragment,{children:[" · Worked by @",n.workedBy]}),n.assignee&&!n.workedBy&&e.jsxs(e.Fragment,{children:[" · Assigned @",n.assignee]})]})]})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>t.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:m,children:[e.jsx(Wo,{size:14})," Save"]})]})})}const yf=rt.memo(pf);function vf(t){return H.urlWithToken(`/artifacts/${encodeURIComponent(t)}/content`)}function jf(t,s){const n=vf(s);window.open(n,"_blank","noopener,noreferrer")}const wr={"1m":60*1e3,"5m":5*60*1e3,"30m":30*60*1e3,"1h":60*60*1e3},tt=56,bt=32,us=22,bf=4,wf=.9,Ra={working:"var(--success)",running:"var(--success)",doing:"var(--info)",queued:"var(--info)",done:"var(--success)",success:"var(--success)",blocked:"var(--warning)",error:"var(--error)",failed:"var(--error)",stuck:"var(--warning)",killed:"var(--error)",idle:"var(--text-dim)",pending:"var(--info)",timed_out:"var(--warning)"};function Ia(t){return t&&Ra[t]||Ra.idle}function Sn(t,s=24){return t?t.length<=s?t:t.slice(0,s-1)+"…":""}function Qn(t){if(t==null)return 0;if(typeof t=="number")return t;const s=new Date(t).getTime();return Number.isNaN(s)?0:s}function La(t){const s=t._timerStart;return typeof s=="number"&&s>0?s:Qn(t.createdAt)||Date.now()}function kf(t,s){return(t.status==="done"||t.status==="archived"||t.status==="failed"||t.status==="killed")&&(Qn(t.completedAt)||Qn(t.updatedAt))||s}function Nf(t){return typeof t.startedAt=="number"&&t.startedAt>0?t.startedAt:Date.now()}function Sf(t,s){return(t.status==="done"||t.status==="success"||t.status==="killed"||t.status==="failed"||t.status==="error"||t.status==="timed_out")&&(t.completedAt||t.lastEventAt)||s}function Cf(t){return t<=6e4?1e4:t<=3e5?3e4:t<=18e5?3e5:6e5}function zf(t,s){const n=new Date(t);return s<=3e5?n.toLocaleTimeString("en-GB",{hour12:!1}):n.toLocaleTimeString("en-GB",{hour12:!1,hour:"2-digit",minute:"2-digit"})}function Mf({snapshot:t,refreshSnapshot:s}){const n=fe(),a=f.useRef(null),[i,r]=f.useState("live"),[o,l]=f.useState("5m"),[c,h]=f.useState(()=>typeof window>"u"?!0:window.innerWidth>900),[m,d]=f.useState([]),[u,p]=f.useState([]),[x,v]=f.useState(!0),[j,g]=f.useState(0),[b,y]=f.useState(Date.now()),[w,S]=f.useState(()=>Date.now()-wr["5m"]*.1),[$,M]=f.useState({width:800,height:400}),[z,A]=f.useState(null),[k,C]=f.useState(""),[_,L]=f.useState([]),[N,T]=f.useState(""),[I,R]=f.useState("normal"),[B,E]=f.useState(""),[P,W]=f.useState(""),[V,K]=f.useState(!1),[D,G]=f.useState(!1),[ee,te]=f.useState([]),F=Ze(),Y=t.agents||[],Q=t.tasks||[],ie=wr[o],ae=w,O=w+ie,X=f.useCallback(async()=>{try{const[q,oe]=await Promise.all([H.get("/background").catch(()=>({instances:[]})),H.get("/activity?limit=200").catch(()=>({events:[]}))]);d(q.instances||[]),p(oe.events||[])}catch(q){At.warn("activity reload failed:",q)}finally{v(!1)}},[]);f.useEffect(()=>{X();const q=setInterval(X,3e3);return()=>clearInterval(q)},[X]),f.useEffect(()=>{g(q=>q+1)},[Q.length,Y.length]),f.useEffect(()=>{if(i==="pause")return;y(Date.now());const q=setInterval(()=>y(Date.now()),1e3);return()=>clearInterval(q)},[i,j]),f.useEffect(()=>{if(i==="pause")return;(b-w)/ie>wf&&S(b-ie*.1)},[b,w,ie,i]),f.useEffect(()=>{S(Date.now()-ie*.1)},[o]),f.useEffect(()=>{i==="live"&&S(Date.now()-ie*.1)},[i]),f.useLayoutEffect(()=>{const q=a.current;if(!q)return;const oe=new ResizeObserver(Se=>{for(const Ce of Se){const{width:ve,height:ze}=Ce.contentRect;M({width:Math.max(200,Math.floor(ve)),height:Math.max(120,Math.floor(ze))})}});return oe.observe(q),()=>oe.disconnect()},[]);const Z=f.useMemo(()=>{const q=[];let oe=0;for(const ve of m){const ze=Nf(ve),Ye=Sf(ve,b);Ye<ae||ze>O||q.push({kind:"bg",id:`bg:${ve.instanceId}`,index:oe++,label:`BG ${Sn(ve.promptPreview,20)||ve.instanceId.slice(0,10)}`,sub:ve.status||"pending",start:ze,end:Ye,data:ve})}const Se=[...Q].sort((ve,ze)=>La(ve)-La(ze)),Ce=[];for(const ve of Se){const ze=La(ve),Ye=kf(ve,b);if(Ye<ae||ze>O)continue;let Lt=-1;for(let $t=0;$t<Ce.length;$t++)if(Ce[$t]<=ze){Ce[$t]=Ye,Lt=$t;break}Lt===-1&&(Ce.push(Ye),Lt=Ce.length-1),q.push({kind:"task",id:`task:${ve.id}`,index:oe+Lt,label:Sn(ve.title,32),sub:ve.status,start:ze,end:Ye,data:ve})}return q},[m,Q,b,ae,O]),J=f.useMemo(()=>{const q=new Map;for(const oe of Z)q.set(oe.id,oe);return q},[Z]),le=f.useCallback(q=>ie<=0?0:(q-ae)/ie*$.width,[ae,ie,$.width]),ce=f.useMemo(()=>{const q=Cf(ie),oe=[],Se=Math.floor(ae/q)*q;for(let Ce=Se;Ce<=O+q;Ce+=q){if(Ce<ae-q)continue;if(Ce>O)break;const ve=le(Ce);ve<-40||ve>$.width+40||oe.push({t:Ce,x:ve,label:zf(Ce,ie)})}return oe},[ae,O,ie,$.width,le]),me=f.useMemo(()=>{const q=[];for(const oe of Z){if(oe.kind==="events")continue;const Se=Math.max(oe.start,ae),Ce=Math.min(oe.end,O);if(Ce<ae||Se>O)continue;const ve=le(Se),ze=le(Ce),Ye=Math.max(bf,ze-ve),Lt=bt+us+oe.index*tt+8,$t=tt-16;let Je="doing";if(oe.kind==="bg"){const Te=oe.data.status||"pending";Te==="done"||Te==="success"?Je="done":Te==="failed"||Te==="killed"||Te==="error"?Je="failed":Te==="queued"||Te==="pending"?Je="queued":Te==="blocked"||Te==="stuck"?Je="blocked":Je="doing"}else{const Te=oe.data.status;Te==="done"||Te==="archived"?Je="done":Te==="failed"||Te==="killed"?Je="failed":Te==="queued"?Je="queued":Te==="blocked"?Je="blocked":Je="doing"}const za=(z==null?void 0:z.id)===oe.id;q.push({id:oe.id,laneIndex:oe.index,x:ve,y:Lt,w:Ye,h:$t,label:oe.label,statusClass:Je,selected:za,data:oe.data,kind:oe.kind,start:oe.start,end:oe.end})}return q},[Z,le,z,ae,O]),be=f.useMemo(()=>{const q=[];for(const oe of u){const Se=Qn(oe.ts);if(Se<ae-5e3||Se>O+5e3)continue;const Ce=le(Se);let ve=bt+12;if(oe.taskId){const ze=J.get(`task:${oe.taskId}`);ze&&(ve=bt+us+ze.index*tt+tt/2)}else if(oe.nodeId){const ze=String(oe.nodeId),Ye=J.get(ze.startsWith("task:")||ze.startsWith("bg:")?ze:`task:${ze}`);Ye&&(ve=bt+us+Ye.index*tt+tt/2)}q.push({id:`${oe.ts}-${oe.kind}-${oe.author??""}-${oe.taskId??""}`,x:Ce,y:ve,kind:oe.kind||"event",ts:Se,text:String(oe.text||oe.kind||""),author:oe.author})}return q},[u,ae,O,le,J]),Ne=f.useMemo(()=>Z.map(q=>({id:q.id,y:bt+us+q.index*tt,h:tt})),[Z]),Me=f.useMemo(()=>{const q=le(b);return Math.max(0,Math.min($.width,q))},[le,b,$.width]),We=f.useCallback(q=>{const Se={id:q.id,kind:q.kind,label:q.label,status:q.statusClass,data:q.data};A(Se)},[]);f.useEffect(()=>{if(!z){L([]),W(""),te([]);return}C(""),T(""),E(""),te([]),(async()=>{try{const q=await H.get(`/activity?nodeId=${encodeURIComponent(z.id)}&limit=50`);L(q.events||[])}catch{L([])}if(z.kind==="bg"){const q=z.data;try{const oe=await H.get(`/background/${encodeURIComponent(q.instanceId)}/output?lines=80`);W(oe.output||"")}catch{W("")}if(q.taskId)try{const oe=await H.get(`/tasks/${encodeURIComponent(q.taskId)}/artifacts`);te((oe.artifacts||[]).map(Se=>Se.id))}catch{te([])}}})()},[z]);const Qe=async()=>{if(!(!z||!k.trim())){G(!0);try{await H.post("/comments",{nodeId:z.id,text:k,author:"user"}),C("");const q=await H.get(`/activity?nodeId=${encodeURIComponent(z.id)}&limit=50`);L(q.events||[]),n.success("Comment added.")}catch(q){n.error(`Comment failed: ${q.message}`)}finally{G(!1)}}},Pe=async()=>{if(!(!z||!N.trim())){K(!0);try{await H.post(`/nodes/${encodeURIComponent(z.id)}/tasks`,{title:N,description:`Created from timeline selection ${z.id}.`,priority:I}),T(""),n.success("Task created."),await s()}catch(q){n.error(`Task create failed: ${q.message}`)}finally{K(!1)}}},Oe=async()=>{if(!z||z.kind!=="bg"||!B.trim())return;const q=z.data;try{const oe=await H.post(`/background/${encodeURIComponent(q.instanceId)}/message`,{message:B});oe.ok?(n.success("Message sent."),E("")):n.warning(oe.error||"Send failed")}catch(oe){n.error(`Send failed: ${oe.message}`)}},Ge=async()=>{if(!z||z.kind!=="bg"||!confirm("Kill this bg instance session?"))return;const q=z.data;try{const oe=await H.del(`/background/${encodeURIComponent(q.instanceId)}`);oe.ok?n.success("Session killed."):n.warning(oe.error||"Kill failed"),await X()}catch(oe){n.error(`Kill failed: ${oe.message}`)}},Mt=async()=>{if(!z||z.kind!=="bg")return;const q=z.data;try{const oe=await H.get(`/background/${encodeURIComponent(q.instanceId)}/output?lines=80`);W(oe.output||"")}catch{}};f.useEffect(()=>{const q=oe=>{oe.key==="Escape"&&A(null)};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const Ls=()=>{g(q=>q+1),X()},qt=bt+us+Z.length*tt;return e.jsxs("div",{className:"view view-activity",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Be,{size:18})," Activity"]}),e.jsx("p",{className:"view-subtitle",children:"Live timeline of agents, tasks, and background sessions. Active tasks pulse; the red line marks “now”."})]}),e.jsx("div",{className:"view-actions",children:e.jsxs("div",{className:"tl-mode-toggle",children:[e.jsxs(U,{variant:i==="live"?"primary":"secondary",size:"sm",onClick:()=>r(i==="live"?"pause":"live"),title:i==="live"?"Pause timeline":"Resume timeline",children:[i==="live"?e.jsx(ki,{size:14}):e.jsx(ws,{size:14}),i==="live"?"Live":"Paused"]}),e.jsx("div",{className:"tl-zoom-group",children:["1m","5m","30m","1h"].map(q=>e.jsx("button",{type:"button",className:se("tl-zoom-btn",o===q&&"tl-zoom-btn-active"),onClick:()=>l(q),title:`Zoom to ${q}`,children:q},q))}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:Ls,title:"Refresh",children:[e.jsx(xe,{size:14})," Refresh"]})]})})]}),x&&e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}),!x&&Y.length===0&&Q.length===0&&m.length===0&&u.length===0?e.jsx(_e,{icon:e.jsx(Be,{size:32}),title:"No activity yet",message:"Once agents, tasks, or background instances exist, they'll show up here on the timeline."}):e.jsx("div",{className:se("tl-view",z&&"tl-view-detail-open"),children:e.jsxs("div",{className:se("tl-body",!c&&"tl-body-stream-collapsed"),children:[e.jsxs("aside",{className:se("tl-stream",!c&&"tl-stream-collapsed"),children:[e.jsxs("div",{className:"tl-stream-head",children:[e.jsxs("h3",{children:[e.jsx(Zs,{size:13})," Live events"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>h(!1),title:"Hide event stream","aria-label":"Hide event stream",children:e.jsx(nh,{size:14})})]}),e.jsx("div",{className:"tl-stream-list",children:u.length===0?e.jsx("div",{className:"tl-stream-empty",children:e.jsx("p",{children:"No events yet."})}):e.jsx(qo,{items:[...u].reverse(),itemHeight:40,height:400,className:"tl-stream-virtual",renderItem:q=>{const oe=q.author?pt:q.kind==="task"?Qt:q.kind==="bg"?Fn:Be;return e.jsxs("div",{className:"tl-stream-event",children:[e.jsx("span",{className:"tl-stream-event-time",children:new Date(q.ts).toLocaleTimeString("en-GB",{hour12:!1})}),e.jsx("span",{className:"tl-stream-event-icon",style:{color:Ia(q.kind)},children:e.jsx(oe,{size:12})}),e.jsx("span",{className:"tl-stream-event-text",children:q.author||q.text||q.kind})]})}})})]}),e.jsxs("div",{className:"tl-canvas-wrap",ref:a,children:[e.jsxs("div",{className:"tl-canvas-toolbar",children:[e.jsxs("div",{className:"tl-canvas-toolbar-left",children:[!c&&e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>h(!0),title:"Show event stream",children:[e.jsx(ah,{size:14})," Events"]}),e.jsx("span",{className:"tl-canvas-mode",children:i==="live"?"● Live":"⏸ Paused"}),e.jsxs("span",{className:"tl-canvas-range",children:[new Date(ae).toLocaleTimeString("en-GB",{hour12:!1})," →"," ",new Date(O).toLocaleTimeString("en-GB",{hour12:!1})]})]}),e.jsxs("div",{className:"tl-canvas-legend",children:[e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--success)"}})," active"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot tl-legend-dot-dashed",style:{borderColor:"var(--info)"}})," queued"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--warning)"}})," blocked"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--error)"}})," error"]}),e.jsx("span",{className:"tl-legend-sep"}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(Zu,{size:11})," agent"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(Ai,{size:11})," task"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(Fn,{size:11})," bg"]})]})]}),e.jsx("div",{className:"tl-canvas-scroll",children:e.jsxs("svg",{className:"tl-canvas",width:$.width,height:Math.max($.height,qt),role:"application","aria-label":"Activity timeline",children:[e.jsx("defs",{children:e.jsx("pattern",{id:"tl-canvas-grid",width:$.width,height:tt,patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:`M 0 0 L 0 ${tt}`,fill:"none",stroke:"var(--border)",strokeWidth:.5,opacity:.35})})}),e.jsx("rect",{width:"100%",height:"100%",fill:"url(#tl-canvas-grid)"}),Ne.map(q=>e.jsx("rect",{className:"tl-lane-bg",x:0,y:q.y,width:$.width,height:q.h,fill:q.id.charCodeAt(q.id.length-1)%2===0?"var(--bg-elev-2)":"var(--bg-elev)",opacity:.4},`bg-${q.id}`)),e.jsx("g",{className:"tl-time-axis",children:ce.map(q=>e.jsxs("g",{children:[e.jsx("line",{x1:q.x,y1:0,x2:q.x,y2:qt,stroke:"var(--border)",strokeWidth:.5,strokeDasharray:"2,4",opacity:.5}),e.jsx("text",{x:q.x+4,y:bt-8,fontSize:10,fontFamily:"var(--font-mono)",fill:"var(--text-dim)",children:q.label})]},`tick-${q.t}`))}),Z.map(q=>{const oe=bt+us+q.index*tt+tt/2;return e.jsxs("g",{className:"tl-lane-label-group",children:[e.jsx("text",{x:6,y:oe-2,className:"tl-lane-label",textAnchor:"start",children:Sn(q.label,28)}),e.jsx("text",{x:6,y:oe+10,className:"tl-lane-label-sub",textAnchor:"start",children:q.sub})]},`label-${q.id}`)}),me.map(q=>{const oe=Ia(q.statusClass),Se=q.id===(z==null?void 0:z.id);return e.jsxs("g",{className:se("tl-task-bar",`tl-task-bar-${q.statusClass}`,Se&&"tl-task-bar-selected"),onClick:()=>We(q),children:[e.jsx("rect",{x:q.x,y:q.y,width:q.w,height:q.h,rx:6,fill:oe,fillOpacity:q.statusClass==="done"?.35:q.statusClass==="queued"?.18:.85,stroke:oe,strokeWidth:Se?2.5:1.5,strokeOpacity:q.statusClass==="done"?.5:1,strokeDasharray:q.statusClass==="queued"?"4 4":void 0,style:{cursor:"pointer"}}),q.w>36&&e.jsx("text",{x:q.x+8,y:q.y+q.h/2+4,fontSize:11,fontFamily:"var(--font-sans)",fontWeight:500,fill:"var(--text-strong)",style:{pointerEvents:"none"},opacity:q.statusClass==="done"?.7:1,children:Sn(q.label,Math.max(4,Math.floor(q.w/7)))})]},`bar-${q.id}`)}),be.map(q=>{const oe=Ia(q.kind);return e.jsxs("g",{className:"tl-event-marker-group",children:[e.jsx("line",{x1:q.x,y1:q.y-6,x2:q.x,y2:q.y+6,stroke:oe,strokeWidth:1.2,opacity:.7}),e.jsx("circle",{cx:q.x,cy:q.y,r:4,fill:oe,opacity:.9,children:e.jsx("title",{children:`${q.kind}${q.author?` · ${q.author}`:""} · ${new Date(q.ts).toLocaleTimeString("en-GB",{hour12:!1})}`})})]},`ev-${q.id}`)}),e.jsx("line",{className:"tl-now-line",x1:Me,y1:0,x2:Me,y2:qt,stroke:"var(--error)",strokeWidth:1.5,opacity:.9}),e.jsxs("g",{className:"tl-now-marker",children:[e.jsx("circle",{cx:Me,cy:bt-4,r:4,fill:"var(--error)"}),e.jsx("text",{x:Me+6,y:bt-4,fontSize:10,fontWeight:700,fill:"var(--error)",fontFamily:"var(--font-mono)",children:"now"})]})]})})]}),z&&e.jsx("aside",{className:"tl-detail tl-detail-enter",children:e.jsxs(ne,{children:[e.jsxs(de,{children:[z.kind==="agent"&&e.jsx(pt,{size:14}),z.kind==="task"&&e.jsx(Qt,{size:14}),z.kind==="bg"&&e.jsx(Fn,{size:14}),z.label,e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>A(null),title:"Close","aria-label":"Close activity detail",style:{marginLeft:"auto"},children:e.jsx(Re,{size:14})})]}),e.jsxs("div",{className:"tl-detail-meta",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"type"})," ",z.kind]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"status"})," ",e.jsx("code",{children:z.status})]}),z.kind==="agent"&&(()=>{const q=z.data;return e.jsxs(e.Fragment,{children:[q.role&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"role"})," ",q.role]}),q.model&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"model"})," ",q.model]})]})})(),z.kind==="task"&&(()=>{const q=z.data;return e.jsxs(e.Fragment,{children:[q.assignee&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"assignee"})," @",q.assignee]}),q.priority&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"priority"})," ",q.priority]}),q.createdAt&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"created"})," ",new Date(q.createdAt).toLocaleString()]})]})})(),z.kind==="bg"&&(()=>{const q=z.data;return e.jsxs(e.Fragment,{children:[q.startedAt&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"started"})," ",new Date(q.startedAt).toLocaleString()]}),q.tmuxSession&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"tmux"})," ",e.jsx("code",{children:q.tmuxSession})," ",q.tmuxActive?e.jsx("span",{className:"tag tag-success",children:"active"}):e.jsx("span",{className:"tag",children:"inactive"})]})]})})()]}),z.kind==="task"&&z.data.description&&e.jsx("div",{className:"tl-detail-desc",children:z.data.description}),z.kind==="bg"&&z.data.promptPreview&&e.jsx("div",{className:"tl-detail-desc",children:z.data.promptPreview}),z.kind==="bg"&&e.jsxs("div",{className:"tl-detail-bg",children:[e.jsx("pre",{className:"tl-bg-output",children:P||"(no output — start the session via tmux attach)"}),e.jsxs("div",{className:"tl-bg-output-actions",children:[e.jsxs(U,{variant:"ghost",size:"sm",onClick:Mt,children:[e.jsx(xe,{size:12})," Refresh output"]}),ee.length>0&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>jf(F,ee[0]),children:[e.jsx(Ve,{size:12})," Open artifact"]}),e.jsxs(U,{variant:"danger",size:"sm",onClick:Ge,children:[e.jsx(Fe,{size:12})," Kill session"]})]}),e.jsxs("div",{className:"tl-form-row",children:[e.jsx("label",{htmlFor:"bg-message-input",className:"sr-only",children:"Send a message to this bg session"}),e.jsx("input",{id:"bg-message-input",className:"input",placeholder:"Send a message to this bg session…",value:B,onChange:q=>E(q.target.value),onKeyDown:q=>{q.key==="Enter"&&Oe()},"aria-label":"Send a message to this bg session"}),e.jsxs(U,{variant:"primary",size:"sm",disabled:!B.trim(),onClick:Oe,children:[e.jsx(Rt,{size:12})," Send"]})]})]}),z.kind!=="bg"&&e.jsxs("div",{className:"tl-detail-create",children:[e.jsx("label",{className:"field-label",htmlFor:"followup-task-title",children:"Create follow-up task"}),e.jsx("input",{id:"followup-task-title",className:"input",placeholder:"Task title",value:N,onChange:q=>T(q.target.value)}),e.jsxs("div",{className:"tl-form-row",children:[e.jsx("label",{htmlFor:"followup-task-priority",className:"sr-only",children:"Task priority"}),e.jsxs("select",{id:"followup-task-priority",className:"select",value:I,onChange:q=>R(q.target.value),"aria-label":"Task priority",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"})]}),e.jsxs(U,{variant:"primary",size:"sm",disabled:!N.trim()||V,onClick:Pe,children:[e.jsx(qe,{size:12})," Add task"]})]})]}),e.jsxs("div",{className:"tl-detail-comments",children:[e.jsxs("div",{className:"field-label",children:[e.jsx(mn,{size:12})," Comments & activity"]}),e.jsxs("ul",{className:"comment-list",children:[_.length===0&&e.jsx("li",{className:"muted",children:"No comments yet."}),_.map((q,oe)=>e.jsxs("li",{className:"comment-item",children:[e.jsxs("div",{className:"comment-head",children:[e.jsx("strong",{children:q.author||"system"}),e.jsxs("span",{className:"muted",children:[q.kind," · ",new Date(q.ts).toLocaleString()]})]}),q.text&&e.jsx("div",{className:"comment-text",children:q.text}),q.taskId&&e.jsxs("div",{className:"muted",children:["→ task ",e.jsx("code",{children:String(q.taskId)})]})]},`c-${oe}`))]}),e.jsxs("div",{className:"comment-input-row",children:[e.jsx("label",{htmlFor:"comment-input",className:"sr-only",children:"Add a comment"}),e.jsx("input",{id:"comment-input",className:"input",placeholder:"Add a comment…",value:k,onChange:q=>C(q.target.value),onKeyDown:q=>{q.key==="Enter"&&!q.shiftKey&&Qe()},"aria-label":"Add a comment"}),e.jsxs(U,{variant:"secondary",size:"sm",disabled:!k.trim()||D,onClick:Qe,children:[e.jsx(Rt,{size:12})," Post"]})]})]})]})},z.id)]})})]})}function $f(t,s){const n=t.length,a=s.length,i=Array.from({length:a+1},()=>Array(n+1).fill(0));for(let r=0;r<=n;r++)i[0][r]=r;for(let r=0;r<=a;r++)i[r][0]=r;for(let r=1;r<=a;r++)for(let o=1;o<=n;o++){const l=t[o-1]===s[r-1]?0:1;i[r][o]=Math.min(i[r][o-1]+1,i[r-1][o]+1,i[r-1][o-1]+l)}return i[a][n]}function Pa(t,s){if(s===t)return 100;if(s.startsWith(t))return 90;const n=s.split(/\s+/);for(const r of n)if(r.startsWith(t))return 80;const a=Math.min(t.length,s.length);return $f(t,s.substring(0,a))<=2?40:s.includes(t)?30:0}function Ef(t,s){const n=t.toLowerCase().trim();return n?s.map(a=>{const i=Pa(n,a.label.toLowerCase()),r=a.value?Pa(n,String(a.value).toLowerCase()):0,o=a.description?Pa(n,a.description.toLowerCase()):0,l=Math.max(i,r,o);if(l===0)return null;const c=i>=r&&i>=o?"label":r>=i&&r>=o?"value":"description",h=c==="label"?a.label:c==="value"?String(a.value):a.description;return{...a,score:l,matchedField:c,matchedTerm:h}}).filter(a=>a!==null).sort((a,i)=>i.score-a.score):[]}const Ii="bizar_settings_recent";function dl(){try{const t=localStorage.getItem(Ii);return t?JSON.parse(t):[]}catch{return[]}}function _f(t){if(t)try{const s=dl().filter(n=>n!==t);s.unshift(t),localStorage.setItem(Ii,JSON.stringify(s.slice(0,5)))}catch{}}function Tf(t,s){if(!s)return t;const n=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`(${n})`,"gi");return t.split(a).map((r,o)=>a.test(r)?e.jsx("mark",{children:r},o):e.jsx("span",{children:r},o))}function Af(t){const s=[];for(const n of t){s.push({key:n.id,label:n.label,section:n.id,description:`${n.fields.length} field${n.fields.length===1?"":"s"}`});for(const a of n.fields)s.push({key:a.key,label:a.label,section:n.id,value:a.value})}return s}function Rf({sections:t,onJump:s}){const[n,a]=f.useState(""),[i,r]=f.useState([]),[o,l]=f.useState(0),[c,h]=f.useState(null),[m,d]=f.useState(!1),u=f.useRef(null),p=f.useRef(null),x=f.useRef(null),v=f.useRef([]);f.useEffect(()=>{v.current=Af(t)},[t]);const j=f.useCallback((k,C=!1)=>{if(p.current&&clearTimeout(p.current),!k.trim()){r([]),l(0);return}const _=()=>{const L=Ef(k,v.current);r(L),l(0)};C?_():p.current=setTimeout(_,150)},[]);f.useEffect(()=>{j(n)},[n,j]),f.useEffect(()=>()=>{p.current&&clearTimeout(p.current),x.current&&clearTimeout(x.current)},[]);const g=(k,C)=>{const _=document.querySelector(`[data-section="${k}"] [data-setting-id="${C}"]`);_&&(_.scrollIntoView({behavior:"smooth",block:"center"}),_.classList.add("setting-flash"),setTimeout(()=>_.classList.remove("setting-flash"),2e3));const L=document.querySelector(`[data-section="${k}"]`);L&&L.scrollIntoView({behavior:"smooth",block:_?"nearest":"start"})},b=k=>{h(k),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>h(null),1500);const C=document.querySelector(`[data-section="${k}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"start"})},y=k=>{var C;_f(n),k.key===k.section?(b(k.section),s(k.section)):(b(k.section),s(k.section,k.key),g(k.section,k.key)),a(""),(C=u.current)==null||C.blur()},w=k=>{var C;k.key==="Escape"?(a(""),(C=u.current)==null||C.blur()):k.key==="ArrowDown"?(k.preventDefault(),l(_=>Math.min(_+1,i.length-1))):k.key==="ArrowUp"?(k.preventDefault(),l(_=>Math.max(_-1,0))):k.key==="Enter"&&(k.preventDefault(),i.length===0&&n.trim()&&j(n,!0),i[o]&&y(i[o]))},S=k=>{y(k)},$=dl(),M=k=>{var C;a(k),(C=u.current)==null||C.focus()},z=()=>{try{localStorage.removeItem(Ii)}catch{}d(k=>k)},A=m&&!n.trim()&&$.length>0;return e.jsxs("div",{className:"settings-search",children:[e.jsxs("div",{className:"settings-search-input-wrap",children:[e.jsx(Ae,{size:13,className:"settings-search-icon"}),e.jsx("input",{ref:u,className:"settings-search-input",placeholder:"Search settings…",value:n,onChange:k=>a(k.target.value),onKeyDown:w,onFocus:()=>d(!0),onBlur:()=>setTimeout(()=>d(!1),150),"aria-label":"Search settings"}),n&&e.jsx("button",{type:"button",className:"icon-btn settings-search-clear",onClick:()=>a(""),"aria-label":"Clear search",children:e.jsx(Re,{size:12})})]}),A&&e.jsxs("div",{className:"settings-search-recent",children:[e.jsxs("div",{className:"settings-search-recent-header",children:[e.jsx("span",{className:"settings-search-recent-label",children:"Recent"}),e.jsx("button",{type:"button",className:"settings-search-recent-clear",onClick:z,tabIndex:-1,children:"Clear"})]}),$.map(k=>e.jsxs("button",{type:"button",className:"settings-search-recent-item",onMouseDown:C=>{C.preventDefault(),M(k)},children:[e.jsx(Ae,{size:11}),e.jsx("span",{children:k})]},k))]}),n&&i.length>0&&e.jsx("div",{className:"settings-search-results",children:i.map((k,C)=>e.jsxs("button",{type:"button",className:se("settings-search-result",C===o&&"settings-search-result-active"),onClick:()=>S(k),onMouseEnter:()=>l(C),children:[e.jsx("span",{className:se("settings-search-result-type",k.key===k.section&&"settings-search-result-type-section"),children:k.key===k.section?"section":"field"}),e.jsx("span",{className:"settings-search-result-label",children:Tf(k.label,n)}),k.key!==k.section&&e.jsx("span",{className:"settings-search-result-key mono muted",children:k.key})]},`${k.section}::${k.key}`))}),n&&i.length===0&&e.jsx("div",{className:"settings-search-empty muted",children:"No matching settings."})]})}const If=[{id:"dark",label:"Dark",Icon:tl},{id:"light",label:"Light",Icon:il},{id:"system",label:"System",Icon:sh}],Lf=[{name:"Purple",accent:"#8b5cf6"},{name:"Blue",accent:"#3b82f6"},{name:"Green",accent:"#10b981"},{name:"Orange",accent:"#f97316"},{name:"Red",accent:"#ef4444"},{name:"Pink",accent:"#ec4899"},{name:"Cyan",accent:"#06b6d4"},{name:"Mono",accent:"#6b7280"}],Pf=["Inter","system-ui","Segoe UI","Roboto","JetBrains Mono","SF Mono","Cascadia Code"];function Df({settings:t,patchTheme:s,patchUi:n}){return e.jsxs(ne,{id:"settings-theme","data-section":"theme",children:[e.jsxs(de,{children:[e.jsx(nl,{size:14})," Theme"]}),e.jsx(ue,{children:"Mode, accent, and colors. Live preview as you tweak."}),e.jsxs("div",{className:"field","data-setting-id":"theme.presets",children:[e.jsx("label",{className:"field-label",children:"Accent presets"}),e.jsx("div",{className:"theme-presets",children:Lf.map(a=>e.jsxs("button",{type:"button",className:se("theme-preset",t.theme.accent===a.accent&&"theme-preset-active"),onClick:()=>s({accent:a.accent}),title:a.name,children:[e.jsx("span",{className:"theme-preset-swatch",style:{background:a.accent}}),e.jsx("span",{className:"theme-preset-name",children:a.name})]},a.name))})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.mode",children:[e.jsx("label",{className:"field-label",children:"Mode"}),e.jsx("div",{className:"theme-row",children:If.map(({id:a,label:i,Icon:r})=>{const o=t.theme.mode===a;return e.jsxs("button",{type:"button",className:se("theme-card",o&&"theme-card-active"),onClick:()=>s({mode:a}),children:[e.jsx(r,{size:16}),e.jsx("span",{className:"theme-card-label",children:i}),e.jsx("span",{className:se("theme-card-swatch",`theme-card-swatch-${a}`)})]},a)})})]}),e.jsx("div",{className:"theme-colors",children:["accent","success","warning","error","info"].map(a=>e.jsxs("div",{className:"field","data-setting-id":`theme.${a}`,children:[e.jsx("label",{className:"field-label",children:a.charAt(0).toUpperCase()+a.slice(1)}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:t.theme[a],onChange:i=>s({[a]:i.target.value}),"aria-label":`${a} color`}),e.jsx("input",{type:"text",className:"input",value:t.theme[a],onChange:i=>s({[a]:i.target.value}),"aria-label":`${a} color hex`})]})]},a))}),e.jsxs("div",{className:"field","data-setting-id":"theme.fontFamily",children:[e.jsx("label",{className:"field-label",children:"Font family"}),e.jsx("select",{className:"select",value:t.theme.fontFamily,onChange:a=>s({fontFamily:a.target.value}),children:Pf.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.fontSize",children:[e.jsxs("label",{className:"field-label",children:["Font size: ",t.theme.fontSize,"px"]}),e.jsx("input",{type:"range",min:12,max:20,value:t.theme.fontSize,onChange:a=>s({fontSize:Number(a.target.value)})})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"theme.compactMode",children:[e.jsx("input",{type:"checkbox",checked:t.theme.compactMode,onChange:a=>s({compactMode:a.target.checked})}),e.jsx("span",{children:"Compact mode (denser UI)"})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"theme.animations",children:[e.jsx("input",{type:"checkbox",checked:t.theme.animations,onChange:a=>s({animations:a.target.checked})}),e.jsx("span",{children:"Enable animations"})]})]})}function Ff({tailscale:t,tailscaleDraft:s,setTailscaleDraft:n,onTailscaleToggle:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(ne,{id:"settings-service","data-section":"service",children:[e.jsxs(de,{children:[e.jsx(Ss,{size:14})," Service"]}),e.jsx(ue,{children:"Background daemon that runs schedules."}),e.jsx("div",{"data-setting-id":"service.enabled",children:t?e.jsxs("div",{className:"service-card",children:[e.jsxs("p",{children:["Status: ",e.jsx("strong",{children:t.settings.enabled?"enabled":"disabled"})," ","· Tailscale installed: ",e.jsx("strong",{children:t.installed?"yes":"no"})," ","· authenticated: ",e.jsx("strong",{children:t.authenticated?"yes":"no"})]}),e.jsxs("p",{className:"muted",children:["Use ",e.jsx("code",{children:"bizar service start"})," / ",e.jsx("code",{children:"bizar service stop"})," in your terminal to control the daemon."]})]}):e.jsx("p",{className:"muted",children:"Loading service status…"})})]}),e.jsxs(ne,{id:"settings-tailscale","data-section":"tailscale",children:[e.jsxs(de,{children:[e.jsx(si,{size:14})," Tailscale serve"]}),e.jsx(ue,{children:"Expose the dashboard over your Tailscale network."}),t?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Installed: ",e.jsx("strong",{children:t.installed?"yes":"no"})," ",t.version&&e.jsxs("span",{className:"muted",children:["(",t.version,")"]})]}),e.jsxs("p",{children:["Authenticated: ",e.jsx("strong",{children:t.authenticated?"yes":"no"})]}),e.jsxs("p",{children:["Serve enabled: ",e.jsx("strong",{children:t.settings.enabled?"yes":"no"})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Port"}),e.jsx("input",{type:"number",className:"input",value:s.port,onChange:i=>n(r=>({...r,port:Number(i.target.value)||4321}))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"tailscale-https",children:"Use HTTPS"}),e.jsx("input",{id:"tailscale-https",type:"checkbox",checked:s.https,onChange:i=>n(r=>({...r,https:i.target.checked}))})]})]}),e.jsx(U,{variant:"primary",onClick:a,children:t.settings.enabled?"Disable serve":"Enable serve"})]}):e.jsx("p",{className:"muted",children:"Loading Tailscale status…"})]})]})}function Of({settings:t,patchNotifications:s}){return e.jsxs(ne,{id:"settings-notifications","data-section":"notifications",children:[e.jsx(de,{children:"Notifications"}),e.jsx(ue,{children:"Toast triggers inside the dashboard."}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"notifications.onAgentComplete",children:[e.jsx("input",{type:"checkbox",checked:!!t.notifications.onAgentComplete,onChange:n=>s({onAgentComplete:n.target.checked})}),e.jsx("span",{children:"Notify when an agent invocation completes"})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"notifications.onPlanApproval",children:[e.jsx("input",{type:"checkbox",checked:!!t.notifications.onPlanApproval,onChange:n=>s({onPlanApproval:n.target.checked})}),e.jsx("span",{children:"Notify when a plan needs approval"})]})]})}function Bf({authStatus:t,setAuthStatus:s}){const n=fe(),[a,i]=f.useState(H.getToken()),[r,o]=f.useState("");f.useEffect(()=>{let m=!1;return(async()=>{try{const d=await H.probeAuthStatus();m||s(d)}catch{m||s({required:!0,loopback:!1,peer:""})}})(),()=>{m=!0}},[]);const l=async()=>{try{const m=await H.get("/auth/reveal");o(m.token),i(m.token),H.setToken(m.token);try{await navigator.clipboard.writeText(m.token),n.success("Token copied to clipboard.")}catch{n.success("Token revealed — copy from the field below.")}}catch(m){n.error(`Reveal failed: ${m.message}`)}},c=async()=>{if(confirm("Regenerate the auth token? Anything still using the old token will start getting 401 errors immediately."))try{const m=await H.post("/auth/regenerate");o(m.token),i(m.token),H.setToken(m.token);try{await navigator.clipboard.writeText(m.token),n.success("New token generated and copied to clipboard.")}catch{n.success("New token generated — copy from the field below. Old token is now invalid.")}}catch(m){n.error(`Regenerate failed: ${m.message}`)}},h=()=>{H.setToken(a.trim()),n.success("Token saved. The dashboard will use it on the next request.")};return e.jsxs(ne,{id:"settings-auth","data-section":"auth",children:[e.jsxs(de,{children:[e.jsx(ss,{size:14})," Authentication"]}),e.jsx(ue,{children:"Localhost and Tailscale browser access are auto-trusted via loopback. A bearer token is still available for non-loopback clients and forced-auth mode."}),e.jsxs("div",{className:"field","data-setting-id":"auth.status",children:[e.jsx("label",{className:"field-label",children:"Server status"}),e.jsxs("p",{style:{margin:"4px 0"},children:["Auth required:"," ",e.jsx("strong",{children:t?t.required?"yes":"no":"probing…"})]}),e.jsxs("p",{style:{margin:"4px 0"},children:["Connection:"," ",e.jsx("strong",{children:t?t.loopback?"loopback (auto-trusted)":"remote":"probing…"})]}),e.jsxs("p",{style:{margin:"4px 0"},children:["Peer address:"," ",t!=null&&t.peer?e.jsx("code",{children:t.peer}):e.jsx("span",{className:"muted",children:"probing…"})]}),e.jsxs("p",{className:"muted",style:{fontSize:12,margin:"4px 0"},children:["Localhost and Tailscale browser access are auto-trusted because the dashboard sees a loopback peer. Paste a token only for non-loopback API clients/scripts, or if you force auth for every connection with"," ",e.jsx("code",{children:"BIZAR_DASHBOARD_REQUIRE_AUTH=1"}),"."]}),e.jsxs("p",{className:"muted",style:{fontSize:12,margin:"4px 0"},children:["Dashboard tokens are generated on first boot and saved to"," ",e.jsx("code",{children:"~/.config/bizar/dashboard-secret"})," (mode 0600)."]}),e.jsx("p",{className:"muted",style:{fontSize:12,margin:"4px 0"},children:"For Tailscale Serve or any reverse-proxy access, paste this token once via the boot screen — it is saved per-origin and works for all subsequent visits."})]}),e.jsxs("div",{className:"field","data-setting-id":"auth.token",children:[e.jsx("label",{className:"field-label",children:"Token (this browser)"}),e.jsx("input",{type:"password",className:"input mono",value:a,onChange:m=>i(m.target.value),placeholder:"Paste token from server stderr or another browser",spellCheck:!1,autoComplete:"off"}),e.jsxs("div",{className:"task-form-row",style:{marginTop:8},children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:h,children:[e.jsx(zi,{size:14})," Save token"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:l,children:[e.jsx(Vt,{size:14})," Reveal & copy server token"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:c,children:[e.jsx(Bo,{size:14})," Regenerate"]})]}),r?e.jsxs("p",{className:"muted",style:{fontSize:12,marginTop:8},children:["Last revealed token (one-time): ",e.jsx("code",{className:"mono",children:r})]}):null,e.jsx("p",{className:"muted",style:{fontSize:12,marginTop:8},children:"Regenerating invalidates the current token immediately. Anything still using the old token will see 401 until it's updated."})]})]})}function Hf({settings:t,patchAgents:s,patchDashboard:n,autoSave:a}){var h,m,d,u;const i=fe(),[r,o]=f.useState({});f.useEffect(()=>{H.get("/settings/plugin-options").then(o).catch(()=>{})},[]);const l=async()=>{try{await H.put("/settings/plugin-options",r),i.success("Saved — restart cline for changes to take effect.")}catch(p){i.error(`Save failed: ${p.message}`)}},c=async()=>{try{const x=await(await fetch("/api/background/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({maxAgeDays:7})})).json();i.success(`Cleaned up ${x.deleted} old instances.`)}catch(p){i.error(`Cleanup failed: ${p.message}`)}};return e.jsxs(e.Fragment,{children:[e.jsxs(ne,{id:"settings-agents","data-section":"agents",children:[e.jsxs(de,{children:[e.jsx(Ss,{size:14})," Agent Behavior"]}),e.jsx(ue,{children:"Limits and timeouts for background agent dispatch."}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"agents-maxParallel",children:["Max parallel agents",e.jsx("span",{className:"meta-badge",children:"default: 6"})]}),e.jsx("input",{id:"agents-maxParallel",type:"number",min:1,max:20,value:((h=t.agents)==null?void 0:h.maxParallel)??6,onChange:p=>s({maxParallel:Math.max(1,Math.min(20,parseInt(p.target.value,10)||6))})})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"agents-stuckThresholdMs",children:["Stuck threshold (ms)",e.jsx("span",{className:"meta-badge",children:"default: 600000 (10 min)"})]}),e.jsx("input",{id:"agents-stuckThresholdMs",type:"number",min:6e4,max:36e5,step:6e4,value:((m=t.agents)==null?void 0:m.stuckThresholdMs)??6e5,onChange:p=>s({stuckThresholdMs:Math.max(6e4,Math.min(36e5,parseInt(p.target.value,10)||6e5))})})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"agents.autoRestart",children:[e.jsx("input",{type:"checkbox",checked:!!((d=t.agents)!=null&&d.autoRestart),onChange:p=>s({autoRestart:p.target.checked})}),e.jsx("span",{children:"Auto-restart stuck agents"})]})]}),e.jsxs(ne,{id:"settings-dashboard","data-section":"dashboard",children:[e.jsxs(de,{children:[e.jsx(Qs,{size:14})," Dashboard"]}),e.jsxs(ue,{children:["Controls how ",e.jsx("code",{children:"bizar"})," starts up."]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"dashboard.autoLaunchWeb",children:[e.jsx("input",{type:"checkbox",checked:t.dashboard.autoLaunchWeb!==!1,onChange:p=>n({autoLaunchWeb:p.target.checked})}),e.jsx("span",{children:"Auto-launch web UI alongside TUI"})]}),e.jsxs("div",{className:"field","data-setting-id":"dashboard.projectsDirectory",style:{marginTop:"var(--space-4)"},children:[e.jsx("label",{className:"field-label",htmlFor:"set-projects-directory",children:"Projects directory"}),e.jsx("input",{id:"set-projects-directory",className:"input",type:"text",placeholder:"/home/user/projects",value:t.dashboard.projectsDirectory??"",onChange:p=>n({projectsDirectory:p.target.value})}),e.jsx("p",{className:"field-help",children:"New projects created via the dashboard will land here, and existing project directories inside this folder are auto-recognized on startup."}),t.dashboard.projectsDirectory&&e.jsxs(e.Fragment,{children:[!/^\/|^[A-Za-z]:/.test(t.dashboard.projectsDirectory)&&e.jsx("p",{style:{color:"var(--warning)",fontSize:11,marginTop:4},children:"Path should be absolute (start with / on Linux/Mac, or a drive letter on Windows)."}),t.dashboard.projectsDirectory.includes("..")&&e.jsx("p",{style:{color:"var(--error)",fontSize:11,marginTop:4},children:"Path traversal not allowed — this will be rejected server-side."})]})]}),e.jsxs("div",{className:"field","data-setting-id":"dashboard.allowedRoots",style:{marginTop:"var(--space-4)"},children:[e.jsxs("label",{className:"field-label",htmlFor:"set-allowed-roots",children:["Additional allowed roots ",e.jsx("span",{className:"muted",children:"(advanced)"})]}),e.jsx(fu,{initialValue:(t.dashboard.allowedRoots??[]).join(`
|
|
396
|
-
`),delay:1500,saveFn:async p=>{const x=p.split(`
|
|
397
|
-
`).map(v=>v.trim()).filter(Boolean);n({allowedRoots:x}),a==null||a("dashboard",{allowedRoots:x})},render:({value:p,onChange:x,onBlur:v})=>e.jsx("textarea",{id:"set-allowed-roots",className:"textarea",rows:4,placeholder:`/workspace
|
|
398
|
-
/srv/projects`,value:p,onChange:j=>x(j.target.value),onBlur:v})},(u=t.dashboard.allowedRoots)==null?void 0:u.join(`
|
|
399
|
-
`)),e.jsx("p",{className:"field-help",children:"Optional. Add filesystem roots beyond your home directory that the file browser and project scanner can access. Each path must be inside your home directory. One per line."}),(()=>{const p=(t.dashboard.allowedRoots??[]).join(`
|
|
400
|
-
`).split(`
|
|
401
|
-
`),x=[];return p.forEach((v,j)=>{v.trim()&&(/^\/|^[A-Za-z]:/.test(v)||x.push({key:`noabs-${j}`,msg:e.jsxs("p",{style:{color:"var(--warning)",fontSize:11,marginTop:2},children:["Line ",j+1,': "',v,'" — should be absolute (start with / or a drive letter).']})}),v.includes("..")&&x.push({key:`dots-${j}`,msg:e.jsxs("p",{style:{color:"var(--error)",fontSize:11,marginTop:2},children:["Line ",j+1,': "',v,`" — contains '..' (server will reject this).`]})}))}),x.map(v=>v.msg)})()]})]}),e.jsxs(ne,{id:"settings-background","data-section":"background",children:[e.jsxs(de,{children:[e.jsx(Ss,{size:14})," Background Agents"]}),e.jsx(ue,{children:"Tune plugin options. Changes take effect on next plugin restart."}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-maxConcurrent",children:["Max concurrent instances",e.jsx("span",{className:"meta-badge",children:"default: 8"})]}),e.jsx("input",{id:"bg-maxConcurrent",type:"number",min:1,max:32,value:r.maxConcurrentInstances??8,onChange:p=>o(x=>({...x,maxConcurrentInstances:Math.max(1,Math.min(32,parseInt(p.target.value,10)||8))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"maxConcurrentInstances"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-toolCallCap",children:["Tool-call cap",e.jsx("span",{className:"meta-badge",children:"default: 500"})]}),e.jsx("input",{id:"bg-toolCallCap",type:"number",min:1,max:5e3,value:r.backgroundToolCallCap??500,onChange:p=>o(x=>({...x,backgroundToolCallCap:Math.max(1,Math.min(5e3,parseInt(p.target.value,10)||500))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundToolCallCap"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-stallTimeout",children:["Stall timeout (ms)",e.jsx("span",{className:"meta-badge",children:"default: 180000"})]}),e.jsx("input",{id:"bg-stallTimeout",type:"number",min:1e4,max:6e5,step:1e3,value:r.backgroundStallTimeoutMs??18e4,onChange:p=>o(x=>({...x,backgroundStallTimeoutMs:Math.max(1e4,Math.min(6e5,parseInt(p.target.value,10)||18e4))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundStallTimeoutMs"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-thinkingLoopTimeout",children:["Thinking-loop timeout (ms)",e.jsx("span",{className:"meta-badge",children:"default: 300000"})]}),e.jsx("input",{id:"bg-thinkingLoopTimeout",type:"number",min:3e4,max:9e5,step:1e3,value:r.backgroundThinkingLoopTimeoutMs??3e5,onChange:p=>o(x=>({...x,backgroundThinkingLoopTimeoutMs:Math.max(3e4,Math.min(9e5,parseInt(p.target.value,10)||3e5))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundThinkingLoopTimeoutMs"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-maxInterventions",children:["Max interventions",e.jsx("span",{className:"meta-badge",children:"default: 1"})]}),e.jsx("input",{id:"bg-maxInterventions",type:"number",min:1,max:3,value:r.backgroundMaxInterventions??1,onChange:p=>o(x=>({...x,backgroundMaxInterventions:Math.max(1,Math.min(3,parseInt(p.target.value,10)||1))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundMaxInterventions"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:l,children:[e.jsx(bs,{size:14})," Save plugin options"]}),e.jsx(U,{variant:"secondary",size:"sm",onClick:c,children:"Cleanup old instances (>7 days)"})]}),e.jsx("div",{className:"form-row",children:e.jsxs("small",{children:["Plugin options are read at startup. Save changes and run ",e.jsx("code",{children:"bizar update"})," to apply."]})})]})]})}function Vf({workspaceId:t,onInviteCreated:s}){const n=Ze(),[a,i]=f.useState(""),[r,o]=f.useState("editor"),[l,c]=f.useState([]),[h,m]=f.useState(!1),[d,u]=f.useState(!1),[p,x]=f.useState(null),[v,j]=f.useState(null);f.useEffect(()=>{g()},[t]);async function g(){m(!0);try{const $=await H.get(`/workspaces/${t}/invites`);c($.invites||[])}catch{}finally{m(!1)}}async function b($){if($.preventDefault(),!!a.trim()){u(!0),j(null);try{const M=await H.post(`/workspaces/${t}/invites`,{email:a.trim(),role:r});i(""),await g(),s==null||s(),n.open({title:"Invite Link Created",children:e.jsxs("div",{className:"invite-link-dialog",children:[e.jsxs("p",{children:["Share this link with ",e.jsx("strong",{children:a})," to invite them as ",e.jsx("strong",{children:r}),":"]}),e.jsxs("div",{className:"invite-url-box",children:[e.jsx(Ju,{size:14}),e.jsx("input",{type:"text",readOnly:!0,value:M.url,onClick:z=>z.target.select()}),e.jsx("button",{type:"button",className:"invite-copy-btn",onClick:()=>{navigator.clipboard.writeText(M.url).catch(()=>{}),x(M.token),setTimeout(()=>x(null),2e3)},children:p===M.token?e.jsx(Ht,{size:14}):e.jsx(Vt,{size:14})})]}),e.jsx("p",{className:"invite-url-note",children:"This link expires in 7 days."})]}),footer:e.jsx(U,{variant:"primary",size:"sm",onClick:()=>n.close(),children:"Done"})})}catch(M){j(M.message||"Failed to create invite")}finally{u(!1)}}}async function y($){if(confirm("Revoke this invite?"))try{await H.del(`/workspaces/${t}/invites/${$}`),await g()}catch(M){j(M.message||"Failed to revoke invite")}}function w($,M){navigator.clipboard.writeText($).catch(()=>{}),x(M),setTimeout(()=>x(null),2e3)}const S={admin:"role-admin",editor:"role-editor",viewer:"role-viewer"};return e.jsxs("div",{className:"invite-dialog",children:[e.jsxs("form",{className:"invite-form",onSubmit:b,children:[e.jsxs("div",{className:"invite-form-row",children:[e.jsxs("div",{className:"invite-form-field",children:[e.jsx("label",{htmlFor:"invite-email",children:"Email address"}),e.jsx("input",{id:"invite-email",type:"email",value:a,onChange:$=>i($.target.value),placeholder:"colleague@example.com",required:!0})]}),e.jsxs("div",{className:"invite-form-field invite-form-field-role",children:[e.jsx("label",{htmlFor:"invite-role",children:"Role"}),e.jsxs("select",{id:"invite-role",value:r,onChange:$=>o($.target.value),children:[e.jsx("option",{value:"viewer",children:"Viewer"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsxs(U,{type:"submit",variant:"primary",size:"sm",loading:d,disabled:!a.trim(),children:[e.jsx(eh,{size:13}),"Invite"]})]}),v&&e.jsx("p",{className:"invite-error",children:v})]}),e.jsxs("div",{className:"invite-list",children:[e.jsx("h4",{className:"invite-list-title",children:"Pending Invites"}),h&&e.jsx("p",{className:"invite-loading",children:"Loading..."}),!h&&l.length===0&&e.jsx("p",{className:"invite-empty",children:"No pending invites"}),l.map($=>e.jsxs("div",{className:"invite-item",children:[e.jsxs("div",{className:"invite-item-info",children:[e.jsx("span",{className:"invite-item-email",children:$.email}),e.jsx("span",{className:se("invite-item-role",S[$.role]),children:$.role})]}),e.jsxs("div",{className:"invite-item-actions",children:[e.jsx("button",{type:"button",className:"invite-action-btn",title:"Copy invite link",onClick:()=>{const M=`${window.location.origin}/accept-invite?token=${$.token}`;w(M,$.token)},children:p===$.token?e.jsx(Ht,{size:13}):e.jsx(Vt,{size:13})}),e.jsx("button",{type:"button",className:"invite-action-btn invite-action-revoke",title:"Revoke invite",onClick:()=>y($.token),children:e.jsx(Fe,{size:13})})]})]},$.token))]})]})}const Uf={admin:Iu,editor:ss,viewer:ks},qf={admin:"role-admin",editor:"role-editor",viewer:"role-viewer"};function Wf(){const[t,s]=f.useState([]),[n,a]=f.useState(!0),[i,r]=f.useState(!1),[o,l]=f.useState(""),[c,h]=f.useState(null),[m,d]=f.useState(null),u=Ze();f.useEffect(()=>{p()},[]);async function p(){a(!0);try{const g=await H.get("/workspaces");s(g.workspaces||[])}catch{h("Failed to load workspaces")}finally{a(!1)}}async function x(g){if(g.preventDefault(),!!o.trim()){r(!0);try{await H.post("/workspaces",{name:o.trim()}),l(""),await p()}catch(b){h(b.message||"Failed to create workspace")}finally{r(!1)}}}async function v(g,b){if(confirm(`Delete workspace "${b}"?`)&&confirm("This cannot be undone."))try{await H.del(`/workspaces/${g}`),await p()}catch(y){h(y.message||"Failed to delete workspace")}}function j(g){navigator.clipboard.writeText(`${window.location.origin}/accept-invite?workspace=${g}`).catch(()=>{}),d(g),setTimeout(()=>d(null),2e3)}return n?e.jsx("div",{className:"settings-section-loading",children:"Loading workspaces..."}):e.jsxs("div",{className:"settings-section settings-section-workspaces",children:[e.jsx("h3",{className:"settings-section-title",children:"Workspaces"}),e.jsx("p",{className:"settings-section-desc",children:"Workspaces let you share access with team members. Each workspace has its own members, settings, and data."}),c&&e.jsxs("div",{className:"settings-section-error",children:[e.jsx("span",{children:c}),e.jsx("button",{onClick:()=>h(null),children:"×"})]}),e.jsxs("form",{className:"workspace-create-form",onSubmit:x,children:[e.jsx("input",{type:"text",placeholder:"New workspace name",value:o,onChange:g=>l(g.target.value),maxLength:64}),e.jsxs(U,{type:"submit",variant:"primary",size:"sm",loading:i,disabled:!o.trim(),children:[e.jsx(qe,{size:13}),"Create"]})]}),e.jsxs("div",{className:"workspace-list",children:[t.length===0&&e.jsx("p",{className:"workspace-list-empty",children:"No workspaces yet. Create one above."}),t.map(({workspace:g,role:b})=>{const y=Uf[b]||ks;return e.jsxs("div",{className:"workspace-item",children:[e.jsxs("div",{className:"workspace-item-info",children:[e.jsx("div",{className:"workspace-item-icon",children:e.jsx(tn,{size:16})}),e.jsxs("div",{className:"workspace-item-details",children:[e.jsx("span",{className:"workspace-item-name",children:g.name}),e.jsxs("span",{className:se("workspace-item-role",qf[b]),children:[e.jsx(y,{size:11}),b]})]})]}),e.jsxs("div",{className:"workspace-item-actions",children:[e.jsx(U,{variant:"ghost",size:"sm",iconOnly:!0,title:"Copy invite link",onClick:()=>j(g.id),children:m===g.id?e.jsx(Ht,{size:13}):e.jsx(Vt,{size:13})}),b==="admin"&&e.jsx(U,{variant:"ghost",size:"sm",iconOnly:!0,title:"Manage members",onClick:()=>{u.open({title:`Manage "${g.name}"`,children:e.jsx(Vf,{workspaceId:g.id,onInviteCreated:()=>p()}),width:520})},children:e.jsx(tn,{size:13})}),b==="admin"&&t.length>1&&e.jsx(U,{variant:"ghost",size:"sm",iconOnly:!0,title:"Delete workspace",onClick:()=>v(g.id,g.name),children:e.jsx(Fe,{size:13})})]})]},g.id)})]})]})}const Gf=[{id:"theme",label:"Theme"},{id:"updates",label:"Updates"},{id:"layout",label:"Layout"},{id:"general",label:"General"},{id:"env-vars",label:"Env Vars"},{id:"network",label:"Network"},{id:"notifications",label:"Notifications"},{id:"auth",label:"Auth"},{id:"agents",label:"Agents"},{id:"dashboard",label:"Dashboard"},{id:"background",label:"Background"},{id:"system-llm",label:"System LLM"},{id:"headroom",label:"Headroom"},{id:"activity-log",label:"Activity"},{id:"about",label:"About"},{id:"workspaces",label:"Workspaces"}],Yf=[{id:"theme",label:"Theme",fields:[{key:"theme.presets",label:"Accent presets",section:"theme"},{key:"theme.accent",label:"Accent color",section:"theme"},{key:"theme.success",label:"Success color",section:"theme"},{key:"theme.warning",label:"Warning color",section:"theme"},{key:"theme.error",label:"Error color",section:"theme"},{key:"theme.info",label:"Info color",section:"theme"},{key:"theme.fontFamily",label:"Font family",section:"theme"},{key:"theme.fontSize",label:"Font size",section:"theme"},{key:"theme.compactMode",label:"Compact mode",section:"theme"},{key:"theme.animations",label:"Animations",section:"theme"}]},{id:"updates",label:"Updates",fields:[{key:"updates.channel",label:"Update channel",section:"updates"}]},{id:"layout",label:"Layout",fields:[{key:"ui.layout",label:"UI layout",section:"layout"},{key:"ui.showHeader",label:"Show header",section:"layout"},{key:"ui.showStatusBar",label:"Show status bar",section:"layout"},{key:"ui.defaultTab",label:"Default tab",section:"layout"}]},{id:"general",label:"General",fields:[{key:"defaultAgent",label:"Default agent",section:"general"},{key:"defaultModel",label:"Model override",section:"general"}]},{id:"env-vars",label:"Environment Variables",fields:[{key:"env-vars.count",label:"Env var count",section:"env-vars"}]},{id:"network",label:"Network",fields:[{key:"tailscale.enabled",label:"Tailscale Serve",section:"network"},{key:"tailscale.port",label:"Tailscale port",section:"network"},{key:"tailscale.https",label:"Tailscale HTTPS",section:"network"},{key:"tailscale.hostname",label:"Tailscale hostname",section:"network"}]},{id:"notifications",label:"Notifications",fields:[{key:"notifications.onAgentComplete",label:"Notify on agent complete",section:"notifications"},{key:"notifications.onPlanApproval",label:"Notify on plan approval",section:"notifications"}]},{id:"auth",label:"Auth",fields:[{key:"auth.enabled",label:"Auth enabled",section:"auth"},{key:"auth.loopback",label:"Loopback mode",section:"auth"},{key:"auth.token",label:"Auth token",section:"auth"}]},{id:"agents",label:"Agents",fields:[{key:"agents.maxParallel",label:"Max parallel agents",section:"agents"},{key:"agents.stuckThresholdMs",label:"Stuck threshold",section:"agents"},{key:"agents.autoRestart",label:"Auto restart",section:"agents"},{key:"workflow.artifactsEnabled",label:"Artifacts enabled",section:"agents"},{key:"workflow.agentsDecideAutonomously",label:"Autonomous decisions",section:"agents"}]},{id:"dashboard",label:"Dashboard",fields:[{key:"dashboard.autoLaunchWeb",label:"Auto-launch web",section:"dashboard"},{key:"dashboard.projectsDirectory",label:"Projects directory",section:"dashboard"},{key:"dashboard.allowedRoots",label:"Allowed roots",section:"dashboard"}]},{id:"background",label:"Background",fields:[{key:"service.enabled",label:"Background service",section:"background"},{key:"service.autostart",label:"Auto-start service",section:"background"}]},{id:"system-llm",label:"System LLM",fields:[{key:"systemLlm.enabled",label:"System LLM enabled",section:"system-llm"}]},{id:"headroom",label:"Headroom",fields:[{key:"headroom.enabled",label:"Headroom enabled",section:"headroom"},{key:"headroom.port",label:"Headroom port",section:"headroom"},{key:"headroom.budget",label:"Headroom budget",section:"headroom"},{key:"headroom.backend",label:"Headroom backend",section:"headroom"}]},{id:"activity-log",label:"Activity",fields:[{key:"activity.log",label:"Activity log",section:"activity-log"}]},{id:"about",label:"About",fields:[{key:"about.version",label:"Version",section:"about"},{key:"about.homepage",label:"Homepage",section:"about"},{key:"about.license",label:"License",section:"about"}]}];function Xf({settings:t,refreshSnapshot:s,settingsMode:n,settingsActiveSection:a,setSettingsActiveSection:i,setActiveTab:r}){const o=fe(),[l,c]=f.useState(t),[h,m]=f.useState(!1),[d,u]=f.useState(!1),[p,x]=f.useState(null),[v,j]=f.useState({port:4321,https:!0,hostname:""}),[g,b]=f.useState(null),y=()=>{r("overview")};f.useEffect(()=>{c(t),m(!1),t.theme&&fs(t.theme)},[t]),f.useEffect(()=>{p&&j({port:p.settings.port,https:p.settings.https!==!1,hostname:p.settings.hostname||""})},[p]),f.useEffect(()=>{H.get("/tailscale/status").then(x).catch(()=>{})},[]);const w=f.useRef(null),S=f.useCallback(async(D,G)=>{c(ee=>({...ee,[D]:G})),w.current&&clearTimeout(w.current),w.current=setTimeout(async()=>{try{await H.put("/settings",{...l,[D]:G})}catch(ee){At.error("autoSave failed",ee)}},300)},[l]);f.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const $=D=>{c(G=>{const ee={...G,theme:{...G.theme,...D}};return fs(ee.theme),ee}),m(!0)},M=D=>{c(G=>({...G,ui:{...G.ui,...D}})),m(!0)},z=(D,G)=>{c(ee=>({...ee,[D]:G})),m(!0)},A=D=>{c(G=>({...G,notifications:{...G.notifications,...D}})),m(!0)},k=D=>{c(G=>({...G,agents:{...G.agents,...D}})),m(!0)},C=D=>{c(G=>({...G,dashboard:{...G.dashboard,...D}})),m(!0)},[_,L]=f.useState(()=>{if(typeof window>"u")return null;const D=window.location.hash.replace(/^#settings-/,"");return Gf.some(G=>G.id===D)?D:null}),N=n?a??null:_,T=D=>{if(n)i==null||i(D);else{L(D);try{if(history.replaceState(null,"",D?`#settings-${D}`:window.location.pathname),D){const G=document.getElementById(`settings-${D}`);G&&G.scrollIntoView({behavior:"smooth",block:"start"})}else window.scrollTo({top:0,behavior:"smooth"})}catch{}}if(D){const G=document.getElementById(`settings-${D}`);G&&G.scrollIntoView({behavior:"smooth",block:"start"})}else window.scrollTo({top:0,behavior:"smooth"})},I=async()=>{try{p!=null&&p.settings.enabled?(await H.post("/tailscale/disable"),o.success("Tailscale serve disabled.")):(await H.post("/tailscale/enable",{port:v.port||4321,https:v.https,hostname:v.hostname||""}),o.success("Tailscale serve enabled.")),x(await H.get("/tailscale/status"))}catch(D){o.error(`Tailscale failed: ${D.message}`)}},R=async()=>{u(!0);try{const D=await H.put("/settings",l);c(D.data),m(!1),Ys(D.data.theme),fs(D.data.theme),o.success("Settings saved."),await s()}catch(D){o.error(`Save failed: ${D.message}`)}finally{u(!1)}},B=async()=>{try{const D=await H.get("/settings");c(D.data),m(!1),Ys(D.data.theme),fs(D.data.theme),o.info("Settings reloaded.",1500)}catch(D){o.error(`Reload failed: ${D.message}`)}},E=async()=>{if(confirm("Reset all settings to defaults?"))try{const D=await H.post("/settings/reset");c(D.data),m(!1),Ys(D.data.theme),fs(D.data.theme),o.success("Settings reset."),await s()}catch(D){o.error(`Reset failed: ${D.message}`)}},P={settings:l,patchTheme:$,patchUi:M,patchTop:z,patchNotifications:A,patchAgents:k,patchDashboard:C},W=l.about||{version:"3.0.4",homepage:"https://github.com/DrB0rk/BizarHarness",license:"MIT"},V=N===null,K=D=>N===D;return e.jsxs("div",{className:"view view-settings",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(wi,{size:18})," Settings"]}),e.jsxs("p",{className:"view-subtitle",children:["Personal preferences. Changes are saved to ",e.jsx("code",{children:"~/.config/bizar/settings.json"}),"."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(U,{variant:"ghost",size:"sm",onClick:E,children:[e.jsx(Bo,{size:14})," Reset"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:B,children:[e.jsx(xe,{size:14})," Reload"]}),e.jsxs(U,{variant:"primary",size:"sm",disabled:!h||d,onClick:R,children:[d?e.jsx("span",{className:"btn-spinner"}):e.jsx(bs,{size:14}),d?"Saving…":"Save"]})]})]}),n&&e.jsxs("div",{className:"settings-mode-banner",children:[e.jsx("span",{children:"You're in settings mode. All sections are visible in the sidebar."}),e.jsx(U,{variant:"secondary",size:"sm",onClick:y,children:"← Back to main view"})]}),e.jsx(Rf,{sections:Yf,onJump:T}),e.jsxs("div",{className:se("settings-grid",N&&"settings-grid-filtered"),"data-active-section":N||void 0,children:[(V||K("theme"))&&e.jsx("div",{id:"settings-theme",children:e.jsx(Df,{...P})}),(V||K("updates"))&&e.jsx("div",{id:"settings-updates",children:e.jsx(pu,{})}),(V||K("layout"))&&e.jsx("div",{id:"settings-general",children:e.jsx(xu,{...P,autoSave:S})}),(V||K("env-vars"))&&e.jsx("div",{id:"settings-env-vars",children:e.jsx(gu,{})}),(V||K("network")||K("service")||K("tailscale"))&&e.jsx("div",{id:"settings-network",children:e.jsx(Ff,{tailscale:p,tailscaleDraft:v,setTailscaleDraft:j,onTailscaleToggle:I})}),(V||K("network")||K("tailscale"))&&e.jsx(yu,{initialStatus:p}),(V||K("notifications"))&&e.jsx("div",{id:"settings-notifications",children:e.jsx(Of,{...P})}),(V||K("auth"))&&e.jsx("div",{id:"settings-auth",children:e.jsx(Bf,{settings:l,authStatus:g,setAuthStatus:b})}),(V||K("agents")||K("dashboard")||K("background"))&&e.jsx("div",{id:"settings-agents",children:e.jsx(Hf,{...P,autoSave:S})}),(V||K("system-llm"))&&e.jsx("div",{id:"settings-system-llm",children:e.jsx(vu,{...P})}),(V||K("headroom"))&&e.jsx("div",{id:"settings-headroom",children:e.jsx(ju,{settings:l,setSettings:c,setDirty:m})}),(V||K("activity-log")||K("about"))&&e.jsx("div",{id:"settings-activity-log",children:e.jsx(bu,{about:W})}),(V||K("workspaces"))&&e.jsx("div",{id:"settings-workspaces",children:e.jsx(Wf,{})})]})]})}const kr=rt.memo(Xf);function Kf({snapshot:t,refreshSnapshot:s}){const n=fe(),a=Ze(),[i,r]=f.useState(Array.isArray(t.mods)?t.mods:[]),[o,l]=f.useState(!0),[c,h]=f.useState(null),[m,d]=f.useState([]),[u,p]=f.useState(null),[x,v]=f.useState(!1),[j,g]=f.useState(null),[b,y]=f.useState(!1),[w,S]=f.useState({}),$=async()=>{var N,T,I;y(!0);try{const R=await H.get("/mods/registry");g({source:((N=R.registry)==null?void 0:N.source)||"",version:(T=R.registry)==null?void 0:T.version,updatedAt:(I=R.registry)==null?void 0:I.updatedAt,mods:R.mods||[]})}catch(R){g({source:"",mods:[],error:R.message})}finally{y(!1)}},M=async N=>{S(T=>({...T,[N]:!0}));try{const T=await H.post("/mods",{id:N});r(I=>[...I.filter(R=>R.id!==T.id),T]),n.success(`Mod "${T.id}" installed from registry.`),await s()}catch(T){n.error(`Install failed: ${T.message}`)}finally{S(T=>({...T,[N]:!1}))}},z=async(N,T=!1)=>{S(I=>({...I,[N]:!0}));try{const I=await H.post(`/mods/${encodeURIComponent(N)}/upgrade`,{backup:T});r(B=>[...B.filter(E=>E.id!==I.mod.id),I.mod]);const R=I.backupPath?` (backup at ${I.backupPath})`:"";n.success(`Mod "${N}" upgraded v${I.from} → v${I.to}${R}.`),await s()}catch(I){n.error(`Upgrade failed: ${I.message}`)}finally{S(I=>({...I,[N]:!1}))}},A=async()=>{try{const N=await H.get("/mods");r(N.mods||[]);try{const T=await H.get("/mods/views");d(T.views||[])}catch{d([])}}catch(N){n.error(`Mods load failed: ${N.message}`)}finally{l(!1)}};f.useEffect(()=>{A()},[]),f.useEffect(()=>{Array.isArray(t.mods)&&t.mods!==i&&r(t.mods)},[t.mods]);const k=()=>{let N=null;a.open({title:"Install mod",children:e.jsxs("div",{children:[e.jsxs("p",{className:"muted",children:["Provide the absolute path to a mod folder (one that contains a ",e.jsx("code",{children:"mod.json"}),"). The folder will be copied to"," ",e.jsx("code",{children:"~/.config/bizar/mods/<id>/"}),"."]}),e.jsx("label",{className:"field-label",htmlFor:"install-mod-path",children:"Path"}),e.jsx("input",{id:"install-mod-path",ref:T=>N=T,className:"input",type:"text",placeholder:"/path/to/my-mod",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Cancel"}),e.jsx(U,{variant:"primary",onClick:async()=>{const T=((N==null?void 0:N.value)||"").trim();if(!T){n.warning("Path is required.");return}try{const I=await H.post("/mods",{path:T});r(R=>[...R,I]),n.success(`Mod "${I.id}" installed.`),a.close(),await s()}catch(I){n.error(`Install failed: ${I.message}`)}},children:"Install"})]})})},C=async N=>{if(confirm(`Uninstall mod "${N}"? This removes the folder from ~/.config/bizar/mods/.`))try{await H.del(`/mods/${encodeURIComponent(N)}`),r(T=>T.filter(I=>I.id!==N)),c===N&&h(null),n.success("Mod uninstalled.")}catch(T){n.error(`Uninstall failed: ${T.message}`)}},_=async N=>{try{const T=await H.put(`/mods/${encodeURIComponent(N.id)}`,{enabled:!N.enabled});r(I=>I.map(R=>R.id===N.id?T:R)),n.success(`Mod ${T.enabled?"enabled":"disabled"}.`)}catch(T){n.error(`Toggle failed: ${T.message}`)}},L=i.find(N=>N.id===c)||null;return o?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}):e.jsxs("div",{className:"view view-mods",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Ns,{size:18})," Mods (",i.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["Extensions installed in ",e.jsx("code",{children:"~/.config/bizar/mods/"}),". Mods can add agents, commands, routes, and views."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:A,children:[e.jsx(xe,{size:14})," Refresh"]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:k,children:[e.jsx(qe,{size:14})," Install mod"]})]})]}),i.length===0?e.jsx(_e,{icon:e.jsx(Ns,{size:32}),title:"No mods installed",message:"Mods are folders with a mod.json. Install one to extend Bizar with custom agents, commands, and views."}):e.jsxs("div",{className:"mods-layout",children:[e.jsx("div",{className:"mods-list",children:i.map(N=>e.jsxs("div",{className:se("mod-list-item",c===N.id&&"mod-list-item-active"),onClick:()=>h(N.id),children:[e.jsxs("div",{className:"mod-list-item-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mod-list-item-name",children:N.name}),e.jsxs("div",{className:"mod-list-item-meta",children:["v",N.version," · ",N.type," · ",N.author]})]}),e.jsxs("div",{className:"mod-list-item-actions",onClick:T=>T.stopPropagation(),children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Toggle enabled",title:N.enabled?"Disable":"Enable",onClick:()=>_(N),children:e.jsx(Ho,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Uninstall",title:"Uninstall",onClick:()=>C(N.id),children:e.jsx(Fe,{size:12})})]})]}),e.jsx("div",{className:"mod-list-item-desc ellipsis-2",title:N.description,children:N.description}),e.jsx("div",{className:"mod-list-item-status",children:e.jsx("span",{className:`mod-mini-pill ${N.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:N.enabled?"enabled":"disabled"})})]},N.id))}),L&&e.jsx(Zf,{mod:L})]}),e.jsxs(ne,{className:"mods-registry-card",children:[e.jsxs("button",{type:"button",className:"mods-registry-head","aria-expanded":x,"aria-controls":"mods-registry-body",onClick:()=>{!j&&!b&&$(),v(N=>!N)},children:[e.jsx(Qs,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"mods-registry-title",children:"Mod registry"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:j!=null&&j.mods?`${j.mods.length} available`:"click to browse"}),e.jsx("span",{className:"mods-registry-spacer"}),x?e.jsx(ct,{size:14,"aria-hidden":!0}):e.jsx(Ut,{size:14,"aria-hidden":!0})]}),x&&e.jsx("div",{id:"mods-registry-body",className:"mods-registry-body",children:b?e.jsx("div",{className:"muted",style:{padding:12,fontSize:12},children:"Loading registry…"}):j!=null&&j.error?e.jsxs("div",{className:"mods-registry-error",children:[e.jsx(en,{size:12})," Could not load registry: ",j.error]}):!j||j.mods.length===0?e.jsx("div",{className:"muted",style:{padding:12,fontSize:12},children:"No mods listed in the registry yet."}):e.jsxs(e.Fragment,{children:[j.source&&e.jsxs("div",{className:"muted",style:{fontSize:11,marginBottom:8},children:["Source: ",e.jsx("code",{children:j.source})]}),e.jsx("div",{className:"mods-registry-grid",children:j.mods.map(N=>{const T=i.some(R=>R.id===N.id),I=!!w[N.id];return e.jsxs("div",{className:"mod-registry-card",children:[e.jsxs("div",{className:"mod-registry-card-head",children:[e.jsx("div",{className:"mod-registry-card-name",children:N.name}),N.latest&&e.jsxs("span",{className:se("mod-registry-version",N.upgradeAvailable&&"mod-registry-version-upgrade"),children:["v",N.latest,N.upgradeAvailable?" ↑":""]})]}),N.description&&e.jsx("div",{className:"mod-registry-card-desc",children:N.description}),e.jsxs("div",{className:"mod-registry-card-meta",children:[N.author&&e.jsxs("span",{className:"muted",children:["by ",N.author]}),N.homepage&&e.jsx("a",{href:N.homepage,target:"_blank",rel:"noopener noreferrer",className:"mod-registry-link",children:"homepage"})]}),(N.permissions||[]).length>0&&e.jsxs("div",{className:"mod-registry-perms",children:[e.jsx(en,{size:10}),(N.permissions||[]).slice(0,4).map(R=>e.jsx("span",{className:"mod-registry-perm",children:R},R)),(N.permissions||[]).length>4&&e.jsxs("span",{className:"mod-registry-perm-more",children:["+",N.permissions.length-4]})]}),e.jsxs("div",{className:"mod-registry-card-actions",children:[!T&&e.jsx(U,{variant:"primary",size:"sm",disabled:I,onClick:()=>M(N.id),title:"Install from registry",children:I?e.jsx(ye,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{size:12})," Install"]})}),T&&N.upgradeAvailable&&e.jsx(U,{variant:"primary",size:"sm",disabled:I,onClick:()=>z(N.id),title:`Upgrade from v${N.installedVersion||"?"} to v${N.upgradeAvailable}`,children:I?e.jsx(ye,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{size:12})," Upgrade to v",N.upgradeAvailable]})}),T&&!N.upgradeAvailable&&e.jsxs(U,{variant:"ghost",size:"sm",disabled:!0,title:`Installed v${N.installedVersion||"?"}`,children:["Installed v",N.installedVersion||"?"]})]})]},N.id)})})]})})]}),m.length>0&&e.jsxs(ne,{className:"mod-views-hint",children:[e.jsxs(de,{children:[e.jsx(Qs,{size:14})," Mod views"]}),e.jsxs(ue,{children:[m.length," mod-supplied view",m.length===1?"":"s"," are now available in the sidebar navigation. Look for the ",e.jsx("strong",{children:"Mods"})," section at the bottom of the sidebar."]})]}),u&&e.jsxs("div",{className:"mod-iframe-panel",children:[e.jsxs("div",{className:"mod-iframe-header",children:[e.jsxs("span",{children:["Mod view — ",e.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:u})]}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close iframe",onClick:()=>p(null),children:e.jsx(Re,{size:14})})]}),e.jsx("iframe",{src:u,className:"mod-iframe",title:"Mod view",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"})]})]})}function Zf({mod:t}){const s=fe(),[n,a]=f.useState(null),[i,r]=f.useState(!1),[o,l]=f.useState(!1),[c,h]=f.useState(null),m=async()=>{r(!0);try{const u=await H.get(`/mods/${t.id}/instructions`);a(u),l(!0)}catch(u){s.error(`Failed to load instructions: ${u.message}`)}finally{r(!1)}},d=async()=>{try{const u=await H.post(`/mods/${t.id}/instructions/reinstall`,{});s.success(`Reinstalled: ${u.counts.agents} agents, ${u.counts.commands} commands, ${u.counts.skills} skills, ${u.counts.instructions} instructions.`),await m()}catch(u){s.error(`Reinstall failed: ${u.message}`)}};return e.jsxs(ne,{className:"mod-details",children:[e.jsxs(de,{children:[e.jsx(Ve,{size:14})," Mod details — ",t.name]}),e.jsx(ue,{children:e.jsx("code",{children:t.path})}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"ID"}),e.jsx("dd",{className:"mono",children:t.id}),e.jsx("dt",{children:"Version"}),e.jsx("dd",{className:"mono",children:t.version}),e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"mono",children:t.type}),e.jsx("dt",{children:"Author"}),e.jsx("dd",{className:"mono",children:t.author||"—"}),e.jsx("dt",{children:"Bizar"}),e.jsx("dd",{className:"mono",children:t.bizar||"*"}),e.jsx("dt",{children:"Enabled"}),e.jsx("dd",{children:t.enabled?"yes":"no"}),e.jsx("dt",{children:"Permissions"}),e.jsxs("dd",{children:[(t.permissions||[]).map(u=>e.jsx("span",{className:"tag",children:u},u)),(t.permissions||[]).length===0&&e.jsx("span",{className:"muted",children:"(none)"})]})]}),e.jsxs("div",{className:"mod-files",children:[e.jsx("div",{className:"muted",children:"Files"}),e.jsx("ul",{children:(t.files||[]).map(u=>e.jsxs("li",{children:[e.jsx("span",{className:"mod-file-cat",children:u.category}),e.jsx("span",{className:"mono",children:u.path})]},u.path))})]}),e.jsxs("div",{className:"mod-instructions",children:[e.jsxs("button",{type:"button",className:"mod-instructions-head","aria-expanded":o,"aria-controls":`mod-instructions-body-${t.id}`,onClick:()=>{!n&&!i&&m(),l(u=>!u)},children:[e.jsx(Ou,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Installed instructions"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:n?`${n.total} files`:"click to view"}),e.jsx("span",{className:"mod-instructions-spacer"}),o?e.jsx(ct,{size:14,"aria-hidden":!0}):e.jsx(Ut,{size:14,"aria-hidden":!0})]}),o&&n&&e.jsxs("div",{id:`mod-instructions-body-${t.id}`,className:"mod-instructions-body",children:[n.agents.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(fh,{size:11})," Agents (",n.agents.length,")"]}),n.agents.map(u=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(p=>p===u.filename?null:u.filename),children:[e.jsx("span",{className:"mono",children:u.filename}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",u.fullPath]})]}),c===u.filename&&e.jsx("pre",{className:"mod-instructions-content",children:u.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},u.filename))]}),n.commands.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(Cs,{size:11})," Commands (",n.commands.length,")"]}),n.commands.map(u=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(p=>p===u.filename?null:u.filename),children:[e.jsx("span",{className:"mono",children:u.filename}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",u.fullPath]})]}),c===u.filename&&e.jsx("pre",{className:"mod-instructions-content",children:u.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},u.filename))]}),n.skills.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(Mi,{size:11})," Skills (",n.skills.length,")"]}),n.skills.map(u=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(p=>p===u.name?null:u.name),children:[e.jsx("span",{className:"mono",children:u.name}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",u.fullPath]})]}),c===u.name&&e.jsx("pre",{className:"mod-instructions-content",children:u.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},u.name))]}),n.total===0&&e.jsxs("div",{className:"muted",style:{padding:8,fontSize:12},children:["This mod did not install any instruction files. Mods install instructions by shipping a top-level ",e.jsx("code",{children:"INSTRUCTIONS.md"}),", an ",e.jsx("code",{children:"agents/"})," directory, a ",e.jsx("code",{children:"commands/"})," directory, or a ",e.jsx("code",{children:"skills/"})," directory."]}),e.jsx("div",{className:"mod-instructions-actions",children:e.jsxs(U,{variant:"ghost",size:"sm",onClick:d,children:[e.jsx(xe,{size:11})," Reinstall from mod folder"]})})]})]})]})}function Qf({viewId:t,reloadKey:s,setActiveTab:n}){const a=fe(),[i,r]=f.useState(null),[o,l]=f.useState(!0),[c,h]=f.useState(0);if(f.useEffect(()=>{let m=!1;return(async()=>{try{const d=await H.get("/mods/views");if(m)return;const u=(d.views||[]).find(p=>p.id===t);r(u||null)}catch(d){a.error(`Failed to load mod view: ${d.message}`)}finally{m||l(!1)}})(),()=>{m=!0}},[t,a]),o)return e.jsx(_e,{title:"Loading mod view…"});if(!i)return e.jsx(_e,{title:"Mod view not found",message:`No view with id "${t}" is currently installed.`,action:e.jsx(U,{onClick:()=>n("mods"),variant:"primary",size:"sm",children:"Open Mods"})});if(i.kind==="iframe"){const m=`/api/mods/${i.modId}/web/index.html?t=${c+(s||0)}`;return e.jsxs("div",{className:"mod-view-iframe-pane",children:[e.jsxs("div",{className:"mod-view-iframe-header",children:[e.jsxs("span",{className:"mod-view-iframe-label",children:[e.jsx(Qs,{size:14}),i.label,e.jsxs("span",{className:"muted",style:{fontSize:11,fontWeight:400},children:["by ",i.modId]})]}),e.jsxs("div",{className:"mod-view-iframe-actions",children:[e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>h(d=>d+1),title:"Reload this view",children:[e.jsx(xe,{size:11})," Reload"]}),e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"icon-btn",title:"Open in new tab",children:e.jsx(Is,{size:12})})]})]}),e.jsx("iframe",{src:m,className:"mod-view-iframe",title:i.label},c+(s||0))]})}if(i.component){const m=i.component,d=i.modId,u=f.lazy(()=>ru(()=>import(`/api/mods/${encodeURIComponent(d)}/views/${encodeURIComponent(m)}`),[]).then(p=>({default:p.default??(()=>null)})));return e.jsxs("div",{className:"mod-view-tab-pane",children:[e.jsx("div",{className:"mod-view-iframe-header",children:e.jsxs("span",{className:"mod-view-iframe-label",children:[e.jsx(Js,{size:14}),i.label,e.jsxs("span",{className:"muted",style:{fontSize:11,fontWeight:400},children:["by ",i.modId]})]})}),e.jsx("div",{className:"mod-view-tab-body",children:e.jsx(Jf,{modId:i.modId,component:i.component,children:e.jsx(f.Suspense,{fallback:e.jsxs("div",{style:{padding:24},children:[e.jsx(ye,{size:"md"})," ",e.jsx("span",{className:"muted",children:"Loading mod view…"})]}),children:e.jsx(u,{})})})})]})}return e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(Js,{size:14})," ",i.label]}),e.jsxs(ue,{children:["by ",i.modId]}),i.description&&e.jsx("p",{className:"muted",style:{marginTop:8},children:i.description}),e.jsxs("p",{className:"muted",style:{fontSize:12,marginTop:12},children:["This mod declared a tab view but did not provide a component path in views/registry.json. Add a ",e.jsx("code",{children:"component"})," field (e.g. ",e.jsx("code",{children:'"MyView.js"'}),") and ship the file under ",e.jsx("code",{children:"views/"}),"."]}),e.jsx("div",{style:{marginTop:12},children:e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>n("mods"),children:"Open Mods page"})})]})}class Jf extends f.Component{constructor(){super(...arguments);Ps(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(){}render(){return this.state.error?e.jsxs("div",{className:"mod-view-error",children:[e.jsx(Ue,{size:16}),e.jsx("strong",{children:"Failed to render mod view"}),e.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:6},children:[this.props.modId," → ",this.props.component,": ",this.state.error.message]})]}):this.props.children}}function ep(t){if(t.type==="cron"&&t.schedule)return`cron: ${t.schedule}`;if(t.type==="interval"){const n=(t.intervalMs||0)/1e3;return n>=3600?`every ${n/3600}h`:n>=60?`every ${n/60}m`:`every ${n}s`}return t.type}function tp({template:t,onUse:s}){return e.jsxs(ne,{className:"schedule-template-card",children:[e.jsxs("div",{className:"schedule-template-header",children:[e.jsx(de,{children:t.name}),t.tags&&t.tags.length>0&&e.jsx("div",{className:"schedule-template-tags",children:t.tags.map(n=>e.jsx("span",{className:"tag",children:n},n))})]}),e.jsx(ue,{children:t.description}),e.jsxs("div",{className:"schedule-template-summary",children:[e.jsx("code",{children:ep(t)})," · ",e.jsx("code",{children:t.action.type})]}),e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>s(t),"aria-label":`Use template: ${t.name}`,children:"Use this template"})]})}const sp=["interval","cron","once"],np=["command","agent","webhook"],ri=[{value:"UTC",label:"UTC"},{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"Europe/London",label:"Europe/London (UK)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}],ap=Array.from({length:12},(t,s)=>s*5),Li=Array.from({length:24},(t,s)=>({value:s,label:s===0?"12 AM":s<12?`${s} AM`:s===12?"12 PM":`${s-12} PM`})),Pi=[{value:"*",label:"Every day"},{value:"0",label:"Sunday"},{value:"1",label:"Monday"},{value:"2",label:"Tuesday"},{value:"3",label:"Wednesday"},{value:"4",label:"Thursday"},{value:"5",label:"Friday"},{value:"6",label:"Saturday"}],ul=[{value:"s",label:"seconds"},{value:"m",label:"minutes"},{value:"h",label:"hours"},{value:"d",label:"days"}];function hl(t){if(typeof t!="string")return null;const s=t.trim().split(/\s+/);if(s.length!==5)return null;const[n,a,,,i]=s,r=parseInt(n,10),o=parseInt(a,10);if(!Number.isFinite(r)||!Number.isFinite(o)||n!==String(r)||a!==String(o))return null;const l=i==="*"?"*":parseInt(i,10);return l===null||i!=="*"&&!Number.isFinite(l)?null:{minute:r,hour:o,dow:i==="*"?"*":String(l)}}function ip(t){if(typeof t!="string")return null;const s=/^(\d+)\s*([smhd])$/i.exec(t.trim());return s?{n:parseInt(s[1],10),unit:s[2].toLowerCase()}:null}function rp(t){var r,o;if(!t)return{name:"",type:"cron",cronMinute:0,cronHour:13,cronDow:"0",showAdvanced:!1,rawCron:"0 13 * * 0",intervalN:30,intervalUnit:"m",onceAt:"",timezone:"UTC",customTimezone:"",actionType:"agent",actionTarget:"",actionPrompt:"",skipIfBudgetLow:!1,maxConcurrent:6,enabled:!0,humanLabel:""};const s=t.type==="cron"?hl(t.schedule):null,n=t.type==="interval"?ip(t.schedule):null,a=t.timezone||"UTC",i=ri.some(l=>l.value===a);return{name:t.name||"",type:t.type,cronMinute:(s==null?void 0:s.minute)??0,cronHour:(s==null?void 0:s.hour)??9,cronDow:(s==null?void 0:s.dow)??"*",showAdvanced:!s,rawCron:t.schedule,intervalN:(n==null?void 0:n.n)??30,intervalUnit:(n==null?void 0:n.unit)??"m",onceAt:t.type==="once"?op(t.schedule):"",timezone:i?a:"Other…",customTimezone:i?"":a,actionType:t.action.type,actionTarget:t.action.target||"",actionPrompt:t.action.prompt||"",skipIfBudgetLow:!!((r=t.budgetCheck)!=null&&r.skipIfBudgetLow),maxConcurrent:Number.isFinite((o=t.budgetCheck)==null?void 0:o.maxConcurrent)?t.budgetCheck.maxConcurrent:6,enabled:t.enabled!==!1,humanLabel:""}}function op(t){if(!t)return"";try{const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=a=>String(a).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())}T${n(s.getHours())}:${n(s.getMinutes())}`}catch{return""}}function lp(t){var n,a,i;if(t.type==="cron"){if(t.showAdvanced)return{schedule:t.rawCron.trim(),humanLabel:t.humanLabel||t.rawCron.trim()};const r=`${t.cronMinute} ${t.cronHour} * * ${t.cronDow}`,o=((n=Pi.find(m=>m.value===t.cronDow))==null?void 0:n.label)||"",l=((a=Li.find(m=>m.value===t.cronHour))==null?void 0:a.label)||`${t.cronHour}`,c=String(t.cronMinute).padStart(2,"0"),h=o==="Every day"?`Every day at ${l.replace(" ","")} (min ${c})`:`Every ${o} at ${l.replace(" ","")} (min ${c})`;return{schedule:r,humanLabel:t.humanLabel||h}}if(t.type==="interval"){const r=((i=ul.find(l=>l.value===t.intervalUnit))==null?void 0:i.label)||t.intervalUnit;return{schedule:`${t.intervalN}${t.intervalUnit}`,humanLabel:t.humanLabel||`Every ${t.intervalN} ${r}`}}return t.onceAt?{schedule:new Date(t.onceAt).toISOString(),humanLabel:t.humanLabel||new Date(t.onceAt).toLocaleString()}:{schedule:"",humanLabel:t.humanLabel||""}}function cp({snapshot:t,refreshSnapshot:s}){var w;const n=fe(),a=Ze(),[i,r]=f.useState(t.schedules||[]),[o,l]=f.useState(!t.schedules),[c,h]=f.useState("schedules"),[m,d]=f.useState([]),[u,p]=f.useState(!1),x=async()=>{try{const S=await H.get("/projects/active/schedules");r(S.schedules||[])}catch(S){n.error(`Schedules load failed: ${S.message}`)}finally{l(!1)}},v=async()=>{p(!0);try{const S=await H.get("/schedules/templates");d(S.templates||[])}catch(S){n.error(`Templates load failed: ${S.message}`)}finally{p(!1)}};f.useEffect(()=>{var S;if((S=t.schedules)!=null&&S.length||t.schedules){r(t.schedules||[]),l(!1);return}x()},[t.schedules]),f.useEffect(()=>{c==="templates"&&m.length===0&&v()},[c]);const j=S=>{a.open({title:S?`Edit schedule: ${S.name}`:"New schedule",width:640,children:e.jsx(dp,{initial:S,onClose:a.close,onSubmitted:async $=>{r(M=>{const z=M.findIndex(k=>k.id===$.id);if(z===-1)return[...M,$];const A=M.slice();return A[z]=$,A}),n.success(S?"Schedule updated.":"Schedule created."),a.close(),await s()},onError:$=>n.error($)})})},g=async S=>{var $;try{const M=await H.post(`/schedules/${encodeURIComponent(S.id)}/run`);n.success(M.ok?"Schedule ran.":`Run failed: ${(($=M.runResult)==null?void 0:$.error)||"unknown"}`),await x()}catch(M){n.error(`Run failed: ${M.message}`)}},b=async S=>{if(confirm(`Delete schedule "${S.name}"?`))try{await H.del(`/schedules/${encodeURIComponent(S.id)}`),r($=>$.filter(M=>M.id!==S.id)),n.success("Schedule deleted.")}catch($){n.error(`Delete failed: ${$.message}`)}},y=async S=>{try{const $=await H.post("/schedules/from-template",{templateId:S.id});r(M=>[...M,$]),h("schedules"),n.success(`Schedule "${$.name}" created from template.`),await s()}catch($){n.error(`Failed to create schedule: ${$.message}`)}};return o?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}):e.jsxs("div",{className:"view view-schedules",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("div",{className:"view-title-row",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Jt,{size:18})," Schedules"]}),e.jsxs("div",{className:"view-section-tabs",children:[e.jsxs("button",{type:"button",className:`tab-btn ${c==="schedules"?"tab-btn-active":""}`,onClick:()=>h("schedules"),children:["Schedules (",i.length,")"]}),e.jsxs("button",{type:"button",className:`tab-btn ${c==="templates"?"tab-btn-active":""}`,onClick:()=>h("templates"),children:[e.jsx(Js,{size:14})," Templates"]})]})]}),e.jsx("p",{className:"view-subtitle",children:c==="schedules"?e.jsxs(e.Fragment,{children:["Recurring tasks for ",e.jsx("strong",{children:((w=t.activeProject)==null?void 0:w.name)||"(none)"}),". Service daemon runs them at the right time."]}):"Example schedules you can use as a starting point."})]}),e.jsxs("div",{className:"view-actions",children:[c==="schedules"&&e.jsxs(e.Fragment,{children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:x,"aria-label":"Refresh schedules",children:[e.jsx(xe,{size:14})," Refresh"]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>j(),children:[e.jsx(qe,{size:14})," New schedule"]})]}),c==="templates"&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:v,disabled:u,children:[e.jsx(xe,{size:14})," Refresh"]})]})]}),c==="templates"?u?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}):m.length===0?e.jsx(_e,{icon:e.jsx(Js,{size:32}),title:"No templates",message:"No schedule templates found. Templates are loaded from templates/schedules/."}):e.jsx("div",{className:"schedule-template-grid",children:m.map(S=>e.jsx(tp,{template:S,onUse:y},S.id))}):i.length===0?e.jsx(_e,{icon:e.jsx(Jt,{size:32}),title:"No schedules",message:t.activeProject?"Add a schedule to run commands, webhooks, or agent tasks on a cron / interval / one-shot basis.":"Activate a project first to scope schedules."}):e.jsx("div",{className:"schedule-grid",children:i.map(S=>{var $;return e.jsxs(ne,{className:"schedule-card",children:[e.jsxs("div",{className:"schedule-card-head",children:[e.jsxs("div",{children:[e.jsx(de,{children:S.name}),e.jsxs(ue,{children:[e.jsx("code",{children:S.type})," ·"," ",e.jsx("span",{title:S.schedule,children:up(S)||S.schedule}),S.timezone&&S.timezone!=="UTC"?e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{children:S.timezone})]}):null," · ",e.jsx("span",{className:S.enabled?"status-on":"status-neutral",children:S.enabled?"enabled":"disabled"})]})]}),e.jsxs("div",{className:"schedule-card-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>j(S),children:[e.jsx(fn,{size:12})," Edit"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>g(S),children:[e.jsx(Yn,{size:12})," Run now"]}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Delete",title:"Delete",onClick:()=>b(S),children:e.jsx(Fe,{size:12})})]})]}),e.jsxs("div",{className:"schedule-card-action",children:[e.jsx("span",{className:"muted",children:"action:"})," ",e.jsxs("code",{children:[S.action.type," ",S.action.target]}),S.action.type==="agent"&&S.action.prompt&&e.jsxs("div",{className:"schedule-card-prompt",children:[e.jsx("span",{className:"muted",children:"prompt:"})," ",S.action.prompt]})]}),(($=S.budgetCheck)==null?void 0:$.skipIfBudgetLow)&&e.jsxs("div",{className:"schedule-card-budget",children:[e.jsx("span",{className:"muted",children:"budget gate:"})," ","skip if concurrent ≥ ",S.budgetCheck.maxConcurrent??6]}),e.jsxs("div",{className:"schedule-card-times",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"last"})," ",S.lastRun?He(S.lastRun):"—",S.lastResult&&e.jsx("span",{className:`tag ${Nr(S.lastResult)}`,children:S.lastResult}),S.lastError&&e.jsxs("span",{className:"muted schedule-card-error",title:S.lastError,children:[" ","— ",Sr(S.lastError,80)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"next"})," ",S.nextRun?e.jsx("span",{title:new Date(S.nextRun).toISOString(),children:hp(S.nextRun,S.timezone)}):"—",S.nextRun&&e.jsxs("span",{className:"muted",children:[" · ",He(S.nextRun)]})]})]}),S.history&&S.history.length>0&&e.jsxs("details",{className:"schedule-card-history",children:[e.jsxs("summary",{children:[e.jsx(Zs,{size:12})," ",S.history.length," run",S.history.length===1?"":"s"]}),e.jsx("ul",{children:S.history.slice(-10).reverse().map((M,z)=>e.jsxs("li",{children:[e.jsx("span",{className:"tabular-nums muted",children:He(M.ts)})," ",e.jsx("span",{className:`tag ${Nr(M.result)}`,children:M.result}),M.error&&e.jsxs("span",{className:"muted",children:[" — ",Sr(M.error,80)]})]},z))})]})]},S.id)})})]})}function dp({initial:t,onClose:s,onSubmitted:n,onError:a}){const[i,r]=f.useState(()=>rp(t)),[o,l]=f.useState(!1),c=f.useMemo(()=>ri.some(d=>d.value===i.timezone)?i.timezone:"Other…",[i.timezone]),h=(d,u)=>{r(p=>({...p,[d]:u}))},m=async d=>{d.preventDefault();const u=i.name.trim();if(!u){a("Name is required.");return}const p=lp(i);if(!p.schedule){a("Schedule value is required.");return}if(!i.actionTarget.trim()){a("Action target is required.");return}const x=i.timezone==="Other…"?i.customTimezone.trim():i.timezone,v={type:i.actionType,target:i.actionTarget.trim()};i.actionType==="agent"&&i.actionPrompt.trim()&&(v.prompt=i.actionPrompt.trim());const j={name:u,type:i.type,schedule:p.schedule,timezone:x||"UTC",action:v,budgetCheck:{maxConcurrent:i.maxConcurrent,skipIfBudgetLow:i.skipIfBudgetLow},enabled:i.enabled};l(!0);try{const g=t?await H.put(`/schedules/${encodeURIComponent(t.id)}`,j):await H.post("/schedules",j);await n(g)}catch(g){a(`${t?"Update":"Create"} failed: ${g.message}`)}finally{l(!1)}};return e.jsxs("form",{className:"schedule-form",onSubmit:m,children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-name",children:"Name"}),e.jsx("input",{id:"schedule-name",className:"input",type:"text",placeholder:"Weekly code review",value:i.name,onChange:d=>h("name",d.target.value),autoFocus:!0}),e.jsx("div",{className:"task-form-row",children:e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-type",children:"Type"}),e.jsx("select",{id:"schedule-type",className:"select",value:i.type,onChange:d=>h("type",d.target.value),children:sp.map(d=>e.jsx("option",{value:d,children:d},d))})]})}),i.type==="cron"&&e.jsxs("div",{className:"schedule-cron-group",children:[!i.showAdvanced&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-dow",children:"Day of week"}),e.jsx("select",{id:"schedule-dow",className:"select",value:i.cronDow,onChange:d=>h("cronDow",d.target.value),children:Pi.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-hour",children:"Hour"}),e.jsx("select",{id:"schedule-hour",className:"select",value:String(i.cronHour),onChange:d=>h("cronHour",parseInt(d.target.value,10)),children:Li.map(d=>e.jsx("option",{value:String(d.value),children:d.label},d.value))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-minute",children:"Minute"}),e.jsx("select",{id:"schedule-minute",className:"select",value:String(i.cronMinute),onChange:d=>h("cronMinute",parseInt(d.target.value,10)),children:ap.map(d=>e.jsx("option",{value:String(d),children:String(d).padStart(2,"0")},d))})]})]})}),i.showAdvanced&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-cron-expr",children:"Cron expression"}),e.jsx("input",{id:"schedule-cron-expr",className:"input",type:"text",value:i.rawCron,onChange:d=>h("rawCron",d.target.value),placeholder:"0 13 * * 0"})]}),e.jsxs("button",{type:"button",className:"link-btn",onClick:()=>h("showAdvanced",!i.showAdvanced),"aria-expanded":i.showAdvanced,children:[e.jsx(ct,{size:12,style:{transform:i.showAdvanced?"rotate(180deg)":"none",transition:"transform 0.15s"}}),i.showAdvanced?"Hide advanced":"Advanced (raw cron)"]})]}),i.type==="interval"&&e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-interval-n",children:"Every"}),e.jsx("input",{id:"schedule-interval-n",className:"input",type:"number",min:1,value:i.intervalN,onChange:d=>h("intervalN",parseInt(d.target.value,10)||1)})]}),e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-interval-unit",children:"Unit"}),e.jsx("select",{id:"schedule-interval-unit",className:"select",value:i.intervalUnit,onChange:d=>h("intervalUnit",d.target.value),children:ul.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))})]})]}),i.type==="once"&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-once-at",children:"Run at"}),e.jsx("input",{id:"schedule-once-at",className:"input",type:"datetime-local",value:i.onceAt,onChange:d=>h("onceAt",d.target.value)})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-timezone",children:"Timezone"}),e.jsxs("select",{id:"schedule-timezone",className:"select",value:c,onChange:d=>h("timezone",d.target.value),children:[ri.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value)),e.jsx("option",{value:"Other…",children:"Other…"})]})]}),i.timezone==="Other…"&&e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-custom-tz",children:"IANA name"}),e.jsx("input",{id:"schedule-custom-tz",className:"input",type:"text",placeholder:"Europe/Paris",value:i.customTimezone,onChange:d=>h("customTimezone",d.target.value)})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-action-type",children:"Action"}),e.jsx("select",{id:"schedule-action-type",className:"select",value:i.actionType,onChange:d=>h("actionType",d.target.value),children:np.map(d=>e.jsx("option",{value:d,children:d},d))})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-action-target",children:"Target"}),e.jsx("input",{id:"schedule-action-target",className:"input",type:"text",placeholder:i.actionType==="webhook"?"https://...":i.actionType==="agent"?"agent name or task ref":"echo hi",value:i.actionTarget,onChange:d=>h("actionTarget",d.target.value)})]})]}),i.actionType==="agent"&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-action-prompt",children:"Prompt (what to send the agent)"}),e.jsx("textarea",{id:"schedule-action-prompt",className:"input",rows:3,placeholder:"Review open PRs for stale code review comments and nudge reviewers.",value:i.actionPrompt,onChange:d=>h("actionPrompt",d.target.value)})]}),e.jsxs("fieldset",{className:"schedule-budget-card",children:[e.jsx("legend",{children:"Budget pre-flight"}),e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{id:"schedule-skip-budget",type:"checkbox",checked:i.skipIfBudgetLow,onChange:d=>h("skipIfBudgetLow",d.target.checked)}),e.jsx("span",{children:"Skip this run when too many background tasks are already running."})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-max-concurrent",children:"Max concurrent bg tasks"}),e.jsx("input",{id:"schedule-max-concurrent",className:"input",type:"number",min:1,max:64,value:i.maxConcurrent,onChange:d=>h("maxConcurrent",parseInt(d.target.value,10)||6),disabled:!i.skipIfBudgetLow})]})]}),e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{id:"schedule-enabled",type:"checkbox",checked:i.enabled,onChange:d=>h("enabled",d.target.checked)}),e.jsx("span",{children:"Enabled"})]}),e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",type:"button",onClick:s,disabled:o,children:"Cancel"}),e.jsx(U,{variant:"primary",type:"submit",disabled:o,children:t?"Save":"Create"})]})]})}function up(t){var r,o;if(t.type!=="cron")return t.schedule;const s=hl(t.schedule);if(!s)return t.schedule;const n=((r=Pi.find(l=>l.value===s.dow))==null?void 0:r.label)||"",a=((o=Li.find(l=>l.value===s.hour))==null?void 0:o.label)||`${s.hour}`,i=String(s.minute).padStart(2,"0");return n==="Every day"?`Every day at ${a} :${i}`:`Every ${n} at ${a} :${i}`}function hp(t,s){try{return new Date(t).toLocaleString(void 0,{timeZone:s||void 0,weekday:"long",hour:"numeric",minute:"2-digit",month:"short",day:"numeric"})}catch{return new Date(t).toLocaleString()}}function Nr(t){return t==="success"?"tag-success":t==="skipped"?"tag-warning":"tag-error"}function Sr(t,s){return t.length<=s?t:t.slice(0,s-1)+"…"}const mp=[{id:"all",label:"All",icon:vt},{id:"shipped",label:"Shipped",icon:Ti},{id:"user",label:"User",icon:tn},{id:"project",label:"Project",icon:lt}],Hn={shipped:"Shipped",user:"User",project:"Project"},fp={shipped:Ti,user:tn,project:lt};function pp({snapshot:t,refreshSnapshot:s}){const n=fe(),a=Ze(),[i,r]=f.useState([]),[o,l]=f.useState({shipped:0,user:0,project:0,all:0}),[c,h]=f.useState(!0),[m,d]=f.useState("all"),[u,p]=f.useState(""),[x,v]=f.useState(null),[j,g]=f.useState(!1),b=async()=>{var $,M,z;h(!0);try{const A=await H.get("/skills");r(A.skills||[]),l({shipped:(($=A.counts)==null?void 0:$.shipped)??0,user:((M=A.counts)==null?void 0:M.user)??0,project:((z=A.counts)==null?void 0:z.project)??0,all:(A.skills||[]).length})}catch(A){n.error(`Skills load failed: ${A.message}`)}finally{h(!1)}};f.useEffect(()=>{b()},[]),f.useEffect(()=>{if(!u.trim()){v(null);return}g(!0);const $=setTimeout(async()=>{try{const M=await H.get(`/skills/search?q=${encodeURIComponent(u.trim())}`);v(M.results||[])}catch(M){n.error(`Search failed: ${M.message}`)}finally{g(!1)}},280);return()=>clearTimeout($)},[u]);const y=f.useMemo(()=>x!==null?x:m==="all"?i:i.filter($=>$.source===m),[i,m,x]),w=async()=>{try{await H.post("/skills/refresh",{}),n.success("Skills refreshed."),await b()}catch($){n.error(`Refresh failed: ${$.message}`)}},S=async $=>{try{const M=await H.get(`/skills/${encodeURIComponent($.source)}/${encodeURIComponent($.name)}`);a.open({title:M.name,width:640,children:e.jsxs("div",{className:"skill-detail",children:[e.jsxs("div",{className:"skill-detail-meta",children:[e.jsx("span",{className:"skill-source-badge","data-source":M.source,children:Hn[M.source]||M.source}),e.jsx("code",{className:"mono text-sm muted",children:M.path})]}),M.description&&e.jsx("p",{className:"skill-detail-desc",children:M.description}),M.body&&e.jsx("div",{className:"skill-detail-body",children:e.jsx("pre",{className:"skill-body-pre",children:M.body})})]}),footer:e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Close"})})}catch{a.open({title:$.name,width:560,children:e.jsxs("div",{className:"skill-detail",children:[e.jsxs("div",{className:"skill-detail-meta",children:[e.jsx("span",{className:"skill-source-badge","data-source":$.source,children:Hn[$.source]||$.source}),e.jsx("code",{className:"mono text-sm muted",children:$.path})]}),$.description&&e.jsx("p",{className:"skill-detail-desc",children:$.description})]}),footer:e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Close"})})}};return e.jsxs("div",{className:"view view-skills",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(vt,{size:18})," Skills"]}),e.jsx("p",{className:"view-subtitle",children:"Browse all available skills — shipped, user, and project-local."})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Ae,{size:14,"aria-hidden":!0}),e.jsx("label",{htmlFor:"skills-search",className:"sr-only",children:"Search skills"}),e.jsx("input",{id:"skills-search",className:"input",type:"text",placeholder:"Search skills…",value:u,onChange:$=>p($.target.value),"aria-label":"Search skills"}),u&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Clear search",onClick:()=>p(""),children:e.jsx(ls,{size:12})})]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:w,children:[e.jsx(xe,{size:14})," Refresh"]})]})]}),!u.trim()&&e.jsx("div",{className:"skills-tabs",children:mp.map($=>{const M=$.icon,z=$.id==="all"?o.all:o[$.id]??0;return e.jsxs("button",{type:"button",className:se("skills-tab",m===$.id&&"skills-tab-active"),onClick:()=>d($.id),children:[e.jsx(M,{size:14}),e.jsx("span",{children:$.label}),e.jsx("span",{className:"skills-tab-count",children:z})]},$.id)})}),u.trim()&&e.jsxs("section",{className:"skills-section",children:[e.jsxs("h3",{className:"skills-section-title",children:[e.jsx(Ae,{size:14})," Search results",j&&e.jsx(ye,{size:"sm"})]}),j?e.jsx("div",{className:"skills-grid",children:[0,1,2].map($=>e.jsx("div",{className:"skill-card skill-card-skeleton"},$))}):x&&x.length===0?e.jsx(_e,{icon:e.jsx(Ae,{size:28}),title:"No matches",message:`No skills match "${u}".`}):e.jsx("div",{className:"skills-grid",children:(x||[]).map(($,M)=>e.jsx(Cr,{skill:$,onShow:()=>S($),searchQ:u},`search-${M}`))})]}),!u.trim()&&e.jsx("section",{className:"skills-section",children:c?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}):y.length===0?e.jsx(_e,{icon:e.jsx(Mi,{size:28}),title:"No skills here",message:m==="all"?"No skills found. Install skills with the skills CLI or add SKILL.md files to a skills directory.":`No skills in the ${Hn[m]} tab.`}):e.jsx("div",{className:"skills-grid",children:y.map(($,M)=>e.jsx(Cr,{skill:$,onShow:()=>S($)},`${$.source}-${$.name}-${M}`))})}),!u.trim()&&e.jsx("footer",{className:"view-footer",children:e.jsxs("span",{className:"text-sm muted",children:["Skills are discovered from"," ",e.jsx("code",{children:"~/.cline/skills/"}),","," ",e.jsx("code",{children:"~/.agents/skills/"}),","," ",e.jsx("code",{children:"bizar-dash/skills/"}),", and project-local directories."]})})]})}function Cr({skill:t,onShow:s,searchQ:n=""}){const a=fp[t.source]||Ti,i=t.description?t.description.length>200?t.description.slice(0,200)+"…":t.description:"No description.";return e.jsxs(ne,{variant:"elevated",interactive:!0,className:"skill-card",children:[e.jsxs("div",{className:"skill-card-head",children:[e.jsx("div",{className:"skill-card-icon",style:{background:"color-mix(in srgb, var(--accent) 12%, transparent)"},children:e.jsx(a,{size:18})}),e.jsxs("div",{className:"skill-card-title-area",children:[e.jsx("div",{className:"skill-card-title",children:xp(t.name,n)}),e.jsx("span",{className:"skill-source-badge","data-source":t.source,children:Hn[t.source]||t.source})]})]}),e.jsx("p",{className:"skill-card-desc",children:i}),e.jsx("div",{className:"skill-card-actions",children:e.jsxs(U,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(Is,{size:12})," View"]})})]})}function xp(t,s){if(!s.trim())return t;const n=t.toLowerCase().indexOf(s.toLowerCase());return n<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,n),e.jsx("mark",{className:"skill-highlight",children:t.slice(n,n+s.length)}),t.slice(n+s.length)]})}const gp=rt.memo(pp);function yp({refreshKey:t,onRefresh:s,setActiveSubPanel:n}){const a=fe(),[i,r]=f.useState(null),[o,l]=f.useState(""),[c,h]=f.useState(!0),m=async j=>{h(!0);try{const[g,b,y,w]=await Promise.all([H.get("/memory/health",j).catch(()=>null),H.get("/memory/status",j).catch(()=>null),H.get("/memory/lightrag/stats",j).catch(()=>null),H.get("/memory/storage",j).catch(()=>null)]);l((b==null?void 0:b.vaultRoot)||""),r({health:g||{score:0,status:"unconfigured",checks:[],message:"memory not initialised"},vault:{exists:!!(b!=null&&b.initialized),vaultRoot:(b==null?void 0:b.vaultRoot)||"",mode:(b==null?void 0:b.mode)||"local-only",noteCount:(b==null?void 0:b.noteCount)||0,totalSize:(w==null?void 0:w.total)||0,folderCount:0,folders:[],lastModified:null,gitClean:(b==null?void 0:b.gitClean)??null,gitBranch:(b==null?void 0:b.branch)||null},lightrag:y||{running:!1,pid:null,host:"127.0.0.1",port:9621,indexedApprox:0,queryCountLast24h:0,lastReindexAt:null},storage:w||{total:0,breakdown:[]}})}catch(g){a.error(`Memory overview failed: ${g.message}`)}finally{h(!1)}};if(f.useEffect(()=>{const j=new AbortController;return m(j.signal),()=>j.abort()},[t]),c&&!i)return e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading memory overview…"})]});if(!i)return e.jsx("div",{className:"muted",children:"No memory data available."});const{health:d,vault:u,lightrag:p,storage:x}=i,v=d.score>=80?"var(--success)":d.score>=50?"var(--warning)":"var(--error)";return e.jsxs("div",{className:"memory-overview",children:[e.jsxs(ne,{variant:"elevated",className:"memory-health-hero",children:[e.jsxs("div",{className:"memory-health-score",style:{borderColor:v},children:[e.jsx("span",{className:"memory-health-score-value",style:{color:v},children:d.score}),e.jsx("span",{className:"memory-health-score-label",children:"/ 100"})]}),e.jsxs("div",{className:"memory-health-meta",children:[e.jsxs("h3",{className:"memory-health-title",children:[e.jsx(Be,{size:16}),"Memory health ·"," ",e.jsx("span",{style:{color:v},children:d.status})]}),e.jsx("p",{className:"memory-health-message",children:d.message}),e.jsxs("p",{className:"memory-health-vault mono muted","data-testid":"memory-overview-vault-path",children:[e.jsx("span",{className:"memory-health-vault-label",children:"Vault:"})," ",o||e.jsx("em",{children:"not initialised"})]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(xe,{size:12})," Refresh"]})]})]}),e.jsxs("div",{className:"memory-source-pills",children:[e.jsxs("button",{type:"button",className:"memory-source-pill",onClick:()=>n("lightrag"),children:[e.jsx(xt,{size:14}),e.jsx("span",{children:"LightRAG"}),e.jsx("span",{className:se("memory-source-pill-status",p.running?"on":"off"),children:p.running?"running":"stopped"})]}),e.jsxs("button",{type:"button",className:"memory-source-pill",onClick:()=>n("obsidian"),children:[e.jsx(Ve,{size:14}),e.jsx("span",{children:"Obsidian Vault"}),e.jsxs("span",{className:se("memory-source-pill-status",u.exists?"on":"off"),children:[u.noteCount," notes"]})]}),e.jsxs("button",{type:"button",className:"memory-source-pill",onClick:()=>n("git"),children:[e.jsx(gt,{size:14}),e.jsx("span",{children:"Git Sync"}),e.jsx("span",{className:se("memory-source-pill-status",u.gitClean===null?"na":u.gitClean?"on":"warn"),children:u.gitClean===null?"—":u.gitClean?"clean":"dirty"})]}),e.jsxs("button",{type:"button",className:"memory-source-pill",onClick:()=>n("semantic"),children:[e.jsx(Ae,{size:14}),e.jsx("span",{children:"Semantic Search"}),e.jsx("span",{className:"memory-source-pill-status na",children:"cross-source"})]})]}),e.jsxs("div",{className:"memory-stat-grid",children:[e.jsx(hs,{icon:e.jsx(xt,{size:16}),label:"LightRAG",value:p.running?`running · ${p.queryCountLast24h} q/24h`:"stopped",sub:p.running?`${p.indexedApprox} indexed chunks`:"start from the LightRAG panel",onClick:()=>n("lightrag")}),e.jsx(hs,{icon:e.jsx(Ve,{size:16}),label:"Obsidian",value:`${u.noteCount} notes`,sub:u.folderCount>0?`${u.folderCount} folders`:"no folders yet",onClick:()=>n("obsidian")}),e.jsx(hs,{icon:e.jsx(gt,{size:16}),label:"Git",value:u.gitBranch?`branch ${u.gitBranch}`:"local-only",sub:u.gitClean===null?"not configured":u.gitClean?"clean working tree":"dirty — commit or pull",onClick:()=>n("git")}),e.jsx(hs,{icon:e.jsx(Xn,{size:16}),label:"Storage",value:vp(x.total),sub:x.breakdown.length>0?`${x.breakdown.length} dirs tracked`:"no memory data on disk"}),e.jsx(hs,{icon:e.jsx(vt,{size:16}),label:"Last reindex",value:p.lastReindexAt?St(p.lastReindexAt):"never",sub:"lightrag ingest",onClick:()=>n("lightrag")}),e.jsx(hs,{icon:e.jsx(en,{size:16}),label:"Health",value:`${d.score}/100`,sub:d.status,onClick:()=>n("config")})]}),d.checks.length>0&&e.jsxs(ne,{children:[e.jsx(de,{children:"Health checks"}),e.jsx(ue,{children:"Composite score across all memory subsystems"}),e.jsx("ul",{className:"memory-check-list",children:d.checks.map(j=>e.jsxs("li",{className:"memory-check-row",children:[e.jsx("span",{className:"memory-check-icon",children:j.pass?e.jsx(Ke,{size:14,style:{color:"var(--success)"}}):j.name.includes("secrets")||j.name.includes("schema")?e.jsx(Ue,{size:14,style:{color:"var(--warning)"}}):e.jsx(ls,{size:14,style:{color:"var(--error)"}})}),e.jsx("span",{className:"memory-check-name",children:j.name}),e.jsx("span",{className:"memory-check-detail muted",children:j.detail})]},j.name))})]})]})}function hs({icon:t,label:s,value:n,sub:a,onClick:i}){const r=i?"button":"div";return e.jsxs(r,{type:i?"button":void 0,onClick:i,className:se("memory-stat-card",i&&"memory-stat-card-clickable"),children:[e.jsx("div",{className:"memory-stat-icon",children:t}),e.jsxs("div",{className:"memory-stat-body",children:[e.jsx("div",{className:"memory-stat-label",children:s}),e.jsx("div",{className:"memory-stat-value",children:n}),e.jsx("div",{className:"memory-stat-sub muted",children:a})]})]})}function vp(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function jp({refreshKey:t}){const s=fe(),[n,a]=f.useState(null),[i,r]=f.useState(null),[o,l]=f.useState([]),[c,h]=f.useState(!0),[m,d]=f.useState(null),[u,p]=f.useState(""),[x,v]=f.useState(null),j=async()=>{h(!0);try{const[z,A,k]=await Promise.all([H.get("/memory/lightrag/stats").catch(()=>null),H.get("/memory/config").then(C=>(C==null?void 0:C.lightrag)||null).catch(()=>null),H.get("/memory/lightrag/log").catch(()=>({lines:[]}))]);a(z),r(A),l((k==null?void 0:k.lines)||[])}catch(z){s.error(`LightRAG status failed: ${z.message}`)}finally{h(!1)}};f.useEffect(()=>{j()},[t]);const g=async(z,A,k)=>{d(z);try{await A(),s.success(k),await j()}catch(C){s.error(`${z} failed: ${C.message}`)}finally{d(null)}},b=()=>g("start",()=>H.post("/memory/lightrag/start",{}),"LightRAG starting…"),y=()=>g("stop",()=>H.post("/memory/lightrag/stop",{}),"LightRAG stopping…"),w=async()=>{d("restart");try{await H.post("/memory/lightrag/stop",{}).catch(()=>{}),await new Promise(z=>setTimeout(z,600)),await H.post("/memory/lightrag/start",{}),s.success("LightRAG restarted."),await j()}catch(z){s.error(`Restart failed: ${z.message}`)}finally{d(null)}},S=()=>g("reindex",()=>H.post("/memory/lightrag/reindex",{}),"Reindex complete."),$=()=>g("rebuild",()=>H.post("/memory/lightrag/rebuild-graph",{}),"Graph rebuilt."),M=async()=>{var z,A,k;if(u.trim()){d("query");try{const C=await H.get(`/memory/query?q=${encodeURIComponent(u)}&topK=8`),_=(z=C==null?void 0:C.semantic)!=null&&z.response?typeof C.semantic.response=="string"?C.semantic.response:JSON.stringify(C.semantic.response):((A=C==null?void 0:C.semantic)==null?void 0:A.error)||"No response";v({ok:!!((k=C==null?void 0:C.semantic)!=null&&k.ok),text:_})}catch(C){v({ok:!1,text:C.message})}finally{d(null)}}};return c&&!n?e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading LightRAG status…"})]}):n?e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(ne,{variant:"elevated",children:[e.jsxs(de,{children:[e.jsx(xt,{size:14}),"LightRAG",e.jsx("span",{className:se("memory-source-pill-status",n.running?"on":"off"),children:n.running?"running":"stopped"})]}),e.jsx(ue,{children:n.running?e.jsxs(e.Fragment,{children:["PID ",e.jsx("code",{children:n.pid})," · ",n.host,":",n.port]}):e.jsx(e.Fragment,{children:"Server is not running. Start it from the controls below."})}),e.jsxs("div",{className:"memory-action-row",children:[e.jsxs(U,{variant:"primary",size:"sm",onClick:b,disabled:!!m||n.running,children:[m==="start"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(ws,{size:12}),"Start"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:y,disabled:!!m||!n.running,children:[m==="stop"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(rh,{size:12}),"Stop"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:w,disabled:!!m,children:[m==="restart"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Ho,{size:12}),"Restart"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:S,disabled:!!m,children:[m==="reindex"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(xe,{size:12}),"Reindex all"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:$,disabled:!!m,title:"Wipe working dir + reindex from scratch",children:[m==="rebuild"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(da,{size:12}),"Rebuild graph"]})]})]}),e.jsxs("div",{className:"memory-stat-grid",children:[e.jsx(Os,{icon:e.jsx(Xn,{size:14}),label:"Indexed chunks (approx)",value:String(n.indexedApprox)}),e.jsx(Os,{icon:e.jsx(bp,{n:n.noteCount}),label:"Notes in vault",value:String(n.noteCount)}),e.jsx(Os,{icon:e.jsx(Ci,{size:14}),label:"Queries last 24h",value:String(n.queryCountLast24h)}),e.jsx(Os,{icon:e.jsx(vt,{size:14}),label:"Avg response",value:n.avgResponseMs!==null?`${n.avgResponseMs} ms`:"—"}),e.jsx(Os,{icon:n.lastReindexOk?e.jsx(Ke,{size:14}):n.lastReindexOk===!1?e.jsx(ls,{size:14}):e.jsx(xe,{size:14}),label:"Last reindex",value:n.lastReindexAt?St(n.lastReindexAt):"never",sub:n.lastReindexInserted!==null?`${n.lastReindexInserted} inserted${n.lastReindexFailed?`, ${n.lastReindexFailed} failed`:""}`:void 0})]}),e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(Ae,{size:14})," Quick search"]}),e.jsx(ue,{children:"Send a natural-language query to the LightRAG index."}),e.jsxs("div",{className:"memory-search-row",children:[e.jsx("label",{htmlFor:"lightrag-query",className:"sr-only",children:"Search LightRAG"}),e.jsx("input",{id:"lightrag-query",type:"text",className:"input",placeholder:"e.g. how does the memory service write notes?",value:u,onChange:z=>p(z.target.value),onKeyDown:z=>{z.key==="Enter"&&M()},disabled:m==="query","aria-label":"Search LightRAG"}),e.jsxs(U,{variant:"primary",onClick:M,disabled:m==="query"||!u.trim(),children:[m==="query"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Ae,{size:12}),"Query"]})]}),x&&e.jsx("div",{className:se("memory-query-result",x.ok?"ok":"err"),children:e.jsx("pre",{className:"mono text-sm",children:x.text})})]}),i&&e.jsxs(ne,{children:[e.jsx(de,{children:"Configuration"}),e.jsxs(ue,{children:["Effective values from ",e.jsx("code",{children:".bizar/memory.json"})," + env defaults."]}),e.jsxs("dl",{className:"memory-config-row",children:[e.jsx("dt",{children:"LLM binding"}),e.jsxs("dd",{children:[e.jsx("code",{children:i.llmBinding})," · ",e.jsx("code",{children:i.llmModel})]}),e.jsx("dt",{children:"Embedding"}),e.jsxs("dd",{children:[e.jsx("code",{children:i.embeddingBinding})," · ",e.jsx("code",{children:i.embeddingModel})]}),e.jsx("dt",{children:"Host"}),e.jsx("dd",{children:e.jsxs("code",{children:[i.host,":",i.port]})}),e.jsx("dt",{children:"Working dir"}),e.jsx("dd",{className:"mono ellipsis",title:i.workingDir,children:i.workingDir})]})]}),o.length>0&&e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(xe,{size:14})," Server log (tail)"]}),e.jsxs(ue,{children:["Last ",o.length," lines from ",e.jsx("code",{children:"lightrag.log"})]}),e.jsx("pre",{className:"memory-log-tail mono text-xs",children:o.join(`
|
|
402
|
-
`)})]})]}):e.jsx("div",{className:"muted",children:"No LightRAG data available."})}function Os({icon:t,label:s,value:n,sub:a}){return e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-icon",children:t}),e.jsxs("div",{className:"memory-stat-body",children:[e.jsx("div",{className:"memory-stat-label",children:s}),e.jsx("div",{className:"memory-stat-value",children:n}),a&&e.jsx("div",{className:"memory-stat-sub muted",children:a})]})]})}function bp({n:t}){return e.jsxs("span",{style:{position:"relative",display:"inline-block"},children:[e.jsx(Ae,{size:14}),e.jsx("span",{className:"memory-mini-badge",children:t})]})}function wp({refreshKey:t}){const s=fe(),n=Ze(),[a,i]=f.useState([]),[r,o]=f.useState(null),[l,c]=f.useState(!0),[h,m]=f.useState(""),[d,u]=f.useState(null),[p,x]=f.useState(!1),[v,j]=f.useState(null),[g,b]=f.useState([]),y=async()=>{var k;c(!0);try{const[C,_]=await Promise.all([H.get("/memory/notes").catch(()=>({notes:[]})),H.get("/memory/obsidian/tree").catch(()=>({tree:null}))]);i(C.notes||[]),o(_.tree),v&&!((k=C.notes)!=null&&k.find(L=>L.relPath===v))&&(j(null),b([]))}catch(C){s.error(`Vault load failed: ${C.message}`)}finally{c(!1)}};f.useEffect(()=>{y()},[t]),f.useEffect(()=>{if(!h.trim()){u(null);return}x(!0);const k=setTimeout(async()=>{try{const C=await H.get(`/memory/search?q=${encodeURIComponent(h)}&limit=50`),_=new Set((C.results||[]).map(L=>L.relPath));u(a.filter(L=>_.has(L.relPath)))}catch(C){s.error(`Search failed: ${C.message}`)}finally{x(!1)}},240);return()=>clearTimeout(k)},[h,a,s]);const w=async k=>{j(k);try{const C=await H.get(`/memory/obsidian/backlinks?note=${encodeURIComponent(k)}`);b(C.backlinks||[])}catch{b([])}},S=()=>{n.open({title:"New note",width:720,children:e.jsx(zr,{mode:"create",onSave:async(k,C,_)=>{try{await H.post("/memory/notes",{path:k,frontmatter:C,body:_}),s.success(`Created ${k}.`),n.close(),await y(),w(k)}catch(L){s.error(`Create failed: ${L.message}`)}},onCancel:()=>n.close()})})},$=async k=>{try{const C=await H.get(`/memory/notes/${k.split("/").map(encodeURIComponent).join("/")}`);n.open({title:`Edit ${k}`,width:720,children:e.jsx(zr,{mode:"edit",initial:{relPath:C.relPath,frontmatter:C.frontmatter,body:C.body},onSave:async(_,L,N)=>{try{await H.put(`/memory/notes/${_.split("/").map(encodeURIComponent).join("/")}`,{frontmatter:L,body:N}),s.success(`Saved ${_}.`),n.close(),await y(),w(_)}catch(T){s.error(`Save failed: ${T.message}`)}},onCancel:()=>n.close()})})}catch(C){s.error(`Load failed: ${C.message}`)}},M=async k=>{if(confirm(`Delete ${k}? This cannot be undone.`))try{await H.del(`/memory/notes/${k.split("/").map(encodeURIComponent).join("/")}`),s.success(`Deleted ${k}.`),v===k&&j(null),await y()}catch(C){s.error(`Delete failed: ${C.message}`)}},z=f.useMemo(()=>[...a].sort((k,C)=>C.mtime-k.mtime),[a]),A=d??z;return l&&!a.length?e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading vault…"})]}):e.jsxs("div",{className:"memory-panel-content memory-obsidian-grid",children:[e.jsxs(ne,{variant:"outlined",className:"memory-tree-card",children:[e.jsxs(de,{children:[e.jsx(lt,{size:14})," Folders"]}),e.jsx(ue,{children:r?`${pl(r)} folder(s)`:"no vault"}),e.jsx("div",{className:"memory-tree-body",children:r?e.jsx(fl,{node:r,depth:0,onSelect:w,selected:v}):null})]}),e.jsxs("div",{className:"memory-obsidian-list-col",children:[e.jsxs("div",{className:"memory-list-toolbar",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Ae,{size:14,"aria-hidden":!0}),e.jsx("label",{htmlFor:"obsidian-search",className:"sr-only",children:"Search notes"}),e.jsx("input",{id:"obsidian-search",type:"text",className:"input",placeholder:"Search notes…",value:h,onChange:k=>m(k.target.value),"aria-label":"Search notes"}),h&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>m(""),"aria-label":"Clear search",children:e.jsx(Re,{size:12})})]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:S,children:[e.jsx(Bu,{size:12})," New note"]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:y,title:"Refresh",children:e.jsx(xe,{size:12})})]}),p&&e.jsx("div",{className:"muted text-sm",children:"Searching…"}),A.length===0?e.jsx(_e,{icon:e.jsx(Ve,{size:28}),title:"No notes",message:a.length===0?'No notes in this vault yet. Click "New note" to create one.':`No notes match "${h}".`}):e.jsx("ul",{className:"memory-note-list",children:A.map(k=>e.jsxs("li",{className:se("memory-note-card",v===k.relPath&&"memory-note-card-active"),children:[e.jsxs("button",{type:"button",className:"memory-note-card-main",onClick:()=>w(k.relPath),children:[e.jsxs("div",{className:"memory-note-card-title",children:[e.jsx(Ve,{size:12}),e.jsx("span",{children:ml(k)})]}),e.jsxs("div",{className:"memory-note-card-meta",children:[e.jsx("code",{className:"muted",children:k.relPath}),e.jsxs("span",{className:"muted",children:["· ",He(k.mtime)]}),!k.schemaValid&&e.jsx("span",{className:"memory-pill-warn",children:"schema"})]})]}),e.jsxs("div",{className:"memory-note-card-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>$(k.relPath),"aria-label":`Edit ${k.relPath}`,title:"Edit",children:e.jsx(fn,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>M(k.relPath),"aria-label":`Delete ${k.relPath}`,title:"Delete",children:e.jsx(Fe,{size:12})})]})]},k.relPath))})]}),e.jsx("div",{className:"memory-obsidian-detail-col",children:v?e.jsx(kp,{relPath:v,onClose:()=>j(null)}):e.jsx(_e,{icon:e.jsx(Ve,{size:28}),title:"Pick a note",message:"Select a note from the list to view its content, frontmatter, and backlinks."})})]})}function ml(t){var n;const s=(n=t.frontmatter)==null?void 0:n.title;return typeof s=="string"&&s.trim()?s:t.relPath.replace(/\.md$/i,"")}function fl({node:t,depth:s,onSelect:n,selected:a}){const[i,r]=f.useState(s<2);return t.type==="note"?e.jsxs("button",{type:"button",className:se("memory-tree-node memory-tree-node-note",a===t.path&&"memory-tree-node-active"),style:{paddingLeft:6+s*12},onClick:()=>n(t.path),children:[e.jsx(Ve,{size:11}),e.jsx("span",{children:t.name})]}):e.jsxs("div",{className:"memory-tree-folder",children:[e.jsxs("button",{type:"button",className:"memory-tree-node memory-tree-node-folder",style:{paddingLeft:6+s*12},onClick:()=>r(o=>!o),children:[i?e.jsx(ct,{size:11}):e.jsx(Ut,{size:11}),e.jsx(lt,{size:11}),e.jsx("span",{children:t.name||"vault"}),t.children&&t.children.length>0&&e.jsx("span",{className:"muted text-xs",children:t.children.length})]}),i&&t.children&&e.jsx("div",{className:"memory-tree-children",children:t.children.map((o,l)=>e.jsx(fl,{node:o,depth:s+1,onSelect:n,selected:a},`${o.path}-${l}`))})]})}function pl(t){return t.type==="note"?0:1+(t.children||[]).reduce((s,n)=>s+pl(n),0)}function kp({relPath:t,onClose:s}){var m,d;const[n,a]=f.useState(null),[i,r]=f.useState([]),[o,l]=f.useState(!0);if(f.useEffect(()=>{let u=!1;return l(!0),(async()=>{try{const[p,x]=await Promise.all([H.get(`/memory/notes/${t.split("/").map(encodeURIComponent).join("/")}`),H.get(`/memory/obsidian/backlinks?note=${encodeURIComponent(t)}`)]);if(u)return;a(p),r(x.backlinks||[])}catch{u||a(null)}finally{u||l(!1)}})(),()=>{u=!0}},[t]),o)return e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"sm"})});if(!n)return e.jsx("div",{className:"muted",children:"Note not found."});const c=Array.isArray((m=n.frontmatter)==null?void 0:m.tags)?n.frontmatter.tags:[],h=Array.isArray((d=n.frontmatter)==null?void 0:d.links)?n.frontmatter.links:[];return e.jsxs("div",{className:"memory-note-detail",children:[e.jsxs("div",{className:"memory-note-detail-head",children:[e.jsx("h3",{children:ml(n)}),e.jsx("button",{type:"button",className:"icon-btn",onClick:s,"aria-label":"Close",children:e.jsx(Re,{size:12})})]}),e.jsxs("div",{className:"memory-note-detail-meta",children:[e.jsx("code",{children:t}),e.jsxs("span",{className:"muted",children:["· modified ",St(n.mtime)]})]}),c.length>0&&e.jsx("div",{className:"memory-tag-row",children:c.map((u,p)=>e.jsx("span",{className:"memory-tag",children:String(u)},p))}),e.jsx("pre",{className:"memory-note-body mono text-sm",children:n.body}),i.length>0&&e.jsxs("div",{className:"memory-backlinks",children:[e.jsx("h4",{children:"Backlinks"}),e.jsx("ul",{children:i.map(u=>e.jsxs("li",{children:[e.jsx("code",{children:u.fromRelPath}),e.jsx("p",{className:"muted text-sm",children:u.snippet})]},u.fromRelPath))})]}),h.length>0&&e.jsxs("div",{className:"memory-backlinks",children:[e.jsx("h4",{children:"Forward links"}),e.jsx("ul",{children:h.map((u,p)=>e.jsx("li",{children:e.jsx("code",{children:String(u)})},p))})]})]})}function zr({mode:t,initial:s,onSave:n,onCancel:a}){const[i,r]=f.useState((s==null?void 0:s.relPath)||"untitled.md"),[o,l]=f.useState(s!=null&&s.frontmatter?Np(s.frontmatter):`title: ""
|
|
403
|
-
tags: []
|
|
404
|
-
`),[c,h]=f.useState((s==null?void 0:s.body)||""),[m,d]=f.useState(!1),u=fe(),p=async()=>{if(!i.endsWith(".md")){u.error("Path must end in .md");return}let x;try{x=Sp(o)||{}}catch(v){u.error(`Frontmatter parse failed: ${v.message}`);return}d(!0);try{await n(i,x,c)}finally{d(!1)}};return e.jsxs("div",{className:"memory-editor-modal",children:[e.jsx("label",{className:"field-label",htmlFor:"obsidian-note-path",children:"Path"}),e.jsx("input",{id:"obsidian-note-path",type:"text",className:"input mono",value:i,onChange:x=>r(x.target.value),disabled:t==="edit",placeholder:"notes/example.md"}),e.jsx("label",{className:"field-label",htmlFor:"obsidian-note-frontmatter",style:{marginTop:12},children:"Frontmatter (YAML)"}),e.jsx("textarea",{id:"obsidian-note-frontmatter",className:"memory-editor-textarea mono text-sm",rows:6,value:o,onChange:x=>l(x.target.value),"aria-label":"Frontmatter YAML"}),e.jsx("label",{className:"field-label",htmlFor:"obsidian-note-body",style:{marginTop:12},children:"Body (Markdown)"}),e.jsx("textarea",{id:"obsidian-note-body",className:"memory-editor-textarea mono text-sm",rows:14,value:c,onChange:x=>h(x.target.value),"aria-label":"Body markdown"}),e.jsxs("div",{className:"modal-footer-actions",style:{marginTop:12},children:[e.jsx(U,{variant:"ghost",onClick:a,disabled:m,children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:p,disabled:m,children:[m&&e.jsx(je,{size:12,className:"memory-spin"}),t==="create"?"Create":"Save"]})]})]})}function Np(t){const s=[];for(const[n,a]of Object.entries(t))if(a!=null)if(Array.isArray(a)){if(a.length===0){s.push(`${n}: []`);continue}s.push(`${n}:`);for(const i of a)s.push(` - ${Da(i)}`)}else if(typeof a=="object"){s.push(`${n}:`);for(const[i,r]of Object.entries(a))s.push(` ${i}: ${Da(r)}`)}else s.push(`${n}: ${Da(a)}`);return s.join(`
|
|
405
|
-
`)}function Da(t){return typeof t=="string"?/[:#\n"']/.test(t)||t===""?JSON.stringify(t):t:typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t)}function Sp(t){const s={},n=t.split(/\r?\n/);let a=0;for(;a<n.length;){const i=n[a];if(!i.trim()||i.trim().startsWith("#")){a++;continue}const r=i.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!r){a++;continue}const[,o,l]=r;if(l===""){const c={},h=[];let m=!1,d=!1;for(;a+1<n.length;){const u=n[a+1];if(!u.startsWith(" "))break;if(u.startsWith(" - "))m=!0,h.push(Fa(u.slice(4))),a++;else{d=!0;const p=u.match(/^ ([A-Za-z_][\w-]*):\s*(.*)$/);p&&(c[p[1]]=Fa(p[2])),a++}}s[o]=m&&!d?h:d?c:{}}else s[o]=Fa(l);a++}return s}function Fa(t){const s=t.trim();return s===""?"":s==="true"?!0:s==="false"?!1:s==="null"||s==="~"?null:/^-?\d+$/.test(s)?parseInt(s,10):/^-?\d+\.\d+$/.test(s)?parseFloat(s):s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")?s.slice(1,-1):s}function Cp({refreshKey:t}){var y,w,S,$;const s=fe(),[n,a]=f.useState(null),[i,r]=f.useState(null),[o,l]=f.useState(!0),[c,h]=f.useState(null),[m,d]=f.useState(null),u=async()=>{var M;l(!0);try{const[z,A,k]=await Promise.all([H.get("/memory/git/status").catch(()=>null),H.get("/memory/git/diff").catch(()=>null),H.get("/memory/config/global").catch(()=>null)]);a(z),r(A),d(((M=k==null?void 0:k.config)==null?void 0:M.git)||null)}catch(z){s.error(`Git status failed: ${z.message}`)}finally{l(!1)}};f.useEffect(()=>{u()},[t]);const p=async(M,z,A)=>{h(M);try{await z(),s.success(A),await u()}catch(k){s.error(`${M} failed: ${k.message}`)}finally{h(null)}},x=()=>p("pull",()=>H.post("/memory/git/pull",{}),"Pull complete."),v=()=>p("push",()=>H.post("/memory/git/push",{}),"Push complete."),j=()=>{const M=prompt("Commit message:",`[memory-sync] ${new Date().toISOString().slice(0,10)} vault sync`);M&&p("commit",()=>H.post("/memory/git/commit",{message:M}),"Committed.")},g=()=>p("fetch",()=>H.post("/memory/git/sync",{push:!1}),"Fetch complete.");if(o&&!n)return e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading git status…"})]});if(!n)return e.jsx("div",{className:"muted",children:"No git data available."});const b=n.mode==="local-only";return e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(ne,{variant:"elevated",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14})," Git sync",b?e.jsx("span",{className:"memory-source-pill-status na",children:"local-only"}):e.jsx("span",{className:se("memory-source-pill-status",n.clean?"on":"warn"),children:n.clean?"clean":"dirty"})]}),e.jsx(ue,{children:b?"Memory is in local-only mode. Configure a shared repo in Settings → Memory to enable git sync.":e.jsxs(e.Fragment,{children:["Branch ",e.jsx("code",{children:n.branch||"—"}),n.ahead?e.jsxs(e.Fragment,{children:[" · ahead ",n.ahead]}):null,n.behind?e.jsxs(e.Fragment,{children:[" · behind ",n.behind]}):null]})}),!b&&e.jsxs("div",{className:"memory-git-status-row",children:[e.jsx(Bs,{ok:n.clean??!1,label:"Working tree"}),e.jsx(Bs,{ok:(n.ahead??0)===0,label:`Ahead: ${n.ahead??0}`}),e.jsx(Bs,{ok:(n.behind??0)===0,label:`Behind: ${n.behind??0}`}),e.jsx(Bs,{ok:(((y=n.modified)==null?void 0:y.length)??0)===0,label:`Modified: ${((w=n.modified)==null?void 0:w.length)??0}`}),e.jsx(Bs,{ok:(((S=n.untracked)==null?void 0:S.length)??0)===0,label:`Untracked: ${(($=n.untracked)==null?void 0:$.length)??0}`})]}),e.jsxs("div",{className:"memory-action-row",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:x,disabled:!!c||b,children:[c==="pull"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(ua,{size:12}),"Pull"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:v,disabled:!!c||b,children:[c==="push"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(pn,{size:12}),"Push"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:j,disabled:!!c||b,children:[c==="commit"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Qo,{size:12}),"Commit"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:g,disabled:!!c||b,children:[c==="fetch"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Xu,{size:12}),"Fetch + sync"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:u,disabled:!!c,children:[e.jsx(xe,{size:12})," Refresh"]})]})]}),m&&e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(ou,{size:14})," Repository"]}),e.jsxs(ue,{children:["Snapshot of ",e.jsx("code",{children:"~/.config/bizar/memory-config.json"})," → git block."]}),e.jsxs("dl",{className:"memory-config-row",children:[e.jsx("dt",{children:"Path"}),e.jsx("dd",{className:"mono ellipsis",title:m.repoPath,children:m.repoPath||"—"}),e.jsx("dt",{children:"Remote"}),e.jsx("dd",{className:"mono ellipsis",title:m.remoteUrl,children:m.remoteUrl||"—"}),e.jsx("dt",{children:"Branch"}),e.jsx("dd",{children:e.jsx("code",{children:m.branch||"main"})}),e.jsx("dt",{children:"Auto-sync"}),e.jsx("dd",{children:m.autoSync?"enabled":"disabled"})]})]}),e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(Yu,{size:14})," Working-tree diff"]}),e.jsx(ue,{children:i!=null&&i.hasDiff?`${i.files.length} file(s) changed`:"no working-tree changes"}),i&&i.files.length>0&&e.jsx("ul",{className:"memory-diff-files",children:i.files.map(M=>e.jsx("li",{children:e.jsx("code",{children:M})},M))}),i&&i.lines.length>1&&e.jsx("pre",{className:"memory-log-tail mono text-xs",children:i.lines.slice(0,400).join(`
|
|
406
|
-
`)})]})]})}function Bs({ok:t,label:s}){return e.jsxs("span",{className:se("memory-git-status-pill",t?"ok":"warn"),children:[t?e.jsx(Ke,{size:11}):e.jsx(je,{size:11,className:"memory-spin"}),s]})}function zp({refreshKey:t}){const s=fe(),[n,a]=f.useState(""),[i,r]=f.useState({lightrag:!0,obsidian:!0}),[o,l]=f.useState(null),[c,h]=f.useState(!1),[m,d]=f.useState(""),u=async x=>{if(x.trim()){h(!0),d(x);try{const v=[...i.lightrag?["lightrag"]:[],...i.obsidian?["obsidian"]:[]],j=await H.post("/memory/semantic-search",{query:x,limit:20,sources:v});l(j.results||[])}catch(v){s.error(`Search failed: ${v.message}`),l([])}finally{h(!1)}}};f.useEffect(()=>{m&&u(m)},[i]),f.useEffect(()=>{m&&u(m)},[t]);const p=f.useMemo(()=>{const x=(o||[]).filter(j=>j.source==="obsidian"),v=(o||[]).filter(j=>j.source==="lightrag");return{obs:x,lr:v}},[o]);return e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(ne,{variant:"elevated",children:[e.jsxs(de,{children:[e.jsx(Ae,{size:14})," Semantic search"]}),e.jsx(ue,{children:"Query both LightRAG (graph-based) and the Obsidian vault in one shot."}),e.jsxs("div",{className:"memory-search-row",children:[e.jsx("label",{htmlFor:"semantic-search-input",className:"sr-only",children:"Semantic search"}),e.jsx("input",{id:"semantic-search-input",type:"text",className:"input",placeholder:"e.g. how are notes indexed?",value:n,onChange:x=>a(x.target.value),onKeyDown:x=>{x.key==="Enter"&&u(n)},disabled:c,"aria-label":"Semantic search query"}),e.jsxs(U,{variant:"primary",onClick:()=>u(n),disabled:c||!n.trim(),children:[c?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Ae,{size:12}),"Search"]})]}),e.jsxs("div",{className:"memory-source-toggle-row",children:[e.jsx(Mr,{active:i.obsidian,onToggle:()=>r(x=>({...x,obsidian:!x.obsidian})),label:"Obsidian",icon:e.jsx(Ve,{size:11})}),e.jsx(Mr,{active:i.lightrag,onToggle:()=>r(x=>({...x,lightrag:!x.lightrag})),label:"LightRAG",icon:e.jsx(xt,{size:11})}),n&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>{a(""),l(null),d("")},"aria-label":"Clear",children:e.jsx(Re,{size:12})})]})]}),c&&e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"md"})}),!c&&o&&o.length===0&&e.jsx(_e,{icon:e.jsx(Ae,{size:28}),title:"No matches",message:`Nothing in scope matched "${m}".`}),p.obs.length>0&&e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(Ve,{size:14})," Obsidian (",p.obs.length,")"]}),e.jsx("ul",{className:"memory-search-result-list",children:p.obs.map((x,v)=>e.jsxs("li",{className:"memory-search-result",children:[e.jsxs("div",{className:"memory-search-result-head",children:[e.jsx("code",{children:x.relPath}),e.jsxs("span",{className:"muted text-xs",children:["score ",x.score.toFixed(1)]})]}),e.jsx("p",{className:"muted text-sm",children:x.snippet})]},`obs-${v}`))})]}),p.lr.length>0&&e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(xt,{size:14})," LightRAG (",p.lr.length,")"]}),e.jsx("div",{className:"memory-search-result-list",children:p.lr.map((x,v)=>e.jsxs("div",{className:"memory-search-result",children:[e.jsxs("div",{className:"memory-search-result-head",children:[e.jsxs("span",{className:"memory-source-pill",children:[e.jsx(xt,{size:11})," LightRAG"]}),x.error&&e.jsxs("span",{className:"muted text-xs",children:["error: ",x.error]})]}),e.jsx("p",{className:"text-sm",children:x.snippet})]},`lr-${v}`))})]})]})}function Mr({active:t,onToggle:s,label:n,icon:a}){return e.jsxs("button",{type:"button",className:se("memory-toggle-chip",t&&"memory-toggle-chip-active"),onClick:s,"aria-pressed":t,children:[a,e.jsx("span",{children:n})]})}function Mp({refreshKey:t}){const s=fe(),[n,a]=f.useState(null),[i,r]=f.useState(!0),[o,l]=f.useState(!1),[c,h]=f.useState(""),[m,d]=f.useState(null),[u,p]=f.useState(""),[x,v]=f.useState(!1),[j,g]=f.useState(!1),[b,y]=f.useState(null),[w,S]=f.useState(null),[$,M]=f.useState(null),[z,A]=f.useState(!1),k=async()=>{var E,P;r(!0);try{const[W,V]=await Promise.all([H.get("/memory/config/global").catch(()=>null),H.get("/memory/status").catch(()=>null)]);W?(a(W.config),h(((P=(E=W.config)==null?void 0:E.git)==null?void 0:P.remoteUrl)||"")):a({}),V&&(d(V),p(K=>K||V.vaultRoot||"")),await C()}catch(W){s.error(`Config load failed: ${W.message}`)}finally{r(!1)}},C=async()=>{try{const E=await H.get("/memory/git/status");E.ok&&y({clean:E.clean,branch:E.branch,modified:E.modified,untracked:E.untracked})}catch{}};f.useEffect(()=>{k()},[t]);const _=async()=>{const E=u.trim();if(!E){s.error("Vault path cannot be empty.");return}g(!0);try{const P=await H.get("/memory/status").catch(()=>null);(P==null?void 0:P.initialized)?(await H.post("/memory/config/vault",{vaultRoot:E}),s.success(`Vault path updated to ${E}.`)):(await H.post("/memory/init",{vaultRoot:E}),s.success(`Vault initialised at ${E}.`)),p(E),await k()}catch(P){s.error(`Vault path save failed: ${P.message}`)}finally{g(!1)}},L=async()=>{v(!0);try{await H.post("/memory/init",{}),s.success("Vault initialised."),await k()}catch(E){s.error(`Init failed: ${E.message}`)}finally{v(!1)}},N=async()=>{if(n){l(!0);try{await H.put("/memory/config/global",{git:{remoteUrl:c}}),s.success("Config saved.")}catch(E){s.error(`Save failed: ${E.message}`)}finally{l(!1)}}},T=async E=>{S(E);try{if(E==="pull"){const P=await H.post("/memory/git/pull",{});P.ok?s.success("Pull successful."):s.error(`Pull failed: ${P.output||"unknown error"}`)}else if(E==="push")(await H.post("/memory/git/push",{})).ok?s.success("Push successful."):s.error("Push failed.");else if(E==="commit"){const P=await H.post("/memory/git/commit",{});P.ok?s.success(`Committed: ${P.message}`):s.error("Commit failed.")}await C()}catch(P){s.error(`${E} failed: ${P.message}`)}finally{S(null)}},I=async()=>{A(!0);try{const E=await H.post("/memory/test-git",{});M(E.checks)}catch(E){s.error(`Test failed: ${E.message}`)}finally{A(!1)}};if(i&&!n)return e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"md"}),e.jsx("p",{children:"Loading config…"})]});if(!n)return e.jsx("div",{className:"muted",children:"No config available."});const R=!!(m!=null&&m.initialized),B=(m==null?void 0:m.vaultRoot)??"";return e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(dr,{size:14})," Vault location"]}),e.jsxs(ue,{children:["The on-disk folder where notes and memory metadata live. Default:"," ",e.jsx("code",{children:"~/.bizar_memory"}),"."]}),e.jsxs("div",{className:"memory-config-form",children:[e.jsxs(Cn,{label:"Current path",inline:!0,children:[e.jsx("span",{className:"memory-vault-path mono","data-testid":"memory-current-vault-path",children:B||e.jsx("span",{className:"muted",children:"not initialised"})}),R?e.jsxs("span",{className:"memory-pill memory-pill-ok",style:{marginLeft:8},title:"Vault folder exists on disk",children:[e.jsx(Ke,{size:10})," initialised"]}):e.jsxs("span",{className:"memory-pill memory-pill-warn",style:{marginLeft:8},title:"Vault folder does not exist yet",children:[e.jsx(ls,{size:10})," not initialised"]})]}),e.jsxs(Cn,{label:"Set path",children:[e.jsx("input",{type:"text",className:"input mono",value:u,onChange:E=>p(E.target.value),placeholder:"~/.bizar_memory","aria-label":"Vault path","data-testid":"memory-vault-path-input"}),e.jsx("span",{className:"field-hint",children:R?"Save to update the working path.":"Save and initialise will create this folder if it does not exist."})]})]}),e.jsxs("div",{className:"memory-action-row",style:{marginTop:12},children:[e.jsxs(U,{variant:"primary",onClick:_,disabled:j||x||!u.trim(),"data-testid":"memory-save-vault-path",children:[j?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(bs,{size:12}),R?"Save path":"Save and initialise"]}),!R&&e.jsxs(U,{variant:"secondary",onClick:L,disabled:x||j,"data-testid":"memory-init-vault",children:[x?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(dr,{size:12}),"Initialise default"]})]})]}),e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(gt,{size:14})," Git sync"]}),e.jsx(ue,{children:"Configure the git remote and sync your memory vault."}),e.jsxs("div",{className:"memory-config-form",children:[e.jsx(Cn,{label:"Remote URL",children:e.jsx("input",{type:"text",className:"input mono",value:c,onChange:E=>h(E.target.value),placeholder:"git@github.com:org/repo.git"})}),b&&e.jsxs(Cn,{label:"Status",inline:!0,children:[e.jsx("span",{className:se("memory-pill",b.clean?"memory-pill-ok":"memory-pill-warn"),children:b.clean?"clean":"dirty"}),b.branch&&e.jsxs("span",{className:"muted",style:{marginLeft:8},children:[e.jsx(gt,{size:12,style:{display:"inline"}})," ",b.branch]}),!b.clean&&b.modified!==void 0&&e.jsxs("span",{className:"muted",style:{marginLeft:8},children:[b.modified," modified, ",b.untracked," untracked"]})]})]}),e.jsxs("div",{className:"memory-action-row",style:{marginTop:12},children:[e.jsxs(U,{variant:"secondary",onClick:()=>T("pull"),disabled:w!==null,children:[w==="pull"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(ts,{size:12}),"Pull"]}),e.jsxs(U,{variant:"secondary",onClick:()=>T("commit"),disabled:w!==null,children:[w==="commit"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Qo,{size:12}),"Commit"]}),e.jsxs(U,{variant:"secondary",onClick:()=>T("push"),disabled:w!==null,children:[w==="push"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(wu,{size:12}),"Push"]})]})]}),e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(si,{size:14})," Connection tests"]}),e.jsx(ue,{children:"Verify the configured git remote is reachable."}),e.jsxs("div",{className:"memory-action-row",children:[e.jsxs(U,{variant:"secondary",onClick:I,disabled:z,children:[z?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(si,{size:12}),"Test git connection"]}),e.jsxs(U,{variant:"primary",onClick:N,disabled:o,children:[o?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(bs,{size:12}),"Save config"]})]}),$&&$.length>0&&e.jsx("ul",{className:"memory-check-list",style:{marginTop:12},children:$.map((E,P)=>e.jsxs("li",{className:"memory-check-row",children:[e.jsx("span",{className:"memory-check-icon",children:e.jsx("span",{className:se("memory-pill",E.pass?"memory-pill-ok":"memory-pill-warn"),children:E.pass?"OK":"FAIL"})}),e.jsx("span",{className:"memory-check-name",children:E.name}),e.jsx("span",{className:"memory-check-detail muted",children:E.detail})]},P))})]})]})}function Cn({label:t,children:s,inline:n}){return n?e.jsxs("div",{className:"memory-config-row-inline",children:[e.jsx("div",{className:"memory-config-row-label",id:`cfg-${t.replace(/\s+/g,"-").toLowerCase()}`,children:t}),e.jsx("div",{className:"memory-config-row-control",role:"group","aria-labelledby":`cfg-${t.replace(/\s+/g,"-").toLowerCase()}`,children:s})]}):e.jsxs("label",{className:"memory-config-row-stack",children:[e.jsx("span",{children:t}),s]})}const _t=800,$r=60,Oa={default:"#8b5cf6",note:"#8b5cf6",entity:"#34d399",concept:"#fbbf24",root:"#f87171"};function $p(t,s){return Oa[t]||Oa[s]||Oa.default}function Ep(t){return 6+Math.min(t.size*2,10)}function _p(t,s){var r,o;if(t.length===0)return[];const n=new Map;for(const l of t)n.set(l.id,new Set);for(const l of s)(r=n.get(l.source))==null||r.add(l.target),(o=n.get(l.target))==null||o.add(l.source);const a=t.map((l,c)=>{const h=c/t.length*Math.PI*2,m=_t*.28;return{...l,x:_t/2+m*Math.cos(h)+(Math.random()-.5)*40,y:_t/2+m*Math.sin(h)+(Math.random()-.5)*40,vx:0,vy:0}}),i=new Map;for(const l of a)i.set(l.id,l);for(let l=0;l<$r;l++){const c=1-l/$r;for(let d=0;d<a.length;d++)for(let u=d+1;u<a.length;u++){const p=a[d],x=a[u],v=x.x-p.x,j=x.y-p.y,g=Math.sqrt(v*v+j*j)||1,b=400*c/(g*g),y=v/g*b,w=j/g*b;p.vx-=y,p.vy-=w,x.vx+=y,x.vy+=w}for(const d of s){const u=i.get(d.source),p=i.get(d.target);if(!u||!p)continue;const x=p.x-u.x,v=p.y-u.y,j=Math.sqrt(x*x+v*v)||1,b=(j-80)*.08*c,y=x/j*b,w=v/j*b;u.vx+=y,u.vy+=w,p.vx-=y,p.vy-=w}const h=_t/2,m=_t/2;for(const d of a)d.vx+=(h-d.x)*.01*c,d.vy+=(m-d.y)*.01*c;for(const d of a)d.vx*=.85,d.vy*=.85,d.x+=d.vx,d.y+=d.vy,d.x=Math.max(20,Math.min(_t-20,d.x)),d.y=Math.max(20,Math.min(_t-20,d.y))}return a}function Tp({data:t,onNodeClick:s,className:n}){const a=f.useRef(null),[i,r]=f.useState({x:0,y:0,scale:1}),o=f.useRef(!1),l=f.useRef({x:0,y:0,tx:0,ty:0}),c=f.useRef(null),[h,m]=f.useState(null),[d,u]=f.useState(null),p=f.useMemo(()=>_p(t.nodes,t.edges),[t.nodes,t.edges]),x=f.useMemo(()=>{const z=new Map;for(const A of p)z.set(A.id,A);return z},[p]),v=f.useCallback(z=>{z.target.closest(".memory-graph-node")||(o.current=!0,l.current={x:z.clientX,y:z.clientY,tx:i.x,ty:i.y})},[i]),j=f.useCallback(z=>{if(!o.current)return;const A=z.clientX-l.current.x,k=z.clientY-l.current.y;r(C=>({...C,x:l.current.tx+A,y:l.current.ty+k}))},[]),g=f.useCallback(()=>{o.current=!1},[]),b=f.useCallback(z=>{z.preventDefault();const A=z.deltaY<0?1.1:.9,k=a.current;if(!k)return;const C=k.getBoundingClientRect(),_=z.clientX-C.left,L=z.clientY-C.top;r(N=>{const T=Math.max(.2,Math.min(4,N.scale*A)),I=T/N.scale;return{x:_-(_-N.x)*I,y:L-(L-N.y)*I,scale:T}})},[]),y=f.useCallback(z=>{const A=Array.from(z.touches);if(A.length===2){const[k,C]=A;c.current=Math.hypot(C.clientX-k.clientX,C.clientY-k.clientY)}else A.length===1&&(o.current=!0,l.current={x:A[0].clientX,y:A[0].clientY,tx:i.x,ty:i.y})},[i]),w=f.useCallback(z=>{const A=Array.from(z.touches);if(A.length===2&&c.current!==null){const[k,C]=A,_=Math.hypot(C.clientX-k.clientX,C.clientY-k.clientY),L=_/c.current;c.current=_,r(N=>({...N,scale:Math.max(.2,Math.min(4,N.scale*L))}))}else if(A.length===1&&o.current){const k=A[0].clientX-l.current.x,C=A[0].clientY-l.current.y;r(_=>({..._,x:l.current.tx+k,y:l.current.ty+C}))}},[]),S=f.useCallback(()=>{o.current=!1,c.current=null},[]),$=f.useCallback(z=>{m(z.id===h?null:z.id),s==null||s(z)},[h,s]),M=Math.max(.5,1/Math.log2(i.scale+1));return e.jsx("svg",{ref:a,className:se("memory-graph-canvas",n),viewBox:`0 0 ${_t} ${_t}`,style:{width:"100%",height:"100%",minHeight:400,cursor:o.current?"grabbing":"grab"},onMouseDown:v,onMouseMove:j,onMouseUp:g,onMouseLeave:g,onWheel:b,onTouchStart:y,onTouchMove:w,onTouchEnd:S,children:e.jsxs("g",{transform:`translate(${i.x},${i.y}) scale(${i.scale})`,children:[t.edges.map((z,A)=>{const k=x.get(z.source),C=x.get(z.target);if(!k||!C)return null;const _=d===z.source||d===z.target||h===z.source||h===z.target;return e.jsx("line",{x1:k.x,y1:k.y,x2:C.x,y2:C.y,stroke:_?"#8b5cf6":"#2d3648",strokeWidth:_?M*2:M,strokeOpacity:_?.9:.5},`e-${A}`)}),p.map(z=>{const A=Ep(z),k=$p(z.group,z.type),C=h===z.id,_=d===z.id;return e.jsxs("g",{className:"memory-graph-node",transform:`translate(${z.x},${z.y})`,onClick:()=>$(z),onMouseEnter:()=>u(z.id),onMouseLeave:()=>u(null),style:{cursor:"pointer"},children:[e.jsx("circle",{r:A+6,fill:"transparent"}),(C||_)&&e.jsx("circle",{r:A+4,fill:k,fillOpacity:.2}),e.jsx("circle",{r:A,fill:k,fillOpacity:C?1:.75,stroke:C?"#fff":k,strokeWidth:C?2:1}),i.scale>.5&&e.jsx("text",{y:A+12,textAnchor:"middle",fontSize:Math.max(8,Math.min(11,10/Math.sqrt(i.scale))),fill:"var(--text-dim, #b4bcd0)",style:{pointerEvents:"none",userSelect:"none"},children:z.label.length>20?z.label.slice(0,18)+"…":z.label})]},z.id)})]})})}const Ap=[{color:"#8b5cf6",label:"Note / Default"},{color:"#34d399",label:"Entity (LightRAG)"},{color:"#fbbf24",label:"Concept (LightRAG)"},{color:"#f87171",label:"Root / Ungrouped"}];function Rp({className:t}){return e.jsx("div",{className:se("memory-graph-legend",t),children:Ap.map(s=>e.jsxs("span",{className:"memory-graph-legend-item",children:[e.jsx("span",{className:"memory-graph-legend-dot",style:{background:s.color}}),s.label]},s.label))})}function Ip({refreshKey:t}){const s=fe(),[n,a]=f.useState({nodes:[],edges:[]}),[i,r]=f.useState(!0),[o,l]=f.useState(null),[c,h]=f.useState(""),[m,d]=f.useState(2),[u,p]=f.useState(""),[x,v]=f.useState(null),[j,g]=f.useState(null),b=f.useCallback(async()=>{var S,$;r(!0),l(null);try{const M=new URLSearchParams({limit:"200"});u&&M.set("root",u),M.set("depth",String(m));const z=await H.get(`/memory/graph?${M}`);a({nodes:z.nodes||[],edges:z.edges||[]}),v({totalNodes:z.totalNodes??((S=z.nodes)==null?void 0:S.length)??0,totalEdges:z.totalEdges??(($=z.edges)==null?void 0:$.length)??0})}catch(M){l(M.message),s.error(`Graph load failed: ${M.message}`)}finally{r(!1)}},[u,m,s]);f.useEffect(()=>{b()},[b,t]);const y=f.useCallback(S=>{g($=>($==null?void 0:$.id)===S.id?null:S)},[]),w=c.trim()?{nodes:n.nodes.filter(S=>S.label.toLowerCase().includes(c.toLowerCase())),edges:n.edges.filter(S=>n.nodes.some($=>$.id===S.source&&$.label.toLowerCase().includes(c.toLowerCase()))||n.nodes.some($=>$.id===S.target&&$.label.toLowerCase().includes(c.toLowerCase())))}:n;return e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(sl,{size:14})," Memory Graph"]}),e.jsx(ue,{children:"Interactive knowledge graph — LightRAG entities + Obsidian wikilinks. Drag to pan, scroll to zoom."}),e.jsxs("div",{className:"memory-graph-controls",children:[e.jsxs("div",{className:"memory-graph-search-row",children:[e.jsx("label",{htmlFor:"graph-filter",className:"sr-only",children:"Filter nodes"}),e.jsx("input",{id:"graph-filter",type:"text",className:"input",placeholder:"Filter nodes…",value:c,onChange:S=>h(S.target.value),style:{maxWidth:240}}),e.jsx("input",{type:"text",className:"input",placeholder:"Root note id (optional)",value:u,onChange:S=>p(S.target.value),style:{maxWidth:240},title:"Start from a specific note"}),e.jsx("label",{htmlFor:"graph-depth",className:"sr-only",children:"Depth"}),e.jsxs("span",{className:"muted text-sm",style:{whiteSpace:"nowrap"},children:["Depth",e.jsx("input",{id:"graph-depth",type:"range",min:1,max:3,value:m,onChange:S=>d(parseInt(S.target.value,10)),style:{marginLeft:8,verticalAlign:"middle"}}),m]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:b,title:"Refresh graph",disabled:i,children:e.jsx(xe,{size:14,className:i?"memory-spin":""})})]}),e.jsx(Rp,{})]})]}),e.jsx(ne,{children:i&&!n.nodes.length?e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading graph…"})]}):o&&!n.nodes.length?e.jsxs("div",{className:"muted text-sm",children:["Failed to load graph: ",o]}):n.nodes.length===0?e.jsx("div",{className:"muted text-sm",children:"No graph data available. Index some notes first with LightRAG or add wikilinks to your vault."}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Tp,{data:w,onNodeClick:y,className:"memory-graph-canvas-svg"}),c&&e.jsxs("div",{className:"text-xs muted",style:{marginTop:4},children:["Showing ",w.nodes.length," of ",n.nodes.length," nodes"]})]})}),j&&e.jsxs(ne,{children:[e.jsx(de,{children:j.label}),e.jsx(ue,{children:e.jsx("code",{children:j.id})}),e.jsxs("dl",{className:"memory-config-row",children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{children:e.jsx("code",{children:j.type})}),e.jsx("dt",{children:"Group"}),e.jsx("dd",{children:e.jsx("code",{children:j.group})}),e.jsx("dt",{children:"Size"}),e.jsx("dd",{children:j.size})]})]}),x&&e.jsx(ne,{children:e.jsxs("div",{className:"memory-graph-stats",children:[e.jsxs("span",{children:[x.totalNodes," node",x.totalNodes!==1?"s":""]}),e.jsx("span",{className:"muted",children:"·"}),e.jsxs("span",{children:[x.totalEdges," edge",x.totalEdges!==1?"s":""]}),c&&e.jsxs("span",{className:"muted",children:["· ",w.nodes.length," shown"]})]})})]})}function Lp({onTextExtracted:t}){const s=fe(),[n,a]=f.useState(null),[i,r]=f.useState(!1),[o,l]=f.useState(!1),c=f.useCallback(async()=>{l(!0);try{const d=await navigator.mediaDevices.getDisplayMedia({video:{mediaSource:"screen"}}),u=document.createElement("video");u.srcObject=d,await u.play();const p=document.createElement("canvas");p.width=u.videoWidth,p.height=u.videoHeight;const x=p.getContext("2d");if(!x){s.error("Failed to get canvas context");return}x.drawImage(u,0,0),d.getTracks().forEach(v=>v.stop()),u.remove(),p.toBlob(async v=>{if(!v){s.error("Failed to capture screenshot");return}const j=URL.createObjectURL(v);a(j),await h(v)},"image/png")}catch(d){d.name!=="NotAllowedError"&&s.error(`Capture failed: ${d.message}`)}finally{l(!1)}},[s]),h=f.useCallback(async d=>{r(!0);try{const u=new FileReader,p=await new Promise((v,j)=>{u.onload=()=>{const g=u.result,b=g.includes(",")?g.split(",")[1]:g;v(b)},u.onerror=()=>j(new Error("FileReader failed")),u.readAsDataURL(d)}),x=await H.post("/ocr/process",{image:p,lang:"eng"});x.ok&&(s.success("Text extracted from screenshot"),t==null||t(x.text,x.notePath))}catch(u){s.error(`OCR failed: ${u.message}`)}finally{r(!1)}},[s,t]),m=f.useCallback(()=>{a(null)},[]);return e.jsxs(ne,{variant:"outlined",className:"screenshot-capture-card",children:[e.jsxs(de,{children:[e.jsx($a,{size:14})," Screenshot Capture"]}),e.jsx("div",{className:"screenshot-capture-body",children:n?e.jsxs("div",{className:"screenshot-capture-preview",children:[e.jsx("img",{src:n,alt:"Captured screenshot",className:"screenshot-capture-img"}),e.jsxs("div",{className:"screenshot-capture-actions",children:[i&&e.jsxs("span",{className:"text-sm muted",children:[e.jsx(je,{size:12,className:"spinner"})," Extracting text…"]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:m,disabled:i,children:"Dismiss"})]})]}):e.jsxs("div",{className:"screenshot-capture-empty",children:[e.jsx($a,{size:32,className:"muted"}),e.jsx("p",{className:"muted text-sm",children:"Capture your screen to extract text via OCR."}),e.jsxs(U,{variant:"primary",size:"sm",onClick:c,disabled:o,children:[o?e.jsx(je,{size:12,className:"spinner"}):e.jsx($a,{size:12}),o?"Selecting…":"Capture Screen"]})]})})]})}function Pp(){const[t,s]=f.useState(null),[n,a]=f.useState(null),i=(r,o)=>{s(r),a(o)};return e.jsxs("div",{className:"screenshot-ocr-panel",children:[e.jsx(Lp,{onTextExtracted:i}),t!==null&&e.jsxs(ne,{variant:"outlined",className:"screenshot-ocr-result-card",children:[e.jsxs(de,{children:[e.jsx(Ve,{size:14})," Extracted Text"]}),n&&e.jsxs(ue,{children:["Saved to: ",n]}),e.jsx("div",{className:"screenshot-ocr-text",children:t?e.jsx("pre",{className:"screenshot-ocr-pre mono text-sm",children:t}):e.jsx("p",{className:"muted text-sm",children:"No text was found in the captured image."})})]})]})}function Dp({refreshKey:t}){return e.jsx("div",{className:"memory-panel-content",children:e.jsx(ne,{variant:"outlined",className:"memory-panel-card",children:e.jsx("div",{className:"memory-panel-body",children:e.jsx(Pp,{})})})})}function Fp({refreshKey:t}){const s=fe(),[n,a]=f.useState(""),[i,r]=f.useState(""),[o,l]=f.useState(""),[c,h]=f.useState(!1),m=async()=>{if(!o.trim()){s.error("Content is required");return}h(!0);try{const d=await H.post("/clipboard/save",{url:n.trim()||void 0,title:i.trim()||void 0,content:o,savedAt:new Date().toISOString()});d.ok&&(s.success(`Saved to ${d.notePath}`),a(""),r(""),l(""))}catch(d){s.error(`Save failed: ${d.message}`)}finally{h(!1)}};return e.jsx("div",{className:"memory-panel-content",children:e.jsx(ne,{variant:"outlined",className:"memory-panel-card",children:e.jsx("div",{className:"memory-panel-body",children:e.jsxs("div",{className:"vault-clipboard-panel",children:[e.jsxs("div",{className:"vault-clipboard-header",children:[e.jsx(Zo,{size:16}),e.jsx("span",{children:"Paste Content"})]}),e.jsx("label",{className:"field-label",htmlFor:"clip-url",children:"URL (optional)"}),e.jsx("input",{id:"clip-url",type:"text",className:"input",placeholder:"https://example.com",value:n,onChange:d=>a(d.target.value)}),e.jsx("label",{className:"field-label",htmlFor:"clip-title",style:{marginTop:10},children:"Title (optional)"}),e.jsx("input",{id:"clip-title",type:"text",className:"input",placeholder:"Page title",value:i,onChange:d=>r(d.target.value)}),e.jsx("label",{className:"field-label",htmlFor:"clip-content",style:{marginTop:10},children:"Content *"}),e.jsx("textarea",{id:"clip-content",className:"input vault-clipboard-textarea mono text-sm",rows:12,placeholder:"Paste or type content to save to your vault…",value:o,onChange:d=>l(d.target.value)}),e.jsx("div",{className:"vault-clipboard-actions",style:{marginTop:12},children:e.jsxs(U,{variant:"primary",size:"sm",onClick:m,disabled:c||!o.trim(),children:[c&&e.jsx(je,{size:12,className:"spinner"}),"Save to Vault"]})})]})})})})}function Op({vaultPath:t,onSaved:s}){const[n,a]=f.useState(!1),[i,r]=f.useState(!1),o=f.useRef(null),l=f.useRef([]),c=async()=>{try{const d=await navigator.mediaDevices.getUserMedia({audio:!0}),u=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",p=new MediaRecorder(d,{mimeType:u});p.ondataavailable=x=>{x.data&&x.data.size>0&&l.current.push(x.data)},p.onstop=async()=>{const x=new Blob(l.current,{type:"audio/webm"});l.current=[],d.getTracks().forEach(v=>v.stop()),await m(x)},p.start(1e3),o.current=p,a(!0)}catch(d){At.error("[VoiceRecorder] failed to start recording:",d)}},h=()=>{const d=o.current;d&&(d.stop(),a(!1),r(!0))},m=async d=>{try{const u=new FormData;u.append("audio",d,"voice-note.webm"),u.append("vaultPath",t||"");const p=await fetch("/api/voice/upload",{method:"POST",body:u});if(!p.ok){At.error("[VoiceRecorder] upload failed:",p.status,await p.text()),r(!1);return}const{notePath:x,transcription:v}=await p.json();s==null||s(x,v)}catch(u){At.error("[VoiceRecorder] upload error:",u)}finally{r(!1)}};return e.jsxs("div",{className:"voice-recorder",children:[!n&&!i&&e.jsxs(U,{variant:"accent",size:"sm",onClick:c,"aria-label":"Start recording",children:[e.jsx(_i,{size:14})," Record"]}),n&&e.jsxs(U,{variant:"danger",size:"sm",onClick:h,"aria-label":"Stop recording",children:[e.jsx(ku,{size:14})," Stop"]}),i&&e.jsxs(U,{variant:"secondary",size:"sm",disabled:!0,children:[e.jsx(je,{size:14,className:"spinning"})," Transcribing…"]})]})}function Bp({note:t,onDelete:s}){const[n,a]=f.useState(!1),[i]=f.useState(()=>{if(!t.audioPath)return null;const l=new Audio(`/api/voice/${t.id}/audio`);return l.onended=()=>a(!1),l}),r=()=>{i&&(n?(i.pause(),i.currentTime=0,a(!1)):(i.play(),a(!0)))},o=new Date(t.createdAtMs).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"voice-note-card",children:[e.jsxs("div",{className:"voice-note-card-head",children:[e.jsxs("div",{className:"voice-note-card-meta",children:[e.jsx("span",{className:"voice-note-date",children:o}),t.durationSec&&e.jsxs("span",{className:"voice-note-duration",children:[Math.round(t.durationSec),"s"]})]}),e.jsxs("div",{className:"voice-note-card-actions",children:[i&&e.jsx("button",{type:"button",className:"icon-btn",onClick:r,"aria-label":n?"Pause":"Play",title:n?"Pause":"Play",children:n?e.jsx(ki,{size:13}):e.jsx(ws,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>s(t.id),"aria-label":"Delete note",title:"Delete note",children:e.jsx(Fe,{size:13})})]})]}),t.transcript&&e.jsx("p",{className:"voice-note-transcript",children:t.transcript}),!t.transcript&&e.jsx("p",{className:"voice-note-no-transcript muted text-sm",children:"No transcription available"})]})}function Hp({vaultPath:t,refreshKey:s=0}){const[n,a]=f.useState([]),[i,r]=f.useState(""),[o,l]=f.useState(!0),c=async()=>{l(!0);try{const d=t?`?vaultPath=${encodeURIComponent(t)}`:"",p=await(await fetch(`/api/voice/list${d}`)).json();a(p.notes||[])}catch(d){At.error("[VoiceNotesPanel] failed to load notes:",d)}finally{l(!1)}};f.useEffect(()=>{c();const d=x=>{try{const v=JSON.parse(x.data);v.type==="voice:updated"&&v.noteId&&a(j=>j.map(g=>{var b;return g.id===v.noteId?{...g,transcript:((b=v.patch)==null?void 0:b.transcript)??g.transcript}:g}))}catch{}},u=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;let p=null;try{p=new WebSocket(u),p.addEventListener("message",d)}catch{}return()=>{p==null||p.removeEventListener("message",d),p==null||p.close()}},[t,s]);const h=async d=>{try{const u=await fetch(`/api/voice/${d}`,{method:"DELETE"});(u.ok||u.status===204)&&a(p=>p.filter(x=>x.id!==d))}catch(u){At.error("[VoiceNotesPanel] delete failed:",u)}},m=n.filter(d=>{var u;return!i||(((u=d.transcript)==null?void 0:u.toLowerCase().includes(i.toLowerCase()))??!1)});return e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(_i,{size:14})," Voice Notes"]}),e.jsx(ue,{children:"Record and transcribe audio notes into your vault"}),e.jsx("div",{className:"memory-search-row",children:e.jsx("input",{type:"text",className:"input search-input",value:i,onChange:d=>r(d.target.value),placeholder:"Search transcripts…","aria-label":"Search voice notes"})}),e.jsx("div",{className:"voice-recorder-row",children:e.jsx(Op,{vaultPath:t,onSaved:c})}),o?e.jsx("p",{className:"muted text-sm",children:"Loading notes…"}):m.length===0?e.jsx("p",{className:"muted text-sm",children:i?"No notes match your search.":"No voice notes yet. Hit Record to add one."}):e.jsx("div",{className:"voice-note-list",children:m.map(d=>e.jsx(Bp,{note:d,onDelete:h},d.id))})]})}const Vp=[{id:"overview",label:"Overview",icon:Jo},{id:"lightrag",label:"LightRAG",icon:xt},{id:"obsidian",label:"Obsidian Vault",icon:Ve},{id:"git",label:"Git Sync",icon:gt},{id:"semantic",label:"Semantic Search",icon:Ae},{id:"config",label:"Config",icon:wi},{id:"graph",label:"Memory Graph",icon:sl},{id:"webclip",label:"Web Clip",icon:Zo},{id:"screenshot",label:"Screenshot OCR",icon:ch},{id:"voice",label:"Voice Notes",icon:_i}];function Up(t){const s=fe(),[n,a]=f.useState("overview"),[i,r]=f.useState(0),o=f.useCallback(()=>{r(h=>h+1)},[]),l=f.useCallback(async()=>{o(),s.info("Refreshing memory…",1200)},[o,s]),c=()=>{switch(n){case"overview":return e.jsx(yp,{refreshKey:i,onRefresh:o,setActiveSubPanel:a});case"lightrag":return e.jsx(jp,{refreshKey:i});case"obsidian":return e.jsx(wp,{refreshKey:i});case"git":return e.jsx(Cp,{refreshKey:i});case"semantic":return e.jsx(zp,{refreshKey:i});case"config":return e.jsx(Mp,{refreshKey:i});case"graph":return e.jsx(Ip,{refreshKey:i});case"webclip":return e.jsx(Fp,{refreshKey:i});case"screenshot":return e.jsx(Dp,{refreshKey:i});case"voice":return e.jsx(Hp,{refreshKey:i});default:return e.jsxs(ne,{children:["Unknown panel: ",n]})}};return e.jsxs("div",{className:"view view-memory memory-tab",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(xt,{size:18})," Memory"]}),e.jsx("p",{className:"view-subtitle",children:"LightRAG, Obsidian vault, git sync, semantic search, web clips, and screenshot OCR — all in one place."})]}),e.jsx("div",{className:"view-actions",children:e.jsx("button",{type:"button",className:"icon-btn",onClick:l,"aria-label":"Refresh memory",title:"Refresh",children:e.jsx(xe,{size:14})})})]}),e.jsxs("div",{className:"memory-tab-body",children:[e.jsx("nav",{className:"memory-source-rail","aria-label":"Memory sources",children:Vp.map(h=>{const m=h.icon,d=n===h.id;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:se("memory-source-button",d&&"memory-source-button-active"),onClick:()=>a(h.id),children:[e.jsx(m,{size:16,"aria-hidden":!0}),e.jsx("span",{children:h.label})]},h.id)})}),e.jsx("div",{className:"memory-main",children:c()},n)]})]})}const qp=rt.memo(Up),Hs=[{id:"1h",label:"Last hour",ms:60*60*1e3},{id:"1d",label:"Last day",ms:24*60*60*1e3},{id:"7d",label:"Last 7 days",ms:7*24*60*60*1e3},{id:"30d",label:"Last 30 days",ms:30*24*60*60*1e3},{id:"all",label:"All time",ms:0}];function Wp(t,s,n,a){const i=n.has(t.id);return e.jsxs(ne,{className:"history-project",style:{marginBottom:4},children:[e.jsxs("div",{className:"history-project-head",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0,flex:1},children:[e.jsxs("div",{className:"history-project-name",children:[e.jsx(lt,{size:16})," ",t.name]}),e.jsx("div",{className:"history-project-meta",children:t.path})]}),e.jsxs("div",{className:"history-project-stats",children:[e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:t.tasks.done}),e.jsxs("span",{className:"muted",children:["/ ",t.tasks.total," done"]})]}),t.tasks.doing>0&&e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:t.tasks.doing}),e.jsx("span",{className:"muted",children:"doing"})]}),t.tasks.blocked>0&&e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:t.tasks.blocked}),e.jsx("span",{className:"muted",children:"blocked"})]}),e.jsxs("span",{className:"history-project-stat",children:[e.jsx(Ve,{size:11})," ",e.jsx("span",{className:"history-project-stat-num",children:t.plans}),e.jsxs("span",{className:"muted",children:[" plan",t.plans===1?"":"s"]})]}),t.lastAccessed&&e.jsx("span",{className:"history-project-stat",children:e.jsxs("span",{className:"muted",children:["last opened ",He(t.lastAccessed)]})})]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>a(t.id),"aria-label":i?"Collapse":"Expand",children:i?e.jsx(ct,{size:14}):e.jsx(Ut,{size:14})})]}),i&&e.jsx("div",{className:"history-timeline-mini",children:s.length===0?e.jsx("div",{className:"muted",style:{padding:"12px 8px",fontSize:12},children:"No events in this time range."}):s.slice(-100).reverse().map((r,o)=>e.jsxs("div",{className:"history-timeline-row",children:[e.jsx("span",{className:"history-timeline-ts",children:new Date(r.ts).toLocaleTimeString()}),e.jsx("span",{className:"history-timeline-kind",children:r.kind||"event"}),e.jsxs("span",{className:"history-timeline-msg",title:String(r.text||r.title||""),children:[r.author?`@${r.author} `:"",String(r.text??r.title??r.name??"")]})]},o))})]},t.id)}function Gp({snapshot:t}){var j,g;const s=fe(),[n,a]=f.useState(null),[i,r]=f.useState(!0),[o,l]=f.useState("1d"),[c,h]=f.useState(new Set),[m,d]=f.useState(0),u=async b=>{try{const y=b?`?since=${encodeURIComponent(b)}&limit=1000`:"?limit=1000",w=await H.get(`/history${y}`);a(w),h(new Set(w.projects.filter(S=>w.events.some($=>$.projectId===S.id)).map(S=>S.id)))}catch(y){s.error(`History load failed: ${y.message}`)}finally{r(!1)}};f.useEffect(()=>{r(!0);const b=Hs.find(y=>y.id===o)||Hs[1];if(b.ms>0){const y=new Date(Date.now()-b.ms).toISOString();u(y)}else u()},[o]),f.useEffect(()=>{const b=setInterval(()=>d(y=>y+1),3e4);return()=>clearInterval(b)},[]);const p=new Map;for(const b of(n==null?void 0:n.events)||[]){const y=b.projectId||"global";p.has(y)||p.set(y,[]),p.get(y).push(b)}const x=b=>{h(y=>{const w=new Set(y);return w.has(b)?w.delete(b):w.add(b),w})},v=()=>{if(!n)return;const b=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),y=URL.createObjectURL(b),w=document.createElement("a");w.href=y,w.download=`bizar-history-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,w.click(),URL.revokeObjectURL(y),s.success("History exported.")};return e.jsxs("div",{className:"view view-history","data-tick":m,children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Zs,{size:18})," History"]}),e.jsxs("p",{className:"view-subtitle",children:["Cross-project history of events, tasks, and plans.",((j=n==null?void 0:n.stats)==null?void 0:j.lastTs)&&e.jsxs(e.Fragment,{children:[" · last event ",He(n.stats.lastTs)]})]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsx(Vu,{size:14,style:{color:"var(--text-dim)"},"aria-hidden":!0}),e.jsx("label",{htmlFor:"history-range",className:"sr-only",children:"Time range"}),e.jsx("select",{id:"history-range",className:"select select-sm",value:o,onChange:b=>l(b.target.value),title:"Time range","aria-label":"Time range",children:Hs.map(b=>e.jsx("option",{value:b.id,children:b.label},b.id))})]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>{r(!0);const b=Hs.find(y=>y.id===o)||Hs[1];b.ms>0?u(new Date(Date.now()-b.ms).toISOString()):u()},children:[e.jsx(xe,{size:14})," Refresh"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:v,children:[e.jsx(ts,{size:14})," Export"]})]})]}),i&&e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading history…"})]}),!i&&n&&e.jsxs("div",{className:"history-list",children:[n.projects.length===0&&e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(lt,{size:14})," No projects"]}),e.jsx(ue,{children:"Register a project in Overview to start tracking history."})]}),n.projects.length>0&&e.jsx(qo,{items:n.projects,itemHeight:70,height:Math.min(n.projects.length*70,500),className:"history-virtual-list",renderItem:b=>Wp(b,p.get(b.id)||[],c,x)}),p.has("global")&&e.jsxs(ne,{className:"history-project",children:[e.jsx("div",{className:"history-project-head",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0,flex:1},children:[e.jsxs("div",{className:"history-project-name",children:[e.jsx(Zs,{size:16})," Global events"]}),e.jsx("div",{className:"history-project-meta",children:"Activity not tied to a specific project"})]})}),e.jsx("div",{className:"history-timeline-mini",children:(p.get("global")||[]).slice(-100).reverse().map((b,y)=>e.jsxs("div",{className:"history-timeline-row",children:[e.jsx("span",{className:"history-timeline-ts",children:new Date(b.ts).toLocaleTimeString()}),e.jsx("span",{className:"history-timeline-kind",children:b.kind||"event"}),e.jsxs("span",{className:"history-timeline-msg",title:String(b.text||b.title||""),children:[b.author?`@${b.author} `:"",String(b.text??b.title??b.name??"")]})]},y))})]}),((g=n.stats)==null?void 0:g.counts)&&Object.keys(n.stats.counts).length>0&&e.jsxs(ne,{children:[e.jsx(de,{children:"Event counts by kind"}),e.jsxs(ue,{children:[n.stats.lines," total lines in log"]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:8},children:Object.entries(n.stats.counts).sort((b,y)=>y[1]-b[1]).slice(0,30).map(([b,y])=>e.jsxs("span",{className:se("tag","tag-neutral"),style:{fontFamily:"var(--font-mono)"},children:[b,": ",y]},b))})]})]})]})}const Ee={top:16,right:20,bottom:40,left:52};function Yp({series:t,height:s=280,onHover:n,className:a}){const i=f.useRef(null),[r,o]=f.useState(null),{labels:l,requests:c,tokens:h}=t,m=l.length;if(m===0)return e.jsx("div",{className:se("usage-chart-empty",a),style:{height:s},children:e.jsx("span",{children:"No data for this range"})});const d=600-Ee.left-Ee.right,u=s-Ee.top-Ee.bottom,p=Math.max(...c,1),x=Math.max(...h,1),v=Math.max(4,Math.min(24,Math.floor(d/m)-4)),j=(d-v*m)/(m+1);function g(_){return Ee.left+j+_*(v+j)}function b(_){return _/p*u*.75}function y(_){return Ee.top+u-_/x*u*.75}const w=h.map((_,L)=>`${g(L)+v/2},${y(_)}`).join(" "),S=[0,.25,.5,.75,1].map(_=>({y:Ee.top+u-_*u*.75,label:_===0?"0":`${Math.round(p*_).toLocaleString()}`})),$=[0,.25,.5,.75,1].map(_=>({y:Ee.top+u-_*u*.75,label:_===0?"0":`${Math.round(x*_/1e3)}k`})),M=Math.max(1,Math.floor(m/7)),z=l.map((_,L)=>({i:L,l:_,x:g(L)+v/2})).filter((_,L)=>L%M===0),A=f.useCallback(_=>{if(!i.current)return;const L=i.current.getBoundingClientRect(),N=(_.clientX-L.left)*(600/L.width),T=(_.clientY-L.top)*(s/L.height),I=N-Ee.left,R=Math.round((I-j/2)/(v+j)),B=Math.max(0,Math.min(m-1,R));o({index:B,x:_.clientX-L.left,y:_.clientY-L.top}),n==null||n(B,N,T)},[m,v,j,n,s]),k=f.useCallback(()=>{o(null),n==null||n(null,0,0)},[n]),C=r;return e.jsxs("div",{ref:i,className:se("usage-chart",a),style:{position:"relative"},children:[e.jsxs("svg",{viewBox:`0 0 600 ${s}`,width:"100%",height:s,style:{display:"block",overflow:"visible"},onMouseMove:A,onMouseLeave:k,children:[S.map((_,L)=>e.jsx("line",{x1:Ee.left,y1:_.y,x2:600-Ee.right,y2:_.y,stroke:"var(--border)",strokeWidth:1,strokeDasharray:"4,3",opacity:.5},`grid-${L}`)),S.map((_,L)=>e.jsx("text",{x:Ee.left-6,y:_.y+4,textAnchor:"end",fontSize:10,fill:"var(--text-muted)",fontFamily:"var(--font-mono, ui-monospace, monospace)",children:_.label},`ly-${L}`)),$.map((_,L)=>e.jsx("text",{x:600-Ee.right+6,y:_.y+4,textAnchor:"start",fontSize:10,fill:"var(--text-muted)",fontFamily:"var(--font-mono, ui-monospace, monospace)",children:_.label},`ry-${L}`)),c.map((_,L)=>{const N=b(_),T=g(L),I=Ee.top+u-N;return e.jsx("rect",{x:T,y:I,width:v,height:N,rx:2,fill:((C==null?void 0:C.index)===L,"var(--accent)"),opacity:(C==null?void 0:C.index)===L?1:.75,style:{transition:"opacity 120ms ease"}},`bar-${L}`)}),e.jsx("polyline",{points:w,fill:"none",stroke:"var(--warning, #d29922)",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",opacity:.9}),h.map((_,L)=>e.jsx("circle",{cx:g(L)+v/2,cy:y(_),r:(C==null?void 0:C.index)===L?5:3,fill:"var(--warning, #d29922)",opacity:(C==null?void 0:C.index)===L?1:.7,style:{transition:"r 120ms ease"}},`dot-${L}`)),z.map(({i:_,l:L,x:N})=>e.jsx("text",{x:N,y:Ee.top+u+18,textAnchor:"middle",fontSize:10,fill:"var(--text-muted)",fontFamily:"var(--font-mono, ui-monospace, monospace)",children:L},`xl-${_}`)),e.jsx("line",{x1:Ee.left,y1:Ee.top+u,x2:600-Ee.right,y2:Ee.top+u,stroke:"var(--border)",strokeWidth:1})]}),C!==null&&e.jsxs("div",{className:"usage-chart-tooltip",style:{left:Math.min(C.x+12,460),top:C.y-60},children:[e.jsx("div",{className:"usage-tooltip-date",children:l[C.index]}),e.jsxs("div",{className:"usage-tooltip-row",children:[e.jsx("span",{className:"usage-tooltip-dot",style:{background:"var(--accent)"}}),e.jsx("span",{children:"Requests:"}),e.jsx("strong",{children:c[C.index].toLocaleString()})]}),e.jsxs("div",{className:"usage-tooltip-row",children:[e.jsx("span",{className:"usage-tooltip-dot",style:{background:"var(--warning, #d29922)"}}),e.jsx("span",{children:"Tokens:"}),e.jsx("strong",{children:h[C.index].toLocaleString()})]})]})]})}function Wt({label:t,col:s,sortKey:n,sortDir:a,onSort:i}){const r=n===s;return e.jsxs("th",{className:se("usage-sort-header",r&&"is-active"),onClick:()=>i(s),"aria-sort":r?a==="asc"?"ascending":"descending":"none",children:[e.jsx("span",{children:t}),e.jsx("span",{className:"usage-sort-icon",children:r?a==="asc"?" ↑":" ↓":" ↕"})]})}function Xp({rows:t,sortKey:s,sortDir:n,onSort:a}){return e.jsx("div",{className:"usage-table-wrap",children:e.jsxs("table",{className:"usage-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(Wt,{label:"Model",col:"modelId",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Requests",col:"requests",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Prompt Tok",col:"promptTokens",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Compl Tok",col:"completionTokens",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Total Tok",col:"totalTokens",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Avg Latency",col:"avgLatencyMs",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Errors",col:"errors",sortKey:s,sortDir:n,onSort:a})]})}),e.jsx("tbody",{children:t.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"usage-table-empty",children:"No data for this range"})}):t.map(i=>e.jsxs("tr",{children:[e.jsx("td",{className:"usage-table-model",children:e.jsx("code",{children:i.modelId})}),e.jsx("td",{className:"mono",children:i.requests.toLocaleString()}),e.jsx("td",{className:"mono",children:i.promptTokens.toLocaleString()}),e.jsx("td",{className:"mono",children:i.completionTokens.toLocaleString()}),e.jsx("td",{className:"mono",children:i.totalTokens.toLocaleString()}),e.jsxs("td",{className:"mono",children:[i.avgLatencyMs,"ms"]}),e.jsx("td",{className:se("mono",i.errors>0&&"is-err"),children:i.errors>0?i.errors:"—"})]},`${i.providerId}::${i.modelId}`))})]})})}function Kp({activeTab:t,setActiveTab:s}){const[n,a]=f.useState("quota"),i=fe();return e.jsxs("div",{className:"view-container view-minimax-usage",children:[e.jsxs("div",{className:"minimax-sub-tabs",children:[e.jsxs("button",{className:se("minimax-sub-tab",n==="quota"&&"is-active"),onClick:()=>a("quota"),children:[e.jsx(Ei,{size:13})," Token Plan"]}),e.jsxs("button",{className:se("minimax-sub-tab",n==="analytics"&&"is-active"),onClick:()=>a("analytics"),children:[e.jsx(Ko,{size:13})," Usage Analytics"]})]}),n==="quota"?e.jsx(Zp,{activeTab:t,setActiveTab:s}):e.jsx(Qp,{toast:i})]})}function Zp({activeTab:t,setActiveTab:s}){var K;const n=fe(),[a,i]=f.useState(null),[r,o]=f.useState(null),[l,c]=f.useState(null),[h,m]=f.useState(!0),[d,u]=f.useState(!1),[p,x]=f.useState(null),[v,j]=f.useState(null),[g,b]=f.useState(!1),[y,w]=f.useState(0),[S,$]=f.useState(!1),[M,z]=f.useState(null),[A,k]=f.useState(""),[C,_]=f.useState(!1),[L,N]=f.useState(!1),T=f.useCallback(async()=>{m(!0),x(null);try{const[D,G,ee]=await Promise.all([H.get("/minimax/status"),H.get("/minimax/remains"),H.get("/minimax/onboarding")]);i(D),o(G),c(ee),D.configured&&w(4)}catch(D){x(D.message||"Failed to load MiniMax data")}finally{m(!1)}},[]);f.useEffect(()=>{T()},[T]);const I=f.useCallback(async()=>{try{await H.post("/minimax/onboarding",{dismissedAt:Date.now()}),c(D=>D&&{...D,dismissedAt:Date.now()})}catch{}},[]),R=f.useCallback(async()=>{if(!A.trim()){n.error("Paste a Subscription Key first.");return}$(!0),z(null);try{const D=await H.post("/minimax/test",{prompt:"Reply with a single word: pong",model:"MiniMax-M3",maxTokens:16});if(z(D),D.ok){w(3),n.success("Key works. Saving…");try{await H.post("/minimax/onboarding/save-key",{key:A.trim(),groupId:"default"}),E(),n.success("Subscription Key saved.")}catch(G){n.error(`Save failed: ${G.message}`)}T()}else n.error(`Verification failed: ${D.message??D.error??"unknown"}`)}catch(D){n.error(`Test request failed: ${D.message}`)}finally{$(!1)}},[A,n,T]),B=f.useCallback(async()=>{if(!A.trim()){n.error("Paste a Subscription Key first.");return}N(!0);try{const D=await H.post("/minimax/onboarding/save-key",{key:A.trim(),groupId:"default"});if(!D.ok){n.error(`Save failed: ${D.message??D.error??"unknown"}`);return}k(""),E(),n.success("Subscription Key saved. Loading quota…"),T()}catch(D){n.error(`Save failed: ${D.message}`)}finally{N(!1)}},[A,n,T]),E=f.useCallback(async()=>{try{await H.del("/minimax/cache")}catch{}},[]),P=f.useCallback(async()=>{u(!0),x(null);try{await H.post("/minimax/remains/refresh"),await T(),n.success("Refreshed")}catch(D){n.error(`Refresh failed: ${D.message}`)}finally{u(!1)}},[T,n]),W=f.useCallback(async()=>{var D;b(!0),j(null);try{const G=await H.post("/minimax/test",{prompt:"Reply with a single word: pong",model:"MiniMax-M3",maxTokens:16});j(G),G.ok?n.success(`Test ok — used ${((D=G.usage)==null?void 0:D.total_tokens)??"?"} tokens`):n.error(`Test failed: ${G.message??G.error??"unknown"}`)}catch(G){n.error(`Test request failed: ${G.message}`)}finally{b(!1)}},[n]);return h&&!a?e.jsxs("div",{className:"view-container",children:[e.jsx(ye,{})," Loading MiniMax data…"]}):a?!a.configured&&(l==null?void 0:l.dismissedAt)==null&&y<4?e.jsx(tx,{step:y,setStep:w,keyDraft:A,setKeyDraft:k,showKey:C,setShowKey:_,verifying:S,verifyResult:M,onVerify:R,onSkip:async()=>{await I(),n.success("Skipped.")},onManualKeySave:B,savingKey:L,status:a}):e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-titles",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(Ei,{size:20,style:{verticalAlign:"text-bottom",marginRight:6}}),"MiniMax Token Plan"]}),e.jsxs("p",{className:"view-subtitle",children:["Remaining 5-hour + weekly quota per model. Fetches live from"," ",e.jsx("code",{children:"www.minimax.io/v1/token_plan/remains"}),"."]})]}),e.jsxs("div",{className:"view-header-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>s("settings"),title:"Configure your Subscription Key",children:[e.jsx(zi,{size:14})," ",a.configured?`Key ${a.apiKeyHint}`:"Add key"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:P,disabled:d,children:[d?e.jsx(je,{size:14,className:"spin"}):e.jsx(xe,{size:14})," Refresh"]})]})]}),r&&!r.ok&&e.jsxs("div",{className:"banner banner-err",children:[e.jsx(Ue,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"Couldn't load quota"}),": ",r.message??r.error??"unknown error"]})]}),(r==null?void 0:r.ok)&&r.models&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"minimax-stats-row",children:[e.jsx(zn,{label:"Models tracked",value:String(r.models.length),hint:"Distinct model quotas returned by the API"}),e.jsx(zn,{label:"Last fetched",value:r.fetchedAt?ex(r.fetchedAt):"—",hint:"Refreshed on demand + every 60s"}),e.jsx(zn,{label:"Group",value:r.groupId??"—",hint:"Usually 'default' for an individual team"}),e.jsx(zn,{label:"API key",value:r.apiKeyHint??"—",hint:"Masked; the real key never leaves auth.json"})]}),e.jsx("div",{className:"minimax-models-grid",children:r.models.map(D=>e.jsx(Jp,{model:D},D.model_name))})]}),a.configured&&e.jsxs(ne,{id:"minimax-test",children:[e.jsxs(de,{children:[e.jsx(Rt,{size:14})," Test the API key"]}),e.jsxs(ue,{children:["One-shot chat completion to ",e.jsxs("code",{children:[a.chatBaseUrl,"/chat/completions"]}),"."]}),e.jsxs("div",{className:"minimax-test-actions",children:[e.jsxs(U,{onClick:W,disabled:g,variant:"primary",size:"sm",children:[g?e.jsx(je,{size:14,className:"spin"}):e.jsx(Rt,{size:14})," Send test prompt"]}),e.jsx("code",{className:"minimax-test-prompt",children:'"Reply with a single word: pong"'})]}),v&&e.jsxs("div",{className:se("minimax-test-result",v.ok?"ok":"err"),children:[v.ok?e.jsx(Ke,{size:14}):e.jsx(Ue,{size:14}),e.jsx("div",{className:"minimax-test-body",children:v.ok?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"minimax-test-line",children:[e.jsx("strong",{children:"model:"})," ",e.jsx("code",{children:v.model})," ·"," ",e.jsx("strong",{children:"finish:"})," ",v.finishReason??"—"]}),v.content&&e.jsx("div",{className:"minimax-test-content",children:e.jsx("code",{children:v.content})}),v.usage&&e.jsxs("div",{className:"minimax-test-usage",children:[e.jsx("strong",{children:"usage:"})," total ",e.jsx("code",{children:v.usage.total_tokens??"?"})," · prompt"," ",e.jsx("code",{children:v.usage.prompt_tokens??"?"})," · completion"," ",e.jsx("code",{children:v.usage.completion_tokens??"?"}),((K=v.usage.prompt_tokens_details)==null?void 0:K.cached_tokens)!=null&&e.jsxs(e.Fragment,{children:[" · cached ",e.jsx("code",{children:v.usage.prompt_tokens_details.cached_tokens})]})]})]}):e.jsx("pre",{children:v.message??v.error??"unknown error"})})]})]})]}):e.jsx("div",{className:"view-container",children:e.jsxs("div",{className:"error-card",children:[e.jsx(Ue,{size:20}),e.jsxs("div",{children:[e.jsx("strong",{children:"Couldn't load MiniMax status"}),e.jsx("pre",{children:p??"unknown error"})]})]})})}function Qp({toast:t}){const[s,n]=f.useState("24h"),[a,i]=f.useState(""),[r,o]=f.useState(""),[l,c]=f.useState(!0),[h,m]=f.useState(null),[d,u]=f.useState([]),[p,x]=f.useState("requests"),[v,j]=f.useState("desc"),[g,b]=f.useState(!1),y=f.useCallback(async(C,_,L)=>{c(!0);try{const N=new URLSearchParams({range:C});C==="custom"&&_&&L&&(N.set("from",String(_)),N.set("to",String(L)));const[T,I]=await Promise.all([H.get(`/usage?${N.toString()}`),H.get("/usage/recent?limit=20")]);m(T),u(I.records)}catch(N){t.error(`Failed to load usage data: ${N.message}`)}finally{c(!1)}},[t]);f.useEffect(()=>{if(s==="custom"){const C=a?new Date(a).getTime():Date.now()-6048e5,_=r?new Date(r).getTime():Date.now();y("custom",C,_)}else y(s)},[s,y]);const w=f.useCallback(C=>{p===C?j(_=>_==="asc"?"desc":"asc"):(x(C),j("desc"))},[p]),S=f.useMemo(()=>h!=null&&h.perModel?[...h.perModel].sort((C,_)=>{const L=C[p]??0,N=_[p]??0,T=typeof L=="number"&&typeof N=="number"?L-N:String(L).localeCompare(String(N));return v==="asc"?T:-T}):[],[h==null?void 0:h.perModel,p,v]),$=f.useMemo(()=>h!=null&&h.daily?{labels:h.daily.map(C=>C.date.slice(5)),requests:h.daily.map(C=>C.requests),tokens:h.daily.map(C=>C.totalTokens)}:{labels:[],requests:[],tokens:[]},[h==null?void 0:h.daily]),M=f.useCallback(async()=>{b(!0),await y(s==="custom"?"custom":s,s==="custom"&&a?new Date(a).getTime():void 0,s==="custom"&&r?new Date(r).getTime():void 0),b(!1)},[y,s,a,r]);if(l&&!h)return e.jsxs("div",{className:"view-container",children:[e.jsx(ye,{})," Loading usage data…"]});const z=h==null?void 0:h.totals,A=(h==null?void 0:h.errors)??[],k=(h==null?void 0:h.perKey)??[];return e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-titles",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(Ko,{size:20,style:{verticalAlign:"text-bottom",marginRight:6}}),"Usage Analytics"]}),e.jsxs("p",{className:"view-subtitle",children:["Aggregated from ",e.jsx("code",{children:"~/.local/share/bizar/usage.jsonl"})," — every chatCompletion and fetchRemains call."]})]}),e.jsx("div",{className:"view-header-actions",children:e.jsxs(U,{variant:"secondary",size:"sm",onClick:M,disabled:g,children:[g?e.jsx(je,{size:14,className:"spin"}):e.jsx(xe,{size:14})," Refresh"]})})]}),e.jsxs("div",{className:"usage-time-range",children:[["24h","7d","30d","custom"].map(C=>e.jsx("button",{className:se("usage-range-chip",s===C&&"is-active"),onClick:()=>n(C),children:C==="custom"?"Custom":C.toUpperCase()},C)),s==="custom"&&e.jsxs("div",{className:"usage-custom-dates",children:[e.jsx("label",{htmlFor:"usage-from-date",className:"sr-only",children:"From date"}),e.jsx("input",{id:"usage-from-date",type:"date",className:"usage-date-input",value:a,onChange:C=>i(C.target.value),"aria-label":"From date"}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:12},"aria-hidden":!0,children:"to"}),e.jsx("label",{htmlFor:"usage-to-date",className:"sr-only",children:"To date"}),e.jsx("input",{id:"usage-to-date",type:"date",className:"usage-date-input",value:r,onChange:C=>o(C.target.value),"aria-label":"To date"})]})]}),e.jsxs("div",{className:"usage-kpi-row",children:[e.jsx(Vs,{label:"Total Requests",value:(z==null?void 0:z.requests.toLocaleString())??"—",sub:z?`${z.errors} errors`:void 0,tone:z&&z.errors>z.requests*.1?"warn":void 0}),e.jsx(Vs,{label:"Total Tokens",value:z?z.totalTokens>=1e3?`${Math.round(z.totalTokens/1e3)}k`:String(z.totalTokens):"—",sub:z?`${z.promptTokens.toLocaleString()} prompt · ${z.completionTokens.toLocaleString()} completion`:void 0}),e.jsx(Vs,{label:"Errors",value:String((z==null?void 0:z.errors)??"—"),sub:A.length>0?`${A[0].code}: ${A[0].count}`:void 0,tone:z&&z.errors>0?"err":void 0}),e.jsx(Vs,{label:"Avg Latency",value:(z==null?void 0:z.avgLatencyMs)!=null?`${z.avgLatencyMs}ms`:"—",sub:(z==null?void 0:z.p95LatencyMs)!=null?`p95 ${z.p95LatencyMs}ms`:void 0}),e.jsx(Vs,{label:"Est. Cost",value:(z==null?void 0:z.costEstimate)!=null&&z.costEstimate>0?`$${z.costEstimate.toFixed(4)}`:"—",sub:"approximate USD",tone:void 0})]}),e.jsxs(ne,{className:"usage-chart-card",children:[e.jsx("div",{className:"usage-chart-wrap",children:e.jsx(Yp,{series:$,height:280})}),e.jsxs("div",{className:"usage-legend",children:[e.jsxs("div",{className:"usage-legend-item",children:[e.jsx("div",{className:"usage-legend-bar",style:{background:"var(--accent)"}}),e.jsx("span",{children:"Requests (bar)"})]}),e.jsxs("div",{className:"usage-legend-item",children:[e.jsx("div",{className:"usage-legend-line",style:{background:"var(--warning, #d29922)"}}),e.jsx("span",{children:"Tokens (line)"})]})]})]}),e.jsxs(ne,{children:[e.jsx(de,{children:"Per-model breakdown"}),e.jsx(Xp,{rows:S,sortKey:p,sortDir:v,onSort:w})]}),k.length>0&&e.jsxs(ne,{children:[e.jsx(de,{children:"API Keys"}),e.jsx("div",{className:"usage-key-row",children:k.map(C=>e.jsxs("span",{className:se("usage-key-badge",C.isBackup?"is-backup":"is-active"),children:[e.jsx("span",{className:"usage-key-dot"}),C.keyEnvVar,C.isBackup?" (backup)":" (active)"," · ",C.requests," req"]},C.keyEnvVar))})]}),d.length>0&&e.jsxs(ne,{children:[e.jsx(de,{children:"Recent activity"}),e.jsx("div",{className:"usage-recent-list",children:d.map((C,_)=>e.jsxs("div",{className:se("usage-recent-item",C.error&&"is-err"),children:[e.jsx("span",{className:"usage-recent-time",children:new Date(C.ts).toLocaleTimeString()}),e.jsx("span",{className:"usage-recent-model",children:e.jsx("code",{children:C.modelId})}),e.jsxs("span",{className:"usage-recent-tokens",children:[C.totalTokens.toLocaleString()," tok"]}),e.jsxs("span",{className:"usage-recent-latency",children:[C.latencyMs,"ms"]}),e.jsx("span",{className:"usage-recent-endpoint",children:C.endpoint})]},`${C.requestId}-${_}`))})]})]})}function Vs({label:t,value:s,sub:n,tone:a}){return e.jsxs("div",{className:"usage-kpi-card",children:[e.jsx("div",{className:"usage-kpi-label",children:t}),e.jsx("div",{className:se("usage-kpi-value",a&&`is-${a}`),children:s}),n&&e.jsx("div",{className:"usage-kpi-sub",children:n})]})}function zn({label:t,value:s,hint:n}){return e.jsxs("div",{className:"stat",children:[e.jsx("div",{className:"stat-label",children:t}),e.jsx("div",{className:"stat-value",children:s}),n&&e.jsx("div",{className:"stat-hint",children:n})]})}function Jp({model:t}){const s=Mn(t.current_interval_remaining_percent??0,0,100),n=Mn(t.current_weekly_remaining_percent??0,0,100),a=Mn(100-s,0,100),i=Mn(100-n,0,100);return e.jsxs(ne,{id:`minimax-model-${t.model_name}`,className:"minimax-model-card",children:[e.jsxs("div",{className:"minimax-model-head",children:[e.jsx("div",{className:"minimax-model-name",children:t.model_name}),e.jsxs("div",{className:se("minimax-model-status",s<25||n<25?"is-warn":"is-ok"),children:[t.current_interval_status===1?"active":"idle"," ·"," ",t.current_weekly_status===1?"week active":"week idle"]})]}),e.jsxs("div",{className:"minimax-quota-rows",children:[e.jsx(Er,{icon:e.jsx(Be,{size:12}),label:"5-hour rolling",remainingPct:s,consumedPct:a,used:t.current_interval_usage_count??0,total:t.current_interval_total_count??0,resetIn:t.intervalResetInHuman,resetISO:t.endTimeISO}),e.jsx(Er,{icon:e.jsx($u,{size:12}),label:"Weekly",remainingPct:n,consumedPct:i,used:t.current_weekly_usage_count??0,total:t.current_weekly_total_count??0,resetIn:t.weeklyResetInHuman,resetISO:t.weeklyEndTimeISO})]})]})}function Er({icon:t,label:s,remainingPct:n,consumedPct:a,used:i,total:r,resetIn:o,resetISO:l}){const c=n>=75?"good":n>=25?"warn":"low";return e.jsxs("div",{className:`minimax-quota-row is-${c}`,children:[e.jsxs("div",{className:"minimax-quota-head",children:[e.jsxs("span",{className:"minimax-quota-label",children:[t," ",s]}),e.jsxs("span",{className:"minimax-quota-remaining",children:[n,"% remaining"]}),e.jsxs("span",{className:"minimax-quota-consumed",children:["· ",a,"% used"]})]}),e.jsx("div",{className:"minimax-bar",children:e.jsx("div",{className:"minimax-bar-fill",style:{width:`${a}%`},"aria-label":`${a}% consumed`})}),e.jsxs("div",{className:"minimax-quota-meta",children:[e.jsxs("span",{children:[e.jsx("strong",{children:i})," / ",r||"—"," requests"]}),e.jsx("span",{title:l,children:o?`resets in ${o}`:"—"})]})]})}function Mn(t,s,n){return Math.max(s,Math.min(n,t))}function ex(t){const s=Date.now()-t;return s<5e3?"just now":s<6e4?`${Math.floor(s/1e3)}s ago`:s<36e5?`${Math.floor(s/6e4)}m ago`:`${Math.floor(s/36e5)}h ago`}function tx({step:t,setStep:s,keyDraft:n,setKeyDraft:a,showKey:i,setShowKey:r,verifying:o,verifyResult:l,onVerify:c,onSkip:h,onManualKeySave:m,savingKey:d,status:u}){return e.jsxs("div",{className:"view-container view-minimax-onboarding",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-titles",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(vt,{size:20,style:{verticalAlign:"text-bottom",marginRight:6}}),"Set up MiniMax Token Plan tracking"]}),e.jsx("p",{className:"view-subtitle",children:"We'll read your Subscription Key and show your remaining quota."})]}),e.jsx("div",{className:"view-header-actions",children:e.jsxs(U,{variant:"ghost",size:"sm",onClick:h,children:[e.jsx(Re,{size:14})," Skip for now"]})})]}),e.jsx("div",{className:"minimax-wizard-stepper",children:["Welcome","Get a key","Paste & test","Done"].map((p,x)=>e.jsxs("div",{className:se("minimax-wizard-step",x===t&&"is-current",x<t&&"is-done",x>t&&"is-todo"),children:[e.jsx("div",{className:"minimax-wizard-step-bullet",children:x<t?e.jsx(Ke,{size:14}):x+1}),e.jsx("div",{className:"minimax-wizard-step-label",children:p})]},p))}),e.jsxs(ne,{id:"minimax-wizard-card",children:[t===0&&e.jsxs("div",{className:"minimax-wizard-body",children:[e.jsx("h3",{className:"minimax-wizard-title",children:"Welcome"}),e.jsxs("p",{className:"minimax-wizard-prose",children:["BizarHarness shows you how much of your MiniMax Token Plan quota you have left — both the ",e.jsx("strong",{children:"5-hour rolling"})," and ",e.jsx("strong",{children:"weekly"})," windows."]}),e.jsxs("ul",{className:"minimax-wizard-list",children:[e.jsxs("li",{children:["Stored in ",e.jsx("code",{children:"~/.local/share/cline/auth.json"}),"."]}),e.jsx("li",{children:"Read fresh on every dashboard load."}),e.jsx("li",{children:"Never logged in full."})]}),e.jsx("div",{className:"minimax-wizard-actions",children:e.jsxs(U,{onClick:()=>s(1),variant:"primary",size:"md",children:["Get started ",e.jsx("span",{style:{marginLeft:6},children:"→"})]})})]}),t===1&&e.jsxs("div",{className:"minimax-wizard-body",children:[e.jsx("h3",{className:"minimax-wizard-title",children:"Get your Subscription Key"}),e.jsx("p",{className:"minimax-wizard-prose",children:"Go to the MiniMax console and copy your Subscription Key."}),e.jsxs("ol",{className:"minimax-wizard-list",children:[e.jsxs("li",{children:["Open ",e.jsxs("a",{href:"https://platform.minimax.io/user-center/payment/token-plan",target:"_blank",rel:"noreferrer",className:"minimax-wizard-link",children:[e.jsx(Is,{size:12})," platform.minimax.io"]})]}),e.jsxs("li",{children:["Click ",e.jsx("strong",{children:"Copy Subscription Key"}),"."]}),e.jsx("li",{children:"Come back here and paste it."})]}),e.jsxs("div",{className:"minimax-wizard-actions",children:[e.jsx(U,{variant:"secondary",size:"md",onClick:()=>s(0),children:"← Back"}),e.jsxs(U,{variant:"primary",size:"md",onClick:()=>s(2),children:["I have my key ",e.jsx("span",{style:{marginLeft:6},children:"→"})]})]})]}),t===2&&e.jsxs("div",{className:"minimax-wizard-body",children:[e.jsx("h3",{className:"minimax-wizard-title",children:"Paste & test"}),e.jsx("p",{className:"minimax-wizard-prose",children:"Paste your key below. We'll test it against the real API before saving."}),e.jsx("div",{className:"minimax-key-row",children:e.jsxs("div",{className:"minimax-key-input-wrap",children:[e.jsx(zi,{size:12,className:"minimax-key-icon","aria-hidden":!0}),e.jsx("label",{htmlFor:"minimax-key-input",className:"sr-only",children:"Subscription Key"}),e.jsx("input",{id:"minimax-key-input",type:i?"text":"password",value:n,onChange:p=>a(p.target.value),placeholder:"sk-cp-...",spellCheck:!1,autoComplete:"off",className:"minimax-key-input",autoFocus:!0,"aria-label":"Subscription Key"}),e.jsx("button",{type:"button",onClick:()=>r(p=>!p),className:"minimax-key-toggle","aria-label":i?"Hide key":"Show key",children:i?e.jsx(ti,{size:13}):e.jsx(ks,{size:13})})]})}),l&&!l.ok&&e.jsxs("div",{className:"minimax-wizard-error",children:[e.jsx(Ue,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:"Verification failed:"})," ",l.message??l.error]})]}),e.jsxs("div",{className:"minimax-wizard-actions",children:[e.jsx(U,{variant:"secondary",size:"md",onClick:()=>s(1),children:"← Back"}),e.jsxs(U,{variant:"primary",size:"md",onClick:c,disabled:o||!n.trim(),children:[o?e.jsx(je,{size:14,className:"spin"}):e.jsx(en,{size:14}),o?"Testing…":"Test & save key"]})]}),e.jsxs("p",{className:"minimax-wizard-prose minimax-wizard-prose--muted",children:["Don't want to test first? ",e.jsx("a",{href:"#",onClick:p=>{p.preventDefault(),m()},className:"minimax-wizard-link",children:"Save without testing"})]})]}),t===3&&e.jsxs("div",{className:"minimax-wizard-body",children:[e.jsxs("h3",{className:"minimax-wizard-title",children:[e.jsx(Ke,{size:18,style:{verticalAlign:"text-bottom",marginRight:6}}),"All set"]}),e.jsx("p",{className:"minimax-wizard-prose",children:"The key works and is saved. Reloading so you can see your live quota."}),e.jsx("div",{className:"minimax-wizard-actions",children:e.jsx(U,{variant:"primary",size:"md",onClick:()=>window.location.reload(),children:"View your quota →"})})]}),e.jsxs("div",{className:"minimax-wizard-footer",children:[e.jsx(en,{size:11}),e.jsxs("span",{children:["Key written to ",e.jsx("code",{children:"~/.local/share/cline/auth.json"})," with mode 0600."]})]})]})]})}const sx=rt.memo(Kp),nx={pending:"info",running:"accent",done:"success",failed:"error",killed:"neutral",timed_out:"warning"},ax={pending:"Pending",running:"Running",done:"Done",failed:"Failed",killed:"Killed",timed_out:"Timed out"};function ix({status:t,dot:s}){const n=nx[t]||"neutral",a=ax[t]||t;return e.jsx(ha,{kind:n,dot:s,children:a})}function rx({instanceId:t,instanceName:s,onConfirm:n,onClose:a}){return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Instance ",e.jsx("code",{children:t}),s?e.jsxs(e.Fragment,{children:[" (",s,")"]}):null," will be terminated. This cannot be undone."]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"ghost",onClick:a,children:"Cancel"}),e.jsx(U,{variant:"danger",onClick:async()=>{await n(),a()},children:"Kill"})]})]})}function ox(t,s,n,a,i){t.open({title:"Kill instance?",width:400,children:e.jsx(rx,{instanceId:n,instanceName:a,onConfirm:async()=>{try{const o=await(await fetch(`/api/background/${encodeURIComponent(n)}`,{method:"DELETE"})).json();o.ok?(s.success(`Instance ${n} killed.`),i==null||i()):s.error(`Kill failed: ${o.error||"unknown error"}`)}catch(r){s.error(`Kill failed: ${r.message}`)}},onClose:()=>t.close()})})}function lx({instance:t}){const s=fe(),[n,a]=f.useState(!1),i=t.tmuxSession,r=i?`tmux attach -t ${i}`:null,o=async()=>{if(r)try{await navigator.clipboard.writeText(r),s.success("Attach command copied")}catch{s.error("Could not copy to clipboard")}},l=async()=>{if(!(!t.instanceId||!i)){a(!0);try{const c=await H.post(`/background/${encodeURIComponent(t.instanceId)}/open-terminal`,{emulator:"system"});if(c.ok)s.success("Opening terminal…");else if(s.error(c.error||"Failed to open terminal"),r)try{await navigator.clipboard.writeText(r),s.success("Command copied to clipboard")}catch{}}catch(c){if(s.error(`Failed: ${c.message}`),r)try{await navigator.clipboard.writeText(r),s.success("Command copied to clipboard")}catch{}}finally{a(!1)}}};return i?e.jsxs(ne,{variant:"outlined",className:"bg-tmux-card",children:[e.jsxs("div",{className:"bg-tmux-card-header",children:[e.jsx(Cs,{size:14}),e.jsx("span",{children:"tmux session"}),t.tmuxActive!==!1?e.jsx("span",{className:"badge badge-success",children:"live"}):e.jsx("span",{className:"badge badge-warning",children:"inactive"})]}),e.jsx("code",{className:"mono bg-tmux-session-name",children:i}),e.jsx("p",{className:"muted bg-tmux-hint",children:"Attach to the agent's tmux session from a terminal on the host running the dashboard."}),e.jsxs("div",{className:"bg-tmux-card-actions",children:[e.jsxs(U,{variant:"ghost",size:"sm",onClick:o,title:"Copy attach command",children:[e.jsx(Vt,{size:14})," Copy"]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:l,loading:n,title:"Open in system terminal",children:[e.jsx(Cs,{size:14})," Open terminal"]})]})]}):e.jsxs(ne,{variant:"outlined",className:"bg-tmux-card bg-tmux-card-warn",children:[e.jsxs("div",{className:"bg-tmux-card-header",children:[e.jsx(Ue,{size:14}),e.jsx("span",{children:"No tmux session"})]}),e.jsx("p",{className:"bg-tmux-hint muted",children:"This instance does not have a tmux session attached. Sessions are created automatically when a background agent starts."})]})}const cx=[{name:"mimir",description:"Deep research & codebase exploration"},{name:"frigg",description:"Read-only codebase Q&A"},{name:"thor",description:"Moderate-complexity implementation"},{name:"tyr",description:"Complex feature implementation"},{name:"heimdall",description:"Quick edits & simple tasks"},{name:"odin",description:"Primary router agent"}],dx=[{label:"1 min",value:6e4},{label:"5 min",value:3e5},{label:"15 min",value:9e5},{label:"30 min",value:18e5},{label:"1 hr",value:36e5},{label:"4 hr",value:144e5}];function ux({open:t,onClose:s,onCreated:n,agents:a=cx}){var $;const i=fe(),[r,o]=f.useState((($=a[0])==null?void 0:$.name)||"mimir"),[l,c]=f.useState(""),[h,m]=f.useState(""),[d,u]=f.useState(3e5),[p,x]=f.useState(!1),[v,j]=f.useState(""),[g,b]=f.useState(!1),[y,w]=f.useState(null);if(!t)return null;const S=async M=>{if(M.preventDefault(),w(null),!l.trim()){w("Prompt is required.");return}b(!0);try{const z=v.split(",").map(C=>C.trim()).filter(C=>C.length>0),A={agent:r,prompt:l,...h.trim()?{model:h.trim()}:{},timeoutMs:d,persistent:p,maxRestarts:3,...z.length>0?{tags:z}:{}},k=await H.post("/background",A);if(k!=null&&k.error)throw new Error(k.message||k.error);i.success(`Spawned ${r} (${k.instanceId.slice(0,14)}…)`),n==null||n(k.instanceId),c(""),m(""),x(!1),j(""),s()}catch(z){w((z==null?void 0:z.message)||"Failed to spawn.")}finally{b(!1)}};return e.jsx("div",{className:"modal-backdrop",role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"modal-card spawn-modal",children:[e.jsxs("div",{className:"spawn-modal-header",children:[e.jsxs("h3",{children:[e.jsx(qe,{size:18})," Spawn background agent"]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:s,title:"Close",children:e.jsx(Re,{size:14})})]}),e.jsxs("form",{onSubmit:S,className:"spawn-modal-body",children:[e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Agent"}),e.jsx("select",{className:"field-input",value:r,onChange:M=>o(M.target.value),required:!0,children:a.map(M=>e.jsxs("option",{value:M.name,children:[M.name,M.description?` — ${M.description}`:""]},M.name))})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Initial prompt"}),e.jsx("textarea",{className:"field-input spawn-modal-textarea",rows:5,value:l,onChange:M=>c(M.target.value),placeholder:"What do you want this agent to do?",required:!0})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Model (optional)"}),e.jsx("input",{type:"text",className:"field-input",value:h,onChange:M=>m(M.target.value),placeholder:"providerID/modelID (leave blank for agent default)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Timeout"}),e.jsx("div",{className:"spawn-modal-timeouts",children:dx.map(M=>e.jsx("button",{type:"button",className:"spawn-modal-timeout-pill"+(M.value===d?" spawn-modal-timeout-pill-active":""),onClick:()=>u(M.value),children:M.label},M.value))}),e.jsx("input",{type:"range",min:6e4,max:144e5,step:6e4,value:d,onChange:M=>u(Number(M.target.value)),className:"spawn-modal-slider"}),e.jsxs("span",{className:"muted",children:[(d/6e4).toFixed(0)," min"]})]}),e.jsxs("label",{className:"field-checkbox",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:M=>x(M.target.checked)}),e.jsx("span",{children:"Persistent — auto-restart on terminal failure (max 3 attempts)"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Tags (optional, comma-separated)"}),e.jsx("input",{type:"text",className:"field-input",value:v,onChange:M=>j(M.target.value),placeholder:"e.g. refactor, urgent"})]}),y&&e.jsx("div",{className:"spawn-modal-error",children:y}),e.jsxs("div",{className:"spawn-modal-actions",children:[e.jsx(U,{variant:"ghost",size:"sm",type:"button",onClick:s,children:"Cancel"}),e.jsx(U,{variant:"primary",size:"sm",type:"submit",disabled:g,children:g?"Spawning…":"Spawn agent"})]})]})]})})}const hx=5e3,_r=3e3,mx=120,fx=32e3;function px(t){return t.status==="pending"||t.status==="running"||t.status==="paused"}function oi(t){return t.status==="paused"}function xx(t){if(!Number.isFinite(t)||t<0)return"—";const s=Math.floor(t/1e3),n=Math.floor(s/3600),a=Math.floor(s%3600/60),i=s%60;return n>0?`${n}h ${a}m ${i}s`:a>0?`${a}m ${i}s`:`${i}s`}function gx(t){const s=fe(),n=Ze(),[a,i]=f.useState([]),[r,o]=f.useState(!0),[l,c]=f.useState(null),[,h]=f.useState(0),[m,d]=f.useState(!1),u=f.useCallback(async()=>{try{const w=await H.get("/background");i(Array.isArray(w==null?void 0:w.instances)?w.instances:[]),c(null)}catch(w){c((w==null?void 0:w.message)||"Failed to load background agents.")}finally{o(!1)}},[]);f.useEffect(()=>{u();const w=setInterval(u,hx);return()=>clearInterval(w)},[u]),f.useEffect(()=>{const w=setInterval(()=>h(S=>(S+1)%1e6),1e3);return()=>clearInterval(w)},[]),f.useEffect(()=>{const w=new es,S=w.on($=>{const M=$.type;(M==="background:change"||M==="background:cleanup"||M==="bg:progress"||M==="bg:tool-call")&&u()});return()=>{S(),w.close()}},[u]);const p=a.filter(px),x=w=>{vx(n,w)},v=async w=>{try{const S=await H.get(`/background/${encodeURIComponent(w.instanceId)}/tmux`);wx(n,S)}catch(S){s.error(`Tmux info failed: ${S.message}`)}},j=w=>{ox(n,s,w.instanceId,w.agent||w.prompt,()=>{i(S=>S.filter($=>$.instanceId!==w.instanceId))})},g=async w=>{try{const S=await H.post(`/background/${encodeURIComponent(w.instanceId)}/pause`,{});S!=null&&S.ok?s.info(`Paused ${w.instanceId.slice(0,14)}…`):s.error((S==null?void 0:S.error)||"Pause failed.")}catch(S){s.error(`Pause failed: ${S.message}`)}},b=async w=>{try{const S=await H.post(`/background/${encodeURIComponent(w.instanceId)}/resume`,{});S!=null&&S.ok?s.info(`Resumed ${w.instanceId.slice(0,14)}…`):s.error((S==null?void 0:S.error)||"Resume failed.")}catch(S){s.error(`Resume failed: ${S.message}`)}},y=w=>{kx(n,s,w,u)};return r?e.jsx("div",{className:"bg-active-view",children:e.jsxs("div",{className:"bg-active-loading",children:[e.jsx(ye,{size:"md"}),e.jsx("span",{children:"Loading background agents…"})]})}):l?e.jsx("div",{className:"bg-active-view",children:e.jsx(_e,{icon:e.jsx(Be,{size:32}),title:"Couldn't load background agents",message:l,action:e.jsxs(U,{variant:"primary",onClick:u,children:[e.jsx(xe,{size:14})," Retry"]})})}):e.jsxs("div",{className:"bg-active-view",children:[e.jsxs("div",{className:"bg-active-header",children:[e.jsxs("div",{className:"bg-active-header-text",children:[e.jsx("h2",{className:"bg-active-title",children:"Active Background Agents"}),e.jsxs("p",{className:"bg-active-subtitle muted",children:[p.length," active · ",a.length," total in store"]})]}),e.jsxs("div",{className:"bg-active-header-actions",children:[e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>d(!0),children:[e.jsx(qe,{size:14})," Spawn"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:u,title:"Refresh now",children:[e.jsx(xe,{size:14})," Refresh"]})]})]}),e.jsx(ux,{open:m,onClose:()=>d(!1),onCreated:()=>{u()}}),p.length===0?e.jsx(_e,{icon:e.jsx(Be,{size:32}),title:"No active background agents",message:"Use the Spawn button above or call bizar_spawn_background from an agent.",action:e.jsxs(U,{variant:"primary",onClick:()=>d(!0),children:[e.jsx(qe,{size:14})," Spawn your first agent"]})}):e.jsx("div",{className:"bg-active-list",children:p.map(w=>e.jsx(yx,{inst:w,onViewOutput:()=>x(w),onOpenTmux:()=>v(w),onKill:()=>j(w),onPause:oi(w)?void 0:()=>g(w),onResume:oi(w)?()=>b(w):void 0,onSteer:()=>y(w)},w.instanceId))})]})}function yx({inst:t,onViewOutput:s,onOpenTmux:n,onKill:a,onPause:i,onResume:r,onSteer:o}){const l=typeof t.startedAt=="number"?t.startedAt:0,c=l?St(l):"—",h=l?Date.now()-l:0,m=Oo(t.prompt,mx),d=typeof t.progress=="number"?t.progress:null;return e.jsxs(ne,{className:"bg-active-card",variant:"elevated",children:[e.jsxs("div",{className:"bg-active-card-top",children:[e.jsxs("div",{className:"bg-active-card-id",children:[e.jsx("code",{className:"mono",children:t.instanceId}),e.jsx(ix,{status:t.status||"pending",dot:!0}),oi(t)&&e.jsxs("span",{className:"bg-active-card-paused-tag",children:[e.jsx(Au,{size:12})," paused"]})]}),e.jsxs("div",{className:"bg-active-card-agent",children:[e.jsx("span",{className:"bg-active-card-agent-label",children:"Agent"}),e.jsx("span",{className:"bg-active-card-agent-name",children:t.agent||"unknown"})]})]}),m&&e.jsx("div",{className:"bg-active-prompt",children:m}),t.currentStep&&e.jsxs("div",{className:"bg-active-step",children:[e.jsx("span",{className:"bg-active-step-label",children:"Step:"}),e.jsx("span",{className:"bg-active-step-value",children:t.currentStep})]}),d!==null&&e.jsxs("div",{className:"progress-bar","aria-label":"Progress",children:[e.jsx("div",{className:"progress-fill",style:{width:`${d<0?100:Math.max(0,Math.min(100,d))}%`}}),e.jsxs("span",{className:"progress-label",children:[d<0?"…":`${Math.round(d)}%`,t.progressMessage?` · ${t.progressMessage}`:""]})]}),e.jsxs("div",{className:"bg-active-meta",children:[e.jsxs("span",{title:c,children:[e.jsx("strong",{children:"Started:"})," ",c]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Duration:"})," ",xx(h)]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Tool calls:"})," ",t.toolCallCount??0]}),t.processId&&e.jsxs("span",{children:[e.jsx("strong",{children:"PID:"})," ",e.jsx("code",{className:"mono",children:t.processId})]}),Array.isArray(t.tags)&&t.tags.length>0&&e.jsxs("span",{children:[e.jsx("strong",{children:"Tags:"})," ",t.tags.map((u,p)=>e.jsxs("span",{className:"tag-pill",children:[u,p<t.tags.length-1?" ":""]},u))]}),t.tmuxSession&&e.jsxs("span",{className:se(t.tmuxActive&&"bg-active-meta-tmux-live"),children:[e.jsx("strong",{children:"tmux:"})," ",e.jsx("code",{className:"mono",children:t.tmuxSession}),t.tmuxActive?" · live":""]})]}),e.jsxs("div",{className:"bg-active-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:s,children:[e.jsx(ks,{size:14})," View output"]}),i&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:i,title:"Pause subprocess (POSIX)",children:[e.jsx(ki,{size:14})," Pause"]}),r&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:r,title:"Resume subprocess (POSIX)",children:[e.jsx(ws,{size:14})," Resume"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:o,title:"Steer with new instructions",children:[e.jsx(Rt,{size:14})," Steer"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:n,children:[e.jsx(Cs,{size:14})," Open in tmux"]}),e.jsxs(U,{variant:"danger",size:"sm",onClick:a,children:[e.jsx(Fe,{size:14})," Kill"]})]}),e.jsx(lx,{instance:t})]})}function vx(t,s){t.open({title:`Output — ${s.agent||s.instanceId}`,width:720,children:e.jsx(jx,{instanceId:s.instanceId})})}function jx({instanceId:t}){const s=fe(),n=f.useRef([]),[a,i]=f.useState(""),[r,o]=f.useState(!0),[l,c]=f.useState(null),[h,m]=f.useState(!0),[d,u]=f.useState(!0),[p,x]=f.useState([]),[v,j]=f.useState(!0),g=f.useRef(null),b=f.useRef(!0),y=f.useCallback(()=>{i(n.current.join(`
|
|
407
|
-
`))},[]),w=f.useCallback(async()=>{try{const M=await H.get(`/background/${encodeURIComponent(t)}/output?lines=300`);if(m((M==null?void 0:M.available)!==!1),M!=null&&M.output&&n.current.length===0){const z=M.output.split(/\r?\n/);n.current=z.slice(-300),y()}c(null)}catch(M){c((M==null?void 0:M.message)||"Failed to load output.")}finally{o(!1)}},[t,y]);f.useEffect(()=>{w();const M=setInterval(w,_r);return()=>clearInterval(M)},[w]),f.useEffect(()=>{const M=new es;let z=!1;const A=M.onStatus(C=>{z=C==="connected",u(z)}),k=M.on(C=>{var L;const _=C;if(_.type==="bg:output"&&_.instanceId===t&&typeof _.line=="string"){n.current.push(_.line);let N=0;for(let T=n.current.length-1;T>=0;T--)if(N+=(((L=n.current[T])==null?void 0:L.length)??0)+1,N>fx){n.current=n.current.slice(T+1);break}i(n.current.join(`
|
|
408
|
-
`))}});return()=>{A(),k(),M.close()}},[t]),f.useEffect(()=>{let M=!1;const z=async()=>{try{const C=await H.get(`/background/${encodeURIComponent(t)}/tool-calls`);!M&&Array.isArray(C==null?void 0:C.toolCalls)&&x(C.toolCalls)}catch{}};z();const A=new es,k=A.on(C=>{const _=C;_.type==="bg:tool-call"&&_.instanceId===t&&z()});return()=>{M=!0,k(),A.close()}},[t]),f.useEffect(()=>{var M;b.current&&((M=g.current)==null||M.scrollIntoView({behavior:"auto",block:"end"}))},[a]);const S=M=>{const z=M.currentTarget,A=z.scrollHeight-z.scrollTop-z.clientHeight<24;b.current=A},$=async()=>{try{await navigator.clipboard.writeText(a),s.success("Output copied.")}catch{}};return e.jsxs("div",{className:"bg-output-modal",children:[e.jsxs("div",{className:"bg-output-toolbar",children:[e.jsx("span",{className:"muted",children:d?`streaming · ${a.length} chars`:h?`${a.length} chars · auto-refresh ${_r/1e3}s (WS idle)`:"Output unavailable (no tmux session)"}),e.jsxs("div",{className:"bg-output-toolbar-actions",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>j(M=>!M),title:"Toggle tool-call history",children:v?"Hide tools":"Show tools"}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:w,title:"Refresh now",children:[e.jsx(xe,{size:14})," Refresh"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:$,disabled:!a,children:[e.jsx(Vt,{size:14})," Copy"]})]})]}),r&&!a?e.jsxs("div",{className:"bg-output-loading",children:[e.jsx(je,{size:16,className:"spin"})," Loading…"]}):l?e.jsx("div",{className:"bg-output-error",children:l}):e.jsxs("div",{className:"bg-output-body",children:[e.jsxs("div",{className:"bg-output-scroll",onScroll:S,children:[e.jsx("pre",{className:"bg-output-pre mono",children:e.jsx("code",{children:a||e.jsx("span",{className:"muted",children:"No output captured yet — waiting for the agent to start…"})})}),e.jsx("div",{ref:g})]}),v&&e.jsx(bx,{calls:p})]})]})}function bx({calls:t}){return e.jsxs("aside",{className:"bg-tool-calls","aria-label":"Tool call history",children:[e.jsxs("h4",{className:"bg-tool-calls-title",children:["Tool calls (",t.length,")"]}),t.length===0?e.jsx("p",{className:"muted bg-tool-calls-empty",children:"No tool calls recorded yet."}):e.jsx("ol",{className:"bg-tool-calls-list",children:t.slice().reverse().map(s=>{const n=s.endedAt&&s.startedAt?`${Math.max(0,s.endedAt-s.startedAt)}ms`:"…";return e.jsxs("li",{className:`bg-tool-call bg-tool-call-${s.status}`,children:[e.jsxs("div",{className:"bg-tool-call-head",children:[e.jsx("code",{className:"mono bg-tool-call-name",children:s.name}),e.jsx("span",{className:`badge badge-${s.status==="error"?"danger":s.status==="ok"?"success":"neutral"}`,children:s.status}),e.jsx("span",{className:"bg-tool-call-dur muted",children:n})]}),s.args&&e.jsx("pre",{className:"bg-tool-call-args mono",children:s.args}),s.result&&e.jsx("pre",{className:"bg-tool-call-result mono",children:s.result.slice(0,240)}),s.error&&e.jsx("pre",{className:"bg-tool-call-error mono",children:s.error})]},s.id)})})]})}function wx(t,s){const n=s.attachCommand||s.session||"";t.open({title:"Attach to tmux",width:520,children:e.jsx(Sx,{info:s,cmd:n})})}function kx(t,s,n,a){t.open({title:`Steer ${n.agent||n.instanceId}`,width:600,children:e.jsx(Nx,{instanceId:n.instanceId,toast:s,onCreated:a,onClose:()=>t.close()})})}function Nx({instanceId:t,toast:s,onCreated:n,onClose:a}){const[i,r]=f.useState(""),[o,l]=f.useState(!1),[c,h]=f.useState(null),m=async()=>{if(!i.trim()){h("Message is required.");return}l(!0);try{const d=await H.post(`/background/${encodeURIComponent(t)}/steer`,{message:i});if(!(d!=null&&d.ok)){h((d==null?void 0:d.error)||"Steer failed.");return}s.success(`Steered → new instance ${(d.newInstanceId??"").slice(0,14)}…`),n(),a()}catch(d){h(d.message)}finally{l(!1)}};return e.jsxs("div",{className:"bg-steer-modal",children:[e.jsxs("p",{className:"muted",children:["Steer kills the current subprocess and spawns a new one with the original prompt + your message appended. The new instance is linked to this one as ",e.jsx("code",{children:"parentInstanceId"}),"."]}),e.jsx("textarea",{className:"field-input bg-steer-textarea",rows:6,value:i,onChange:d=>r(d.target.value),placeholder:"What do you want the agent to do differently?"}),c&&e.jsx("div",{className:"bg-steer-error",children:c}),e.jsxs("div",{className:"bg-steer-actions",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),e.jsx(U,{variant:"primary",size:"sm",onClick:m,disabled:o||!i.trim(),children:o?"Steering…":"Steer"})]})]})}function Sx({info:t,cmd:s}){const[n,a]=f.useState(!1),i=async()=>{try{await navigator.clipboard.writeText(s),a(!0),window.setTimeout(()=>a(!1),1500)}catch{}};return e.jsx("div",{className:"bg-tmux-modal",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"bg-tmux-meta",children:[t.exists?e.jsx("span",{className:"badge badge-success",children:"session live"}):e.jsxs("span",{className:"badge badge-warning",children:["session not running",t.reason?` — ${t.reason}`:""]}),t.session&&e.jsxs("span",{className:"bg-tmux-session muted",children:["· session ",e.jsx("code",{className:"mono",children:t.session})]})]}),e.jsx("label",{className:"field-label",children:"Attach command"}),e.jsxs("div",{className:"bg-tmux-command-row",children:[e.jsx("code",{className:"bg-tmux-command mono",children:s}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:i,children:[e.jsx(Vt,{size:14})," ",n?"Copied":"Copy"]})]}),e.jsx("p",{className:"muted bg-tmux-hint",children:"Paste this into a terminal on the host running the dashboard. The dashboard itself does not open terminals."})]}):e.jsx("p",{className:"muted",children:"No tmux session attached to this instance."})})}const Cx={system:{title:"System health",icon:Ss,emptyTitle:"No system checks",emptyMessage:"System checks did not return any rows."},services:{title:"Services",icon:Ci,emptyTitle:"No service probes",emptyMessage:"Service probes did not return any rows."},counts:{title:"Counts",icon:Be,emptyTitle:"No counts",emptyMessage:"No counts reported by the dashboard stores."},errors:{title:"Recent errors",icon:ys,emptyTitle:"No recent errors",emptyMessage:"No error lines in the service log within the last hour."},actions:{title:"Actions",icon:xh,emptyTitle:"No actions",emptyMessage:"No actions available."}};function zx(t){return t==="ok"?Ke:t==="warn"?Tu:ys}function Mx(t){return t==="ok"?"ok":t==="warn"?"warn":"fail"}function Ba({category:t,title:s,icon:n,checks:a,info:i,meta:r,children:o,className:l}){const c=Cx[t],h=n??c.icon,m=s??c.title,d=a.length>0||i&&i.length>0||o;return e.jsxs(ne,{className:se("doctor-panel",`doctor-panel-${t}`,l),children:[e.jsxs(de,{children:[e.jsx(h,{size:14,"aria-hidden":!0}),e.jsx("span",{children:m}),r?e.jsx("span",{className:"card-meta-inline muted",children:r}):null]}),d?e.jsxs("div",{className:"doctor-panel-body",children:[o,a.length>0?e.jsx("ul",{className:"doctor-check-list",role:"list",children:a.map(u=>{const p=zx(u.status);return e.jsxs("li",{className:se("doctor-check-row",`doctor-check-${u.status}`),children:[e.jsx("span",{className:"doctor-check-icon","aria-hidden":!0,children:e.jsx(p,{size:14,className:se("doctor-check-icon-svg",u.status==="ok"&&"doctor-check-icon-ok",u.status==="warn"&&"doctor-check-icon-warn",u.status==="fail"&&"doctor-check-icon-fail")})}),e.jsx("span",{className:"doctor-check-name mono",children:u.name}),e.jsx("span",{className:"doctor-check-message",children:u.message}),e.jsx(ha,{kind:u.status,dot:!0,children:Mx(u.status)})]},u.name)})}):null,i&&i.length>0?e.jsx("dl",{className:"doctor-info-list",children:i.map(u=>e.jsxs(rt.Fragment,{children:[e.jsx("dt",{children:u.label}),e.jsx("dd",{className:"tabular-nums",children:u.value})]},u.label))}):null]}):e.jsx(_e,{icon:e.jsx(h,{size:28,"aria-hidden":!0}),title:c.emptyTitle,message:c.emptyMessage})]})}const $x=3e4;function Ex({setActiveTab:t}){var $;const s=fe(),[n,a]=f.useState(null),[i,r]=f.useState(!0),[o,l]=f.useState(!1),[c,h]=f.useState(null),[m,d]=f.useState(!0),u=f.useRef(!1),p=f.useCallback(async()=>{l(!0);try{const M=await H.get("/doctor");u.current||(a(M),h(Date.now()),r(!1))}catch(M){u.current||(r(!1),s.error(`Doctor refresh failed: ${M.message}`))}finally{u.current||l(!1)}},[s]);f.useEffect(()=>(u.current=!1,p(),()=>{u.current=!0}),[p]),f.useEffect(()=>{if(!m)return;const z=setInterval(async()=>{try{const A=await H.get("/doctor/health");a(k=>k&&((k.health.status!==A.status||k.health.issues.length!==A.issues.length)&&p(),k))}catch{}},$x);return()=>clearInterval(z)},[m,p]);const x=async M=>{var z;try{const A=await H.post("/doctor/check",{checkName:M});s.info(`${A.name}: ${A.message}`,4e3),await p()}catch(A){const k=A;s.error(`Check failed: ${((z=k.data)==null?void 0:z.message)??A.message}`)}},v=()=>{if(n)try{const M=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),z=URL.createObjectURL(M),A=document.createElement("a");A.href=z,A.download=`doctor-snapshot-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,document.body.appendChild(A),A.click(),document.body.removeChild(A),URL.revokeObjectURL(z)}catch(M){s.error(`Export failed: ${M.message}`)}},j=()=>{t("settings")},g=n==null?void 0:n.counts,b=f.useMemo(()=>g?[{label:"Tasks",value:g.tasks},{label:"Schedules",value:g.schedules},{label:"Mods",value:g.mods},{label:"Providers",value:g.providers},{label:"MCPs",value:g.mcps},{label:"Agents",value:g.agents},{label:"Projects",value:g.projects},{label:"Workspaces",value:g.workspaces},{label:"Voice notes",value:g.voiceNotes},{label:"Eval runs",value:g.evalRuns},{label:"Backups",value:g.backups}]:[],[g]);if(i)return e.jsxs("div",{className:"view view-doctor view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Running health checks…"})]});if(!n)return e.jsx("div",{className:"view view-doctor",children:e.jsxs(ne,{children:[e.jsxs(de,{children:[e.jsx(ys,{size:14})," Doctor unavailable"]}),e.jsx(ue,{children:"Could not reach /api/doctor."}),e.jsx("div",{className:"doctor-fallback-actions",children:e.jsxs(U,{variant:"primary",onClick:p,children:[e.jsx(xe,{size:12})," Retry"]})})]})});const y=n.health.status,w=y==="ok"?Ke:y==="warn"?Ue:ys,S=y==="ok"?"Healthy":y==="warn"?"Warning":"Failed";return e.jsxs("div",{className:"view view-doctor","data-overall":y,children:[e.jsxs("div",{className:"doctor-header",children:[e.jsxs("div",{className:"doctor-header-row",children:[e.jsxs("div",{className:"doctor-header-title",children:[e.jsx(al,{size:20,"aria-hidden":!0}),e.jsx("h1",{children:"Doctor"})]}),e.jsx("div",{className:"doctor-header-status",children:e.jsxs("span",{className:se("doctor-overall-pill",`doctor-overall-${y}`),children:[e.jsx(w,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"doctor-overall-label",children:S}),e.jsxs(ha,{kind:y,dot:!0,children:[n.health.issues.length," issue",n.health.issues.length===1?"":"s"]})]})})]}),e.jsxs("div",{className:"doctor-header-meta muted",children:[e.jsx(Jt,{size:12,"aria-hidden":!0}),e.jsxs("span",{"aria-live":"polite","aria-atomic":"true",children:["v",n.bizarVersion," · ",n.platform,"/",n.arch," ·"," ","up ",Math.floor(n.uptime),"s",c?` · refreshed ${St(new Date(c))}`:""]})]})]}),e.jsxs("div",{className:"doctor-grid",children:[e.jsx(Ba,{category:"system",checks:n.checks.system,meta:`${n.platform}/${n.arch}`}),e.jsx(Ba,{category:"services",checks:n.checks.services,meta:($=n.services.cline)!=null&&$.reachable?`cline on ${n.services.cline.port??"?"}`:"cline not connected"}),e.jsx(Ba,{category:"counts",checks:[],info:b,meta:g!=null&&g.activeProject?`active: ${g.activeProject}`:"no active project"}),e.jsxs(ne,{className:"doctor-errors-card",children:[e.jsxs(de,{children:[e.jsx(ys,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Recent errors (last hour)"}),e.jsxs("span",{className:"card-meta-inline muted",children:[n.recentErrors.length," line",n.recentErrors.length===1?"":"s"]})]}),n.recentErrors.length===0?e.jsx("div",{className:"muted doctor-errors-empty",children:"No errors in the last hour. Nice."}):e.jsx("ul",{className:"doctor-errors-list",role:"list",children:n.recentErrors.map((M,z)=>e.jsxs("li",{className:"doctor-error-row",children:[e.jsx("span",{className:"doctor-error-ts mono",children:M.ts?St(new Date(M.ts)):"??:??:??"}),e.jsx("span",{className:"doctor-error-line mono",children:M.line})]},`${M.tsMs??z}-${z}`))})]}),e.jsxs(ne,{className:"doctor-actions-card",children:[e.jsxs(de,{children:[e.jsx(Yn,{size:14,"aria-hidden":!0})," Actions"]}),e.jsx(ue,{children:"Run a check, view logs, or export the snapshot."}),e.jsxs("div",{className:"doctor-actions-row",children:[e.jsxs(U,{variant:"primary",onClick:p,disabled:o,"aria-label":"Refresh diagnostics",children:[o?e.jsx(ye,{size:"sm"}):e.jsx(xe,{size:12}),o?"Running…":"Run Health Check Now"]}),e.jsxs(U,{variant:"secondary",onClick:j,children:[e.jsx(Ve,{size:12})," View Full Logs"]}),e.jsxs(U,{variant:"secondary",onClick:v,children:[e.jsx(ts,{size:12})," Export Diagnostics as JSON"]}),e.jsx(U,{variant:"ghost",onClick:()=>d(M=>!M),"aria-label":m?"Pause auto-refresh":"Resume auto-refresh",children:m?"Pause auto-refresh":"Resume auto-refresh"})]}),n.checks.services.some(M=>M.status!=="ok")||n.checks.config.some(M=>M.status!=="ok")?e.jsxs("div",{className:"doctor-actions-rerun",children:[e.jsx("span",{className:"muted",children:"Rerun a single check:"}),e.jsx("div",{className:"doctor-actions-rerun-row",children:[...n.checks.services,...n.checks.config].filter(M=>M.status!=="ok").map(M=>e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>x(M.name),title:`Run check: ${M.name}`,children:[e.jsx(Yn,{size:10})," ",M.name]},M.name))})]}):null]})]})]})}const _x=rt.memo(Ex);function Tx({snapshot:t,setActiveTab:s,refreshSnapshot:n}){var p;const a=fe(),[i,r]=f.useState(!1),[o,l]=f.useState(null),c=f.useMemo(()=>[{id:"instructions",label:"Instructions",description:"AGENTS.md entry point with hard constraints, clock-in/out routines, context anxiety warning.",icon:e.jsx(Mi,{size:16}),checks:[{id:"inst-file",label:"AGENTS.md exists",severity:"critical",status:"pass"},{id:"inst-summary",label:"System description in first 10 lines",severity:"critical",status:"pass"},{id:"inst-verify",label:"Verification commands listed",severity:"critical",status:"pass"},{id:"inst-hard",label:"Hard constraints (MUST / MUST NOT)",severity:"recommended",status:"pass"},{id:"inst-state",label:"State files enumerated",severity:"recommended",status:"pass"},{id:"inst-clock",label:"Clock-in / Clock-out routines",severity:"recommended",status:"pass"}]},{id:"tools",label:"Tools",description:"Scoped tool permissions, MCP integrations, integration docs.",icon:e.jsx(Xn,{size:16}),checks:[{id:"tools-scope",label:"Tool access scoped (.claude/settings.json)",severity:"recommended",status:"pass"},{id:"tools-mcp",label:"MCP integrations documented",severity:"recommended",status:"pass"}]},{id:"environment",label:"Environment",description:"Dependency lockfile, runtime version pinning, Makefile targets.",icon:e.jsx(Be,{size:16}),checks:[{id:"env-lock",label:"Dependency lockfile",severity:"critical",status:"pass"},{id:"env-pin",label:"Runtime version pinned (.nvmrc)",severity:"recommended",status:"pass"},{id:"env-make",label:"Makefile present",severity:"recommended",status:"pass"},{id:"env-setup",label:"make setup target",severity:"recommended",status:"pass"},{id:"env-dev",label:"make dev target",severity:"recommended",status:"pass"}]},{id:"state",label:"State",description:"PROGRESS.md, DECISIONS.md, feature_list.json — cross-session state.",icon:e.jsx(Xn,{size:16}),checks:[{id:"state-progress",label:"PROGRESS.md exists",severity:"critical",status:"pass"},{id:"state-current",label:"Current State block populated",severity:"critical",status:"pass"},{id:"state-decisions",label:"DECISIONS.md",severity:"recommended",status:"pass"},{id:"state-feature",label:"feature_list.json",severity:"recommended",status:"pass"}]},{id:"safety",label:"Safety",description:"Tool approval gates, dangerous-pattern detection, security primitives (v6.0.0).",icon:e.jsx(ss,{size:16}),checks:[{id:"safety-patterns",label:"36+ dangerous patterns registered",severity:"critical",status:"pass"},{id:"safety-gate",label:"Tool approval gate in beforeTool",severity:"critical",status:"pass"},{id:"safety-flush",label:"Pre-compaction memory flush",severity:"recommended",status:"pass"},{id:"safety-curator",label:"Skill curator (closed learning loop)",severity:"recommended",status:"pass"},{id:"safety-graph",label:"Knowledge graph query tools",severity:"recommended",status:"pass"}]},{id:"feedback",label:"Feedback",description:"Verification pipelines, make check / test / e2e, clean-check.",icon:e.jsx(Ke,{size:16}),checks:[{id:"fb-check",label:"make check target",severity:"recommended",status:"pass"},{id:"fb-test",label:"make test target",severity:"recommended",status:"pass"},{id:"fb-e2e",label:"make e2e target",severity:"recommended",status:"pass"},{id:"fb-cleancheck",label:"make clean-check (5 dimensions)",severity:"recommended",status:"pass"},{id:"fb-arch",label:"make check-arch (.harness/arch-rules.json)",severity:"recommended",status:"pass"},{id:"fb-vcr",label:"make vcr (VCR ratio)",severity:"recommended",status:"pass"},{id:"fb-trace",label:"make session-start/end (traces)",severity:"recommended",status:"pass"}]}],[]),h=f.useMemo(()=>{const x=c.flatMap(S=>S.checks).length,v=c.flatMap(S=>S.checks).filter(S=>S.status==="pass").length,j=c.flatMap(S=>S.checks).filter(S=>S.severity==="critical"),g=j.filter(S=>S.status==="pass").length,b=c.flatMap(S=>S.checks).filter(S=>S.severity==="recommended"),y=b.filter(S=>S.status==="pass").length,w=x===0?1:v/x;return{total:x,passing:v,critical:j.length,criticalPass:g,recommended:b.length,recommendedPass:y,ratio:w}},[c]),m=async()=>{r(!0);try{await n(),a.show("Snapshot refreshed","success")}finally{r(!1)}},d=()=>{a.show("Audit script runs via `make check-arch` from a shell","info")},u=((p=t.cline)==null?void 0:p.state)==="active";return e.jsxs("div",{className:"harness-page",children:[e.jsxs("header",{className:"harness-header",children:[e.jsxs("div",{className:"harness-header-left",children:[e.jsx("div",{className:"harness-icon-wrap",children:e.jsx(ss,{size:22})}),e.jsxs("div",{children:[e.jsx("h1",{className:"harness-title",children:"Harness Engineering"}),e.jsx("p",{className:"harness-subtitle",children:"v6.0.0 — 5 subsystems × 12 checks. All passing."})]})]}),e.jsxs("div",{className:"harness-header-actions",children:[e.jsxs("button",{type:"button",className:"btn btn-secondary",onClick:d,children:[e.jsx(Du,{size:14}),"Run audit"]}),e.jsxs("button",{type:"button",className:"btn btn-primary",onClick:m,children:[e.jsx(xe,{size:14,className:i?"spin":""}),"Refresh"]})]})]}),e.jsxs("section",{className:"harness-audit",children:[e.jsxs("div",{className:"harness-card",children:[e.jsx("span",{className:"harness-card-label",children:"Audit score"}),e.jsxs("span",{className:se("harness-card-value",h.ratio>=.99?"pass":h.ratio>=.85?"warn":"fail"),children:[h.passing,"/",h.total]}),e.jsxs("span",{className:"harness-card-sub",children:[(h.ratio*100).toFixed(1),"% passing"]})]}),e.jsxs("div",{className:"harness-card",children:[e.jsx("span",{className:"harness-card-label",children:"Critical"}),e.jsxs("span",{className:se("harness-card-value",h.criticalPass===h.critical?"pass":"fail"),children:[h.criticalPass,"/",h.critical]}),e.jsx("span",{className:"harness-card-sub",children:"all must-have"})]}),e.jsxs("div",{className:"harness-card",children:[e.jsx("span",{className:"harness-card-label",children:"Recommended"}),e.jsxs("span",{className:se("harness-card-value",h.recommendedPass===h.recommended?"pass":"warn"),children:[h.recommendedPass,"/",h.recommended]}),e.jsx("span",{className:"harness-card-sub",children:"best practice"})]}),e.jsxs("div",{className:"harness-card",children:[e.jsx("span",{className:"harness-card-label",children:"Cline runtime"}),e.jsx("span",{className:se("harness-card-value",u?"pass":"warn"),children:u?"in-process":"subprocess"}),e.jsx("span",{className:"harness-card-sub",children:"ClineCore in-process v6.0.0"})]})]}),e.jsx("section",{className:"harness-subsystems",children:c.map(x=>{const v=x.checks.filter(b=>b.status==="pass").length,j=x.checks.length,g=v===j;return e.jsxs(ne,{className:se("harness-subsystem-card",g?"harness-pass":"harness-warn"),children:[e.jsxs("div",{className:"harness-subsystem-head",children:[e.jsx("div",{className:"harness-subsystem-icon",children:x.icon}),e.jsxs("div",{className:"harness-subsystem-title",children:[e.jsx("h3",{children:x.label}),e.jsx("span",{className:"muted",children:x.description})]}),e.jsx("div",{className:"harness-subsystem-score",children:e.jsxs("span",{className:se("harness-card-value-sm",g?"pass":"warn"),children:[v,"/",j]})})]}),e.jsx("ul",{className:"harness-checklist",children:x.checks.map(b=>e.jsxs("li",{className:se("harness-check",b.status),children:[b.status==="pass"?e.jsx(Ke,{size:13,className:"pass"}):e.jsx(ls,{size:13,className:"fail"}),e.jsx("span",{className:"harness-check-label",children:b.label}),e.jsx("span",{className:se("harness-check-severity",b.severity),children:b.severity})]},b.id))})]},x.id)})}),e.jsxs("section",{className:"harness-quick-actions",children:[e.jsxs(ne,{children:[e.jsx(de,{children:"Harness commands"}),e.jsx(ue,{children:"Run from a shell to verify / repair the harness."}),e.jsxs("div",{className:"harness-command-grid",children:[e.jsx("code",{children:"make check"}),e.jsx("span",{children:"Full verification pipeline (typecheck + tests)"}),e.jsx("code",{children:"make e2e"}),e.jsx("span",{children:"Real plugin load + 22 tool/hook checks"}),e.jsx("code",{children:"make vcr"}),e.jsx("span",{children:"VCR ratio (passing / activated features)"}),e.jsx("code",{children:"make verify-feature ID=F-001"}),e.jsx("span",{children:"Verify a specific feature by ID"}),e.jsx("code",{children:"make check-arch"}),e.jsx("span",{children:"Run architectural constraints"}),e.jsx("code",{children:"make clean-check"}),e.jsx("span",{children:"5-dimension clean-state check"}),e.jsx("code",{children:"make session-start"}),e.jsx("span",{children:"Record session start to .harness/traces/"}),e.jsx("code",{children:"make session-end"}),e.jsx("span",{children:"Record session end to .harness/traces/"})]})]}),e.jsxs(ne,{children:[e.jsx(de,{children:"Documentation"}),e.jsx(ue,{children:"Entry point + topic docs."}),e.jsxs("ul",{className:"harness-docs-list",children:[e.jsxs("li",{children:[e.jsx("button",{type:"button",className:"link",onClick:()=>s("doctor"),children:"Doctor"})," ",e.jsx("span",{className:"muted",children:"— runtime health + service status"})]}),e.jsxs("li",{children:[e.jsx("a",{className:"link",href:"/api/doctor/health",target:"_blank",rel:"noreferrer",children:"/api/doctor/health"})," ",e.jsx("span",{className:"muted",children:"— health endpoint"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"AGENTS.md"})," ",e.jsx("span",{className:"muted",children:"— entry point with hard constraints"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"PROGRESS.md"})," ",e.jsx("span",{className:"muted",children:"— current state, in progress, next steps"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"DECISIONS.md"})," ",e.jsx("span",{className:"muted",children:"— architectural decision log (ADRs)"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"feature_list.json"})," ",e.jsx("span",{className:"muted",children:"— machine-readable feature state"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"docs/architecture.md"})," ",e.jsx("span",{className:"muted",children:"— layer model + module map"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"docs/quality-document.md"})," ",e.jsx("span",{className:"muted",children:"— per-module A/B/C/D scores"})]}),e.jsxs("li",{children:[e.jsx("code",{children:".harness/arch-rules.json"})," ",e.jsx("span",{className:"muted",children:"— architectural rule registry"})]})]})]})]})]})}function Ax(t){return e.jsx(Tx,{...t})}function Rx(t){return t.total<=0?"fail":t.failed===0?"pass":t.passed/t.total>.8?"warn":"fail"}function xl({run:t,onClick:s,selected:n,ariaLabel:a}){const i=Rx(t),r=t.total>0?(t.passed/t.total*100).toFixed(1):"0.0",o=!!s;return e.jsxs(ne,{onClick:s,interactive:o,"aria-label":a??`Eval run ${t.id}`,"aria-pressed":o?n:void 0,className:se("eval-run-card",n&&"eval-run-card-selected",`eval-run-${i}`),children:[e.jsxs("div",{className:"eval-run-head",children:[e.jsx(de,{className:"eval-run-title",children:t.id}),e.jsxs("span",{className:se("eval-status",`is-${i}`),children:[t.passed,"/",t.total," (",r,"%)"]})]}),e.jsxs(ue,{className:"eval-run-meta",children:[St(t.startedAt)," · ",t.suitePath]})]})}const Ha=8;function Ix({onAdded:t,onCancel:s}){const n=fe(),[a,i]=f.useState(""),[r,o]=f.useState(""),[l,c]=f.useState(""),[h,m]=f.useState("thor"),[d,u]=f.useState(!1),p=async x=>{if(x.preventDefault(),!a||!r||!l){n.error("name, suitePath, and cron are required");return}u(!0);try{const v=await H.post("/eval/schedules",{name:a,suitePath:r,cron:l,agent:h});t(v),n.success("Schedule created")}catch(v){n.error(`Failed to create schedule: ${v.message}`)}finally{u(!1)}};return e.jsxs("form",{className:"eval-schedule-form",onSubmit:p,children:[e.jsxs("div",{className:"form-row",children:[e.jsx("label",{htmlFor:"sched-name",children:"Name"}),e.jsx("input",{id:"sched-name",type:"text",value:a,onChange:x=>i(x.target.value),placeholder:"Daily fixture check",required:!0})]}),e.jsxs("div",{className:"form-row",children:[e.jsx("label",{htmlFor:"sched-suite",children:"Suite path"}),e.jsx("input",{id:"sched-suite",type:"text",value:r,onChange:x=>o(x.target.value),placeholder:"./fixtures",required:!0})]}),e.jsxs("div",{className:"form-row",children:[e.jsx("label",{htmlFor:"sched-cron",children:"Cron"}),e.jsx("input",{id:"sched-cron",type:"text",value:l,onChange:x=>c(x.target.value),placeholder:"0 8 * * *",required:!0})]}),e.jsxs("div",{className:"form-row",children:[e.jsx("label",{htmlFor:"sched-agent",children:"Agent"}),e.jsx("input",{id:"sched-agent",type:"text",value:h,onChange:x=>m(x.target.value),placeholder:"thor"})]}),e.jsxs("div",{className:"form-actions",children:[e.jsx(U,{type:"submit",variant:"primary",size:"sm",disabled:d,children:d?"Creating…":"Create schedule"}),e.jsx(U,{type:"button",variant:"ghost",size:"sm",onClick:s,children:"Cancel"})]})]})}function Lx({setActiveTab:t}){const s=fe(),[n,a]=f.useState([]),[i,r]=f.useState(!0),[o,l]=f.useState("runs"),[c,h]=f.useState([]),[m,d]=f.useState(!1),[u,p]=f.useState(!1),x=f.useRef(!1),v=f.useCallback(async()=>{r(!0);try{const S=await H.get(`/eval/runs?limit=${Ha}`);x.current||a(S.runs||[])}catch(S){x.current||s.error(`Failed to load eval runs: ${S.message}`)}finally{x.current||r(!1)}},[s]),j=f.useCallback(async()=>{d(!0);try{const S=await H.get("/eval/schedules");x.current||h(S.schedules||[])}catch(S){x.current||s.error(`Failed to load eval schedules: ${S.message}`)}finally{x.current||d(!1)}},[s]);f.useEffect(()=>(x.current=!1,v(),o==="schedules"&&j(),()=>{x.current=!0}),[v,j,o]);const g=async S=>{try{await H.del(`/eval/schedules/${S}`),h($=>$.filter(M=>M.id!==S)),s.success("Schedule deleted")}catch($){s.error(`Failed to delete schedule: ${$.message}`)}},b=n.slice(0,Ha),y=n.reduce((S,$)=>(S.total+=$.total,S.passed+=$.passed,S.failed+=$.failed,$.failed===0&&(S.fullPass+=1),S),{total:0,passed:0,failed:0,fullPass:0}),w=y.total>0?(y.passed/y.total*100).toFixed(1):"—";return e.jsxs("div",{className:"view view-eval","data-testid":"eval-overview",children:[e.jsxs("div",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(Ot,{size:20,"aria-hidden":!0})," Eval"]}),e.jsx("p",{className:"view-subtitle muted",children:"Track golden-fixture runs, catch regressions, and compare run history."})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:v,disabled:i,children:[i?e.jsx(ye,{size:"sm"}):e.jsx(xe,{size:12}),i?"Refreshing…":"Refresh"]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>t("evalReport"),title:"Open the full eval report",children:[e.jsx(Is,{size:12})," Open Eval Report"]})]})]}),e.jsxs("div",{className:"eval-summary-grid",children:[e.jsxs(ne,{className:"eval-summary-card",children:[e.jsx(de,{children:"Recent runs"}),e.jsx("div",{className:"eval-summary-value",children:n.length}),e.jsxs(ue,{className:"muted",children:["Latest ",Ha," runs across all suites."]})]}),e.jsxs(ne,{className:"eval-summary-card",children:[e.jsx(de,{children:"Fixtures run"}),e.jsx("div",{className:"eval-summary-value",children:y.total}),e.jsx(ue,{className:"muted",children:e.jsxs("span",{className:se("eval-rate",y.failed===0?"is-pass":"is-fail"),children:[w,"% pass rate"]})})]}),e.jsxs(ne,{className:"eval-summary-card",children:[e.jsx(de,{children:"Clean runs"}),e.jsx("div",{className:"eval-summary-value",children:y.fullPass}),e.jsx(ue,{className:"muted",children:"Runs where every fixture passed."})]}),e.jsxs(ne,{className:"eval-summary-card eval-summary-cta",children:[e.jsx(de,{children:"Compare runs"}),e.jsx(ue,{children:"Open the detailed report to diff two runs side-by-side and spot regressions fixture by fixture."}),e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>t("evalReport"),className:"eval-summary-cta-btn",children:["Open report ",e.jsx(Yo,{size:12})]})]})]}),e.jsxs("div",{className:"eval-recent-section",children:[e.jsxs("div",{className:"eval-sub-tabs",children:[e.jsxs("button",{type:"button",className:se("eval-sub-tab",o==="runs"?"is-active":""),onClick:()=>l("runs"),children:[e.jsx(Ot,{size:12,"aria-hidden":!0})," Runs"]}),e.jsxs("button",{type:"button",className:se("eval-sub-tab",o==="schedules"?"is-active":""),onClick:()=>{l("schedules"),c.length===0&&j()},children:[e.jsx(Jt,{size:12,"aria-hidden":!0})," Schedules"]})]}),o==="runs"?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"eval-section-title",children:"Recent runs"}),i&&b.length===0?e.jsxs("div",{className:"eval-runs-loading",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"muted",children:"Loading runs…"})]}):b.length===0?e.jsx(_e,{icon:e.jsx(Ot,{size:28}),title:"No eval runs yet",message:e.jsxs(e.Fragment,{children:["Run a suite via the CLI:"," ",e.jsx("code",{className:"mono",children:"bizar eval run ./path/to/fixtures"}),". Results will appear here."]})}):e.jsx("div",{className:"eval-runs-list",children:b.map(S=>e.jsx(xl,{run:S},S.id))})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"eval-section-title",children:"Schedules"}),m?e.jsxs("div",{className:"eval-runs-loading",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"muted",children:"Loading schedules…"})]}):c.length===0?e.jsx(_e,{icon:e.jsx(Jt,{size:28}),title:"No eval schedules",message:"Schedules let you run eval suites automatically on a cron. Add one below."}):e.jsx("div",{className:"eval-schedules-list",children:c.map(S=>e.jsx(ne,{className:"eval-schedule-card",children:e.jsxs("div",{className:"eval-schedule-row",children:[e.jsxs("div",{className:"eval-schedule-info",children:[e.jsx(de,{children:S.name}),e.jsxs(ue,{className:"muted",children:[S.cron," · ",S.suitePath," · agent:",S.agent||"thor"]})]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>g(S.id),title:"Delete schedule",children:e.jsx(Fe,{size:12,"aria-hidden":!0})})]})},S.id))}),e.jsxs("div",{className:"eval-schedule-add",children:[e.jsx(Ix,{onAdded:S=>{h($=>[...$,S]),p(!1)},onCancel:()=>p(!1)}),!u&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>p(!0),children:[e.jsx(qe,{size:12,"aria-hidden":!0})," Add schedule"]})]})]})]})]})}const Px=rt.memo(Lx);function gl(t,s){const n=new Map(t.results.map(l=>[l.fixtureId,l])),a=new Map(s.results.map(l=>[l.fixtureId,l])),i=new Set([...n.keys(),...a.keys()]),r=[];for(const l of i){const c=n.get(l),h=a.get(l),m=c?c.ok:null,d=h?h.ok:null;let u;c&&h?m===d?u="same":m===!1&&d===!0?u="improved":u="regressed":h&&!c?u="added":u="removed",r.push({fixtureId:l,before:m,after:d,change:u})}const o={regressed:0,improved:1,added:2,removed:3,same:4};return r.sort((l,c)=>{const h=o[l.change]-o[c.change];return h!==0?h:l.fixtureId.localeCompare(c.fixtureId)}),r}function Dx({runA:t,runB:s,title:n="Regression Analysis"}){const a=gl(t,s),i=a.filter(c=>c.change==="improved").length,r=a.filter(c=>c.change==="regressed").length,o=a.filter(c=>c.change==="same").length,l=a.filter(c=>c.change!=="same");return e.jsxs("div",{className:"eval-diff","data-testid":"eval-diff",children:[e.jsx("h3",{className:"eval-diff-title",children:n}),e.jsxs("div",{className:"eval-diff-subtitle muted",children:["Comparing ",e.jsx("code",{className:"mono",children:t.id})," →"," ",e.jsx("code",{className:"mono",children:s.id})]}),e.jsxs("div",{className:"eval-diff-stats","aria-label":"Diff summary",children:[e.jsxs("span",{className:"eval-diff-stat improved",children:[e.jsx("span",{className:"eval-diff-stat-icon","aria-hidden":!0,children:"+"}),i," improved"]}),e.jsxs("span",{className:"eval-diff-stat regressed",children:[e.jsx("span",{className:"eval-diff-stat-icon","aria-hidden":!0,children:"−"}),r," regressed"]}),e.jsxs("span",{className:"eval-diff-stat unchanged muted",children:[o," unchanged"]})]}),l.length===0?e.jsx("p",{className:"eval-diff-empty muted",children:"No fixture-level changes between these runs."}):e.jsx("ul",{className:"eval-diff-list",role:"list",children:l.map(c=>e.jsxs("li",{"data-fixture-id":c.fixtureId,className:se("eval-diff-row",`is-${c.change}`),children:[e.jsx("span",{className:"eval-diff-fixture mono",children:c.fixtureId}),e.jsx("span",{className:"eval-diff-arrow","aria-hidden":!0,children:"→"}),e.jsxs("span",{className:"eval-diff-states",children:[e.jsx("span",{className:se("eval-diff-state",c.before?"is-pass":"is-fail"),children:c.before===null?"—":c.before?"pass":"fail"}),e.jsx("span",{className:"eval-diff-arrow-small","aria-hidden":!0,children:"→"}),e.jsx("span",{className:se("eval-diff-state",c.after?"is-pass":"is-fail"),children:c.after===null?"—":c.after?"pass":"fail"})]})]},c.fixtureId))})]})}function Fx({runId:t,variant:s="secondary",size:n="sm"}){const a=()=>{const i=H.getToken();window.open(`/api/eval/runs/${encodeURIComponent(t)}/export.csv?_t=${encodeURIComponent(i)}`,"_blank")};return e.jsxs(U,{variant:s,size:n,onClick:a,title:"Export results as CSV",children:[e.jsx(ts,{size:14,"aria-hidden":!0}),"Export CSV"]})}function Ox({run:t,onClearCompare:s,compareRun:n,onClearSelection:a,runsForDiff:i}){const r=t.total>0?(t.passed/t.total*100).toFixed(1):"0.0",o=[...t.results].sort((l,c)=>l.ok!==c.ok?l.ok?1:-1:l.fixtureId.localeCompare(c.fixtureId));return e.jsxs("div",{className:"eval-run-detail","data-testid":"eval-run-detail",children:[e.jsxs(ne,{className:"eval-run-detail-header",children:[e.jsxs("div",{className:"eval-run-detail-header-row",children:[e.jsxs(de,{children:[e.jsx(Ot,{size:14,"aria-hidden":!0})," ",t.id]}),e.jsxs("div",{className:"eval-run-detail-actions",children:[e.jsx(Fx,{runId:t.id}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:a,title:"Close detail",children:[e.jsx(Re,{size:12})," Close"]})]})]}),e.jsxs(ue,{children:[St(t.startedAt),t.finishedAt?` → ${St(t.finishedAt)}`:""," · ",t.suitePath]}),e.jsxs("div",{className:"eval-run-detail-summary",children:[e.jsxs("span",{className:se("eval-status",t.failed===0?"is-pass":"is-fail"),children:[t.passed,"/",t.total," (",r,"%)"]}),e.jsxs("span",{className:"muted",children:[t.failed," failed · ",t.passed," passed"]})]})]}),n?e.jsx(ne,{className:"eval-diff-card",children:(()=>{const l=i.find(d=>d.id===n);if(!l)return e.jsxs("div",{className:"eval-diff-missing muted",children:["Baseline run ",e.jsx("code",{children:n})," not loaded. Pick another from the list."]});const c=gl(l,t),h=c.filter(d=>d.change==="improved").length,m=c.filter(d=>d.change==="regressed").length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"eval-diff-card-head",children:[e.jsxs("span",{className:"eval-diff-card-title",children:[e.jsx(Go,{size:14,"aria-hidden":!0})," Comparing ",l.id," → ",t.id]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(Re,{size:12})," Clear baseline"]})]}),e.jsxs("div",{className:"eval-diff-stats","aria-label":"Diff summary",children:[e.jsxs("span",{className:"eval-diff-stat improved",children:["+",h," improved"]}),e.jsxs("span",{className:"eval-diff-stat regressed",children:["−",m," regressed"]})]}),e.jsx(Dx,{runA:l,runB:t})]})})()}):e.jsx(ne,{className:"eval-baseline-hint",children:e.jsx(ue,{children:"Tip: click another run in the list to use it as a baseline for diffing."})}),e.jsxs(ne,{className:"eval-fixtures-card",children:[e.jsxs(de,{children:["Fixtures (",t.results.length,")"]}),o.length===0?e.jsx(ue,{className:"muted",children:"No fixture results in this run."}):e.jsx("ul",{className:"eval-fixtures-list",role:"list",children:o.map(l=>e.jsxs("li",{className:se("eval-fixture-row",l.ok?"is-pass":"is-fail"),children:[e.jsx("span",{className:se("eval-fixture-pill",l.ok?"is-pass":"is-fail"),"aria-label":l.ok?"pass":"fail",children:l.ok?"✓":"✗"}),e.jsx("span",{className:"eval-fixture-id mono",children:l.fixtureId}),!l.ok&&l.checks?e.jsx("span",{className:"eval-fixture-fails muted",children:l.checks.filter(c=>!c.ok).map(c=>c.message).filter(Boolean).join(" · ")}):null,l.latencyMs!=null?e.jsxs("span",{className:"eval-fixture-latency muted",children:[Math.round(l.latencyMs),"ms"]}):null]},l.fixtureId))})]})]})}function Bx({setActiveTab:t}){const s=fe(),[n,a]=f.useState([]),[i,r]=f.useState(!0),[o,l]=f.useState(null),[c,h]=f.useState(null),[m,d]=f.useState(null),[u,p]=f.useState(!1),[x,v]=f.useState(null),j=f.useRef(!1),g=f.useCallback(async()=>{r(!0);try{const M=await H.get("/eval/runs");j.current||a(M.runs||[])}catch(M){j.current||s.error(`Failed to load eval runs: ${M.message}`)}finally{j.current||r(!1)}},[s]),b=f.useCallback(async M=>{p(!0);try{const z=await H.get(`/eval/runs/${encodeURIComponent(M)}`);j.current||d(z)}catch(z){j.current||(s.error(`Failed to load run ${M}: ${z.message}`),d(null))}finally{j.current||p(!1)}},[s]),y=f.useCallback(async M=>{try{const z=await H.get(`/eval/runs/${encodeURIComponent(M)}`);j.current||v(z)}catch(z){j.current||(s.error(`Failed to load run ${M}: ${z.message}`),v(null))}},[s]);f.useEffect(()=>(j.current=!1,g(),()=>{j.current=!0}),[g]);const w=async M=>{M!==o&&(l(M),h(null),v(null),await b(M))},S=async M=>{M!==o&&(h(M),await y(M))},$=[];return x&&$.push(x),m&&$.push(m),e.jsxs("div",{className:"view view-eval-report","data-testid":"eval-report",children:[e.jsxs("div",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(Ot,{size:20,"aria-hidden":!0})," Eval Reports"]}),e.jsx("p",{className:"view-subtitle muted",children:"Browse eval runs, inspect per-fixture results, and diff two runs to spot regressions."})]}),e.jsx("div",{className:"view-actions",children:e.jsxs(U,{variant:"secondary",size:"sm",onClick:g,disabled:i,children:[i?e.jsx(ye,{size:"sm"}):e.jsx(xe,{size:12}),i?"Refreshing…":"Refresh"]})})]}),e.jsxs("div",{className:"eval-grid",children:[e.jsx("div",{className:"eval-runs-list",children:i&&n.length===0?e.jsxs("div",{className:"eval-runs-loading",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"muted",children:"Loading runs…"})]}):n.length===0?e.jsx(_e,{icon:e.jsx(Ot,{size:28}),title:"No eval runs yet",message:e.jsxs(e.Fragment,{children:["Run a suite via the CLI:"," ",e.jsx("code",{className:"mono",children:"bizar eval run ./path/to/fixtures"}),"."]})}):n.map(M=>e.jsxs("div",{className:"eval-run-card-wrap",children:[e.jsx(xl,{run:M,selected:M.id===o,onClick:()=>w(M.id)}),o&&M.id!==o?e.jsxs("button",{type:"button",className:"eval-baseline-btn",onClick:()=>S(M.id),title:"Use this run as a baseline for diffing",children:[e.jsx(Go,{size:10,"aria-hidden":!0}),"Use as baseline"]}):null]},M.id))}),e.jsx("div",{className:"eval-detail",children:u&&!m?e.jsxs("div",{className:"eval-detail-loading",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"muted",children:"Loading run details…"})]}):m?e.jsx(Ox,{run:m,compareRun:c,runsForDiff:$,onClearCompare:()=>{h(null),v(null)},onClearSelection:()=>{l(null),d(null),h(null),v(null)}}):e.jsx(ne,{className:"eval-detail-empty",children:e.jsx(_e,{icon:e.jsx(Ot,{size:28}),title:"Select a run",message:"Pick an eval run from the list to view fixture-by-fixture results, latency, and per-check failure details."})})})]})]})}const Hx=rt.memo(Bx),$n=4e3;function Vx({onPlan:t,compact:s=!1}){const n=fe(),[a,i]=f.useState(""),[r,o]=f.useState(!1),l=async()=>{const c=a.trim();if(!c){n.error("Enter a goal first.");return}if(c.length>$n){n.error(`Goal must be ${$n} chars or fewer.`);return}o(!0);try{const h=await H.post("/goal-planner/plan",{goal:c});t&&t(h),n.success(`Plan generated: ${h.steps.length} steps.`)}catch(h){const m=(h==null?void 0:h.message)||"Planner failed";n.error(`Planner failed: ${m}`)}finally{o(!1)}};return e.jsxs("div",{className:`goal-input${s?" goal-input-compact":""}`,children:[e.jsxs("label",{className:"goal-input-label",htmlFor:"goal-input-textarea",children:[e.jsx(vt,{size:14,"aria-hidden":!0}),"Plain-English goal"]}),e.jsx("textarea",{id:"goal-input-textarea",className:"goal-input-textarea",value:a,onChange:c=>i(c.target.value),placeholder:"e.g. Research the latest advancements in quantum computing, then design and build a small demo, test it, and document the result.",disabled:r,maxLength:$n,rows:s?3:5,"data-testid":"goal-input-textarea"}),e.jsxs("div",{className:"goal-input-footer",children:[e.jsxs("span",{className:"goal-input-counter","data-testid":"goal-input-counter",children:[a.length," / ",$n]}),e.jsxs(U,{variant:"primary",size:"md",onClick:l,loading:r,disabled:r||!a.trim(),"data-testid":"goal-input-submit",children:[e.jsx(Rt,{size:14,"aria-hidden":!0}),r?"Planning…":"Generate plan"]})]})]})}function Le({children:t,className:s,variant:n,onRemove:a,...i}){return e.jsxs("span",{className:se("tag",n?`tag-${n}`:void 0,s),...i,children:[t,a&&e.jsx("button",{type:"button",className:"tag-remove","aria-label":`Remove ${typeof t=="string"?t:"tag"}`,onClick:a,children:"×"})]})}function Ux(t){if(!Number.isFinite(t)||t<0)return"—";const s=Math.floor(t/1e3),n=Math.floor(s/3600),a=Math.floor(s%3600/60),i=s%60;return n>0?`${n}h ${a}m`:a>0?`${a}m ${i}s`:`${i}s`}function qx({plan:t}){return t?e.jsxs(ne,{className:"plan-visualization","data-testid":"plan-visualization",children:[e.jsxs("div",{className:"plan-viz-header",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14,"aria-hidden":!0})," Execution plan"]}),e.jsxs("div",{className:"plan-viz-badges",children:[e.jsxs(Le,{variant:"info",children:[t.steps.length," steps"]}),e.jsxs(Le,{variant:"accent",children:["Cost ",t.totalCost]}),e.jsxs(Le,{variant:"success",children:[e.jsx(Jt,{size:10,"aria-hidden":!0})," ",Ux(t.totalDurationMs)]})]})]}),e.jsxs(ue,{className:"plan-viz-goal",children:["Goal: ",t.goal]}),e.jsx("ol",{className:"plan-viz-tree",role:"tree",children:t.steps.map(s=>e.jsx(Wx,{step:s},s.id))})]}):e.jsxs(ne,{className:"plan-visualization",children:[e.jsx(de,{children:"Execution plan"}),e.jsx(ue,{children:"Submit a goal to generate a plan."})]})}function Wx({step:t}){const[s,n]=f.useState(!1);return e.jsxs("li",{className:"plan-viz-row",role:"treeitem","aria-expanded":s,children:[e.jsxs("button",{type:"button",className:"plan-viz-row-head",onClick:()=>n(a=>!a),"data-testid":`plan-step-${t.id}`,children:[e.jsx("span",{className:"plan-viz-chevron",children:s?e.jsx(ct,{size:14,"aria-hidden":!0}):e.jsx(Ut,{size:14,"aria-hidden":!0})}),e.jsx("span",{className:se("plan-viz-action",`is-${t.action}`),children:t.action}),e.jsx("span",{className:"plan-viz-title",children:t.title}),e.jsxs("span",{className:"plan-viz-agent",children:["@",t.agent]}),e.jsx("span",{className:"plan-viz-cost",children:t.estimatedCost})]}),s&&e.jsxs("div",{className:"plan-viz-row-body","data-testid":`plan-step-${t.id}-body`,children:[e.jsx("p",{children:t.description}),t.deps.length>0&&e.jsxs("div",{className:"plan-viz-deps",children:[e.jsx("strong",{children:"Deps:"}),e.jsx("ul",{children:t.deps.map(a=>e.jsx("li",{children:e.jsx("code",{children:a})},a))})]}),e.jsxs("div",{className:"plan-viz-effects",children:[e.jsx("strong",{children:"Effects:"}),e.jsx("ul",{children:t.effects.map(a=>e.jsx("li",{children:e.jsx("code",{children:a})},a))})]})]})]})}function $e(t){if(typeof t=="string"||typeof t=="number")return""+t;let s="";if(Array.isArray(t))for(let n=0,a;n<t.length;n++)(a=$e(t[n]))!==""&&(s+=(s&&" ")+a);else for(let n in t)t[n]&&(s+=(s&&" ")+n);return s}var Gx={value:()=>{}};function fa(){for(var t=0,s=arguments.length,n={},a;t<s;++t){if(!(a=arguments[t]+"")||a in n||/[\s.]/.test(a))throw new Error("illegal type: "+a);n[a]=[]}return new Vn(n)}function Vn(t){this._=t}function Yx(t,s){return t.trim().split(/^|\s+/).map(function(n){var a="",i=n.indexOf(".");if(i>=0&&(a=n.slice(i+1),n=n.slice(0,i)),n&&!s.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:a}})}Vn.prototype=fa.prototype={constructor:Vn,on:function(t,s){var n=this._,a=Yx(t+"",n),i,r=-1,o=a.length;if(arguments.length<2){for(;++r<o;)if((i=(t=a[r]).type)&&(i=Xx(n[i],t.name)))return i;return}if(s!=null&&typeof s!="function")throw new Error("invalid callback: "+s);for(;++r<o;)if(i=(t=a[r]).type)n[i]=Tr(n[i],t.name,s);else if(s==null)for(i in n)n[i]=Tr(n[i],t.name,null);return this},copy:function(){var t={},s=this._;for(var n in s)t[n]=s[n].slice();return new Vn(t)},call:function(t,s){if((i=arguments.length-2)>0)for(var n=new Array(i),a=0,i,r;a<i;++a)n[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(r=this._[t],a=0,i=r.length;a<i;++a)r[a].value.apply(s,n)},apply:function(t,s,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var a=this._[t],i=0,r=a.length;i<r;++i)a[i].value.apply(s,n)}};function Xx(t,s){for(var n=0,a=t.length,i;n<a;++n)if((i=t[n]).name===s)return i.value}function Tr(t,s,n){for(var a=0,i=t.length;a<i;++a)if(t[a].name===s){t[a]=Gx,t=t.slice(0,a).concat(t.slice(a+1));break}return n!=null&&t.push({name:s,value:n}),t}var li="http://www.w3.org/1999/xhtml";const Ar={svg:"http://www.w3.org/2000/svg",xhtml:li,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function pa(t){var s=t+="",n=s.indexOf(":");return n>=0&&(s=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Ar.hasOwnProperty(s)?{space:Ar[s],local:t}:t}function Kx(t){return function(){var s=this.ownerDocument,n=this.namespaceURI;return n===li&&s.documentElement.namespaceURI===li?s.createElement(t):s.createElementNS(n,t)}}function Zx(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function yl(t){var s=pa(t);return(s.local?Zx:Kx)(s)}function Qx(){}function Di(t){return t==null?Qx:function(){return this.querySelector(t)}}function Jx(t){typeof t!="function"&&(t=Di(t));for(var s=this._groups,n=s.length,a=new Array(n),i=0;i<n;++i)for(var r=s[i],o=r.length,l=a[i]=new Array(o),c,h,m=0;m<o;++m)(c=r[m])&&(h=t.call(c,c.__data__,m,r))&&("__data__"in c&&(h.__data__=c.__data__),l[m]=h);return new it(a,this._parents)}function eg(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function tg(){return[]}function vl(t){return t==null?tg:function(){return this.querySelectorAll(t)}}function sg(t){return function(){return eg(t.apply(this,arguments))}}function ng(t){typeof t=="function"?t=sg(t):t=vl(t);for(var s=this._groups,n=s.length,a=[],i=[],r=0;r<n;++r)for(var o=s[r],l=o.length,c,h=0;h<l;++h)(c=o[h])&&(a.push(t.call(c,c.__data__,h,o)),i.push(c));return new it(a,i)}function jl(t){return function(){return this.matches(t)}}function bl(t){return function(s){return s.matches(t)}}var ag=Array.prototype.find;function ig(t){return function(){return ag.call(this.children,t)}}function rg(){return this.firstElementChild}function og(t){return this.select(t==null?rg:ig(typeof t=="function"?t:bl(t)))}var lg=Array.prototype.filter;function cg(){return Array.from(this.children)}function dg(t){return function(){return lg.call(this.children,t)}}function ug(t){return this.selectAll(t==null?cg:dg(typeof t=="function"?t:bl(t)))}function hg(t){typeof t!="function"&&(t=jl(t));for(var s=this._groups,n=s.length,a=new Array(n),i=0;i<n;++i)for(var r=s[i],o=r.length,l=a[i]=[],c,h=0;h<o;++h)(c=r[h])&&t.call(c,c.__data__,h,r)&&l.push(c);return new it(a,this._parents)}function wl(t){return new Array(t.length)}function mg(){return new it(this._enter||this._groups.map(wl),this._parents)}function Jn(t,s){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=s}Jn.prototype={constructor:Jn,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,s){return this._parent.insertBefore(t,s)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function fg(t){return function(){return t}}function pg(t,s,n,a,i,r){for(var o=0,l,c=s.length,h=r.length;o<h;++o)(l=s[o])?(l.__data__=r[o],a[o]=l):n[o]=new Jn(t,r[o]);for(;o<c;++o)(l=s[o])&&(i[o]=l)}function xg(t,s,n,a,i,r,o){var l,c,h=new Map,m=s.length,d=r.length,u=new Array(m),p;for(l=0;l<m;++l)(c=s[l])&&(u[l]=p=o.call(c,c.__data__,l,s)+"",h.has(p)?i[l]=c:h.set(p,c));for(l=0;l<d;++l)p=o.call(t,r[l],l,r)+"",(c=h.get(p))?(a[l]=c,c.__data__=r[l],h.delete(p)):n[l]=new Jn(t,r[l]);for(l=0;l<m;++l)(c=s[l])&&h.get(u[l])===c&&(i[l]=c)}function gg(t){return t.__data__}function yg(t,s){if(!arguments.length)return Array.from(this,gg);var n=s?xg:pg,a=this._parents,i=this._groups;typeof t!="function"&&(t=fg(t));for(var r=i.length,o=new Array(r),l=new Array(r),c=new Array(r),h=0;h<r;++h){var m=a[h],d=i[h],u=d.length,p=vg(t.call(m,m&&m.__data__,h,a)),x=p.length,v=l[h]=new Array(x),j=o[h]=new Array(x),g=c[h]=new Array(u);n(m,d,v,j,g,p,s);for(var b=0,y=0,w,S;b<x;++b)if(w=v[b]){for(b>=y&&(y=b+1);!(S=j[y])&&++y<x;);w._next=S||null}}return o=new it(o,a),o._enter=l,o._exit=c,o}function vg(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function jg(){return new it(this._exit||this._groups.map(wl),this._parents)}function bg(t,s,n){var a=this.enter(),i=this,r=this.exit();return typeof t=="function"?(a=t(a),a&&(a=a.selection())):a=a.append(t+""),s!=null&&(i=s(i),i&&(i=i.selection())),n==null?r.remove():n(r),a&&i?a.merge(i).order():i}function wg(t){for(var s=t.selection?t.selection():t,n=this._groups,a=s._groups,i=n.length,r=a.length,o=Math.min(i,r),l=new Array(i),c=0;c<o;++c)for(var h=n[c],m=a[c],d=h.length,u=l[c]=new Array(d),p,x=0;x<d;++x)(p=h[x]||m[x])&&(u[x]=p);for(;c<i;++c)l[c]=n[c];return new it(l,this._parents)}function kg(){for(var t=this._groups,s=-1,n=t.length;++s<n;)for(var a=t[s],i=a.length-1,r=a[i],o;--i>=0;)(o=a[i])&&(r&&o.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(o,r),r=o);return this}function Ng(t){t||(t=Sg);function s(d,u){return d&&u?t(d.__data__,u.__data__):!d-!u}for(var n=this._groups,a=n.length,i=new Array(a),r=0;r<a;++r){for(var o=n[r],l=o.length,c=i[r]=new Array(l),h,m=0;m<l;++m)(h=o[m])&&(c[m]=h);c.sort(s)}return new it(i,this._parents).order()}function Sg(t,s){return t<s?-1:t>s?1:t>=s?0:NaN}function Cg(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function zg(){return Array.from(this)}function Mg(){for(var t=this._groups,s=0,n=t.length;s<n;++s)for(var a=t[s],i=0,r=a.length;i<r;++i){var o=a[i];if(o)return o}return null}function $g(){let t=0;for(const s of this)++t;return t}function Eg(){return!this.node()}function _g(t){for(var s=this._groups,n=0,a=s.length;n<a;++n)for(var i=s[n],r=0,o=i.length,l;r<o;++r)(l=i[r])&&t.call(l,l.__data__,r,i);return this}function Tg(t){return function(){this.removeAttribute(t)}}function Ag(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Rg(t,s){return function(){this.setAttribute(t,s)}}function Ig(t,s){return function(){this.setAttributeNS(t.space,t.local,s)}}function Lg(t,s){return function(){var n=s.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function Pg(t,s){return function(){var n=s.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Dg(t,s){var n=pa(t);if(arguments.length<2){var a=this.node();return n.local?a.getAttributeNS(n.space,n.local):a.getAttribute(n)}return this.each((s==null?n.local?Ag:Tg:typeof s=="function"?n.local?Pg:Lg:n.local?Ig:Rg)(n,s))}function kl(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Fg(t){return function(){this.style.removeProperty(t)}}function Og(t,s,n){return function(){this.style.setProperty(t,s,n)}}function Bg(t,s,n){return function(){var a=s.apply(this,arguments);a==null?this.style.removeProperty(t):this.style.setProperty(t,a,n)}}function Hg(t,s,n){return arguments.length>1?this.each((s==null?Fg:typeof s=="function"?Bg:Og)(t,s,n??"")):zs(this.node(),t)}function zs(t,s){return t.style.getPropertyValue(s)||kl(t).getComputedStyle(t,null).getPropertyValue(s)}function Vg(t){return function(){delete this[t]}}function Ug(t,s){return function(){this[t]=s}}function qg(t,s){return function(){var n=s.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Wg(t,s){return arguments.length>1?this.each((s==null?Vg:typeof s=="function"?qg:Ug)(t,s)):this.node()[t]}function Nl(t){return t.trim().split(/^|\s+/)}function Fi(t){return t.classList||new Sl(t)}function Sl(t){this._node=t,this._names=Nl(t.getAttribute("class")||"")}Sl.prototype={add:function(t){var s=this._names.indexOf(t);s<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var s=this._names.indexOf(t);s>=0&&(this._names.splice(s,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Cl(t,s){for(var n=Fi(t),a=-1,i=s.length;++a<i;)n.add(s[a])}function zl(t,s){for(var n=Fi(t),a=-1,i=s.length;++a<i;)n.remove(s[a])}function Gg(t){return function(){Cl(this,t)}}function Yg(t){return function(){zl(this,t)}}function Xg(t,s){return function(){(s.apply(this,arguments)?Cl:zl)(this,t)}}function Kg(t,s){var n=Nl(t+"");if(arguments.length<2){for(var a=Fi(this.node()),i=-1,r=n.length;++i<r;)if(!a.contains(n[i]))return!1;return!0}return this.each((typeof s=="function"?Xg:s?Gg:Yg)(n,s))}function Zg(){this.textContent=""}function Qg(t){return function(){this.textContent=t}}function Jg(t){return function(){var s=t.apply(this,arguments);this.textContent=s??""}}function ey(t){return arguments.length?this.each(t==null?Zg:(typeof t=="function"?Jg:Qg)(t)):this.node().textContent}function ty(){this.innerHTML=""}function sy(t){return function(){this.innerHTML=t}}function ny(t){return function(){var s=t.apply(this,arguments);this.innerHTML=s??""}}function ay(t){return arguments.length?this.each(t==null?ty:(typeof t=="function"?ny:sy)(t)):this.node().innerHTML}function iy(){this.nextSibling&&this.parentNode.appendChild(this)}function ry(){return this.each(iy)}function oy(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ly(){return this.each(oy)}function cy(t){var s=typeof t=="function"?t:yl(t);return this.select(function(){return this.appendChild(s.apply(this,arguments))})}function dy(){return null}function uy(t,s){var n=typeof t=="function"?t:yl(t),a=s==null?dy:typeof s=="function"?s:Di(s);return this.select(function(){return this.insertBefore(n.apply(this,arguments),a.apply(this,arguments)||null)})}function hy(){var t=this.parentNode;t&&t.removeChild(this)}function my(){return this.each(hy)}function fy(){var t=this.cloneNode(!1),s=this.parentNode;return s?s.insertBefore(t,this.nextSibling):t}function py(){var t=this.cloneNode(!0),s=this.parentNode;return s?s.insertBefore(t,this.nextSibling):t}function xy(t){return this.select(t?py:fy)}function gy(t){return arguments.length?this.property("__data__",t):this.node().__data__}function yy(t){return function(s){t.call(this,s,this.__data__)}}function vy(t){return t.trim().split(/^|\s+/).map(function(s){var n="",a=s.indexOf(".");return a>=0&&(n=s.slice(a+1),s=s.slice(0,a)),{type:s,name:n}})}function jy(t){return function(){var s=this.__on;if(s){for(var n=0,a=-1,i=s.length,r;n<i;++n)r=s[n],(!t.type||r.type===t.type)&&r.name===t.name?this.removeEventListener(r.type,r.listener,r.options):s[++a]=r;++a?s.length=a:delete this.__on}}}function by(t,s,n){return function(){var a=this.__on,i,r=yy(s);if(a){for(var o=0,l=a.length;o<l;++o)if((i=a[o]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=r,i.options=n),i.value=s;return}}this.addEventListener(t.type,r,n),i={type:t.type,name:t.name,value:s,listener:r,options:n},a?a.push(i):this.__on=[i]}}function wy(t,s,n){var a=vy(t+""),i,r=a.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,h=l.length,m;c<h;++c)for(i=0,m=l[c];i<r;++i)if((o=a[i]).type===m.type&&o.name===m.name)return m.value}return}for(l=s?by:jy,i=0;i<r;++i)this.each(l(a[i],s,n));return this}function Ml(t,s,n){var a=kl(t),i=a.CustomEvent;typeof i=="function"?i=new i(s,n):(i=a.document.createEvent("Event"),n?(i.initEvent(s,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(s,!1,!1)),t.dispatchEvent(i)}function ky(t,s){return function(){return Ml(this,t,s)}}function Ny(t,s){return function(){return Ml(this,t,s.apply(this,arguments))}}function Sy(t,s){return this.each((typeof s=="function"?Ny:ky)(t,s))}function*Cy(){for(var t=this._groups,s=0,n=t.length;s<n;++s)for(var a=t[s],i=0,r=a.length,o;i<r;++i)(o=a[i])&&(yield o)}var $l=[null];function it(t,s){this._groups=t,this._parents=s}function xn(){return new it([[document.documentElement]],$l)}function zy(){return this}it.prototype=xn.prototype={constructor:it,select:Jx,selectAll:ng,selectChild:og,selectChildren:ug,filter:hg,data:yg,enter:mg,exit:jg,join:bg,merge:wg,selection:zy,order:kg,sort:Ng,call:Cg,nodes:zg,node:Mg,size:$g,empty:Eg,each:_g,attr:Dg,style:Hg,property:Wg,classed:Kg,text:ey,html:ay,raise:ry,lower:ly,append:cy,insert:uy,remove:my,clone:xy,datum:gy,on:wy,dispatch:Sy,[Symbol.iterator]:Cy};function at(t){return typeof t=="string"?new it([[document.querySelector(t)]],[document.documentElement]):new it([[t]],$l)}function My(t){let s;for(;s=t.sourceEvent;)t=s;return t}function dt(t,s){if(t=My(t),s===void 0&&(s=t.currentTarget),s){var n=s.ownerSVGElement||s;if(n.createSVGPoint){var a=n.createSVGPoint();return a.x=t.clientX,a.y=t.clientY,a=a.matrixTransform(s.getScreenCTM().inverse()),[a.x,a.y]}if(s.getBoundingClientRect){var i=s.getBoundingClientRect();return[t.clientX-i.left-s.clientLeft,t.clientY-i.top-s.clientTop]}}return[t.pageX,t.pageY]}const $y={passive:!1},nn={capture:!0,passive:!1};function Va(t){t.stopImmediatePropagation()}function vs(t){t.preventDefault(),t.stopImmediatePropagation()}function El(t){var s=t.document.documentElement,n=at(t).on("dragstart.drag",vs,nn);"onselectstart"in s?n.on("selectstart.drag",vs,nn):(s.__noselect=s.style.MozUserSelect,s.style.MozUserSelect="none")}function _l(t,s){var n=t.document.documentElement,a=at(t).on("dragstart.drag",null);s&&(a.on("click.drag",vs,nn),setTimeout(function(){a.on("click.drag",null)},0)),"onselectstart"in n?a.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const En=t=>()=>t;function ci(t,{sourceEvent:s,subject:n,target:a,identifier:i,active:r,x:o,y:l,dx:c,dy:h,dispatch:m}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:s,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:a,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:m}})}ci.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function Ey(t){return!t.ctrlKey&&!t.button}function _y(){return this.parentNode}function Ty(t,s){return s??{x:t.x,y:t.y}}function Ay(){return navigator.maxTouchPoints||"ontouchstart"in this}function Tl(){var t=Ey,s=_y,n=Ty,a=Ay,i={},r=fa("start","drag","end"),o=0,l,c,h,m,d=0;function u(w){w.on("mousedown.drag",p).filter(a).on("touchstart.drag",j).on("touchmove.drag",g,$y).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,S){if(!(m||!t.call(this,w,S))){var $=y(this,s.call(this,w,S),w,S,"mouse");$&&(at(w.view).on("mousemove.drag",x,nn).on("mouseup.drag",v,nn),El(w.view),Va(w),h=!1,l=w.clientX,c=w.clientY,$("start",w))}}function x(w){if(vs(w),!h){var S=w.clientX-l,$=w.clientY-c;h=S*S+$*$>d}i.mouse("drag",w)}function v(w){at(w.view).on("mousemove.drag mouseup.drag",null),_l(w.view,h),vs(w),i.mouse("end",w)}function j(w,S){if(t.call(this,w,S)){var $=w.changedTouches,M=s.call(this,w,S),z=$.length,A,k;for(A=0;A<z;++A)(k=y(this,M,w,S,$[A].identifier,$[A]))&&(Va(w),k("start",w,$[A]))}}function g(w){var S=w.changedTouches,$=S.length,M,z;for(M=0;M<$;++M)(z=i[S[M].identifier])&&(vs(w),z("drag",w,S[M]))}function b(w){var S=w.changedTouches,$=S.length,M,z;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),M=0;M<$;++M)(z=i[S[M].identifier])&&(Va(w),z("end",w,S[M]))}function y(w,S,$,M,z,A){var k=r.copy(),C=dt(A||$,S),_,L,N;if((N=n.call(w,new ci("beforestart",{sourceEvent:$,target:u,identifier:z,active:o,x:C[0],y:C[1],dx:0,dy:0,dispatch:k}),M))!=null)return _=N.x-C[0]||0,L=N.y-C[1]||0,function T(I,R,B){var E=C,P;switch(I){case"start":i[z]=T,P=o++;break;case"end":delete i[z],--o;case"drag":C=dt(B||R,S),P=o;break}k.call(I,w,new ci(I,{sourceEvent:R,subject:N,target:u,identifier:z,active:P,x:C[0]+_,y:C[1]+L,dx:C[0]-E[0],dy:C[1]-E[1],dispatch:k}),M)}}return u.filter=function(w){return arguments.length?(t=typeof w=="function"?w:En(!!w),u):t},u.container=function(w){return arguments.length?(s=typeof w=="function"?w:En(w),u):s},u.subject=function(w){return arguments.length?(n=typeof w=="function"?w:En(w),u):n},u.touchable=function(w){return arguments.length?(a=typeof w=="function"?w:En(!!w),u):a},u.on=function(){var w=r.on.apply(r,arguments);return w===r?u:w},u.clickDistance=function(w){return arguments.length?(d=(w=+w)*w,u):Math.sqrt(d)},u}function Oi(t,s,n){t.prototype=s.prototype=n,n.constructor=t}function Al(t,s){var n=Object.create(t.prototype);for(var a in s)n[a]=s[a];return n}function gn(){}var an=.7,ea=1/an,js="\\s*([+-]?\\d+)\\s*",rn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Nt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ry=/^#([0-9a-f]{3,8})$/,Iy=new RegExp(`^rgb\\(${js},${js},${js}\\)$`),Ly=new RegExp(`^rgb\\(${Nt},${Nt},${Nt}\\)$`),Py=new RegExp(`^rgba\\(${js},${js},${js},${rn}\\)$`),Dy=new RegExp(`^rgba\\(${Nt},${Nt},${Nt},${rn}\\)$`),Fy=new RegExp(`^hsl\\(${rn},${Nt},${Nt}\\)$`),Oy=new RegExp(`^hsla\\(${rn},${Nt},${Nt},${rn}\\)$`),Rr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Oi(gn,ns,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Ir,formatHex:Ir,formatHex8:By,formatHsl:Hy,formatRgb:Lr,toString:Lr});function Ir(){return this.rgb().formatHex()}function By(){return this.rgb().formatHex8()}function Hy(){return Rl(this).formatHsl()}function Lr(){return this.rgb().formatRgb()}function ns(t){var s,n;return t=(t+"").trim().toLowerCase(),(s=Ry.exec(t))?(n=s[1].length,s=parseInt(s[1],16),n===6?Pr(s):n===3?new Xe(s>>8&15|s>>4&240,s>>4&15|s&240,(s&15)<<4|s&15,1):n===8?_n(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):n===4?_n(s>>12&15|s>>8&240,s>>8&15|s>>4&240,s>>4&15|s&240,((s&15)<<4|s&15)/255):null):(s=Iy.exec(t))?new Xe(s[1],s[2],s[3],1):(s=Ly.exec(t))?new Xe(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Py.exec(t))?_n(s[1],s[2],s[3],s[4]):(s=Dy.exec(t))?_n(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Fy.exec(t))?Or(s[1],s[2]/100,s[3]/100,1):(s=Oy.exec(t))?Or(s[1],s[2]/100,s[3]/100,s[4]):Rr.hasOwnProperty(t)?Pr(Rr[t]):t==="transparent"?new Xe(NaN,NaN,NaN,0):null}function Pr(t){return new Xe(t>>16&255,t>>8&255,t&255,1)}function _n(t,s,n,a){return a<=0&&(t=s=n=NaN),new Xe(t,s,n,a)}function Vy(t){return t instanceof gn||(t=ns(t)),t?(t=t.rgb(),new Xe(t.r,t.g,t.b,t.opacity)):new Xe}function di(t,s,n,a){return arguments.length===1?Vy(t):new Xe(t,s,n,a??1)}function Xe(t,s,n,a){this.r=+t,this.g=+s,this.b=+n,this.opacity=+a}Oi(Xe,di,Al(gn,{brighter(t){return t=t==null?ea:Math.pow(ea,t),new Xe(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?an:Math.pow(an,t),new Xe(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Xe(Kt(this.r),Kt(this.g),Kt(this.b),ta(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Dr,formatHex:Dr,formatHex8:Uy,formatRgb:Fr,toString:Fr}));function Dr(){return`#${Xt(this.r)}${Xt(this.g)}${Xt(this.b)}`}function Uy(){return`#${Xt(this.r)}${Xt(this.g)}${Xt(this.b)}${Xt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Fr(){const t=ta(this.opacity);return`${t===1?"rgb(":"rgba("}${Kt(this.r)}, ${Kt(this.g)}, ${Kt(this.b)}${t===1?")":`, ${t})`}`}function ta(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Kt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Xt(t){return t=Kt(t),(t<16?"0":"")+t.toString(16)}function Or(t,s,n,a){return a<=0?t=s=n=NaN:n<=0||n>=1?t=s=NaN:s<=0&&(t=NaN),new ut(t,s,n,a)}function Rl(t){if(t instanceof ut)return new ut(t.h,t.s,t.l,t.opacity);if(t instanceof gn||(t=ns(t)),!t)return new ut;if(t instanceof ut)return t;t=t.rgb();var s=t.r/255,n=t.g/255,a=t.b/255,i=Math.min(s,n,a),r=Math.max(s,n,a),o=NaN,l=r-i,c=(r+i)/2;return l?(s===r?o=(n-a)/l+(n<a)*6:n===r?o=(a-s)/l+2:o=(s-n)/l+4,l/=c<.5?r+i:2-r-i,o*=60):l=c>0&&c<1?0:o,new ut(o,l,c,t.opacity)}function qy(t,s,n,a){return arguments.length===1?Rl(t):new ut(t,s,n,a??1)}function ut(t,s,n,a){this.h=+t,this.s=+s,this.l=+n,this.opacity=+a}Oi(ut,qy,Al(gn,{brighter(t){return t=t==null?ea:Math.pow(ea,t),new ut(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?an:Math.pow(an,t),new ut(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,s=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,a=n+(n<.5?n:1-n)*s,i=2*n-a;return new Xe(Ua(t>=240?t-240:t+120,i,a),Ua(t,i,a),Ua(t<120?t+240:t-120,i,a),this.opacity)},clamp(){return new ut(Br(this.h),Tn(this.s),Tn(this.l),ta(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ta(this.opacity);return`${t===1?"hsl(":"hsla("}${Br(this.h)}, ${Tn(this.s)*100}%, ${Tn(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Br(t){return t=(t||0)%360,t<0?t+360:t}function Tn(t){return Math.max(0,Math.min(1,t||0))}function Ua(t,s,n){return(t<60?s+(n-s)*t/60:t<180?n:t<240?s+(n-s)*(240-t)/60:s)*255}const Bi=t=>()=>t;function Wy(t,s){return function(n){return t+n*s}}function Gy(t,s,n){return t=Math.pow(t,n),s=Math.pow(s,n)-t,n=1/n,function(a){return Math.pow(t+a*s,n)}}function Yy(t){return(t=+t)==1?Il:function(s,n){return n-s?Gy(s,n,t):Bi(isNaN(s)?n:s)}}function Il(t,s){var n=s-t;return n?Wy(t,n):Bi(isNaN(t)?s:t)}const sa=function t(s){var n=Yy(s);function a(i,r){var o=n((i=di(i)).r,(r=di(r)).r),l=n(i.g,r.g),c=n(i.b,r.b),h=Il(i.opacity,r.opacity);return function(m){return i.r=o(m),i.g=l(m),i.b=c(m),i.opacity=h(m),i+""}}return a.gamma=t,a}(1);function Xy(t,s){s||(s=[]);var n=t?Math.min(s.length,t.length):0,a=s.slice(),i;return function(r){for(i=0;i<n;++i)a[i]=t[i]*(1-r)+s[i]*r;return a}}function Ky(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Zy(t,s){var n=s?s.length:0,a=t?Math.min(n,t.length):0,i=new Array(a),r=new Array(n),o;for(o=0;o<a;++o)i[o]=Xs(t[o],s[o]);for(;o<n;++o)r[o]=s[o];return function(l){for(o=0;o<a;++o)r[o]=i[o](l);return r}}function Qy(t,s){var n=new Date;return t=+t,s=+s,function(a){return n.setTime(t*(1-a)+s*a),n}}function kt(t,s){return t=+t,s=+s,function(n){return t*(1-n)+s*n}}function Jy(t,s){var n={},a={},i;(t===null||typeof t!="object")&&(t={}),(s===null||typeof s!="object")&&(s={});for(i in s)i in t?n[i]=Xs(t[i],s[i]):a[i]=s[i];return function(r){for(i in n)a[i]=n[i](r);return a}}var ui=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,qa=new RegExp(ui.source,"g");function ev(t){return function(){return t}}function tv(t){return function(s){return t(s)+""}}function Ll(t,s){var n=ui.lastIndex=qa.lastIndex=0,a,i,r,o=-1,l=[],c=[];for(t=t+"",s=s+"";(a=ui.exec(t))&&(i=qa.exec(s));)(r=i.index)>n&&(r=s.slice(n,r),l[o]?l[o]+=r:l[++o]=r),(a=a[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:kt(a,i)})),n=qa.lastIndex;return n<s.length&&(r=s.slice(n),l[o]?l[o]+=r:l[++o]=r),l.length<2?c[0]?tv(c[0].x):ev(s):(s=c.length,function(h){for(var m=0,d;m<s;++m)l[(d=c[m]).i]=d.x(h);return l.join("")})}function Xs(t,s){var n=typeof s,a;return s==null||n==="boolean"?Bi(s):(n==="number"?kt:n==="string"?(a=ns(s))?(s=a,sa):Ll:s instanceof ns?sa:s instanceof Date?Qy:Ky(s)?Xy:Array.isArray(s)?Zy:typeof s.valueOf!="function"&&typeof s.toString!="function"||isNaN(s)?Jy:kt)(t,s)}var Hr=180/Math.PI,hi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Pl(t,s,n,a,i,r){var o,l,c;return(o=Math.sqrt(t*t+s*s))&&(t/=o,s/=o),(c=t*n+s*a)&&(n-=t*c,a-=s*c),(l=Math.sqrt(n*n+a*a))&&(n/=l,a/=l,c/=l),t*a<s*n&&(t=-t,s=-s,c=-c,o=-o),{translateX:i,translateY:r,rotate:Math.atan2(s,t)*Hr,skewX:Math.atan(c)*Hr,scaleX:o,scaleY:l}}var An;function sv(t){const s=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return s.isIdentity?hi:Pl(s.a,s.b,s.c,s.d,s.e,s.f)}function nv(t){return t==null||(An||(An=document.createElementNS("http://www.w3.org/2000/svg","g")),An.setAttribute("transform",t),!(t=An.transform.baseVal.consolidate()))?hi:(t=t.matrix,Pl(t.a,t.b,t.c,t.d,t.e,t.f))}function Dl(t,s,n,a){function i(h){return h.length?h.pop()+" ":""}function r(h,m,d,u,p,x){if(h!==d||m!==u){var v=p.push("translate(",null,s,null,n);x.push({i:v-4,x:kt(h,d)},{i:v-2,x:kt(m,u)})}else(d||u)&&p.push("translate("+d+s+u+n)}function o(h,m,d,u){h!==m?(h-m>180?m+=360:m-h>180&&(h+=360),u.push({i:d.push(i(d)+"rotate(",null,a)-2,x:kt(h,m)})):m&&d.push(i(d)+"rotate("+m+a)}function l(h,m,d,u){h!==m?u.push({i:d.push(i(d)+"skewX(",null,a)-2,x:kt(h,m)}):m&&d.push(i(d)+"skewX("+m+a)}function c(h,m,d,u,p,x){if(h!==d||m!==u){var v=p.push(i(p)+"scale(",null,",",null,")");x.push({i:v-4,x:kt(h,d)},{i:v-2,x:kt(m,u)})}else(d!==1||u!==1)&&p.push(i(p)+"scale("+d+","+u+")")}return function(h,m){var d=[],u=[];return h=t(h),m=t(m),r(h.translateX,h.translateY,m.translateX,m.translateY,d,u),o(h.rotate,m.rotate,d,u),l(h.skewX,m.skewX,d,u),c(h.scaleX,h.scaleY,m.scaleX,m.scaleY,d,u),h=m=null,function(p){for(var x=-1,v=u.length,j;++x<v;)d[(j=u[x]).i]=j.x(p);return d.join("")}}}var av=Dl(sv,"px, ","px)","deg)"),iv=Dl(nv,", ",")",")"),rv=1e-12;function Vr(t){return((t=Math.exp(t))+1/t)/2}function ov(t){return((t=Math.exp(t))-1/t)/2}function lv(t){return((t=Math.exp(2*t))-1)/(t+1)}const Un=function t(s,n,a){function i(r,o){var l=r[0],c=r[1],h=r[2],m=o[0],d=o[1],u=o[2],p=m-l,x=d-c,v=p*p+x*x,j,g;if(v<rv)g=Math.log(u/h)/s,j=function(M){return[l+M*p,c+M*x,h*Math.exp(s*M*g)]};else{var b=Math.sqrt(v),y=(u*u-h*h+a*v)/(2*h*n*b),w=(u*u-h*h-a*v)/(2*u*n*b),S=Math.log(Math.sqrt(y*y+1)-y),$=Math.log(Math.sqrt(w*w+1)-w);g=($-S)/s,j=function(M){var z=M*g,A=Vr(S),k=h/(n*b)*(A*lv(s*z+S)-ov(S));return[l+k*p,c+k*x,h*A/Vr(s*z+S)]}}return j.duration=g*1e3*s/Math.SQRT2,j}return i.rho=function(r){var o=Math.max(.001,+r),l=o*o,c=l*l;return t(o,l,c)},i}(Math.SQRT2,2,4);var Ms=0,Ws=0,Us=0,Fl=1e3,na,Gs,aa=0,as=0,xa=0,on=typeof performance=="object"&&performance.now?performance:Date,Ol=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Hi(){return as||(Ol(cv),as=on.now()+xa)}function cv(){as=0}function ia(){this._call=this._time=this._next=null}ia.prototype=Bl.prototype={constructor:ia,restart:function(t,s,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Hi():+n)+(s==null?0:+s),!this._next&&Gs!==this&&(Gs?Gs._next=this:na=this,Gs=this),this._call=t,this._time=n,mi()},stop:function(){this._call&&(this._call=null,this._time=1/0,mi())}};function Bl(t,s,n){var a=new ia;return a.restart(t,s,n),a}function dv(){Hi(),++Ms;for(var t=na,s;t;)(s=as-t._time)>=0&&t._call.call(void 0,s),t=t._next;--Ms}function Ur(){as=(aa=on.now())+xa,Ms=Ws=0;try{dv()}finally{Ms=0,hv(),as=0}}function uv(){var t=on.now(),s=t-aa;s>Fl&&(xa-=s,aa=t)}function hv(){for(var t,s=na,n,a=1/0;s;)s._call?(a>s._time&&(a=s._time),t=s,s=s._next):(n=s._next,s._next=null,s=t?t._next=n:na=n);Gs=t,mi(a)}function mi(t){if(!Ms){Ws&&(Ws=clearTimeout(Ws));var s=t-as;s>24?(t<1/0&&(Ws=setTimeout(Ur,t-on.now()-xa)),Us&&(Us=clearInterval(Us))):(Us||(aa=on.now(),Us=setInterval(uv,Fl)),Ms=1,Ol(Ur))}}function qr(t,s,n){var a=new ia;return s=s==null?0:+s,a.restart(i=>{a.stop(),t(i+s)},s,n),a}var mv=fa("start","end","cancel","interrupt"),fv=[],Hl=0,Wr=1,fi=2,qn=3,Gr=4,pi=5,Wn=6;function ga(t,s,n,a,i,r){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;pv(t,n,{name:s,index:a,group:i,on:mv,tween:fv,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:Hl})}function Vi(t,s){var n=jt(t,s);if(n.state>Hl)throw new Error("too late; already scheduled");return n}function Ct(t,s){var n=jt(t,s);if(n.state>qn)throw new Error("too late; already running");return n}function jt(t,s){var n=t.__transition;if(!n||!(n=n[s]))throw new Error("transition not found");return n}function pv(t,s,n){var a=t.__transition,i;a[s]=n,n.timer=Bl(r,0,n.time);function r(h){n.state=Wr,n.timer.restart(o,n.delay,n.time),n.delay<=h&&o(h-n.delay)}function o(h){var m,d,u,p;if(n.state!==Wr)return c();for(m in a)if(p=a[m],p.name===n.name){if(p.state===qn)return qr(o);p.state===Gr?(p.state=Wn,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete a[m]):+m<s&&(p.state=Wn,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete a[m])}if(qr(function(){n.state===qn&&(n.state=Gr,n.timer.restart(l,n.delay,n.time),l(h))}),n.state=fi,n.on.call("start",t,t.__data__,n.index,n.group),n.state===fi){for(n.state=qn,i=new Array(u=n.tween.length),m=0,d=-1;m<u;++m)(p=n.tween[m].value.call(t,t.__data__,n.index,n.group))&&(i[++d]=p);i.length=d+1}}function l(h){for(var m=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(c),n.state=pi,1),d=-1,u=i.length;++d<u;)i[d].call(t,m);n.state===pi&&(n.on.call("end",t,t.__data__,n.index,n.group),c())}function c(){n.state=Wn,n.timer.stop(),delete a[s];for(var h in a)return;delete t.__transition}}function Gn(t,s){var n=t.__transition,a,i,r=!0,o;if(n){s=s==null?null:s+"";for(o in n){if((a=n[o]).name!==s){r=!1;continue}i=a.state>fi&&a.state<pi,a.state=Wn,a.timer.stop(),a.on.call(i?"interrupt":"cancel",t,t.__data__,a.index,a.group),delete n[o]}r&&delete t.__transition}}function xv(t){return this.each(function(){Gn(this,t)})}function gv(t,s){var n,a;return function(){var i=Ct(this,t),r=i.tween;if(r!==n){a=n=r;for(var o=0,l=a.length;o<l;++o)if(a[o].name===s){a=a.slice(),a.splice(o,1);break}}i.tween=a}}function yv(t,s,n){var a,i;if(typeof n!="function")throw new Error;return function(){var r=Ct(this,t),o=r.tween;if(o!==a){i=(a=o).slice();for(var l={name:s,value:n},c=0,h=i.length;c<h;++c)if(i[c].name===s){i[c]=l;break}c===h&&i.push(l)}r.tween=i}}function vv(t,s){var n=this._id;if(t+="",arguments.length<2){for(var a=jt(this.node(),n).tween,i=0,r=a.length,o;i<r;++i)if((o=a[i]).name===t)return o.value;return null}return this.each((s==null?gv:yv)(n,t,s))}function Ui(t,s,n){var a=t._id;return t.each(function(){var i=Ct(this,a);(i.value||(i.value={}))[s]=n.apply(this,arguments)}),function(i){return jt(i,a).value[s]}}function Vl(t,s){var n;return(typeof s=="number"?kt:s instanceof ns?sa:(n=ns(s))?(s=n,sa):Ll)(t,s)}function jv(t){return function(){this.removeAttribute(t)}}function bv(t){return function(){this.removeAttributeNS(t.space,t.local)}}function wv(t,s,n){var a,i=n+"",r;return function(){var o=this.getAttribute(t);return o===i?null:o===a?r:r=s(a=o,n)}}function kv(t,s,n){var a,i=n+"",r;return function(){var o=this.getAttributeNS(t.space,t.local);return o===i?null:o===a?r:r=s(a=o,n)}}function Nv(t,s,n){var a,i,r;return function(){var o,l=n(this),c;return l==null?void this.removeAttribute(t):(o=this.getAttribute(t),c=l+"",o===c?null:o===a&&c===i?r:(i=c,r=s(a=o,l)))}}function Sv(t,s,n){var a,i,r;return function(){var o,l=n(this),c;return l==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),c=l+"",o===c?null:o===a&&c===i?r:(i=c,r=s(a=o,l)))}}function Cv(t,s){var n=pa(t),a=n==="transform"?iv:Vl;return this.attrTween(t,typeof s=="function"?(n.local?Sv:Nv)(n,a,Ui(this,"attr."+t,s)):s==null?(n.local?bv:jv)(n):(n.local?kv:wv)(n,a,s))}function zv(t,s){return function(n){this.setAttribute(t,s.call(this,n))}}function Mv(t,s){return function(n){this.setAttributeNS(t.space,t.local,s.call(this,n))}}function $v(t,s){var n,a;function i(){var r=s.apply(this,arguments);return r!==a&&(n=(a=r)&&Mv(t,r)),n}return i._value=s,i}function Ev(t,s){var n,a;function i(){var r=s.apply(this,arguments);return r!==a&&(n=(a=r)&&zv(t,r)),n}return i._value=s,i}function _v(t,s){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(s==null)return this.tween(n,null);if(typeof s!="function")throw new Error;var a=pa(t);return this.tween(n,(a.local?$v:Ev)(a,s))}function Tv(t,s){return function(){Vi(this,t).delay=+s.apply(this,arguments)}}function Av(t,s){return s=+s,function(){Vi(this,t).delay=s}}function Rv(t){var s=this._id;return arguments.length?this.each((typeof t=="function"?Tv:Av)(s,t)):jt(this.node(),s).delay}function Iv(t,s){return function(){Ct(this,t).duration=+s.apply(this,arguments)}}function Lv(t,s){return s=+s,function(){Ct(this,t).duration=s}}function Pv(t){var s=this._id;return arguments.length?this.each((typeof t=="function"?Iv:Lv)(s,t)):jt(this.node(),s).duration}function Dv(t,s){if(typeof s!="function")throw new Error;return function(){Ct(this,t).ease=s}}function Fv(t){var s=this._id;return arguments.length?this.each(Dv(s,t)):jt(this.node(),s).ease}function Ov(t,s){return function(){var n=s.apply(this,arguments);if(typeof n!="function")throw new Error;Ct(this,t).ease=n}}function Bv(t){if(typeof t!="function")throw new Error;return this.each(Ov(this._id,t))}function Hv(t){typeof t!="function"&&(t=jl(t));for(var s=this._groups,n=s.length,a=new Array(n),i=0;i<n;++i)for(var r=s[i],o=r.length,l=a[i]=[],c,h=0;h<o;++h)(c=r[h])&&t.call(c,c.__data__,h,r)&&l.push(c);return new It(a,this._parents,this._name,this._id)}function Vv(t){if(t._id!==this._id)throw new Error;for(var s=this._groups,n=t._groups,a=s.length,i=n.length,r=Math.min(a,i),o=new Array(a),l=0;l<r;++l)for(var c=s[l],h=n[l],m=c.length,d=o[l]=new Array(m),u,p=0;p<m;++p)(u=c[p]||h[p])&&(d[p]=u);for(;l<a;++l)o[l]=s[l];return new It(o,this._parents,this._name,this._id)}function Uv(t){return(t+"").trim().split(/^|\s+/).every(function(s){var n=s.indexOf(".");return n>=0&&(s=s.slice(0,n)),!s||s==="start"})}function qv(t,s,n){var a,i,r=Uv(s)?Vi:Ct;return function(){var o=r(this,t),l=o.on;l!==a&&(i=(a=l).copy()).on(s,n),o.on=i}}function Wv(t,s){var n=this._id;return arguments.length<2?jt(this.node(),n).on.on(t):this.each(qv(n,t,s))}function Gv(t){return function(){var s=this.parentNode;for(var n in this.__transition)if(+n!==t)return;s&&s.removeChild(this)}}function Yv(){return this.on("end.remove",Gv(this._id))}function Xv(t){var s=this._name,n=this._id;typeof t!="function"&&(t=Di(t));for(var a=this._groups,i=a.length,r=new Array(i),o=0;o<i;++o)for(var l=a[o],c=l.length,h=r[o]=new Array(c),m,d,u=0;u<c;++u)(m=l[u])&&(d=t.call(m,m.__data__,u,l))&&("__data__"in m&&(d.__data__=m.__data__),h[u]=d,ga(h[u],s,n,u,h,jt(m,n)));return new It(r,this._parents,s,n)}function Kv(t){var s=this._name,n=this._id;typeof t!="function"&&(t=vl(t));for(var a=this._groups,i=a.length,r=[],o=[],l=0;l<i;++l)for(var c=a[l],h=c.length,m,d=0;d<h;++d)if(m=c[d]){for(var u=t.call(m,m.__data__,d,c),p,x=jt(m,n),v=0,j=u.length;v<j;++v)(p=u[v])&&ga(p,s,n,v,u,x);r.push(u),o.push(m)}return new It(r,o,s,n)}var Zv=xn.prototype.constructor;function Qv(){return new Zv(this._groups,this._parents)}function Jv(t,s){var n,a,i;return function(){var r=zs(this,t),o=(this.style.removeProperty(t),zs(this,t));return r===o?null:r===n&&o===a?i:i=s(n=r,a=o)}}function Ul(t){return function(){this.style.removeProperty(t)}}function ej(t,s,n){var a,i=n+"",r;return function(){var o=zs(this,t);return o===i?null:o===a?r:r=s(a=o,n)}}function tj(t,s,n){var a,i,r;return function(){var o=zs(this,t),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(t),zs(this,t))),o===c?null:o===a&&c===i?r:(i=c,r=s(a=o,l))}}function sj(t,s){var n,a,i,r="style."+s,o="end."+r,l;return function(){var c=Ct(this,t),h=c.on,m=c.value[r]==null?l||(l=Ul(s)):void 0;(h!==n||i!==m)&&(a=(n=h).copy()).on(o,i=m),c.on=a}}function nj(t,s,n){var a=(t+="")=="transform"?av:Vl;return s==null?this.styleTween(t,Jv(t,a)).on("end.style."+t,Ul(t)):typeof s=="function"?this.styleTween(t,tj(t,a,Ui(this,"style."+t,s))).each(sj(this._id,t)):this.styleTween(t,ej(t,a,s),n).on("end.style."+t,null)}function aj(t,s,n){return function(a){this.style.setProperty(t,s.call(this,a),n)}}function ij(t,s,n){var a,i;function r(){var o=s.apply(this,arguments);return o!==i&&(a=(i=o)&&aj(t,o,n)),a}return r._value=s,r}function rj(t,s,n){var a="style."+(t+="");if(arguments.length<2)return(a=this.tween(a))&&a._value;if(s==null)return this.tween(a,null);if(typeof s!="function")throw new Error;return this.tween(a,ij(t,s,n??""))}function oj(t){return function(){this.textContent=t}}function lj(t){return function(){var s=t(this);this.textContent=s??""}}function cj(t){return this.tween("text",typeof t=="function"?lj(Ui(this,"text",t)):oj(t==null?"":t+""))}function dj(t){return function(s){this.textContent=t.call(this,s)}}function uj(t){var s,n;function a(){var i=t.apply(this,arguments);return i!==n&&(s=(n=i)&&dj(i)),s}return a._value=t,a}function hj(t){var s="text";if(arguments.length<1)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,uj(t))}function mj(){for(var t=this._name,s=this._id,n=ql(),a=this._groups,i=a.length,r=0;r<i;++r)for(var o=a[r],l=o.length,c,h=0;h<l;++h)if(c=o[h]){var m=jt(c,s);ga(c,t,n,h,o,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new It(a,this._parents,t,n)}function fj(){var t,s,n=this,a=n._id,i=n.size();return new Promise(function(r,o){var l={value:o},c={value:function(){--i===0&&r()}};n.each(function(){var h=Ct(this,a),m=h.on;m!==t&&(s=(t=m).copy(),s._.cancel.push(l),s._.interrupt.push(l),s._.end.push(c)),h.on=s}),i===0&&r()})}var pj=0;function It(t,s,n,a){this._groups=t,this._parents=s,this._name=n,this._id=a}function ql(){return++pj}var Et=xn.prototype;It.prototype={constructor:It,select:Xv,selectAll:Kv,selectChild:Et.selectChild,selectChildren:Et.selectChildren,filter:Hv,merge:Vv,selection:Qv,transition:mj,call:Et.call,nodes:Et.nodes,node:Et.node,size:Et.size,empty:Et.empty,each:Et.each,on:Wv,attr:Cv,attrTween:_v,style:nj,styleTween:rj,text:cj,textTween:hj,remove:Yv,tween:vv,delay:Rv,duration:Pv,ease:Fv,easeVarying:Bv,end:fj,[Symbol.iterator]:Et[Symbol.iterator]};function xj(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var gj={time:null,delay:0,duration:250,ease:xj};function yj(t,s){for(var n;!(n=t.__transition)||!(n=n[s]);)if(!(t=t.parentNode))throw new Error(`transition ${s} not found`);return n}function vj(t){var s,n;t instanceof It?(s=t._id,t=t._name):(s=ql(),(n=gj).time=Hi(),t=t==null?null:t+"");for(var a=this._groups,i=a.length,r=0;r<i;++r)for(var o=a[r],l=o.length,c,h=0;h<l;++h)(c=o[h])&&ga(c,t,s,h,o,n||yj(c,s));return new It(a,this._parents,t,s)}xn.prototype.interrupt=xv;xn.prototype.transition=vj;const Rn=t=>()=>t;function jj(t,{sourceEvent:s,target:n,transform:a,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:s,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:a,enumerable:!0,configurable:!0},_:{value:i}})}function Tt(t,s,n){this.k=t,this.x=s,this.y=n}Tt.prototype={constructor:Tt,scale:function(t){return t===1?this:new Tt(this.k*t,this.x,this.y)},translate:function(t,s){return t===0&s===0?this:new Tt(this.k,this.x+this.k*t,this.y+this.k*s)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ya=new Tt(1,0,0);Wl.prototype=Tt.prototype;function Wl(t){for(;!t.__zoom;)if(!(t=t.parentNode))return ya;return t.__zoom}function Wa(t){t.stopImmediatePropagation()}function qs(t){t.preventDefault(),t.stopImmediatePropagation()}function bj(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function wj(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Yr(){return this.__zoom||ya}function kj(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Nj(){return navigator.maxTouchPoints||"ontouchstart"in this}function Sj(t,s,n){var a=t.invertX(s[0][0])-n[0][0],i=t.invertX(s[1][0])-n[1][0],r=t.invertY(s[0][1])-n[0][1],o=t.invertY(s[1][1])-n[1][1];return t.translate(i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i),o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o))}function Gl(){var t=bj,s=wj,n=Sj,a=kj,i=Nj,r=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Un,h=fa("start","zoom","end"),m,d,u,p=500,x=150,v=0,j=10;function g(N){N.property("__zoom",Yr).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",k).filter(i).on("touchstart.zoom",C).on("touchmove.zoom",_).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(N,T,I,R){var B=N.selection?N.selection():N;B.property("__zoom",Yr),N!==B?S(N,T,I,R):B.interrupt().each(function(){$(this,arguments).event(R).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},g.scaleBy=function(N,T,I,R){g.scaleTo(N,function(){var B=this.__zoom.k,E=typeof T=="function"?T.apply(this,arguments):T;return B*E},I,R)},g.scaleTo=function(N,T,I,R){g.transform(N,function(){var B=s.apply(this,arguments),E=this.__zoom,P=I==null?w(B):typeof I=="function"?I.apply(this,arguments):I,W=E.invert(P),V=typeof T=="function"?T.apply(this,arguments):T;return n(y(b(E,V),P,W),B,o)},I,R)},g.translateBy=function(N,T,I,R){g.transform(N,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof I=="function"?I.apply(this,arguments):I),s.apply(this,arguments),o)},null,R)},g.translateTo=function(N,T,I,R,B){g.transform(N,function(){var E=s.apply(this,arguments),P=this.__zoom,W=R==null?w(E):typeof R=="function"?R.apply(this,arguments):R;return n(ya.translate(W[0],W[1]).scale(P.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof I=="function"?-I.apply(this,arguments):-I),E,o)},R,B)};function b(N,T){return T=Math.max(r[0],Math.min(r[1],T)),T===N.k?N:new Tt(T,N.x,N.y)}function y(N,T,I){var R=T[0]-I[0]*N.k,B=T[1]-I[1]*N.k;return R===N.x&&B===N.y?N:new Tt(N.k,R,B)}function w(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function S(N,T,I,R){N.on("start.zoom",function(){$(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(R).end()}).tween("zoom",function(){var B=this,E=arguments,P=$(B,E).event(R),W=s.apply(B,E),V=I==null?w(W):typeof I=="function"?I.apply(B,E):I,K=Math.max(W[1][0]-W[0][0],W[1][1]-W[0][1]),D=B.__zoom,G=typeof T=="function"?T.apply(B,E):T,ee=c(D.invert(V).concat(K/D.k),G.invert(V).concat(K/G.k));return function(te){if(te===1)te=G;else{var F=ee(te),Y=K/F[2];te=new Tt(Y,V[0]-F[0]*Y,V[1]-F[1]*Y)}P.zoom(null,te)}})}function $(N,T,I){return!I&&N.__zooming||new M(N,T)}function M(N,T){this.that=N,this.args=T,this.active=0,this.sourceEvent=null,this.extent=s.apply(N,T),this.taps=0}M.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,T){return this.mouse&&N!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var T=at(this.that).datum();h.call(N,this.that,new jj(N,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:h}),T)}};function z(N,...T){if(!t.apply(this,arguments))return;var I=$(this,T).event(N),R=this.__zoom,B=Math.max(r[0],Math.min(r[1],R.k*Math.pow(2,a.apply(this,arguments)))),E=dt(N);if(I.wheel)(I.mouse[0][0]!==E[0]||I.mouse[0][1]!==E[1])&&(I.mouse[1]=R.invert(I.mouse[0]=E)),clearTimeout(I.wheel);else{if(R.k===B)return;I.mouse=[E,R.invert(E)],Gn(this),I.start()}qs(N),I.wheel=setTimeout(P,x),I.zoom("mouse",n(y(b(R,B),I.mouse[0],I.mouse[1]),I.extent,o));function P(){I.wheel=null,I.end()}}function A(N,...T){if(u||!t.apply(this,arguments))return;var I=N.currentTarget,R=$(this,T,!0).event(N),B=at(N.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",K,!0),E=dt(N,I),P=N.clientX,W=N.clientY;El(N.view),Wa(N),R.mouse=[E,this.__zoom.invert(E)],Gn(this),R.start();function V(D){if(qs(D),!R.moved){var G=D.clientX-P,ee=D.clientY-W;R.moved=G*G+ee*ee>v}R.event(D).zoom("mouse",n(y(R.that.__zoom,R.mouse[0]=dt(D,I),R.mouse[1]),R.extent,o))}function K(D){B.on("mousemove.zoom mouseup.zoom",null),_l(D.view,R.moved),qs(D),R.event(D).end()}}function k(N,...T){if(t.apply(this,arguments)){var I=this.__zoom,R=dt(N.changedTouches?N.changedTouches[0]:N,this),B=I.invert(R),E=I.k*(N.shiftKey?.5:2),P=n(y(b(I,E),R,B),s.apply(this,T),o);qs(N),l>0?at(this).transition().duration(l).call(S,P,R,N):at(this).call(g.transform,P,R,N)}}function C(N,...T){if(t.apply(this,arguments)){var I=N.touches,R=I.length,B=$(this,T,N.changedTouches.length===R).event(N),E,P,W,V;for(Wa(N),P=0;P<R;++P)W=I[P],V=dt(W,this),V=[V,this.__zoom.invert(V),W.identifier],B.touch0?!B.touch1&&B.touch0[2]!==V[2]&&(B.touch1=V,B.taps=0):(B.touch0=V,E=!0,B.taps=1+!!m);m&&(m=clearTimeout(m)),E&&(B.taps<2&&(d=V[0],m=setTimeout(function(){m=null},p)),Gn(this),B.start())}}function _(N,...T){if(this.__zooming){var I=$(this,T).event(N),R=N.changedTouches,B=R.length,E,P,W,V;for(qs(N),E=0;E<B;++E)P=R[E],W=dt(P,this),I.touch0&&I.touch0[2]===P.identifier?I.touch0[0]=W:I.touch1&&I.touch1[2]===P.identifier&&(I.touch1[0]=W);if(P=I.that.__zoom,I.touch1){var K=I.touch0[0],D=I.touch0[1],G=I.touch1[0],ee=I.touch1[1],te=(te=G[0]-K[0])*te+(te=G[1]-K[1])*te,F=(F=ee[0]-D[0])*F+(F=ee[1]-D[1])*F;P=b(P,Math.sqrt(te/F)),W=[(K[0]+G[0])/2,(K[1]+G[1])/2],V=[(D[0]+ee[0])/2,(D[1]+ee[1])/2]}else if(I.touch0)W=I.touch0[0],V=I.touch0[1];else return;I.zoom("touch",n(y(P,W,V),I.extent,o))}}function L(N,...T){if(this.__zooming){var I=$(this,T).event(N),R=N.changedTouches,B=R.length,E,P;for(Wa(N),u&&clearTimeout(u),u=setTimeout(function(){u=null},p),E=0;E<B;++E)P=R[E],I.touch0&&I.touch0[2]===P.identifier?delete I.touch0:I.touch1&&I.touch1[2]===P.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(P=dt(P,this),Math.hypot(d[0]-P[0],d[1]-P[1])<j)){var W=at(this).on("dblclick.zoom");W&&W.apply(this,arguments)}}}return g.wheelDelta=function(N){return arguments.length?(a=typeof N=="function"?N:Rn(+N),g):a},g.filter=function(N){return arguments.length?(t=typeof N=="function"?N:Rn(!!N),g):t},g.touchable=function(N){return arguments.length?(i=typeof N=="function"?N:Rn(!!N),g):i},g.extent=function(N){return arguments.length?(s=typeof N=="function"?N:Rn([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),g):s},g.scaleExtent=function(N){return arguments.length?(r[0]=+N[0],r[1]=+N[1],g):[r[0],r[1]]},g.translateExtent=function(N){return arguments.length?(o[0][0]=+N[0][0],o[1][0]=+N[1][0],o[0][1]=+N[0][1],o[1][1]=+N[1][1],g):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},g.constrain=function(N){return arguments.length?(n=N,g):n},g.duration=function(N){return arguments.length?(l=+N,g):l},g.interpolate=function(N){return arguments.length?(c=N,g):c},g.on=function(){var N=h.on.apply(h,arguments);return N===h?g:N},g.clickDistance=function(N){return arguments.length?(v=(N=+N)*N,g):Math.sqrt(v)},g.tapDistance=function(N){return arguments.length?(j=+N,g):j},g}const yt={error001:(t="react")=>`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:s,sourceHandle:n,targetHandle:a})=>`Couldn't create edge for ${t} handle id: "${t==="source"?n:a}", edge id: ${s}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ln=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Yl=["Enter"," ","Escape"],Xl={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:s,y:n})=>`Moved selected node ${t}. New position, x: ${s}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var $s;(function(t){t.Strict="strict",t.Loose="loose"})($s||($s={}));var Zt;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Zt||(Zt={}));var cn;(function(t){t.Partial="partial",t.Full="full"})(cn||(cn={}));const Kl={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ft;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Ft||(Ft={}));var ra;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(ra||(ra={}));var he;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(he||(he={}));const Xr={[he.Left]:he.Right,[he.Right]:he.Left,[he.Top]:he.Bottom,[he.Bottom]:he.Top};function Zl(t){return t===null?null:t?"valid":"invalid"}const Ql=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,Cj=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),qi=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),yn=(t,s=[0,0])=>{const{width:n,height:a}=zt(t),i=t.origin??s,r=n*i[0],o=a*i[1];return{x:t.position.x-r,y:t.position.y-o}},zj=(t,s={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((a,i)=>{const r=typeof i=="string";let o=!s.nodeLookup&&!r?i:void 0;s.nodeLookup&&(o=r?s.nodeLookup.get(i):qi(i)?i:s.nodeLookup.get(i.id));const l=o?oa(o,s.nodeOrigin):{x:0,y:0,x2:0,y2:0};return va(a,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ja(n)},vn=(t,s={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},a=!1;return t.forEach(i=>{(s.filter===void 0||s.filter(i))&&(n=va(n,oa(i)),a=!0)}),a?ja(n):{x:0,y:0,width:0,height:0}},Wi=(t,s,[n,a,i]=[0,0,1],r=!1,o=!1)=>{const l=(s.x-n)/i,c=(s.y-a)/i,h=s.width/i,m=s.height/i,d=[];for(const u of t.values()){const{measured:p,selectable:x=!0,hidden:v=!1}=u;if(o&&!x||v)continue;const j=p.width??u.width??u.initialWidth??0,g=p.height??u.height??u.initialHeight??0,{x:b,y}=u.internals.positionAbsolute,w=sc(l,c,h,m,b,y,j,g),S=j*g,$=r&&w>0;(!u.internals.handleBounds||$||w>=S||u.dragging)&&d.push(u)}return d},Mj=(t,s)=>{const n=new Set;return t.forEach(a=>{n.add(a.id)}),s.filter(a=>n.has(a.source)||n.has(a.target))};function $j(t,s){const n=new Map,a=s!=null&&s.nodes?new Set(s.nodes.map(i=>i.id)):null;return t.forEach(i=>{let r;if(s!=null&&s.includeHiddenNodes){const{width:o,height:l}=zt(i);r=o>0&&l>0}else r=!!(i.measured.width&&i.measured.height&&!i.hidden);r&&(!a||a.has(i.id))&&n.set(i.id,i)}),n}async function Ej({nodes:t,width:s,height:n,panZoom:a,minZoom:i,maxZoom:r},o){if(t.size===0)return!0;const l=$j(t,o),c=vn(l),h=Yi(c,s,n,(o==null?void 0:o.minZoom)??i,(o==null?void 0:o.maxZoom)??r,(o==null?void 0:o.padding)??.1);return await a.setViewport(h,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0}function Jl({nodeId:t,nextPosition:s,nodeLookup:n,nodeOrigin:a=[0,0],nodeExtent:i,onError:r}){const o=n.get(t),l=o.parentId?n.get(o.parentId):void 0,{x:c,y:h}=l?l.internals.positionAbsolute:{x:0,y:0},m=o.origin??a;let d=o.extent||i;if(o.extent==="parent"&&!o.expandParent)if(!l)r==null||r("005",yt.error005());else{const p=l.measured.width,x=l.measured.height;p&&x&&(d=[[c,h],[c+p,h+x]])}else l&&rs(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+h],[o.extent[1][0]+c,o.extent[1][1]+h]]);const u=rs(d)?is(s,d,o.measured):s;return(o.measured.width===void 0||o.measured.height===void 0)&&(r==null||r("015",yt.error015())),{position:{x:u.x-c+(o.measured.width??0)*m[0],y:u.y-h+(o.measured.height??0)*m[1]},positionAbsolute:u}}async function _j({nodesToRemove:t=[],edgesToRemove:s=[],nodes:n,edges:a,onBeforeDelete:i}){const r=new Set(t.map(u=>u.id)),o=[];for(const u of n){if(u.deletable===!1)continue;const p=r.has(u.id),x=!p&&u.parentId&&o.find(v=>v.id===u.parentId);(p||x)&&o.push(u)}const l=new Set(s.map(u=>u.id)),c=a.filter(u=>u.deletable!==!1),m=Mj(o,c);for(const u of c)l.has(u.id)&&!m.find(x=>x.id===u.id)&&m.push(u);if(!i)return{edges:m,nodes:o};const d=await i({nodes:o,edges:m});return typeof d=="boolean"?d?{edges:m,nodes:o}:{edges:[],nodes:[]}:d}const Es=(t,s=0,n=1)=>Math.min(Math.max(t,s),n),is=(t={x:0,y:0},s,n)=>({x:Es(t.x,s[0][0],s[1][0]-((n==null?void 0:n.width)??0)),y:Es(t.y,s[0][1],s[1][1]-((n==null?void 0:n.height)??0))});function ec(t,s,n){const{width:a,height:i}=zt(n),{x:r,y:o}=n.internals.positionAbsolute;return is(t,[[r,o],[r+a,o+i]],s)}const Kr=(t,s,n)=>t<s?Es(Math.abs(t-s),1,s)/s:t>n?-Es(Math.abs(t-n),1,s)/s:0,Gi=(t,s,n=15,a=40)=>{const i=Kr(t.x,a,s.width-a)*n,r=Kr(t.y,a,s.height-a)*n;return[i,r]},va=(t,s)=>({x:Math.min(t.x,s.x),y:Math.min(t.y,s.y),x2:Math.max(t.x2,s.x2),y2:Math.max(t.y2,s.y2)}),xi=({x:t,y:s,width:n,height:a})=>({x:t,y:s,x2:t+n,y2:s+a}),ja=({x:t,y:s,x2:n,y2:a})=>({x:t,y:s,width:n-t,height:a-s}),dn=(t,s=[0,0])=>{var i,r;const{x:n,y:a}=qi(t)?t.internals.positionAbsolute:yn(t,s);return{x:n,y:a,width:((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0,height:((r=t.measured)==null?void 0:r.height)??t.height??t.initialHeight??0}},oa=(t,s=[0,0])=>{var i,r;const{x:n,y:a}=qi(t)?t.internals.positionAbsolute:yn(t,s);return{x:n,y:a,x2:n+(((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0),y2:a+(((r=t.measured)==null?void 0:r.height)??t.height??t.initialHeight??0)}},tc=(t,s)=>ja(va(xi(t),xi(s))),sc=(t,s,n,a,i,r,o,l)=>{const c=Math.max(0,Math.min(t+n,i+o)-Math.max(t,i)),h=Math.max(0,Math.min(s+a,r+l)-Math.max(s,r));return Math.ceil(c*h)},la=(t,s)=>sc(t.x,t.y,t.width,t.height,s.x,s.y,s.width,s.height),Zr=t=>mt(t.width)&&mt(t.height)&&mt(t.x)&&mt(t.y),mt=t=>!isNaN(t)&&isFinite(t),nc=(t,s)=>(n,a)=>{},jn=(t,s=[1,1])=>({x:s[0]*Math.round(t.x/s[0]),y:s[1]*Math.round(t.y/s[1])}),bn=({x:t,y:s},[n,a,i],r=!1,o=[1,1])=>{const l={x:(t-n)/i,y:(s-a)/i};return r?jn(l,o):l},_s=({x:t,y:s},[n,a,i])=>({x:t*i+n,y:s*i+a});function ms(t,s){if(typeof t=="number")return Math.floor((s-s/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(n)}if(typeof t=="string"&&t.endsWith("%")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(s*n*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Tj(t,s,n){if(typeof t=="string"||typeof t=="number"){const a=ms(t,n),i=ms(t,s);return{top:a,right:i,bottom:a,left:i,x:i*2,y:a*2}}if(typeof t=="object"){const a=ms(t.top??t.y??0,n),i=ms(t.bottom??t.y??0,n),r=ms(t.left??t.x??0,s),o=ms(t.right??t.x??0,s);return{top:a,right:o,bottom:i,left:r,x:r+o,y:a+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Aj(t,s,n,a,i,r){const{x:o,y:l}=_s(t,[s,n,a]),{x:c,y:h}=_s({x:t.x+t.width,y:t.y+t.height},[s,n,a]),m=i-c,d=r-h;return{left:Math.floor(o),top:Math.floor(l),right:Math.floor(m),bottom:Math.floor(d)}}const Yi=(t,s,n,a,i,r)=>{const o=Tj(r,s,n),l=(s-o.x)/t.width,c=(n-o.y)/t.height,h=Math.min(l,c),m=Es(h,a,i),d=t.x+t.width/2,u=t.y+t.height/2,p=s/2-d*m,x=n/2-u*m,v=Aj(t,p,x,m,s,n),j={left:Math.min(v.left-o.left,0),top:Math.min(v.top-o.top,0),right:Math.min(v.right-o.right,0),bottom:Math.min(v.bottom-o.bottom,0)};return{x:p-j.left+j.right,y:x-j.top+j.bottom,zoom:m}},un=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function rs(t){return t!=null&&t!=="parent"}function zt(t){var s,n;return{width:((s=t.measured)==null?void 0:s.width)??t.width??t.initialWidth??0,height:((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight??0}}function ac(t){var s,n;return(((s=t.measured)==null?void 0:s.width)??t.width??t.initialWidth)!==void 0&&(((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight)!==void 0}function ic(t,s={width:0,height:0},n,a,i){const r={...t},o=a.get(n);if(o){const l=o.origin||i;r.x+=o.internals.positionAbsolute.x-(s.width??0)*l[0],r.y+=o.internals.positionAbsolute.y-(s.height??0)*l[1]}return r}function Qr(t,s){if(t.size!==s.size)return!1;for(const n of t)if(!s.has(n))return!1;return!0}function Rj(){let t,s;return{promise:new Promise((a,i)=>{t=a,s=i}),resolve:t,reject:s}}function Ij(t){return{...Xl,...t||{}}}function Ks(t,{snapGrid:s=[0,0],snapToGrid:n=!1,transform:a,containerBounds:i}){const{x:r,y:o}=ft(t),l=bn({x:r-((i==null?void 0:i.left)??0),y:o-((i==null?void 0:i.top)??0)},a),{x:c,y:h}=n?jn(l,s):l;return{xSnapped:c,ySnapped:h,...l}}const Xi=t=>({width:t.offsetWidth,height:t.offsetHeight}),rc=t=>{var s;return((s=t==null?void 0:t.getRootNode)==null?void 0:s.call(t))||(window==null?void 0:window.document)},Lj=["INPUT","SELECT","TEXTAREA"];function oc(t){var a,i;const s=((i=(a=t.composedPath)==null?void 0:a.call(t))==null?void 0:i[0])||t.target;return(s==null?void 0:s.nodeType)!==1?!1:Lj.includes(s.nodeName)||s.hasAttribute("contenteditable")||!!s.closest(".nokey")}const lc=t=>"clientX"in t,ft=(t,s)=>{var r,o;const n=lc(t),a=n?t.clientX:(r=t.touches)==null?void 0:r[0].clientX,i=n?t.clientY:(o=t.touches)==null?void 0:o[0].clientY;return{x:a-((s==null?void 0:s.left)??0),y:i-((s==null?void 0:s.top)??0)}},Jr=(t,s,n,a,i)=>{const r=s.querySelectorAll(`.${t}`);return!r||!r.length?null:Array.from(r).map(o=>{const l=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:t,nodeId:i,position:o.getAttribute("data-handlepos"),x:(l.left-n.left)/a,y:(l.top-n.top)/a,...Xi(o)}})};function cc({sourceX:t,sourceY:s,targetX:n,targetY:a,sourceControlX:i,sourceControlY:r,targetControlX:o,targetControlY:l}){const c=t*.125+i*.375+o*.375+n*.125,h=s*.125+r*.375+l*.375+a*.125,m=Math.abs(c-t),d=Math.abs(h-s);return[c,h,m,d]}function In(t,s){return t>=0?.5*t:s*25*Math.sqrt(-t)}function eo({pos:t,x1:s,y1:n,x2:a,y2:i,c:r}){switch(t){case he.Left:return[s-In(s-a,r),n];case he.Right:return[s+In(a-s,r),n];case he.Top:return[s,n-In(n-i,r)];case he.Bottom:return[s,n+In(i-n,r)]}}function dc({sourceX:t,sourceY:s,sourcePosition:n=he.Bottom,targetX:a,targetY:i,targetPosition:r=he.Top,curvature:o=.25}){const[l,c]=eo({pos:n,x1:t,y1:s,x2:a,y2:i,c:o}),[h,m]=eo({pos:r,x1:a,y1:i,x2:t,y2:s,c:o}),[d,u,p,x]=cc({sourceX:t,sourceY:s,targetX:a,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:h,targetControlY:m});return[`M${t},${s} C${l},${c} ${h},${m} ${a},${i}`,d,u,p,x]}function uc({sourceX:t,sourceY:s,targetX:n,targetY:a}){const i=Math.abs(n-t)/2,r=n<t?n+i:n-i,o=Math.abs(a-s)/2,l=a<s?a+o:a-o;return[r,l,i,o]}function Pj({sourceNode:t,targetNode:s,selected:n=!1,zIndex:a=0,elevateOnSelect:i=!1,zIndexMode:r="basic"}){if(r==="manual")return a;const o=i&&n?a+1e3:a,l=Math.max(t.parentId||i&&t.selected?t.internals.z:0,s.parentId||i&&s.selected?s.internals.z:0);return o+l}function Dj({sourceNode:t,targetNode:s,width:n,height:a,transform:i}){const r=va(oa(t),oa(s));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const o={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:a/i[2]};return la(o,ja(r))>0}const Fj=({source:t,sourceHandle:s,target:n,targetHandle:a})=>`xy-edge__${t}${s||""}-${n}${a||""}`,Oj=(t,s)=>s.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),Bj=(t,s,n={})=>{var r;if(!t.source||!t.target)return(r=n.onError)==null||r.call(n,"006",yt.error006()),s;const a=n.getEdgeId||Fj;let i;return Ql(t)?i={...t}:i={...t,id:a(t)},Oj(i,s)?s:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,s.concat(i))};function hc({sourceX:t,sourceY:s,targetX:n,targetY:a}){const[i,r,o,l]=uc({sourceX:t,sourceY:s,targetX:n,targetY:a});return[`M ${t},${s}L ${n},${a}`,i,r,o,l]}const to={[he.Left]:{x:-1,y:0},[he.Right]:{x:1,y:0},[he.Top]:{x:0,y:-1},[he.Bottom]:{x:0,y:1}},Hj=({source:t,sourcePosition:s=he.Bottom,target:n})=>s===he.Left||s===he.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},so=(t,s)=>Math.sqrt(Math.pow(s.x-t.x,2)+Math.pow(s.y-t.y,2));function Vj({source:t,sourcePosition:s=he.Bottom,target:n,targetPosition:a=he.Top,center:i,offset:r,stepPosition:o}){const l=to[s],c=to[a],h={x:t.x+l.x*r,y:t.y+l.y*r},m={x:n.x+c.x*r,y:n.y+c.y*r},d=Hj({source:h,sourcePosition:s,target:m}),u=d.x!==0?"x":"y",p=d[u];let x=[],v,j;const g={x:0,y:0},b={x:0,y:0},[,,y,w]=uc({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(l[u]*c[u]===-1){u==="x"?(v=i.x??h.x+(m.x-h.x)*o,j=i.y??(h.y+m.y)/2):(v=i.x??(h.x+m.x)/2,j=i.y??h.y+(m.y-h.y)*o);const z=[{x:v,y:h.y},{x:v,y:m.y}],A=[{x:h.x,y:j},{x:m.x,y:j}];l[u]===p?x=u==="x"?z:A:x=u==="x"?A:z}else{const z=[{x:h.x,y:m.y}],A=[{x:m.x,y:h.y}];if(u==="x"?x=l.x===p?A:z:x=l.y===p?z:A,s===a){const N=Math.abs(t[u]-n[u]);if(N<=r){const T=Math.min(r-1,r-N);l[u]===p?g[u]=(h[u]>t[u]?-1:1)*T:b[u]=(m[u]>n[u]?-1:1)*T}}if(s!==a){const N=u==="x"?"y":"x",T=l[u]===c[N],I=h[N]>m[N],R=h[N]<m[N];(l[u]===1&&(!T&&I||T&&R)||l[u]!==1&&(!T&&R||T&&I))&&(x=u==="x"?z:A)}const k={x:h.x+g.x,y:h.y+g.y},C={x:m.x+b.x,y:m.y+b.y},_=Math.max(Math.abs(k.x-x[0].x),Math.abs(C.x-x[0].x)),L=Math.max(Math.abs(k.y-x[0].y),Math.abs(C.y-x[0].y));_>=L?(v=(k.x+C.x)/2,j=x[0].y):(v=x[0].x,j=(k.y+C.y)/2)}const S={x:h.x+g.x,y:h.y+g.y},$={x:m.x+b.x,y:m.y+b.y};return[[t,...S.x!==x[0].x||S.y!==x[0].y?[S]:[],...x,...$.x!==x[x.length-1].x||$.y!==x[x.length-1].y?[$]:[],n],v,j,y,w]}function Uj(t,s,n,a){const i=Math.min(so(t,s)/2,so(s,n)/2,a),{x:r,y:o}=s;if(t.x===r&&r===n.x||t.y===o&&o===n.y)return`L${r} ${o}`;if(t.y===o){const h=t.x<n.x?-1:1,m=t.y<n.y?1:-1;return`L ${r+i*h},${o}Q ${r},${o} ${r},${o+i*m}`}const l=t.x<n.x?1:-1,c=t.y<n.y?-1:1;return`L ${r},${o+i*c}Q ${r},${o} ${r+i*l},${o}`}function gi({sourceX:t,sourceY:s,sourcePosition:n=he.Bottom,targetX:a,targetY:i,targetPosition:r=he.Top,borderRadius:o=5,centerX:l,centerY:c,offset:h=20,stepPosition:m=.5}){const[d,u,p,x,v]=Vj({source:{x:t,y:s},sourcePosition:n,target:{x:a,y:i},targetPosition:r,center:{x:l,y:c},offset:h,stepPosition:m});let j=`M${d[0].x} ${d[0].y}`;for(let g=1;g<d.length-1;g++)j+=Uj(d[g-1],d[g],d[g+1],o);return j+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[j,u,p,x,v]}function no(t){var s;return t&&!!(t.internals.handleBounds||(s=t.handles)!=null&&s.length)&&!!(t.measured.width||t.width||t.initialWidth)}function qj(t){var d;const{sourceNode:s,targetNode:n}=t;if(!no(s)||!no(n))return null;const a=s.internals.handleBounds||ao(s.handles),i=n.internals.handleBounds||ao(n.handles),r=io((a==null?void 0:a.source)??[],t.sourceHandle),o=io(t.connectionMode===$s.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),t.targetHandle);if(!r||!o)return(d=t.onError)==null||d.call(t,"008",yt.error008(r?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const l=(r==null?void 0:r.position)||he.Bottom,c=(o==null?void 0:o.position)||he.Top,h=os(s,r,l),m=os(n,o,c);return{sourceX:h.x,sourceY:h.y,targetX:m.x,targetY:m.y,sourcePosition:l,targetPosition:c}}function ao(t){if(!t)return null;const s=[],n=[];for(const a of t)a.width=a.width??1,a.height=a.height??1,a.type==="source"?s.push(a):a.type==="target"&&n.push(a);return{source:s,target:n}}function os(t,s,n=he.Left,a=!1){const i=((s==null?void 0:s.x)??0)+t.internals.positionAbsolute.x,r=((s==null?void 0:s.y)??0)+t.internals.positionAbsolute.y,{width:o,height:l}=s??zt(t);if(a)return{x:i+o/2,y:r+l/2};switch((s==null?void 0:s.position)??n){case he.Top:return{x:i+o/2,y:r};case he.Right:return{x:i+o,y:r+l/2};case he.Bottom:return{x:i+o/2,y:r+l};case he.Left:return{x:i,y:r+l/2}}}function io(t,s){return t&&(s?t.find(n=>n.id===s):t[0])||null}function yi(t,s){return t?typeof t=="string"?t:`${s?`${s}__`:""}${Object.keys(t).sort().map(a=>`${a}=${t[a]}`).join("&")}`:""}function Wj(t,{id:s,defaultColor:n,defaultMarkerStart:a,defaultMarkerEnd:i}){const r=new Set;return t.reduce((o,l)=>([l.markerStart||a,l.markerEnd||i].forEach(c=>{if(c&&typeof c=="object"){const h=yi(c,s);r.has(h)||(o.push({id:h,color:c.color||n,...c}),r.add(h))}}),o),[]).sort((o,l)=>o.id.localeCompare(l.id))}const mc=1e3,Gj=10,Ki={nodeOrigin:[0,0],nodeExtent:ln,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Yj={...Ki,checkEquality:!0};function Zi(t,s){const n={...t};for(const a in s)s[a]!==void 0&&(n[a]=s[a]);return n}function Xj(t,s,n){const a=Zi(Ki,n);for(const i of t.values())if(i.parentId)Ji(i,t,s,a);else{const r=yn(i,a.nodeOrigin),o=rs(i.extent)?i.extent:a.nodeExtent,l=is(r,o,zt(i));i.internals.positionAbsolute=l}}function Kj(t,s){if(!t.handles)return t.measured?s==null?void 0:s.internals.handleBounds:void 0;const n=[],a=[];for(const i of t.handles){const r={id:i.id,width:i.width??1,height:i.height??1,nodeId:t.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(r):i.type==="target"&&a.push(r)}return{source:n,target:a}}function Qi(t){return t==="manual"}function vi(t,s,n,a={}){var m,d;const i=Zi(Yj,a),r={i:0},o=new Map(s),l=i!=null&&i.elevateNodesOnSelect&&!Qi(i.zIndexMode)?mc:0;let c=t.length>0,h=!1;s.clear(),n.clear();for(const u of t){let p=o.get(u.id);if(i.checkEquality&&u===(p==null?void 0:p.internals.userNode))s.set(u.id,p);else{const x=yn(u,i.nodeOrigin),v=rs(u.extent)?u.extent:i.nodeExtent,j=is(x,v,zt(u));p={...i.defaults,...u,measured:{width:(m=u.measured)==null?void 0:m.width,height:(d=u.measured)==null?void 0:d.height},internals:{positionAbsolute:j,handleBounds:Kj(u,p),z:fc(u,l,i.zIndexMode),userNode:u}},s.set(u.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),u.parentId&&Ji(p,s,n,a,r),h||(h=u.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:h}}function Zj(t,s){if(!t.parentId)return;const n=s.get(t.parentId);n?n.set(t.id,t):s.set(t.parentId,new Map([[t.id,t]]))}function Ji(t,s,n,a,i){const{elevateNodesOnSelect:r,nodeOrigin:o,nodeExtent:l,zIndexMode:c}=Zi(Ki,a),h=t.parentId,m=s.get(h);if(!m){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Zj(t,n),i&&!m.parentId&&m.internals.rootParentIndex===void 0&&c==="auto"&&(m.internals.rootParentIndex=++i.i,m.internals.z=m.internals.z+i.i*Gj),i&&m.internals.rootParentIndex!==void 0&&(i.i=m.internals.rootParentIndex);const d=r&&!Qi(c)?mc:0,{x:u,y:p,z:x}=Qj(t,m,o,l,d,c),{positionAbsolute:v}=t.internals,j=u!==v.x||p!==v.y;(j||x!==t.internals.z)&&s.set(t.id,{...t,internals:{...t.internals,positionAbsolute:j?{x:u,y:p}:v,z:x}})}function fc(t,s,n){const a=mt(t.zIndex)?t.zIndex:0;return Qi(n)?a:a+(t.selected?s:0)}function Qj(t,s,n,a,i,r){const{x:o,y:l}=s.internals.positionAbsolute,c=zt(t),h=yn(t,n),m=rs(t.extent)?is(h,t.extent,c):h;let d=is({x:o+m.x,y:l+m.y},a,c);t.extent==="parent"&&(d=ec(d,c,s));const u=fc(t,i,r),p=s.internals.z??0;return{x:d.x,y:d.y,z:p>=u?p+1:u}}function er(t,s,n,a=[0,0]){var o;const i=[],r=new Map;for(const l of t){const c=s.get(l.parentId);if(!c)continue;const h=((o=r.get(l.parentId))==null?void 0:o.expandedRect)??dn(c),m=tc(h,l.rect);r.set(l.parentId,{expandedRect:m,parent:c})}return r.size>0&&r.forEach(({expandedRect:l,parent:c},h)=>{var y;const m=c.internals.positionAbsolute,d=zt(c),u=c.origin??a,p=l.x<m.x?Math.round(Math.abs(m.x-l.x)):0,x=l.y<m.y?Math.round(Math.abs(m.y-l.y)):0,v=Math.max(d.width,Math.round(l.width)),j=Math.max(d.height,Math.round(l.height)),g=(v-d.width)*u[0],b=(j-d.height)*u[1];(p>0||x>0||g||b)&&(i.push({id:h,type:"position",position:{x:c.position.x-p+g,y:c.position.y-x+b}}),(y=n.get(h))==null||y.forEach(w=>{t.some(S=>S.id===w.id)||i.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+x}})})),(d.width<l.width||d.height<l.height||p||x)&&i.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:v+(p?u[0]*p-g:0),height:j+(x?u[1]*x-b:0)}})}),i}function Jj(t,s,n,a,i,r,o){const l=a==null?void 0:a.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const h=[],m=window.getComputedStyle(l),{m22:d}=new window.DOMMatrixReadOnly(m.transform),u=[];for(const p of t.values()){const x=s.get(p.id);if(!x)continue;if(x.hidden){s.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),c=!0;continue}const v=Xi(p.nodeElement),j=x.measured.width!==v.width||x.measured.height!==v.height;if(!!(v.width&&v.height&&(j||!x.internals.handleBounds||p.force))){const b=p.nodeElement.getBoundingClientRect(),y=rs(x.extent)?x.extent:r;let{positionAbsolute:w}=x.internals;if(x.parentId&&x.extent==="parent"){const $=s.get(x.parentId);$&&(w=ec(w,v,$))}else y&&(w=is(w,y,v));const S={...x,measured:v,internals:{...x.internals,positionAbsolute:w,handleBounds:{source:Jr("source",p.nodeElement,b,d,x.id),target:Jr("target",p.nodeElement,b,d,x.id)}}};s.set(x.id,S),x.parentId&&Ji(S,s,n,{nodeOrigin:i,zIndexMode:o}),c=!0,j&&(h.push({id:x.id,type:"dimensions",dimensions:v}),x.expandParent&&x.parentId&&u.push({id:x.id,parentId:x.parentId,rect:dn(S,i)}))}}if(u.length>0){const p=er(u,s,n,i);h.push(...p)}return{changes:h,updatedInternals:c}}async function eb({delta:t,panZoom:s,transform:n,translateExtent:a,width:i,height:r}){if(!s||!t.x&&!t.y)return!1;const o=await s.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[i,r]],a);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function ro(t,s,n,a,i,r){let o=i;const l=a.get(o)||new Map;a.set(o,l.set(n,s)),o=`${i}-${t}`;const c=a.get(o)||new Map;if(a.set(o,c.set(n,s)),r){o=`${i}-${t}-${r}`;const h=a.get(o)||new Map;a.set(o,h.set(n,s))}}function pc(t,s,n){t.clear(),s.clear();for(const a of n){const{source:i,target:r,sourceHandle:o=null,targetHandle:l=null}=a,c={edgeId:a.id,source:i,target:r,sourceHandle:o,targetHandle:l},h=`${i}-${o}--${r}-${l}`,m=`${r}-${l}--${i}-${o}`;ro("source",c,m,t,i,o),ro("target",c,h,t,r,l),s.set(a.id,a)}}function xc(t,s){if(!t.parentId)return!1;const n=s.get(t.parentId);return n?n.selected?!0:xc(n,s):!1}function oo(t,s,n){var i;let a=t;do{if((i=a==null?void 0:a.matches)!=null&&i.call(a,s))return!0;if(a===n)return!1;a=a==null?void 0:a.parentElement}while(a);return!1}function tb(t,s,n,a){const i=new Map;for(const[r,o]of t)if((o.selected||o.id===a)&&(!o.parentId||!xc(o,t))&&(o.draggable||s&&typeof o.draggable>"u")){const l=t.get(r);l&&i.set(r,{id:r,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return i}function Ga({nodeId:t,dragItems:s,nodeLookup:n,dragging:a=!0}){var o,l,c;const i=[];for(const[h,m]of s){const d=(o=n.get(h))==null?void 0:o.internals.userNode;d&&i.push({...d,position:m.position,dragging:a})}if(!t)return[i[0],i];const r=(l=n.get(t))==null?void 0:l.internals.userNode;return[r?{...r,position:((c=s.get(t))==null?void 0:c.position)||r.position,dragging:a}:i[0],i]}function sb({dragItems:t,snapGrid:s,x:n,y:a}){const i=t.values().next().value;if(!i)return null;const r={x:n-i.distance.x,y:a-i.distance.y},o=jn(r,s);return{x:o.x-r.x,y:o.y-r.y}}function nb({onNodeMouseDown:t,getStoreItems:s,onDragStart:n,onDrag:a,onDragStop:i}){let r={x:null,y:null},o=0,l=new Map,c=!1,h={x:0,y:0},m=null,d=!1,u=null,p=!1,x=!1,v=null;function j({noDragClassName:b,handleSelector:y,domNode:w,isSelectable:S,nodeId:$,nodeClickDistance:M=0}){u=at(w);function z({x:_,y:L}){const{nodeLookup:N,nodeExtent:T,snapGrid:I,snapToGrid:R,nodeOrigin:B,onNodeDrag:E,onSelectionDrag:P,onError:W,updateNodePositions:V}=s();r={x:_,y:L};let K=!1;const D=l.size>1,G=D&&T?xi(vn(l)):null,ee=D&&R?sb({dragItems:l,snapGrid:I,x:_,y:L}):null;for(const[te,F]of l){if(!N.has(te))continue;let Y={x:_-F.distance.x,y:L-F.distance.y};R&&(Y=ee?{x:Math.round(Y.x+ee.x),y:Math.round(Y.y+ee.y)}:jn(Y,I));let Q=null;if(D&&T&&!F.extent&&G){const{positionAbsolute:O}=F.internals,X=O.x-G.x+T[0][0],Z=O.x+F.measured.width-G.x2+T[1][0],J=O.y-G.y+T[0][1],le=O.y+F.measured.height-G.y2+T[1][1];Q=[[X,J],[Z,le]]}const{position:ie,positionAbsolute:ae}=Jl({nodeId:te,nextPosition:Y,nodeLookup:N,nodeExtent:Q||T,nodeOrigin:B,onError:W});K=K||F.position.x!==ie.x||F.position.y!==ie.y,F.position=ie,F.internals.positionAbsolute=ae}if(x=x||K,!!K&&(V(l,!0),v&&(a||E||!$&&P))){const[te,F]=Ga({nodeId:$,dragItems:l,nodeLookup:N});a==null||a(v,l,te,F),E==null||E(v,te,F),$||P==null||P(v,F)}}async function A(){if(!m)return;const{transform:_,panBy:L,autoPanSpeed:N,autoPanOnNodeDrag:T}=s();if(!T){c=!1,cancelAnimationFrame(o);return}const[I,R]=Gi(h,m,N);(I!==0||R!==0)&&(r.x=(r.x??0)-I/_[2],r.y=(r.y??0)-R/_[2],await L({x:I,y:R})&&z(r)),o=requestAnimationFrame(A)}function k(_){var D;const{nodeLookup:L,multiSelectionActive:N,nodesDraggable:T,transform:I,snapGrid:R,snapToGrid:B,selectNodesOnDrag:E,onNodeDragStart:P,onSelectionDragStart:W,unselectNodesAndEdges:V}=s();d=!0,(!E||!S)&&!N&&$&&((D=L.get($))!=null&&D.selected||V()),S&&E&&$&&(t==null||t($));const K=Ks(_.sourceEvent,{transform:I,snapGrid:R,snapToGrid:B,containerBounds:m});if(r=K,l=tb(L,T,K,$),l.size>0&&(n||P||!$&&W)){const[G,ee]=Ga({nodeId:$,dragItems:l,nodeLookup:L});n==null||n(_.sourceEvent,l,G,ee),P==null||P(_.sourceEvent,G,ee),$||W==null||W(_.sourceEvent,ee)}}const C=Tl().clickDistance(M).on("start",_=>{const{domNode:L,nodeDragThreshold:N,transform:T,snapGrid:I,snapToGrid:R}=s();m=(L==null?void 0:L.getBoundingClientRect())||null,p=!1,x=!1,v=_.sourceEvent,N===0&&k(_),r=Ks(_.sourceEvent,{transform:T,snapGrid:I,snapToGrid:R,containerBounds:m}),h=ft(_.sourceEvent,m)}).on("drag",_=>{const{autoPanOnNodeDrag:L,transform:N,snapGrid:T,snapToGrid:I,nodeDragThreshold:R,nodeLookup:B}=s(),E=Ks(_.sourceEvent,{transform:N,snapGrid:T,snapToGrid:I,containerBounds:m});if(v=_.sourceEvent,(_.sourceEvent.type==="touchmove"&&_.sourceEvent.touches.length>1||$&&!B.has($))&&(p=!0),!p){if(!c&&L&&d&&(c=!0,A()),!d){const P=ft(_.sourceEvent,m),W=P.x-h.x,V=P.y-h.y;Math.sqrt(W*W+V*V)>R&&k(_)}(r.x!==E.xSnapped||r.y!==E.ySnapped)&&l&&d&&(h=ft(_.sourceEvent,m),z(E))}}).on("end",_=>{if(!d||p){p&&l.size>0&&s().updateNodePositions(l,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),l.size>0){const{nodeLookup:L,updateNodePositions:N,onNodeDragStop:T,onSelectionDragStop:I}=s();if(x&&(N(l,!1),x=!1),i||T||!$&&I){const[R,B]=Ga({nodeId:$,dragItems:l,nodeLookup:L,dragging:!1});i==null||i(_.sourceEvent,l,R,B),T==null||T(_.sourceEvent,R,B),$||I==null||I(_.sourceEvent,B)}}}).filter(_=>{const L=_.target;return!_.button&&(!b||!oo(L,`.${b}`,w))&&(!y||oo(L,y,w))});u.call(C)}function g(){u==null||u.on(".drag",null)}return{update:j,destroy:g}}function ab(t,s,n){const a=[],i={x:t.x-n,y:t.y-n,width:n*2,height:n*2};for(const r of s.values())la(i,dn(r))>0&&a.push(r);return a}const ib=250;function rb(t,s,n,a){var l,c;let i=[],r=1/0;const o=ab(t,n,s+ib);for(const h of o){const m=[...((l=h.internals.handleBounds)==null?void 0:l.source)??[],...((c=h.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of m){if(a.nodeId===d.nodeId&&a.type===d.type&&a.id===d.id)continue;const{x:u,y:p}=os(h,d,d.position,!0),x=Math.sqrt(Math.pow(u-t.x,2)+Math.pow(p-t.y,2));x>s||(x<r?(i=[{...d,x:u,y:p}],r=x):x===r&&i.push({...d,x:u,y:p}))}}if(!i.length)return null;if(i.length>1){const h=a.type==="source"?"target":"source";return i.find(m=>m.type===h)??i[0]}return i[0]}function gc(t,s,n,a,i,r=!1){var h,m,d;const o=a.get(t);if(!o)return null;const l=i==="strict"?(h=o.internals.handleBounds)==null?void 0:h[s]:[...((m=o.internals.handleBounds)==null?void 0:m.source)??[],...((d=o.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?l==null?void 0:l.find(u=>u.id===n):l==null?void 0:l[0])??null;return c&&r?{...c,...os(o,c,c.position,!0)}:c}function yc(t,s){return t||(s!=null&&s.classList.contains("target")?"target":s!=null&&s.classList.contains("source")?"source":null)}function ob(t,s){let n=null;return s?n=!0:t&&!s&&(n=!1),n}const vc=()=>!0;function lb(t,{connectionMode:s,connectionRadius:n,handleId:a,nodeId:i,edgeUpdaterType:r,isTarget:o,domNode:l,nodeLookup:c,lib:h,autoPanOnConnect:m,flowId:d,panBy:u,cancelConnection:p,onConnectStart:x,onConnect:v,onConnectEnd:j,isValidConnection:g=vc,onReconnectEnd:b,updateConnection:y,getTransform:w,getFromHandle:S,autoPanSpeed:$,dragThreshold:M=1,handleDomNode:z}){const A=rc(t.target);let k=0,C;const{x:_,y:L}=ft(t),N=yc(r,z),T=l==null?void 0:l.getBoundingClientRect();let I=!1;if(!T||!N)return;const R=gc(i,N,a,c,s);if(!R)return;let B=ft(t,T),E=!1,P=null,W=!1,V=null;function K(){if(!m||!T)return;const[ie,ae]=Gi(B,T,$);u({x:ie,y:ae}),k=requestAnimationFrame(K)}const D={...R,nodeId:i,type:N,position:R.position},G=c.get(i);let te={inProgress:!0,isValid:null,from:os(G,D,he.Left,!0),fromHandle:D,fromPosition:D.position,fromNode:G,to:B,toHandle:null,toPosition:Xr[D.position],toNode:null,pointer:B};function F(){I=!0,y(te),x==null||x(t,{nodeId:i,handleId:a,handleType:N})}M===0&&F();function Y(ie){if(!I){const{x:le,y:ce}=ft(ie),me=le-_,be=ce-L;if(!(me*me+be*be>M*M))return;F()}if(!S()||!D){Q(ie);return}const ae=w();B=ft(ie,T),C=rb(bn(B,ae,!1,[1,1]),n,c,D),E||(K(),E=!0);const O=jc(ie,{handle:C,connectionMode:s,fromNodeId:i,fromHandleId:a,fromType:o?"target":"source",isValidConnection:g,doc:A,lib:h,flowId:d,nodeLookup:c});V=O.handleDomNode,P=O.connection,W=ob(!!C,O.isValid);const X=c.get(i),Z=X?os(X,D,he.Left,!0):te.from,J={...te,from:Z,isValid:W,to:O.toHandle&&W?_s({x:O.toHandle.x,y:O.toHandle.y},ae):B,toHandle:O.toHandle,toPosition:W&&O.toHandle?O.toHandle.position:Xr[D.position],toNode:O.toHandle?c.get(O.toHandle.nodeId):null,pointer:B};y(J),te=J}function Q(ie){if(!("touches"in ie&&ie.touches.length>0)){if(I){(C||V)&&P&&W&&(v==null||v(P));const{inProgress:ae,...O}=te,X={...O,toPosition:te.toHandle?te.toPosition:null};j==null||j(ie,X),r&&(b==null||b(ie,X))}p(),cancelAnimationFrame(k),E=!1,W=!1,P=null,V=null,A.removeEventListener("mousemove",Y),A.removeEventListener("mouseup",Q),A.removeEventListener("touchmove",Y),A.removeEventListener("touchend",Q)}}A.addEventListener("mousemove",Y),A.addEventListener("mouseup",Q),A.addEventListener("touchmove",Y),A.addEventListener("touchend",Q)}function jc(t,{handle:s,connectionMode:n,fromNodeId:a,fromHandleId:i,fromType:r,doc:o,lib:l,flowId:c,isValidConnection:h=vc,nodeLookup:m}){const d=r==="target",u=s?o.querySelector(`.${l}-flow__handle[data-id="${c}-${s==null?void 0:s.nodeId}-${s==null?void 0:s.id}-${s==null?void 0:s.type}"]`):null,{x:p,y:x}=ft(t),v=o.elementFromPoint(p,x),j=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:u,g={handleDomNode:j,isValid:!1,connection:null,toHandle:null};if(j){const b=yc(void 0,j),y=j.getAttribute("data-nodeid"),w=j.getAttribute("data-handleid"),S=j.classList.contains("connectable"),$=j.classList.contains("connectableend");if(!y||!b)return g;const M={source:d?y:a,sourceHandle:d?w:i,target:d?a:y,targetHandle:d?i:w};g.connection=M;const A=S&&$&&(n===$s.Strict?d&&b==="source"||!d&&b==="target":y!==a||w!==i);g.isValid=A&&h(M),g.toHandle=gc(y,b,w,m,n,!0)}return g}const ji={onPointerDown:lb,isValid:jc};function cb({domNode:t,panZoom:s,getTransform:n,getViewScale:a}){const i=at(t);function r({translateExtent:l,width:c,height:h,zoomStep:m=1,pannable:d=!0,zoomable:u=!0,inversePan:p=!1}){const x=y=>{if(y.sourceEvent.type!=="wheel"||!s)return;const w=n(),S=y.sourceEvent.ctrlKey&&un()?10:1,$=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*m,M=w[2]*Math.pow(2,$*S);s.scaleTo(M)};let v=[0,0];const j=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(v=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},g=y=>{const w=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!s)return;const S=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],$=[S[0]-v[0],S[1]-v[1]];v=S;const M=a()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),z={x:w[0]-$[0]*M,y:w[1]-$[1]*M},A=[[0,0],[c,h]];s.setViewportConstrained({x:z.x,y:z.y,zoom:w[2]},A,l)},b=Gl().on("start",j).on("zoom",d?g:null).on("zoom.wheel",u?x:null);i.call(b,{})}function o(){i.on("zoom",null)}return{update:r,destroy:o,pointer:dt}}const ba=t=>({x:t.x,y:t.y,zoom:t.k}),Ya=({x:t,y:s,zoom:n})=>ya.translate(t,s).scale(n),xs=(t,s)=>t.target.closest(`.${s}`),bc=(t,s)=>s===2&&Array.isArray(t)&&t.includes(2),db=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Xa=(t,s=0,n=db,a=()=>{})=>{const i=typeof s=="number"&&s>0;return i||a(),i?t.transition().duration(s).ease(n).on("end",a):t},wc=t=>{const s=t.ctrlKey&&un()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*s};function ub({zoomPanValues:t,noWheelClassName:s,d3Selection:n,d3Zoom:a,panOnScrollMode:i,panOnScrollSpeed:r,zoomOnPinch:o,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:h}){return m=>{if(xs(m,s))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(m.ctrlKey&&o){const j=dt(m),g=wc(m),b=d*Math.pow(2,g);a.scaleTo(n,b,j,m);return}const u=m.deltaMode===1?20:1;let p=i===Zt.Vertical?0:m.deltaX*u,x=i===Zt.Horizontal?0:m.deltaY*u;!un()&&m.shiftKey&&i!==Zt.Vertical&&(p=m.deltaY*u,x=0),a.translateBy(n,-(p/d)*r,-(x/d)*r,{internal:!0});const v=ba(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?c==null||c(m,v):(t.isPanScrolling=!0,l==null||l(m,v)),t.panScrollTimeout=setTimeout(()=>{h==null||h(m,v),t.isPanScrolling=!1},150)}}function hb({noWheelClassName:t,preventScrolling:s,d3ZoomHandler:n}){return function(a,i){const r=a.type==="wheel",o=!s&&r&&!a.ctrlKey,l=xs(a,t);if(a.ctrlKey&&r&&l&&a.preventDefault(),o||l)return null;a.preventDefault(),n.call(this,a,i)}}function mb({zoomPanValues:t,onDraggingChange:s,onPanZoomStart:n}){return a=>{var r,o,l;if((r=a.sourceEvent)!=null&&r.internal)return;const i=ba(a.transform);t.mouseButton=((o=a.sourceEvent)==null?void 0:o.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=i,((l=a.sourceEvent)==null?void 0:l.type)==="mousedown"&&s(!0),n&&(n==null||n(a.sourceEvent,i))}}function fb({zoomPanValues:t,panOnDrag:s,onPaneContextMenu:n,onTransformChange:a,onPanZoom:i}){return r=>{var o,l;t.usedRightMouseButton=!!(n&&bc(s,t.mouseButton??0)),(o=r.sourceEvent)!=null&&o.sync||a([r.transform.x,r.transform.y,r.transform.k]),i&&!((l=r.sourceEvent)!=null&&l.internal)&&(i==null||i(r.sourceEvent,ba(r.transform)))}}function pb({zoomPanValues:t,panOnDrag:s,panOnScroll:n,onDraggingChange:a,onPanZoomEnd:i,onPaneContextMenu:r}){return o=>{var l;if(!((l=o.sourceEvent)!=null&&l.internal)&&(t.isZoomingOrPanning=!1,r&&bc(s,t.mouseButton??0)&&!t.usedRightMouseButton&&o.sourceEvent&&r(o.sourceEvent),t.usedRightMouseButton=!1,a(!1),i)){const c=ba(o.transform);t.prevViewport=c,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{i==null||i(o.sourceEvent,c)},n?150:0)}}}function xb({zoomActivationKeyPressed:t,zoomOnScroll:s,zoomOnPinch:n,panOnDrag:a,panOnScroll:i,zoomOnDoubleClick:r,userSelectionActive:o,noWheelClassName:l,noPanClassName:c,lib:h,connectionInProgress:m}){return d=>{var j;const u=t||s,p=n&&d.ctrlKey,x=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(xs(d,`${h}-flow__node`)||xs(d,`${h}-flow__edge`)))return!0;if(!a&&!u&&!i&&!r&&!n||o||m&&!x||xs(d,l)&&x||xs(d,c)&&(!x||i&&x&&!t)||!n&&d.ctrlKey&&x)return!1;if(!n&&d.type==="touchstart"&&((j=d.touches)==null?void 0:j.length)>1)return d.preventDefault(),!1;if(!u&&!i&&!p&&x||!a&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(a)&&!a.includes(d.button)&&d.type==="mousedown")return!1;const v=Array.isArray(a)&&a.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||x)&&v}}function gb({domNode:t,minZoom:s,maxZoom:n,translateExtent:a,viewport:i,onPanZoom:r,onPanZoomStart:o,onPanZoomEnd:l,onDraggingChange:c}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=t.getBoundingClientRect();let d=[[0,0],[m.width,m.height]];const u=typeof ResizeObserver<"u"?new ResizeObserver(L=>{const N=L[0];N&&(d=[[0,0],[N.contentRect.width,N.contentRect.height]])}):null;u==null||u.observe(t);const p=Gl().extent(()=>d).scaleExtent([s,n]).translateExtent(a),x=at(t).call(p);w({x:i.x,y:i.y,zoom:Es(i.zoom,s,n)},[[0,0],[m.width,m.height]],a);const v=x.on("wheel.zoom"),j=x.on("dblclick.zoom");p.wheelDelta(wc);async function g(L,N){return x?new Promise(T=>{p==null||p.interpolate((N==null?void 0:N.interpolate)==="linear"?Xs:Un).transform(Xa(x,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>T(!0)),L)}):!1}function b({noWheelClassName:L,noPanClassName:N,onPaneContextMenu:T,userSelectionActive:I,panOnScroll:R,panOnDrag:B,panOnScrollMode:E,panOnScrollSpeed:P,preventScrolling:W,zoomOnPinch:V,zoomOnScroll:K,zoomOnDoubleClick:D,zoomActivationKeyPressed:G,lib:ee,onTransformChange:te,connectionInProgress:F,paneClickDistance:Y,selectionOnDrag:Q}){I&&!h.isZoomingOrPanning&&y();const ie=R&&!G&&!I;p.clickDistance(Q?1/0:!mt(Y)||Y<0?0:Y);const ae=ie?ub({zoomPanValues:h,noWheelClassName:L,d3Selection:x,d3Zoom:p,panOnScrollMode:E,panOnScrollSpeed:P,zoomOnPinch:V,onPanZoomStart:o,onPanZoom:r,onPanZoomEnd:l}):hb({noWheelClassName:L,preventScrolling:W,d3ZoomHandler:v});x.on("wheel.zoom",ae,{passive:!1});const O=mb({zoomPanValues:h,onDraggingChange:c,onPanZoomStart:o});p.on("start",O);const X=fb({zoomPanValues:h,panOnDrag:B,onPaneContextMenu:!!T,onPanZoom:r,onTransformChange:te});p.on("zoom",X);const Z=pb({zoomPanValues:h,panOnDrag:B,panOnScroll:R,onPaneContextMenu:T,onPanZoomEnd:l,onDraggingChange:c});p.on("end",Z);const J=xb({zoomActivationKeyPressed:G,panOnDrag:B,zoomOnScroll:K,panOnScroll:R,zoomOnDoubleClick:D,zoomOnPinch:V,userSelectionActive:I,noPanClassName:N,noWheelClassName:L,lib:ee,connectionInProgress:F});p.filter(J),D?x.on("dblclick.zoom",j):x.on("dblclick.zoom",null)}function y(){p.on("zoom",null)}async function w(L,N,T){const I=Ya(L),R=p==null?void 0:p.constrain()(I,N,T);return R&&await g(R),R}async function S(L,N){const T=Ya(L);return await g(T,N),T}function $(L){if(x){const N=Ya(L),T=x.property("__zoom");(T.k!==L.zoom||T.x!==L.x||T.y!==L.y)&&(p==null||p.transform(x,N,null,{sync:!0}))}}function M(){const L=x?Wl(x.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}async function z(L,N){return x?new Promise(T=>{p==null||p.interpolate((N==null?void 0:N.interpolate)==="linear"?Xs:Un).scaleTo(Xa(x,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>T(!0)),L)}):!1}async function A(L,N){return x?new Promise(T=>{p==null||p.interpolate((N==null?void 0:N.interpolate)==="linear"?Xs:Un).scaleBy(Xa(x,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>T(!0)),L)}):!1}function k(L){p==null||p.scaleExtent(L)}function C(L){p==null||p.translateExtent(L)}function _(L){const N=!mt(L)||L<0?0:L;p==null||p.clickDistance(N)}return{update:b,destroy:y,setViewport:S,setViewportConstrained:w,getViewport:M,scaleTo:z,scaleBy:A,setScaleExtent:k,setTranslateExtent:C,syncViewport:$,setClickDistance:_}}var Ts;(function(t){t.Line="line",t.Handle="handle"})(Ts||(Ts={}));function yb({width:t,prevWidth:s,height:n,prevHeight:a,affectsX:i,affectsY:r}){const o=t-s,l=n-a,c=[o>0?1:o<0?-1:0,l>0?1:l<0?-1:0];return o&&i&&(c[0]=c[0]*-1),l&&r&&(c[1]=c[1]*-1),c}function lo(t){const s=t.includes("right")||t.includes("left"),n=t.includes("bottom")||t.includes("top"),a=t.includes("left"),i=t.includes("top");return{isHorizontal:s,isVertical:n,affectsX:a,affectsY:i}}function Pt(t,s){return Math.max(0,s-t)}function Dt(t,s){return Math.max(0,t-s)}function Ln(t,s,n){return Math.max(0,s-t,t-n)}function co(t,s){return t?!s:s}function vb(t,s,n,a,i,r,o,l){let{affectsX:c,affectsY:h}=s;const{isHorizontal:m,isVertical:d}=s,u=m&&d,{xSnapped:p,ySnapped:x}=n,{minWidth:v,maxWidth:j,minHeight:g,maxHeight:b}=a,{x:y,y:w,width:S,height:$,aspectRatio:M}=t;let z=Math.floor(m?p-t.pointerX:0),A=Math.floor(d?x-t.pointerY:0);const k=S+(c?-z:z),C=$+(h?-A:A),_=-r[0]*S,L=-r[1]*$;let N=Ln(k,v,j),T=Ln(C,g,b);if(o){let B=0,E=0;c&&z<0?B=Pt(y+z+_,o[0][0]):!c&&z>0&&(B=Dt(y+k+_,o[1][0])),h&&A<0?E=Pt(w+A+L,o[0][1]):!h&&A>0&&(E=Dt(w+C+L,o[1][1])),N=Math.max(N,B),T=Math.max(T,E)}if(l){let B=0,E=0;c&&z>0?B=Dt(y+z,l[0][0]):!c&&z<0&&(B=Pt(y+k,l[1][0])),h&&A>0?E=Dt(w+A,l[0][1]):!h&&A<0&&(E=Pt(w+C,l[1][1])),N=Math.max(N,B),T=Math.max(T,E)}if(i){if(m){const B=Ln(k/M,g,b)*M;if(N=Math.max(N,B),o){let E=0;!c&&!h||c&&!h&&u?E=Dt(w+L+k/M,o[1][1])*M:E=Pt(w+L+(c?z:-z)/M,o[0][1])*M,N=Math.max(N,E)}if(l){let E=0;!c&&!h||c&&!h&&u?E=Pt(w+k/M,l[1][1])*M:E=Dt(w+(c?z:-z)/M,l[0][1])*M,N=Math.max(N,E)}}if(d){const B=Ln(C*M,v,j)/M;if(T=Math.max(T,B),o){let E=0;!c&&!h||h&&!c&&u?E=Dt(y+C*M+_,o[1][0])/M:E=Pt(y+(h?A:-A)*M+_,o[0][0])/M,T=Math.max(T,E)}if(l){let E=0;!c&&!h||h&&!c&&u?E=Pt(y+C*M,l[1][0])/M:E=Dt(y+(h?A:-A)*M,l[0][0])/M,T=Math.max(T,E)}}}A=A+(A<0?T:-T),z=z+(z<0?N:-N),i&&(u?k>C*M?A=(co(c,h)?-z:z)/M:z=(co(c,h)?-A:A)*M:m?(A=z/M,h=c):(z=A*M,c=h));const I=c?y+z:y,R=h?w+A:w;return{width:S+(c?-z:z),height:$+(h?-A:A),x:r[0]*z*(c?-1:1)+I,y:r[1]*A*(h?-1:1)+R}}const kc={width:0,height:0,x:0,y:0},jb={...kc,pointerX:0,pointerY:0,aspectRatio:1};function bb(t,s,n){const a=s.position.x+t.position.x,i=s.position.y+t.position.y,r=t.measured.width??0,o=t.measured.height??0,l=n[0]*r,c=n[1]*o;return[[a-l,i-c],[a+r-l,i+o-c]]}function wb({domNode:t,nodeId:s,getStoreItems:n,onChange:a,onEnd:i}){const r=at(t);let o={controlDirection:lo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:h,boundaries:m,keepAspectRatio:d,resizeDirection:u,onResizeStart:p,onResize:x,onResizeEnd:v,shouldResize:j}){let g={...kc},b={...jb};o={boundaries:m,resizeDirection:u,keepAspectRatio:d,controlDirection:lo(h)};let y,w=null,S=[],$,M,z,A=!1;const k=Tl().on("start",C=>{const{nodeLookup:_,transform:L,snapGrid:N,snapToGrid:T,nodeOrigin:I,paneDomNode:R}=n();if(y=_.get(s),!y)return;w=(R==null?void 0:R.getBoundingClientRect())??null;const{xSnapped:B,ySnapped:E}=Ks(C.sourceEvent,{transform:L,snapGrid:N,snapToGrid:T,containerBounds:w});g={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},b={...g,pointerX:B,pointerY:E,aspectRatio:g.width/g.height},$=void 0,M=rs(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&($=_.get(y.parentId)),$&&y.extent==="parent"&&(M=[[0,0],[$.measured.width,$.measured.height]]),S=[],z=void 0;for(const[P,W]of _)if(W.parentId===s&&(S.push({id:P,position:{...W.position},extent:W.extent}),W.extent==="parent"||W.expandParent)){const V=bb(W,y,W.origin??I);z?z=[[Math.min(V[0][0],z[0][0]),Math.min(V[0][1],z[0][1])],[Math.max(V[1][0],z[1][0]),Math.max(V[1][1],z[1][1])]]:z=V}p==null||p(C,{...g})}).on("drag",C=>{const{transform:_,snapGrid:L,snapToGrid:N,nodeOrigin:T}=n(),I=Ks(C.sourceEvent,{transform:_,snapGrid:L,snapToGrid:N,containerBounds:w}),R=[];if(!y)return;const{x:B,y:E,width:P,height:W}=g,V={},K=y.origin??T,{width:D,height:G,x:ee,y:te}=vb(b,o.controlDirection,I,o.boundaries,o.keepAspectRatio,K,M,z),F=D!==P,Y=G!==W,Q=ee!==B&&F,ie=te!==E&&Y;if(!Q&&!ie&&!F&&!Y)return;if((Q||ie||K[0]===1||K[1]===1)&&(V.x=Q?ee:g.x,V.y=ie?te:g.y,g.x=V.x,g.y=V.y,S.length>0)){const Z=ee-B,J=te-E;for(const le of S)le.position={x:le.position.x-Z+K[0]*(D-P),y:le.position.y-J+K[1]*(G-W)},R.push(le)}if((F||Y)&&(V.width=F&&(!o.resizeDirection||o.resizeDirection==="horizontal")?D:g.width,V.height=Y&&(!o.resizeDirection||o.resizeDirection==="vertical")?G:g.height,g.width=V.width,g.height=V.height),$&&y.expandParent){const Z=K[0]*(V.width??0);V.x&&V.x<Z&&(g.x=Z,b.x=b.x-(V.x-Z));const J=K[1]*(V.height??0);V.y&&V.y<J&&(g.y=J,b.y=b.y-(V.y-J))}const ae=yb({width:g.width,prevWidth:P,height:g.height,prevHeight:W,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),O={...g,direction:ae};(j==null?void 0:j(C,O))!==!1&&(A=!0,x==null||x(C,O),a(V,R))}).on("end",C=>{A&&(v==null||v(C,{...g}),i==null||i({...g}),A=!1)});r.call(k)}function c(){r.on(".drag",null)}return{update:l,destroy:c}}var Nc={exports:{}},Sc={},Cc={exports:{}},zc={};/**
|
|
409
|
-
* @license React
|
|
410
|
-
* use-sync-external-store-shim.production.js
|
|
411
|
-
*
|
|
412
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
413
|
-
*
|
|
414
|
-
* This source code is licensed under the MIT license found in the
|
|
415
|
-
* LICENSE file in the root directory of this source tree.
|
|
416
|
-
*/var As=f;function kb(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Nb=typeof Object.is=="function"?Object.is:kb,Sb=As.useState,Cb=As.useEffect,zb=As.useLayoutEffect,Mb=As.useDebugValue;function $b(t,s){var n=s(),a=Sb({inst:{value:n,getSnapshot:s}}),i=a[0].inst,r=a[1];return zb(function(){i.value=n,i.getSnapshot=s,Ka(i)&&r({inst:i})},[t,n,s]),Cb(function(){return Ka(i)&&r({inst:i}),t(function(){Ka(i)&&r({inst:i})})},[t]),Mb(n),n}function Ka(t){var s=t.getSnapshot;t=t.value;try{var n=s();return!Nb(t,n)}catch{return!0}}function Eb(t,s){return s()}var _b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Eb:$b;zc.useSyncExternalStore=As.useSyncExternalStore!==void 0?As.useSyncExternalStore:_b;Cc.exports=zc;var Tb=Cc.exports;/**
|
|
417
|
-
* @license React
|
|
418
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
419
|
-
*
|
|
420
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
421
|
-
*
|
|
422
|
-
* This source code is licensed under the MIT license found in the
|
|
423
|
-
* LICENSE file in the root directory of this source tree.
|
|
424
|
-
*/var wa=f,Ab=Tb;function Rb(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Ib=typeof Object.is=="function"?Object.is:Rb,Lb=Ab.useSyncExternalStore,Pb=wa.useRef,Db=wa.useEffect,Fb=wa.useMemo,Ob=wa.useDebugValue;Sc.useSyncExternalStoreWithSelector=function(t,s,n,a,i){var r=Pb(null);if(r.current===null){var o={hasValue:!1,value:null};r.current=o}else o=r.current;r=Fb(function(){function c(p){if(!h){if(h=!0,m=p,p=a(p),i!==void 0&&o.hasValue){var x=o.value;if(i(x,p))return d=x}return d=p}if(x=d,Ib(m,p))return x;var v=a(p);return i!==void 0&&i(x,v)?(m=p,x):(m=p,d=v)}var h=!1,m,d,u=n===void 0?null:n;return[function(){return c(s())},u===null?void 0:function(){return c(u())}]},[s,n,a,i]);var l=Lb(t,r[0],r[1]);return Db(function(){o.hasValue=!0,o.value=l},[l]),Ob(l),l};Nc.exports=Sc;var Bb=Nc.exports;const Hb=lu(Bb),Vb={},uo=t=>{let s;const n=new Set,a=(m,d)=>{const u=typeof m=="function"?m(s):m;if(!Object.is(u,s)){const p=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),n.forEach(x=>x(s,p))}},i=()=>s,c={setState:a,getState:i,getInitialState:()=>h,subscribe:m=>(n.add(m),()=>n.delete(m)),destroy:()=>{(Vb?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},h=s=t(a,i,c);return c},Ub=t=>t?uo(t):uo,{useDebugValue:qb}=rt,{useSyncExternalStoreWithSelector:Wb}=Hb,Gb=t=>t;function Mc(t,s=Gb,n){const a=Wb(t.subscribe,t.getState,t.getServerState||t.getInitialState,s,n);return qb(a),a}const ho=(t,s)=>{const n=Ub(t),a=(i,r=s)=>Mc(n,i,r);return Object.assign(a,n),a},Yb=(t,s)=>t?ho(t,s):ho;function ke(t,s){if(Object.is(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;if(t instanceof Map&&s instanceof Map){if(t.size!==s.size)return!1;for(const[a,i]of t)if(!Object.is(i,s.get(a)))return!1;return!0}if(t instanceof Set&&s instanceof Set){if(t.size!==s.size)return!1;for(const a of t)if(!s.has(a))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(s).length)return!1;for(const a of n)if(!Object.prototype.hasOwnProperty.call(s,a)||!Object.is(t[a],s[a]))return!1;return!0}const ka=f.createContext(null),Xb=ka.Provider,$c=yt.error001("react");function ge(t,s){const n=f.useContext(ka);if(n===null)throw new Error($c);return Mc(n,t,s)}function we(){const t=f.useContext(ka);if(t===null)throw new Error($c);return f.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const mo={display:"none"},Kb={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ec="react-flow__node-desc",_c="react-flow__edge-desc",Zb="react-flow__aria-live",Qb=t=>t.ariaLiveMessage,Jb=t=>t.ariaLabelConfig;function e0({rfId:t}){const s=ge(Qb);return e.jsx("div",{id:`${Zb}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:Kb,children:s})}function t0({rfId:t,disableKeyboardA11y:s}){const n=ge(Jb);return e.jsxs(e.Fragment,{children:[e.jsx("div",{id:`${Ec}-${t}`,style:mo,children:s?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),e.jsx("div",{id:`${_c}-${t}`,style:mo,children:n["edge.a11yDescription.default"]}),!s&&e.jsx(e0,{rfId:t})]})}const Na=f.forwardRef(({position:t="top-left",children:s,className:n,style:a,...i},r)=>{const o=`${t}`.split("-");return e.jsx("div",{className:$e(["react-flow__panel",n,...o]),style:a,ref:r,...i,children:s})});Na.displayName="Panel";const fo="https://reactflow.dev?utm_source=attribution";function s0({proOptions:t,position:s="bottom-right"}){return t!=null&&t.hideAttribution?null:e.jsx(Na,{position:s,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${fo}`,children:e.jsx("a",{href:fo,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const n0=t=>{const s=[],n=[];for(const[,a]of t.nodeLookup)a.selected&&s.push(a.internals.userNode);for(const[,a]of t.edgeLookup)a.selected&&n.push(a);return{selectedNodes:s,selectedEdges:n}},Pn=t=>t.id;function a0(t,s){return ke(t.selectedNodes.map(Pn),s.selectedNodes.map(Pn))&&ke(t.selectedEdges.map(Pn),s.selectedEdges.map(Pn))}function i0({onSelectionChange:t}){const s=we(),{selectedNodes:n,selectedEdges:a}=ge(n0,a0);return f.useEffect(()=>{const i={nodes:n,edges:a};t==null||t(i),s.getState().onSelectionChangeHandlers.forEach(r=>r(i))},[n,a,t]),null}const r0=t=>!!t.onSelectionChangeHandlers;function o0({onSelectionChange:t}){const s=ge(r0);return t||s?e.jsx(i0,{onSelectionChange:t}):null}const Tc=[0,0],l0={x:0,y:0,zoom:1},c0=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],po=[...c0,"rfId"],d0=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),xo={translateExtent:ln,nodeOrigin:Tc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function u0(t){const{setNodes:s,setEdges:n,setMinZoom:a,setMaxZoom:i,setTranslateExtent:r,setNodeExtent:o,reset:l,setDefaultNodesAndEdges:c}=ge(d0,ke),h=we();f.useEffect(()=>(c(t.defaultNodes,t.defaultEdges),()=>{m.current=xo,l()}),[]);const m=f.useRef(xo);return f.useEffect(()=>{for(const d of po){const u=t[d],p=m.current[d];u!==p&&(typeof t[d]>"u"||(d==="nodes"?s(u):d==="edges"?n(u):d==="minZoom"?a(u):d==="maxZoom"?i(u):d==="translateExtent"?r(u):d==="nodeExtent"?o(u):d==="ariaLabelConfig"?h.setState({ariaLabelConfig:Ij(u)}):d==="fitView"?h.setState({fitViewQueued:u}):d==="fitViewOptions"?h.setState({fitViewOptions:u}):h.setState({[d]:u})))}m.current=t},po.map(d=>t[d])),null}function go(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function h0(t){var a;const[s,n]=f.useState(t==="system"?null:t);return f.useEffect(()=>{if(t!=="system"){n(t);return}const i=go(),r=()=>n(i!=null&&i.matches?"dark":"light");return r(),i==null||i.addEventListener("change",r),()=>{i==null||i.removeEventListener("change",r)}},[t]),s!==null?s:(a=go())!=null&&a.matches?"dark":"light"}const yo=typeof document<"u"?document:null;function hn(t=null,s={target:yo,actInsideInputWithModifier:!0}){const[n,a]=f.useState(!1),i=f.useRef(!1),r=f.useRef(new Set([])),[o,l]=f.useMemo(()=>{if(t!==null){const h=(Array.isArray(t)?t:[t]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
425
|
-
`).replace(`
|
|
426
|
-
|
|
427
|
-
`,`
|
|
428
|
-
+`).split(`
|
|
429
|
-
`)),m=h.reduce((d,u)=>d.concat(...u),[]);return[h,m]}return[[],[]]},[t]);return f.useEffect(()=>{const c=(s==null?void 0:s.target)??yo,h=(s==null?void 0:s.actInsideInputWithModifier)??!0;if(t!==null){const m=p=>{var j,g;if(i.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!i.current||i.current&&!h)&&oc(p))return!1;const v=jo(p.code,l);if(r.current.add(p[v]),vo(o,r.current,!1)){const b=((g=(j=p.composedPath)==null?void 0:j.call(p))==null?void 0:g[0])||p.target,y=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";s.preventDefault!==!1&&(i.current||!y)&&p.preventDefault(),a(!0)}},d=p=>{const x=jo(p.code,l);vo(o,r.current,!0)?(a(!1),r.current.clear()):r.current.delete(p[x]),p.key==="Meta"&&r.current.clear(),i.current=!1},u=()=>{r.current.clear(),a(!1)};return c==null||c.addEventListener("keydown",m),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",u),window.addEventListener("contextmenu",u),()=>{c==null||c.removeEventListener("keydown",m),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",u),window.removeEventListener("contextmenu",u)}}},[t,a]),n}function vo(t,s,n){return t.filter(a=>n||a.length===s.size).some(a=>a.every(i=>s.has(i)))}function jo(t,s){return s.includes(t)?"code":"key"}const m0=()=>{const t=we();return f.useMemo(()=>({zoomIn:async s=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1.2,s):!1},zoomOut:async s=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1/1.2,s):!1},zoomTo:async(s,n)=>{const{panZoom:a}=t.getState();return a?a.scaleTo(s,n):!1},getZoom:()=>t.getState().transform[2],setViewport:async(s,n)=>{const{transform:[a,i,r],panZoom:o}=t.getState();return o?(await o.setViewport({x:s.x??a,y:s.y??i,zoom:s.zoom??r},n),!0):!1},getViewport:()=>{const[s,n,a]=t.getState().transform;return{x:s,y:n,zoom:a}},setCenter:async(s,n,a)=>t.getState().setCenter(s,n,a),fitBounds:async(s,n)=>{const{width:a,height:i,minZoom:r,maxZoom:o,panZoom:l}=t.getState(),c=Yi(s,a,i,r,o,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(s,n={})=>{const{transform:a,snapGrid:i,snapToGrid:r,domNode:o}=t.getState();if(!o)return s;const{x:l,y:c}=o.getBoundingClientRect(),h={x:s.x-l,y:s.y-c},m=n.snapGrid??i,d=n.snapToGrid??r;return bn(h,a,d,m)},flowToScreenPosition:s=>{const{transform:n,domNode:a}=t.getState();if(!a)return s;const{x:i,y:r}=a.getBoundingClientRect(),o=_s(s,n);return{x:o.x+i,y:o.y+r}}}),[])};function Ac(t,s){const n=[],a=new Map,i=[];for(const r of t)if(r.type==="add"){i.push(r);continue}else if(r.type==="remove"||r.type==="replace")a.set(r.id,[r]);else{const o=a.get(r.id);o?o.push(r):a.set(r.id,[r])}for(const r of s){const o=a.get(r.id);if(!o){n.push(r);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const l={...r};for(const c of o)f0(c,l);n.push(l)}return i.length&&i.forEach(r=>{r.index!==void 0?n.splice(r.index,0,{...r.item}):n.push({...r.item})}),n}function f0(t,s){switch(t.type){case"select":{s.selected=t.selected;break}case"position":{typeof t.position<"u"&&(s.position=t.position),typeof t.dragging<"u"&&(s.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(s.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(s.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(s.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(s.resizing=t.resizing);break}}}function p0(t,s){return Ac(t,s)}function x0(t,s){return Ac(t,s)}function Gt(t,s){return{id:t,type:"select",selected:s}}function gs(t,s=new Set,n=!1){const a=[];for(const[i,r]of t){const o=s.has(i);!(r.selected===void 0&&!o)&&r.selected!==o&&(n&&(r.selected=o),a.push(Gt(r.id,o)))}return a}function bo({items:t=[],lookup:s}){var i;const n=[],a=new Map(t.map(r=>[r.id,r]));for(const[r,o]of t.entries()){const l=s.get(o.id),c=((i=l==null?void 0:l.internals)==null?void 0:i.userNode)??l;c!==void 0&&c!==o&&n.push({id:o.id,item:o,type:"replace"}),c===void 0&&n.push({item:o,type:"add",index:r})}for(const[r]of s)a.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function wo(t){return{id:t.id,type:"remove"}}const g0=nc();function y0(t,s,n={}){return Bj(t,s,{...n,onError:n.onError??g0})}const ko=t=>Cj(t),v0=t=>Ql(t);function Rc(t){return f.forwardRef(t)}const Ic=typeof window<"u"?f.useLayoutEffect:f.useEffect;function No(t){const[s,n]=f.useState(BigInt(0)),[a]=f.useState(()=>j0(()=>n(i=>i+BigInt(1))));return Ic(()=>{const i=a.get();i.length&&(t(i),a.reset())},[s]),a}function j0(t){let s=[];return{get:()=>s,reset:()=>{s=[]},push:n=>{s.push(n),t()}}}const Lc=f.createContext(null);function b0({children:t}){const s=we(),n=f.useCallback(l=>{const{nodes:c=[],setNodes:h,hasDefaultNodes:m,onNodesChange:d,nodeLookup:u,fitViewQueued:p,onNodesChangeMiddlewareMap:x}=s.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let j=bo({items:v,lookup:u});for(const g of x.values())j=g(j);m&&h(v),j.length>0?d==null||d(j):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:b,setNodes:y}=s.getState();g&&y(b)})},[]),a=No(n),i=f.useCallback(l=>{const{edges:c=[],setEdges:h,hasDefaultEdges:m,onEdgesChange:d,edgeLookup:u}=s.getState();let p=c;for(const x of l)p=typeof x=="function"?x(p):x;m?h(p):d&&d(bo({items:p,lookup:u}))},[]),r=No(i),o=f.useMemo(()=>({nodeQueue:a,edgeQueue:r}),[]);return e.jsx(Lc.Provider,{value:o,children:t})}function w0(){const t=f.useContext(Lc);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const k0=t=>!!t.panZoom;function tr(){const t=m0(),s=we(),n=w0(),a=ge(k0),i=f.useMemo(()=>{const r=d=>s.getState().nodeLookup.get(d),o=d=>{n.nodeQueue.push(d)},l=d=>{n.edgeQueue.push(d)},c=d=>{var g,b;const{nodeLookup:u,nodeOrigin:p}=s.getState(),x=ko(d)?d:u.get(d.id),v=x.parentId?ic(x.position,x.measured,x.parentId,u,p):x.position,j={...x,position:v,width:((g=x.measured)==null?void 0:g.width)??x.width,height:((b=x.measured)==null?void 0:b.height)??x.height};return dn(j)},h=(d,u,p={replace:!1})=>{o(x=>x.map(v=>{if(v.id===d){const j=typeof u=="function"?u(v):u;return p.replace&&ko(j)?j:{...v,...j}}return v}))},m=(d,u,p={replace:!1})=>{l(x=>x.map(v=>{if(v.id===d){const j=typeof u=="function"?u(v):u;return p.replace&&v0(j)?j:{...v,...j}}return v}))};return{getNodes:()=>s.getState().nodes.map(d=>({...d})),getNode:d=>{var u;return(u=r(d))==null?void 0:u.internals.userNode},getInternalNode:r,getEdges:()=>{const{edges:d=[]}=s.getState();return d.map(u=>({...u}))},getEdge:d=>s.getState().edgeLookup.get(d),setNodes:o,setEdges:l,addNodes:d=>{const u=Array.isArray(d)?d:[d];n.nodeQueue.push(p=>[...p,...u])},addEdges:d=>{const u=Array.isArray(d)?d:[d];n.edgeQueue.push(p=>[...p,...u])},toObject:()=>{const{nodes:d=[],edges:u=[],transform:p}=s.getState(),[x,v,j]=p;return{nodes:d.map(g=>({...g})),edges:u.map(g=>({...g})),viewport:{x,y:v,zoom:j}}},deleteElements:async({nodes:d=[],edges:u=[]})=>{const{nodes:p,edges:x,onNodesDelete:v,onEdgesDelete:j,triggerNodeChanges:g,triggerEdgeChanges:b,onDelete:y,onBeforeDelete:w}=s.getState(),{nodes:S,edges:$}=await _j({nodesToRemove:d,edgesToRemove:u,nodes:p,edges:x,onBeforeDelete:w}),M=$.length>0,z=S.length>0;if(M){const A=$.map(wo);j==null||j($),b(A)}if(z){const A=S.map(wo);v==null||v(S),g(A)}return(z||M)&&(y==null||y({nodes:S,edges:$})),{deletedNodes:S,deletedEdges:$}},getIntersectingNodes:(d,u=!0,p)=>{const x=Zr(d),v=x?d:c(d),j=p!==void 0;return v?(p||s.getState().nodes).filter(g=>{const b=s.getState().nodeLookup.get(g.id);if(b&&!x&&(g.id===d.id||!b.internals.positionAbsolute))return!1;const y=dn(j?g:b),w=la(y,v);return u&&w>0||w>=y.width*y.height||w>=v.width*v.height}):[]},isNodeIntersecting:(d,u,p=!0)=>{const v=Zr(d)?d:c(d);if(!v)return!1;const j=la(v,u);return p&&j>0||j>=u.width*u.height||j>=v.width*v.height},updateNode:h,updateNodeData:(d,u,p={replace:!1})=>{h(d,x=>{const v=typeof u=="function"?u(x):u;return p.replace?{...x,data:v}:{...x,data:{...x.data,...v}}},p)},updateEdge:m,updateEdgeData:(d,u,p={replace:!1})=>{m(d,x=>{const v=typeof u=="function"?u(x):u;return p.replace?{...x,data:v}:{...x,data:{...x.data,...v}}},p)},getNodesBounds:d=>{const{nodeLookup:u,nodeOrigin:p}=s.getState();return zj(d,{nodeLookup:u,nodeOrigin:p})},getHandleConnections:({type:d,id:u,nodeId:p})=>{var x;return Array.from(((x=s.getState().connectionLookup.get(`${p}-${d}${u?`-${u}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:d,handleId:u,nodeId:p})=>{var x;return Array.from(((x=s.getState().connectionLookup.get(`${p}${d?u?`-${d}-${u}`:`-${d}`:""}`))==null?void 0:x.values())??[])},fitView:async d=>{const u=s.getState().fitViewResolver??Rj();return s.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:u}),n.nodeQueue.push(p=>[...p]),u.promise}}},[]);return f.useMemo(()=>({...i,...t,viewportInitialized:a}),[a])}const So=t=>t.selected,N0=typeof window<"u"?window:void 0;function S0({deleteKeyCode:t,multiSelectionKeyCode:s}){const n=we(),{deleteElements:a}=tr(),i=hn(t,{actInsideInputWithModifier:!1}),r=hn(s,{target:N0});f.useEffect(()=>{if(i){const{edges:o,nodes:l}=n.getState();a({nodes:l.filter(So),edges:o.filter(So)}),n.setState({nodesSelectionActive:!1})}},[i]),f.useEffect(()=>{n.setState({multiSelectionActive:r})},[r])}function C0(t){const s=we();f.useEffect(()=>{const n=()=>{var i,r,o,l;if(!t.current||!(((r=(i=t.current).checkVisibility)==null?void 0:r.call(i))??!0))return!1;const a=Xi(t.current);(a.height===0||a.width===0)&&((l=(o=s.getState()).onError)==null||l.call(o,"004",yt.error004())),s.setState({width:a.width||500,height:a.height||500})};if(t.current){n(),window.addEventListener("resize",n);const a=new ResizeObserver(()=>n());return a.observe(t.current),()=>{window.removeEventListener("resize",n),a&&t.current&&a.unobserve(t.current)}}},[])}const Sa={position:"absolute",width:"100%",height:"100%",top:0,left:0},z0=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function M0({onPaneContextMenu:t,zoomOnScroll:s=!0,zoomOnPinch:n=!0,panOnScroll:a=!1,panOnScrollSpeed:i=.5,panOnScrollMode:r=Zt.Free,zoomOnDoubleClick:o=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:h,minZoom:m,maxZoom:d,zoomActivationKeyCode:u,preventScrolling:p=!0,children:x,noWheelClassName:v,noPanClassName:j,onViewportChange:g,isControlledViewport:b,paneClickDistance:y,selectionOnDrag:w}){const S=we(),$=f.useRef(null),{userSelectionActive:M,lib:z,connectionInProgress:A}=ge(z0,ke),k=hn(u),C=f.useRef();C0($);const _=f.useCallback(L=>{g==null||g({x:L[0],y:L[1],zoom:L[2]}),b||S.setState({transform:L})},[g,b]);return f.useEffect(()=>{if($.current){C.current=gb({domNode:$.current,minZoom:m,maxZoom:d,translateExtent:h,viewport:c,onDraggingChange:I=>S.setState(R=>R.paneDragging===I?R:{paneDragging:I}),onPanZoomStart:(I,R)=>{const{onViewportChangeStart:B,onMoveStart:E}=S.getState();E==null||E(I,R),B==null||B(R)},onPanZoom:(I,R)=>{const{onViewportChange:B,onMove:E}=S.getState();E==null||E(I,R),B==null||B(R)},onPanZoomEnd:(I,R)=>{const{onViewportChangeEnd:B,onMoveEnd:E}=S.getState();E==null||E(I,R),B==null||B(R)}});const{x:L,y:N,zoom:T}=C.current.getViewport();return S.setState({panZoom:C.current,transform:[L,N,T],domNode:$.current.closest(".react-flow")}),()=>{var I;(I=C.current)==null||I.destroy()}}},[]),f.useEffect(()=>{var L;(L=C.current)==null||L.update({onPaneContextMenu:t,zoomOnScroll:s,zoomOnPinch:n,panOnScroll:a,panOnScrollSpeed:i,panOnScrollMode:r,zoomOnDoubleClick:o,panOnDrag:l,zoomActivationKeyPressed:k,preventScrolling:p,noPanClassName:j,userSelectionActive:M,noWheelClassName:v,lib:z,onTransformChange:_,connectionInProgress:A,selectionOnDrag:w,paneClickDistance:y})},[t,s,n,a,i,r,o,l,k,p,j,M,v,z,_,A,w,y]),e.jsx("div",{className:"react-flow__renderer",ref:$,style:Sa,children:x})}const $0=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function E0(){const{userSelectionActive:t,userSelectionRect:s}=ge($0,ke);return t&&s?e.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:s.width,height:s.height,transform:`translate(${s.x}px, ${s.y}px)`}}):null}const Za=(t,s)=>n=>{n.target===s.current&&(t==null||t(n))},_0=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function T0({isSelecting:t,selectionKeyPressed:s,selectionMode:n=cn.Full,panOnDrag:a,autoPanOnSelection:i,paneClickDistance:r,selectionOnDrag:o,onSelectionStart:l,onSelectionEnd:c,onPaneClick:h,onPaneContextMenu:m,onPaneScroll:d,onPaneMouseEnter:u,onPaneMouseMove:p,onPaneMouseLeave:x,children:v}){const j=f.useRef(0),g=we(),{userSelectionActive:b,elementsSelectable:y,dragging:w,panBy:S,autoPanSpeed:$}=ge(_0,ke),M=y&&(t||b),z=f.useRef(null),A=f.useRef(),k=f.useRef(new Set),C=f.useRef(new Set),_=f.useRef(!1),L=f.useRef(!1),N=f.useRef({x:0,y:0}),T=f.useRef(!1),I=F=>{if(L.current||_.current||g.getState().connection.inProgress){L.current=!1,_.current=!1;return}h==null||h(F),g.getState().resetSelectedElements(),g.setState({nodesSelectionActive:!1})},R=F=>{if(Array.isArray(a)&&(a!=null&&a.includes(2))){F.preventDefault();return}m==null||m(F)},B=d?F=>d(F):void 0,E=F=>{L.current&&(F.stopPropagation(),L.current=!1)},P=F=>{var le,ce;const{domNode:Y,transform:Q}=g.getState();if(A.current=Y==null?void 0:Y.getBoundingClientRect(),!A.current)return;const ie=F.target===z.current;if(!ie&&!!F.target.closest(".nokey")||!t||!(o&&ie||s)||F.button!==0||!F.isPrimary)return;(ce=(le=F.target)==null?void 0:le.setPointerCapture)==null||ce.call(le,F.pointerId),L.current=!1;const{x:X,y:Z}=ft(F.nativeEvent,A.current),J=bn({x:X,y:Z},Q);g.setState({userSelectionRect:{width:0,height:0,startX:J.x,startY:J.y,x:X,y:Z}}),ie||(F.stopPropagation(),F.preventDefault())};function W(F,Y){const{userSelectionRect:Q}=g.getState();if(!Q)return;const{transform:ie,nodeLookup:ae,edgeLookup:O,connectionLookup:X,triggerNodeChanges:Z,triggerEdgeChanges:J,defaultEdgeOptions:le}=g.getState(),ce={x:Q.startX,y:Q.startY},{x:me,y:be}=_s(ce,ie),Ne={startX:ce.x,startY:ce.y,x:F<me?F:me,y:Y<be?Y:be,width:Math.abs(F-me),height:Math.abs(Y-be)},Me=k.current,We=C.current;k.current=new Set(Wi(ae,Ne,ie,n===cn.Partial,!0).map(Pe=>Pe.id)),C.current=new Set;const Qe=(le==null?void 0:le.selectable)??!0;for(const Pe of k.current){const Oe=X.get(Pe);if(Oe)for(const{edgeId:Ge}of Oe.values()){const Mt=O.get(Ge);Mt&&(Mt.selectable??Qe)&&C.current.add(Ge)}}if(!Qr(Me,k.current)){const Pe=gs(ae,k.current,!0);Z(Pe)}if(!Qr(We,C.current)){const Pe=gs(O,C.current);J(Pe)}g.setState({userSelectionRect:Ne,userSelectionActive:!0,nodesSelectionActive:!1})}function V(){if(!i||!A.current)return;const[F,Y]=Gi(N.current,A.current,$);S({x:F,y:Y}).then(Q=>{if(!L.current||!Q){j.current=requestAnimationFrame(V);return}const{x:ie,y:ae}=N.current;W(ie,ae),j.current=requestAnimationFrame(V)})}const K=()=>{cancelAnimationFrame(j.current),j.current=0,T.current=!1};f.useEffect(()=>()=>K(),[]);const D=F=>{const{userSelectionRect:Y,transform:Q,resetSelectedElements:ie}=g.getState();if(!A.current||!Y)return;const{x:ae,y:O}=ft(F.nativeEvent,A.current);N.current={x:ae,y:O};const X=_s({x:Y.startX,y:Y.startY},Q);if(!L.current){const Z=s?0:r;if(Math.hypot(ae-X.x,O-X.y)<=Z)return;ie(),l==null||l(F)}L.current=!0,T.current||(V(),T.current=!0),W(ae,O)},G=F=>{var Y,Q;if(!M){F.target===z.current&&g.getState().connection.inProgress&&(_.current=!0);return}F.button===0&&((Q=(Y=F.target)==null?void 0:Y.releasePointerCapture)==null||Q.call(Y,F.pointerId),!b&&F.target===z.current&&g.getState().userSelectionRect&&(I==null||I(F)),g.setState({userSelectionActive:!1,userSelectionRect:null}),L.current&&(c==null||c(F),g.setState({nodesSelectionActive:k.current.size>0})),K())},ee=F=>{var Y,Q;(Q=(Y=F.target)==null?void 0:Y.releasePointerCapture)==null||Q.call(Y,F.pointerId),K()},te=a===!0||Array.isArray(a)&&a.includes(0);return e.jsxs("div",{className:$e(["react-flow__pane",{draggable:te,dragging:w,selection:t}]),onClick:M?void 0:Za(I,z),onContextMenu:Za(R,z),onWheel:Za(B,z),onPointerEnter:M?void 0:u,onPointerMove:M?D:p,onPointerUp:G,onPointerCancel:M?ee:void 0,onPointerDownCapture:M?P:void 0,onClickCapture:M?E:void 0,onPointerLeave:x,ref:z,style:Sa,children:[v,e.jsx(E0,{})]})}function bi({id:t,store:s,unselect:n=!1,nodeRef:a}){const{addSelectedNodes:i,unselectNodesAndEdges:r,multiSelectionActive:o,nodeLookup:l,onError:c}=s.getState(),h=l.get(t);if(!h){c==null||c("012",yt.error012(t));return}s.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&o)&&(r({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var m;return(m=a==null?void 0:a.current)==null?void 0:m.blur()})):i([t])}function Pc({nodeRef:t,disabled:s=!1,noDragClassName:n,handleSelector:a,nodeId:i,isSelectable:r,nodeClickDistance:o}){const l=we(),[c,h]=f.useState(!1),m=f.useRef();return f.useEffect(()=>{if(!s)return m.current=nb({getStoreItems:()=>l.getState(),onNodeMouseDown:d=>{bi({id:d,store:l,nodeRef:t})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}}),()=>{var d;(d=m.current)==null||d.destroy(),m.current=void 0}},[s,l,t]),f.useEffect(()=>{s||!t.current||!m.current||m.current.update({noDragClassName:n,handleSelector:a,domNode:t.current,isSelectable:r,nodeId:i,nodeClickDistance:o})},[n,a,s,r,t,i,o]),c}const A0=t=>s=>s.selected&&(s.draggable||t&&typeof s.draggable>"u");function Dc(){const t=we();return f.useCallback(n=>{const{nodeExtent:a,snapToGrid:i,snapGrid:r,nodesDraggable:o,onError:l,updateNodePositions:c,nodeLookup:h,nodeOrigin:m}=t.getState(),d=new Map,u=A0(o),p=i?r[0]:5,x=i?r[1]:5,v=n.direction.x*p*n.factor,j=n.direction.y*x*n.factor;for(const[,g]of h){if(!u(g))continue;let b={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+j};i&&(b=jn(b,r));const{position:y,positionAbsolute:w}=Jl({nodeId:g.id,nextPosition:b,nodeLookup:h,nodeExtent:a,nodeOrigin:m,onError:l});g.position=y,g.internals.positionAbsolute=w,d.set(g.id,g)}c(d)},[])}const sr=f.createContext(null),R0=sr.Provider;sr.Consumer;const Fc=()=>f.useContext(sr),I0=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Oc=f.createContext(null);function L0({children:t}){const s=ge(I0,ke);return e.jsx(Oc.Provider,{value:s,children:t})}function P0(){const t=f.useContext(Oc);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const D0={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},F0=(t,s,n)=>a=>{const{connectionClickStartHandle:i,connectionMode:r,connection:o}=a,{fromHandle:l,toHandle:c,isValid:h}=o;if(!l&&!i)return D0;const m=(c==null?void 0:c.nodeId)===t&&(c==null?void 0:c.id)===s&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===t&&(l==null?void 0:l.id)===s&&(l==null?void 0:l.type)===n,connectingTo:m,clickConnecting:(i==null?void 0:i.nodeId)===t&&(i==null?void 0:i.id)===s&&(i==null?void 0:i.type)===n,isPossibleEndHandle:r===$s.Strict?(l==null?void 0:l.type)!==n:t!==(l==null?void 0:l.nodeId)||s!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!i,valid:m&&h}};function O0({type:t="source",position:s=he.Top,isValidConnection:n,isConnectable:a=!0,isConnectableStart:i=!0,isConnectableEnd:r=!0,id:o,onConnect:l,children:c,className:h,onMouseDown:m,onTouchStart:d,...u},p){var T,I;const x=o||null,v=t==="target",j=we(),g=Fc(),{connectOnClick:b,noPanClassName:y,rfId:w}=P0(),{connectingFrom:S,connectingTo:$,clickConnecting:M,isPossibleEndHandle:z,connectionInProcess:A,clickConnectionInProcess:k,valid:C}=ge(F0(g,x,t),ke);g||(I=(T=j.getState()).onError)==null||I.call(T,"010",yt.error010());const _=R=>{const{defaultEdgeOptions:B,onConnect:E,hasDefaultEdges:P}=j.getState(),W={...B,...R};if(P){const{edges:V,setEdges:K,onError:D}=j.getState();K(y0(W,V,{onError:D}))}E==null||E(W),l==null||l(W)},L=R=>{if(!g)return;const B=lc(R.nativeEvent);if(i&&(B&&R.button===0||!B)){const E=j.getState();ji.onPointerDown(R.nativeEvent,{handleDomNode:R.currentTarget,autoPanOnConnect:E.autoPanOnConnect,connectionMode:E.connectionMode,connectionRadius:E.connectionRadius,domNode:E.domNode,nodeLookup:E.nodeLookup,lib:E.lib,isTarget:v,handleId:x,nodeId:g,flowId:E.rfId,panBy:E.panBy,cancelConnection:E.cancelConnection,onConnectStart:E.onConnectStart,onConnectEnd:(...P)=>{var W,V;return(V=(W=j.getState()).onConnectEnd)==null?void 0:V.call(W,...P)},updateConnection:E.updateConnection,onConnect:_,isValidConnection:n||((...P)=>{var W,V;return((V=(W=j.getState()).isValidConnection)==null?void 0:V.call(W,...P))??!0}),getTransform:()=>j.getState().transform,getFromHandle:()=>j.getState().connection.fromHandle,autoPanSpeed:E.autoPanSpeed,dragThreshold:E.connectionDragThreshold})}B?m==null||m(R):d==null||d(R)},N=R=>{const{onClickConnectStart:B,onClickConnectEnd:E,connectionClickStartHandle:P,connectionMode:W,isValidConnection:V,lib:K,rfId:D,nodeLookup:G,connection:ee}=j.getState();if(!g||!P&&!i)return;if(!P){B==null||B(R.nativeEvent,{nodeId:g,handleId:x,handleType:t}),j.setState({connectionClickStartHandle:{nodeId:g,type:t,id:x}});return}const te=rc(R.target),F=n||V,{connection:Y,isValid:Q}=ji.isValid(R.nativeEvent,{handle:{nodeId:g,id:x,type:t},connectionMode:W,fromNodeId:P.nodeId,fromHandleId:P.id||null,fromType:P.type,isValidConnection:F,flowId:D,doc:te,lib:K,nodeLookup:G});Q&&Y&&_(Y);const ie=structuredClone(ee);delete ie.inProgress,ie.toPosition=ie.toHandle?ie.toHandle.position:null,E==null||E(R,ie),j.setState({connectionClickStartHandle:null})};return e.jsx("div",{"data-handleid":x,"data-nodeid":g,"data-handlepos":s,"data-id":`${w}-${g}-${x}-${t}`,className:$e(["react-flow__handle",`react-flow__handle-${s}`,"nodrag",y,h,{source:!v,target:v,connectable:a,connectablestart:i,connectableend:r,clickconnecting:M,connectingfrom:S,connectingto:$,valid:C,connectionindicator:a&&(!A||z)&&(A||k?r:i)}]),onMouseDown:L,onTouchStart:L,onClick:b?N:void 0,ref:p,...u,children:c})}const Rs=f.memo(Rc(O0));function B0({data:t,isConnectable:s,sourcePosition:n=he.Bottom}){return e.jsxs(e.Fragment,{children:[t==null?void 0:t.label,e.jsx(Rs,{type:"source",position:n,isConnectable:s})]})}function H0({data:t,isConnectable:s,targetPosition:n=he.Top,sourcePosition:a=he.Bottom}){return e.jsxs(e.Fragment,{children:[e.jsx(Rs,{type:"target",position:n,isConnectable:s}),t==null?void 0:t.label,e.jsx(Rs,{type:"source",position:a,isConnectable:s})]})}function V0(){return null}function U0({data:t,isConnectable:s,targetPosition:n=he.Top}){return e.jsxs(e.Fragment,{children:[e.jsx(Rs,{type:"target",position:n,isConnectable:s}),t==null?void 0:t.label]})}const ca={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Co={input:B0,default:H0,output:U0,group:V0};function q0(t){var s,n,a,i;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((s=t.style)==null?void 0:s.width),height:t.height??t.initialHeight??((n=t.style)==null?void 0:n.height)}:{width:t.width??((a=t.style)==null?void 0:a.width),height:t.height??((i=t.style)==null?void 0:i.height)}}const W0=t=>{const{width:s,height:n,x:a,y:i}=vn(t.nodeLookup,{filter:r=>!!r.selected});return{width:mt(s)?s:null,height:mt(n)?n:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${a}px,${i}px)`}};function G0({onSelectionContextMenu:t,noPanClassName:s,disableKeyboardA11y:n}){const a=we(),{width:i,height:r,transformString:o,userSelectionActive:l}=ge(W0,ke),c=Dc(),h=f.useRef(null);f.useEffect(()=>{var p;n||(p=h.current)==null||p.focus({preventScroll:!0})},[n]);const m=!l&&i!==null&&r!==null;if(Pc({nodeRef:h,disabled:!m}),!m)return null;const d=t?p=>{const x=a.getState().nodes.filter(v=>v.selected);t(p,x)}:void 0,u=p=>{Object.prototype.hasOwnProperty.call(ca,p.key)&&(p.preventDefault(),c({direction:ca[p.key],factor:p.shiftKey?4:1}))};return e.jsx("div",{className:$e(["react-flow__nodesselection","react-flow__container",s]),style:{transform:o},children:e.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:u,style:{width:i,height:r}})})}const zo=typeof window<"u"?window:void 0,Y0=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Bc({children:t,onPaneClick:s,onPaneMouseEnter:n,onPaneMouseMove:a,onPaneMouseLeave:i,onPaneContextMenu:r,onPaneScroll:o,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:h,selectionOnDrag:m,selectionMode:d,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:v,zoomActivationKeyCode:j,elementsSelectable:g,zoomOnScroll:b,zoomOnPinch:y,panOnScroll:w,panOnScrollSpeed:S,panOnScrollMode:$,zoomOnDoubleClick:M,panOnDrag:z,autoPanOnSelection:A,defaultViewport:k,translateExtent:C,minZoom:_,maxZoom:L,preventScrolling:N,onSelectionContextMenu:T,noWheelClassName:I,noPanClassName:R,disableKeyboardA11y:B,onViewportChange:E,isControlledViewport:P}){const{nodesSelectionActive:W,userSelectionActive:V}=ge(Y0,ke),K=hn(h,{target:zo}),D=hn(v,{target:zo}),G=D||z,ee=D||w,te=m&&G!==!0,F=K||V||te;return S0({deleteKeyCode:c,multiSelectionKeyCode:x}),e.jsx(M0,{onPaneContextMenu:r,elementsSelectable:g,zoomOnScroll:b,zoomOnPinch:y,panOnScroll:ee,panOnScrollSpeed:S,panOnScrollMode:$,zoomOnDoubleClick:M,panOnDrag:!K&&G,defaultViewport:k,translateExtent:C,minZoom:_,maxZoom:L,zoomActivationKeyCode:j,preventScrolling:N,noWheelClassName:I,noPanClassName:R,onViewportChange:E,isControlledViewport:P,paneClickDistance:l,selectionOnDrag:te,children:e.jsxs(T0,{onSelectionStart:u,onSelectionEnd:p,onPaneClick:s,onPaneMouseEnter:n,onPaneMouseMove:a,onPaneMouseLeave:i,onPaneContextMenu:r,onPaneScroll:o,panOnDrag:G,autoPanOnSelection:A,isSelecting:!!F,selectionMode:d,selectionKeyPressed:K,paneClickDistance:l,selectionOnDrag:te,children:[t,W&&e.jsx(G0,{onSelectionContextMenu:T,noPanClassName:R,disableKeyboardA11y:B})]})})}Bc.displayName="FlowRenderer";const X0=f.memo(Bc),K0=t=>s=>t?Wi(s.nodeLookup,{x:0,y:0,width:s.width,height:s.height},s.transform,!0).map(n=>n.id):Array.from(s.nodeLookup.keys());function Z0(t){return ge(f.useCallback(K0(t),[t]),ke)}const Q0=t=>t.updateNodeInternals;function J0(){const t=ge(Q0),[s]=f.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const a=new Map;n.forEach(i=>{const r=i.target.getAttribute("data-id");a.set(r,{id:r,nodeElement:i.target,force:!0})}),t(a)}));return f.useEffect(()=>()=>{s==null||s.disconnect()},[s]),s}function e1({node:t,nodeType:s,hasDimensions:n,resizeObserver:a}){const i=we(),r=f.useRef(null),o=f.useRef(null),l=f.useRef(t.sourcePosition),c=f.useRef(t.targetPosition),h=f.useRef(s),m=n&&!!t.internals.handleBounds;return f.useEffect(()=>{r.current&&!t.hidden&&(!m||o.current!==r.current)&&(o.current&&(a==null||a.unobserve(o.current)),a==null||a.observe(r.current),o.current=r.current)},[m,t.hidden]),f.useEffect(()=>()=>{o.current&&(a==null||a.unobserve(o.current),o.current=null)},[]),f.useEffect(()=>{if(r.current){const d=h.current!==s,u=l.current!==t.sourcePosition,p=c.current!==t.targetPosition;(d||u||p)&&(h.current=s,l.current=t.sourcePosition,c.current=t.targetPosition,i.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:r.current,force:!0}]])))}},[t.id,s,t.sourcePosition,t.targetPosition]),r}function t1({id:t,onClick:s,onMouseEnter:n,onMouseMove:a,onMouseLeave:i,onContextMenu:r,onDoubleClick:o,nodesDraggable:l,elementsSelectable:c,nodesConnectable:h,nodesFocusable:m,resizeObserver:d,noDragClassName:u,noPanClassName:p,disableKeyboardA11y:x,rfId:v,nodeTypes:j,nodeClickDistance:g,onError:b}){const{node:y,internals:w,isParent:S}=ge(F=>{const Y=F.nodeLookup.get(t),Q=F.parentLookup.has(t);return{node:Y,internals:Y.internals,isParent:Q}},ke);let $=y.type||"default",M=(j==null?void 0:j[$])||Co[$];M===void 0&&(b==null||b("003",yt.error003($)),$="default",M=(j==null?void 0:j.default)||Co.default);const z=!!(y.draggable||l&&typeof y.draggable>"u"),A=!!(y.selectable||c&&typeof y.selectable>"u"),k=!!(y.connectable||h&&typeof y.connectable>"u"),C=!!(y.focusable||m&&typeof y.focusable>"u"),_=we(),L=ac(y),N=e1({node:y,nodeType:$,hasDimensions:L,resizeObserver:d}),T=Pc({nodeRef:N,disabled:y.hidden||!z,noDragClassName:u,handleSelector:y.dragHandle,nodeId:t,isSelectable:A,nodeClickDistance:g}),I=Dc();if(y.hidden)return null;const R=zt(y),B=q0(y),E=A||z||s||n||a||i,P=n?F=>n(F,{...w.userNode}):void 0,W=a?F=>a(F,{...w.userNode}):void 0,V=i?F=>i(F,{...w.userNode}):void 0,K=r?F=>r(F,{...w.userNode}):void 0,D=o?F=>o(F,{...w.userNode}):void 0,G=F=>{const{selectNodesOnDrag:Y,nodeDragThreshold:Q}=_.getState();A&&(!Y||!z||Q>0)&&bi({id:t,store:_,nodeRef:N}),s&&s(F,{...w.userNode})},ee=F=>{if(!(oc(F.nativeEvent)||x)){if(Yl.includes(F.key)&&A){const Y=F.key==="Escape";bi({id:t,store:_,unselect:Y,nodeRef:N})}else if(z&&y.selected&&Object.prototype.hasOwnProperty.call(ca,F.key)){F.preventDefault();const{ariaLabelConfig:Y}=_.getState();_.setState({ariaLiveMessage:Y["node.a11yDescription.ariaLiveMessage"]({direction:F.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),I({direction:ca[F.key],factor:F.shiftKey?4:1})}}},te=()=>{var X;if(x||!((X=N.current)!=null&&X.matches(":focus-visible")))return;const{transform:F,width:Y,height:Q,autoPanOnNodeFocus:ie,setCenter:ae}=_.getState();if(!ie)return;Wi(new Map([[t,y]]),{x:0,y:0,width:Y,height:Q},F,!0).length>0||ae(y.position.x+R.width/2,y.position.y+R.height/2,{zoom:F[2]})};return e.jsx("div",{className:$e(["react-flow__node",`react-flow__node-${$}`,{[p]:z},y.className,{selected:y.selected,selectable:A,parent:S,draggable:z,dragging:T}]),ref:N,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:E?"all":"none",visibility:L?"visible":"hidden",...y.style,...B},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:P,onMouseMove:W,onMouseLeave:V,onContextMenu:K,onClick:G,onDoubleClick:D,onKeyDown:C?ee:void 0,tabIndex:C?0:void 0,onFocus:C?te:void 0,role:y.ariaRole??(C?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${Ec}-${v}`,"aria-label":y.ariaLabel,...y.domAttributes,children:e.jsx(R0,{value:t,children:e.jsx(M,{id:t,data:y.data,type:$,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:y.selected??!1,selectable:A,draggable:z,deletable:y.deletable??!0,isConnectable:k,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:T,dragHandle:y.dragHandle,zIndex:w.z,parentId:y.parentId,...R})})})}var s1=f.memo(t1);const n1=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Hc(t){const{nodesConnectable:s,nodesFocusable:n,elementsSelectable:a,onError:i}=ge(n1,ke),r=Z0(t.onlyRenderVisibleElements),o=J0();return e.jsx("div",{className:"react-flow__nodes",style:Sa,children:r.map(l=>e.jsx(s1,{id:l,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:o,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:s,nodesFocusable:n,elementsSelectable:a,nodeClickDistance:t.nodeClickDistance,onError:i},l))})}Hc.displayName="NodeRenderer";const a1=f.memo(Hc);function i1(t){return ge(f.useCallback(n=>{if(!t)return n.edges.map(i=>i.id);const a=[];if(n.width&&n.height)for(const i of n.edges){const r=n.nodeLookup.get(i.source),o=n.nodeLookup.get(i.target);r&&o&&Dj({sourceNode:r,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&a.push(i.id)}return a},[t]),ke)}const r1=({color:t="none",strokeWidth:s=1})=>{const n={strokeWidth:s,...t&&{stroke:t}};return e.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},o1=({color:t="none",strokeWidth:s=1})=>{const n={strokeWidth:s,...t&&{stroke:t,fill:t}};return e.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Mo={[ra.Arrow]:r1,[ra.ArrowClosed]:o1};function l1(t){const s=we();return f.useMemo(()=>{var i,r;return Object.prototype.hasOwnProperty.call(Mo,t)?Mo[t]:((r=(i=s.getState()).onError)==null||r.call(i,"009",yt.error009(t)),null)},[t])}const c1=({id:t,type:s,color:n,width:a=12.5,height:i=12.5,markerUnits:r="strokeWidth",strokeWidth:o,orient:l="auto-start-reverse"})=>{const c=l1(s);return c?e.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${a}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:r,orient:l,refX:"0",refY:"0",children:e.jsx(c,{color:n,strokeWidth:o})}):null},Vc=({defaultColor:t,rfId:s})=>{const n=ge(r=>r.edges),a=ge(r=>r.defaultEdgeOptions),i=f.useMemo(()=>Wj(n,{id:s,defaultColor:t,defaultMarkerStart:a==null?void 0:a.markerStart,defaultMarkerEnd:a==null?void 0:a.markerEnd}),[n,a,s,t]);return i.length?e.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:e.jsx("defs",{children:i.map(r=>e.jsx(c1,{id:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient},r.id))})}):null};Vc.displayName="MarkerDefinitions";var d1=f.memo(Vc);function Uc({x:t,y:s,label:n,labelStyle:a,labelShowBg:i=!0,labelBgStyle:r,labelBgPadding:o=[2,4],labelBgBorderRadius:l=2,children:c,className:h,...m}){const[d,u]=f.useState({x:1,y:0,width:0,height:0}),p=$e(["react-flow__edge-textwrapper",h]),x=f.useRef(null);return f.useEffect(()=>{if(x.current){const v=x.current.getBBox();u({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?e.jsxs("g",{transform:`translate(${t-d.width/2} ${s-d.height/2})`,className:p,visibility:d.width?"visible":"hidden",...m,children:[i&&e.jsx("rect",{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:"react-flow__edge-textbg",style:r,rx:l,ry:l}),e.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:x,style:a,children:n}),c]}):null}Uc.displayName="EdgeText";const u1=f.memo(Uc);function Ca({path:t,labelX:s,labelY:n,label:a,labelStyle:i,labelShowBg:r,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:h=20,...m}){return e.jsxs(e.Fragment,{children:[e.jsx("path",{...m,d:t,fill:"none",className:$e(["react-flow__edge-path",m.className])}),h?e.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,a&&mt(s)&&mt(n)?e.jsx(u1,{x:s,y:n,label:a,labelStyle:i,labelShowBg:r,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function $o({pos:t,x1:s,y1:n,x2:a,y2:i}){return t===he.Left||t===he.Right?[.5*(s+a),n]:[s,.5*(n+i)]}function qc({sourceX:t,sourceY:s,sourcePosition:n=he.Bottom,targetX:a,targetY:i,targetPosition:r=he.Top}){const[o,l]=$o({pos:n,x1:t,y1:s,x2:a,y2:i}),[c,h]=$o({pos:r,x1:a,y1:i,x2:t,y2:s}),[m,d,u,p]=cc({sourceX:t,sourceY:s,targetX:a,targetY:i,sourceControlX:o,sourceControlY:l,targetControlX:c,targetControlY:h});return[`M${t},${s} C${o},${l} ${c},${h} ${a},${i}`,m,d,u,p]}function Wc(t){return f.memo(({id:s,sourceX:n,sourceY:a,targetX:i,targetY:r,sourcePosition:o,targetPosition:l,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:v,markerStart:j,interactionWidth:g})=>{const[b,y,w]=qc({sourceX:n,sourceY:a,sourcePosition:o,targetX:i,targetY:r,targetPosition:l}),S=t.isInternal?void 0:s;return e.jsx(Ca,{id:S,path:b,labelX:y,labelY:w,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:v,markerStart:j,interactionWidth:g})})}const h1=Wc({isInternal:!1}),Gc=Wc({isInternal:!0});h1.displayName="SimpleBezierEdge";Gc.displayName="SimpleBezierEdgeInternal";function Yc(t){return f.memo(({id:s,sourceX:n,sourceY:a,targetX:i,targetY:r,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:d,style:u,sourcePosition:p=he.Bottom,targetPosition:x=he.Top,markerEnd:v,markerStart:j,pathOptions:g,interactionWidth:b})=>{const[y,w,S]=gi({sourceX:n,sourceY:a,sourcePosition:p,targetX:i,targetY:r,targetPosition:x,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),$=t.isInternal?void 0:s;return e.jsx(Ca,{id:$,path:y,labelX:w,labelY:S,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:d,style:u,markerEnd:v,markerStart:j,interactionWidth:b})})}const Xc=Yc({isInternal:!1}),Kc=Yc({isInternal:!0});Xc.displayName="SmoothStepEdge";Kc.displayName="SmoothStepEdgeInternal";function Zc(t){return f.memo(({id:s,...n})=>{var i;const a=t.isInternal?void 0:s;return e.jsx(Xc,{...n,id:a,pathOptions:f.useMemo(()=>{var r;return{borderRadius:0,offset:(r=n.pathOptions)==null?void 0:r.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const m1=Zc({isInternal:!1}),Qc=Zc({isInternal:!0});m1.displayName="StepEdge";Qc.displayName="StepEdgeInternal";function Jc(t){return f.memo(({id:s,sourceX:n,sourceY:a,targetX:i,targetY:r,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:v})=>{const[j,g,b]=hc({sourceX:n,sourceY:a,targetX:i,targetY:r}),y=t.isInternal?void 0:s;return e.jsx(Ca,{id:y,path:j,labelX:g,labelY:b,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:v})})}const f1=Jc({isInternal:!1}),ed=Jc({isInternal:!0});f1.displayName="StraightEdge";ed.displayName="StraightEdgeInternal";function td(t){return f.memo(({id:s,sourceX:n,sourceY:a,targetX:i,targetY:r,sourcePosition:o=he.Bottom,targetPosition:l=he.Top,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:v,markerStart:j,pathOptions:g,interactionWidth:b})=>{const[y,w,S]=dc({sourceX:n,sourceY:a,sourcePosition:o,targetX:i,targetY:r,targetPosition:l,curvature:g==null?void 0:g.curvature}),$=t.isInternal?void 0:s;return e.jsx(Ca,{id:$,path:y,labelX:w,labelY:S,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:v,markerStart:j,interactionWidth:b})})}const p1=td({isInternal:!1}),sd=td({isInternal:!0});p1.displayName="BezierEdge";sd.displayName="BezierEdgeInternal";const Eo={default:sd,straight:ed,step:Qc,smoothstep:Kc,simplebezier:Gc},_o={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},x1=(t,s,n)=>n===he.Left?t-s:n===he.Right?t+s:t,g1=(t,s,n)=>n===he.Top?t-s:n===he.Bottom?t+s:t,To="react-flow__edgeupdater";function Ao({position:t,centerX:s,centerY:n,radius:a=10,onMouseDown:i,onMouseEnter:r,onMouseOut:o,type:l}){return e.jsx("circle",{onMouseDown:i,onMouseEnter:r,onMouseOut:o,className:$e([To,`${To}-${l}`]),cx:x1(s,a,t),cy:g1(n,a,t),r:a,stroke:"transparent",fill:"transparent"})}function y1({isReconnectable:t,reconnectRadius:s,edge:n,sourceX:a,sourceY:i,targetX:r,targetY:o,sourcePosition:l,targetPosition:c,onReconnect:h,onReconnectStart:m,onReconnectEnd:d,setReconnecting:u,setUpdateHover:p}){const x=we(),v=(w,S)=>{if(w.button!==0)return;const{autoPanOnConnect:$,domNode:M,connectionMode:z,connectionRadius:A,lib:k,onConnectStart:C,cancelConnection:_,nodeLookup:L,rfId:N,panBy:T,updateConnection:I}=x.getState(),R=S.type==="target",B=(W,V)=>{u(!1),d==null||d(W,n,S.type,V)},E=W=>h==null?void 0:h(n,W),P=(W,V)=>{u(!0),m==null||m(w,n,S.type),C==null||C(W,V)};ji.onPointerDown(w.nativeEvent,{autoPanOnConnect:$,connectionMode:z,connectionRadius:A,domNode:M,handleId:S.id,nodeId:S.nodeId,nodeLookup:L,isTarget:R,edgeUpdaterType:S.type,lib:k,flowId:N,cancelConnection:_,panBy:T,isValidConnection:(...W)=>{var V,K;return((K=(V=x.getState()).isValidConnection)==null?void 0:K.call(V,...W))??!0},onConnect:E,onConnectStart:P,onConnectEnd:(...W)=>{var V,K;return(K=(V=x.getState()).onConnectEnd)==null?void 0:K.call(V,...W)},onReconnectEnd:B,updateConnection:I,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},j=w=>v(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=w=>v(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>p(!0),y=()=>p(!1);return e.jsxs(e.Fragment,{children:[(t===!0||t==="source")&&e.jsx(Ao,{position:l,centerX:a,centerY:i,radius:s,onMouseDown:j,onMouseEnter:b,onMouseOut:y,type:"source"}),(t===!0||t==="target")&&e.jsx(Ao,{position:c,centerX:r,centerY:o,radius:s,onMouseDown:g,onMouseEnter:b,onMouseOut:y,type:"target"})]})}function v1({id:t,edgesFocusable:s,edgesReconnectable:n,elementsSelectable:a,onClick:i,onDoubleClick:r,onContextMenu:o,onMouseEnter:l,onMouseMove:c,onMouseLeave:h,reconnectRadius:m,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,rfId:x,edgeTypes:v,noPanClassName:j,onError:g,disableKeyboardA11y:b}){let y=ge(ae=>ae.edgeLookup.get(t));const w=ge(ae=>ae.defaultEdgeOptions);y=w?{...w,...y}:y;let S=y.type||"default",$=(v==null?void 0:v[S])||Eo[S];$===void 0&&(g==null||g("011",yt.error011(S)),S="default",$=(v==null?void 0:v.default)||Eo.default);const M=!!(y.focusable||s&&typeof y.focusable>"u"),z=typeof d<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),A=!!(y.selectable||a&&typeof y.selectable>"u"),k=f.useRef(null),[C,_]=f.useState(!1),[L,N]=f.useState(!1),T=we(),{zIndex:I=y.zIndex,sourceX:R,sourceY:B,targetX:E,targetY:P,sourcePosition:W,targetPosition:V}=ge(f.useCallback(ae=>{const O=ae.nodeLookup.get(y.source),X=ae.nodeLookup.get(y.target);if(!O||!X)return _o;const Z=qj({id:t,sourceNode:O,targetNode:X,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:ae.connectionMode,onError:g}),J=Pj({selected:y.selected,zIndex:y.zIndex,sourceNode:O,targetNode:X,elevateOnSelect:ae.elevateEdgesOnSelect,zIndexMode:ae.zIndexMode});return{...Z||_o,zIndex:J}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),ke),K=f.useMemo(()=>y.markerStart?`url('#${yi(y.markerStart,x)}')`:void 0,[y.markerStart,x]),D=f.useMemo(()=>y.markerEnd?`url('#${yi(y.markerEnd,x)}')`:void 0,[y.markerEnd,x]);if(y.hidden||R===null||B===null||E===null||P===null)return null;const G=ae=>{var J;const{addSelectedEdges:O,unselectNodesAndEdges:X,multiSelectionActive:Z}=T.getState();A&&(T.setState({nodesSelectionActive:!1}),y.selected&&Z?(X({nodes:[],edges:[y]}),(J=k.current)==null||J.blur()):O([t])),i&&i(ae,y)},ee=r?ae=>{r(ae,{...y})}:void 0,te=o?ae=>{o(ae,{...y})}:void 0,F=l?ae=>{l(ae,{...y})}:void 0,Y=c?ae=>{c(ae,{...y})}:void 0,Q=h?ae=>{h(ae,{...y})}:void 0,ie=ae=>{var O;if(!b&&Yl.includes(ae.key)&&A){const{unselectNodesAndEdges:X,addSelectedEdges:Z}=T.getState();ae.key==="Escape"?((O=k.current)==null||O.blur(),X({edges:[y]})):Z([t])}};return e.jsx("svg",{style:{zIndex:I},children:e.jsxs("g",{className:$e(["react-flow__edge",`react-flow__edge-${S}`,y.className,j,{selected:y.selected,animated:y.animated,inactive:!A&&!i,updating:C,selectable:A}]),onClick:G,onDoubleClick:ee,onContextMenu:te,onMouseEnter:F,onMouseMove:Y,onMouseLeave:Q,onKeyDown:M?ie:void 0,tabIndex:M?0:void 0,role:y.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":M?`${_c}-${x}`:void 0,ref:k,...y.domAttributes,children:[!L&&e.jsx($,{id:t,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:A,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:R,sourceY:B,targetX:E,targetY:P,sourcePosition:W,targetPosition:V,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:K,markerEnd:D,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),z&&e.jsx(y1,{edge:y,isReconnectable:z,reconnectRadius:m,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,sourceX:R,sourceY:B,targetX:E,targetY:P,sourcePosition:W,targetPosition:V,setUpdateHover:_,setReconnecting:N})]})})}var j1=f.memo(v1);const b1=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function nd({defaultMarkerColor:t,onlyRenderVisibleElements:s,rfId:n,edgeTypes:a,noPanClassName:i,onReconnect:r,onEdgeContextMenu:o,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:h,onEdgeClick:m,reconnectRadius:d,onEdgeDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,disableKeyboardA11y:v}){const{edgesFocusable:j,edgesReconnectable:g,elementsSelectable:b,onError:y}=ge(b1,ke),w=i1(s);return e.jsxs("div",{className:"react-flow__edges",children:[e.jsx(d1,{defaultColor:t,rfId:n}),w.map(S=>e.jsx(j1,{id:S,edgesFocusable:j,edgesReconnectable:g,elementsSelectable:b,noPanClassName:i,onReconnect:r,onContextMenu:o,onMouseEnter:l,onMouseMove:c,onMouseLeave:h,onClick:m,reconnectRadius:d,onDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,rfId:n,onError:y,edgeTypes:a,disableKeyboardA11y:v},S))]})}nd.displayName="EdgeRenderer";const w1=f.memo(nd),Ro=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function k1({children:t}){const s=we(),n=f.useRef(null),[a]=f.useState(()=>s.getState().transform);return Ic(()=>{let i=null;const r=()=>{const o=s.getState().transform;i&&o[0]===i[0]&&o[1]===i[1]&&o[2]===i[2]||(i=o,n.current&&(n.current.style.transform=Ro(o)))};return r(),s.subscribe(r)},[s]),e.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Ro(a)},children:t})}function N1(t){const s=tr(),n=f.useRef(!1);f.useEffect(()=>{!n.current&&s.viewportInitialized&&t&&(setTimeout(()=>t(s),1),n.current=!0)},[t,s.viewportInitialized])}const S1=t=>{var s;return(s=t.panZoom)==null?void 0:s.syncViewport};function C1(t){const s=ge(S1),n=we();return f.useEffect(()=>{t&&(s==null||s(t),n.setState({transform:[t.x,t.y,t.zoom]}))},[t,s]),null}function z1(t){return t.connection.inProgress?{...t.connection,to:bn(t.connection.to,t.transform)}:{...t.connection}}function M1(t){return z1}function $1(t){const s=M1();return ge(s,ke)}const E1=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function _1({containerStyle:t,style:s,type:n,component:a}){const{nodesConnectable:i,width:r,height:o,isValid:l,inProgress:c}=ge(E1,ke);return!(r&&i&&c)?null:e.jsx("svg",{style:t,width:r,height:o,className:"react-flow__connectionline react-flow__container",children:e.jsx("g",{className:$e(["react-flow__connection",Zl(l)]),children:e.jsx(ad,{style:s,type:n,CustomComponent:a,isValid:l})})})}const ad=({style:t,type:s=Ft.Bezier,CustomComponent:n,isValid:a})=>{const{inProgress:i,from:r,fromNode:o,fromHandle:l,fromPosition:c,to:h,toNode:m,toHandle:d,toPosition:u,pointer:p}=$1();if(!i)return;if(n)return e.jsx(n,{connectionLineType:s,connectionLineStyle:t,fromNode:o,fromHandle:l,fromX:r.x,fromY:r.y,toX:h.x,toY:h.y,fromPosition:c,toPosition:u,connectionStatus:Zl(a),toNode:m,toHandle:d,pointer:p});let x="";const v={sourceX:r.x,sourceY:r.y,sourcePosition:c,targetX:h.x,targetY:h.y,targetPosition:u};switch(s){case Ft.Bezier:[x]=dc(v);break;case Ft.SimpleBezier:[x]=qc(v);break;case Ft.Step:[x]=gi({...v,borderRadius:0});break;case Ft.SmoothStep:[x]=gi(v);break;default:[x]=hc(v)}return e.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:t})};ad.displayName="ConnectionLine";const T1={};function Io(t=T1){f.useRef(t),we(),f.useEffect(()=>{},[t])}function A1(){we(),f.useRef(!1),f.useEffect(()=>{},[])}function id({nodeTypes:t,edgeTypes:s,onInit:n,onNodeClick:a,onEdgeClick:i,onNodeDoubleClick:r,onEdgeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:d,onSelectionStart:u,onSelectionEnd:p,connectionLineType:x,connectionLineStyle:v,connectionLineComponent:j,connectionLineContainerStyle:g,selectionKeyCode:b,selectionOnDrag:y,selectionMode:w,multiSelectionKeyCode:S,panActivationKeyCode:$,zoomActivationKeyCode:M,deleteKeyCode:z,onlyRenderVisibleElements:A,elementsSelectable:k,defaultViewport:C,translateExtent:_,minZoom:L,maxZoom:N,preventScrolling:T,defaultMarkerColor:I,zoomOnScroll:R,zoomOnPinch:B,panOnScroll:E,panOnScrollSpeed:P,panOnScrollMode:W,zoomOnDoubleClick:V,panOnDrag:K,autoPanOnSelection:D,onPaneClick:G,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:F,onPaneScroll:Y,onPaneContextMenu:Q,paneClickDistance:ie,nodeClickDistance:ae,onEdgeContextMenu:O,onEdgeMouseEnter:X,onEdgeMouseMove:Z,onEdgeMouseLeave:J,reconnectRadius:le,onReconnect:ce,onReconnectStart:me,onReconnectEnd:be,noDragClassName:Ne,noWheelClassName:Me,noPanClassName:We,disableKeyboardA11y:Qe,nodeExtent:Pe,rfId:Oe,viewport:Ge,onViewportChange:Mt,nodesDraggable:Ls}){return Io(t),Io(s),A1(),N1(n),C1(Ge),e.jsx(X0,{onPaneClick:G,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:F,onPaneContextMenu:Q,onPaneScroll:Y,paneClickDistance:ie,deleteKeyCode:z,selectionKeyCode:b,selectionOnDrag:y,selectionMode:w,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:S,panActivationKeyCode:$,zoomActivationKeyCode:M,elementsSelectable:k,zoomOnScroll:R,zoomOnPinch:B,zoomOnDoubleClick:V,panOnScroll:E,panOnScrollSpeed:P,panOnScrollMode:W,panOnDrag:K,autoPanOnSelection:D,defaultViewport:C,translateExtent:_,minZoom:L,maxZoom:N,onSelectionContextMenu:d,preventScrolling:T,noDragClassName:Ne,noWheelClassName:Me,noPanClassName:We,disableKeyboardA11y:Qe,onViewportChange:Mt,isControlledViewport:!!Ge,children:e.jsxs(k1,{children:[e.jsx(w1,{edgeTypes:s,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:ce,onReconnectStart:me,onReconnectEnd:be,onlyRenderVisibleElements:A,onEdgeContextMenu:O,onEdgeMouseEnter:X,onEdgeMouseMove:Z,onEdgeMouseLeave:J,reconnectRadius:le,defaultMarkerColor:I,noPanClassName:We,disableKeyboardA11y:Qe,rfId:Oe}),e.jsx(_1,{style:v,type:x,component:j,containerStyle:g}),e.jsx("div",{className:"react-flow__edgelabel-renderer"}),e.jsx(a1,{nodeTypes:t,onNodeClick:a,onNodeDoubleClick:r,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:h,onNodeContextMenu:m,nodeClickDistance:ae,onlyRenderVisibleElements:A,noPanClassName:We,noDragClassName:Ne,disableKeyboardA11y:Qe,nodeExtent:Pe,rfId:Oe,nodesDraggable:Ls}),e.jsx("div",{className:"react-flow__viewport-portal"})]})})}id.displayName="GraphView";const R1=f.memo(id),I1=nc(),Lo=({nodes:t,edges:s,defaultNodes:n,defaultEdges:a,width:i,height:r,fitView:o,fitViewOptions:l,minZoom:c=.5,maxZoom:h=2,nodeOrigin:m,nodeExtent:d,zIndexMode:u="basic"}={})=>{const p=new Map,x=new Map,v=new Map,j=new Map,g=a??s??[],b=n??t??[],y=m??[0,0],w=d??ln;pc(v,j,g);const{nodesInitialized:S}=vi(b,p,x,{nodeOrigin:y,nodeExtent:w,zIndexMode:u});let $=[0,0,1];if(o&&i&&r){const M=vn(p,{filter:C=>!!((C.width||C.initialWidth)&&(C.height||C.initialHeight))}),{x:z,y:A,zoom:k}=Yi(M,i,r,c,h,(l==null?void 0:l.padding)??.1);$=[z,A,k]}return{rfId:"1",width:i??0,height:r??0,transform:$,nodes:b,nodesInitialized:S,nodeLookup:p,parentLookup:x,edges:g,edgeLookup:j,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:a!==void 0,panZoom:null,minZoom:c,maxZoom:h,translateExtent:ln,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:$s.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:l,fitViewResolver:null,connection:{...Kl},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:I1,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Xl,zIndexMode:u,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},L1=({nodes:t,edges:s,defaultNodes:n,defaultEdges:a,width:i,height:r,fitView:o,fitViewOptions:l,minZoom:c,maxZoom:h,nodeOrigin:m,nodeExtent:d,zIndexMode:u})=>Yb((p,x)=>{async function v(){const{nodeLookup:j,panZoom:g,fitViewOptions:b,fitViewResolver:y,width:w,height:S,minZoom:$,maxZoom:M}=x();g&&(await Ej({nodes:j,width:w,height:S,panZoom:g,minZoom:$,maxZoom:M},b),y==null||y.resolve(!0),p({fitViewResolver:null}))}return{...Lo({nodes:t,edges:s,width:i,height:r,fitView:o,fitViewOptions:l,minZoom:c,maxZoom:h,nodeOrigin:m,nodeExtent:d,defaultNodes:n,defaultEdges:a,zIndexMode:u}),setNodes:j=>{const{nodeLookup:g,parentLookup:b,nodeOrigin:y,elevateNodesOnSelect:w,fitViewQueued:S,zIndexMode:$,nodesSelectionActive:M}=x(),{nodesInitialized:z,hasSelectedNodes:A}=vi(j,g,b,{nodeOrigin:y,nodeExtent:d,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:$}),k=M&&A;S&&z?(v(),p({nodes:j,nodesInitialized:z,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:k})):p({nodes:j,nodesInitialized:z,nodesSelectionActive:k})},setEdges:j=>{const{connectionLookup:g,edgeLookup:b}=x();pc(g,b,j),p({edges:j})},setDefaultNodesAndEdges:(j,g)=>{if(j){const{setNodes:b}=x();b(j),p({hasDefaultNodes:!0})}if(g){const{setEdges:b}=x();b(g),p({hasDefaultEdges:!0})}},updateNodeInternals:j=>{const{triggerNodeChanges:g,nodeLookup:b,parentLookup:y,domNode:w,nodeOrigin:S,nodeExtent:$,debug:M,fitViewQueued:z,zIndexMode:A}=x(),{changes:k,updatedInternals:C}=Jj(j,b,y,w,S,$,A);C&&(Xj(b,y,{nodeOrigin:S,nodeExtent:$,zIndexMode:A}),z?(v(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(k==null?void 0:k.length)>0&&(M&&console.log("React Flow: trigger node changes",k),g==null||g(k)))},updateNodePositions:(j,g=!1)=>{const b=[];let y=[];const{nodeLookup:w,triggerNodeChanges:S,connection:$,updateConnection:M,onNodesChangeMiddlewareMap:z}=x();for(const[A,k]of j){const C=w.get(A),_=!!(C!=null&&C.expandParent&&(C!=null&&C.parentId)&&(k!=null&&k.position)),L={id:A,type:"position",position:_?{x:Math.max(0,k.position.x),y:Math.max(0,k.position.y)}:k.position,dragging:g};if(C&&$.inProgress&&$.fromNode.id===C.id){const N=os(C,$.fromHandle,he.Left,!0);M({...$,from:N})}_&&C.parentId&&b.push({id:A,parentId:C.parentId,rect:{...k.internals.positionAbsolute,width:k.measured.width??0,height:k.measured.height??0}}),y.push(L)}if(b.length>0){const{parentLookup:A,nodeOrigin:k}=x(),C=er(b,w,A,k);y.push(...C)}for(const A of z.values())y=A(y);S(y)},triggerNodeChanges:j=>{const{onNodesChange:g,setNodes:b,nodes:y,hasDefaultNodes:w,debug:S}=x();if(j!=null&&j.length){if(w){const $=p0(j,y);b($)}S&&console.log("React Flow: trigger node changes",j),g==null||g(j)}},triggerEdgeChanges:j=>{const{onEdgesChange:g,setEdges:b,edges:y,hasDefaultEdges:w,debug:S}=x();if(j!=null&&j.length){if(w){const $=x0(j,y);b($)}S&&console.log("React Flow: trigger edge changes",j),g==null||g(j)}},addSelectedNodes:j=>{const{multiSelectionActive:g,edgeLookup:b,nodeLookup:y,triggerNodeChanges:w,triggerEdgeChanges:S}=x();if(g){const $=j.map(M=>Gt(M,!0));w($);return}w(gs(y,new Set([...j]),!0)),S(gs(b))},addSelectedEdges:j=>{const{multiSelectionActive:g,edgeLookup:b,nodeLookup:y,triggerNodeChanges:w,triggerEdgeChanges:S}=x();if(g){const $=j.map(M=>Gt(M,!0));S($);return}S(gs(b,new Set([...j]))),w(gs(y,new Set,!0))},unselectNodesAndEdges:({nodes:j,edges:g}={})=>{const{edges:b,nodes:y,nodeLookup:w,triggerNodeChanges:S,triggerEdgeChanges:$}=x(),M=j||y,z=g||b,A=[];for(const C of M){if(!C.selected)continue;const _=w.get(C.id);_&&(_.selected=!1),A.push(Gt(C.id,!1))}const k=[];for(const C of z)C.selected&&k.push(Gt(C.id,!1));S(A),$(k)},setMinZoom:j=>{const{panZoom:g,maxZoom:b}=x();g==null||g.setScaleExtent([j,b]),p({minZoom:j})},setMaxZoom:j=>{const{panZoom:g,minZoom:b}=x();g==null||g.setScaleExtent([b,j]),p({maxZoom:j})},setTranslateExtent:j=>{var g;(g=x().panZoom)==null||g.setTranslateExtent(j),p({translateExtent:j})},resetSelectedElements:()=>{const{edges:j,nodes:g,triggerNodeChanges:b,triggerEdgeChanges:y,elementsSelectable:w}=x();if(!w)return;const S=g.reduce((M,z)=>z.selected?[...M,Gt(z.id,!1)]:M,[]),$=j.reduce((M,z)=>z.selected?[...M,Gt(z.id,!1)]:M,[]);b(S),y($)},setNodeExtent:j=>{const{nodes:g,nodeLookup:b,parentLookup:y,nodeOrigin:w,elevateNodesOnSelect:S,nodeExtent:$,zIndexMode:M}=x();j[0][0]===$[0][0]&&j[0][1]===$[0][1]&&j[1][0]===$[1][0]&&j[1][1]===$[1][1]||(vi(g,b,y,{nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:M}),p({nodeExtent:j}))},panBy:j=>{const{transform:g,width:b,height:y,panZoom:w,translateExtent:S}=x();return eb({delta:j,panZoom:w,transform:g,translateExtent:S,width:b,height:y})},setCenter:async(j,g,b)=>{const{width:y,height:w,maxZoom:S,panZoom:$}=x();if(!$)return!1;const M=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:S;return await $.setViewport({x:y/2-j*M,y:w/2-g*M,zoom:M},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),!0},cancelConnection:()=>{p({connection:{...Kl}})},updateConnection:j=>{p({connection:j})},reset:()=>p({...Lo()})}},Object.is);function P1({initialNodes:t,initialEdges:s,defaultNodes:n,defaultEdges:a,initialWidth:i,initialHeight:r,initialMinZoom:o,initialMaxZoom:l,initialFitViewOptions:c,fitView:h,nodeOrigin:m,nodeExtent:d,zIndexMode:u,children:p}){const[x]=f.useState(()=>L1({nodes:t,edges:s,defaultNodes:n,defaultEdges:a,width:i,height:r,fitView:h,minZoom:o,maxZoom:l,fitViewOptions:c,nodeOrigin:m,nodeExtent:d,zIndexMode:u}));return e.jsx(Xb,{value:x,children:e.jsx(b0,{children:e.jsx(L0,{children:p})})})}function D1({children:t,nodes:s,edges:n,defaultNodes:a,defaultEdges:i,width:r,height:o,fitView:l,fitViewOptions:c,minZoom:h,maxZoom:m,nodeOrigin:d,nodeExtent:u,zIndexMode:p}){return f.useContext(ka)?e.jsx(e.Fragment,{children:t}):e.jsx(P1,{initialNodes:s,initialEdges:n,defaultNodes:a,defaultEdges:i,initialWidth:r,initialHeight:o,fitView:l,initialFitViewOptions:c,initialMinZoom:h,initialMaxZoom:m,nodeOrigin:d,nodeExtent:u,zIndexMode:p,children:t})}const F1={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function O1({nodes:t,edges:s,defaultNodes:n,defaultEdges:a,className:i,nodeTypes:r,edgeTypes:o,onNodeClick:l,onEdgeClick:c,onInit:h,onMove:m,onMoveStart:d,onMoveEnd:u,onConnect:p,onConnectStart:x,onConnectEnd:v,onClickConnectStart:j,onClickConnectEnd:g,onNodeMouseEnter:b,onNodeMouseMove:y,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:$,onNodeDragStart:M,onNodeDrag:z,onNodeDragStop:A,onNodesDelete:k,onEdgesDelete:C,onDelete:_,onSelectionChange:L,onSelectionDragStart:N,onSelectionDrag:T,onSelectionDragStop:I,onSelectionContextMenu:R,onSelectionStart:B,onSelectionEnd:E,onBeforeDelete:P,connectionMode:W,connectionLineType:V=Ft.Bezier,connectionLineStyle:K,connectionLineComponent:D,connectionLineContainerStyle:G,deleteKeyCode:ee="Backspace",selectionKeyCode:te="Shift",selectionOnDrag:F=!1,selectionMode:Y=cn.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:ie=un()?"Meta":"Control",zoomActivationKeyCode:ae=un()?"Meta":"Control",snapToGrid:O,snapGrid:X,onlyRenderVisibleElements:Z=!1,selectNodesOnDrag:J,nodesDraggable:le,autoPanOnNodeFocus:ce,nodesConnectable:me,nodesFocusable:be,nodeOrigin:Ne=Tc,edgesFocusable:Me,edgesReconnectable:We,elementsSelectable:Qe=!0,defaultViewport:Pe=l0,minZoom:Oe=.5,maxZoom:Ge=2,translateExtent:Mt=ln,preventScrolling:Ls=!0,nodeExtent:qt,defaultMarkerColor:q="#b1b1b7",zoomOnScroll:oe=!0,zoomOnPinch:Se=!0,panOnScroll:Ce=!1,panOnScrollSpeed:ve=.5,panOnScrollMode:ze=Zt.Free,zoomOnDoubleClick:Ye=!0,panOnDrag:Lt=!0,onPaneClick:$t,onPaneMouseEnter:Je,onPaneMouseMove:za,onPaneMouseLeave:Te,onPaneScroll:dd,onPaneContextMenu:ud,paneClickDistance:hd=1,nodeClickDistance:md=0,children:fd,onReconnect:pd,onReconnectStart:xd,onReconnectEnd:gd,onEdgeContextMenu:yd,onEdgeDoubleClick:vd,onEdgeMouseEnter:jd,onEdgeMouseMove:bd,onEdgeMouseLeave:wd,reconnectRadius:kd=10,onNodesChange:Nd,onEdgesChange:Sd,noDragClassName:Cd="nodrag",noWheelClassName:zd="nowheel",noPanClassName:nr="nopan",fitView:ar,fitViewOptions:ir,connectOnClick:Md,attributionPosition:$d,proOptions:Ed,defaultEdgeOptions:_d,elevateNodesOnSelect:Td=!0,elevateEdgesOnSelect:Ad=!1,disableKeyboardA11y:rr=!1,autoPanOnConnect:Rd,autoPanOnNodeDrag:Id,autoPanOnSelection:Ld=!0,autoPanSpeed:Pd,connectionRadius:Dd,isValidConnection:Fd,onError:Od,style:Bd,id:or,nodeDragThreshold:Hd,connectionDragThreshold:Vd,viewport:Ud,onViewportChange:qd,width:Wd,height:Gd,colorMode:Yd="light",debug:Xd,onScroll:wn,ariaLabelConfig:Kd,zIndexMode:lr="basic",...Zd},Qd){const Ma=or||"1",Jd=h0(Yd),eu=f.useCallback(cr=>{cr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),wn==null||wn(cr)},[wn]);return e.jsx("div",{"data-testid":"rf__wrapper",...Zd,onScroll:eu,style:{...Bd,...F1},ref:Qd,className:$e(["react-flow",i,Jd]),id:or,role:"application",children:e.jsxs(D1,{nodes:t,edges:s,width:Wd,height:Gd,fitView:ar,fitViewOptions:ir,minZoom:Oe,maxZoom:Ge,nodeOrigin:Ne,nodeExtent:qt,zIndexMode:lr,children:[e.jsx(u0,{nodes:t,edges:s,defaultNodes:n,defaultEdges:a,onConnect:p,onConnectStart:x,onConnectEnd:v,onClickConnectStart:j,onClickConnectEnd:g,nodesDraggable:le,autoPanOnNodeFocus:ce,nodesConnectable:me,nodesFocusable:be,edgesFocusable:Me,edgesReconnectable:We,elementsSelectable:Qe,elevateNodesOnSelect:Td,elevateEdgesOnSelect:Ad,minZoom:Oe,maxZoom:Ge,nodeExtent:qt,onNodesChange:Nd,onEdgesChange:Sd,snapToGrid:O,snapGrid:X,connectionMode:W,translateExtent:Mt,connectOnClick:Md,defaultEdgeOptions:_d,fitView:ar,fitViewOptions:ir,onNodesDelete:k,onEdgesDelete:C,onDelete:_,onNodeDragStart:M,onNodeDrag:z,onNodeDragStop:A,onSelectionDrag:T,onSelectionDragStart:N,onSelectionDragStop:I,onMove:m,onMoveStart:d,onMoveEnd:u,noPanClassName:nr,nodeOrigin:Ne,rfId:Ma,autoPanOnConnect:Rd,autoPanOnNodeDrag:Id,autoPanSpeed:Pd,onError:Od,connectionRadius:Dd,isValidConnection:Fd,selectNodesOnDrag:J,nodeDragThreshold:Hd,connectionDragThreshold:Vd,onBeforeDelete:P,debug:Xd,ariaLabelConfig:Kd,zIndexMode:lr}),e.jsx(R1,{onInit:h,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:y,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:$,nodeTypes:r,edgeTypes:o,connectionLineType:V,connectionLineStyle:K,connectionLineComponent:D,connectionLineContainerStyle:G,selectionKeyCode:te,selectionOnDrag:F,selectionMode:Y,deleteKeyCode:ee,multiSelectionKeyCode:ie,panActivationKeyCode:Q,zoomActivationKeyCode:ae,onlyRenderVisibleElements:Z,defaultViewport:Pe,translateExtent:Mt,minZoom:Oe,maxZoom:Ge,preventScrolling:Ls,zoomOnScroll:oe,zoomOnPinch:Se,zoomOnDoubleClick:Ye,panOnScroll:Ce,panOnScrollSpeed:ve,panOnScrollMode:ze,panOnDrag:Lt,autoPanOnSelection:Ld,onPaneClick:$t,onPaneMouseEnter:Je,onPaneMouseMove:za,onPaneMouseLeave:Te,onPaneScroll:dd,onPaneContextMenu:ud,paneClickDistance:hd,nodeClickDistance:md,onSelectionContextMenu:R,onSelectionStart:B,onSelectionEnd:E,onReconnect:pd,onReconnectStart:xd,onReconnectEnd:gd,onEdgeContextMenu:yd,onEdgeDoubleClick:vd,onEdgeMouseEnter:jd,onEdgeMouseMove:bd,onEdgeMouseLeave:wd,reconnectRadius:kd,defaultMarkerColor:q,noDragClassName:Cd,noWheelClassName:zd,noPanClassName:nr,rfId:Ma,disableKeyboardA11y:rr,nodeExtent:qt,viewport:Ud,onViewportChange:qd,nodesDraggable:le}),e.jsx(o0,{onSelectionChange:L}),fd,e.jsx(s0,{proOptions:Ed,position:$d}),e.jsx(t0,{rfId:Ma,disableKeyboardA11y:rr})]})})}var B1=Rc(O1);function H1({dimensions:t,lineWidth:s,variant:n,className:a}){return e.jsx("path",{strokeWidth:s,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:$e(["react-flow__background-pattern",n,a])})}function V1({radius:t,className:s}){return e.jsx("circle",{cx:t,cy:t,r:t,className:$e(["react-flow__background-pattern","dots",s])})}var Bt;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Bt||(Bt={}));const U1={[Bt.Dots]:1,[Bt.Lines]:1,[Bt.Cross]:6},q1=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function rd({id:t,variant:s=Bt.Dots,gap:n=20,size:a,lineWidth:i=1,offset:r=0,color:o,bgColor:l,style:c,className:h,patternClassName:m}){const d=f.useRef(null),{transform:u,patternId:p}=ge(q1,ke),x=a||U1[s],v=s===Bt.Dots,j=s===Bt.Cross,g=Array.isArray(n)?n:[n,n],b=[g[0]*u[2]||1,g[1]*u[2]||1],y=x*u[2],w=Array.isArray(r)?r:[r,r],S=j?[y,y]:b,$=[w[0]*u[2]||1+S[0]/2,w[1]*u[2]||1+S[1]/2],M=`${p}${t||""}`;return e.jsxs("svg",{className:$e(["react-flow__background",h]),style:{...c,...Sa,"--xy-background-color-props":l,"--xy-background-pattern-color-props":o},ref:d,"data-testid":"rf__background",children:[e.jsx("pattern",{id:M,x:u[0]%b[0],y:u[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:v?e.jsx(V1,{radius:y/2,className:m}):e.jsx(H1,{dimensions:S,lineWidth:i,variant:s,className:m})}),e.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}rd.displayName="Background";const W1=f.memo(rd);function G1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:e.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Y1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:e.jsx("path",{d:"M0 0h32v4.2H0z"})})}function X1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:e.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function K1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:e.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Z1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:e.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Dn({children:t,className:s,...n}){return e.jsx("button",{type:"button",className:$e(["react-flow__controls-button",s]),...n,children:t})}const Q1=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function od({style:t,showZoom:s=!0,showFitView:n=!0,showInteractive:a=!0,fitViewOptions:i,onZoomIn:r,onZoomOut:o,onFitView:l,onInteractiveChange:c,className:h,children:m,position:d="bottom-left",orientation:u="vertical","aria-label":p}){const x=we(),{isInteractive:v,minZoomReached:j,maxZoomReached:g,ariaLabelConfig:b}=ge(Q1,ke),{zoomIn:y,zoomOut:w,fitView:S}=tr(),$=()=>{y(),r==null||r()},M=()=>{w(),o==null||o()},z=()=>{S(i),l==null||l()},A=()=>{x.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},k=u==="horizontal"?"horizontal":"vertical";return e.jsxs(Na,{className:$e(["react-flow__controls",k,h]),position:d,style:t,"data-testid":"rf__controls","aria-label":p??b["controls.ariaLabel"],children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(Dn,{onClick:$,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:g,children:e.jsx(G1,{})}),e.jsx(Dn,{onClick:M,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:j,children:e.jsx(Y1,{})})]}),n&&e.jsx(Dn,{className:"react-flow__controls-fitview",onClick:z,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:e.jsx(X1,{})}),a&&e.jsx(Dn,{className:"react-flow__controls-interactive",onClick:A,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:v?e.jsx(Z1,{}):e.jsx(K1,{})}),m]})}od.displayName="Controls";const J1=f.memo(od);function ew({id:t,x:s,y:n,width:a,height:i,style:r,color:o,strokeColor:l,strokeWidth:c,className:h,borderRadius:m,shapeRendering:d,selected:u,onClick:p}){const{background:x,backgroundColor:v}=r||{},j=o||x||v;return e.jsx("rect",{className:$e(["react-flow__minimap-node",{selected:u},h]),x:s,y:n,rx:m,ry:m,width:a,height:i,style:{fill:j,stroke:l,strokeWidth:c},shapeRendering:d,onClick:p?g=>p(g,t):void 0})}const tw=f.memo(ew),sw=t=>t.nodes.map(s=>s.id),Qa=t=>t instanceof Function?t:()=>t;function nw({nodeStrokeColor:t,nodeColor:s,nodeClassName:n="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:r=tw,onClick:o}){const l=ge(sw,ke),c=Qa(s),h=Qa(t),m=Qa(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return e.jsx(e.Fragment,{children:l.map(u=>e.jsx(iw,{id:u,nodeColorFunc:c,nodeStrokeColorFunc:h,nodeClassNameFunc:m,nodeBorderRadius:a,nodeStrokeWidth:i,NodeComponent:r,onClick:o,shapeRendering:d},u))})}function aw({id:t,nodeColorFunc:s,nodeStrokeColorFunc:n,nodeClassNameFunc:a,nodeBorderRadius:i,nodeStrokeWidth:r,shapeRendering:o,NodeComponent:l,onClick:c}){const{node:h,x:m,y:d,width:u,height:p}=ge(x=>{const v=x.nodeLookup.get(t);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const j=v.internals.userNode,{x:g,y:b}=v.internals.positionAbsolute,{width:y,height:w}=zt(j);return{node:j,x:g,y:b,width:y,height:w}},ke);return!h||h.hidden||!ac(h)?null:e.jsx(l,{x:m,y:d,width:u,height:p,style:h.style,selected:!!h.selected,className:a(h),color:s(h),borderRadius:i,strokeColor:n(h),strokeWidth:r,shapeRendering:o,onClick:c,id:h.id})}const iw=f.memo(aw);var rw=f.memo(nw);const ow=200,lw=150,cw=t=>!t.hidden,dw=t=>{const s={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:s,boundingRect:t.nodeLookup.size>0?tc(vn(t.nodeLookup,{filter:cw}),s):s,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},Po=(t,s)=>t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height,uw=(t,s)=>Po(t.viewBB,s.viewBB)&&Po(t.boundingRect,s.boundingRect)&&t.rfId===s.rfId&&t.panZoom===s.panZoom&&t.translateExtent===s.translateExtent&&t.flowWidth===s.flowWidth&&t.flowHeight===s.flowHeight&&t.ariaLabelConfig===s.ariaLabelConfig,hw="react-flow__minimap-desc";function ld({style:t,className:s,nodeStrokeColor:n,nodeColor:a,nodeClassName:i="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:l,bgColor:c,maskColor:h,maskStrokeColor:m,maskStrokeWidth:d,position:u="bottom-right",onClick:p,onNodeClick:x,pannable:v=!1,zoomable:j=!1,ariaLabel:g,inversePan:b,zoomStep:y=1,offsetScale:w=5}){const S=we(),$=f.useRef(null),{boundingRect:M,viewBB:z,rfId:A,panZoom:k,translateExtent:C,flowWidth:_,flowHeight:L,ariaLabelConfig:N}=ge(dw,uw),T=(t==null?void 0:t.width)??ow,I=(t==null?void 0:t.height)??lw,R=M.width/T,B=M.height/I,E=Math.max(R,B),P=E*T,W=E*I,V=w*E,K=M.x-(P-M.width)/2-V,D=M.y-(W-M.height)/2-V,G=P+V*2,ee=W+V*2,te=`${hw}-${A}`,F=f.useRef(0),Y=f.useRef();F.current=E,f.useEffect(()=>{if($.current&&k)return Y.current=cb({domNode:$.current,panZoom:k,getTransform:()=>S.getState().transform,getViewScale:()=>F.current}),()=>{var O;(O=Y.current)==null||O.destroy()}},[k]),f.useEffect(()=>{var O;(O=Y.current)==null||O.update({translateExtent:C,width:_,height:L,inversePan:b,pannable:v,zoomStep:y,zoomable:j})},[v,j,b,y,C,_,L]);const Q=p?O=>{var J;const[X,Z]=((J=Y.current)==null?void 0:J.pointer(O))||[0,0];p(O,{x:X,y:Z})}:void 0,ie=x?f.useCallback((O,X)=>{const Z=S.getState().nodeLookup.get(X).internals.userNode;x(O,Z)},[]):void 0,ae=g??N["minimap.ariaLabel"];return e.jsx(Na,{position:u,style:{...t,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*E:void 0,"--xy-minimap-node-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:$e(["react-flow__minimap",s]),"data-testid":"rf__minimap",children:e.jsxs("svg",{width:T,height:I,viewBox:`${K} ${D} ${G} ${ee}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":te,ref:$,onClick:Q,children:[ae&&e.jsx("title",{id:te,children:ae}),e.jsx(rw,{onClick:ie,nodeColor:a,nodeStrokeColor:n,nodeBorderRadius:r,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:l}),e.jsx("path",{className:"react-flow__minimap-mask",d:`M${K-V},${D-V}h${G+V*2}v${ee+V*2}h${-G-V*2}z
|
|
430
|
-
M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ld.displayName="MiniMap";const mw=f.memo(ld),fw=t=>s=>t?`${Math.max(1/s.transform[2],1)}`:void 0,pw={[Ts.Line]:"right",[Ts.Handle]:"bottom-right"};function xw({nodeId:t,position:s,variant:n=Ts.Handle,className:a,style:i=void 0,children:r,color:o,minWidth:l=10,minHeight:c=10,maxWidth:h=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:u,autoScale:p=!0,shouldResize:x,onResizeStart:v,onResize:j,onResizeEnd:g}){const b=Fc(),y=typeof t=="string"?t:b,w=we(),S=f.useRef(null),$=n===Ts.Handle,M=ge(f.useCallback(fw($&&p),[$,p]),ke),z=f.useRef(null),A=s??pw[n];f.useEffect(()=>{if(!(!S.current||!y))return z.current||(z.current=wb({domNode:S.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:C,transform:_,snapGrid:L,snapToGrid:N,nodeOrigin:T,domNode:I}=w.getState();return{nodeLookup:C,transform:_,snapGrid:L,snapToGrid:N,nodeOrigin:T,paneDomNode:I}},onChange:(C,_)=>{const{triggerNodeChanges:L,nodeLookup:N,parentLookup:T,nodeOrigin:I}=w.getState(),R=[],B={x:C.x,y:C.y},E=N.get(y);if(E&&E.expandParent&&E.parentId){const P=E.origin??I,W=C.width??E.measured.width??0,V=C.height??E.measured.height??0,K={id:E.id,parentId:E.parentId,rect:{width:W,height:V,...ic({x:C.x??E.position.x,y:C.y??E.position.y},{width:W,height:V},E.parentId,N,P)}},D=er([K],N,T,I);R.push(...D),B.x=C.x?Math.max(P[0]*W,C.x):void 0,B.y=C.y?Math.max(P[1]*V,C.y):void 0}if(B.x!==void 0&&B.y!==void 0){const P={id:y,type:"position",position:{...B}};R.push(P)}if(C.width!==void 0&&C.height!==void 0){const W={id:y,type:"dimensions",resizing:!0,setAttributes:u?u==="horizontal"?"width":"height":!0,dimensions:{width:C.width,height:C.height}};R.push(W)}for(const P of _){const W={...P,type:"position"};R.push(W)}L(R)},onEnd:({width:C,height:_})=>{const L={id:y,type:"dimensions",resizing:!1,dimensions:{width:C,height:_}};w.getState().triggerNodeChanges([L])}})),z.current.update({controlPosition:A,boundaries:{minWidth:l,minHeight:c,maxWidth:h,maxHeight:m},keepAspectRatio:d,resizeDirection:u,onResizeStart:v,onResize:j,onResizeEnd:g,shouldResize:x}),()=>{var C;(C=z.current)==null||C.destroy()}},[A,l,c,h,m,d,v,j,g,x]);const k=A.split("-");return e.jsx("div",{className:$e(["react-flow__resize-control","nodrag",...k,n,a]),ref:S,style:{...i,scale:M,...o&&{[$?"backgroundColor":"borderColor"]:o}},children:r})}f.memo(xw);function gw({data:t}){return e.jsxs("div",{className:`dep-node is-${t.action||"research"}`,children:[e.jsx(Rs,{type:"target",position:he.Left,className:"dep-handle"}),e.jsx("div",{className:"dep-node-action",children:t.action}),e.jsx("div",{className:"dep-node-label",children:t.label}),e.jsxs("div",{className:"dep-node-agent",children:["@",t.agent]}),e.jsx(Rs,{type:"source",position:he.Right,className:"dep-handle"})]})}const yw={step:gw};function vw({plan:t}){const s=f.useMemo(()=>{if(!t)return[];t.steps.length;const a=new Map,i=(l,c=new Set)=>{const h=a.get(l);if(h!==void 0)return h;if(c.has(l))return 0;c.add(l);const m=t.steps.find(u=>u.id===l);if(!m||m.deps.length===0)return a.set(l,0),c.delete(l),0;let d=0;for(const u of m.deps){const p=i(u,c);p>d&&(d=p)}return a.set(l,d+1),c.delete(l),d+1};for(const l of t.steps)i(l.id);const r=new Map;for(const l of t.steps){const c=a.get(l.id)??0,h=r.get(c)||[];h.push(l.id),r.set(c,h)}const o=[];for(const[l,c]of r){const h=c.length;c.forEach((m,d)=>{const u=t.steps.find(v=>v.id===m);if(!u)return;const p=60+l*220,x=40+(d-(h-1)/2)*90;o.push({id:u.id,type:"step",position:{x:p,y:x},data:{label:u.title,action:u.action,agent:u.agent}})})}return o},[t]),n=f.useMemo(()=>t?t.steps.flatMap(a=>a.deps.map(i=>({id:`${i}->${a.id}`,source:i,target:a.id,animated:!0}))):[],[t]);return t?t.steps.length===0?e.jsxs(ne,{className:"dep-graph","data-testid":"dep-graph",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14,"aria-hidden":!0})," Dependency graph"]}),e.jsx(ue,{children:"Empty plan — nothing to render."})]}):e.jsxs(ne,{className:"dep-graph","data-testid":"dep-graph",children:[e.jsxs("div",{className:"dep-graph-header",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14,"aria-hidden":!0})," Dependency graph"]}),e.jsxs(Le,{variant:"info",children:[t.steps.length," nodes"]}),e.jsxs(Le,{variant:"accent",children:[n.length," edges"]})]}),e.jsxs(ue,{children:["Plan step DAG · ",t.goal.slice(0,80)]}),e.jsx("div",{className:"dep-graph-canvas","data-testid":"dep-graph-canvas",children:e.jsxs(B1,{nodes:s,edges:n,nodeTypes:yw,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},children:[e.jsx(W1,{gap:16,size:1}),e.jsx(J1,{showInteractive:!1}),e.jsx(mw,{pannable:!0,zoomable:!0})]})})]}):e.jsxs(ne,{className:"dep-graph","data-testid":"dep-graph",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14,"aria-hidden":!0})," Dependency graph"]}),e.jsx(ue,{children:"Submit a goal to render the dependency DAG."})]})}const jw=200;function bw(t){return t==="agent:status"?"status":t==="agent:restarted"?"restarted":t==="agent:stuck"?"stuck":t==="agent:message"?"message":"info"}function ww(t,s,n){const a=bw(t),i=`${n}-${Math.random().toString(36).slice(2,7)}`;if(t==="agent:message"){const l=(s==null?void 0:s.message)||s;return{id:i,ts:n,from:String((l==null?void 0:l.from)||"unknown"),to:String((l==null?void 0:l.to)||"unknown"),message:String((l==null?void 0:l.text)||(l==null?void 0:l.message)||JSON.stringify(l).slice(0,160)),kind:a,raw:s}}const r=(s==null?void 0:s.agent)||s,o=String((r==null?void 0:r.name)||"agent");return{id:i,ts:n,from:o,to:a==="stuck"?"orchestrator":"broadcast",message:`${t} ${r!=null&&r.status?`→ ${r.status}`:""}`.trim(),kind:a,raw:s}}function kw({maxRows:t=jw}){const[s,n]=f.useState([]);return f.useEffect(()=>{const a=new es,i=a.on(r=>{const o=r.type;if(!o||!o.startsWith("agent:"))return;const l=r,c=Number(l.ts)||Date.now();n(h=>{const m=[...h,ww(o,l,c)];return m.length>t?m.slice(m.length-t):m})});return()=>{i(),a.close()}},[t]),e.jsxs(ne,{className:"comm-log","data-testid":"communication-log",children:[e.jsxs("div",{className:"comm-log-header",children:[e.jsxs(de,{children:[e.jsx(mn,{size:14,"aria-hidden":!0})," Communication log"]}),e.jsx(Le,{variant:"neutral","data-testid":"communication-log-count",children:s.length})]}),e.jsxs(ue,{children:["Inter-agent message bus trace · bounded to ",t," rows"]}),e.jsxs("ul",{className:"comm-log-list","data-testid":"communication-log-list",children:[s.length===0&&e.jsx("li",{className:"comm-log-empty","data-testid":"communication-log-empty",children:"No agent messages yet. Stream will appear here live."}),s.slice().reverse().map(a=>e.jsxs("li",{className:`comm-log-row is-${a.kind}`,"data-testid":"communication-log-row","data-kind":a.kind,children:[e.jsxs("div",{className:"comm-log-row-meta",children:[e.jsx("span",{className:"comm-log-from",children:a.from}),e.jsx(Yo,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"comm-log-to",children:a.to}),e.jsx(Le,{variant:"neutral",className:`comm-log-kind is-${a.kind}`,children:a.kind}),e.jsx("time",{className:"comm-log-time",dateTime:new Date(a.ts).toISOString(),children:new Date(a.ts).toLocaleTimeString()})]}),e.jsx("div",{className:"comm-log-message",children:a.message})]},a.id))]})]})}const Ja=500;function Nw(t){return t.startsWith("goal:")?"success":t.startsWith("task:")?"info":t.includes("error")||t.includes("fail")?"error":t.includes("stuck")||t.includes("blocked")||t.includes("warn")?"warning":t==="ping"||t==="pong"||t==="refresh"?"control":"info"}function Sw(t,s){return s&&Object.keys(s).slice(0,3).map(a=>`${a}=${Cw(s[a])}`).join(" ")||t}function Cw(t){return t==null?"null":typeof t=="string"?t.length>20?`"${t.slice(0,20)}…"`:`"${t}"`:typeof t=="number"||typeof t=="boolean"?String(t):Array.isArray(t)?`[${t.length}]`:typeof t=="object"?`{${Object.keys(t).length}}`:String(t)}function zw(){const[t,s]=f.useState([]);f.useEffect(()=>{const a=new es,i=a.on(r=>{const o=r,l=o.type;if(!l)return;const c=Number(o.ts)||Date.now(),h={id:`${c}-${Math.random().toString(36).slice(2,7)}`,ts:c,type:l,severity:Nw(l),preview:Sw(l,o)};s(m=>{const d=[...m,h];return d.length>Ja?d.slice(d.length-Ja):d})});return()=>{i(),a.close()}},[]);const n=f.useMemo(()=>{const a={info:0,success:0,warning:0,error:0,control:0};for(const i of t)a[i.severity]+=1;return a},[t]);return e.jsxs(ne,{className:"event-log","data-testid":"event-log",children:[e.jsxs("div",{className:"event-log-header",children:[e.jsxs(de,{children:[e.jsx(Be,{size:14,"aria-hidden":!0})," Real-time events"]}),e.jsx(Le,{variant:"neutral","data-testid":"event-log-count",children:t.length})]}),e.jsxs(ue,{children:["Live WebSocket event ticker · bounded to ",Ja," rows"]}),e.jsxs("div",{className:"event-log-summary","data-testid":"event-log-summary",children:[e.jsxs(Le,{variant:"info",children:["info ",n.info]}),e.jsxs(Le,{variant:"success",children:["success ",n.success]}),e.jsxs(Le,{variant:"warning",children:["warning ",n.warning]}),e.jsxs(Le,{variant:"error",children:["error ",n.error]}),e.jsxs(Le,{variant:"neutral",children:["control ",n.control]})]}),e.jsxs("ul",{className:"event-log-list","data-testid":"event-log-list",children:[t.length===0&&e.jsx("li",{className:"event-log-empty","data-testid":"event-log-empty",children:"No events yet. Events will stream here as the server emits them."}),t.slice().reverse().map(a=>e.jsxs("li",{className:`event-log-row is-${a.severity}`,"data-testid":"event-log-row","data-severity":a.severity,children:[e.jsx("time",{className:"event-log-time",dateTime:new Date(a.ts).toISOString(),children:new Date(a.ts).toLocaleTimeString()}),e.jsx("code",{className:"event-log-type",children:a.type}),e.jsx("span",{className:"event-log-preview",children:a.preview})]},a.id))]})]})}function Mw(t){const s=t.compileCheck?{name:"Compile check",status:"passed",value:!0,threshold:!0,detail:"make check is green."}:{name:"Compile check",status:"failed",value:!1,threshold:!0,detail:"Typecheck error — fix before marking passing."},n=t.testCoverage>=80?{name:"Test coverage",status:"passed",value:t.testCoverage,threshold:80,detail:"Coverage meets the B-grade threshold."}:t.testCoverage>=60?{name:"Test coverage",status:"warning",value:t.testCoverage,threshold:80,detail:"Coverage is below the B-grade threshold."}:{name:"Test coverage",status:"failed",value:t.testCoverage,threshold:80,detail:"Coverage is critical."},a=t.archScore>=90?{name:"Arch compliance",status:"passed",value:t.archScore,threshold:90,detail:"All non-trivial arch-rules satisfied."}:t.archScore>=70?{name:"Arch compliance",status:"warning",value:t.archScore,threshold:90,detail:"Minor arch-rule violations."}:{name:"Arch compliance",status:"failed",value:t.archScore,threshold:90,detail:"Multiple arch-rule violations."},i=t.evidencePresent?{name:"Verification evidence",status:"passed",value:!0,threshold:!0,detail:"Test output + commit hash captured."}:{name:"Verification evidence",status:"failed",value:!1,threshold:!0,detail:"No evidence recorded yet."};return[s,n,a,i]}function $w({status:t}){return t==="passed"?e.jsx(Ke,{size:14,className:"qg-icon is-pass"}):t==="warning"?e.jsx(Ue,{size:14,className:"qg-icon is-warn"}):e.jsx(ls,{size:14,className:"qg-icon is-fail"})}function Ew({status:t}){return t==="passed"?e.jsx(Le,{variant:"success",children:"passed"}):t==="warning"?e.jsx(Le,{variant:"warning",children:"warning"}):e.jsx(Le,{variant:"error",children:"failed"})}function _w({plan:t,metrics:s}){const n=Mw(s),a=n.filter(i=>i.status==="passed").length;return e.jsxs(ne,{className:"qg-panel","data-testid":"quality-gates",children:[e.jsxs("div",{className:"qg-header",children:[e.jsxs(de,{children:[e.jsx(ss,{size:14,"aria-hidden":!0})," Quality gates"]}),e.jsxs(Le,{variant:a===n.length?"success":a>0?"warning":"error",children:[a,"/",n.length," passing"]})]}),e.jsxs(ue,{children:["L09 rubric (Correctness / Arch compliance / Test coverage / Verification evidence) —"," ",t?`evaluating against plan with ${t.steps.length} steps.`:"awaiting plan."]}),e.jsx("ul",{className:"qg-list","data-testid":"quality-gates-list",children:n.map(i=>e.jsxs("li",{className:`qg-row is-${i.status}`,"data-testid":"quality-gates-row","data-status":i.status,children:[e.jsxs("div",{className:"qg-row-head",children:[e.jsx($w,{status:i.status}),e.jsx("span",{className:"qg-name",children:i.name}),e.jsx(Ew,{status:i.status})]}),e.jsxs("div",{className:"qg-row-body",children:[e.jsx("span",{className:"qg-detail",children:i.detail}),typeof i.value=="number"&&e.jsxs("span",{className:"qg-threshold",children:["current: ",i.value,"% · threshold: ",i.threshold,"%"]}),typeof i.value=="boolean"&&e.jsxs("span",{className:"qg-threshold",children:["current: ",String(i.value)," · threshold: ",String(i.threshold)]})]})]},i.name))})]})}const Tw={compileCheck:"compile-check",testCoverage:"unit",archScore:"check-arch",evidencePresent:"e2e"};function Aw(t){const[s,n]=f.useState(null),[a,i]=f.useState(!1),[r,o]=f.useState(0),[l,c]=f.useState(0),[h,m]=f.useState(!1);return f.useEffect(()=>{const d=new es,u=d.on(p=>{switch(p.type){case"task:progress":o(v=>Do(v+5,0,100)),m(!0);break;case"tasks:change":m(!0);break;case"goal:planned":i(!0),o(v=>v<25?25:v),c(v=>v<30?30:v),m(!0);break;case"agents:change":case"agent:status":c(v=>Do(v+2,0,100));break}});return()=>{u(),d.close()}},[]),e.jsxs("div",{className:"goal-planner-page","data-testid":"goal-planner-page",children:[e.jsxs("header",{className:"goal-planner-header",children:[e.jsxs("div",{className:"goal-planner-title-row",children:[e.jsx(Ai,{size:20,"aria-hidden":!0}),e.jsx("h2",{children:"Goal Planner"}),e.jsx("span",{className:"badge badge-info","data-testid":"goal-planner-version",children:"v6.4.0"})]}),e.jsxs("p",{className:"goal-planner-blurb",children:[e.jsx(vt,{size:12,"aria-hidden":!0})," Type a goal in plain English. We decompose it into clauses, map each clause to a Bizar action template, and run A* over the action space to produce an executable plan. The four panels below update in real time as the harness streams events."]})]}),e.jsxs("div",{className:"goal-planner-grid",children:[e.jsx("section",{className:"goal-planner-input-row",children:e.jsx(Vx,{onPlan:n})}),e.jsx("section",{className:"goal-planner-plan-row",children:e.jsx(qx,{plan:s})}),e.jsx("section",{className:"goal-planner-panel-row",children:e.jsx(vw,{plan:s})}),e.jsx("section",{className:"goal-planner-panel-row",children:e.jsx(kw,{})}),e.jsx("section",{className:"goal-planner-panel-row",children:e.jsx(zw,{})}),e.jsx("section",{className:"goal-planner-panel-row",children:e.jsx(_w,{plan:s,metrics:{compileCheck:a,testCoverage:r,archScore:l,evidencePresent:h}})})]}),e.jsx("footer",{className:"goal-planner-footer",children:e.jsxs(ne,{children:[e.jsx(de,{children:"How this works"}),e.jsxs(ue,{children:["Rubric dimensions: ",Object.values(Tw).join(" · "),". The dependency graph uses @xyflow/react; the message bus and event ticker subscribe to the shared WebSocket feed (never a second connection)."]})]})})]})}function Do(t,s,n){return Math.max(s,Math.min(n,t))}function Rw(t){return e.jsx(Aw,{...t})}const ei={overview:mm,chat:Em,agents:Tm,artifacts:rf,memory:qp,tasks:yf,activity:Mf,background:gx,config:kr,settings:kr,mods:Kf,schedules:cp,skills:gp,history:Gp,minimax:sx,doctor:_x,harness:Ax,eval:Px,evalReport:Hx,"goal-planner":Rw},Iw="v6.0.0";function Lw(t,s,n,a){if(ei[t]){const o=ei[t];return e.jsx(o,{...s})}const i=n.find(o=>o.id===t);if(i)return e.jsx(Qf,{viewId:i.id,reloadKey:a,activeTab:s.activeTab,setActiveTab:s.setActiveTab});const r=ei.overview;return e.jsx(r,{...s})}function Pw({onSaved:t}){const[s,n]=f.useState(""),a=f.useRef(null);f.useEffect(()=>{var o;(o=a.current)==null||o.focus()},[]);const i=()=>{const o=s.trim();o&&(H.setToken(o),t())},r=o=>{o.key==="Escape"&&(o.preventDefault(),t()),o.key==="Enter"&&(o.preventDefault(),i())};return e.jsxs("form",{className:"token-entry-form",onSubmit:o=>{o.preventDefault(),i()},children:[e.jsxs("div",{className:"token-entry-row",children:[e.jsx("input",{ref:a,type:"password",className:"input mono",value:s,onChange:o=>n(o.target.value),placeholder:"Paste auth token",spellCheck:!1,autoComplete:"off",onKeyDown:r}),e.jsx(U,{type:"submit",variant:"primary",size:"sm",disabled:!s.trim(),children:"Save & retry"})]}),e.jsxs("p",{className:"token-entry-hint",children:["Where do I find this token? Check the file"," ",e.jsx("code",{children:"~/.config/bizar/dashboard-secret"})," on the machine running the dashboard, or look for it in the server output."]})]})}function Dw(){return e.jsx(hu,{children:e.jsx(yh,{children:e.jsx(Fw,{})})})}function Fw(){var Q,ie,ae;const t=fe(),s=Ze(),{isModalOpen:n}=s,a=f.useRef(!1),[i,r]=f.useState("overview"),[o,l]=f.useState(null),[c,h]=f.useState(null),[m,d]=f.useState("connecting"),[u,p]=f.useState(null),[x,v]=f.useState(!1),[j,g]=f.useState(null),[b,y]=f.useState(!1),[w,S]=f.useState(!1),[$,M]=f.useState([]),[z,A]=f.useState(!1),[k,C]=f.useState([]),[_,L]=f.useState(0),N=f.useRef(null),[T,I]=f.useState(null);f.useEffect(()=>{let O=!1;return(async()=>{try{const X=await H.get("/mods/views");if(O)return;C(X.views||[])}catch{O||C([])}})(),()=>{O=!0}},[_,o==null?void 0:o.mods]),f.useEffect(()=>{if(!T)return;const O=T.on(X=>{((X==null?void 0:X.type)==="mod:change"||(X==null?void 0:X.type)==="mod:enabled"||(X==null?void 0:X.type)==="mod:installed")&&L(Z=>Z+1)});return()=>O()},[T]),f.useEffect(()=>{c!=null&&c.theme&&(Ys(c.theme),fs(c.theme))},[c==null?void 0:c.theme]),f.useEffect(()=>{a.current=n},[n]),f.useEffect(()=>{var Z;if(((Z=c==null?void 0:c.theme)==null?void 0:Z.mode)!=="system")return;const O=window.matchMedia("(prefers-color-scheme: light)"),X=()=>Ys(c.theme.mode);return O.addEventListener("change",X),()=>O.removeEventListener("change",X)},[(Q=c==null?void 0:c.theme)==null?void 0:Q.mode]);const R=f.useCallback(async()=>{let O=!1;const X=()=>Promise.all([H.get("/snapshot").catch(()=>null),H.get("/settings").catch(()=>null),H.get("/agents/stuck").catch(()=>null)]),Z=(J,le,ce)=>{J&&l(J),le!=null&&le.data&&h(le.data),ce!=null&&ce.stuck&&M(ce.stuck)};try{const J=await H.probeAuthStatus(),[le,ce,me]=await X();if(Z(le,ce,me),le||ce){p(null);return}if(!J.loopback){p("Dashboard server unreachable.");return}await new Promise(We=>setTimeout(We,1e3));const[be,Ne,Me]=await X();Z(be,Ne,Me),!be&&!Ne&&p("Dashboard server unreachable.")}catch(J){const le=(J==null?void 0:J.message)??"unknown error";if(J instanceof cu&&J.status===401){p(le),y(!0),t.error(`Auth required: ${le}`);return}p(le),t.error(`Failed to load: ${le}`)}},[t]);f.useEffect(()=>{let O=!1;const X=setTimeout(()=>{O||R()},0);return()=>{O=!0,clearTimeout(X)}},[R]),f.useEffect(()=>{let O=!1;return H.get("/settings").then(X=>{var J,le;if(O)return;const Z=(le=(J=X==null?void 0:X.data)==null?void 0:J.ui)==null?void 0:le.defaultTab;Z&&r(Z)}).catch(()=>{}),()=>{O=!0}},[]),f.useEffect(()=>{let O=!1;const X=async()=>{try{const J=await H.get("/agents/stuck");O||M(le=>{const ce=J.stuck||[];return le.length===0&&ce.length>0&&t.warning(`${ce.length} agent${ce.length===1?"":"s"} stuck`,5e3),ce})}catch{}},Z=setInterval(X,3e4);return X(),()=>{O=!0,clearInterval(Z)}},[]),f.useEffect(()=>{const O=new es;N.current=O,I(O);const X=O.onStatus(J=>d(J)),Z=O.on(J=>{var le;if(J.type==="snapshot"&&"data"in J&&J.data)l(ce=>({...ce??{},...J.data}));else if(J.type==="change"){const ce=J,me=((le=ce.path)==null?void 0:le.split("/").pop())||ce.path||"";t.info(`File changed: ${me}`,2500)}else if(J.type==="tasks:change"){const ce=J;l(me=>{if(!me)return me;const be=(me.tasks||[]).map(Me=>Me.id===ce.task.id?ce.task:Me),Ne=be.some(Me=>Me.id===ce.task.id);return{...me,tasks:Ne?be:[ce.task,...be]}})}else if(J.type==="tasks:delete"){const ce=J;l(me=>me&&{...me,tasks:(me.tasks||[]).filter(be=>be.id!==ce.id)})}else if(J.type==="settings:change"){const ce=J;ce.settings&&h(ce.settings)}else if(J.type==="project:change")H.get("/snapshot").then(ce=>l(me=>({...me??{},...ce}))).catch(()=>{});else if(J.type==="agents:change"||J.type==="schedules:change")H.get("/snapshot").then(ce=>l(me=>({...me??{},...ce}))).catch(()=>{});else if(J.type==="agent:status"||J.type==="agent:restarted"){const ce=J;l(me=>{if(!me)return me;const be=(me.agents||[]).map(Ne=>Ne.name===ce.agent.name?ce.agent:Ne);return{...me,agents:be}})}else if(J.type==="artifact:change")H.get("/artifacts").then(ce=>{l(me=>me&&{...me,artifacts:ce.artifacts||[]})}).catch(()=>{});else if(J.type==="agent:stuck")M(J.agents||[]);else if(J.type==="dialog:show"){const ce=J;ce.dialog&&s.open({title:ce.dialog.title,width:520,children:e.jsx(Wh,{dialog:ce.dialog,onClose:()=>s.close()})})}});return()=>{X(),Z(),O.close(),I(null)}},[t]);const B=f.useCallback(O=>T?T.on(O):()=>{},[T]),E=f.useRef(0);f.useEffect(()=>{const O=()=>{E.current=Date.now()+1500};return document.addEventListener("mousedown",O,!0),document.addEventListener("click",O,!0),document.addEventListener("focusin",O,!0),document.addEventListener("keydown",O,!0),()=>{document.removeEventListener("mousedown",O,!0),document.removeEventListener("click",O,!0),document.removeEventListener("focusin",O,!0),document.removeEventListener("keydown",O,!0)}},[]),f.useEffect(()=>{const O={};ni.forEach((Z,J)=>{O[String(J+1)]=Z.id});const X=Z=>{var We,Qe,Pe,Oe;if((Z.metaKey||Z.ctrlKey)&&Z.key.toLowerCase()==="k"){Z.preventDefault(),S(!0);return}if(Z.key==="/"&&!Z.metaKey&&!Z.ctrlKey){const Ge=(Qe=(We=Z.target)==null?void 0:We.tagName)==null?void 0:Qe.toLowerCase();if(Ge!=="input"&&Ge!=="textarea"&&!((Pe=Z.target)!=null&&Pe.isContentEditable)){Z.preventDefault(),S(!0);return}}const J=document.activeElement;if(!J||J===document.body||J===document.documentElement)return;const ce=Z.target,me=(Oe=ce==null?void 0:ce.tagName)==null?void 0:Oe.toLowerCase(),be=me==="input"||me==="textarea"||me==="select"||me==="button"||me==="option"||me==="label"||!!(ce!=null&&ce.isContentEditable);let Ne=!1;if(ce&&typeof ce.closest=="function"&&(Ne=!!ce.closest('form, [role="dialog"], [contenteditable], [data-no-key]')),Z.repeat||a.current||be||Ne||Z.metaKey||Z.ctrlKey||Z.altKey||Z.shiftKey||Date.now()<E.current)return;const Me=O[Z.key];Me&&(Z.preventDefault(),W(Me))};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[]);const P=f.useMemo(()=>async()=>{try{const O=await H.get("/snapshot");l(X=>({...X??{},...O}))}catch(O){t.error(`Refresh failed: ${O.message}`)}},[t]),W=f.useCallback(O=>{r(O),v(O==="settings")},[]),V=f.useMemo(()=>{const O=k.map(X=>({id:X.id,label:X.label,icon:X.kind==="iframe"?Qs:Js,isMod:!0,modId:X.modId}));return[...ni,...O]},[k]),K=f.useMemo(()=>({state:"active",label:"in-process",detail:"ClineCore running in-process (v6.0.0, no subprocess)"}),[]),D=f.useMemo(()=>o&&c?Lw(i,{snapshot:o,settings:c,activeTab:i,setActiveTab:W,refreshSnapshot:P,settingsMode:x,settingsActiveSection:j,setSettingsActiveSection:g},k,_):null,[i,o,c,k,_,P,x,j,g,W]),G=async()=>{try{const O=await H.get("/projects");l(X=>{var Z;return X&&{...X,projects:O.projects||[],activeProject:((Z=O.projects)==null?void 0:Z.find(J=>J.id===O.active))||null}})}catch(O){t.error(`Projects refresh failed: ${O.message}`)}},ee=async O=>{try{await H.post(`/projects/${encodeURIComponent(O)}/activate`),l(X=>X&&{...X,activeProject:X.projects.find(Z=>Z.id===O)||null})}catch(X){t.error(`Activate failed: ${X.message}`)}},te=O=>{const X=O.type;if(X==="agent")W("agents");else if(X==="task")W("tasks");else if(X==="mod")W("mods");else if(X==="schedule")W("schedules");else if(X==="project"){const Z=O.item.id;ee(Z)}else if(X==="command")t.info(`/${O.item.name} — run from the TUI`,2500);else if(X==="setting"){const Z=O.item.id||O.item.path||"";W("settings");const J=le=>{if(le<=0)return;const ce=Z?document.querySelector(`[data-setting-id="${CSS.escape(Z)}"]`):null;ce?(ce.scrollIntoView({behavior:"smooth",block:"center"}),ce.classList.remove("setting-flash"),ce.offsetWidth,ce.classList.add("setting-flash"),window.setTimeout(()=>ce.classList.remove("setting-flash"),1500)):window.setTimeout(()=>J(le-1),80)};window.setTimeout(()=>J(15),60)}},F=((ie=c==null?void 0:c.ui)==null?void 0:ie.layout)||"topnav",Y=((ae=c==null?void 0:c.ui)==null?void 0:ae.showHeader)!==!1;return e.jsxs("div",{className:"app","data-layout":F,"data-active-tab":i,children:[e.jsx("a",{className:"skip-to-main",href:"#main-content",children:"Skip to main content"}),Y&&e.jsx($h,{activeTab:i,onTabChange:W,wsStatus:m,version:Iw,activeProject:(o==null?void 0:o.activeProject)||null,projects:(o==null?void 0:o.projects)||[],onProjectChange:ee,onProjectsRefresh:G,onOpenSearch:()=>S(!0),settings:c,notificationsSlot:e.jsx(Dh,{wsSubscribe:B}),showTabs:F==="topnav",extraTabs:V,clineStatus:K}),$.length>0&&!z&&e.jsxs("div",{className:"stuck-banner",role:"alert",children:[e.jsx(Ue,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:$.length})," agent",$.length===1?"":"s"," stuck:"," ",e.jsx("span",{className:"mono",children:$.map(O=>O.name).join(", ")})]}),e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>{W("agents"),A(!0)},children:"Review"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Dismiss",onClick:()=>A(!0),children:e.jsx(Re,{size:14})})]}),e.jsxs("div",{className:"layout-body",children:[F!=="topnav"&&e.jsx(Rh,{tabs:V,activeTab:i,onTabChange:W,settingsMode:x,settingsActiveSection:j,onSettingsSectionChange:g,onExitSettings:()=>W("overview")}),e.jsxs("main",{className:"content",id:"main-content",tabIndex:-1,children:[u&&e.jsxs("div",{className:"boot-error",children:[e.jsx("h2",{children:"Dashboard unavailable"}),e.jsx("p",{children:u}),b&&e.jsx(Pw,{onSaved:()=>{y(!1),R()}}),e.jsxs("p",{className:"boot-error-hint",children:["Make sure the Bizar dashboard server is running. Try"," ",e.jsx("code",{children:"bizar-dash start"})," in your terminal."]})]}),!u&&(!o||!c)&&e.jsxs("div",{className:"loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading Bizar…"})]}),D&&e.jsx(f.Suspense,{fallback:e.jsxs("div",{className:"loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading…"})]}),children:e.jsx(Ow,{children:D})})]})]}),e.jsx(Ih,{open:w,onClose:()=>S(!1),onSelect:te})]})}class Ow extends f.Component{constructor(){super(...arguments);Ps(this,"state",{err:null});Ps(this,"reset",()=>this.setState({err:null}))}static getDerivedStateFromError(n){return{err:n}}componentDidCatch(n,a){At.error("[ViewErrorBoundary] caught render error:",n,a==null?void 0:a.componentStack)}render(){return this.state.err?e.jsxs("div",{className:"view-error-fallback",role:"alert",children:[e.jsx(Ue,{size:20}),e.jsxs("div",{className:"view-error-body",children:[e.jsx("strong",{children:"This view crashed."}),e.jsx("pre",{children:this.state.err.message}),e.jsx(U,{variant:"secondary",size:"sm",onClick:this.reset,children:"Retry"})]})]}):this.props.children}}function Bw(){const[t,s]=f.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-width: 767px)").matches);return f.useEffect(()=>{const n=window.matchMedia("(max-width: 767px)"),a=i=>s(i.matches);return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[]),t?e.jsx(uu,{}):e.jsx(Dw,{})}const cd=document.getElementById("root");if(!cd)throw new Error("Root element #root not found");du(cd).render(e.jsx(f.StrictMode,{children:e.jsx(Bw,{})}));
|