@wrongstack/webui 0.297.0 → 0.298.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/dist/assets/AgentRosterView-C8j2NuD1.js +11 -0
- package/dist/assets/{AnalyticsDashboard-CkceglT6.js → AnalyticsDashboard-D2_HYmYw.js} +1 -1
- package/dist/assets/AudienceMemoryPanel-SzXptIQj.js +3 -0
- package/dist/assets/{ChangesView-DouwIaDk.js → ChangesView-D31wr7_h.js} +1 -1
- package/dist/assets/ChronicleDashboard-B7P4f1hr.js +1 -0
- package/dist/assets/CodeEditor-BRDwx8Y-.js +1 -0
- package/dist/assets/CodeMap-uabWaeJH.js +1 -0
- package/dist/assets/{CronJobsPanel-CAImDL8t.js → CronJobsPanel-C9shS0P2.js} +1 -1
- package/dist/assets/DeadCodeScanPanel-CHud_Ugp.js +2 -0
- package/dist/assets/{DebugDashboard-DLNPZIEI.js → DebugDashboard-DmqpGXnx.js} +1 -1
- package/dist/assets/{DesignGalleryView-D0azMq2e.js → DesignGalleryView-CnAHpKa1.js} +1 -1
- package/dist/assets/GoalView-DaptZIKr.js +1 -0
- package/dist/assets/KanbanView-DA5Ulb8C.js +3 -0
- package/dist/assets/MailboxDetailView-CQtHeWVs.js +1 -0
- package/dist/assets/MemoryManager-BWuSS0Pg.js +1 -0
- package/dist/assets/{ModelPicker-CN-UD3lc.js → ModelPicker-Dt0wCi90.js} +1 -1
- package/dist/assets/OfficeMapPanel-CUNRI3X7.js +4 -0
- package/dist/assets/{ProcessMonitor-ButM8C0T.js → ProcessMonitor-Dq760Vqm.js} +1 -1
- package/dist/assets/QueuePanel-ZcJliKcY.js +1 -0
- package/dist/assets/{RefreshDebugView-DVvWsh9A.js → RefreshDebugView-SivBV0LN.js} +1 -1
- package/dist/assets/SageTabs-CGrc4PuM.js +2 -0
- package/dist/assets/SddHub-oU47Hv8Y.js +2 -0
- package/dist/assets/SessionsDashboard-Dp-Mr844.js +1 -0
- package/dist/assets/SetupScreen-BWA_dTU0.js +1 -0
- package/dist/assets/SkillDetailView-DmRgd_uu.js +3 -0
- package/dist/assets/{SpecsView-BJs_okSx.js → SpecsView-CzYtHNbj.js} +1 -1
- package/dist/assets/TechStackView-p9PKj9pQ.js +1 -0
- package/dist/assets/{TerminalPanel-W2V0X7b9.js → TerminalPanel-BRSYloOD.js} +1 -1
- package/dist/assets/{Toaster-CbcX_Cou.js → Toaster-Bd6ckyrP.js} +1 -1
- package/dist/assets/{activity-CbbZyUMG.js → activity-Bo6DncWg.js} +1 -1
- package/dist/assets/{activity-C4z6-WoZ.js → activity-C34aPcFU.js} +1 -1
- package/dist/assets/{activity-B4Ngvkan.js → activity-CBdzUJQ_.js} +1 -1
- package/dist/assets/{activity-B8uejnae.js → activity-CLYyxeC6.js} +1 -1
- package/dist/assets/{activity-qoJ3grs0.js → activity-Cv_EIWjY.js} +1 -1
- package/dist/assets/{activity-B5MvPWYV.js → activity-Wr0_Gb8A.js} +1 -1
- package/dist/assets/{activity-D57y5l1T.js → activity-kCY0dGRC.js} +1 -1
- package/dist/assets/{button-uGqXvobk.js → button-Clh96jMK.js} +1 -1
- package/dist/assets/chat-store-CWhuSNod.js +17 -0
- package/dist/assets/{codemap-activity-store-DP3mCZu1.js → codemap-activity-store-C1XWbXeZ.js} +1 -1
- package/dist/assets/codemap-index-store-DDT3gP6t.js +1 -0
- package/dist/assets/common-BfVFjVhf.js +1 -0
- package/dist/assets/common-C5hY-d_0.js +1 -0
- package/dist/assets/{dialog-CT1PTjzK.js → dialog-DYJUM0p1.js} +1 -1
- package/dist/assets/{empty-state-CdyXy96A.js → empty-state-BV-Y8c35.js} +1 -1
- package/dist/assets/{i18n-1BkaqMgr.js → i18n-DOuSY1L8.js} +2 -2
- package/dist/assets/index-C09Opuro.css +1 -0
- package/dist/assets/index-DxZTscTk.js +132 -0
- package/dist/assets/{input-B-VCX2sG.js → input-CW-Yw2Wu.js} +1 -1
- package/dist/assets/{mailbox-store-DVoNbOZr.js → mailbox-store-_8voaug1.js} +1 -1
- package/dist/assets/markdown-sSmz-Ua_.js +44 -0
- package/dist/assets/{progress-ring-CFOvGxw7.js → progress-ring-DPV94fM-.js} +1 -1
- package/dist/assets/{roster-ws-DXm0krqH.js → roster-ws-q8Cp6us7.js} +1 -1
- package/dist/assets/session-store-D4JWBP5w.js +1 -0
- package/dist/assets/settings-B9EPDhAL.js +1 -0
- package/dist/assets/{settings-DEmKlLmn.js → settings-BBNOO9wC.js} +1 -1
- package/dist/assets/settings-BoXoFVdx.js +1 -0
- package/dist/assets/settings-CkXKHC77.js +1 -0
- package/dist/assets/settings-DWIDXI2K.js +1 -0
- package/dist/assets/settings-r_KOGrbF.js +1 -0
- package/dist/assets/settings-tyKsHhya.js +1 -0
- package/dist/assets/{shared-jvJxtKc5.js → shared-DidGznBo.js} +1 -1
- package/dist/assets/stores-CpZiOiOP.js +7 -0
- package/dist/assets/ui-store-C-oyG_br.js +1 -0
- package/dist/assets/useWebSocket-BTXT0rOW.js +28 -0
- package/dist/assets/{utils-CN2sfDVP.js → utils-DxDx8yib.js} +1 -1
- package/dist/assets/{vendor-2VBBgNb5.js → vendor-BTDGplXK.js} +28 -28
- package/dist/assets/{view-navigation-Cgy5xh9q.js → view-navigation-BRtuAwZo.js} +1 -1
- package/dist/assets/ws-client-DqIqzkfU.js +1 -0
- package/dist/components/ChatInput/refine-panel-host.d.ts +9 -1
- package/dist/components/DeadCodeScanPanel/DeadCodeScanPanel.d.ts +1 -3
- package/dist/components/PanelSuspense.d.ts +8 -0
- package/dist/components/SettingsPanel/DisplaySection.d.ts +20 -0
- package/dist/components/ViewRouter.d.ts +12 -0
- package/dist/components/WorkbenchTopbar.d.ts +53 -0
- package/dist/components/codemap-model.d.ts +2 -0
- package/dist/hooks/useViewport.d.ts +38 -0
- package/dist/hooks/useWebSocket.d.ts +1 -0
- package/dist/index.html +24 -25
- package/dist/index.js +55560 -54349
- package/dist/lib/view-navigation.d.ts +1 -1
- package/dist/lib/ws-client.d.ts +16 -8
- package/dist/providers.json +10 -0
- package/dist/stores/chat-store.d.ts +36 -3
- package/dist/stores/config-store.d.ts +0 -2
- package/dist/stores/local-prefs.d.ts +20 -0
- package/dist/stores/session-store.d.ts +3 -0
- package/dist/stores/ui-store.d.ts +8 -1
- package/dist/types/client-message.d.ts +1 -0
- package/dist/types/connections.d.ts +7 -1
- package/dist/types/system.d.ts +4 -0
- package/package.json +8 -7
- package/dist/App.d.ts.map +0 -1
- package/dist/assets/AgentRosterView-Cje2NBtU.js +0 -11
- package/dist/assets/AudienceMemoryPanel-DB-8ISNP.js +0 -3
- package/dist/assets/ChronicleDashboard-B4Khm6hu.js +0 -1
- package/dist/assets/CodeEditor-CrKbA5s8.js +0 -1
- package/dist/assets/CodeMap-Dz8yNlUe.js +0 -1
- package/dist/assets/DeadCodeScanPanel-C5ehBTQF.js +0 -2
- package/dist/assets/GoalView-gtQRK78W.js +0 -1
- package/dist/assets/KanbanView-BXKe19EI.js +0 -3
- package/dist/assets/LazyMarkdown-BGwFjYKr.js +0 -3
- package/dist/assets/MailboxDetailView-D4fXipos.js +0 -1
- package/dist/assets/MemoryManager-D_rquas9.js +0 -1
- package/dist/assets/OfficeMapPanel-CJFrTNmg.js +0 -4
- package/dist/assets/QueuePanel-C5oihwYM.js +0 -1
- package/dist/assets/SageTabs-C9vAgvCD.js +0 -2
- package/dist/assets/SddHub-D_nsWjuM.js +0 -2
- package/dist/assets/SessionsDashboard-DdwU3Ma5.js +0 -1
- package/dist/assets/SetupScreen-CQCfLdPI.js +0 -1
- package/dist/assets/SkillDetailView-mVxi-9jo.js +0 -3
- package/dist/assets/TechStackView-BZ4M7TYc.js +0 -1
- package/dist/assets/chat-store-CM1dMeuY.js +0 -17
- package/dist/assets/codemap-index-store-DyAe3ZYJ.js +0 -1
- package/dist/assets/common-D8_r1x8x.js +0 -1
- package/dist/assets/common-suUxW9sA.js +0 -1
- package/dist/assets/index-BPfIz78e.js +0 -131
- package/dist/assets/index-BlceaIyu.css +0 -1
- package/dist/assets/markdown-L6DLSM7f.js +0 -44
- package/dist/assets/session-store-BsNYnfOc.js +0 -1
- package/dist/assets/settings-C5F2tQ7C.js +0 -1
- package/dist/assets/settings-Cdk8i_p6.js +0 -1
- package/dist/assets/settings-D6wFOw5n.js +0 -1
- package/dist/assets/settings-DCEOkxYE.js +0 -1
- package/dist/assets/settings-DsflqNn0.js +0 -1
- package/dist/assets/settings-skShEZ2B.js +0 -1
- package/dist/assets/stores-mpa0202y.js +0 -6
- package/dist/assets/ui-store-CS-njcmT.js +0 -1
- package/dist/assets/useWebSocket-Dh3aAFDE.js +0 -28
- package/dist/assets/ws-client-WVGn8ORh.js +0 -1
- package/dist/components/AgentOfficeDetails.d.ts.map +0 -1
- package/dist/components/AgentOfficeView/model.d.ts.map +0 -1
- package/dist/components/AgentOfficeView.d.ts.map +0 -1
- package/dist/components/AgentRosterCatalogTab.d.ts.map +0 -1
- package/dist/components/AgentRosterChrome.d.ts.map +0 -1
- package/dist/components/AgentRosterLiveTab.d.ts.map +0 -1
- package/dist/components/AgentRosterSelfLearningTab.d.ts.map +0 -1
- package/dist/components/AgentRosterView.d.ts.map +0 -1
- package/dist/components/AgentRuntimePolicyEditor.d.ts.map +0 -1
- package/dist/components/AgentTranscript.d.ts.map +0 -1
- package/dist/components/AgentsMonitor.d.ts.map +0 -1
- package/dist/components/AgentsPage/format.d.ts.map +0 -1
- package/dist/components/AgentsPage.d.ts.map +0 -1
- package/dist/components/AnalyticsDashboard.d.ts.map +0 -1
- package/dist/components/AudienceMemoryPanel.d.ts.map +0 -1
- package/dist/components/AutonomyPicker.d.ts.map +0 -1
- package/dist/components/AvailabilityCalendarEditor.d.ts.map +0 -1
- package/dist/components/BoardView.d.ts.map +0 -1
- package/dist/components/ChangesView.d.ts.map +0 -1
- package/dist/components/ChatInput/code-detect.d.ts.map +0 -1
- package/dist/components/ChatInput/draft-token-counter.d.ts.map +0 -1
- package/dist/components/ChatInput/file-mention-picker.d.ts.map +0 -1
- package/dist/components/ChatInput/image-attach-control.d.ts.map +0 -1
- package/dist/components/ChatInput/image-attachments.d.ts.map +0 -1
- package/dist/components/ChatInput/queued-messages.d.ts.map +0 -1
- package/dist/components/ChatInput/refine-panel-host.d.ts.map +0 -1
- package/dist/components/ChatInput/slash-commands.d.ts.map +0 -1
- package/dist/components/ChatInput/slash-popup.d.ts.map +0 -1
- package/dist/components/ChatInput/slash-routing.d.ts.map +0 -1
- package/dist/components/ChatInput/stop-controls.d.ts.map +0 -1
- package/dist/components/ChatInput/use-paste-drop.d.ts.map +0 -1
- package/dist/components/ChatInput.d.ts.map +0 -1
- package/dist/components/ChatView/ThinkingBubble.d.ts.map +0 -1
- package/dist/components/ChatView/index.d.ts.map +0 -1
- package/dist/components/ChatView/utils.d.ts.map +0 -1
- package/dist/components/ChatView.d.ts.map +0 -1
- package/dist/components/CheckpointTimeline.d.ts.map +0 -1
- package/dist/components/ChipMultiSelect.d.ts.map +0 -1
- package/dist/components/ChronicleDashboard.d.ts.map +0 -1
- package/dist/components/ChroniclePipelineStrip.d.ts.map +0 -1
- package/dist/components/CodeEditor.d.ts.map +0 -1
- package/dist/components/CodeMap.d.ts.map +0 -1
- package/dist/components/CodeMapActivityDrawer.d.ts.map +0 -1
- package/dist/components/CodeMapActivityHelpers.d.ts.map +0 -1
- package/dist/components/CodeMapActivityStreamPanel.d.ts.map +0 -1
- package/dist/components/CodeMapCanvasSurface.d.ts.map +0 -1
- package/dist/components/CodeMapCanvasToolbar.d.ts.map +0 -1
- package/dist/components/CodeMapConfig.d.ts.map +0 -1
- package/dist/components/CodeMapDirectoryTree.d.ts.map +0 -1
- package/dist/components/CodeMapFlowState.d.ts.map +0 -1
- package/dist/components/CodeMapHeader.d.ts.map +0 -1
- package/dist/components/CodeMapLiveOverlay.d.ts.map +0 -1
- package/dist/components/CodeMapRelationInspector.d.ts.map +0 -1
- package/dist/components/CodeMapRelations.d.ts.map +0 -1
- package/dist/components/CodeMapSearchResults.d.ts.map +0 -1
- package/dist/components/CodeMapSelectedNodeSummary.d.ts.map +0 -1
- package/dist/components/CodeMapTreeSidebar.d.ts.map +0 -1
- package/dist/components/CodeMapVisuals.d.ts.map +0 -1
- package/dist/components/CollabPanel.d.ts.map +0 -1
- package/dist/components/CommandPalette/export-utils.d.ts.map +0 -1
- package/dist/components/CommandPalette/index.d.ts.map +0 -1
- package/dist/components/CommandPalette.d.ts.map +0 -1
- package/dist/components/ConfirmDialog.d.ts.map +0 -1
- package/dist/components/ConfirmModal.d.ts.map +0 -1
- package/dist/components/ConnectionBanner.d.ts.map +0 -1
- package/dist/components/ContextBar.d.ts.map +0 -1
- package/dist/components/ContextBreakdownModal.d.ts.map +0 -1
- package/dist/components/ContextDashboard.d.ts.map +0 -1
- package/dist/components/ContextMemoryMonitor.d.ts.map +0 -1
- package/dist/components/ContextModePicker.d.ts.map +0 -1
- package/dist/components/CostChip.d.ts.map +0 -1
- package/dist/components/CronJobsPanel.d.ts.map +0 -1
- package/dist/components/CronTrigger.d.ts.map +0 -1
- package/dist/components/CustomRosterPanel.d.ts.map +0 -1
- package/dist/components/DeadCodeScanPanel/DeadCodeScanPanel.d.ts.map +0 -1
- package/dist/components/DebugDashboard.d.ts.map +0 -1
- package/dist/components/DependencyGraph.d.ts.map +0 -1
- package/dist/components/DesignGalleryView.d.ts.map +0 -1
- package/dist/components/DiffView.d.ts.map +0 -1
- package/dist/components/ErrorBoundary.d.ts.map +0 -1
- package/dist/components/FallbackEditor.d.ts.map +0 -1
- package/dist/components/FileActivityDrawer.d.ts.map +0 -1
- package/dist/components/FileExplorer.d.ts.map +0 -1
- package/dist/components/FilePicker.d.ts.map +0 -1
- package/dist/components/FileReferenceChip.d.ts.map +0 -1
- package/dist/components/FleetMonitor.d.ts.map +0 -1
- package/dist/components/FleetPanel.d.ts.map +0 -1
- package/dist/components/GoalPanel.d.ts.map +0 -1
- package/dist/components/GoalView.d.ts.map +0 -1
- package/dist/components/InspectorPanel.d.ts.map +0 -1
- package/dist/components/KanbanAgentRunPanel.d.ts.map +0 -1
- package/dist/components/KanbanBoardChrome.d.ts.map +0 -1
- package/dist/components/KanbanBoardSidebar.d.ts.map +0 -1
- package/dist/components/KanbanBoardState.d.ts.map +0 -1
- package/dist/components/KanbanBoundaryEditor.d.ts.map +0 -1
- package/dist/components/KanbanCleanerAlert.d.ts.map +0 -1
- package/dist/components/KanbanColumnView.d.ts.map +0 -1
- package/dist/components/KanbanDecompositionPanel.d.ts.map +0 -1
- package/dist/components/KanbanQueueHealthBar.d.ts.map +0 -1
- package/dist/components/KanbanRunControls.d.ts.map +0 -1
- package/dist/components/KanbanTaskActivityRecorder.d.ts.map +0 -1
- package/dist/components/KanbanTaskCompletionChecks.d.ts.map +0 -1
- package/dist/components/KanbanTaskFields.d.ts.map +0 -1
- package/dist/components/KanbanTaskInspector.d.ts.map +0 -1
- package/dist/components/KanbanTaskOptions.d.ts.map +0 -1
- package/dist/components/KanbanTaskTree.d.ts.map +0 -1
- package/dist/components/KanbanVerificationDashboard.d.ts.map +0 -1
- package/dist/components/KanbanView.d.ts.map +0 -1
- package/dist/components/KanbanViewModeTabs.d.ts.map +0 -1
- package/dist/components/MailboxDetailView.d.ts.map +0 -1
- package/dist/components/MailboxPanel.d.ts.map +0 -1
- package/dist/components/MemoryManager/DeleteMemoryDialog.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryDetail.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryDrawer.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryEditor.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryFilters.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryGraph.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryInjectorTrace.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryLifecycleTrace.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryList.d.ts.map +0 -1
- package/dist/components/MemoryManager/MemoryManagerEmpty.d.ts.map +0 -1
- package/dist/components/MemoryManager/SageTabs.d.ts.map +0 -1
- package/dist/components/MemoryManager/index.d.ts.map +0 -1
- package/dist/components/MemoryManager/selectors.d.ts.map +0 -1
- package/dist/components/MemoryManager/shared.d.ts.map +0 -1
- package/dist/components/MessageBubble/AttachmentGallery.d.ts.map +0 -1
- package/dist/components/MessageBubble/CopyButton.d.ts.map +0 -1
- package/dist/components/MessageBubble/ErrorBody.d.ts.map +0 -1
- package/dist/components/MessageBubble/LazyMarkdown.d.ts.map +0 -1
- package/dist/components/MessageBubble/StreamingMarkdown.d.ts.map +0 -1
- package/dist/components/MessageBubble/ToolInputView.d.ts.map +0 -1
- package/dist/components/MessageBubble/ToolLedgerCard.d.ts.map +0 -1
- package/dist/components/MessageBubble/index.d.ts.map +0 -1
- package/dist/components/MessageBubble/utils.d.ts.map +0 -1
- package/dist/components/MessageBubble.d.ts.map +0 -1
- package/dist/components/ModePicker.d.ts.map +0 -1
- package/dist/components/ModelPickDialog.d.ts.map +0 -1
- package/dist/components/ModelPicker.d.ts.map +0 -1
- package/dist/components/ModelSelectDialog.d.ts.map +0 -1
- package/dist/components/MonacoDiffView.d.ts.map +0 -1
- package/dist/components/NextStepsBar.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/CanvasPanels.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/Hud.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/Overlays.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/SelectedNodeDetailPanel.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/edges.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/nodes.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/resolve.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/use-recently-finished.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas/utils.d.ts.map +0 -1
- package/dist/components/OfficeMapCanvas.d.ts.map +0 -1
- package/dist/components/OfficeMapPanel.d.ts.map +0 -1
- package/dist/components/OfficeMapSettingsPanel.d.ts.map +0 -1
- package/dist/components/PhasePanel.d.ts.map +0 -1
- package/dist/components/PlanPanel.d.ts.map +0 -1
- package/dist/components/ProcessMonitor.d.ts.map +0 -1
- package/dist/components/PromptLibraryModal.d.ts.map +0 -1
- package/dist/components/ProviderWaitingRoom.d.ts.map +0 -1
- package/dist/components/QueuePanel.d.ts.map +0 -1
- package/dist/components/QuickModelSwitcher.d.ts.map +0 -1
- package/dist/components/QuickModelSwitcher.filter.d.ts.map +0 -1
- package/dist/components/RefinePanel.d.ts.map +0 -1
- package/dist/components/RefreshDebugView.d.ts.map +0 -1
- package/dist/components/SageMemoryCard.d.ts.map +0 -1
- package/dist/components/SddActivityFeed.d.ts.map +0 -1
- package/dist/components/SddBoardView.d.ts.map +0 -1
- package/dist/components/SddDestroyDialog.d.ts.map +0 -1
- package/dist/components/SddFlowGraph.d.ts.map +0 -1
- package/dist/components/SddHub.d.ts.map +0 -1
- package/dist/components/SddKanbanView.d.ts.map +0 -1
- package/dist/components/SddTaskDrawer.d.ts.map +0 -1
- package/dist/components/SddWizard.d.ts.map +0 -1
- package/dist/components/SearchOverlay.d.ts.map +0 -1
- package/dist/components/SendButton.d.ts.map +0 -1
- package/dist/components/SessionWatchPanel.d.ts.map +0 -1
- package/dist/components/SessionsDashboard.d.ts.map +0 -1
- package/dist/components/SettingsPanel/BasicSettingsTabs.d.ts.map +0 -1
- package/dist/components/SettingsPanel/BrainSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ChimeraSettingsPanel.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ClearAllowlistDialog.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ConnectionsHealthSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/FallbacksSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/FleetSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/IntegrationsSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/MCPSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ModelSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/OAuthLoginSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/PluginToggleList.d.ts.map +0 -1
- package/dist/components/SettingsPanel/PreferenceControls.d.ts.map +0 -1
- package/dist/components/SettingsPanel/PreferenceToggle.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ProviderModelsPanel.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ProviderModelsPanel.filter.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ProviderSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/RoutingSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/SecuritySection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ShadowSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/ToolsSection.d.ts.map +0 -1
- package/dist/components/SettingsPanel/brain-section-options.d.ts.map +0 -1
- package/dist/components/SettingsPanel/index.d.ts.map +0 -1
- package/dist/components/SettingsPanel/local-presets.d.ts.map +0 -1
- package/dist/components/SettingsPanel/official-servers.d.ts.map +0 -1
- package/dist/components/SettingsPanel/settings-panel-reducers.d.ts.map +0 -1
- package/dist/components/SettingsPanel/undo-send-decision.d.ts.map +0 -1
- package/dist/components/SettingsPanel.d.ts.map +0 -1
- package/dist/components/SetupScreen/CustomProviderSection.d.ts.map +0 -1
- package/dist/components/SetupScreen/ModelEditor.d.ts.map +0 -1
- package/dist/components/SetupScreen/ProviderKeyCard.d.ts.map +0 -1
- package/dist/components/SetupScreen/key-operation.d.ts.map +0 -1
- package/dist/components/SetupScreen/popular-providers.d.ts.map +0 -1
- package/dist/components/SetupScreen/relative-time.d.ts.map +0 -1
- package/dist/components/SetupScreen/types.d.ts.map +0 -1
- package/dist/components/SetupScreen.d.ts.map +0 -1
- package/dist/components/ShortcutsOverlay.d.ts.map +0 -1
- package/dist/components/SideEffectTimeline.d.ts.map +0 -1
- package/dist/components/SidePanel/AgentsPanel.d.ts.map +0 -1
- package/dist/components/SidePanel/ChangesPanel.d.ts.map +0 -1
- package/dist/components/SidePanel/DesignStudioPanel.d.ts.map +0 -1
- package/dist/components/SidePanel/SessionList.d.ts.map +0 -1
- package/dist/components/SidePanel/SessionPanel.d.ts.map +0 -1
- package/dist/components/SidePanel/SkillsList.d.ts.map +0 -1
- package/dist/components/SidePanel/WorktreesPanel.d.ts.map +0 -1
- package/dist/components/SidePanel/index.d.ts.map +0 -1
- package/dist/components/SkillDetailView.d.ts.map +0 -1
- package/dist/components/SpecsView.d.ts.map +0 -1
- package/dist/components/TaskActivityTimeline.d.ts.map +0 -1
- package/dist/components/TaskBoard.d.ts.map +0 -1
- package/dist/components/TaskCard.d.ts.map +0 -1
- package/dist/components/TaskExecutionAttempts.d.ts.map +0 -1
- package/dist/components/TaskIntelligencePanel.d.ts.map +0 -1
- package/dist/components/TaskRiskPanel.d.ts.map +0 -1
- package/dist/components/TaskVerificationSection.d.ts.map +0 -1
- package/dist/components/TasksPanel.d.ts.map +0 -1
- package/dist/components/TechStackView/DependencyDetail.d.ts.map +0 -1
- package/dist/components/TechStackView/DependencyTable.d.ts.map +0 -1
- package/dist/components/TechStackView/FindingsPanel.d.ts.map +0 -1
- package/dist/components/TechStackView/TechStackToolbar.d.ts.map +0 -1
- package/dist/components/TechStackView/index.d.ts.map +0 -1
- package/dist/components/TechStackView/shared.d.ts.map +0 -1
- package/dist/components/TerminalPanel.d.ts.map +0 -1
- package/dist/components/ThemeProvider.d.ts.map +0 -1
- package/dist/components/Toaster.d.ts.map +0 -1
- package/dist/components/TodosPanel.d.ts.map +0 -1
- package/dist/components/ToolGroup.d.ts.map +0 -1
- package/dist/components/ToolResult.d.ts.map +0 -1
- package/dist/components/UpdateBanner.d.ts.map +0 -1
- package/dist/components/VerificationReportPanel.d.ts.map +0 -1
- package/dist/components/WatchMessageBubble.d.ts.map +0 -1
- package/dist/components/WelcomeScreen.d.ts.map +0 -1
- package/dist/components/WorkDashboard.d.ts.map +0 -1
- package/dist/components/WorkspaceDock.d.ts.map +0 -1
- package/dist/components/WorktreeGraph.d.ts.map +0 -1
- package/dist/components/WorktreeLanes.d.ts.map +0 -1
- package/dist/components/WorktreeOrphans.d.ts.map +0 -1
- package/dist/components/activity-bar/index.d.ts.map +0 -1
- package/dist/components/activity-bar/nav.d.ts.map +0 -1
- package/dist/components/agent-roster-data.d.ts.map +0 -1
- package/dist/components/agents/AgentDetailSection.d.ts.map +0 -1
- package/dist/components/agents/AgentRosterCard.d.ts.map +0 -1
- package/dist/components/agents/FleetSummaryBar.d.ts.map +0 -1
- package/dist/components/codemap-model.d.ts.map +0 -1
- package/dist/components/context-editor/ContextWindowEditor.d.ts.map +0 -1
- package/dist/components/dashboard-primitives.d.ts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/monaco-theme.d.ts.map +0 -1
- package/dist/components/toaster-helpers.d.ts.map +0 -1
- package/dist/components/ui/PickerCardList.d.ts.map +0 -1
- package/dist/components/ui/api-key-display.d.ts.map +0 -1
- package/dist/components/ui/badge.d.ts.map +0 -1
- package/dist/components/ui/button.d.ts.map +0 -1
- package/dist/components/ui/concurrency-gauge.d.ts.map +0 -1
- package/dist/components/ui/dialog.d.ts.map +0 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/components/ui/empty-state.d.ts.map +0 -1
- package/dist/components/ui/event-timeline.d.ts.map +0 -1
- package/dist/components/ui/fleet-agent-row.d.ts.map +0 -1
- package/dist/components/ui/index.d.ts.map +0 -1
- package/dist/components/ui/input.d.ts.map +0 -1
- package/dist/components/ui/pagination.d.ts.map +0 -1
- package/dist/components/ui/progress-ring.d.ts.map +0 -1
- package/dist/components/ui/scroll-area.d.ts.map +0 -1
- package/dist/components/ui/sheet.d.ts.map +0 -1
- package/dist/components/ui/sparkline.d.ts.map +0 -1
- package/dist/components/ui/tabs.d.ts.map +0 -1
- package/dist/components/useAgentRosterData.d.ts.map +0 -1
- package/dist/components/useKanbanRegistrySessionIds.d.ts.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/use-ws-handlers.d.ts.map +0 -1
- package/dist/hooks/useDesktopBridge.d.ts.map +0 -1
- package/dist/hooks/useF5Resilience.d.ts.map +0 -1
- package/dist/hooks/useFieldKeyboardNav.d.ts.map +0 -1
- package/dist/hooks/useFleetPolling.d.ts.map +0 -1
- package/dist/hooks/useGitInfo.d.ts.map +0 -1
- package/dist/hooks/useGlobalKeyboardShortcuts.d.ts.map +0 -1
- package/dist/hooks/useHorizontalScroll.d.ts.map +0 -1
- package/dist/hooks/useKanbanMeta.d.ts.map +0 -1
- package/dist/hooks/useMemoryForFile.d.ts.map +0 -1
- package/dist/hooks/usePagination.d.ts.map +0 -1
- package/dist/hooks/useProviderModels.d.ts.map +0 -1
- package/dist/hooks/useScrollPosition.d.ts.map +0 -1
- package/dist/hooks/useWebSocket.d.ts.map +0 -1
- package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +0 -1
- package/dist/hooks/ws-handlers/coordinator-handlers.d.ts.map +0 -1
- package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts.map +0 -1
- package/dist/hooks/ws-handlers/fleet-handlers.d.ts.map +0 -1
- package/dist/hooks/ws-handlers/misc-handlers.d.ts.map +0 -1
- package/dist/hooks/ws-handlers/session-handlers.d.ts.map +0 -1
- package/dist/hooks/ws-handlers/techstack-handlers.d.ts.map +0 -1
- package/dist/hooks/ws-handlers.d.ts.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/languages.d.ts.map +0 -1
- package/dist/index.css.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/lib/accent-colors.d.ts.map +0 -1
- package/dist/lib/agent-office.d.ts.map +0 -1
- package/dist/lib/agent-status.d.ts.map +0 -1
- package/dist/lib/chime.d.ts.map +0 -1
- package/dist/lib/color.d.ts.map +0 -1
- package/dist/lib/completion.d.ts.map +0 -1
- package/dist/lib/core-browser-shim.d.ts.map +0 -1
- package/dist/lib/default-prompt-pools.d.ts.map +0 -1
- package/dist/lib/desktop-host.d.ts.map +0 -1
- package/dist/lib/desktop-shell.d.ts.map +0 -1
- package/dist/lib/fallback-ref.d.ts.map +0 -1
- package/dist/lib/favicon.d.ts.map +0 -1
- package/dist/lib/file-icons.d.ts.map +0 -1
- package/dist/lib/goal.d.ts.map +0 -1
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/kanban-cleaner.d.ts.map +0 -1
- package/dist/lib/kanban-metadata.d.ts.map +0 -1
- package/dist/lib/kanban-verification.d.ts.map +0 -1
- package/dist/lib/model-calendar.d.ts.map +0 -1
- package/dist/lib/model-matrix-routes.d.ts.map +0 -1
- package/dist/lib/notify.d.ts.map +0 -1
- package/dist/lib/plugin-enablement.d.ts.map +0 -1
- package/dist/lib/roster-ws.d.ts.map +0 -1
- package/dist/lib/sage-block.d.ts.map +0 -1
- package/dist/lib/sdd-theme.d.ts.map +0 -1
- package/dist/lib/stream-coalescer.d.ts.map +0 -1
- package/dist/lib/terminal-dock.d.ts.map +0 -1
- package/dist/lib/tool-icon.d.ts.map +0 -1
- package/dist/lib/tool-summary.d.ts.map +0 -1
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/view-navigation.d.ts.map +0 -1
- package/dist/lib/ws-client-actions.d.ts.map +0 -1
- package/dist/lib/ws-client-contracts.d.ts.map +0 -1
- package/dist/lib/ws-client-helpers.d.ts.map +0 -1
- package/dist/lib/ws-client-utils.d.ts.map +0 -1
- package/dist/lib/ws-client.d.ts.map +0 -1
- package/dist/main.d.ts.map +0 -1
- package/dist/protocol-compatibility.d.ts.map +0 -1
- package/dist/stores/auto-submit-streak.d.ts.map +0 -1
- package/dist/stores/chat-store.d.ts.map +0 -1
- package/dist/stores/codemap-activity-store.d.ts.map +0 -1
- package/dist/stores/codemap-index-store.d.ts.map +0 -1
- package/dist/stores/config-store.d.ts.map +0 -1
- package/dist/stores/context-editor-store.d.ts.map +0 -1
- package/dist/stores/coordinator-monitor-store.d.ts.map +0 -1
- package/dist/stores/cron-store.d.ts.map +0 -1
- package/dist/stores/file-reference-store.d.ts.map +0 -1
- package/dist/stores/file-store.d.ts.map +0 -1
- package/dist/stores/fleet-store.d.ts.map +0 -1
- package/dist/stores/git-changes-store.d.ts.map +0 -1
- package/dist/stores/git-info-store.d.ts.map +0 -1
- package/dist/stores/goal-assess-store.d.ts.map +0 -1
- package/dist/stores/goal-run-store.d.ts.map +0 -1
- package/dist/stores/goal-state-store.d.ts.map +0 -1
- package/dist/stores/goal-store.d.ts.map +0 -1
- package/dist/stores/history-store.d.ts.map +0 -1
- package/dist/stores/index.d.ts.map +0 -1
- package/dist/stores/kanban-store.d.ts.map +0 -1
- package/dist/stores/local-prefs.d.ts.map +0 -1
- package/dist/stores/mailbox-store.d.ts.map +0 -1
- package/dist/stores/memory-injector-store.d.ts.map +0 -1
- package/dist/stores/memory-lifecycle-store.d.ts.map +0 -1
- package/dist/stores/monitor-store.d.ts.map +0 -1
- package/dist/stores/office-map-store.d.ts.map +0 -1
- package/dist/stores/provider-status-store.d.ts.map +0 -1
- package/dist/stores/sdd-board-store.d.ts.map +0 -1
- package/dist/stores/sdd-wizard-store.d.ts.map +0 -1
- package/dist/stores/session-store.d.ts.map +0 -1
- package/dist/stores/side-effect-store.d.ts.map +0 -1
- package/dist/stores/specs-store.d.ts.map +0 -1
- package/dist/stores/techstack-store.d.ts.map +0 -1
- package/dist/stores/types.d.ts.map +0 -1
- package/dist/stores/ui-store.d.ts.map +0 -1
- package/dist/stores/viz-store.d.ts.map +0 -1
- package/dist/stores/worktree-store.d.ts.map +0 -1
- package/dist/types/brain.d.ts.map +0 -1
- package/dist/types/chronicle.d.ts.map +0 -1
- package/dist/types/client-message.d.ts.map +0 -1
- package/dist/types/collab.d.ts.map +0 -1
- package/dist/types/connections.d.ts.map +0 -1
- package/dist/types/goal-kanban-worktree.d.ts.map +0 -1
- package/dist/types/protocol-core.d.ts.map +0 -1
- package/dist/types/runtime.d.ts.map +0 -1
- package/dist/types/sage.d.ts.map +0 -1
- package/dist/types/server-message.d.ts.map +0 -1
- package/dist/types/skills-design.d.ts.map +0 -1
- package/dist/types/system.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -7
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Ar as n,Bn as r,Jn as i,Ln as a,Mi as o,Mn as s,Nt as c,On as l,Pr as u,Qt as d,Rn as f,Sa as p,Tt as m,Wi as h,Wn as g,Xt as _,Yi as v,Zt as y,_ as b,_a as x,_i as S,a as C,at as w,ba as T,bn as E,c as ee,ct as D,d as te,da as O,et as ne,f as re,ft as k,gi as A,h as ie,hr as j,i as ae,it as M,kr as oe,l as se,lr as N,m as ce,ma as P,mi as le,mr as ue,mt as de,o as fe,oi as pe,p as me,pi as F,r as he,ri as ge,rr as _e,rt as I,s as L,st as ve,ti as R,u as ye,v as be,zi as xe,zn as Se,zr as z}from"./vendor-2VBBgNb5.js";import"./i18n-1BkaqMgr.js";import{s as Ce}from"./ws-client-WVGn8ORh.js";import{t as B}from"./utils-CN2sfDVP.js";import{t as we}from"./session-store-BsNYnfOc.js";import{_ as Te,c as V,l as H,x as Ee}from"./stores-mpa0202y.js";import{r as De}from"./mailbox-store-DVoNbOZr.js";import{f as Oe}from"./markdown-L6DLSM7f.js";import{c as ke,s as Ae,t as je}from"./LazyMarkdown-BGwFjYKr.js";import{C as Me,D as Ne,E as Pe,m as Fe}from"./index-BPfIz78e.js";var U=e(p(),1);function Ie(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Le(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function W(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function G(e,t){for(let n of t){let t=W(e[n]);if(t)return t}}function K(e,t){for(let n of t){let t=Le(e[n]);if(t!==void 0)return t}}function Re(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function ze(e){return e?e.split(/\r?\n/).length:0}function Be(e){let t=0,n=0;for(let r of e.split(/\r?\n/))r.startsWith(`+++`)||r.startsWith(`---`)||(r.startsWith(`+`)&&(t+=1),r.startsWith(`-`)&&(n+=1));return t||n?{added:t,removed:n}:null}function Ve(e){let t=e.split(/\r?\n/,1)[0]?.trim()??e;return t.length>72?`${t.slice(0,69)}…`:t}function He(e){let t=e.toLowerCase().replace(/[.:/-]+/g,`_`);return/^(read|view|open_file|read_file)|file_read/.test(t)?`read`:/^(write|create|save)|file_write/.test(t)?`write`:/edit|update|patch|replace|apply_patch/.test(t)?`edit`:/bash|shell|terminal|exec|command|powershell|cmd/.test(t)?`terminal`:/fetch|browser|browse|http|url|web/.test(t)?`web`:/search|grep|find|glob|query/.test(t)?`search`:/memory|recall|remember/.test(t)?`memory`:`other`}function Ue(e,t){let n=(Array.isArray(e.fileTargets)?e.fileTargets:[]).flatMap(e=>{let t=Ie(e),n=G(t,[`filePath`,`file_path`,`path`]);return n?[{filePath:n,operation:W(t.operation),line:K(t,[`line`,`startLine`,`start_line`]),endLine:K(t,[`endLine`,`end_line`])}]:[]});if(n.length>0)return n;let r=G(t,[`file_path`,`filePath`,`path`,`filename`,`target_file`,`targetFile`]);return r?[{filePath:r,line:K(t,[`line`,`start_line`,`startLine`,`offset`]),endLine:K(t,[`end_line`,`endLine`])}]:[]}function We(e,t){let n=e?.line??K(t,[`line`,`start_line`,`startLine`,`offset`]),r=e?.endLine??K(t,[`end_line`,`endLine`]),i=K(t,[`limit`,`line_count`,`lineCount`]);return r===void 0&&n!==void 0&&i!==void 0&&i>0&&(r=n+i-1),n!==void 0&&r!==void 0?{start:n,end:r,label:`L${n}–${r}`}:n===void 0?{}:{start:n,label:`L${n}`}}function Ge(e,t,n,r,i,a){let o=We(a,n),s=a?.filePath??G(n,[`file_path`,`filePath`,`path`,`filename`]),c=s?Re(s):void 0;if(e===`read`)return{target:s,summary:i===void 0?o.label?`${o.label} queued to read`:`Reading file`:`${i.toLocaleString()} lines read`,lineLabel:o.label};if(e===`write`){let e=G(n,[`content`,`text`,`data`]),t=K(r,[`inputLines`])??(e?ze(e):void 0);return{target:s,summary:t===void 0?`Writing file`:`${t.toLocaleString()} lines written`,lineLabel:o.label}}if(e===`edit`){let e=G(n,[`patch`,`diff`]),t=e?Be(e):null,i=G(n,[`old_string`,`oldString`,`search`]),a=G(n,[`new_string`,`newString`,`replacement`]),c=K(r,[`addedLines`]),l=K(r,[`removedLines`]),u=K(r,[`oldLines`]),d=K(r,[`newLines`]);return{target:s,summary:t||c!==void 0||l!==void 0?`+${t?.added??c??0} / −${t?.removed??l??0} lines`:i!==void 0||a!==void 0||u!==void 0||d!==void 0?`${i?ze(i):u??0} → ${a?ze(a):d??0} lines`:o.label?`${o.label} updated`:`Updating file`,lineLabel:o.label}}if(e===`terminal`){let e=G(n,[`command`,`cmd`,`script`,`shell`])??t;return{summary:Ve(e),target:e}}if(e===`web`){let e=G(n,[`url`,`href`,`uri`]),t=G(n,[`query`,`q`,`search`]);return{target:e??t,summary:e?`Fetched ${e}`:t?`Looked up “${t}”`:`Went online`}}if(e===`search`){let e=G(n,[`query`,`pattern`,`q`,`search`])??c;return{target:s??e,summary:e?`Searched “${e}”`:`Searching project`}}if(e===`memory`){let e=G(n,[`query`,`text`,`key`]);return{target:e,summary:e?`Recalled “${e}”`:`Checking memory`}}return{target:s,summary:c?`${t} · ${c}`:t}}function Ke(e,t){let n=W(t.name)??W(t.toolName);if(n)return n;if(e.kind===`agent:tool`)return e.target??void 0;if(e.kind.startsWith(`tool:`))return e.source}function qe(e,t,n){return W(t.agentId)??W(t.subagentId)??(e.kind===`agent:tool`?e.source:void 0)??(e.source!==n&&e.source!==`filesystem`?e.source:void 0)??`leader`}function Je(e){return W(e.parentSessionId)??W(e.sessionId)}function Ye(e,t){return e.kind===`tool:started`||e.kind===`tool:progress`?`running`:t.ok===!1?`failed`:`succeeded`}function Xe(e){if(![`tool:started`,`tool:progress`,`tool:executed`,`agent:tool`].includes(e.kind))return null;let t=Ie(e.data),n=Ke(e,t);if(!n)return null;let r=qe(e,t,n),i=t.input,a=Ie(i),o=Ue(t,a),s=Le(t.outputLines),c=He(n),l=Ge(c,n,a,t,s,o[0]),u=W(t.id),d=Math.floor(e.timestamp/2e3),f=Ye(e,t),p=Le(t.durationMs);return{id:u?`${r}:${u}`:`${r}:${n}:${d}`,agentId:r,agentName:W(t.agentName),sessionId:Je(t),toolName:n,kind:c,status:f,startedAt:f===`running`?e.timestamp:Math.max(0,e.timestamp-(p??0)),...f===`running`?{}:{completedAt:e.timestamp},durationMs:p,target:l.target,summary:l.summary,lineLabel:l.lineLabel,outputLines:s,outputBytes:Le(t.outputBytes),outputTokens:Le(t.outputTokens),input:i,output:W(t.output),fileTargets:o,raw:e.raw??t}}function Ze(e,t,n){return e?.length?nt(e.map(e=>({id:`snapshot:${n??`session`}:${t}:${e.id}`,kind:`tool:executed`,timestamp:e.completedAt,source:t,target:e.name,label:e.name,data:{...e,agentId:t,sessionId:n},flowGroup:`agent:${t}`})),t,n):[]}function Qe(e){return e?.length?e.map(e=>({id:e.id,direction:e.direction,from:e.from,to:e.to,type:e.type,subject:e.subject,body:``,priority:`normal`,timestamp:new Date(e.at).toISOString(),timestampMs:e.at,unread:e.direction===`incoming`})).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,12):[]}function $e(e,t,n=3e4){let r=new Map;e.forEach((e,t)=>{for(let n of[e.agent.serverId,e.agent.mailboxId,e.agent.name]){let e=q(n);e&&!r.has(e)&&r.set(e,t)}});let i=new Set,a=[];for(let o of e){let e=o.mail[0];if(!e||i.has(e.id)||t-e.timestampMs>n)continue;let s=r.get(q(e.from)),c=r.get(q(e.to));s===void 0||c===void 0||s===c||(i.add(e.id),a.push({id:e.id,mail:e,fromIndex:s,toIndex:c}))}return a}function et(e,t){return e.toLowerCase()===t.toLowerCase()}function q(e){return e?.trim().toLowerCase()??``}function tt(e,t,n){let r=new Set([t.serverId,t.mailboxId,t.name].map(q).filter(e=>e.length>0)),i=n?`@session:${q(n)}`:``,a=q(t.role),o=q(t.serverId)===`leader`||q(t.serverId).startsWith(`leader@`)||a===`lead`||a===`leader`;return e.flatMap(e=>{let t=q(e.from),n=q(e.to),a=r.has(t),s=n===`*`||n===`all`||i.length>0&&n===i,c=(e.audience!==`leaders`||o)&&(r.has(n)||o&&s);if(!c&&!a)return[];let l=Date.parse(e.timestamp);return[{...e,direction:c?`incoming`:`outgoing`,timestampMs:Number.isFinite(l)?l:0,unread:c&&!Object.keys(e.readBy??{}).some(e=>r.has(q(e)))}]}).sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,8)}function nt(e,t,n){let r=new Map;for(let i=e.length-1;i>=0;--i){let a=e[i];if(!a)continue;let o=Xe(a);if(!o||!et(o.agentId,t)||n&&o.sessionId&&o.sessionId!==n)continue;let s=r.get(o.id);r.set(o.id,s?{...s,...o,startedAt:Math.min(s.startedAt,o.startedAt),fileTargets:o.fileTargets.length>0?o.fileTargets:s.fileTargets,input:o.input??s.input,output:o.output??s.output,raw:o.raw??s.raw}:o)}let i=[...r.values()].sort((e,t)=>(t.completedAt??t.startedAt)-(e.completedAt??e.startedAt));return i.filter((e,t)=>e.input!==void 0||e.fileTargets.length>0||e.output!==void 0||!i.some((n,r)=>r!==t&&n.toolName===e.toolName&&(n.input!==void 0||n.fileTargets.length>0||n.output!==void 0)&&Math.abs((n.completedAt??n.startedAt)-(e.completedAt??e.startedAt))<2500))}function rt(e,t,n){let r=He(t),i={read:`Reading a file`,write:`Writing a file`,edit:`Updating code`,terminal:`Running a command`,web:`Working online`,search:`Searching project`,memory:`Checking memory`,other:t};return{id:`${e}:live:${t}`,agentId:e,sessionId:n,toolName:t,kind:r,status:`running`,startedAt:Date.now(),summary:i[r],fileTargets:[]}}var J=ne(),it={read:y,write:z,edit:z,terminal:c,web:R,search:oe,memory:f,other:F};function at(e,t=46){if(!e||e.length<=t)return e;let n=e.split(/[\\/]/).slice(-2).join(`/`);return n.length<=t?`…/${n}`:`…${e.slice(-(t-1))}`}function ot(e){return e===void 0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`}function st(e){if(e===void 0)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Y({label:e,value:t}){return(0,J.jsxs)(`div`,{className:`agent-office__detail-row`,children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(`strong`,{children:t})]})}function ct({selected:e,onClose:t}){let{t:n}=x(),{call:r,agentName:i}=e,a=it[r.kind],o=st(r.input),s=st(r.output);return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${r.toolName} details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:B(`agent-office__detail-icon`,`is-${r.kind}`),children:(0,J.jsx)(a,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:n(`activity:agentOffice.toolCall`)}),(0,J.jsx)(`h2`,{children:r.toolName})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close details`,children:(0,J.jsx)(w,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:B(`agent-office__status-dot`,r.status===`running`&&`is-active`,r.status===`failed`&&`is-failed`)}),(0,J.jsx)(`strong`,{children:r.summary}),(0,J.jsx)(`span`,{children:r.status})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.execution`)}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.agent`),value:i}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.started`),value:new Date(r.startedAt).toLocaleTimeString()}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.duration`),value:ot(r.durationMs)}),r.sessionId&&(0,J.jsx)(Y,{label:n(`activity:agentOffice.session`),value:at(r.sessionId,28)})]}),(r.target||r.fileTargets.length>0)&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.target`)}),r.target&&(0,J.jsx)(`code`,{className:`agent-office__target-code`,children:r.target}),r.fileTargets.map((e,t)=>(0,J.jsxs)(`div`,{className:`agent-office__file-target`,children:[(0,J.jsx)(u,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:e.filePath}),(e.line||e.endLine)&&(0,J.jsxs)(`strong`,{children:[`L`,e.line??1,e.endLine?`–${e.endLine}`:``]})]},`${e.filePath}:${t}`))]}),(r.outputLines!==void 0||r.outputBytes!==void 0||r.outputTokens!==void 0)&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.resultSize`)}),(0,J.jsxs)(`div`,{className:`agent-office__metric-grid`,children:[r.outputLines!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r.outputLines.toLocaleString()}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.lines`)})]}),r.outputBytes!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:r.outputBytes.toLocaleString()}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.bytes`)})]}),r.outputTokens!==void 0&&(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`strong`,{children:[`≈`,r.outputTokens.toLocaleString()]}),(0,J.jsx)(`span`,{children:n(`activity:agentOffice.tokens`)})]})]})]}),o&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.input`)}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:o})})]}),s&&(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.outputPreview`)}),(0,J.jsx)(`pre`,{children:(0,J.jsx)(`code`,{children:s})})]})]})}function lt({selected:e,onClose:t}){let{t:n}=x(),{mail:i,agentName:a}=e;return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${i.subject} details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-mail`,children:(0,J.jsx)(r,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:i.direction===`incoming`?`INCOMING MAIL`:`OUTGOING MAIL`}),(0,J.jsx)(`h2`,{children:i.subject})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close mail details`,children:(0,J.jsx)(w,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:B(`agent-office__status-dot`,i.unread&&`is-active`)}),(0,J.jsxs)(`strong`,{children:[i.from,` → `,i.to]}),(0,J.jsx)(`span`,{children:i.type}),i.audience===`leaders`&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(g,{className:`h-3 w-3`}),` `,n(`activity:mailbox.audienceLeaders`)]})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:mailbox.messages`)}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.agent`),value:a}),(0,J.jsx)(Y,{label:n(`activity:agentOffice.started`),value:new Date(i.timestampMs).toLocaleTimeString()}),(0,J.jsx)(Y,{label:`Priority`,value:i.priority}),(0,J.jsx)(Y,{label:`Route`,value:`${i.from} → ${i.to}`})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:i.subject}),(0,J.jsx)(`div`,{className:`agent-office__mail-body`,children:i.body})]})]})}function ut({selected:e,onClose:t}){let{t:n}=x();return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.agentName} task details`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-task`,children:(0,J.jsx)(i,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:n(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`h2`,{children:e.agentName})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close task details`,children:(0,J.jsx)(w,{})})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.task`)}),e.taskId&&(0,J.jsx)(Y,{label:`ID`,value:e.taskId}),(0,J.jsx)(`div`,{className:`agent-office__task-body`,children:e.task})]})]})}function dt({selected:e,onClose:t}){let{t:n}=x(),r=e.todos.filter(e=>e.status!==`completed`).length;return(0,J.jsxs)(`aside`,{className:`agent-office__detail`,"aria-label":`${e.officeLabel} briefing`,children:[(0,J.jsxs)(`div`,{className:`agent-office__detail-header`,children:[(0,J.jsx)(`div`,{className:`agent-office__detail-icon is-briefing`,children:(0,J.jsx)(a,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.officeBriefing`)}),(0,J.jsx)(`h2`,{children:e.officeLabel})]}),(0,J.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close office briefing`,children:(0,J.jsx)(w,{})})]}),(0,J.jsxs)(`div`,{className:`agent-office__detail-status`,children:[(0,J.jsx)(`span`,{className:B(`agent-office__status-dot`,(e.instructionActive||r>0)&&`is-active`)}),(0,J.jsx)(`strong`,{children:e.telemetryConnected?n(`activity:agentOffice.activeTodos`):n(`activity:agentOffice.telemetryWaiting`)}),(0,J.jsx)(`span`,{children:e.telemetryConnected?r:`—`})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:e.instructionActive?n(`activity:agentOffice.activeInstruction`):n(`activity:agentOffice.leaderPrompt`)}),e.promptAt!==void 0&&(0,J.jsx)(Y,{label:n(`activity:agentOffice.promptReceived`),value:new Date(e.promptAt).toLocaleString()}),(0,J.jsx)(`div`,{className:`agent-office__task-body`,children:e.prompt??(e.telemetryConnected?n(`activity:agentOffice.noPrompt`):n(`activity:agentOffice.telemetryWaiting`))})]}),(0,J.jsxs)(`section`,{className:`agent-office__detail-section`,children:[(0,J.jsx)(`h3`,{children:n(`activity:agentOffice.todos`)}),(0,J.jsx)(`div`,{className:`agent-office__todo-detail-list`,children:e.telemetryConnected?e.todos.length>0?e.todos.map(e=>(0,J.jsxs)(`div`,{className:B(`agent-office__todo-detail`,`is-${e.status}`),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{children:e.content}),(0,J.jsx)(`small`,{children:n(`activity:agentOffice.todoStatus.${e.status}`)})]})]},e.id)):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.noActiveTodos`)}):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:n(`activity:agentOffice.todoTelemetryWaiting`)})})]})]})}function ft({selected:e,onClose:t}){return e.kind===`tool`?(0,J.jsx)(ct,{selected:e,onClose:t}):e.kind===`mail`?(0,J.jsx)(lt,{selected:e,onClose:t}):e.kind===`task`?(0,J.jsx)(ut,{selected:e,onClose:t}):(0,J.jsx)(dt,{selected:e,onClose:t})}function pt(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}M`}function mt(e,t){if(!e)return`never`;let n=Date.parse(e);if(!Number.isFinite(n))return`never`;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s ago`:r<3600?`${Math.round(r/60)}m ago`:r<86400?`${Math.round(r/3600)}h ago`:`${Math.round(r/86400)}d ago`}function ht(e,t){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.round(r/60)}m`:`${Math.round(r/3600)}h`}function gt(e){if(!e)return;let t=e.split(`/`);return t[t.length-1]?.slice(0,18)}function _t(e,t=56){if(!e)return;let n=e.replace(/\s+/g,` `).trim();if(n)return n.length<=t?n:t<=1?`…`:`${n.slice(0,t-1).trimEnd()}…`}function vt(e,t){if(e.length===0)return{positions:new Map,columns:0,rows:0,columnWidth:380};let n=Math.max(1,...e.map(e=>e.agentCount)),r=Math.max(380,Math.min(3,n)*190+80),i=e=>270+Math.max(1,...e.map(e=>Math.ceil(Math.max(1,e.agentCount)/3)))*150,a=Math.max(320,t.width),o=Math.max(240,t.height),s=1,c=-1/0,l=1/0;for(let t=1;t<=e.length;t+=1){let n=[];for(let r=0;r<e.length;r+=t)n.push(i(e.slice(r,r+t)));let u=n.length,d=Math.max(660,Math.min(t,e.length)*r),f=320+n.reduce((e,t)=>e+t,0)+Math.max(0,u-1)*100,p=Math.min(a/d,o/f),m=Math.abs(Math.log(d/f/(a/o)));(p>c+1e-9||Math.abs(p-c)<=1e-9&&m<l)&&(s=t,c=p,l=m)}let u=new Map,d=370;for(let t=0;t<e.length;t+=s){let n=e.slice(t,t+s);n.forEach((e,t)=>{u.set(e.id,{x:600+(t-(n.length-1)/2)*r,y:d})}),d+=i(n)+100}return{positions:u,columns:s,rows:Math.ceil(e.length/s),columnWidth:r}}function yt(e,t,n,r=640){let i=Math.min(3,n),a=Math.floor(t/i),o=t%i;return{x:e-(Math.min(i,n-a*i)-1)*190/2+o*190,y:r+a*150}}function bt(e){return e===`tui`?`tui`:e===`repl`||e===`cli`?`repl`:`webui`}function xt(e){return e===`tui`?`TUI`:e===`repl`?`REPL`:`WebUI`}function St(e){switch(e){case`running`:case`active`:return`active`;case`idle`:return`idle`;case`completed`:return`completed`;case`failed`:case`error`:return`error`;case`stopped`:return`offline`;default:return`idle`}}function Ct(e){if(e)return e.split(`/`).filter(Boolean).pop()??e}function wt(e){let t=Ct(e)??e??``;return t.length>10?`…${t.slice(-8)}`:t}function Tt(e,t){let n=Ct(t);if(n)return e.find(e=>Ct(e.sessionId)===n)}function Et(e,t){let n=St(t.status);return{officeId:`${e}__agent-${t.id}`,serverId:t.id,name:t.name??t.id,status:n,iteration:t.iteration??0,toolCalls:t.toolCalls??0,costUsd:t.costUsd??0,tokensIn:t.tokensIn??0,tokensOut:t.tokensOut??0,ctxPct:t.ctxPct,model:t.model,currentTool:t.currentTool,currentTask:t.description,taskId:t.taskId,presenceSource:`fleet`}}function Dt(e,t){return e===`cli`?`CLI`:e===`repl`?`REPL`:xt(t)}function Ot(e,t,n=[],r=new Map,i=Date.now()){let a=new Set,o=[];for(let n of e){let e=bt(n.clientType),r=Dt(n.clientType,e),i=`client-${n.pid??n.sessionId}`,s=[],c=!1;for(let e of n.agents){a.add(e.id);let n=t.get(e.id),r=St(n?.status??e.status);(r===`active`||r===`streaming`)&&(c=!0),s.push({officeId:`${i}__agent-${e.id}`,serverId:e.id,name:n?.name??e.name??e.id,status:r,iteration:n?.iteration??e.iterations??0,toolCalls:n?.toolCalls??e.toolCalls??0,costUsd:n?.costUsd??e.costUsd??0,tokensIn:n?.tokensIn??e.tokensIn??0,tokensOut:n?.tokensOut??e.tokensOut??0,ctxPct:n?.ctxPct??e.ctxPct,model:n?.model??e.model,lastActivityAt:e.lastActivityAt,currentTool:n?.currentTool??e.currentTool,currentTask:e.currentTask??n?.description,taskId:e.taskId??n?.taskId,recentTools:e.recentTools,recentMail:e.recentMail,activity:e.activity,presenceSource:`registry`})}let l=n.status===`closing`||n.status===`stale`||n.status===`lost`?`offline`:c?`active`:`idle`,u=n.agents.find(e=>e.id===`leader`);o.push({id:i,type:e,label:`${r} · ${n.pid?`PID ${n.pid}`:wt(n.sessionId)}`,sublabel:[`session ${wt(n.sessionId)}`,n.gitBranch?`⎇ ${n.gitBranch}`:``,n.workingDir?n.workingDir.split(/[\\/]/).filter(Boolean).pop():``].filter(Boolean).join(` · `),status:l,sessionId:n.sessionId,pid:n.pid,branch:n.gitBranch,workingDir:n.workingDir,startedAt:n.startedAt,lastHeartbeatAt:n.lastHeartbeatAt,latestPrompt:u?.latestPrompt,latestPromptAt:u?.latestPromptAt,activeInstruction:u?.status===`running`||u?.status===`streaming`?u.latestPrompt??u.currentTask:void 0,todos:u?.todos,agents:s})}for(let e of n.filter(e=>e.online)){let t=Tt(o,e.sessionId);if(!t)continue;let n=e.name.trim().toLowerCase(),r=t.agents.find(t=>t.serverId===e.agentId||t.name.trim().toLowerCase()===n);r&&(a.add(e.agentId),r.mailboxId=e.agentId,r.role=e.role,r.currentTask=r.currentTask??e.currentTask,r.currentTool=r.currentTool??e.currentTool)}let s=[...t.values()].filter(e=>!a.has(e.id)),c,l=()=>{if(c)return c;let e=o.find(e=>e.type===`webui`);return e?(c=e,e):(c={id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI`,status:`idle`,agents:[]},o.push(c),c)};for(let e of s){let t=Tt(o,e.sessionId)??l(),n=Et(t.id,e);(n.status===`active`||n.status===`streaming`)&&t.status!==`offline`&&(t.status=`active`),t.agents.push(n),a.add(e.id)}for(let[e,t]of r){if(a.has(e)||i-t.finishedAt>9e5)continue;let n=Tt(o,t.agent.sessionId);n&&n.agents.push(Et(n.id,t.agent))}return o.length===0&&o.push({id:`client-self`,type:`webui`,label:`This WebUI`,sublabel:`Web UI · connecting…`,status:`idle`,agents:[]}),o}function kt(e){return e.startsWith(`tool`)?`hsl(var(--warning))`:e.startsWith(`mailbox`)?`hsl(var(--info))`:e.startsWith(`provider`)?`hsl(var(--primary))`:e.startsWith(`agent`)||e.startsWith(`subagent`)?`hsl(var(--success))`:e.includes(`error`)?`hsl(var(--destructive))`:`hsl(var(--primary))`}var At=new Set([`completed`,`failed`,`timeout`,`stopped`]);function jt(e){let t=(0,U.useRef)(new Map).current;return(0,U.useMemo)(()=>{let n=Date.now(),r=new Set;for(let i of e.values())if(r.add(i.id),At.has(i.status)){let e=t.get(i.id);e?e.agent=i:t.set(i.id,{agent:i,finishedAt:i.completedAt??n})}else t.delete(i.id);for(let[e,n]of[...t.entries()])!r.has(e)&&!At.has(n.agent.status)&&t.set(e,{agent:{...n.agent,status:`stopped`},finishedAt:n.finishedAt});for(let[e,r]of t)n-r.finishedAt>9e5&&t.delete(e);return{map:t,now:n}},[e,t])}var Mt=[`bot`,`cactus`,`duck`,`radio`],Nt={leader:`plum`,builder:`ocean`,researcher:`mint`,reviewer:`rose`,planner:`amber`,operator:`graphite`},Pt={leader:0,builder:1,researcher:2,reviewer:3,planner:4,operator:5},Ft={read:y,write:z,edit:z,terminal:c,web:R,search:oe,memory:f,other:F},It={leader:h,builder:F,researcher:y,reviewer:xe,planner:i,operator:c};function Lt(e){if(e.serverId===`leader`||e.serverId.startsWith(`leader@`))return`leader`;let t=[e.role,e.name,e.currentTask].filter(Boolean).join(` `).toLowerCase();return/review|critic|audit|security|test|qa|verify|checker/.test(t)?`reviewer`:/research|analyst|explor|investig|search|hunter|recon/.test(t)?`researcher`:/plan|architect|design|coordinat|strateg|spec/.test(t)?`planner`:/build|implement|code|develop|engineer|refactor|fix|frontend|backend/.test(t)?`builder`:`operator`}function Rt(e,t){let n=2166136261;for(let t=0;t<e.length;t+=1)n^=e.charCodeAt(t),n=Math.imul(n,16777619);let r=n>>>0;return{palette:Nt[t],layout:r%4,clutter:Math.floor(r/4)%3,avatar:Pt[t],motion:Math.floor(r/31)%4,charm:Mt[Math.floor(r/47)%Mt.length]}}function zt(e,t=22){let n=e.split(`/`).filter(Boolean).pop()??e;return n.length>t?`${n.slice(0,t-1)}…`:n}function Bt(e,t=46){if(!e||e.length<=t)return e;let n=e.split(/[\\/]/).slice(-2).join(`/`);return n.length<=t?`…/${n}`:`…${e.slice(-(t-1))}`}function Vt(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m`:`${Math.floor(r/60)}h`}function Ht(e,t){if(!e)return`—`;let n=Date.parse(e);if(!Number.isFinite(n))return`—`;let r=Math.max(0,Math.floor((t-n)/1e3));return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function Ut(e){let t=new Set,n=new Set,r=new Set,i=0,a=0,o={files:0,reads:0,writes:0,edits:0,linesAdded:0,linesRemoved:0,terminalCalls:0,incomingMail:0,outgoingMail:0};for(let s of e){let e=s.agent.activity;for(let n of e?.filesTouched??[])t.add(n);o.reads+=e?.reads??0,o.writes+=e?.writes??0,o.edits+=e?.edits??0,o.linesAdded+=e?.linesAdded??0,o.linesRemoved+=e?.linesRemoved??0,o.terminalCalls+=e?.terminalCalls??0,i+=e?.mailReceived??0,a+=e?.mailSent??0;for(let e of s.mail)(e.direction===`incoming`?n:r).add(e.id)}return o.files=t.size,o.incomingMail=Math.max(i,n.size),o.outgoingMail=Math.max(a,r.size),o}function Wt(e,t,n){return n.map((n,r)=>({...rt(e.serverId,n.name,t.sessionId),id:`${e.serverId}:log:${n.at}:${r}`,kind:He(n.name),status:n.ok?`succeeded`:`failed`,startedAt:Math.max(0,n.at-n.durationMs),completedAt:n.at,durationMs:n.durationMs,summary:n.ok?`${n.name} completed`:`${n.name} failed`}))}function Gt(...e){let t=[];for(let n of e.flat()){let e=n.completedAt??n.startedAt;t.some(t=>(t.id===n.id||t.toolName===n.toolName)&&Math.abs((t.completedAt??t.startedAt)-e)<2500)||t.push(n)}return t.sort((e,t)=>(t.completedAt??t.startedAt)-(e.completedAt??e.startedAt))}function Kt(...e){let t=new Map;for(let n of e.flat())t.set(n.id,n);return[...t.values()].sort((e,t)=>t.timestampMs-e.timestampMs).slice(0,12)}function qt({kind:e,active:t}){let n=Ft[e];return(0,J.jsxs)(`span`,{className:B(`agent-office__tool-glyph`,`is-${e}`,t&&`is-active`),children:[e===`read`&&(0,J.jsx)(u,{className:`agent-office__file-underlay`,"aria-hidden":`true`}),(0,J.jsx)(n,{"aria-hidden":`true`})]})}function Jt({active:e,failed:t,role:n,variant:r,motion:i}){let a=It[n];return(0,J.jsxs)(`div`,{className:B(`agent-office__avatar`,`is-${n}`,`is-avatar-${r}`,`is-motion-${i}`,e&&`is-active`,!e&&!t&&`is-idle`,t&&`is-failed`),"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{className:`agent-office__avatar-chair`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-body`}),(0,J.jsxs)(`span`,{className:`agent-office__avatar-head`,children:[(0,J.jsx)(`span`,{className:`agent-office__avatar-hair`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-face`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-mouth`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-headset`})]}),(0,J.jsx)(`span`,{className:`agent-office__avatar-arm`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-prop`}),(0,J.jsx)(`span`,{className:`agent-office__avatar-role-badge`,children:(0,J.jsx)(a,{})})]})}function Yt({call:e,compact:t=!1,onSelect:n}){let r=e.status===`running`;return(0,J.jsxs)(`button`,{type:`button`,className:B(`agent-office__parcel`,`is-${e.kind}`,t&&`is-compact`,r&&`is-running`,e.status===`failed`&&`is-failed`),onClick:n,"aria-label":`${e.toolName}: ${e.summary}`,children:[(0,J.jsx)(qt,{kind:e.kind,active:r}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsxs)(`span`,{className:`agent-office__parcel-topline`,children:[(0,J.jsx)(`strong`,{children:e.toolName}),e.lineLabel&&(0,J.jsx)(`span`,{className:`agent-office__line-chip`,children:e.lineLabel})]}),!t&&e.target&&(0,J.jsx)(`span`,{className:`agent-office__parcel-target`,children:Bt(e.target)}),(0,J.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.summary})]}),(0,J.jsx)(`span`,{className:`agent-office__parcel-state`,"aria-hidden":`true`,children:r?(0,J.jsx)(`span`,{className:`agent-office__pulse-dot`}):e.status===`failed`?(0,J.jsx)(w,{}):(0,J.jsx)(xe,{})})]})}function Xt({mail:e,compact:t=!1,onSelect:n}){let i=e.direction===`incoming`;return(0,J.jsxs)(`button`,{type:`button`,className:B(`agent-office__mail-parcel`,t&&`is-compact`,i?`is-incoming`:`is-outgoing`,e.unread&&`is-unread`),onClick:n,"aria-label":`${i?`Incoming`:`Outgoing`} mail: ${e.subject}`,children:[(0,J.jsx)(`span`,{className:`agent-office__mail-icon`,children:i?(0,J.jsx)(N,{"aria-hidden":`true`}):(0,J.jsx)(_,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsx)(`strong`,{children:i?`${e.from} →`:`→ ${e.to}`}),(0,J.jsx)(`span`,{className:`agent-office__parcel-summary`,children:e.subject})]}),(0,J.jsx)(r,{"aria-hidden":`true`})]})}function Zt({office:e,now:t}){let{t:i}=x(),{client:a,agents:o,stats:s}=e,l=a.lastHeartbeatAt?Date.parse(a.lastHeartbeatAt):NaN,u=Number.isFinite(l)&&t-l<2e4,d=Number.isFinite(l)&&!u,f=o.some(({agent:e})=>e.presenceSource===`registry`),p=u?`VERIFIED`:d?`DELAYED`:f?`REGISTRY`:`LOCAL`,m=o.some(({agent:e})=>e.recentTools!==void 0||e.activity!==void 0),g=o.some(({agent:e})=>e.toolCalls>0&&e.recentTools===void 0&&e.activity===void 0);return(0,J.jsxs)(`header`,{className:`agent-office__client-header`,children:[(0,J.jsxs)(`div`,{className:`agent-office__client-title`,children:[(0,J.jsx)(`span`,{className:`agent-office__client-icon`,children:(0,J.jsx)(h,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{className:`agent-office__client-copy`,children:[(0,J.jsx)(`strong`,{children:a.label}),(0,J.jsx)(`span`,{children:a.sublabel||a.sessionId})]}),(0,J.jsxs)(`div`,{className:`agent-office__client-presence`,children:[(0,J.jsxs)(`span`,{className:`agent-office__client-agent-count`,children:[o.length,` `,i(`activity:agentOffice.agents`)]}),(0,J.jsxs)(`span`,{className:B(`agent-office__presence-chip`,!d&&`is-live`,d&&`is-legacy`),children:[(0,J.jsx)(ve,{"aria-hidden":`true`}),` `,p]}),(0,J.jsxs)(`span`,{className:`agent-office__presence-chip`,children:[(0,J.jsx)(S,{"aria-hidden":`true`}),` `,Ht(a.startedAt,t),` UP`]}),(0,J.jsxs)(`span`,{className:B(`agent-office__presence-chip`,g?`is-legacy`:m&&`is-telemetry`),children:[(0,J.jsx)(P,{"aria-hidden":`true`}),g?`RECONNECT`:m?`TOOLS LIVE`:`READY`]})]})]}),(0,J.jsxs)(`fieldset`,{className:`agent-office__client-stats`,"aria-label":`Session activity totals`,children:[(0,J.jsxs)(`span`,{title:`Unique files touched`,children:[(0,J.jsx)(n,{}),` `,(0,J.jsx)(`strong`,{children:s.files}),` FILES`]}),(0,J.jsxs)(`span`,{title:`File reads`,children:[(0,J.jsx)(y,{}),` `,(0,J.jsx)(`strong`,{children:s.reads}),` READ`]}),(0,J.jsxs)(`span`,{title:`Files written`,children:[(0,J.jsx)(z,{}),` `,(0,J.jsx)(`strong`,{children:s.writes}),` WRITE`]}),(0,J.jsxs)(`span`,{title:`Files edited`,children:[(0,J.jsx)(z,{}),` `,(0,J.jsx)(`strong`,{children:s.edits}),` EDIT`]}),(0,J.jsxs)(`span`,{className:`agent-office__client-delta`,title:`Lines added and removed`,children:[(0,J.jsxs)(`strong`,{children:[`+`,s.linesAdded]}),` / `,(0,J.jsxs)(`b`,{children:[`−`,s.linesRemoved]})]}),(0,J.jsxs)(`span`,{title:`Terminal commands`,children:[(0,J.jsx)(c,{}),` `,(0,J.jsx)(`strong`,{children:s.terminalCalls}),` TERM`]}),(0,J.jsxs)(`span`,{title:`Incoming and outgoing mail`,children:[(0,J.jsx)(r,{}),` `,(0,J.jsx)(`strong`,{children:s.incomingMail}),`↓ `,(0,J.jsx)(`strong`,{children:s.outgoingMail}),`↑`]})]})]})}function Qt({office:e,now:n,onSelect:r}){let{t:o}=x(),{client:s}=e,c=s.todos!==void 0,l=s.todos??[],u=l.filter(e=>e.status!==`completed`),d=l.length-u.length,f=!!s.activeInstruction,p=s.activeInstruction??s.latestPrompt,m=s.latestPromptAt!==void 0&&n-s.latestPromptAt<3e4,h=()=>r({kind:`briefing`,officeLabel:s.label,prompt:p,promptAt:s.latestPromptAt,instructionActive:f,telemetryConnected:c,todos:l});return(0,J.jsxs)(`section`,{className:`agent-office__briefing`,"aria-label":o(`activity:agentOffice.officeBriefing`),children:[(0,J.jsxs)(`button`,{type:`button`,className:B(`agent-office__prompt-card`,f&&`is-active`,m&&`is-fresh`,!c&&`is-waiting`),onClick:h,children:[(0,J.jsx)(`span`,{className:`agent-office__briefing-icon is-prompt`,children:(0,J.jsx)(a,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__briefing-copy`,children:[(0,J.jsx)(`span`,{children:o(f?`activity:agentOffice.activeInstruction`:`activity:agentOffice.leaderPrompt`)}),(0,J.jsx)(`strong`,{children:p??o(c?`activity:agentOffice.noPrompt`:`activity:agentOffice.telemetryWaiting`)})]}),f&&(0,J.jsxs)(`span`,{className:`agent-office__instruction-live`,children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),` LIVE`]}),s.latestPromptAt!==void 0&&(0,J.jsx)(`time`,{dateTime:new Date(s.latestPromptAt).toISOString(),children:Vt(s.latestPromptAt,n)})]}),(0,J.jsxs)(`button`,{type:`button`,className:B(`agent-office__todo-board`,u.length>0&&`has-active`,!c&&`is-waiting`),onClick:h,children:[(0,J.jsxs)(`span`,{className:`agent-office__todo-heading`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(i,{"aria-hidden":`true`}),` `,o(`activity:agentOffice.activeTodos`)]}),(0,J.jsx)(`strong`,{children:c?o(`activity:agentOffice.todoProgress`,{done:d,total:l.length}):o(`activity:agentOffice.syncWaiting`)})]}),(0,J.jsxs)(`span`,{className:`agent-office__todo-preview`,children:[c?u.length>0?u.slice(0,3).map(e=>(0,J.jsxs)(`span`,{className:B(`agent-office__todo-line`,`is-${e.status}`),children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:e.activeForm||e.content})]},e.id)):(0,J.jsxs)(`span`,{className:`agent-office__todo-empty`,children:[(0,J.jsx)(t,{"aria-hidden":`true`}),l.length>0?o(`activity:agentOffice.allTodosDone`):o(`activity:agentOffice.noActiveTodos`)]}):(0,J.jsxs)(`span`,{className:`agent-office__todo-empty is-waiting`,children:[(0,J.jsx)(P,{"aria-hidden":`true`}),o(`activity:agentOffice.todoTelemetryWaiting`)]}),u.length>3&&(0,J.jsx)(`span`,{className:`agent-office__todo-more`,children:o(`activity:agentOffice.moreTodos`,{count:u.length-3})})]})]})]})}function $t({active:e}){let{t}=x();return(0,J.jsxs)(`div`,{className:`agent-office__parcel agent-office__parcel--empty`,children:[(0,J.jsx)(`span`,{className:`agent-office__tool-glyph`,children:(0,J.jsx)(v,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__parcel-copy`,children:[(0,J.jsx)(`strong`,{children:t(e?`activity:agentOffice.thinking`:`activity:agentOffice.waiting`)}),(0,J.jsx)(`span`,{children:t(e?`activity:agentOffice.preparing`:`activity:agentOffice.deskReady`)})]})]})}function en({model:e,now:t,onSelect:n,routedMailIds:a}){let{t:o}=x(),{agent:s,client:c,current:l,display:u,history:d,mail:f}=e,p=s.status===`active`||s.status===`streaming`,m=s.status===`error`,h=f[0],g=Lt(s),_=Rt(`${c.sessionId}:${s.serverId}:${s.name}`,g),v=h&&t-h.timestampMs<3e4&&!a?.has(h.id),y=d.slice(0,6),b=y[0]?.completedAt??y[0]?.startedAt??u?.completedAt??u?.startedAt,S=l?`is-tool-${l.kind}`:void 0;return(0,J.jsxs)(`article`,{className:B(`agent-office__lane`,`is-desk-${_.palette}`,`is-layout-${_.layout}`,`is-clutter-${_.clutter}`,p&&`is-active`,m&&`is-failed`),children:[(0,J.jsxs)(`div`,{className:`agent-office__identity`,children:[(0,J.jsxs)(`div`,{className:`agent-office__identity-line`,children:[(0,J.jsx)(`span`,{className:B(`agent-office__status-dot`,p&&`is-active`,m&&`is-failed`)}),(0,J.jsx)(`strong`,{title:s.name,children:s.name}),(0,J.jsxs)(`span`,{className:`agent-office__agent-verified`,title:s.presenceSource===`registry`?`Verified by live session registry`:`Verified by local fleet state`,children:[(0,J.jsx)(xe,{"aria-hidden":`true`}),s.presenceSource===`registry`?`LIVE`:`LOCAL`]})]}),(0,J.jsx)(`span`,{className:`agent-office__role`,children:s.role??(s.serverId===`leader`||s.serverId.startsWith(`leader@`)?o(`activity:agentOffice.leadAgent`):o(`activity:agentOffice.agent`))}),(0,J.jsxs)(`div`,{className:`agent-office__agent-meta`,children:[(0,J.jsx)(`span`,{children:c.branch?`⎇ ${c.branch}`:c.type.toUpperCase()}),(0,J.jsx)(`span`,{children:o(`activity:agentOffice.callsCount`,{count:s.toolCalls})}),s.model&&(0,J.jsx)(`span`,{className:`agent-office__model-chip`,title:s.model,children:zt(s.model)})]}),s.currentTask&&(0,J.jsxs)(`button`,{type:`button`,className:`agent-office__agent-task`,onClick:()=>n({kind:`task`,task:s.currentTask??``,taskId:s.taskId,agentName:s.name}),children:[(0,J.jsx)(i,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`small`,{children:s.currentTask})]})]}),!s.currentTask&&p&&(0,J.jsxs)(`div`,{className:`agent-office__agent-task is-missing`,children:[(0,J.jsx)(P,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`strong`,{children:o(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`small`,{children:c.todos===void 0?o(`activity:agentOffice.telemetryWaiting`):o(`activity:agentOffice.taskNotReported`)})]})]}),h&&(0,J.jsxs)(`button`,{type:`button`,className:B(`agent-office__identity-mail`,h.unread&&`is-unread`),onClick:()=>n({kind:`mail`,mail:h,agentName:s.name}),"aria-label":`${f.length} mail messages. Latest: ${h.subject}`,children:[(0,J.jsx)(r,{"aria-hidden":`true`}),(0,J.jsxs)(`span`,{children:[(0,J.jsxs)(`strong`,{children:[f.length,` MAIL`]}),(0,J.jsx)(`small`,{children:h.subject})]})]})]}),(0,J.jsxs)(`div`,{className:B(`agent-office__scene`,S),children:[(0,J.jsxs)(`div`,{className:`agent-office__window`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsxs)(`div`,{className:`agent-office__plant`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`div`,{className:`agent-office__desk-zone`,"aria-hidden":`true`,children:[(0,J.jsx)(Jt,{active:p,failed:m,role:g,variant:_.avatar,motion:_.motion}),(0,J.jsx)(`span`,{className:`agent-office__monitor`,children:u?(0,J.jsx)(qt,{kind:u.kind,active:l!==void 0}):(0,J.jsx)(F,{})}),(0,J.jsxs)(`span`,{className:`agent-office__activity-fx`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsx)(`span`,{className:`agent-office__desk`}),(0,J.jsx)(`span`,{className:`agent-office__desk-lamp`}),(0,J.jsxs)(`span`,{className:`agent-office__desk-clutter`,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`span`,{className:B(`agent-office__desk-charm`,`is-${_.charm}`),children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`b`,{})]}),(0,J.jsxs)(`span`,{className:B(`agent-office__mug`,`is-${g}`),children:[(0,J.jsx)(`i`,{"aria-hidden":`true`}),(0,J.jsx)(`b`,{"aria-hidden":`true`})]})]}),v&&(0,J.jsx)(`div`,{className:B(`agent-office__mail-flyby`,`is-${h.direction}`),children:(0,J.jsx)(Xt,{mail:h,compact:!0,onSelect:()=>n({kind:`mail`,mail:h,agentName:s.name})},h.id)}),(0,J.jsxs)(`div`,{className:B(`agent-office__conveyor`,l&&`is-moving`),children:[(0,J.jsxs)(`div`,{className:`agent-office__belt`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(`div`,{className:`agent-office__current-action`,children:u?(0,J.jsx)(Yt,{call:u,onSelect:()=>n({kind:`tool`,call:u,agentName:s.name})},u.id):(0,J.jsx)($t,{active:p})})]})]}),(0,J.jsxs)(`div`,{className:`agent-office__history`,children:[(0,J.jsxs)(`div`,{className:`agent-office__history-heading`,children:[(0,J.jsx)(`span`,{children:o(`activity:agentOffice.recent`)}),b!==void 0&&(0,J.jsx)(`span`,{children:Vt(b,t)})]}),(0,J.jsx)(`div`,{className:`agent-office__history-list`,children:y.length>0?y.map(e=>(0,J.jsx)(Yt,{call:e,compact:!0,onSelect:()=>n({kind:`tool`,call:e,agentName:s.name})},`tool:${e.id}`)):(0,J.jsx)(`span`,{className:`agent-office__history-empty`,children:s.toolCalls>0&&s.recentTools===void 0&&s.activity===void 0?o(`activity:agentOffice.telemetryReconnect`):o(`activity:agentOffice.noCalls`)})})]})]})}function tn(e){return e.agent.status===`active`||e.agent.status===`streaming`||e.agent.status===`error`}function nn({agents:e,now:t,onSelect:n}){let{t:i}=x();return(0,J.jsxs)(`section`,{className:`agent-office__lounge`,"aria-label":i(`activity:agentOffice.breakRoom`),children:[(0,J.jsxs)(`header`,{className:`agent-office__lounge-heading`,children:[(0,J.jsx)(le,{"aria-hidden":`true`}),(0,J.jsx)(`strong`,{children:i(`activity:agentOffice.breakRoom`)}),(0,J.jsx)(`span`,{children:i(`activity:agentOffice.onBreak`,{count:e.length})})]}),(0,J.jsx)(`div`,{className:`agent-office__lounge-seats`,children:e.map(e=>{let{agent:a,history:o,mail:s}=e,c=Lt(a),l=It[c],u=s.filter(e=>e.unread).length,d=o[0]?.completedAt??o[0]?.startedAt,f=s[0],p=()=>{a.currentTask?n({kind:`task`,task:a.currentTask,taskId:a.taskId,agentName:a.name}):f&&n({kind:`mail`,mail:f,agentName:a.name})},m=!!a.currentTask||!!f;return(0,J.jsxs)(`button`,{type:`button`,className:B(`agent-office__lounge-seat`,`is-${c}`),onClick:p,disabled:!m,children:[(0,J.jsx)(`span`,{className:`agent-office__lounge-avatar`,children:(0,J.jsx)(l,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`agent-office__lounge-copy`,children:[(0,J.jsx)(`strong`,{children:a.name}),(0,J.jsx)(`small`,{children:a.role??i(`activity:agentOffice.agent`)})]}),(0,J.jsxs)(`span`,{className:`agent-office__lounge-meta`,children:[d!==void 0&&(0,J.jsx)(`span`,{children:Vt(d,t)}),u>0&&(0,J.jsxs)(`span`,{className:`agent-office__lounge-mail`,children:[(0,J.jsx)(r,{"aria-hidden":`true`}),` `,u]})]})]},e.key)})})]})}function rn(){let{t:e}=x(),t=H(e=>e.liveSessions),n=H(e=>e.aggregate),i=Ee(e=>e.agents),a=De(e=>e.agents),o=De(e=>e.messages),s=Ce(e=>e.toolEvents),c=we(e=>e.projectName),l=jt(i),[u,d]=(0,U.useState)(null),f=(0,U.useMemo)(()=>Ot(t,i,a,l.map,l.now),[t,i,a,l]),p=(0,U.useMemo)(()=>f.flatMap(e=>e.agents.map(t=>{let n=Gt(nt(s,t.serverId,e.sessionId),Ze(t.recentTools,t.serverId,e.sessionId),Wt(t,e,i.get(t.serverId)?.toolLog??[])),r=t.status===`active`||t.status===`streaming`,a=n.find(e=>e.status===`running`);!a&&r&&t.currentTool&&(a=rt(t.serverId,t.currentTool,e.sessionId));let c=a??n[0],l=n.filter(e=>e.status!==`running`).slice(0,6),u=Kt(Qe(t.recentMail),tt(o,t,e.sessionId));return{key:t.officeId,client:e,agent:t,calls:n,current:a,display:c,history:l,mail:u}})),[f,i,o,s]),m=(0,U.useMemo)(()=>f.map(e=>{let t=p.filter(t=>t.client.id===e.id);return{client:e,agents:t,stats:Ut(t)}}).filter(e=>e.agents.length>0),[f,p]),g=p.filter(({agent:e})=>e.status===`active`||e.status===`streaming`).length,_=c||t.find(e=>e.projectName)?.projectName||e(`activity:office.fleetHq`),y=Date.now();return(0,J.jsxs)(`div`,{className:`agent-office`,children:[(0,J.jsxs)(`header`,{className:`agent-office__header`,children:[(0,J.jsxs)(`div`,{className:`agent-office__title`,children:[(0,J.jsx)(`span`,{className:`agent-office__brand-mark`,children:(0,J.jsx)(h,{"aria-hidden":`true`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{children:e(`activity:agentOffice.liveProjectOffice`)}),(0,J.jsx)(`h1`,{children:_})]})]}),(0,J.jsxs)(`div`,{className:`agent-office__live-pill`,children:[(0,J.jsx)(`span`,{}),` LIVE`]}),(0,J.jsxs)(`div`,{className:`agent-office__summary`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(v,{}),(0,J.jsx)(`strong`,{children:p.length}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.agents`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(M,{}),(0,J.jsx)(`strong`,{children:g}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.working`)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(P,{}),(0,J.jsx)(`strong`,{children:n.toolCalls.toLocaleString()}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.toolCalls`)})]})]})]}),(0,J.jsx)(`main`,{className:`agent-office__floor`,children:p.length>0?m.map(t=>{let n=t.agents.filter(tn),i=t.agents.filter(e=>!tn(e)),a=$e(n,y),o=new Set(a.map(e=>e.id));return(0,J.jsxs)(`section`,{className:`agent-office__client-office`,children:[(0,J.jsx)(Zt,{office:t,now:y}),(0,J.jsx)(Qt,{office:t,now:y,onSelect:d}),n.length>0&&(0,J.jsxs)(`div`,{className:`agent-office__column-headings`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{children:e(`activity:agentOffice.team`)}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.liveDesk`)}),(0,J.jsx)(`span`,{children:e(`activity:agentOffice.lastActions`)})]}),(0,J.jsxs)(`div`,{className:`agent-office__client-desks`,children:[n.map(e=>(0,J.jsx)(en,{model:e,now:y,onSelect:d,routedMailIds:o},e.key)),a.length>0&&(0,J.jsx)(`div`,{className:`agent-office__mail-routes`,"aria-hidden":`true`,children:a.map(e=>(0,J.jsx)(`div`,{className:`agent-office__mail-route`,style:{"--from":`${(e.fromIndex+.5)/n.length*100}%`,"--to":`${(e.toIndex+.5)/n.length*100}%`},children:(0,J.jsx)(`span`,{className:`agent-office__mail-route-parcel`,children:(0,J.jsx)(r,{"aria-hidden":`true`})})},e.id))}),n.length===0&&(0,J.jsxs)(`div`,{className:`agent-office__desks-empty`,children:[(0,J.jsx)(le,{"aria-hidden":`true`}),e(`activity:agentOffice.desksEmpty`)]})]}),i.length>0&&(0,J.jsx)(nn,{agents:i,now:y,onSelect:d})]},t.client.id)}):(0,J.jsxs)(`div`,{className:`agent-office__empty-state`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(ve,{"aria-hidden":`true`})}),(0,J.jsx)(`h2`,{children:e(`activity:agentOffice.readyTitle`)}),(0,J.jsx)(`p`,{children:e(`activity:agentOffice.readyBody`)})]})}),(0,J.jsxs)(`footer`,{className:`agent-office__footer`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`agent-office__status-dot is-active`}),` `,e(`activity:agentOffice.liveEvent`)]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(j,{}),` `,e(`activity:agentOffice.connectedSessions`,{count:t.length})]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(S,{}),` `,e(`activity:agentOffice.detailHint`)]})]}),u&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:`agent-office__detail-backdrop`,onClick:()=>d(null),"aria-label":`Close tool details`}),(0,J.jsx)(ft,{selected:u,onClose:()=>d(null)})]})]})}function an(){let{t:e}=x(),{clientCounts:t,currentSession:n,totalAgents:r,activeAgents:i,aggregate:a}=H(I(e=>({clientCounts:e.clientCounts,currentSession:e.currentSession,totalAgents:e.totalAgents,activeAgents:e.activeAgents,aggregate:e.aggregate}))),o=t.tui+t.webui+t.repl,c=e=>e?.toLocaleString()??`0`;return(0,J.jsxs)(`div`,{className:`absolute left-4 top-20 z-10 rounded-xl border border-border/70 bg-card/90 p-3 text-foreground shadow-xl backdrop-blur`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(P,{className:`h-3.5 w-3.5 text-success`}),(0,J.jsx)(`span`,{className:`text-[10px] font-bold uppercase text-muted-foreground`,children:e(`activity:office.sessionStats`)})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5 text-[10px]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(k,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.clients`)})]}),(0,J.jsxs)(`span`,{className:`font-mono text-foreground`,children:[i,` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,J.jsx)(`span`,{className:`text-success`,children:o})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 pl-4 text-[9px]`,children:[t.tui>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(m,{className:`h-2.5 w-2.5 text-success`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`TUI`}),(0,J.jsx)(`span`,{className:`font-mono text-success`,children:t.tui})]}),t.webui>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(s,{className:`h-2.5 w-2.5 text-primary`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`WebUI`}),(0,J.jsx)(`span`,{className:`font-mono text-primary`,children:t.webui})]}),t.repl>0&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(m,{className:`h-2.5 w-2.5 text-warning`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`REPL`}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:t.repl})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(v,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.agents`)})]}),(0,J.jsxs)(`span`,{className:`font-mono text-foreground`,children:[i,` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),` `,(0,J.jsx)(`span`,{className:`text-primary`,children:r})]})]}),n.model&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(pe,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.model`)})]}),(0,J.jsx)(`span`,{className:`max-w-[120px] truncate font-mono text-primary`,title:n.model,children:n.model.split(`/`).pop()?.slice(0,16)})]}),n.mode&&(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(M,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:officeMap.mode`)})]}),(0,J.jsx)(`span`,{className:B(`font-mono uppercase text-[9px] px-1.5 py-0.5 rounded`,n.mode===`auto`&&`bg-primary/10 text-primary`,n.mode===`suggest`&&`bg-success/10 text-success`,n.mode===`off`&&`bg-muted text-muted-foreground`,![`auto`,`suggest`,`off`].includes(n.mode||``)&&`bg-muted text-muted-foreground`),children:n.mode})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(ue,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.toolCallsLabel`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:c(a.toolCalls)})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 space-y-1 border-t border-border/70 pt-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`IN`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.input`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:c(a.tokensIn)})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:`OUT`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.output`)})]}),(0,J.jsx)(`span`,{className:`font-mono text-[9px] text-foreground`,children:c(a.tokensOut)})]})]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-4 border-t border-border/70 pt-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(ge,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.cost`)})]}),(0,J.jsx)(`span`,{className:`font-mono font-medium text-success`,children:(e=>e==null?`$0.0000`:`$${e.toFixed(4)}`)(a.costUsd)})]})]})]})}function on({events:e,now:t}){let{t:n}=x(),r=e.slice(0,14);return(0,J.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 pointer-events-none px-3 pb-3`,children:(0,J.jsxs)(`div`,{className:`pointer-events-auto mx-auto max-w-3xl rounded-lg border border-border/70 bg-card/90 px-3 py-2 shadow-xl backdrop-blur`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] uppercase text-primary`,children:[(0,J.jsx)(P,{className:`h-3 w-3`}),n(`activity:office.liveActivity`)]}),r.length===0?(0,J.jsx)(`div`,{className:`text-[11px] italic text-muted-foreground`,children:n(`activity:office.waitingActivity`)}):(0,J.jsx)(`div`,{className:`flex flex-col gap-0.5 max-h-32 overflow-hidden`,children:r.map(e=>{let r=Math.max(0,Math.round((t-e.timestamp)/1e3));return(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] leading-tight`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{backgroundColor:kt(e.kind)}}),(0,J.jsx)(`span`,{className:`flex-1 truncate text-foreground`,children:e.label}),(0,J.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:r<1?n(`activity:office.now`):`${r}s`})]},e.id)})})]})})}function sn(e){if(e<1e3)return`${e}ms`;let t=Math.round(e/100);return t<600?`${(t/10).toFixed(1)}s`:`${Math.floor(t/600)}m ${Math.round(t%600/10)}s`}var cn={user:{Icon:de,labelKey:`activity:message.roleYou`,avatarBg:`bg-primary`,avatarColor:`text-primary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-primary/20`,bubbleBg:`bg-transparent`,bubbleBorder:`border-primary/40`,textColor:`text-foreground`},assistant:{Icon:v,labelKey:`activity:message.roleAssistant`,avatarBg:`bg-accent`,avatarColor:`text-accent-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-accent/20`,bubbleBg:`bg-card`,bubbleBorder:`border-border`,textColor:`text-foreground`},tool:{Icon:m,labelKey:`activity:message.roleTool`,avatarBg:`bg-secondary`,avatarColor:`text-secondary-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-secondary/20`,bubbleBg:`bg-muted/80`,bubbleBorder:`border-border`,textColor:`text-foreground`},system:{Icon:v,labelKey:`activity:transcript.kindSystem`,avatarBg:`bg-muted`,avatarColor:`text-muted-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-muted/20`,bubbleBg:`bg-muted/50`,bubbleBorder:`border-border`,textColor:`text-muted-foreground`},error:{Icon:o,labelKey:`activity:transcript.kindError`,avatarBg:`bg-destructive`,avatarColor:`text-destructive-foreground`,avatarRing:`ring-2 ring-offset-2 ring-offset-background ring-destructive/20`,bubbleBg:`bg-destructive/5`,bubbleBorder:`border-destructive/20`,textColor:`text-destructive`}};function ln({entry:e}){let{t}=x();return e.role===`error`?(0,J.jsx)(Pe,{text:e.text}):e.role===`tool`?(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 tool-details`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground`,children:[(0,J.jsx)(m,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{className:`font-mono`,children:e.tool??t(`activity:watch.toolFallback`)}),e.durationMs!==void 0&&(0,J.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground font-normal tabular-nums`,children:[(0,J.jsx)(A,{className:`h-3 w-3 inline mr-0.5 align-text-bottom`}),sn(e.durationMs)]})]}),e.input!==void 0&&e.input!==null&&(0,J.jsx)(`div`,{className:`p-3 bg-muted/50 rounded-lg overflow-x-auto`,children:(0,J.jsx)(Me,{input:e.input})}),e.output!==void 0&&e.output!==null?(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:typeof e.output==`string`?(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.output}):(0,J.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs bg-card rounded-lg p-2 border border-border overflow-x-auto`,children:JSON.stringify(e.output,null,2)})}):e.text?(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.text})}):null,e.isError&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:t(`activity:watch.toolFailed`)}),e.text&&(0,J.jsx)(`pre`,{className:`mt-1 text-xs whitespace-pre-wrap text-destructive/80`,children:e.text})]})]}):(0,J.jsx)(`div`,{className:`text-sm leading-relaxed markdown-content`,children:(0,J.jsx)(je,{remarkPlugins:[Oe],rehypePlugins:ke,components:Ae,children:e.text})})}function un({entry:e,isContinuation:t=!1}){let{t:n}=x(),r=cn[e.role],i=r.Icon;return(0,J.jsxs)(`div`,{className:`group flex gap-3 animate-message msg-bubble rounded-lg transition-shadow`,children:[t?(0,J.jsx)(`div`,{className:`flex-shrink-0 w-8`}):(0,J.jsx)(`div`,{className:B(`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center`,r.avatarBg,r.avatarColor,r.avatarRing),children:(0,J.jsx)(i,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 min-w-0 flex-1`,children:[!t&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:B(`text-xs font-medium`,r.textColor),children:e.role===`tool`&&e.tool?e.tool:n(r.labelKey)}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}),e.role===`tool`&&e.durationMs!==void 0&&(0,J.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`· `,sn(e.durationMs)]})]}),(0,J.jsx)(`div`,{className:B(`rounded-2xl px-4 py-3 border`,e.role===`user`&&`rounded-br-md`,e.role===`assistant`&&`rounded-bl-md`,e.role===`tool`&&`rounded-bl-sm`,e.role===`system`&&`rounded-bl-sm opacity-70`,e.role===`error`&&`rounded-bl-sm`,r.bubbleBg,r.bubbleBorder),children:(0,J.jsx)(`div`,{className:B(`text-sm leading-relaxed markdown-content`,r.textColor),children:(0,J.jsx)(ln,{entry:e})})}),e.text&&e.role!==`error`&&(0,J.jsx)(`div`,{className:`opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,J.jsx)(Ne,{text:e.text,label:n(`common:action.copy`)})})]})]})}var dn=[`steer`,`ask`,`assign`,`note`],fn=2500;function pn({sessionId:e,limit:t=200}){let[n,r]=(0,U.useState)(null),{t:i}=x(),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(``),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(`steer`),[h,g]=(0,U.useState)(`high`),[_,y]=(0,U.useState)([]),[b,S]=(0,U.useState)(!1),C=(0,U.useRef)(null),w=(0,U.useRef)(!0),E=(0,U.useRef)(!0),ee=H(e=>e.liveSessions),D=(0,U.useMemo)(()=>ee.find(t=>t.sessionId===e),[ee,e]),te=(0,U.useMemo)(()=>{let e=D;return e?`${e.status}|${e.agents.map(e=>`${e.id}:${e.status}:${e.toolCalls??0}:${e.iterations??0}`).join(`,`)}`:``},[D]),O=D?.status===`active`||(D?.agents.some(e=>e.status===`running`||e.status===`streaming`)??!1),ne=(0,U.useMemo)(()=>{if(!D)return null;let e=D.agents.find(e=>e.status===`running`||e.status===`streaming`);return e?.currentTool?`🔧 ${e.currentTool}`:e?i(`activity:sessionWatch.working`,{name:e.name??e.id}):null},[D,i]),re=(0,U.useMemo)(()=>{if(!D)return null;let e=D.agents.find(e=>e.partialText&&(e.status===`streaming`||e.status===`running`))??D.agents.find(e=>e.partialText);return e?.partialText?{label:e.id===`leader`?i(`activity:sessionWatch.claude`):e.name||e.id,text:e.partialText}:null},[D,i]),k=(0,U.useCallback)(async()=>{try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/events?limit=${t}`);if(!n.ok)throw Error(`HTTP ${n.status}`);let i=await n.json();E.current&&(r(i),o(null))}catch(e){E.current&&o(e instanceof Error?e.message:String(e))}},[e,t]),A=(0,U.useCallback)(async()=>{try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/mailbox`);if(!t.ok)return;let n=await t.json();E.current&&Array.isArray(n.thread)&&y(n.thread)}catch{}},[e]);(0,U.useEffect)(()=>{E.current=!0,r(null),o(null),y([]),k(),A();let e=setInterval(()=>{document.hidden||(k(),A())},fn);return()=>{E.current=!1,clearInterval(e)}},[k,A]),(0,U.useEffect)(()=>{te&&k()},[te,k]),(0,U.useEffect)(()=>{w.current&&C.current&&(C.current.scrollTop=C.current.scrollHeight)},[n,re]);let ie=()=>{let e=C.current;e&&(w.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},j=async()=>{let t=s.trim();if(!(!t||l)){u(!0),f(null);try{let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t,type:p,priority:h})});if(!n.ok)throw Error(`HTTP ${n.status}`);c(``),f(O?T.t(`activity:sessionWatch.sentRunning`):T.t(`activity:sessionWatch.sentIdle`)),A()}catch(e){f(T.t(`activity:sessionWatch.sentFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(!1)}}},ae=async()=>{if(!b){S(!0),f(null);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({reason:T.t(`activity:sessionWatch.interruptReason`)})});if(!t.ok)throw Error(`HTTP ${t.status}`);f(T.t(`activity:sessionWatch.interruptSent`)),A()}catch(e){f(T.t(`activity:sessionWatch.interruptFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{S(!1)}}},M=n?.entries??[];return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:B(`h-1.5 w-1.5 rounded-full`,O?`bg-success animate-pulse`:`bg-muted-foreground`)}),i(`activity:sessionWatch.liveStream`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,J.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[i(`activity:sessionWatch.events`,{count:n.total}),` · `,n.status]}),O&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>void ae(),disabled:b,title:i(`activity:sessionWatch.interruptTitle`),className:`rounded border border-destructive/40 bg-destructive/15 px-1.5 py-0.5 text-[10px] text-destructive hover:bg-destructive/25 disabled:opacity-40 transition-colors`,children:i(b?`activity:sessionWatch.interrupting`:`activity:sessionWatch.interrupt`)})]})]}),ne&&(0,J.jsxs)(`div`,{className:`mb-1.5 shrink-0 text-[10px] text-foreground truncate`,children:[`▶ `,ne]}),a&&(0,J.jsxs)(`div`,{className:`text-[11px] text-destructive mb-1 shrink-0`,children:[`· `,a]}),(0,J.jsxs)(`div`,{ref:C,onScroll:ie,className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain space-y-1.5 pr-1`,children:[M.length===0&&!a&&(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground italic`,children:i(`activity:sessionWatch.loading`)}),M.map((e,t)=>(0,J.jsx)(un,{entry:e,isContinuation:t>0&&M[t-1].role===e.role},`${e.ts}-${t}`)),re&&(0,J.jsxs)(`div`,{className:`flex gap-3 animate-message`,children:[(0,J.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center bg-accent text-accent-foreground ring-2 ring-offset-2 ring-offset-background ring-accent/20`,children:(0,J.jsx)(v,{className:`h-4 w-4 animate-pulse`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 max-w-[85%] min-w-0`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground px-1`,children:re.label}),(0,J.jsx)(`div`,{className:`rounded-2xl rounded-bl-md px-4 py-3 bg-card border border-border`,children:(0,J.jsxs)(`span`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words`,children:[re.text,(0,J.jsx)(`span`,{className:`animate-pulse text-primary`,children:`▋`})]})})]})]})]}),_.length>0&&(0,J.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0 max-h-28 overflow-y-auto space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:i(`activity:mailbox.messages`)}),_.slice(-6).map(e=>{let t=e.completed?i(`activity:sessionWatch.done`):e.readByLeader?i(`activity:sessionWatch.read`):i(`activity:sessionWatch.delivered`);return(0,J.jsxs)(`div`,{className:`text-[10px] leading-snug`,children:[(0,J.jsx)(`span`,{className:B(`font-semibold mr-1.5`,e.fromLeader?`text-accent`:`text-primary`),children:e.fromLeader?i(`activity:sessionWatch.agent`):i(`activity:sessionWatch.you`)}),(0,J.jsx)(`span`,{className:`text-foreground whitespace-pre-wrap break-words`,children:e.body}),!e.fromLeader&&(0,J.jsx)(`span`,{className:B(`ml-1.5 text-[9px]`,e.completed?`text-success`:e.readByLeader?`text-primary`:`text-muted-foreground`),children:t})]},e.id)})]}),(0,J.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-border shrink-0`,children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,J.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),title:i(`activity:sessionWatch.msgType.${p}Hint`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:dn.map(e=>(0,J.jsx)(`option`,{value:e,children:i(`activity:sessionWatch.msgType.${e}Label`)},e))}),(0,J.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value),title:i(`activity:sessionWatch.priority`),className:`rounded bg-muted border border-border px-1.5 py-0.5 text-[10px] text-foreground focus:outline-none focus:ring-1 focus:ring-ring`,children:[(0,J.jsx)(`option`,{value:`high`,children:`high`}),(0,J.jsx)(`option`,{value:`normal`,children:`normal`}),(0,J.jsx)(`option`,{value:`low`,children:`low`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-end gap-1.5`,children:[(0,J.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),j())},rows:2,placeholder:i(`activity:sessionWatch.placeholder`,{label:i(`activity:sessionWatch.msgType.${p}Label`)}),className:`flex-1 resize-none rounded-md bg-muted border border-border px-2 py-1 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void j(),disabled:l||!s.trim(),className:`shrink-0 rounded-md bg-primary text-primary-foreground px-2.5 py-1.5 text-xs hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:l?`…`:i(`activity:sessionWatch.send`)})]}),d&&(0,J.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:d}),(0,J.jsx)(`div`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:i(`activity:sessionWatch.sendHint`)})]})]})}var X={primary:`hsl(var(--primary))`,info:`hsl(var(--info))`,success:`hsl(var(--success))`,warning:`hsl(var(--warning))`,destructive:`hsl(var(--destructive))`,muted:`hsl(var(--muted-foreground))`},mn=.12;function hn(e){return Math.min(100,Math.max(0,e??0))}function Z({status:e,small:t,activity:n=0}){let r=t?`w-2 h-2`:`w-3 h-3`,i=t?4+n*4:6+n*6,a={idle:`bg-muted-foreground`,active:`bg-success`,streaming:`bg-primary`,completed:`bg-primary`,error:`bg-destructive`,offline:`bg-muted-foreground/60`},o={idle:X.muted,active:X.success,streaming:X.primary,completed:X.primary,error:X.destructive,offline:X.muted};return(0,J.jsx)(`span`,{className:B(`rounded-full`,r,n>0&&`animate-pulse`,a[e]),style:{boxShadow:n>0?`0 0 ${i}px ${o[e]}`:void 0}})}function Q(){let e={opacity:0,width:1,height:1,minWidth:0,border:`none`,background:`transparent`};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(L,{type:`target`,position:b.Top,style:e,isConnectable:!1}),(0,J.jsx)(L,{type:`source`,position:b.Bottom,style:e,isConnectable:!1})]})}function gn({data:e}){let{t}=x();return(0,J.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border/60 pt-1.5 text-[10px] text-muted-foreground`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.agentCount??0}),` `,t(`activity:office.agentsSuffix`)]}),e.startedAt&&(0,J.jsx)(`span`,{children:t(`activity:office.upPrefix`,{time:ht(e.startedAt,Date.now())})})]})}function _n({data:e}){let{t}=x(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`offline`,a=e.color||X.info;return(0,J.jsxs)(`div`,{className:B(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-primary/15`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35 opacity-60`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:B(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-primary/15`:`bg-primary/10`),children:(0,J.jsx)(s,{className:`h-5 w-5`,style:{color:a}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:a},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.webuiClient`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsx)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(D,{className:`h-3 w-3 text-muted-foreground`}),(0,J.jsx)(`span`,{children:t(`activity:office.disconnected`)})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ve,{className:`h-3 w-3 text-success`}),(0,J.jsx)(`span`,{children:t(`activity:office.connected`)})]})}),n&&(0,J.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-primary/20`,children:(0,J.jsx)(`div`,{className:`h-full animate-pulse bg-primary`,style:{width:`60%`}})}),(0,J.jsx)(gn,{data:e})]})}function vn({data:e}){let{t}=x(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.color||X.success;return(0,J.jsxs)(`div`,{className:B(`rounded-xl border-2 p-4 min-w-[180px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-success/15`,r&&`border-destructive/50 bg-destructive/10`,!n&&!r&&`border-success/30 bg-success/10`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:B(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-success/15`:`bg-success/10`),children:(0,J.jsx)(m,{className:`h-5 w-5`,style:{color:i}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:i},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.tuiClient`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-2 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(m,{className:`h-3 w-3 text-success`}),(0,J.jsx)(`span`,{children:t(`activity:office.terminal`)})]}),(0,J.jsx)(gn,{data:e})]})}function yn({data:e}){let{t}=x(),n=e.status===`active`||e.status===`streaming`,r=e.color||X.warning;return(0,J.jsxs)(`div`,{className:B(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,n&&`shadow-lg shadow-warning/15`,!n&&`border-warning/30 bg-warning/10`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:B(`flex items-center justify-center w-10 h-10 rounded-lg`,n?`bg-warning/15`:`bg-warning/10`),children:(0,J.jsx)(m,{className:`h-5 w-5`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold truncate`,style:{color:r},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`activity:office.repl`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),e.sublabel&&(0,J.jsx)(`div`,{className:`mb-1 truncate text-[10px] text-muted-foreground`,children:e.sublabel}),(0,J.jsx)(gn,{data:e})]})}function bn({data:e}){let{t}=x(),n=e.status===`active`||e.status===`streaming`,r=e.color||X.primary;return(0,J.jsxs)(`div`,{className:`relative min-w-[200px] rounded-xl border-2 border-border/70 bg-card/90 p-4 shadow-lg backdrop-blur-sm transition-all`,children:[(0,J.jsx)(Q,{}),(0,J.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 rounded-full bg-primary px-2 py-0.5 text-[11px] font-bold text-primary-foreground`,children:t(`activity:office.coordinator`)}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,J.jsx)(`div`,{className:B(`flex items-center justify-center w-12 h-12 rounded-xl`,n?`bg-primary/15`:`bg-primary/10`),children:(0,J.jsx)(pe,{className:`h-6 w-6`,style:{color:r}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-sm font-bold truncate`,style:{color:r},children:e.label}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e.sublabel||t(`activity:office.fleetSummary`)})]}),(0,J.jsx)(Z,{status:e.status,activity:e.vizActivity??0})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px] mb-2`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`font-mono`,children:[(0,J.jsx)(`span`,{className:`text-success`,children:e.agentsActive||0}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,J.jsx)(`span`,{className:`text-primary`,children:e.agentsTotal||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:officeMap.agents`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-warning`,children:(e.toolCalls||0).toLocaleString()}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.toolCallsLabel`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsx)(`div`,{className:`font-mono text-foreground`,children:pt(e.tokensIn)}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.tokensLabel`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.cost`)})]})]}),n&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-primary`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-primary`}),t(`activity:office.coordinatingFleet`)]})]})}function xn({data:e}){let{t}=x(),n=e.status===`active`||e.status===`streaming`,r=e.status===`error`,i=e.status===`completed`,a=e.color||X.primary,o=hn(e.ctxPct);return(0,J.jsxs)(`div`,{className:B(`w-[170px] min-w-0 max-w-[170px] overflow-hidden rounded-lg border p-3 transition-all backdrop-blur-sm`,n&&`border-primary/50 bg-primary/10 shadow-lg shadow-primary/10`,r&&`border-destructive/50 bg-destructive/10`,i&&`border-border/70 bg-muted/35`,!n&&!r&&!i&&`border-primary/30 bg-primary/10`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,J.jsx)(v,{className:`h-4 w-4 shrink-0`,style:{color:a}}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-[11px] font-bold truncate`,style:{color:a},children:e.label}),e.model&&(0,J.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:gt(e.model)})]}),(0,J.jsx)(Z,{status:e.status,small:!0,activity:e.vizActivity??0})]}),e.currentTask&&(0,J.jsxs)(`div`,{className:`mb-1.5 flex min-w-0 items-center gap-1 overflow-hidden text-[11px] text-primary`,children:[(0,J.jsx)(`span`,{className:B(`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`,n&&`animate-pulse`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:e.currentTask,children:_t(e.currentTask,72)})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-2 gap-y-0.5 text-[11px] mb-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`iter`}),(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.iteration||0})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tools`}),(0,J.jsx)(`span`,{className:`font-mono text-warning`,children:e.toolCalls||0})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tok`}),(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:pt((e.tokensIn||0)+(e.tokensOut||0))})]}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`cost`}),(0,J.jsxs)(`span`,{className:`font-mono text-success`,children:[`$`,(e.costUsd||0).toFixed(3)]})]})]}),o>0&&(0,J.jsxs)(`div`,{className:`mb-1`,children:[(0,J.jsxs)(`div`,{className:`mb-0.5 flex justify-between text-[10px] text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:`ctx`}),(0,J.jsxs)(`span`,{className:B(`font-mono`,o>=90?`text-destructive`:o>=70?`text-warning`:`text-muted-foreground`),children:[o,`%`]})]}),(0,J.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-muted`,children:(0,J.jsx)(`div`,{className:B(`h-full`,o>=90?`bg-destructive`:o>=70?`bg-warning`:`bg-primary`),style:{width:`${o}%`}})})]}),e.lastActivityAt&&(0,J.jsxs)(`div`,{className:B(`flex items-center gap-1 text-[10px]`,n?`text-muted-foreground/70`:`text-muted-foreground`),children:[i&&(0,J.jsx)(`span`,{className:`text-success`,children:t(`activity:office.donePrefix`)}),r&&(0,J.jsx)(`span`,{className:`text-destructive`,children:t(`activity:office.failedPrefix`)}),(0,J.jsx)(`span`,{children:t(`activity:office.seenPrefix`,{time:mt(e.lastActivityAt,Date.now())})})]})]})}function Sn({data:e}){let{t}=x();return(0,J.jsxs)(`div`,{className:B(`rounded-lg border border-dashed p-3 min-w-[120px] transition-all opacity-40`,`border-border/70 bg-muted/30`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(O,{className:`h-4 w-4 text-muted-foreground`}),(0,J.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,J.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:e.label})}),(0,J.jsx)(Z,{status:e.status,small:!0,activity:e.vizActivity??0})]}),(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`activity:office.availableDesk`)})]})}function Cn({data:e}){let{t}=x(),n=e.color||X.warning,i=(e.unreadCount||0)>0;return(0,J.jsxs)(`div`,{className:B(`rounded-xl border-2 p-4 min-w-[160px] transition-all backdrop-blur-sm`,i&&`border-warning/50 bg-warning/10 shadow-lg shadow-warning/10`,!i&&`border-warning/30 bg-warning/6`),children:[(0,J.jsx)(Q,{}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,J.jsx)(`div`,{className:B(`flex items-center justify-center w-10 h-10 rounded-lg`,i?`bg-warning/18`:`bg-warning/10`),children:(0,J.jsx)(r,{className:`h-5 w-5`,style:{color:n}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold`,style:{color:n},children:t(`activity:office.mailboxHub`)}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i?t(`activity:office.unreadSuffix`,{count:e.unreadCount||0}):t(`activity:office.allClear`)})]}),i&&(0,J.jsx)(`div`,{className:`flex h-5 w-5 items-center justify-center rounded-full bg-warning text-[10px] font-bold text-background`,children:e.unreadCount})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-warning`,children:[(0,J.jsx)(_,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e.messageCount||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.total`)})]}),(0,J.jsxs)(`div`,{className:`rounded bg-muted/40 p-1.5 text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-success`,children:[(0,J.jsx)(N,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e.unreadCount||0})]}),(0,J.jsx)(`div`,{className:`text-muted-foreground`,children:t(`activity:office.unreadLabel`)})]})]}),e.sublabel&&(0,J.jsxs)(`div`,{className:`mt-2 truncate border-t border-border/60 pt-1.5 text-[11px] text-muted-foreground`,children:[`✉ `,e.sublabel]})]})}var wn={webui:_n,tui:vn,repl:yn,coordinator:bn,agent:xn,mailbox:Cn,desk:Sn};function $({k:e,v:t,accent:n}){return(0,J.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:e}),(0,J.jsx)(`span`,{className:B(`font-mono truncate text-right`,n??`text-foreground/80`),children:t})]})}function Tn({selectedNode:e,selectedAgentTranscript:t,mailboxMessages:n,onClose:i,onOpenWatch:a}){let{t:o}=x(),c=e.data,l=Date.now(),u=c.kind===`agent`,d=c.kind===`webui`||c.kind===`tui`||c.kind===`repl`,f=(c.tokensIn||0)+(c.tokensOut||0),p=hn(c.ctxPct);return(0,J.jsxs)(`div`,{className:B(`absolute top-20 right-4 bg-background border border-border rounded-lg p-4 shadow-xl z-20`,c.kind===`agent`?`w-[28rem] max-w-[calc(100%-2rem)]`:c.sessionId?`w-80`:`w-64`),children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c.kind===`webui`&&(0,J.jsx)(s,{className:`h-4 w-4 text-info`}),c.kind===`tui`&&(0,J.jsx)(m,{className:`h-4 w-4 text-success`}),c.kind===`coordinator`&&(0,J.jsx)(pe,{className:`h-4 w-4 text-primary`}),c.kind===`agent`&&(0,J.jsx)(v,{className:`h-4 w-4 text-primary`}),c.kind===`mailbox`&&(0,J.jsx)(r,{className:`h-4 w-4 text-warning`}),(0,J.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:c.label})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c.sessionId&&(0,J.jsx)(`button`,{type:`button`,title:o(`activity:office.openFullView`),onClick:()=>a({sessionId:c.sessionId,label:c.label}),className:`text-muted-foreground hover:text-primary`,children:(0,J.jsx)(Se,{className:`h-3.5 w-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:i,className:`text-muted-foreground hover:text-foreground text-lg leading-none`,children:`×`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,J.jsx)($,{k:`Status`,v:String(c.status).toUpperCase(),accent:B(c.status===`active`&&`text-success`,c.status===`streaming`&&`text-primary`,c.status===`error`&&`text-destructive`,c.status===`idle`&&`text-muted-foreground`,c.status===`offline`&&`text-muted-foreground/70`)}),u&&(0,J.jsxs)(J.Fragment,{children:[c.model&&(0,J.jsx)($,{k:`Model`,v:gt(c.model),accent:`text-primary`}),c.currentTask&&(0,J.jsxs)(`div`,{className:`pt-1`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:o(`activity:agentOffice.currentTask`)}),(0,J.jsx)(`div`,{className:`mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap break-words font-mono text-[10px] text-primary`,children:c.currentTask})]}),(0,J.jsx)($,{k:`Iterations`,v:c.iteration||0,accent:`text-primary`}),(0,J.jsx)($,{k:`Tool calls`,v:c.toolCalls||0,accent:`text-warning`}),(0,J.jsx)($,{k:`Tokens in`,v:pt(c.tokensIn)}),(0,J.jsx)($,{k:`Tokens out`,v:pt(c.tokensOut)}),(0,J.jsx)($,{k:`Tokens total`,v:pt(f)}),p>0&&(0,J.jsx)($,{k:`Context`,v:`${p}%`,accent:p>=90?`text-destructive`:p>=70?`text-warning`:`text-foreground/70`}),(0,J.jsx)($,{k:`Cost`,v:`$${(c.costUsd||0).toFixed(4)}`,accent:`text-success`}),c.lastActivityAt&&(0,J.jsx)($,{k:`Last seen`,v:mt(c.lastActivityAt,l),accent:`text-muted-foreground`}),(0,J.jsx)(`div`,{className:`pt-2`,children:(0,J.jsx)(Fe,{entries:t,agentName:c.label,compact:!0,maxHeightClassName:`max-h-64`})})]}),d&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Surface`,v:xt(c.kind),accent:`text-foreground/80`}),c.branch&&(0,J.jsx)($,{k:`Branch`,v:`⎇ ${c.branch}`,accent:`text-foreground/70`}),c.pid!=null&&(0,J.jsx)($,{k:`PID`,v:c.pid}),c.workingDir&&(0,J.jsx)($,{k:`Dir`,v:c.workingDir,accent:`text-muted-foreground`}),(0,J.jsx)($,{k:`Agents`,v:c.agentCount??0,accent:`text-primary`}),c.startedAt&&(0,J.jsx)($,{k:`Uptime`,v:ht(c.startedAt,l),accent:`text-foreground/70`})]}),c.kind===`mailbox`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Total messages`,v:c.messageCount||0,accent:`text-warning`}),(0,J.jsx)($,{k:`Unread`,v:c.unreadCount||0,accent:`text-warning`}),n.length>0&&(0,J.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-border pt-2`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:o(`activity:office.recent`)}),[...n].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp)).slice(0,6).map(e=>(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[10px]`,children:[(0,J.jsx)(`span`,{className:B(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,!e.completed&&(e.readByCount??0)===0?`bg-warning`:e.completed?`bg-success`:`bg-muted`)}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`truncate text-foreground/80`,children:e.subject||o(`activity:office.noSubject`)}),(0,J.jsxs)(`div`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:[e.from,` → `,e.to,` · `,mt(e.timestamp,l),e.audience===`leaders`?` · ${o(`activity:mailbox.audienceLeaders`)}`:``]})]})]},e.id))]})]}),c.kind===`coordinator`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{k:`Connections`,v:c.connections||0,accent:`text-primary`}),(0,J.jsx)($,{k:`Iterations`,v:c.iteration||0,accent:`text-primary`})]}),(u||d)&&c.sessionId&&(0,J.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 h-72`,children:(0,J.jsx)(pn,{sessionId:c.sessionId})})]})]})}var En={wire:({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i,targetPosition:a,data:o,selected:s})=>{let c=o?.color||X.primary,l=V(e=>e.animateEdges),u=o?.animated&&l?Math.max(.15,o?.intensity??.6):0,[d,f,p]=be({sourceX:e,sourceY:t,sourcePosition:i??b.Bottom,targetX:n,targetY:r,targetPosition:a??b.Top,curvature:.28}),m=5+u*7,h=5+u*4,g=m+h,_=`${Math.max(.5,1.6-u).toFixed(2)}s`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:s?2.5:1.4,strokeOpacity:s?.9:.28,className:`react-flow__edge-path`}),u>.05&&(0,J.jsx)(`path`,{d,fill:`none`,stroke:c,strokeWidth:2.2,strokeOpacity:.45+u*.5,strokeDasharray:`${m} ${h}`,strokeLinecap:`round`,style:{filter:`drop-shadow(0 0 ${2+u*4}px ${c})`},children:(0,J.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:g,to:`0`,dur:_,repeatCount:`indefinite`})}),o?.label&&u>.1&&(0,J.jsx)(fe,{children:(0,J.jsx)(`div`,{style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`},className:`pointer-events-none max-w-[220px] truncate whitespace-nowrap rounded-full border border-border/70 bg-card/90 px-1.5 py-0.5 text-[8px] font-medium text-foreground backdrop-blur-sm`,children:o.label})})]})}};function Dn(){let{t:e}=x();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`absolute bottom-4 left-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,J.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendStatus`)}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-success`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendActive`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendIdle`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 animate-pulse rounded-full bg-destructive`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendError`)})]})]})]}),(0,J.jsxs)(`div`,{className:`absolute bottom-4 right-4 z-10 rounded-lg border border-border/70 bg-card/90 p-3 text-[10px] shadow-xl backdrop-blur`,children:[(0,J.jsx)(`div`,{className:`mb-2 font-bold text-foreground`,children:e(`activity:office.legendConnections`)}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-warning`,children:`✉`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendMail`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-primary`,children:`→`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendTask`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-success`,children:`●`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:office.legendStatusConn`)})]})]})]})]})}function On({draft:e,isSending:t,result:n,onClose:r,onDraftChange:i,onSend:a}){let{t:o}=x();return(0,J.jsxs)(`div`,{className:`absolute right-4 top-16 z-30 w-80 rounded-xl border border-warning/35 bg-card/95 p-3 shadow-2xl backdrop-blur`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold text-warning`,children:[(0,J.jsx)(_,{className:`h-3.5 w-3.5`}),` `,o(`activity:office.broadcastToAll`)]}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`text-base leading-none text-muted-foreground hover:text-foreground`,children:`×`})]}),(0,J.jsx)(`textarea`,{value:e,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),a())},rows:3,placeholder:o(`activity:office.broadcastPlaceholder`),className:`w-full resize-none rounded-md border border-border/70 bg-background/70 px-2 py-1 text-[11px] text-foreground placeholder:text-muted-foreground focus:border-warning/45 focus:outline-none`}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:o(`activity:office.broadcastSendHint`)}),(0,J.jsx)(`button`,{type:`button`,onClick:a,disabled:t||!e.trim(),className:`rounded-md border border-warning/35 bg-warning/12 px-2.5 py-1 text-[11px] text-warning transition-colors hover:bg-warning/18 disabled:cursor-not-allowed disabled:opacity-40`,children:t?`…`:o(`activity:office.broadcast`)})]}),n&&(0,J.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:n})]})}function kn({broadcastOpen:e,labels:t,onArrange:n,onBroadcastToggle:r,onFeedToggle:i,showFeed:a}){return(0,J.jsxs)(se,{position:`top-right`,className:`flex items-center gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:n,title:t.arrangeTitle,className:`flex items-center gap-1.5 rounded-md border border-border/70 bg-card/90 px-2.5 py-1.5 text-xs text-foreground shadow-sm transition-colors hover:bg-accent`,children:[(0,J.jsx)(_e,{className:`h-3.5 w-3.5`}),t.arrange]}),(0,J.jsxs)(`button`,{type:`button`,onClick:i,title:t.feedTitle,className:B(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,a?`border-primary/35 bg-primary/10 text-primary`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,J.jsx)(d,{className:`h-3.5 w-3.5`}),t.feed]}),(0,J.jsxs)(`button`,{type:`button`,onClick:r,title:t.broadcastTitle,className:B(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border text-xs transition-colors`,e?`border-warning/35 bg-warning/10 text-warning`:`border-border/70 bg-card/90 text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,J.jsx)(_,{className:`h-3.5 w-3.5`}),t.broadcast]})]})}function An(){return(0,J.jsx)(ee,{className:`rounded-lg border border-border/70 bg-card/90`,nodeColor:e=>{switch(e.data.kind){case`coordinator`:return X.primary;case`webui`:return X.info;case`tui`:return X.success;case`repl`:case`mailbox`:return X.warning;default:return X.primary}},maskColor:`hsl(var(--background) / 0.72)`})}function jn({closeTitle:e,label:t,onClose:n,sessionId:r,streamTitle:i}){return(0,J.jsxs)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex w-[min(680px,92%)] flex-col border-l border-border bg-background shadow-2xl`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5 shrink-0 bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(v,{className:`h-4 w-4 text-primary shrink-0`}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-bold text-foreground`,children:t}),(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:i})]})]}),(0,J.jsx)(`button`,{type:`button`,onClick:n,title:e,className:`text-muted-foreground hover:text-foreground text-xl leading-none shrink-0`,children:`×`})]}),(0,J.jsx)(`div`,{className:`flex-1 min-h-0 p-4`,children:(0,J.jsx)(pn,{sessionId:r,limit:500})})]})}function Mn(){let{t:e}=x(),{fitView:t}=ie(),n=(0,U.useRef)(null),[r,i]=(0,U.useState)({width:1280,height:720});(0,U.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{let{width:t,height:n}=e.getBoundingClientRect();t<1||n<1||i(e=>Math.abs(e.width-t)<2&&Math.abs(e.height-n)<2?e:{width:t,height:n})};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]);let a=Ce(e=>e.events),o=Ee(e=>e.agents),s=Ee(e=>e.agentTranscripts),c=Ee(e=>e.leaderId),l=H(e=>e.liveSessions),u=De(e=>e.messages),d=De(e=>e.agents),f=we(e=>e.session),p=jt(o),m=(0,U.useMemo)(()=>Ot(l,o,d,p.map,p.now),[l,o,d,p]),g=V(e=>e.showHud),_=V(e=>e.showLegend),v=V(e=>e.showMinimap),y=V(e=>e.showControls),b=V(e=>e.showFeed),S=V(e=>e.setShowFeed),w=V(e=>e.background),[T,E,ee]=ce([]),[D,O,ne]=me([]),[k,A]=(0,U.useState)(null),[j,M]=(0,U.useState)(null),[oe,se]=(0,U.useState)(!1),[N,P]=(0,U.useState)(``),[le,ue]=(0,U.useState)(!1),[de,fe]=(0,U.useState)(null),pe=(0,U.useMemo)(()=>{if(k?.data.kind!==`agent`)return Te;let e=k.data.serverId??(k.id.includes(`__agent-`)?k.id.split(`__agent-`).pop():k.id.replace(/^agent-/,``));return e?s.get(e)??Te:Te},[s,k]),F=(0,U.useCallback)(async()=>{let e=N.trim();if(!(!e||le)){ue(!0),fe(null);try{let t=await fetch(`/api/fleet/broadcast`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e})});if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();P(``),fe(`Delivered to ${n.delivered??0}/${n.targets??0} session(s)`)}catch(e){fe(`Failed: ${e instanceof Error?e.message:String(e)}`)}finally{ue(!1)}}},[N,le]),ge=(0,U.useRef)(new Map),_e=4e3,I=(0,U.useRef)(new Map),L=(0,U.useRef)(new Map),ve=(0,U.useRef)(new Map),R=(0,U.useRef)(new Map),ye=(0,U.useRef)(``);(0,U.useEffect)(()=>{let n=[],i=[],a=Date.now(),s=vt(m.map(e=>({id:e.id,agentCount:e.agents.length})),r),l=u.filter(e=>!e.completed&&(e.readByCount??0)===0).length,d=u.length?[...u].sort((e,t)=>Date.parse(t.timestamp)-Date.parse(e.timestamp))[0]:void 0;n.push({id:`mailbox`,type:`mailbox`,position:{x:830,y:50},data:{label:e(`activity:office.mailboxHub`),kind:`mailbox`,status:l>0?`active`:`idle`,unreadCount:l,messageCount:u.length,sublabel:d?`${d.from} → ${d.to}: ${d.subject}`:void 0,color:X.warning}});let f=0,p=0,h=0,g=0,_=0;for(let e of m)for(let t of e.agents)p+=1,(t.status===`active`||t.status===`streaming`)&&(f+=1),h+=t.toolCalls,g+=t.costUsd,_+=t.tokensIn+t.tokensOut;let v=c?o.get(c):null,y=f>0;n.push({id:`coordinator`,type:`coordinator`,position:{x:370,y:50},data:{label:e(`activity:office.fleetHqLabel`),sublabel:e(`activity:office.clientsSuffix`,{count:m.length}),kind:`coordinator`,status:v?.status===`failed`?`error`:y?`active`:`idle`,connections:m.length,agentsActive:f,agentsTotal:p,toolCalls:h,costUsd:g,tokensIn:_,color:X.primary}});let b={tui:X.success,webui:X.info,repl:X.warning};for(let t of m){let r=s.positions.get(t.id)??{x:600,y:370},o=r.x,c=r.y,u=b[t.type],d=t.status===`active`;if(n.push({id:t.id,type:t.type,position:{x:o,y:c},data:{label:t.label,sublabel:t.sublabel,kind:t.type,status:t.status,sessionId:t.sessionId,pid:t.pid,branch:t.branch,workingDir:t.workingDir,startedAt:t.startedAt,agentCount:t.agents.length,color:u}}),i.push({id:`${t.id}->coordinator`,source:t.id,target:`coordinator`,type:`wire`,animated:d,data:{color:u,animated:d,label:e(`activity:office.controlLabel`),flowType:`task`}}),i.push({id:`mailbox->${t.id}`,source:`mailbox`,target:t.id,type:`wire`,animated:l>0,data:{color:X.warning,animated:l>0,label:l>0?`${l}`:void 0,flowType:`mail`}}),t.agents.length===0){n.push({id:`desk-${t.id}`,type:`desk`,position:{x:o,y:c+270},data:{label:e(`activity:office.idleDesk`),kind:`agent`,status:`idle`,color:X.muted}});continue}t.agents.forEach((r,s)=>{let l=r.status===`active`||r.status===`streaming`,u=R.current.get(r.serverId);if(u&&(r.toolCalls>u.toolCalls||r.iteration>u.iteration)||l){ge.current.set(r.officeId,a+_e);let e=L.current.get(r.officeId)??0;L.current.set(r.officeId,Math.min(1,e+(1-e)*.5));for(let e of[`${t.id}->${r.officeId}`,`${t.id}->coordinator`]){let t=I.current.get(e)??0;I.current.set(e,Math.min(1,t+.5))}}R.current.set(r.serverId,{toolCalls:r.toolCalls,iteration:r.iteration}),n.push({id:r.officeId,type:`agent`,position:yt(o,s,t.agents.length,c+270),data:{label:r.name,kind:`agent`,status:r.status,serverId:r.serverId,sessionId:t.sessionId,currentTask:r.currentTask,iteration:r.iteration,toolCalls:r.toolCalls,costUsd:r.costUsd,tokensIn:r.tokensIn,tokensOut:r.tokensOut,ctxPct:r.ctxPct,model:r.model,lastActivityAt:r.lastActivityAt,color:X.primary}}),i.push({id:`${t.id}->${r.officeId}`,source:t.id,target:r.officeId,type:`wire`,animated:l,data:{color:X.primary,animated:l,label:l?_t(r.currentTask,48)??e(`activity:office.taskFallback`):void 0,flowType:`task`}})})}let x=new Set(m.flatMap(e=>e.agents.map(e=>e.serverId)));for(let e of[...R.current.keys()])x.has(e)||R.current.delete(e);let S=n.map(e=>{let t=ge.current.get(e.id),n=L.current.get(e.id)??0;return t&&t>a&&e.data.status!==`error`&&e.data.status!==`offline`?{...e,data:{...e.data,status:`active`,vizActivity:n}}:{...e,data:{...e.data,vizActivity:n}}}),C=i.map(e=>{let t=I.current.get(e.id)??0;return t>.05?{...e,animated:!0,data:{...e.data,animated:!0,intensity:t}}:e}),w=new Map;for(let e of S)w.set(e.id,{...e.position});ve.current=w,E(S),O(C);let T=[`${Math.round(r.width)}x${Math.round(r.height)}`,`${s.columns}x${s.rows}`,m.map(e=>`${e.id}:${e.agents.length}`).join(`|`),S.map(e=>e.id).sort().join(`|`)].join(`:`);if(T!==ye.current){ye.current=T;let e=setTimeout(()=>t({padding:mn,duration:300}),50);return()=>clearTimeout(e)}},[m,c,o,u,f,r,_e,E,O,t]);let be=m.flatMap(e=>e.agents.map(t=>({clientId:e.id,clientType:e.type,officeId:t.officeId,serverId:t.serverId}))),xe=m.map(e=>e.id),Se=new Map;for(let e of be)(!Se.has(e.serverId)||e.clientType===`webui`)&&Se.set(e.serverId,e.officeId);function z(e){return Se.get(e)??`agent-${e}`}function B(e){let t=e.split(`__agent-`)[0];return t&&t!==e?`${t}->${e}`:`coordinator->${e}`}function Oe(e){switch(e.kind){case`mailbox:send`:case`mailbox:deliver`:return{nodes:[`mailbox`],edges:e.kind===`mailbox:send`?xe.map(e=>`mailbox->${e}`):[],status:`active`};case`agent:spawned`:{let t=z(e.source);return{nodes:[`coordinator`,t],edges:[B(t)],status:`active`}}case`agent:tool`:case`tool:started`:case`tool:progress`:{let t=z(e.source);return{nodes:[`coordinator`,t],edges:[B(t)],status:e.kind===`tool:progress`||e.kind===`tool:started`?`streaming`:`active`}}case`tool:executed`:{let t=z(e.target??e.source);return{nodes:[t],edges:[B(t)],status:`active`}}case`provider:call`:case`provider:delta`:case`provider:response`:return{nodes:[`coordinator`],edges:[],status:e.kind===`provider:delta`?`streaming`:`active`};case`iteration:start`:case`iteration:end`:return{nodes:[`coordinator`],edges:be.map(e=>B(e.officeId)),status:e.kind===`iteration:start`?`streaming`:`active`};case`agent:text`:{let t=z(e.source);return{nodes:[t],edges:[B(t)],status:`streaming`}}case`agent:status`:{let t=z(e.source);return{nodes:[`coordinator`,t],edges:[B(t)],status:e.data&&typeof e.data==`object`&&`status`in e.data&&String(e.data.status)===`failed`?`error`:`completed`}}case`agent:ctx`:return{nodes:[z(e.source)],edges:[],status:`active`};case`budget:extended`:return{nodes:[`coordinator`,z(e.source)],edges:[],status:`active`};case`context:compacted`:case`context:repaired`:return{nodes:[`coordinator`],edges:[],status:`active`};case`error`:return{nodes:e.source?[z(e.source)]:[],edges:[],status:`error`};case`cost:update`:return{nodes:[`coordinator`],edges:[],status:`active`};case`fleet:snapshot`:{let t=e.data?.sessions??[],n=[`coordinator`];for(let e of t)if(e.agents)for(let t of e.agents){let e=z(t.id);n.includes(e)||n.push(e)}return{nodes:n,edges:[],status:`active`}}default:return{nodes:[],edges:[],status:`idle`}}}(0,U.useEffect)(()=>{if(a.length===0)return;let e=a[0];if(!e)return;let{nodes:t,edges:n,status:r}=Oe(e),i=Date.now();t.length>0&&(t.forEach(e=>{ge.current.set(e,i+_e);let t=L.current.get(e)??0;L.current.set(e,Math.min(1,t+(1-t)*.5))}),E(e=>e.map(e=>t.includes(e.id)?{...e,data:{...e.data,status:r,vizActivity:L.current.get(e.id)??0}}:e))),n.length>0&&(n.forEach(e=>{let t=I.current.get(e)??0;I.current.set(e,Math.min(1,t+.5))}),O(e=>e.map(e=>n.includes(e.id)?{...e,animated:!0,data:{...e.data,animated:!0,intensity:I.current.get(e.id)??1}}:e)))},[a,E,O,_e,o]),(0,U.useEffect)(()=>{let e=setInterval(()=>{let e=new Map,t=!1;for(let[n,r]of I.current){let i=r*.85;i<.05?(I.current.delete(n),e.set(n,{intensity:0,animated:!1}),t=!0):(I.current.set(n,i),e.set(n,{intensity:i,animated:!0}),t=!0)}t&&O(t=>t.map(t=>{let n=e.get(t.id);return n?{...t,animated:n.animated,data:{...t.data,animated:n.animated,intensity:n.intensity}}:t}));let n=new Map,r=!1;for(let[e,t]of L.current){let i=t*.9;i<.03?(L.current.delete(e),n.set(e,0),r=!0):(L.current.set(e,i),n.set(e,i),r=!0)}r&&E(e=>e.map(e=>{let t=n.get(e.id);return t===void 0?e:{...e,data:{...e.data,vizActivity:t}}}))},1e3);return()=>clearInterval(e)},[O,E]);let ke=(0,U.useCallback)(e=>O(t=>te({...e,type:`wire`},t)),[O]),Ae=(0,U.useCallback)((e,t)=>{A(t)},[]),je=(0,U.useCallback)(()=>{A(null)},[]);(0,U.useEffect)(()=>{if(!j)return;let e=e=>{e.key===`Escape`&&M(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[j]);let Me=(0,U.useCallback)(()=>{E(e=>e.map(e=>{let t=ve.current.get(e.id);return t?{...e,position:{...t}}:e})),setTimeout(()=>t({padding:mn,duration:300}),50)},[E,t]),[,Ne]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>{document.hidden||Ne(e=>e+1)},2e3);return()=>clearInterval(e)},[]),(0,J.jsxs)(`div`,{ref:n,className:`relative h-full w-full overflow-hidden bg-[hsl(var(--surface-2)/0.55)]`,children:[(0,J.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`
|
|
2
|
-
linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
|
|
3
|
-
linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px)
|
|
4
|
-
`,backgroundSize:`40px 40px`}}),g&&(0,J.jsx)(an,{}),(0,J.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-10`,children:(0,J.jsx)(`div`,{className:`rounded-lg border border-border/70 bg-card/90 px-4 py-2 shadow-xl backdrop-blur`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-foreground`,children:[(0,J.jsx)(h,{className:`h-4 w-4 text-primary`}),e(`activity:office.fleetHq`),(0,J.jsx)(`span`,{className:`ml-2 h-2 w-2 animate-pulse rounded-full bg-success`}),(0,J.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:e(`activity:office.live`)})]})})}),_&&(0,J.jsx)(Dn,{}),(0,J.jsxs)(re,{nodes:T,edges:D,onNodesChange:ee,onEdgesChange:ne,onConnect:ke,onNodeClick:Ae,onPaneClick:je,nodeTypes:wn,edgeTypes:En,fitView:!0,fitViewOptions:{padding:mn},minZoom:.15,maxZoom:1.5,defaultEdgeOptions:{type:`wire`},proOptions:{hideAttribution:!0},children:[(0,J.jsx)(kn,{broadcastOpen:oe,labels:{arrange:e(`activity:office.arrange`),arrangeTitle:e(`activity:office.arrangeTitle`),broadcast:e(`activity:office.broadcast`),broadcastTitle:e(`activity:office.broadcastTitle`),feed:e(`activity:office.feed`),feedTitle:e(`activity:office.feedTitle`)},onArrange:Me,onBroadcastToggle:()=>se(e=>!e),onFeedToggle:()=>S(!b),showFeed:b}),w!==`none`&&(0,J.jsx)(he,{variant:w===`lines`?ae.Lines:w===`cross`?ae.Cross:ae.Dots,gap:20,size:1,color:`hsl(var(--border) / 0.35)`}),y&&(0,J.jsx)(C,{className:`rounded-lg border border-border/70 bg-card/90 [&>button]:bg-card [&>button]:text-foreground`}),v&&(0,J.jsx)(An,{})]}),b&&(0,J.jsx)(on,{events:a,now:Date.now()}),oe&&(0,J.jsx)(On,{draft:N,isSending:le,result:de,onClose:()=>se(!1),onDraftChange:P,onSend:()=>void F()}),k&&(0,J.jsx)(Tn,{selectedNode:k,selectedAgentTranscript:pe,mailboxMessages:u,onClose:je,onOpenWatch:M}),j&&(0,J.jsx)(jn,{closeTitle:e(`activity:office.closeEsc`),label:j.label,onClose:()=>M(null),sessionId:j.sessionId,streamTitle:e(`activity:office.fullOperationStream`)})]})}function Nn(){let{t:e}=x(),t=V(e=>e.viewMode),n=V(e=>e.setViewMode),r=[{id:`office`,label:e(`activity:agentOffice.office`),description:e(`activity:agentOffice.officeDescription`),icon:E},{id:`topology`,label:e(`activity:agentOffice.topology`),description:e(`activity:agentOffice.topologyDescription`),icon:l}],i=(e,t)=>{let i;if(e.key===`ArrowLeft`&&(i=(t-1+r.length)%r.length),e.key===`ArrowRight`&&(i=(t+1)%r.length),e.key===`Home`&&(i=0),e.key===`End`&&(i=r.length-1),i===void 0)return;e.preventDefault();let a=r[i];a&&(n(a.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[i]?.focus())};return(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col bg-background`,children:[(0,J.jsx)(`nav`,{"aria-label":`${e(`activity:agentOffice.office`)} / ${e(`activity:agentOffice.topology`)}`,className:`relative z-[60] shrink-0 border-b border-border bg-card/95 px-3 pt-2 shadow-[0_8px_28px_hsl(var(--shadow-color)/0.1)] backdrop-blur-xl sm:px-5`,children:(0,J.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`mx-auto grid w-full max-w-3xl grid-cols-2 gap-1`,children:r.map((e,r)=>{let a=e.icon,o=t===e.id;return(0,J.jsxs)(`button`,{id:`office-map-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":`office-map-view-panel`,tabIndex:o?0:-1,onClick:()=>n(e.id),onKeyDown:e=>i(e,r),className:B(`group relative flex min-w-0 items-center gap-2.5 border-b-2 px-3 py-2.5 text-left transition-all duration-200 sm:gap-3 sm:px-5`,o?`border-primary bg-primary/[0.07] text-foreground`:`border-transparent text-muted-foreground hover:border-border hover:bg-accent/60 hover:text-foreground`),children:[(0,J.jsx)(`span`,{className:B(`grid h-8 w-8 shrink-0 place-items-center rounded-lg border transition-colors`,o?`border-primary/35 bg-primary/15 text-primary`:`border-border bg-background/70 text-muted-foreground group-hover:text-foreground`),children:(0,J.jsx)(a,{className:`h-4 w-4`,"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`strong`,{className:`block truncate font-display text-xs font-semibold sm:text-sm`,children:e.label}),(0,J.jsx)(`small`,{className:`hidden truncate font-mono text-[9px] font-normal text-muted-foreground sm:block`,children:e.description})]}),(0,J.jsx)(`span`,{"aria-hidden":`true`,className:B(`ml-auto h-1.5 w-1.5 shrink-0 rounded-full transition-all`,o?`bg-primary shadow-[0_0_0_4px_hsl(var(--primary)/0.12)]`:`bg-border`)})]},e.id)})})}),(0,J.jsx)(`div`,{id:`office-map-view-panel`,role:`tabpanel`,"aria-labelledby":`office-map-tab-${t}`,className:`relative min-h-0 flex-1`,children:t===`office`?(0,J.jsx)(rn,{}):(0,J.jsx)(ye,{children:(0,J.jsx)(Mn,{})})})]})}export{Nn as OfficeMapPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CM1dMeuY.js";import{Ct as n,Sa as r,Xn as i,_a as a,at as o,et as s,ia as c,ua as l}from"./vendor-2VBBgNb5.js";import"./i18n-1BkaqMgr.js";import{t as u}from"./utils-CN2sfDVP.js";import"./stores-mpa0202y.js";import{n as d,o as f,r as p,t as m}from"./dialog-CT1PTjzK.js";var h=e(r(),1),g=s(),_={btw:{label:`btw`,titleKey:`btwTitle`,tone:`bg-primary/10 text-primary border-primary/30`},steer:{label:`steer`,titleKey:`steerTitle`,tone:`bg-warning/10 text-warning border-warning/35`},queue:{label:`queue`,titleKey:`queueTitle`,tone:`bg-info/10 text-info border-info/30`}};function v({open:e,onClose:r,className:s}){let{t:v}=a(),y=t(e=>e.queue),b=t(e=>e.removeQueued),x=t(e=>e.clearQueue),[S,C]=(0,h.useState)(`oldest`),w=(0,h.useCallback)(e=>{b(e)},[b]),T=(0,h.useMemo)(()=>{let e=y.map((e,t)=>({item:e,sourceIdx:t}));return e.sort((e,t)=>S===`newest`?t.item.addedAt-e.item.addedAt:e.item.addedAt-t.item.addedAt),e},[y,S]);return(0,g.jsx)(m,{open:e,onOpenChange:e=>{e||r()},children:(0,g.jsxs)(d,{className:u(`max-w-lg gap-0 overflow-hidden border-border/80 bg-card p-0 pt-[10dvh] flex flex-col max-h-[70dvh]`,s),showCloseButton:!1,children:[(0,g.jsx)(f,{className:`sr-only`,children:v(`activity:queue.heading`)}),(0,g.jsx)(p,{className:`sr-only`,children:v(`activity:queue.subtitle`,{count:y.length})}),(0,g.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/70 bg-card/95 px-4 py-3 shrink-0`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,g.jsx)(`span`,{className:`flex items-center justify-center w-8 h-8 rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,g.jsx)(i,{className:`h-4 w-4`})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold`,children:v(`activity:queue.heading`)}),(0,g.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:v(`activity:queue.subtitle`,{count:y.length})})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,g.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>e===`newest`?`oldest`:`newest`),className:u(`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs transition-colors font-medium`,`text-muted-foreground hover:bg-muted hover:text-foreground`),title:v(S===`newest`?`activity:queue.sortNewestTitle`:`activity:queue.sortOldestTitle`),"data-testid":`queue-sort-toggle`,children:[S===`newest`?(0,g.jsx)(l,{className:`h-3 w-3`}):(0,g.jsx)(c,{className:`h-3 w-3`}),v(S===`newest`?`activity:queue.newest`:`activity:queue.oldest`)]}),y.length>0&&(0,g.jsxs)(`button`,{type:`button`,onClick:()=>x(),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs text-destructive hover:bg-destructive/10 transition-colors font-medium`,title:v(`activity:queue.clearTitle`),"data-testid":`queue-clear-all`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),v(`activity:queue.clear`)]})]})]}),(0,g.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain`,children:y.length===0?(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 gap-3 text-muted-foreground`,children:[(0,g.jsx)(i,{className:`h-10 w-10 opacity-15`}),(0,g.jsx)(`p`,{className:`text-sm font-medium`,children:v(`activity:queue.emptyTitle`)}),(0,g.jsx)(`p`,{className:`text-xs text-center max-w-xs`,children:v(`activity:queue.emptyBody`)})]}):(0,g.jsx)(`ul`,{className:`divide-y divide-border/60`,"data-testid":`queue-list`,children:T.map(({item:e,sourceIdx:t},n)=>{let r=_[e.mode];return(0,g.jsxs)(`li`,{className:`flex items-start justify-between gap-3 px-4 py-3 text-xs transition-colors hover:bg-muted/35`,"data-testid":`queue-item`,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0 flex-1`,children:[(0,g.jsxs)(`span`,{className:`mt-1 text-[10px] font-mono text-muted-foreground shrink-0 w-5 text-right tabular-nums`,children:[n+1,`.`]}),(0,g.jsx)(`span`,{className:u(`shrink-0 inline-flex items-center justify-center rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,r.tone),title:v(`activity:queue.${r.titleKey}`),"data-testid":`queue-mode-${e.mode}`,children:r.label}),(0,g.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed min-w-0 break-words`,children:e.text.length>120?`${e.text.slice(0,117)}…`:e.text})]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>w(t),className:`ml-1 p-1.5 rounded-md shrink-0 hover:bg-destructive/10 hover:text-destructive transition-colors`,title:v(`activity:queue.removeTitle`),"data-testid":`queue-remove-${t}`,children:(0,g.jsx)(o,{className:`h-3.5 w-3.5`})})]},`${e.addedAt}-${t}`)})})}),y.length>0&&(0,g.jsx)(`div`,{className:`border-t border-border/70 bg-muted/20 px-4 py-2.5 shrink-0`,children:(0,g.jsx)(`p`,{className:`text-[10px] text-muted-foreground text-center`,children:v(`activity:queue.footer`)})})]})})}export{v as QueuePanel};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MemoryManager-D_rquas9.js","assets/rolldown-runtime-QTnfLwEv.js","assets/vendor-2VBBgNb5.js","assets/monaco-BLUV5g0U.js","assets/monaco-Bowa0-zp.css","assets/markdown-L6DLSM7f.js","assets/vendor-BMdWcCR4.css","assets/ui-store-CS-njcmT.js","assets/useWebSocket-Dh3aAFDE.js","assets/chat-store-CM1dMeuY.js","assets/utils-CN2sfDVP.js","assets/i18n-1BkaqMgr.js","assets/activity-qoJ3grs0.js","assets/chat-BJzPxfyr.js","assets/commandPalette-DpaemFux.js","assets/common-suUxW9sA.js","assets/settings-D6wFOw5n.js","assets/setup-BFcmn89w.js","assets/toasts-BL_8kH4B.js","assets/ws-client-WVGn8ORh.js","assets/session-store-BsNYnfOc.js","assets/codemap-activity-store-DP3mCZu1.js","assets/stores-mpa0202y.js","assets/mailbox-store-DVoNbOZr.js","assets/view-navigation-Cgy5xh9q.js","assets/codemap-index-store-DyAe3ZYJ.js","assets/Toaster-CbcX_Cou.js","assets/dialog-CT1PTjzK.js","assets/button-uGqXvobk.js","assets/input-B-VCX2sG.js","assets/index-BPfIz78e.js","assets/ModelPicker-CN-UD3lc.js","assets/LazyMarkdown-BGwFjYKr.js","assets/index-BlceaIyu.css","assets/roster-ws-DXm0krqH.js","assets/shared-jvJxtKc5.js","assets/AudienceMemoryPanel-DB-8ISNP.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Sa as t,Zn as n,et as r,pt as i}from"./vendor-2VBBgNb5.js";import{s as a}from"./monaco-BLUV5g0U.js";import{t as o}from"./utils-CN2sfDVP.js";import{_ as s,g as c,h as l,v as u}from"./index-BPfIz78e.js";var d=e(t(),1),f=r(),p=(0,d.lazy)(()=>a(()=>import(`./MemoryManager-D_rquas9.js`).then(e=>({default:e.MemoryManager})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]))),m=(0,d.lazy)(()=>a(()=>import(`./AudienceMemoryPanel-DB-8ISNP.js`).then(e=>({default:e.AudienceMemoryPanel})),__vite__mapDeps([36,1,2,3,4,5,6,8,9,10,11,7,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35])));function h({label:e}){return(0,f.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-background text-xs text-muted-foreground`,"aria-busy":`true`,children:(0,f.jsxs)(`span`,{className:`font-mono uppercase tracking-wide`,children:[e,`…`]})})}var g=[{value:`all`,label:`All memories`,hint:`Inspect, curate, retire`,Icon:n},{value:`audience`,label:`Audience-scoped`,hint:`Guidance routed to agents`,Icon:i}];function _({defaultValue:e=`all`}={}){return(0,f.jsxs)(l,{defaultValue:e,className:`flex h-full min-h-0 min-w-0 flex-1 flex-col`,children:[(0,f.jsx)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-border/70 bg-card/55 px-4 py-2 sm:px-5`,role:`presentation`,children:(0,f.jsx)(s,{"aria-label":`SAGE memory lenses`,className:`h-9 bg-muted/40 p-1 shadow-none`,children:g.map(({value:e,label:t,hint:n,Icon:r})=>(0,f.jsxs)(u,{value:e,className:o(`h-7 gap-2 px-3 text-[11px] font-semibold uppercase tracking-wide`,`data-[state=active]:bg-background data-[state=active]:text-foreground`,`data-[state=active]:shadow-[0_0_0_1px_hsl(var(--border)/0.7)]`),children:[(0,f.jsx)(r,{className:`size-3.5`}),(0,f.jsx)(`span`,{children:t}),(0,f.jsx)(`span`,{className:`hidden font-mono text-[9px] font-normal normal-case text-muted-foreground sm:inline`,children:n})]},e))})}),(0,f.jsx)(c,{value:`all`,className:`mt-0 flex-1 overflow-hidden ring-offset-0 focus-visible:ring-0`,children:(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(h,{label:`Loading SAGE`}),children:(0,f.jsx)(p,{})})}),(0,f.jsx)(c,{value:`audience`,className:`mt-0 flex-1 overflow-hidden ring-offset-0 focus-visible:ring-0`,children:(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(h,{label:`Loading audience memories`}),children:(0,f.jsx)(m,{})})})]})}export{_ as SageTabs};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$r as t,Ai as n,Ct as r,Et as i,Ft as a,Ii as o,Ir as s,It as c,Kn as l,Lt as u,Mt as d,On as ee,Pn as f,Ri as p,Sa as m,Si as h,Tt as g,Xt as te,Yi as _,_a as v,an as y,at as b,ba as x,br as S,bt as C,et as w,gi as T,gt as ne,in as E,it as D,ma as O,mn as k,mt as A,oi as j,sa as re,yn as M,yt as N,zi as P,zn as ie}from"./vendor-2VBBgNb5.js";import"./i18n-1BkaqMgr.js";import{n as F}from"./ui-store-CS-njcmT.js";import{t as ae}from"./useWebSocket-Dh3aAFDE.js";import{t as I}from"./utils-CN2sfDVP.js";import{a as L,o as R,u as z}from"./stores-mpa0202y.js";import{o as B}from"./view-navigation-Cgy5xh9q.js";import{a as V,i as H,n as U,o as W,r as G,t as K}from"./dialog-CT1PTjzK.js";import{t as q}from"./button-uGqXvobk.js";import{n as oe,t as se}from"./ModelPicker-CN-UD3lc.js";import{b as ce,u as le}from"./index-BPfIz78e.js";import{a as J,c as ue,i as Y,l as X,n as de,o as fe,r as pe,s as me,t as he,u as ge}from"./progress-ring-CFOvGxw7.js";import{SpecsView as _e}from"./SpecsView-BJs_okSx.js";var Z=e(m(),1),Q=w();function ve({feed:e,now:t}){let{t:n}=v();return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-semibold text-foreground`,children:[(0,Q.jsx)(O,{className:`h-3.5 w-3.5 text-warning`}),n(`activity:sdd.activityHeading`)]}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 space-y-1 overflow-auto overscroll-contain p-2`,children:e.length===0?(0,Q.jsx)(`p`,{className:`px-1 pt-4 text-center text-[11px] text-muted-foreground`,children:n(`activity:sdd.feedEmpty`)}):e.map((e,n)=>{let r=Y[e.kind]??Y.started,i=r.icon;return(0,Q.jsxs)(`div`,{className:I(`sdd-rise flex items-start gap-2 rounded-md px-2 py-1.5 text-[11px]`,n===0?`bg-muted`:`hover:bg-muted`),children:[(0,Q.jsx)(i,{className:I(`mt-0.5 h-3.5 w-3.5 shrink-0`,r.color)}),(0,Q.jsx)(`span`,{className:`flex-1 leading-snug text-foreground`,children:e.text}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums text-[10px] text-muted-foreground`,children:me(e.ts,t)})]},`${e.ts}-${n}`)})})]})}function ye({open:e,onOpenChange:t,snapshot:n,busy:i,onConfirm:a}){let{t:o}=v(),s=n?.mergedCommits?.length??0,c=n?.baseBranch,[u,d]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&d(!1)},[e]);let ee=n?.status===`running`||n?.status===`paused`,f=(0,Z.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.worktreeBranch&&e.add(t.worktreeBranch);return e.size},[n?.tasks]),p=(0,Z.useMemo)(()=>{let e=new Set;for(let t of n?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.add(t.agentName);return e.size},[n?.tasks]);return(0,Q.jsx)(K,{open:e,onOpenChange:e=>!i&&t(e),children:(0,Q.jsxs)(U,{className:`sm:max-w-lg border-destructive/50`,children:[(0,Q.jsxs)(V,{children:[(0,Q.jsxs)(W,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`h-5 w-5 text-destructive`}),o(`activity:sdd.destroyTitle`)]}),(0,Q.jsx)(G,{children:o(`activity:sdd.destroyDesc`)})]}),(0,Q.jsxs)(`ul`,{className:`space-y-1.5 py-1 text-sm`,children:[ee&&(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:p>0?o(`activity:sdd.stopRunAgents`,{count:p}):o(`activity:sdd.stopRun`)})]}),(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:f>0?o(`activity:sdd.removeWorktreesCount`,{count:f}):o(`activity:sdd.removeWorktreesAll`)})]}),(0,Q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 text-destructive`,children:`■`}),(0,Q.jsx)(`span`,{children:o(`activity:sdd.deleteArtifacts`)})]})]}),s>0&&(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md border border-warning/30 bg-warning/5 p-2.5 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`mt-0.5 h-4 w-4 accent-warning`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:o(`activity:sdd.revertMerged`,{count:s})}),` `,`on `,(0,Q.jsx)(`code`,{className:`text-xs`,children:c??o(`activity:sdd.baseBranchFallback`)}),(0,Q.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:o(`activity:sdd.revertHint`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted/50 p-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),o(s>0&&!u?`activity:sdd.noteLeaveMerged`:`activity:sdd.noteAbandon`)]}),(0,Q.jsxs)(H,{className:`gap-2 sm:gap-2`,children:[(0,Q.jsx)(q,{variant:`outline`,size:`sm`,disabled:i,onClick:()=>t(!1),children:o(`common:action.cancel`)}),(0,Q.jsx)(q,{size:`sm`,disabled:i,onClick:()=>a(u),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(l,{className:`mr-1 h-3.5 w-3.5 animate-spin`}),` `,o(`activity:sdd.destroying`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(r,{className:`mr-1 h-3.5 w-3.5`}),` `,o(`activity:sdd.destroyAll`)]})})]})]})})}var be=[{key:`pending`,labelKey:`kanbanBacklog`,accent:`border-border/70`,head:`text-muted-foreground`},{key:`queued`,labelKey:`kanbanReady`,accent:`border-primary/35`,head:`text-primary`},{key:`in_progress`,labelKey:`kanbanRunning`,accent:`border-warning/45`,head:`text-warning`},{key:`review`,labelKey:`kanbanReview`,accent:`border-primary/35`,head:`text-primary`},{key:`failed`,labelKey:`kanbanFailed`,accent:`border-destructive/35`,head:`text-destructive`},{key:`completed`,labelKey:`kanbanDone`,accent:`border-success/35`,head:`text-success`}];function xe({tasks:e,selectedId:t,onTaskClick:n}){let{t:r}=v(),i=(0,Z.useMemo)(()=>{let t=new Map;for(let e of be)t.set(e.key,[]);for(let n of e){let e=n.displayStatus===`blocked`?`pending`:n.displayStatus===`cancelled`?`failed`:n.displayStatus;(t.get(e)??t.get(`pending`))?.push(n)}return t},[e]);return(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 gap-3 overflow-x-auto p-4`,children:be.map(e=>{let a=i.get(e.key)??[];return(0,Q.jsxs)(`div`,{className:`flex min-h-0 w-64 shrink-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:I(`mb-2 flex items-center gap-2 border-b-2 pb-1.5`,e.accent),children:[(0,Q.jsx)(`span`,{className:I(`text-xs font-bold uppercase tracking-wide`,e.head),children:r(`activity:sdd.${e.labelKey}`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.length})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1`,children:[a.map(e=>(0,Q.jsx)(Se,{task:e,selected:e.id===t,onClick:()=>n(e.id)},e.id)),a.length===0&&(0,Q.jsx)(`div`,{className:`rounded-md border border-dashed border-border py-6 text-center text-[10px] text-muted-foreground`,children:r(`activity:sdd.kanbanEmpty`)})]})]},e.key)})})}function Se({task:e,selected:t,onClick:n}){let r=e.displayStatus===`in_progress`;return(0,Q.jsxs)(`button`,{type:`button`,onClick:n,className:I(`sdd-node-enter w-full rounded-lg border bg-card/85 p-2 text-left shadow-sm transition hover:border-primary/35 hover:bg-accent/35`,t?`border-primary/55 ring-1 ring-primary/35`:`border-border/70`,r&&`sdd-node-running`,e.displayStatus===`completed`&&`sdd-node-complete`,e.displayStatus===`failed`&&`sdd-node-failed`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[r&&(0,Q.jsx)(l,{className:`h-3 w-3 animate-spin text-warning`}),e.displayStatus===`completed`&&(0,Q.jsx)(P,{className:`h-3 w-3 text-success`}),e.displayStatus===`failed`&&(0,Q.jsx)(b,{className:`h-3 w-3 text-destructive`}),(0,Q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.shortId}),(0,Q.jsx)(`span`,{className:I(`ml-auto rounded px-1.5 text-[9px] font-bold uppercase`,X(e.priority).chip),children:e.priority})]}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-snug text-foreground`,children:e.title}),(e.agentName||e.worktreeBranch||e.retries)&&(0,Q.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[e.agentName&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:I(`flex h-4 w-4 items-center justify-center rounded-full text-[8px] font-bold text-white`,r?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:fe(e.agentName)}),(0,Q.jsx)(`span`,{className:`max-w-[80px] truncate text-[10px] text-muted-foreground`,children:e.agentName})]}),e.retries?(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[9px] text-destructive`,children:[(0,Q.jsx)(E,{className:`h-2.5 w-2.5`}),e.retries]}):null,e.worktreeBranch&&(0,Q.jsx)(S,{className:`ml-auto h-2.5 w-2.5 text-muted-foreground`})]})]})}function Ce({task:e,allTasks:t,feed:n,now:i,expanded:o,modelCandidates:s,defaultModel:c,onClose:l,onToggleExpanded:u,onRetry:ee,onReassign:p,onSetModel:m,onSetVerification:h,onCancel:g,onDelete:te,onSplit:_,onSelectTask:y}){let{t:x}=v(),C=ge(e.displayStatus),w=C.icon,D=e.displayStatus===`in_progress`,O=e.displayStatus===`pending`||e.displayStatus===`blocked`||e.displayStatus===`queued`,[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(``),[N,F]=(0,Z.useState)(null),[ae,L]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(``),[B,V]=(0,Z.useState)(!1),[H,U]=(0,Z.useState)(e.verificationCommand??``),W=()=>{j.trim()&&(p(e.id,j.trim()),A(!1),M(``))},G=()=>{let t=R.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean).map(e=>{let[t,...n]=e.split(`::`),r=(t??``).trim();return{title:r,description:n.join(`::`).trim()||r}}).filter(e=>e.title);t.length&&(_(e.id,t),L(!1),z(``))},K=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.shortId,e])),[t]),q=(0,Z.useMemo)(()=>t.filter(t=>t.deps.includes(e.shortId)),[t,e.shortId]),oe=(0,Z.useMemo)(()=>n.filter(t=>t.taskId===e.id||t.taskShortId===e.shortId),[n,e.id,e.shortId]),ce=e.startedAt&&!e.completedAt?ue(i-e.startedAt):e.startedAt&&e.completedAt?ue(e.completedAt-e.startedAt):null;return(0,Q.jsxs)(`div`,{className:`sdd-rise flex h-full min-h-0 min-w-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:I(`flex items-center gap-2 border-b border-border/70 bg-card/70 px-3 py-2`,o&&`px-5 py-3`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:l,className:`text-muted-foreground hover:text-foreground`,title:x(`activity:sddTask.backTitle`),children:(0,Q.jsx)(re,{className:`h-4 w-4`})}),(0,Q.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),u&&(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`ml-1 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition hover:bg-muted hover:text-foreground`,title:x(o?`activity:sddTask.collapseTitle`:`activity:sddTask.expandTitle`),"aria-label":x(o?`activity:sddTask.collapseTitle`:`activity:sddTask.expandTitle`),"aria-pressed":o,children:o?(0,Q.jsx)(f,{className:`h-4 w-4`}):(0,Q.jsx)(ie,{className:`h-4 w-4`})}),(0,Q.jsxs)(`span`,{className:I(`ml-auto flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]`,C.ring,C.text),children:[(0,Q.jsx)(w,{className:I(`h-3 w-3`,D&&`animate-spin`)}),C.label]})]}),(0,Q.jsxs)(`div`,{className:I(`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain`,o?`grid grid-cols-2 content-start gap-4 p-5`:`space-y-3 p-3`),children:[(0,Q.jsx)(`h3`,{className:I(`text-sm font-semibold leading-snug text-foreground`,o&&`col-span-2 text-lg`),children:e.title}),e.agentName&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/70 bg-muted/45 p-2`,children:[(0,Q.jsx)(`span`,{className:I(`flex h-7 w-7 items-center justify-center rounded-full text-[10px] font-bold text-white`,D?`bg-warning sdd-agent-live`:`bg-muted-foreground`),children:fe(e.agentName)}),(0,Q.jsxs)(`div`,{className:`leading-tight`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:e.agentName}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:x(D?`activity:sddTask.workingOn`:`activity:sddTask.assigned`)})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 text-[11px]`,children:[(0,Q.jsx)(Te,{label:x(`activity:sddTask.metaPriority`),children:(0,Q.jsx)(`span`,{className:I(`font-medium uppercase`,X(e.priority).text),children:e.priority})}),(0,Q.jsx)(Te,{label:x(`activity:sddTask.metaType`),children:e.type}),ce&&(0,Q.jsx)(Te,{label:e.completedAt?x(`activity:sddTask.metaDuration`):x(`activity:sddTask.metaElapsed`),children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(T,{className:`h-3 w-3 text-muted-foreground`}),ce]})}),e.retries?(0,Q.jsx)(Te,{label:x(`activity:sddTask.metaRetries`),children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-destructive`,children:[(0,Q.jsx)(E,{className:`h-3 w-3`}),e.retries]})}):null,e.worktreeBranch&&(0,Q.jsx)(Te,{label:x(`activity:sddTask.metaWorktree`),full:!0,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-foreground`,title:e.worktreeBranch,children:[(0,Q.jsx)(S,{className:`h-3 w-3 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.worktreeBranch})]})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[x(`activity:sddTask.workerModel`),!e.model&&c&&(0,Q.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,x(`activity:sddTask.runDefault`,{model:c})]})]}),(0,Q.jsx)(se,{value:e.model,provider:e.provider,candidates:s,placeholder:c?x(`activity:sddTask.runDefaultPlaceholderModel`,{model:c}):x(`activity:sddTask.runDefaultPlaceholder`),onPick:(t,n)=>m(e.id,t,n),onReset:e.model?()=>m(e.id,void 0,void 0):void 0}),e.fallbackModels&&e.fallbackModels.length>0&&(0,Q.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.fallbackModels.map(e=>(0,Q.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`↳ `,e]},e))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[x(`activity:sddTask.verificationCmd`),(0,Q.jsxs)(`span`,{className:`font-normal normal-case text-muted-foreground`,children:[`· `,x(`activity:sddTask.gatesCompletion`)]})]}),B?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`input`,{value:H,onChange:e=>U(e.target.value),onKeyDown:t=>{t.key===`Enter`?(h(e.id,H.trim()||void 0),V(!1)):t.key===`Escape`&&(U(e.verificationCommand??``),V(!1))},placeholder:x(`activity:sddTask.verifyPlaceholder`),className:`w-full rounded border border-border bg-background px-2 py-1 font-mono text-[11px] text-foreground`}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{h(e.id,H.trim()||void 0),V(!1)},className:`rounded bg-primary px-2 py-0.5 text-[10px] text-primary-foreground hover:opacity-90`,children:x(`common:action.save`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{U(e.verificationCommand??``),V(!1)},className:`rounded bg-muted px-2 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:x(`common:action.cancel`)})]})]}):e.verificationCommand?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.verificationState&&(0,Q.jsx)(`span`,{title:e.verificationDetail,className:e.verificationState===`passed`?`rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success`:`rounded bg-destructive/10 px-1.5 py-0.5 text-[10px] text-destructive`,children:e.verificationState===`passed`?`✓ verified`:`✗ failed`}),(0,Q.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e.verificationCommand}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>V(!0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:x(`common:action.edit`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>h(e.id,void 0),className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted/80`,children:x(`common:action.clear`)})]}):(0,Q.jsx)(`button`,{type:`button`,onClick:()=>V(!0),className:`rounded border border-dashed border-border px-2 py-1 text-[10px] text-muted-foreground hover:bg-muted`,children:x(`activity:sddTask.addVerify`)})]}),e.description&&(0,Q.jsxs)(`div`,{className:I(o&&`col-span-2`),children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:x(`activity:sddTask.description`)}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md bg-muted p-2 text-[11px] leading-relaxed text-foreground`,children:e.description})]}),(0,Q.jsx)(we,{events:oe,expanded:o}),e.deps.length>0&&(0,Q.jsx)(Ee,{title:x(`activity:sddTask.dependsOn`),shortIds:e.deps,byShort:K,onSelectTask:y}),q.length>0&&(0,Q.jsx)(Ee,{title:x(`activity:sddTask.blocks`),shortIds:q.map(e=>e.shortId),byShort:K,onSelectTask:y})]}),(0,Q.jsxs)(`div`,{className:I(`border-t border-border p-2`,o&&`px-5 py-3`),children:[k?(0,Q.jsxs)(`div`,{className:`sdd-rise flex items-center gap-1.5`,children:[(0,Q.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&W(),e.key===`Escape`&&A(!1)},placeholder:x(`activity:sddTask.newWorkerPlaceholder`),className:`min-w-0 flex-1 rounded-md border border-border/70 bg-background px-2 py-1.5 text-xs outline-none focus:border-primary/60`}),(0,Q.jsx)(`button`,{type:`button`,onClick:W,disabled:!j.trim(),className:`rounded-md bg-primary/10 px-2 py-1.5 text-xs font-medium text-primary hover:bg-primary/15 disabled:opacity-40`,children:(0,Q.jsx)(P,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!1),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(b,{className:`h-3.5 w-3.5`})})]}):N?(0,Q.jsxs)(`div`,{className:`sdd-rise flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`flex-1 text-xs text-foreground`,children:x(N===`stop`?`activity:sddTask.confirmStop`:`activity:sddTask.confirmDelete`)}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{N===`stop`?g(e.id):te(e.id),F(null)},className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(P,{className:`h-3.5 w-3.5`}),` `,x(N===`stop`?`common:action.stop`:`common:action.delete`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(null),className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(b,{className:`h-3.5 w-3.5`})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ee(e.id),title:x(`activity:sddTask.retryTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-warning/12 py-1.5 text-xs font-medium text-warning hover:bg-warning/18`,children:[(0,Q.jsx)(E,{className:`h-3.5 w-3.5`}),` `,x(`common:action.retry`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>A(!0),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),` `,x(`activity:sddTask.reassign`)]}),D&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>F(`stop`),title:x(`activity:sddTask.stopTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-destructive/10 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(d,{className:`h-3.5 w-3.5`}),` `,x(`common:action.stop`)]}),!D&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>L(!0),title:x(`activity:sddTask.splitTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(a,{className:`h-3.5 w-3.5`}),` `,x(`activity:sddTask.split`)]}),O&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>F(`delete`),title:x(`activity:sddTask.deleteTitle`),className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-destructive/10 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/15`,children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5`}),` `,x(`common:action.delete`)]})]}),ae&&(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,htmlFor:`sdd-split-input`,children:x(`activity:sddTask.splitHint`)}),(0,Q.jsx)(`textarea`,{id:`sdd-split-input`,rows:3,value:R,onChange:e=>z(e.target.value),placeholder:x(`activity:sddTask.splitPlaceholder`),className:`w-full resize-y rounded-md border border-border/70 bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring`}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:G,className:`inline-flex flex-1 items-center justify-center gap-1 rounded-md bg-primary/10 py-1.5 text-xs font-medium text-primary hover:bg-primary/15`,children:[(0,Q.jsx)(a,{className:`h-3.5 w-3.5`}),` `,x(`activity:sddTask.splitInto`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{L(!1),z(``)},className:`rounded-md bg-muted px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted`,children:(0,Q.jsx)(b,{className:`h-3.5 w-3.5`})})]})]})]})]})}function we({events:e,expanded:t}){let{t:n}=v();return(0,Q.jsxs)(`section`,{className:I(`rounded-lg border border-border/70 bg-background/45`,t&&`col-span-2`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-3 py-2.5`,children:[(0,Q.jsx)(O,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`activity:sddTask.eventLog`)}),(0,Q.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,children:e.length}),(0,Q.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:n(`activity:sddTask.newestFirst`)})]}),e.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-5 text-center text-[11px] text-muted-foreground`,children:n(`activity:sddTask.noEvents`)}):(0,Q.jsx)(`div`,{className:I(`divide-y divide-border/45 overflow-auto`,t?`max-h-[32rem]`:`max-h-72`),children:e.map((e,t)=>{let n=e.kind===`file`,r=e.kind===`tool`,i=e.ok===!1||e.kind===`failed`||e.kind===`verification_failed`,a=n?s:r?g:O;return(0,Q.jsxs)(`div`,{className:I(`grid grid-cols-[4.75rem_1rem_minmax(0,1fr)] gap-2 px-3 py-2.5 text-[11px]`,i&&`bg-destructive/[0.035]`),children:[(0,Q.jsx)(`time`,{dateTime:new Date(e.ts).toISOString(),className:`font-mono text-[10px] text-muted-foreground`,title:new Date(e.ts).toLocaleString(),children:new Date(e.ts).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,Q.jsx)(a,{className:I(`mt-0.5 h-3.5 w-3.5`,i?`text-destructive`:n?`text-info`:r?`text-warning`:`text-primary`)}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.action&&(0,Q.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] font-medium text-foreground`,children:e.action}),e.agentName&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.agentName}),e.durationMs!==void 0&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.durationMs<1e3?`${Math.round(e.durationMs)}ms`:`${(e.durationMs/1e3).toFixed(1)}s`})]}),e.filePath?(0,Q.jsx)(`code`,{className:`mt-1 block break-all font-mono text-[10px] leading-relaxed text-foreground`,children:e.filePath}):e.detail?(0,Q.jsx)(`code`,{className:`mt-1 block break-words font-mono text-[10px] leading-relaxed text-muted-foreground`,children:e.detail}):(0,Q.jsx)(`p`,{className:`mt-1 break-words leading-relaxed text-foreground`,children:e.text})]})]},`${e.ts}-${e.kind}-${t}`)})})]})}function Te({label:e,children:t,full:n}){return(0,Q.jsxs)(`div`,{className:I(`rounded-md border border-border bg-muted/50 px-2 py-1`,n&&`col-span-2`),children:[(0,Q.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`text-foreground`,children:t})]})}function Ee({title:e,shortIds:t,byShort:n,onSelectTask:r}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>{let t=n.get(e);return(0,Q.jsxs)(`button`,{type:`button`,disabled:!t,onClick:()=>t&&r(t.id),className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-foreground hover:bg-muted disabled:opacity-50`,title:t?.title,children:[(0,Q.jsx)(`span`,{className:I(`h-1.5 w-1.5 rounded-full`,ge(t?.displayStatus??`pending`).dot)}),(0,Q.jsx)(`span`,{className:`font-mono`,children:e})]},e)})})]})}function De({onClose:e}){let{t:n}=v(),{client:i}=ae(),a=R(e=>e.snapshot),o=R(e=>e.lifecycleResult),s=R(e=>e.destroying),c=R(e=>e.setDestroying),l=R(e=>e.setLifecycleResult),[u,ee]=(0,Z.useState)(()=>Date.now()),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,te]=(0,Z.useState)(`graph`),[_,y]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{i?.send?.({type:`sdd.board.get`})},[i]);let x=a&&(a.status===`running`||a.status===`paused`);(0,Z.useEffect)(()=>{if(!x)return;let e=setInterval(()=>ee(Date.now()),1e3);return ee(Date.now()),()=>clearInterval(e)},[x]);let S=(0,Z.useCallback)(e=>i?.send?.(e),[i]),w=(0,Z.useRef)(null),T=(0,Z.useCallback)(e=>{w.current=null,S({type:`sdd.board.destroy`,payload:{revertMerged:e}})},[S]),ne=(0,Z.useCallback)(e=>{y(!1),l(null),c(!0),x?(S({type:`sdd.board.stop`,payload:{}}),w.current={revertMerged:e,deadline:Date.now()+2e4}):T(e)},[x,S,T,c,l]);(0,Z.useEffect)(()=>{let e=w.current;e&&(!x||Date.now()>=e.deadline)&&T(e.revertMerged)},[x,a,T]);let A=(0,Z.useCallback)(()=>{l(null),S({type:`sdd.board.cleanup_worktrees`,payload:{}})},[S,l]),re=(0,Z.useCallback)(()=>{l(null),S({type:`sdd.board.rollback`,payload:{}})},[S,l]),P=(0,Z.useMemo)(()=>(a?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch})),[a?.tasks]),ie=(0,Z.useMemo)(()=>{let e=new Map;for(let t of a?.tasks??[])t.displayStatus===`in_progress`&&t.agentName&&e.set(t.agentName,{name:t.agentName,task:t.title});return[...e.values()]},[a?.tasks]),L=(0,Z.useCallback)(e=>p(e),[]),B=(0,Z.useCallback)(()=>{p(null),h(!1)},[]),V=(0,Z.useCallback)(e=>S({type:`sdd.board.retry`,payload:{taskId:e}}),[S]),H=(0,Z.useCallback)(()=>S({type:`sdd.board.retry_all_failed`,payload:{}}),[S]),U=(0,Z.useCallback)((e,t)=>{let n=t.trim();n&&S({type:`sdd.board.reassign`,payload:{taskId:e,agentName:n}})},[S]),W=(0,Z.useCallback)((e,t,n)=>S({type:`sdd.board.set_task_model`,payload:{taskId:e,model:t,provider:n}}),[S]),G=(0,Z.useCallback)((e,t)=>S({type:`sdd.board.set_task_verification`,payload:{taskId:e,verificationCommand:t}}),[S]),K=(0,Z.useCallback)(e=>S({type:`sdd.board.cancel_task`,payload:{taskId:e}}),[S]),se=(0,Z.useCallback)(e=>{S({type:`sdd.board.delete_task`,payload:{taskId:e}}),p(null),h(!1)},[S]),ce=(0,Z.useCallback)((e,t)=>{S({type:`sdd.board.split_task`,payload:{taskId:e,subtasks:t}}),p(null),h(!1)},[S]),le=oe(f!==null),Y=(0,Z.useMemo)(()=>a?.tasks.find(e=>e.id===f)??null,[a?.tasks,f]),X=a?.progress,me=a?.diagnostics?.deadlockChains??[];return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsxs)(`header`,{className:`sdd-sheen shrink-0 border-b border-border px-4 pb-3 pt-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(O,{className:`h-5 w-5 text-warning`}),(0,Q.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:a?.title??n(`activity:sddBoard.titleFallback`)}),a&&(0,Q.jsx)(`span`,{className:I(`rounded-full border px-2 py-0.5 text-[11px] font-medium capitalize`,J[a.status]??J.idle),children:a.status}),a?.defaultModel&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-[10px] text-muted-foreground`,title:n(`activity:sddBoard.defaultModelTitle`),children:[(0,Q.jsx)(j,{className:`h-3 w-3 text-primary`}),a.defaultModel]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,Q.jsxs)(`button`,{type:`button`,title:`Open the mirrored kanban board(s) for this run (one per dependency wave)`,onClick:()=>{let e=`run:${a.runId}`,t=z.getState().boards.filter(t=>t.tags?.includes(e)),n=t.find(e=>e.tags?.includes(`phase:wave-0`))??t[0];n&&z.getState().setActiveBoardId(n.id),F.getState().setCurrentView(`kanban`)},className:`inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted`,children:[(0,Q.jsx)(O,{className:`h-3.5 w-3.5`}),` Kanban`]}),a&&(0,Q.jsx)(`div`,{className:`flex items-center rounded-md border border-border bg-muted p-0.5 text-[11px]`,children:[`graph`,`kanban`].map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>te(e),className:I(`rounded px-2 py-0.5 capitalize transition`,g===e?`bg-primary/12 text-primary`:`text-muted-foreground hover:text-foreground`),children:n(e===`graph`?`activity:sddBoard.graphLabel`:`activity:sddBoard.kanbanLabel`)},e))}),x&&(X?.failed??0)>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:H,title:n(`activity:sddBoard.retryAllTitle`),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(E,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddBoard.retryFailed`,{count:X?.failed??0})]}),x&&(0,Q.jsxs)(Q.Fragment,{children:[a?.status===`paused`?(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.resume`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-success/15 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/25`,children:[(0,Q.jsx)(k,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddBoard.resume`)]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.pause`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(M,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddBoard.pause`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>S({type:`sdd.board.stop`,payload:{}}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/15 px-2.5 py-1 text-xs font-medium text-destructive hover:bg-destructive/25`,children:[(0,Q.jsx)(d,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddBoard.stop`)]})]}),a&&!x&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:A,title:n(`activity:sddBoard.cleanTitle`),className:`inline-flex items-center gap-1 rounded-md bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted/80`,children:[(0,Q.jsx)(t,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddBoard.cleanWorktrees`)]}),(a.mergedCommits?.length??0)>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:re,title:n(`activity:sddBoard.rollbackTitle`,{count:a.mergedCommits?.length??0,base:a.baseBranch??n(`activity:sdd.baseBranchFallback`)}),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/25`,children:[(0,Q.jsx)(N,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddBoard.rollback`,{count:a.mergedCommits?.length??0})]})]}),a&&(s?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-destructive/15 px-2.5 py-1 text-xs font-medium text-destructive`,children:[(0,Q.jsx)(E,{className:`h-3.5 w-3.5 animate-spin`}),` `,n(x?`activity:sddBoard.stopping`:`activity:sddBoard.destroying`)]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>y(!0),title:n(`activity:sddBoard.destroyTitle`),className:`inline-flex items-center gap-1 rounded-md bg-destructive px-2.5 py-1 text-xs font-medium text-destructive-foreground hover:bg-destructive/90`,children:[(0,Q.jsx)(r,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddBoard.destroy`)]})),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Q.jsx)(b,{className:`h-4 w-4`})})]})]}),a&&X&&(0,Q.jsxs)(`div`,{className:`mt-2.5 flex items-center gap-5`,children:[(0,Q.jsx)(he,{pct:X.percentComplete}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,Q.jsx)(Ae,{label:n(`activity:sddBoard.statDone`),value:`${X.completed}/${X.total}`,color:`text-success`}),X.inProgress>0&&(0,Q.jsx)(Ae,{label:n(`activity:sddBoard.statRunning`),value:X.inProgress,color:`text-warning`}),X.failed>0&&(0,Q.jsx)(Ae,{label:n(`activity:sddBoard.statFailed`),value:X.failed,color:`text-destructive`}),(0,Q.jsx)(Ae,{label:n(`activity:sddBoard.statWave`),value:a.wave+1,color:`text-primary`}),x&&a.startedAt>0&&(0,Q.jsx)(Ae,{label:n(`activity:sddBoard.statElapsed`),value:ue(u-a.startedAt),color:`text-foreground`})]}),(0,Q.jsx)(`div`,{className:`flex min-h-[24px] items-center gap-1.5`,children:ie.length===0?(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:n(`activity:sddBoard.noActiveWorkers`)}):ie.map((e,t)=>(0,Q.jsxs)(`span`,{title:`${e.name} → ${e.task}`,className:`flex items-center gap-1 rounded-full bg-muted py-0.5 pl-0.5 pr-2`,children:[(0,Q.jsx)(`span`,{className:I(`sdd-agent-live flex h-5 w-5 items-center justify-center rounded-full text-[9px] font-bold text-white`,pe[t%pe.length]),children:fe(e.name)}),(0,Q.jsx)(`span`,{className:`max-w-[90px] truncate text-[11px] text-foreground`,children:e.name})]},e.name))})]})]})]}),o&&(0,Q.jsx)(ke,{result:o,onDismiss:()=>l(null)}),me.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:[(0,Q.jsx)(C,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-semibold`,children:n(`activity:sddBoard.deadlock`)}),me.map(e=>(0,Q.jsxs)(`div`,{className:`font-mono`,children:[e.blocked,` ← `,e.blockedBy.join(`, `)]},e.blocked))]})]}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:a?g===`graph`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(de,{tasks:P,columns:a.columns,onTaskClick:L}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full bg-black/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur`,children:n(`activity:sddBoard.clickTaskHint`)})]}):(0,Q.jsx)(xe,{tasks:a.tasks,selectedId:f,onTaskClick:L}):(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,Q.jsx)(D,{className:`h-10 w-10 text-primary/40`}),(0,Q.jsx)(`p`,{className:`text-foreground`,children:n(`activity:sddBoard.noRunTitle`)}),(0,Q.jsx)(`p`,{className:`max-w-sm text-center text-xs text-muted-foreground`,children:n(`activity:sddBoard.noRunBody`)})]})}),a&&(0,Q.jsx)(`aside`,{"data-testid":`sdd-task-panel`,"data-expanded":m&&Y?`true`:`false`,className:I(`shrink-0 border-l border-border bg-card transition-[width] duration-200 ease-out`,m&&Y?`w-[min(72rem,72vw)]`:`w-80`),children:Y?(0,Q.jsx)(Ce,{task:Y,allTasks:a.tasks,feed:a.taskEvents?.[Y.id]??a.feed??[],now:u,expanded:m,modelCandidates:le,defaultModel:a.defaultModel,onClose:B,onToggleExpanded:()=>h(e=>!e),onRetry:V,onReassign:U,onSetModel:W,onSetVerification:G,onCancel:K,onDelete:se,onSplit:ce,onSelectTask:p},Y.id):(0,Q.jsx)(ve,{feed:a.feed??[],now:u})})]}),(0,Q.jsx)(ye,{open:_,onOpenChange:y,snapshot:a,busy:s,onConfirm:ne})]})}function Oe(e){let t=e.op===`cleanup_worktrees`?`lcClean`:e.op===`rollback`?`lcRollback`:`lcDestroy`,n=x.t(`activity:sddBoard.${t}`);if(!e.ok)return x.t(`activity:sddBoard.lcFailed`,{op:n,reason:e.reason??x.t(`activity:sddBoard.lcUnknownError`)});let r=[];typeof e.removed==`number`&&r.push(x.t(`activity:sddBoard.lcWorktrees`,{count:e.removed})),typeof e.reverted==`number`&&e.reverted>0&&r.push(x.t(`activity:sddBoard.lcCommits`,{count:e.reverted})),e.deleted?.length&&r.push(x.t(`activity:sddBoard.lcDeleted`,{items:e.deleted.join(`, `)}));let i=r.length?r.join(` · `):x.t(`activity:sddBoard.lcNothing`);return e.reason?x.t(`activity:sddBoard.lcNote`,{op:n,body:i,reason:e.reason}):x.t(`activity:sddBoard.lcOk`,{op:n,body:i})}function ke({result:e,onDismiss:t}){let r=!e.ok||!!e.reason;return(0,Q.jsxs)(`div`,{className:I(`flex items-start gap-2 border-b px-4 py-2 text-xs`,r?`border-warning/30 bg-warning/5 text-warning`:`border-success/30 bg-success/5 text-success`),children:[r?(0,Q.jsx)(h,{className:`mt-0.5 h-4 w-4 shrink-0`}):(0,Q.jsx)(n,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1`,children:Oe(e)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 opacity-60 hover:opacity-100`,children:(0,Q.jsx)(b,{className:`h-3.5 w-3.5`})})]})}function Ae({label:e,value:t,color:n}){return(0,Q.jsxs)(`span`,{className:`flex items-baseline gap-1`,children:[(0,Q.jsx)(`span`,{className:I(`font-semibold tabular-nums`,n),children:t}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e})]})}var je={idle:`phaseStart`,questioning:`phaseInterview`,spec_review:`phaseSpecReview`,implementation:`phasePlanning`,task_review:`phaseTaskReview`,executing:`phaseRunning`,done:`phaseDone`},Me=[`questioning`,`spec_review`,`implementation`,`task_review`,`executing`];function Ne({onClose:e,onRunStarted:t}){let{t:n}=v(),{client:r}=ae(),a=L(e=>e.snapshot),s=L(e=>e.agentText),d=L(e=>e.error),f=L(e=>e.startedRunId),m=L(e=>e.setStartedRunId),[h,g]=(0,Z.useState)(``),[_,x]=(0,Z.useState)(``),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!0),[ne,E]=(0,Z.useState)(!0),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(void 0),[j,re]=(0,Z.useState)(void 0),[M,N]=(0,Z.useState)([]),[ie,F]=(0,Z.useState)(4),[R,z]=(0,Z.useState)(!0),[B,V]=(0,Z.useState)(!1),H=oe(D),U=(0,Z.useCallback)(e=>r?.send?.(e),[r]),W=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{U({type:`sdd.spec.get`})},[U]),(0,Z.useEffect)(()=>{W.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[a?.answers.length??0,s]),(0,Z.useEffect)(()=>{f&&(m(null),t?.())},[t,m,f]);let G=a?.busy??!1,K=a?.phase??`idle`,J=!!a?.sessionId,ue=!!a?.resumed,Y=a?.lastRunId;(0,Z.useEffect)(()=>{J&&C(!1)},[J]);let fe=a?.answers[a.answers.length-1]?.question??``,pe=!!a&&(a.taskCount>0||!!a.graphId||K===`task_review`||K===`executing`),me=()=>{let e=h.trim();!e||G||S||(C(!0),U({type:`sdd.spec.start`,payload:{goal:e}}))},he=()=>{let e=_.trim();!e||G||(U({type:`sdd.spec.message`,payload:{text:e}}),x(``))},ge=()=>!G&&U({type:`sdd.spec.approve`,payload:{}}),_e=()=>{U({type:`sdd.run.start`,payload:{parallelSlots:ie,worktrees:R,planDecompose:B,...k?{model:k,provider:j}:{},...M.length?{fallbackModels:M}:{}}}),O(!1)},ve=()=>{G||U({type:`sdd.spec.discard`,payload:{}})},ye=(0,Z.useMemo)(()=>(a?.board?.tasks??[]).map(e=>({id:e.id,shortId:e.shortId,title:e.title,displayStatus:e.displayStatus,priority:e.priority,deps:e.deps,agentName:e.agentName,worktreeBranch:e.worktreeBranch,retries:e.retries})),[a?.board]),be=ye.length>0;return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsxs)(`header`,{className:`sdd-sheen flex shrink-0 items-center justify-between border-b border-border px-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{className:`h-5 w-5 text-primary`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold`,children:a?.title||n(`activity:sddWizard.titleFallback`)}),J&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[n(`activity:sddWizard.${je[K]??`phaseStart`}`),K===`questioning`&&` · ${n(`activity:sddWizard.questionsSuffix`,{cur:a?.questionCount??0,max:a?.maxQuestions??0})}`,a&&a.taskCount>0?` · ${n(`activity:sddWizard.tasksSuffix`,{count:a.taskCount})}`:``]})]}),G&&(0,Q.jsx)(l,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Y&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t?.(),className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-muted`,children:[(0,Q.jsx)(y,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddWizard.openLiveBoard`)]}),J&&(0,Q.jsx)(`button`,{type:`button`,onClick:ve,disabled:G,title:n(`activity:sddWizard.discardTitle`),className:`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-destructive/10 hover:text-destructive disabled:opacity-50`,children:n(`activity:sddWizard.discardInterview`)}),pe&&(0,Q.jsxs)(`div`,{className:`relative flex items-center gap-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>O(e=>!e),title:n(`activity:sddWizard.runCfgTitle`),className:I(`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium`,k||M.length||B?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-muted text-muted-foreground hover:text-foreground`),children:[(0,Q.jsx)(u,{className:`h-3.5 w-3.5`}),k||n(`activity:sddWizard.modelsLabel`)]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:_e,className:`inline-flex items-center gap-1 rounded-md bg-success/15 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/25`,children:[(0,Q.jsx)(y,{className:`h-3.5 w-3.5`}),` `,n(`activity:sddWizard.startRun`)]}),D&&(0,Q.jsxs)(`div`,{className:`sdd-rise absolute right-0 top-9 z-50 w-72 rounded-lg border border-border bg-popover p-3 shadow-xl`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.defaultWorkerModel`)}),(0,Q.jsx)(se,{value:k,provider:j,candidates:H,placeholder:n(`activity:sddWizard.leaderDefaultPlaceholder`),resetLabel:n(`activity:sddWizard.useSessionDefault`),onPick:(e,t)=>{A(e),re(t)},onReset:k?()=>{A(void 0),re(void 0)}:void 0}),(0,Q.jsx)(`div`,{className:`mb-1 mt-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.fallbackChain`)}),(0,Q.jsx)(le,{value:M,candidates:H,onChange:N}),(0,Q.jsx)(`p`,{className:`mt-2 text-[10px] text-muted-foreground`,children:n(`activity:sddWizard.appliesToAll`)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`sdd-slots`,className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.parallelAgents`)}),(0,Q.jsx)(`input`,{id:`sdd-slots`,type:`number`,min:1,max:16,value:ie,onChange:e=>{let t=Number.parseInt(e.target.value,10);F(Number.isFinite(t)?Math.min(16,Math.max(1,t)):1)},className:`w-16 rounded-md border border-border bg-background px-2 py-1 text-right text-xs outline-none focus:border-primary`})]}),(0,Q.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.isolateWorktrees`)}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:R,onChange:e=>z(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:n(R?`activity:sddWizard.worktreeOn`:`activity:sddWizard.worktreeOff`)}),(0,Q.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:n(`activity:sddWizard.planDecompose`)}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:B,onChange:e=>V(e.target.checked),className:`h-3.5 w-3.5 accent-primary`})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:n(B?`activity:sddWizard.planDecomposeOn`:`activity:sddWizard.planDecomposeOff`)})]})]}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:e,children:(0,Q.jsx)(b,{className:`h-4 w-4`})})]})]}),J&&(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b bg-card/50 px-4 py-1.5 text-[11px]`,children:Me.map((e,t)=>{let r=e===K,i=Me.indexOf(K)>t;return(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`span`,{className:I(`rounded-full px-2 py-0.5`,r?`bg-primary/15 text-primary`:i?`text-success`:`text-muted-foreground`),children:[i&&(0,Q.jsx)(P,{className:`mr-0.5 inline h-3 w-3`}),n(`activity:sddWizard.${je[e]}`)]}),t<Me.length-1&&(0,Q.jsx)(`span`,{className:`text-muted-foreground/65`,children:`→`})]},e)})}),(0,Q.jsxs)(`div`,{ref:ce(`sdd-wizard`),className:`min-h-0 flex-1 overflow-auto overscroll-contain p-4`,children:[d&&(0,Q.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/5 p-2 text-xs text-destructive`,children:d}),ue&&J&&(0,Q.jsx)(`div`,{className:`mb-3 rounded-md border border-primary/30 bg-primary/5 px-3 py-2 text-xs text-primary`,children:n(`activity:sddWizard.resumeBanner`)}),J?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[be&&(0,Q.jsxs)(`div`,{className:`sdd-rise overflow-hidden rounded-lg border border-primary/20 bg-[hsl(var(--surface-2)/0.85)]`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>T(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-1.5 text-[11px] font-medium text-primary hover:bg-muted/40`,children:[w?(0,Q.jsx)(p,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(ee,{className:`h-3.5 w-3.5`}),n(`activity:sddWizard.taskGraphSummary`,{count:a?.taskCount??0}),(0,Q.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n(w?`activity:sddWizard.dragToExplore`:`activity:sddWizard.show`)})]}),w&&(0,Q.jsx)(`div`,{className:`h-[32dvh] min-h-[200px]`,children:(0,Q.jsx)(de,{tasks:ye,columns:a?.board?.columns??[]})})]}),(0,Q.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3`,children:[a?.goal&&(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(i,{className:`h-3 w-3`}),` `,n(`activity:sddWizard.goalLabel`)]}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:a.goal})]}),a?.answers.length||s&&K===`questioning`||G?(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[a?.answers.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Q.jsx)(Fe,{speaker:`assistant`,text:e.question}),(0,Q.jsx)(Fe,{speaker:`user`,text:e.answer})]},e.question.slice(0,64))),s&&K===`questioning`&&s!==fe&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:s}),G&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:``,thinking:!0})]}):null,a?.spec&&(0,Q.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card p-3`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-sm font-semibold`,children:[(0,Q.jsx)(c,{className:`h-3.5 w-3.5 text-primary`}),a.spec.title]}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.spec.overview}),(0,Q.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:a.spec.requirements.map(e=>(0,Q.jsxs)(`li`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(`span`,{className:I(`shrink-0 font-mono uppercase`,X(e.priority).text),children:e.priority[0]}),(0,Q.jsx)(`span`,{children:e.description})]},`${e.priority}-${e.description.slice(0,32)}`))})]}),s&&(K===`implementation`||K===`task_review`)&&(0,Q.jsxs)(`div`,{className:`sdd-rise rounded-md border border-border bg-card`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>!e),className:`flex w-full items-center gap-1.5 border-b border-border/60 px-3 py-2 text-sm font-semibold hover:bg-muted/40`,children:[ne?(0,Q.jsx)(p,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(o,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(c,{className:`h-3.5 w-3.5 text-primary`}),` `,n(`activity:sddWizard.implementationPlan`)]}),ne&&(0,Q.jsx)(`div`,{className:`max-h-[40dvh] overflow-auto px-3 py-2`,children:(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:Pe(s)})})]}),s&&K!==`questioning`&&K!==`implementation`&&K!==`task_review`&&!a?.spec&&(0,Q.jsx)(Fe,{speaker:`assistant`,text:s}),(K===`spec_review`||K===`implementation`||K===`task_review`)&&(0,Q.jsxs)(q,{variant:`secondary`,onClick:ge,disabled:G,children:[(0,Q.jsx)(P,{className:`mr-1.5 h-4 w-4`}),n(K===`spec_review`?`activity:sddWizard.approveSpec`:K===`task_review`?`activity:sddWizard.approveTasks`:`activity:sddWizard.approvePlan`)]}),(0,Q.jsx)(`div`,{ref:W})]})]}):(0,Q.jsxs)(`div`,{className:`mx-auto mt-8 max-w-xl`,children:[(0,Q.jsx)(`label`,{className:`mb-2 block text-sm font-medium`,htmlFor:`sdd-goal`,children:n(`activity:sddWizard.goalPrompt`)}),(0,Q.jsx)(`textarea`,{id:`sdd-goal`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&me()},rows:4,placeholder:n(`activity:sddWizard.goalPlaceholder`),className:`w-full resize-none rounded-md border border-border bg-card px-3 py-2 text-sm outline-none focus:border-primary`}),(0,Q.jsx)(q,{className:`mt-3`,onClick:me,disabled:!h.trim()||S,children:S?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(l,{className:`mr-1.5 h-4 w-4 animate-spin`}),` `,n(`activity:sddWizard.startingInterview`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(c,{className:`mr-1.5 h-4 w-4`}),` `,n(`activity:sddWizard.startInterview`)]})}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:n(`activity:sddWizard.introBody`)})]})]}),J&&K!==`executing`&&K!==`done`&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2 border-t bg-card px-4 py-2`,children:[(0,Q.jsx)(`textarea`,{value:_,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),he())},rows:1,placeholder:n(K===`questioning`?`activity:sddWizard.answerPlaceholder`:`activity:sddWizard.changePlaceholder`),disabled:G,className:`max-h-32 flex-1 resize-none rounded-md border border-border bg-background px-3 py-2 text-sm outline-none focus:border-primary disabled:opacity-50`}),(0,Q.jsx)(q,{size:`icon`,onClick:he,disabled:G||!_.trim(),children:(0,Q.jsx)(te,{className:`h-4 w-4`})})]})]})}function Pe(e){let t=e.replace(/```json[\s\S]*?```/gi,``).trim();return t.length>0?t:e.trim()}function Fe({speaker:e,text:t,live:n,thinking:r}){let i=e===`user`;return(0,Q.jsxs)(`div`,{className:I(`sdd-rise flex items-start gap-2`,i&&`flex-row-reverse`),children:[(0,Q.jsx)(`span`,{className:I(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-info/15 text-info`:`bg-primary/15 text-primary`,(n||r)&&`sdd-agent-live`),children:i?(0,Q.jsx)(A,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`div`,{className:I(`max-w-[80%] whitespace-pre-wrap rounded-2xl px-3 py-2 text-sm leading-relaxed text-foreground`,i?`rounded-tr-sm bg-info/10`:`rounded-tl-sm bg-muted`),children:r?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 py-0.5`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-200ms]`}),(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground [animation-delay:-100ms]`}),(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 animate-bounce rounded-full bg-muted-foreground`})]}):t})]})}var $=[{id:`project`,labelKey:`activity:sddhub.tabProject`},{id:`board`,labelKey:`activity:sddhub.tabBoard`},{id:`specs`,labelKey:`activity:sddhub.tabSpecs`}];function Ie(){let{t:e}=v(),[t,n]=(0,Z.useState)(`project`),r=L(e=>e.startedRunId),i=L(e=>e.setStartedRunId),a=()=>B(`chat`),o=(0,Z.useCallback)(()=>n(`board`),[]);(0,Z.useEffect)(()=>{r&&(n(`board`),i(null))},[r,i]);let s=(e,t)=>{let r;if(e.key===`ArrowLeft`&&(r=(t-1+$.length)%$.length),e.key===`ArrowRight`&&(r=(t+1)%$.length),e.key===`Home`&&(r=0),e.key===`End`&&(r=$.length-1),r===void 0)return;e.preventDefault();let i=$[r];i&&(n(i.id),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[r]?.focus())};return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,Q.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,className:`flex shrink-0 items-end border-b border-border/70 bg-card px-4`,children:$.map((r,i)=>{let a=t===r.id;return(0,Q.jsxs)(`button`,{id:`sdd-hub-tab-${r.id}`,type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`sdd-hub-panel-${r.id}`,tabIndex:a?0:-1,onClick:()=>n(r.id),onKeyDown:e=>s(e,i),className:I(`relative px-4 py-2.5 text-sm font-medium transition-colors`,a?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e(r.labelKey),a&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`absolute bottom-0 left-0 right-0 h-0.5 bg-primary`})]},r.id)})}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(`div`,{id:`sdd-hub-panel-project`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-project`,hidden:t!==`project`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Ne,{onClose:a,onRunStarted:o})}),(0,Q.jsx)(`div`,{id:`sdd-hub-panel-board`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-board`,hidden:t!==`board`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(De,{onClose:a})}),(0,Q.jsx)(`div`,{id:`sdd-hub-panel-specs`,role:`tabpanel`,"aria-labelledby":`sdd-hub-tab-specs`,hidden:t!==`specs`,className:`h-full overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(_e,{onClose:a,onRunStarted:o})})]})]})}export{Ie as SddHub};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Ct as n,Di as r,Kn as i,Kr as a,Mi as o,Mr as s,Sa as c,Zt as l,_a as u,_i as d,_n as f,at as p,ba as m,bt as h,cn as ee,ct as g,et as _,gi as v,jt as te,ln as y,ma as b,mn as ne,oi as re,ot as x,pr as S,rt as C,st as w,wi as T}from"./vendor-2VBBgNb5.js";import"./i18n-1BkaqMgr.js";import{n as E}from"./ui-store-CS-njcmT.js";import{t as D}from"./useWebSocket-Dh3aAFDE.js";import{t as O}from"./utils-CN2sfDVP.js";import{t as k}from"./session-store-BsNYnfOc.js";import{M as A,d as j}from"./stores-mpa0202y.js";import{_ as M,b as N,f as P,g as F,h as I,v as L,x as ie}from"./index-BPfIz78e.js";var R=e(c(),1),z=_(),ae=10,oe=20,B=e=>{if(!e)return 0;let t=Date.parse(e);return Number.isNaN(t)?0:t},V=e=>(e.iterationCount??0)+(e.toolCallCount??0)+(e.fileChangeCount??0),se=e=>{let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Math.max(0,Date.now()-t);if(n<6e4)return m.t(`common:time.justNow`);if(n<36e5)return m.t(`common:time.minutesAgo`,{count:Math.floor(n/6e4)});if(n<864e5)return m.t(`common:time.hoursAgo`,{count:Math.floor(n/36e5)});let r=Math.floor(n/864e5);return r<7?m.t(`common:time.daysAgo`,{count:r}):new Date(t).toLocaleDateString()},H=e=>e.lastActivityAt??e.endedAt??e.startedAt;function ce(e){let t=B(e.startedAt);if(!t)return``;let n=e.isCurrent?Date.now():B(e.endedAt)||t,r=Math.max(0,Math.floor((n-t)/6e4));if(r<1)return`<1m`;if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function U(e){return new Intl.NumberFormat(void 0,{notation:e>=1e3?`compact`:`standard`,maximumFractionDigits:1}).format(e)}function le(e){return e.filter(e=>e.tokenTotal===0&&!e.isCurrent).map(e=>e.id)}function ue(e,t){let n=t.query.trim().toLocaleLowerCase(),r=new Set(t.favoriteIds);return[...e.filter(e=>{if(!(!n||[e.name,e.title,e.lastUserMessage,e.model,e.provider,e.id,...Object.keys(e.toolBreakdown??{})].some(e=>e?.toLocaleLowerCase().includes(n))))return!1;switch(t.filter){case`favorites`:return r.has(e.id);case`active`:return e.isCurrent;case`completed`:return!e.isCurrent&&(e.outcome===`completed`||e.outcome===void 0&&!!e.endedAt);case`issues`:return e.outcome===`error`||e.outcome===`timeout`||e.outcome===`aborted`||(e.toolErrorCount??0)>0;default:return!0}})].sort((e,n)=>{if(t.sort===`tokens`&&n.tokenTotal!==e.tokenTotal)return n.tokenTotal-e.tokenTotal;if(t.sort===`activity`){let t=V(n)-V(e);if(t!==0)return t}return B(H(n))-B(H(e))})}function de(e,t,n=Date.now()){let r=new Date(n);r.setHours(0,0,0,0);let i=r.getTime(),a=i-864e5,o=i-6*864e5,s=new Set(t),c=e.filter(e=>s.has(e.id)),l={today:[],yesterday:[],thisWeek:[],earlier:[]};for(let t of e){if(s.has(t.id))continue;let e=B(H(t));e>=i?l.today.push(t):e>=a?l.yesterday.push(t):e>=o?l.thisWeek.push(t):l.earlier.push(t)}let u=[];c.length>0&&u.push({label:`favorites`,rows:c,favorite:!0});for(let e of[`today`,`yesterday`,`thisWeek`,`earlier`])l[e].length>0&&u.push({label:e,rows:l[e]});return u}function fe(e){return e.reduce((e,t)=>({sessions:e.sessions+1,active:e.active+ +!!t.isCurrent,tokens:e.tokens+t.tokenTotal,tools:e.tools+(t.toolCallCount??0),files:e.files+(t.fileChangeCount??0),errors:e.errors+(t.toolErrorCount??0)+ +(t.outcome===`error`)}),{sessions:0,active:0,tokens:0,tools:0,files:0,errors:0})}function pe(e){if(e.isCurrent)return{icon:b,label:`active`,defaultLabel:`Active`,className:`text-primary`};switch(e.outcome){case`completed`:return{icon:t,label:`completed`,defaultLabel:`Completed`,className:`text-success`};case`error`:return{icon:h,label:`error`,defaultLabel:`Error`,className:`text-destructive`};case`timeout`:return{icon:d,label:`timeout`,defaultLabel:`Timed out`,className:`text-warning`};case`aborted`:return{icon:T,label:`aborted`,defaultLabel:`Aborted`,className:`text-muted-foreground`};default:return e.endedAt?{icon:t,label:`completed`,defaultLabel:`Completed`,className:`text-success`}:{icon:S,label:`saved`,defaultLabel:`Saved session`,className:`text-muted-foreground`}}}function me({stats:e}){let{t}=u();return(0,z.jsx)(`div`,{className:`grid grid-cols-2 border-b border-border/75 bg-card md:grid-cols-5`,children:[{label:t(`activity:sessions.stats.sessions`,{defaultValue:`Sessions`}),value:e.sessions,icon:S},{label:t(`activity:sessions.stats.tokens`,{defaultValue:`Tokens`}),value:e.tokens,icon:b},{label:t(`activity:sessions.stats.tools`,{defaultValue:`Tool calls`}),value:e.tools,icon:x},{label:t(`activity:sessions.stats.files`,{defaultValue:`Files changed`}),value:e.files,icon:a},{label:t(`activity:sessions.stats.errors`,{defaultValue:`Errors`}),value:e.errors,icon:h}].map(e=>{let t=e.icon;return(0,z.jsxs)(`div`,{className:`border-b border-r border-border/75 px-4 py-3 md:border-b-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[(0,z.jsx)(t,{className:`h-3 w-3`}),e.label]}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-xl font-semibold tabular-nums`,children:U(e.value)})]},e.label)})})}function W({historyQuery:e,setHistoryQuery:t,historyEntries:r,historyLoading:o,historyError:s,wsConnected:c,listSessions:d,resumeSession:m,deleteSession:g,renameSession:_,variant:v=`sidebar`}){let{t:y}=u(),b=E(e=>e.favoriteSessionIds),re=E(e=>e.toggleFavoriteSession),C=E(e=>e.sessionNicknames),w=E(e=>e.setSessionNickname),[T,D]=(0,R.useState)(`all`),[k,A]=(0,R.useState)(`recent`),[j,M]=(0,R.useState)(null),[N,F]=(0,R.useState)(``),[I,L]=(0,R.useState)(null),[B,V]=(0,R.useState)(1),W=(0,R.useRef)(null),G=(0,R.useRef)(null),K=v===`workspace`,q=(0,R.useCallback)(e=>e.name||C[e.id]||e.title||y(`activity:sessions.empty`),[C,y]),J=(0,R.useCallback)(e=>{M(e.id),F(e.name??C[e.id]??e.title??``)},[C]),Y=(0,R.useCallback)(e=>{M(null),w(e,N),_(e,N)},[N,_,w]);(0,R.useEffect)(()=>{I&&r.some(e=>e.id===I&&e.isCurrent)&&(L(null),W.current&&clearTimeout(W.current))},[r,I]),(0,R.useEffect)(()=>{j&&(G.current?.focus(),G.current?.select())},[j]),(0,R.useEffect)(()=>()=>{W.current&&clearTimeout(W.current)},[]);let X=(0,R.useCallback)(e=>{L(e),m(e),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>L(null),1e4)},[m]),Z=(0,R.useMemo)(()=>le(r),[r]),Q=(0,R.useMemo)(()=>ue(r,{query:e,filter:T,sort:k,favoriteIds:b}),[b,T,r,e,k]),$=K?oe:ae,he=(0,R.useMemo)(()=>Q.slice((B-1)*$,B*$),[B,$,Q]),ge=(0,R.useMemo)(()=>de(he,b),[b,he]),_e=(0,R.useMemo)(()=>fe(r),[r]);(0,R.useEffect)(()=>{V(1)},[T,e,k]),(0,R.useEffect)(()=>{let e=Math.max(1,Math.ceil(Q.length/$));B>e&&V(e)},[B,$,Q.length]);let ve=(0,R.useCallback)(async()=>{if(Z.length!==0&&await ie({title:y(`activity:sessions.deleteEmptyTitle`,{count:Z.length}),message:y(`activity:sessions.deleteEmptyConfirmBody`),confirmLabel:y(`common:action.delete`),danger:!0}))for(let e of Z)g(e)},[g,Z,y]),ye=[{id:`all`,label:y(`activity:sessions.filters.all`,{defaultValue:`All`})},{id:`favorites`,label:y(`activity:sessions.filters.favorites`,{defaultValue:`Pinned`})},{id:`active`,label:y(`activity:sessions.filters.active`,{defaultValue:`Active`})},{id:`completed`,label:y(`activity:sessions.filters.completed`,{defaultValue:`Completed`})},{id:`issues`,label:y(`activity:sessions.filters.issues`,{defaultValue:`Issues`})}];return(0,z.jsxs)(`div`,{className:O(`flex min-h-0 min-w-0 flex-1 flex-col bg-background`,K&&`h-full`),"data-history-variant":v,children:[K?(0,z.jsx)(me,{stats:_e}):null,(0,z.jsxs)(`div`,{className:O(`border-b border-border/75 bg-card`,K?`px-4 py-3`:`px-3 py-2`),children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:y(`activity:sessions.recentSessions`)}),K?(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:y(`activity:sessions.workspaceHint`,{defaultValue:`Search, inspect, pin and resume every project conversation.`})}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center border border-border/75`,children:[Z.length>0?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center justify-center gap-1 border-r border-border/75 px-2 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:opacity-40`,onClick:ve,disabled:!c,title:y(`activity:sessions.deleteEmptyTitle`,{count:Z.length}),children:[(0,z.jsx)(n,{className:`h-3.5 w-3.5`}),K?(0,z.jsx)(`span`,{className:`text-[10px]`,children:Z.length}):null]}):null,(0,z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:()=>d(200),disabled:!c,title:y(`common:action.refresh`),children:o?(0,z.jsx)(i,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(ee,{className:`h-3.5 w-3.5`})})]})]}),(0,z.jsxs)(`div`,{className:O(`grid gap-2`,K?`mt-3 lg:grid-cols-[minmax(18rem,1fr)_auto_auto]`:`mt-2`),children:[(0,z.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,z.jsx)(l,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(`input`,{type:`search`,value:e,onChange:e=>t(e.target.value),placeholder:y(`activity:sessions.filterPlaceholder`),"aria-label":y(`activity:sessions.filterPlaceholder`),className:`h-9 w-full border border-border/75 bg-background pl-8 pr-8 text-xs outline-none transition-colors placeholder:text-muted-foreground/70 focus:border-primary focus:ring-1 focus:ring-primary`}),e?(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(``),className:`absolute right-0 top-0 inline-flex h-9 w-8 items-center justify-center text-muted-foreground hover:text-foreground`,title:y(`activity:sessions.clearFilter`),children:(0,z.jsx)(p,{className:`h-3.5 w-3.5`})}):null]}),(0,z.jsxs)(`fieldset`,{className:`flex min-w-0 overflow-x-auto border border-border/75`,children:[(0,z.jsx)(`legend`,{className:`sr-only`,children:`History filters`}),ye.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>D(e.id),"aria-pressed":T===e.id,className:O(`h-9 shrink-0 border-r border-border/75 px-2.5 text-[10px] font-semibold uppercase tracking-[0.08em] transition-colors last:border-r-0`,T===e.id?`bg-foreground text-background`:`bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:e.label},e.id))]}),(0,z.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),"aria-label":y(`activity:sessions.sort.label`,{defaultValue:`Sort sessions`}),className:`h-9 border border-border/75 bg-background px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground outline-none focus:border-primary`,children:[(0,z.jsx)(`option`,{value:`recent`,children:y(`activity:sessions.sort.recent`,{defaultValue:`Recent`})}),(0,z.jsx)(`option`,{value:`tokens`,children:y(`activity:sessions.sort.tokens`,{defaultValue:`Most tokens`})}),(0,z.jsx)(`option`,{value:`activity`,children:y(`activity:sessions.sort.activity`,{defaultValue:`Most activity`})})]})]})]}),s?(0,z.jsx)(`div`,{className:`border-b border-destructive/30 bg-destructive/5 px-4 py-2 text-xs text-destructive`,children:s}):null,(0,z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain overflow-x-hidden [scrollbar-gutter:stable]`,children:r.length===0&&!o?(0,z.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,z.jsx)(S,{className:`h-9 w-9 opacity-25`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:y(`activity:sessions.noHistory`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:y(`activity:sessions.noHistoryHint`)})]}):ge.length===0?(0,z.jsxs)(`div`,{className:`flex min-h-56 flex-col items-center justify-center px-4 py-10 text-center text-muted-foreground`,children:[(0,z.jsx)(l,{className:`h-9 w-9 opacity-25`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:y(`activity:sessions.noMatches`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:y(`activity:sessions.noMatchesHint`)})]}):(0,z.jsxs)(`div`,{className:O(K?`mx-auto w-full max-w-7xl p-4 lg:p-6`:`p-2`),children:[(0,z.jsx)(`div`,{className:O(`space-y-5`,K&&`grid gap-x-5 space-y-0 xl:grid-cols-2`),children:ge.map(e=>(0,z.jsxs)(`section`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:O(`sticky top-0 z-[1] flex items-center gap-1 border-b border-border/75 bg-background/95 px-1 py-2 text-[10px] font-semibold uppercase tracking-[0.14em] backdrop-blur-sm`,e.favorite?`text-warning`:`text-muted-foreground`),children:[e.favorite?(0,z.jsx)(te,{className:`h-3 w-3 fill-current`}):null,y(`activity:sessions.group.${e.label}`),(0,z.jsx)(`span`,{className:`ml-1 font-mono font-normal text-muted-foreground`,children:e.rows.length})]}),(0,z.jsx)(`div`,{className:`divide-y divide-border/75 border-x border-b border-border/75`,children:e.rows.map(e=>{let t=b.includes(e.id),r=pe(e),o=r.icon,s=j===e.id,c=I===e.id;return(0,z.jsxs)(`article`,{className:O(`group grid min-w-0 grid-cols-[minmax(0,1fr)_auto] bg-card transition-colors`,e.isCurrent?`border-l-2 border-l-primary bg-primary/5`:`border-l-2 border-l-transparent hover:bg-muted/45`),"data-session-id":e.id,children:[s?(0,z.jsxs)(`div`,{className:`min-w-0 px-3 py-3`,children:[(0,z.jsx)(`label`,{className:`block text-[10px] font-semibold uppercase tracking-[0.1em] text-muted-foreground`,htmlFor:`session-name-${e.id}`,children:y(`activity:sessions.rename`,{defaultValue:`Session name`})}),(0,z.jsx)(`input`,{ref:G,id:`session-name-${e.id}`,value:N,onChange:e=>F(e.target.value),onBlur:()=>Y(e.id),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),Y(e.id)):t.key===`Escape`&&(t.preventDefault(),M(null))},placeholder:e.title||y(`activity:sessions.nicknamePlaceholder`),className:`mt-1 h-8 w-full border border-primary bg-background px-2 text-sm outline-none ring-1 ring-primary`})]}):(0,z.jsx)(`button`,{type:`button`,disabled:e.isCurrent||I!==null,onClick:()=>X(e.id),onDoubleClick:()=>J(e),"aria-current":e.isCurrent?`page`:void 0,className:`min-w-0 px-3 py-3 text-left outline-none focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:cursor-default`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,z.jsx)(`span`,{className:O(`mt-0.5 shrink-0`,r.className),title:y(`activity:sessions.status.${r.label}`,{defaultValue:r.defaultLabel}),children:(0,z.jsx)(o,{className:O(`h-3.5 w-3.5`,e.isCurrent&&`animate-pulse`)})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-semibold text-foreground`,title:q(e),children:q(e)}),(0,z.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:[e.provider,`/`,e.model]}),e.lastUserMessage?(0,z.jsx)(`div`,{className:`mt-1 truncate text-xs text-muted-foreground`,title:e.lastUserMessage,children:e.lastUserMessage}):null,(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[10px] text-muted-foreground`,children:[c?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-sans font-semibold text-primary`,children:[(0,z.jsx)(i,{className:`h-3 w-3 animate-spin`}),y(`activity:sessions.resuming`)]}):(0,z.jsx)(`span`,{title:new Date(H(e)).toLocaleString(),children:se(H(e))}),(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,z.jsx)(`span`,{children:ce(e)}),e.tokenTotal>0?(0,z.jsxs)(`span`,{children:[U(e.tokenTotal),` tok`]}):null,(e.messageCount??0)>0?(0,z.jsxs)(`span`,{children:[U(e.messageCount??0),` msg`]}):null,(e.toolCallCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(x,{className:`h-3 w-3`}),e.toolCallCount]}):null,(e.fileChangeCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(a,{className:`h-3 w-3`}),e.fileChangeCount]}):null,(e.toolErrorCount??0)>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-destructive`,children:[(0,z.jsx)(h,{className:`h-3 w-3`}),e.toolErrorCount]}):null]})]})]})}),(0,z.jsxs)(`div`,{className:`flex items-start gap-0.5 p-2`,children:[!e.isCurrent&&K&&!s?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>X(e.id),disabled:I!==null,className:`inline-flex h-7 items-center gap-1 border border-border/75 px-2 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground hover:border-primary hover:text-primary disabled:opacity-40`,title:y(`activity:sessions.resume`,{defaultValue:`Resume session`}),children:[(0,z.jsx)(ne,{className:`h-3 w-3`}),y(`activity:sessions.resumeShort`,{defaultValue:`Resume`})]}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>re(e.id),"aria-pressed":t,className:O(`inline-flex h-7 w-7 items-center justify-center transition-colors hover:bg-warning/10 hover:text-warning`,t?`text-warning`:`text-muted-foreground`),title:y(t?`activity:sessions.unfavorite`:`activity:sessions.markFavorite`),children:(0,z.jsx)(te,{className:O(`h-3.5 w-3.5`,t&&`fill-current`)})}),s?null:(0,z.jsx)(`button`,{type:`button`,onClick:()=>J(e),className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary`,title:y(`activity:sessions.renameAction`,{defaultValue:`Rename`}),children:(0,z.jsx)(f,{className:`h-3.5 w-3.5`})}),e.isCurrent?null:(0,z.jsx)(`button`,{type:`button`,onClick:async()=>{await ie({title:y(`activity:sessions.deleteSessionConfirmTitle`),message:y(`activity:sessions.deleteSessionConfirmBody`,{name:q(e)}),confirmLabel:y(`common:action.delete`),danger:!0})&&g(e.id)},className:`inline-flex h-7 w-7 items-center justify-center text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,title:y(`activity:sessions.deleteSessionTitle`),children:(0,z.jsx)(n,{className:`h-3.5 w-3.5`})})]})]},e.id)})})]},e.label))}),(0,z.jsx)(P,{page:B,pageSize:$,totalItems:Q.length,onPageChange:V,compact:!K,itemLabel:`sessions`})]})})]})}var G=12;async function K(e){try{let t=await e.clone().json(),n=typeof t.error==`string`?t.error:t.message;if(typeof n==`string`&&n.trim())return n}catch{try{let t=await e.text();if(t.trim())return t.trim()}catch{}}return e.statusText||`HTTP ${e.status}`}function q(e){switch(e){case`running`:return{icon:(0,z.jsx)(b,{className:`h-3.5 w-3.5`}),cls:`text-success`};case`streaming`:return{icon:(0,z.jsx)(y,{className:`h-3.5 w-3.5`}),cls:`text-primary`};case`waiting_user`:return{icon:(0,z.jsx)(v,{className:`h-3.5 w-3.5`}),cls:`text-warning`};case`error`:return{icon:(0,z.jsx)(o,{className:`h-3.5 w-3.5`}),cls:`text-destructive`};case`idle`:return{icon:(0,z.jsx)(r,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`};default:return{icon:(0,z.jsx)(t,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`}}}function J(e){switch(e){case`active`:return{icon:(0,z.jsx)(w,{className:`h-3.5 w-3.5`}),cls:`text-success`,badge:`border-success/25 bg-success/8 text-success`};case`idle`:return{icon:(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),cls:`text-primary`,badge:`border-primary/25 bg-primary/10 text-primary`};case`closing`:return{icon:(0,z.jsx)(v,{className:`h-3.5 w-3.5`}),cls:`text-warning`,badge:`border-warning/25 bg-warning/10 text-warning`};case`lost`:return{icon:(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),cls:`text-destructive/60`,badge:`border-destructive/15 bg-destructive/5 text-destructive/70`};default:return{icon:(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),cls:`text-muted-foreground`,badge:`border-border bg-muted text-muted-foreground`}}}function Y(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`<1m`;if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function X(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<10)return m.t(`common:time.justNow`);if(n<60)return m.t(`common:time.secondsAgo`,{count:n});let r=Math.floor(n/60);return r<60?m.t(`common:time.minutesAgo`,{count:r}):m.t(`common:time.hoursAgo`,{count:Math.floor(r/60)})}function Z(){let e=A(e=>e.wsConnected),t=k(e=>e.session?.id),{entries:n,loading:r,error:i}=j(C(e=>({entries:e.entries,loading:e.loading,error:e.error}))),{listSessions:a,resumeSession:o,deleteSession:s,renameSession:c}=D(),[l,u]=(0,R.useState)(``);return(0,R.useEffect)(()=>{e&&a(200)},[t,a,e]),(0,z.jsx)(W,{historyQuery:l,setHistoryQuery:u,historyEntries:n,historyLoading:r,historyError:i,wsConnected:e,listSessions:a,resumeSession:o,deleteSession:s,renameSession:c,variant:`workspace`})}function Q(){let{t:e}=u();return(0,z.jsxs)(I,{defaultValue:`history`,className:`flex h-full min-h-0 flex-col bg-background`,"data-testid":`sessions-workspace`,children:[(0,z.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border/75 bg-card px-4 py-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-primary`,children:e(`activity:sessions.workspaceEyebrow`,{defaultValue:`Conversation control`})}),(0,z.jsx)(`h1`,{className:`mt-0.5 text-lg font-semibold tracking-tight`,children:e(`activity:sessions.workspaceTitle`,{defaultValue:`Sessions`})})]}),(0,z.jsxs)(M,{className:`h-9 min-h-9 justify-start border-border/75 bg-background p-0 shadow-none`,children:[(0,z.jsxs)(L,{value:`history`,className:`h-9 gap-1.5 border-r border-border/75 px-3 text-xs shadow-none data-[state=active]:bg-foreground data-[state=active]:text-background data-[state=active]:ring-0`,children:[(0,z.jsx)(S,{className:`h-3.5 w-3.5`}),e(`activity:sessions.tabs.history`,{defaultValue:`History`})]}),(0,z.jsxs)(L,{value:`live`,className:`h-9 gap-1.5 px-3 text-xs shadow-none data-[state=active]:bg-foreground data-[state=active]:text-background data-[state=active]:ring-0`,children:[(0,z.jsx)(y,{className:`h-3.5 w-3.5`}),e(`activity:sessions.tabs.live`,{defaultValue:`Live sessions`})]})]})]}),(0,z.jsx)(F,{value:`history`,className:`mt-0 min-h-0 flex-1 overflow-hidden ring-0`,children:(0,z.jsx)(Z,{})}),(0,z.jsx)(F,{value:`live`,className:`mt-0 min-h-0 flex-1 overflow-hidden ring-0`,children:(0,z.jsx)($,{})})]})}function $(){let{t:e}=u(),[t,n]=(0,R.useState)([]),[r,a]=(0,R.useState)(!0),[c,l]=(0,R.useState)(null),[d,f]=(0,R.useState)(1),p=N(`sessions`,!r&&!c&&t.length>0),m=(0,R.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(!e.ok){if(e.status===404){l(null),n([]);return}throw Error(`HTTP ${e.status}: ${await K(e)}`)}if(!(e.headers.get(`content-type`)?.toLowerCase()??``).includes(`application/json`)){l(null),n([]);return}let t=await e.json();if(!Array.isArray(t)){l(null),n([]);return}n(e=>{let n=t;if(e.length===n.length){let t=!0;for(let r=0;r<n.length;r++){let i=n[r],a=e[r];if(i.sessionId!==a.sessionId||i.status!==a.status||i.agentCount!==a.agentCount||i.startedAt!==a.startedAt){t=!1;break}}if(t)return e}return n}),l(null)}catch(e){if(e instanceof SyntaxError){l(null),n([]);return}l(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,R.useEffect)(()=>{m();let e=setInterval(m,5e3);return()=>clearInterval(e)},[m]);let h=t.filter(e=>e.status===`active`).length,ee=t.reduce((e,t)=>e+t.agentCount,0),_=t.slice((d-1)*G,d*G);return(0,R.useEffect)(()=>{let e=Math.max(1,Math.ceil(t.length/G));d>e&&f(e)},[d,t.length]),r?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground`,children:[(0,z.jsx)(i,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:liveSessions.loading`)]})}):c?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface max-w-lg p-5 text-center`,children:[(0,z.jsx)(o,{className:`mx-auto h-8 w-8 text-warning`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium`,children:e(`activity:liveSessions.apiUnavailable`)}),(0,z.jsx)(`p`,{className:`mt-1 break-words text-xs text-muted-foreground`,children:c})]})}):t.length===0?(0,z.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,z.jsxs)(`div`,{className:`ws-surface max-w-md p-6 text-center text-muted-foreground`,children:[(0,z.jsx)(g,{className:`mx-auto h-9 w-9 opacity-50`}),(0,z.jsx)(`p`,{className:`mt-3 text-sm font-medium text-foreground`,children:e(`activity:liveSessions.empty`)}),(0,z.jsx)(`p`,{className:`mt-1 text-xs`,children:e(`activity:liveSessions.autoRefresh`)})]})}):(0,z.jsx)(`div`,{ref:p,className:`h-full min-h-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4`,children:[(0,z.jsx)(`header`,{className:`border border-border/70 bg-card/75 p-4`,children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(w,{className:`h-4 w-4 text-primary`}),(0,z.jsx)(`h2`,{className:`text-base font-semibold`,children:e(`activity:liveSessions.heading`,{count:t.length})})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:liveSessions.autoRefresh`)})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-center sm:min-w-[22rem]`,children:[(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:t.length}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Sessions`})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-success`,children:h}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Active`})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:ee}),(0,z.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:`Agents`})]})]})]})}),(0,z.jsx)(`div`,{className:`grid gap-3`,children:_.map(t=>{let n=J(t.status);return(0,z.jsxs)(`article`,{className:`border border-border/70 bg-card/75 p-3 sm:p-4`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:n.cls,children:n.icon}),(0,z.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold`,title:t.projectName,children:t.projectName}),(0,z.jsx)(`span`,{className:`bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:t.projectSlug}),(0,z.jsx)(`span`,{className:`inline-flex items-center border px-1.5 py-0.5 text-[10px] font-semibold uppercase ${n.badge}`,children:t.status})]}),(0,z.jsxs)(`div`,{className:`mt-2 grid gap-1.5 text-xs text-muted-foreground md:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,z.jsx)(re,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono`,title:t.workingDir,children:t.workingDir})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t.gitBranch?(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1 text-primary`,children:[(0,z.jsx)(s,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate font-mono`,children:t.gitBranch})]}):null,(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(v,{className:`h-3.5 w-3.5`}),Y(t.startedAt)]}),(0,z.jsx)(`span`,{className:`font-mono`,children:e(`activity:liveSessions.pidLabel`,{pid:t.pid})})]})]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs sm:grid-cols-3 lg:w-64`,children:[(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Agents`}),(0,z.jsx)(`div`,{className:`font-semibold tabular-nums`,children:t.agentCount})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Status`}),(0,z.jsx)(`div`,{className:`truncate font-mono font-semibold`,children:t.status})]}),(0,z.jsxs)(`div`,{className:`border border-border/70 bg-background/50 px-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`Runtime`}),(0,z.jsx)(`div`,{className:`font-mono font-semibold`,children:Y(t.startedAt)})]})]})]}),(0,z.jsxs)(`div`,{className:`mt-3 overflow-hidden border border-border/70 bg-background/45`,children:[t.agents.length===0?(0,z.jsx)(`div`,{className:`px-3 py-3 text-xs text-muted-foreground`,children:e(`activity:liveSessions.noAgents`)}):(0,z.jsx)(`div`,{className:`divide-y divide-border/60`,children:t.agents.slice(0,5).map(t=>{let n=q(t.status);return(0,z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-1 px-3 py-2 text-xs sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,14rem)_auto]`,children:[(0,z.jsx)(`span`,{className:O(`mt-0.5 shrink-0`,n.cls),children:n.icon}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate font-medium`,title:t.name,children:t.name}),(0,z.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground`,children:e(`activity:liveSessions.agentMeta`,{iter:t.iterations,tools:t.toolCalls,ago:X(t.lastActivityAt)})})]}),(0,z.jsx)(`div`,{className:`min-w-0 font-mono text-[10px] text-muted-foreground sm:text-xs`,children:t.currentTool?(0,z.jsx)(`span`,{className:`block truncate`,title:t.currentTool,children:t.currentTool}):(0,z.jsx)(`span`,{className:`text-muted-foreground/75`,children:t.status})}),(0,z.jsx)(`span`,{className:`hidden font-mono text-[10px] text-muted-foreground sm:block`,children:X(t.lastActivityAt)})]},t.id)})}),t.agents.length>5?(0,z.jsx)(`div`,{className:`border-t border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:e(`activity:liveSessions.andMore`,{count:t.agents.length-5})}):null]})]},t.sessionId)})}),(0,z.jsx)(P,{page:d,pageSize:G,totalItems:t.length,onPageChange:f,itemLabel:`sessions`})]})})}export{Q as SessionsDashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,Ii as n,It as r,Kn as i,Kt as a,Ri as o,Sa as s,Yi as c,Zr as l,_a as u,_r as d,aa as f,ba as p,ci as m,cn as h,et as g,pn as _,rt as v,sr as y,t as b,xr as x,zi as S}from"./vendor-2VBBgNb5.js";import"./i18n-1BkaqMgr.js";import{t as C}from"./useWebSocket-Dh3aAFDE.js";import{t as w}from"./ws-client-WVGn8ORh.js";import{t as T}from"./utils-CN2sfDVP.js";import{M as ee}from"./stores-mpa0202y.js";import{o as E}from"./view-navigation-Cgy5xh9q.js";import{n as D}from"./Toaster-CbcX_Cou.js";import{a as O,n as te,o as ne,r as k,t as A}from"./dialog-CT1PTjzK.js";import{t as j}from"./button-uGqXvobk.js";import{t as M}from"./input-B-VCX2sG.js";import{c as N,f as P,i as F,o as I,p as L,s as R,y as z}from"./index-BPfIz78e.js";var B=e(s(),1);function V(e,t=8e3){return new Promise((n,r)=>{let i=setTimeout(()=>{a(),r(Error(`timeout`))},t),a=e.on(`key.operation_result`,e=>{clearTimeout(i),a(),n(e.payload)})})}var H=g();function re({onKeySaved:e}){let{t}=u(),[r,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(`openai-compatible`),[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(!1),[v,y]=(0,B.useState)([]),{setFieldRef:b,handleKeyDown:x}=N(),S=async()=>{if(o.trim()){g(!0);try{let n=w(ee.getState().wsUrl),r=V(n);n.send({type:`provider.add`,payload:{id:o.trim(),family:c,baseUrl:d.trim()||void 0,apiKey:p.trim()||void 0,models:v.length>0?v.map(e=>e.id):void 0,customModels:v.length>0?Object.fromEntries(v.filter(e=>e.name||e.maxOutput||e.capabilities).map(e=>[e.id,{...e.name&&e.name!==e.id?{name:e.name}:{},...e.maxOutput?{maxOutput:e.maxOutput}:{},...e.capabilities&&Object.values(e.capabilities).some(Boolean)?{capabilities:e.capabilities}:{}}])):void 0}});let i=await r;if(!i.success)throw Error(i.message);D.success(t(`setup:screen.toasts.providerAdded`,{id:o.trim()})),e(o.trim()),n.listSavedProviders(),n.probeProvider(o.trim()),s(``),f(``),m(``),y([]),a(!1)}catch(e){let n=e instanceof Error&&e.message&&e.message!==`timeout`?e.message:null;D.error(n??t(`setup:screen.toasts.providerAddFailed`))}finally{g(!1)}}};return(0,H.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border/60 overflow-hidden`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>a(!r),className:`w-full flex items-center gap-3 p-4 text-left hover:bg-muted/30 transition-colors`,children:[(0,H.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-muted/50 flex items-center justify-center`,children:(0,H.jsx)(_,{className:`h-5 w-5 text-muted-foreground`})}),(0,H.jsxs)(`div`,{className:`flex-1`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`setup:screen.custom.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`setup:screen.custom.description`)})]}),(0,H.jsx)(n,{className:T(`h-4 w-4 text-muted-foreground transition-transform`,r&&`rotate-90`)})]}),r&&(0,H.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/40`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5 pt-3`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground block`,children:t(`setup:screen.custom.localServers`)}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:I.map(e=>(0,H.jsx)(j,{type:`button`,size:`sm`,variant:o===e.id?`default`:`outline`,onClick:()=>{s(e.id),l(`openai-compatible`),f(e.defaultBaseUrl),e.noAuth&&m(``),y([])},title:e.hint,children:e.label},e.id))})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.providerId`)}),(0,H.jsx)(M,{placeholder:`e.g. my-llm`,value:o,onChange:e=>s(e.target.value),className:`text-sm`,ref:b(0),onKeyDown:e=>x(e,0)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.family`)}),(0,H.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm`,ref:b(1),onKeyDown:e=>x(e,1),children:[(0,H.jsx)(`option`,{value:`openai-compatible`,children:t(`setup:screen.custom.familyOpenAiCompatible`)}),(0,H.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,H.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,H.jsx)(`option`,{value:`google`,children:`Google`})]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.baseUrl`)}),(0,H.jsx)(M,{placeholder:`e.g. http://localhost:11434/v1`,value:d,onChange:e=>f(e.target.value),className:`text-sm font-mono`,ref:b(2),onKeyDown:e=>x(e,2)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground mb-1 block`,children:t(`setup:screen.custom.apiKey`)}),(0,H.jsx)(M,{type:`password`,placeholder:t(`setup:screen.custom.apiKeyPlaceholder`),value:p,onChange:e=>m(e.target.value),className:`text-sm font-mono`,ref:b(3),onKeyDown:e=>x(e,3)})]}),(0,H.jsx)(F,{models:v,onChange:y}),(0,H.jsxs)(j,{onClick:S,disabled:!o.trim()||h,size:`sm`,ref:b(4),onKeyDown:e=>x(e,4,S),children:[h?(0,H.jsx)(i,{className:`h-4 w-4 animate-spin mr-2`}):null,t(`setup:screen.custom.add`)]})]})]})}var U=R();async function ie(e,t){try{let n=await fetch(e,{signal:t});if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.json();if(!Array.isArray(r))throw Error(`Expected JSON array`);let i=r.filter(e=>typeof e.id==`string`&&typeof e.name==`string`&&typeof e.family==`string`);return i.length>0?i:U}catch{return U}}function ae(e,t){let n=new Date().getTime()-e.getTime(),r=Math.floor(n/1e3);if(r<10)return t(`setup:screen.time.justNow`);if(r<60)return t(`setup:screen.time.secondsAgo`,{count:r});let i=Math.floor(r/60);if(i<60)return t(`setup:screen.time.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`setup:screen.time.hoursAgo`,{count:a}):t(`setup:screen.time.daysAgo`,{count:Math.floor(a/24)})}var oe=e(b(),1);function se({popular:e,catalogProvider:t,savedProvider:r,onKeySaved:s,probeResult:c}){let{t:d}=u(),[f,p]=(0,B.useState)(``),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!!r?.apiKeys.some(e=>e.isActive)),[y,b]=(0,B.useState)(!1),[C,E]=(0,B.useState)(!1),[N,P]=(0,B.useState)(!1),[F,I]=(0,B.useState)(null);(0,B.useEffect)(()=>{N&&e.referral&&oe.toDataURL(e.referral.url,{width:200,margin:2,color:{dark:`#000000`,light:`#ffffff`}}).then(e=>I(e)).catch(()=>I(null))},[N,e.referral]);let L=async()=>{if(f.trim()){g(!0);try{let n=w(ee.getState().wsUrl),r=V(n);t?n.addKey(e.id,`default`,f.trim()):n.send({type:`provider.add`,payload:{id:e.id,family:e.family,apiKey:f.trim()}});let i=await r;if(!i.success)throw Error(i.message);v(!0),p(``),D.success(d(`setup:screen.toasts.keySaved`,{name:e.name})),s(e.id),n.listSavedProviders(),n.probeProvider(e.id)}catch(t){let n=t instanceof Error&&t.message&&t.message!==`timeout`?t.message:null;D.error(n??d(`setup:screen.toasts.keySaveFailed`,{name:e.name}))}finally{g(!1)}}},R=e=>{e.key===`Enter`&&f.trim()&&L()},z=async()=>{if(e.referral)try{await navigator.clipboard.writeText(e.referral.url),E(!0),D.success(d(`setup:screen.toasts.referralCopied`)),setTimeout(()=>E(!1),2e3)}catch{D.error(d(`setup:screen.toasts.referralCopyFailed`))}},re=t&&t.modelCount>0;return(0,H.jsxs)(`div`,{className:T(`rounded-xl border p-4 transition-all`,_?`border-success/30 bg-success/5`:`bg-gradient-to-br ${e.color}`),children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`text-2xl shrink-0 mt-0.5`,children:e.icon}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),_&&(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-success/10 text-success border border-success/20`,children:[(0,H.jsx)(S,{className:`h-2.5 w-2.5`}),d(`setup:screen.card.keySaved`)]}),e.referral&&!_&&(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-warning/10 text-warning border border-warning/20`,children:[(0,H.jsx)(x,{className:`h-2.5 w-2.5`}),d(`setup:screen.card.referral`)]})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.referral&&!_&&(0,H.jsxs)(`p`,{className:`text-[11px] text-warning/80 mt-1`,children:[`🎁 `,e.referral.reward]}),_?_?(0,H.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[r?.baseUrl&&(0,H.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70 font-mono truncate`,title:r.baseUrl,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground/50`,children:`URL: `}),r.baseUrl]}),r?.models&&r.models.length>0&&(0,H.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:[(0,H.jsx)(`span`,{className:`text-muted-foreground/50`,children:`Models: `}),r.pickedModelId??r.models[0],(0,H.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[` (+`,r.models.length-1,` more)`]})]}),c===`probing`?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground mt-1`,children:[(0,H.jsx)(i,{className:`h-3 w-3 animate-spin`}),d(`setup:screen.probe.checking`,`Checking connection…`)]}):c?.ok?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-success mt-1`,children:[(0,H.jsx)(S,{className:`h-3 w-3`}),(0,H.jsxs)(`span`,{children:[d(`setup:screen.probe.connected`,`Connected`),c.modelCount!=null&&` · ${c.modelCount} ${d(`setup:screen.probe.models`,`models`)}`,c.elapsedMs!=null&&` · ${c.elapsedMs}ms`]})]}):c&&!c.ok?(0,H.jsxs)(`div`,{className:`flex items-start gap-1.5 text-[11px] text-destructive mt-1`,children:[(0,H.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:`✕`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:d(`setup:screen.probe.failed`,`Probe failed`)}),c.status===`no_base_url`&&(0,H.jsx)(`span`,{className:`block text-destructive/70`,children:d(`setup:screen.probe.noBaseUrl`,`No base URL configured`)}),c.status===`unreachable`&&(0,H.jsxs)(`span`,{className:`block text-destructive/70`,children:[d(`setup:screen.probe.unreachable`,`Could not connect`),c.detail?`: ${c.detail}`:``]}),c.status!==`no_base_url`&&c.status!==`unreachable`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`block text-destructive/70`,children:c.httpStatus==null?c.status:`${d(`setup:screen.probe.httpStatus`,`Status`)} ${c.httpStatus}`}),c.detail&&(0,H.jsx)(`span`,{className:`block text-destructive/70 truncate max-w-[250px]`,title:c.detail,children:c.detail})]})]})]}):null,re&&(0,H.jsxs)(`button`,{type:`button`,onClick:()=>b(!y),className:`text-[11px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[d(`setup:screen.providers.modelsAvailable`,{count:t?.modelCount??0}),y?(0,H.jsx)(o,{className:`h-3 w-3`}):(0,H.jsx)(n,{className:`h-3 w-3`})]})]}):null:(0,H.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(M,{type:`password`,placeholder:e.keyPlaceholder,value:f,onChange:e=>p(e.target.value),onKeyDown:R,className:`font-mono text-sm`}),(0,H.jsx)(j,{onClick:L,disabled:!f.trim()||h,size:`sm`,className:`shrink-0`,children:h?(0,H.jsx)(i,{className:`h-4 w-4 animate-spin`}):d(`setup:screen.card.save`)})]}),e.docsUrl&&(0,H.jsxs)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors`,children:[d(`setup:screen.card.getKey`),` `,(0,H.jsx)(l,{className:`h-3 w-3`})]}),e.referral&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:z,className:`inline-flex items-center gap-1 text-[11px] text-warning/80 hover:text-warning transition-colors`,children:C?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(S,{className:`h-3 w-3`}),` `,d(`setup:screen.card.copied`)]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(m,{className:`h-3 w-3`}),` `,d(`setup:screen.card.copyReferral`)]})}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>P(!0),className:`inline-flex items-center gap-1 text-[11px] text-warning/80 hover:text-warning transition-colors`,children:[(0,H.jsx)(a,{className:`h-3 w-3`}),` `,d(`setup:screen.card.share`)]})]})]})]})]}),(0,H.jsx)(A,{open:N,onOpenChange:P,children:(0,H.jsxs)(te,{className:`sm:max-w-md`,children:[(0,H.jsxs)(O,{children:[(0,H.jsxs)(ne,{className:`flex items-center gap-2`,children:[(0,H.jsx)(x,{className:`h-4 w-4 text-warning`}),d(`setup:screen.share.title`,{name:e.name})]}),(0,H.jsx)(k,{children:d(`setup:screen.share.description`)})]}),(0,H.jsx)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:e.referral&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`text-sm text-center`,children:(0,H.jsxs)(`p`,{className:`font-medium text-warning`,children:[`🎁 `,e.referral.reward]})}),F?(0,H.jsx)(`div`,{className:`rounded-lg border border-border p-2 bg-white`,children:(0,H.jsx)(`img`,{src:F,alt:d(`setup:screen.card.qrAlt`,{name:e.name}),className:`w-[200px] h-[200px]`})}):(0,H.jsx)(`div`,{className:`w-[200px] h-[200px] rounded-lg border border-border flex items-center justify-center bg-muted`,children:(0,H.jsx)(i,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),(0,H.jsxs)(`div`,{className:`w-full space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://twitter.com/intent/tweet?text=${t}&url=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.twitter`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.jsx)(`path`,{d:`M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z`})}),`X`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(e.referral.url),n=encodeURIComponent(`Check out ${e.name}! ${e.referral.reward}`);window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${t}&summary=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.linkedin`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.jsx)(`path`,{d:`M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z`})}),`LinkedIn`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward} ${e.referral.url}`);window.open(`https://t.me/share/url?url=${t}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.telegram`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.jsx)(`path`,{d:`M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z`})}),`Telegram`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://wa.me/?text=${t}%20${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.whatsapp`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.jsx)(`path`,{d:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.134 1.585 5.934L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z`})}),`WhatsApp`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(e.referral.url),n=encodeURIComponent(`${e.name} - ${e.referral.reward}`);window.open(`https://www.reddit.com/submit?url=${t}&title=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.reddit`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.jsx)(`path`,{d:`M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 0 1.108-.701 1.25 1.25 0 0 1 2.144.33zm-8.811 8.748c-.968 0-1.754.786-1.754 1.754 0 .968.786 1.754 1.754 1.754.968 0 1.754-.786 1.754-1.754 0-.968-.786-1.754-1.754-1.754zm7.944 0c-.968 0-1.754.786-1.754 1.754 0 .968.786 1.754 1.754 1.754.968 0 1.754-.786 1.754-1.754 0-.968-.786-1.754-1.754-1.754z`})}),`Reddit`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`https://www.facebook.com/sharer/sharer.php?u=${n}"e=${t}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-border bg-card text-xs text-foreground hover:bg-muted transition-colors`,title:d(`setup:screen.share.facebook`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`currentColor`,viewBox:`0 0 24 24`,children:(0,H.jsx)(`path`,{d:`M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z`})}),`Facebook`]}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{let t=encodeURIComponent(`Check out ${e.name}! 🎁 ${e.referral.reward}`),n=encodeURIComponent(e.referral.url);window.open(`mailto:?subject=${t}&body=${n}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-muted text-muted-foreground text-xs hover:bg-muted/80 transition-colors`,title:d(`setup:screen.share.email`),children:[(0,H.jsx)(`svg`,{role:`img`,"aria-hidden":`true`,className:`h-3.5 w-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:(0,H.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25H4.5a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75`})}),`Email`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(M,{value:e.referral.url,readOnly:!0,className:`font-mono text-xs flex-1`}),(0,H.jsx)(j,{size:`sm`,variant:`outline`,onClick:z,className:`shrink-0`,children:C?(0,H.jsx)(S,{className:`h-4 w-4`}):(0,H.jsx)(m,{className:`h-4 w-4`})})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground text-center`,children:d(`setup:screen.share.hint`)})]})]})})]})})]})}function W(){let{t:e}=u(),{model:a,setProvider:o,setModel:s,wsConnected:l,wsUrl:m}=ee(v(e=>({model:e.model,setProvider:e.setProvider,setModel:e.setModel,wsConnected:e.wsConnected,wsUrl:e.wsUrl})));C();let[g,_]=(0,B.useState)([]),[b,x]=(0,B.useState)({}),[O,te]=(0,B.useState)([]),[ne,k]=(0,B.useState)(!1),[A,M]=(0,B.useState)(null),[N,F]=(0,B.useState)(0),[I,R]=(0,B.useState)(new Set),[V,oe]=(0,B.useState)({}),[W,ce]=(0,B.useState)(U),[G,K]=(0,B.useState)(!1),[le,ue]=(0,B.useState)(0),[de,fe]=(0,B.useState)(0),[q,pe]=(0,B.useState)(null),J=(0,B.useRef)(!0);(0,B.useEffect)(()=>{let e=new AbortController,t=`${window.location.origin}/providers.json`;return K(!0),ie(t,e.signal).then(t=>{if(t!==U){if(ce(t),K(!1),!J.current){let e=t.length-de;e>0?D.success(p.t(`setup:screen.toasts.providersLoadedNew`,{count:t.length,diff:e})):e<0?D.success(p.t(`setup:screen.toasts.providersLoadedRemoved`,{count:t.length,diff:Math.abs(e)})):D.success(p.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:t.length})),fe(t.length)}pe(new Date);return}return ie(`https://raw.githubusercontent.com/WrongStack/WrongStack/main/packages/webui/public/providers.json`,e.signal)}).then(e=>{if(e){if(ce(e),!J.current){let t=e.length-de;t>0?D.success(p.t(`setup:screen.toasts.providersLoadedNew`,{count:e.length,diff:t})):t<0?D.success(p.t(`setup:screen.toasts.providersLoadedRemoved`,{count:e.length,diff:Math.abs(t)})):D.success(p.t(`setup:screen.toasts.providersLoadedNoChanges`,{count:e.length})),fe(e.length)}pe(new Date)}}).catch(()=>{J.current||D.error(p.t(`setup:screen.toasts.providersRefreshFailed`))}).finally(()=>{K(!1),J.current=!1}),()=>e.abort()},[le]);let[Y,me]=(0,B.useState)(null),[X,Z]=(0,B.useState)(null),[he,ge]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!l)return;let e=w(m),t=setTimeout(()=>{t=null,k(!1),M(p.t(`setup:screen.errors.backendNotResponding`))},8e3),n=()=>{t&&=(clearTimeout(t),null)},r=e.on(`provider.catalog`,e=>{if(e.type===`provider.catalog`){n(),M(null);let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));_(t),k(!1)}}),i=e.on(`provider.models`,e=>{if(e.type===`provider.models`){let t=e.payload;if(t.provider!==Y)return;x(e=>({...e,[t.provider]:t.models})),ge(!1),t.models.length===1?Z(t.models[0].id):a&&t.models.some(e=>e.id===a)&&Z(a)}}),o=e.on(`providers.saved`,e=>{if(e.type===`providers.saved`){let t=e.payload.providers.sort((e,t)=>e.id.localeCompare(t.id));te(t);let n=new Set(t.filter(e=>e.apiKeys.some(e=>e.isActive)).map(e=>e.id));R(n)}}),s=e.on(`provider.probe`,e=>{if(e.type!==`provider.probe`)return;let t=e.payload;oe(e=>({...e,[t.providerId]:t}))});return M(null),k(!0),e.listProviders(),()=>{n(),r?.(),i?.(),o?.(),s?.()}},[l,m,a,N]);let _e=(0,B.useCallback)(()=>{M(null),F(e=>e+1)},[]),ve=(0,B.useCallback)(()=>{ue(e=>e+1)},[]),ye=(0,B.useCallback)(t=>ae(t,e),[e]),be=(0,B.useCallback)(e=>{R(t=>new Set([...t,e])),me(e),Z(null)},[]),xe=I.size>0;(0,B.useEffect)(()=>{if(!Y||!l)return;let e=w(m);b[Y]||(ge(!0),e.listProviderModels(Y))},[Y,l,m,b]);let Se=Y?b[Y]??[]:[],Ce=(0,B.useCallback)(async()=>{if(!Y||!X)return;if(!I.has(Y)){D.error(`Please save the provider configuration before starting a session.`);return}o(Y),s(X);let e=w(m),t=await e.switchModel(Y,X,5e3);t.success?(e.newSession(),E(`chat`)):D.error(t.message||p.t(`setup:screen.errors.modelSwitchTimeout`))},[Y,X,o,s,m]),we=(0,B.useCallback)(async()=>{if(!Y||!X)return;o(Y),s(X);let e=await w(m).switchModel(Y,X,5e3);e.success?E(`chat`):D.error(e.message||p.t(`setup:screen.errors.modelSwitchTimeout`))},[Y,X,o,s,m]),Te=new Set(W.map(e=>e.id)),Ee=g.filter(e=>!Te.has(e.id)).sort((e,t)=>e.id.localeCompare(t.id)),Q=L(Ee,10);L(O,9);let $=L(Se,12,Y);return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,H.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b bg-card px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-6`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,H.jsx)(`img`,{src:`/wrongstack.svg`,alt:`WrongStack`,draggable:!1,className:`ws-brand-logo h-10 w-10 shrink-0 border border-border/70 shadow-sm`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h1`,{className:`truncate text-lg font-semibold`,children:e(`setup:screen.header.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground sm:truncate`,children:e(`setup:screen.header.subtitle`)})]})]}),xe&&Y?(0,H.jsxs)(`span`,{className:`text-xs text-success/80`,children:[(0,H.jsx)(S,{className:`h-3 w-3 inline-block mr-1`}),e(`setup:screen.header.continue`)]}):null]}),(0,H.jsx)(z,{className:`min-h-0 flex-1`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-8 p-4 pb-4 sm:p-6`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,H.jsxs)(`div`,{className:T(`flex min-w-0 items-center gap-1.5`,xe?`text-success`:`text-primary font-medium`),children:[(0,H.jsx)(y,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.addKeys`)})]}),(0,H.jsx)(n,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`div`,{className:T(`flex min-w-0 items-center gap-1.5`,Y?`text-primary font-medium`:`text-muted-foreground`),children:[(0,H.jsx)(c,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.pickModel`)})]}),(0,H.jsx)(n,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsxs)(`div`,{className:T(`flex min-w-0 items-center gap-1.5`,Y&&X?`text-primary font-medium`:`text-muted-foreground`),children:[(0,H.jsx)(r,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{children:e(`setup:screen.steps.start`)})]})]}),(0,H.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-primary/20 bg-primary/5 p-4`,children:[(0,H.jsx)(t,{className:`h-5 w-5 text-primary shrink-0 mt-0.5`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium`,children:e(`setup:screen.security.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`setup:screen.security.body`)})]})]}),A?(0,H.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-4 py-12 rounded-xl border border-destructive/30 bg-destructive/5 px-6`,children:[(0,H.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-destructive/10 border border-destructive/30 flex items-center justify-center`,children:(0,H.jsx)(d,{className:`h-6 w-6 text-destructive`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:e(`setup:screen.errors.backendUnreachable`)}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 max-w-sm`,children:A})]}),(0,H.jsxs)(j,{onClick:_e,size:`sm`,variant:`outline`,children:[(0,H.jsx)(i,{className:`h-4 w-4 mr-2`}),e(`setup:screen.errors.retry`)]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.popular`)}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[G&&(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,H.jsx)(i,{className:`h-3 w-3 animate-spin`}),e(`setup:screen.providers.updating`)]}),q&&!G&&(0,H.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,title:q.toLocaleString(),children:ye(q)}),(0,H.jsxs)(`button`,{type:`button`,onClick:ve,disabled:G,className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,title:e(`setup:screen.providers.refreshTitle`),children:[(0,H.jsx)(h,{className:T(`h-3 w-3`,G&&`animate-spin`)}),e(`setup:screen.providers.refresh`)]})]})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:W.map(e=>(0,H.jsx)(se,{popular:e,catalogProvider:g.find(t=>t.id===e.id),savedProvider:O.find(t=>t.id===e.id),onKeySaved:be,probeResult:V[e.id]},e.id))})]}),Ee.length>0&&(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.more`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Q.pageItems.map(t=>(0,H.jsx)(se,{popular:{id:t.id,name:t.name,description:e(`setup:screen.providers.catalogDescription`,{family:t.family,count:t.modelCount}),icon:`🔗`,color:`from-muted/60 to-muted/20 border-border hover:border-primary/40`,keyPlaceholder:`API key`,family:t.family},catalogProvider:t,savedProvider:O.find(e=>e.id===t.id),onKeySaved:be,probeResult:V[t.id]},t.id))}),(0,H.jsx)(P,{page:Q.page,pageSize:Q.pageSize,totalItems:Q.totalItems,onPageChange:Q.setPage,itemLabel:`providers`})]}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-muted-foreground uppercase tracking-wider`,children:e(`setup:screen.providers.selfHosted`)}),(0,H.jsx)(re,{onKeySaved:be})]})]}),ne&&(0,H.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,H.jsx)(i,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),Y&&(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`h2`,{className:`text-base font-semibold flex items-center gap-2`,children:[(0,H.jsx)(r,{className:`h-4 w-4 text-primary`}),e(`setup:screen.start.chooseModel`)]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{me(null),Z(null)},className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:e(`setup:screen.start.addMoreKeys`)})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`setup:screen.start.modelsFor`,{provider:Y})}),he?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,H.jsx)(i,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):Se.length>0?(0,H.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:$.pageItems.map(e=>{let t=e.contextWindow?`${(e.contextWindow/1e6).toFixed(0)}M ctx`:null;return(0,H.jsx)(`button`,{type:`button`,onClick:()=>Z(e.id),className:T(`w-full text-left rounded-xl border p-3 transition-all`,`hover:border-primary/40 hover:bg-primary/5`,X===e.id?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border bg-card`),children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`span`,{className:`font-medium text-sm`,children:e.name}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[t&&(0,H.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:t}),e.capabilities.slice(0,3).map(e=>(0,H.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary border border-primary/20`,children:e},e))]})]}),X===e.id&&(0,H.jsx)(`div`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary`,children:(0,H.jsx)(S,{className:`h-3 w-3 text-primary-foreground`})})]})},e.id)})}):(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground py-8 text-center`,children:e(`setup:screen.errors.noModels`)}),(0,H.jsx)(P,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,itemLabel:`models`})]}),Y&&X&&(0,H.jsxs)(`div`,{className:`sticky bottom-0 -mx-4 border-t bg-background/80 px-4 py-4 backdrop-blur-sm sm:-mx-6 sm:px-6`,children:[(0,H.jsx)(`div`,{className:`mb-3 flex min-w-0 items-center justify-between gap-2 text-sm text-muted-foreground`,children:(0,H.jsxs)(`span`,{className:`min-w-0 truncate`,children:[Y,` / `,X]})}),(0,H.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,H.jsxs)(j,{onClick:Ce,className:`flex-1`,size:`lg`,children:[(0,H.jsx)(c,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.startSession`),(0,H.jsx)(f,{className:`h-4 w-4 ml-2`})]}),(0,H.jsxs)(j,{onClick:we,variant:`outline`,className:`flex-1`,size:`lg`,children:[(0,H.jsx)(S,{className:`h-4 w-4 mr-2`}),e(`setup:screen.start.saveConfig`)]})]}),(0,H.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60 text-center mt-2`,children:e(`setup:screen.start.saveConfigHint`)})]})]})})]})}export{W as SetupScreen};
|