libre-webui 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -17
- package/backend/dist/db.d.ts.map +1 -1
- package/backend/dist/db.js +45 -0
- package/backend/dist/db.js.map +1 -1
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +33 -9
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/middleware/auth.d.ts.map +1 -1
- package/backend/dist/middleware/index.d.ts.map +1 -1
- package/backend/dist/models/personaModel.d.ts.map +1 -1
- package/backend/dist/models/personaModel.js.map +1 -1
- package/backend/dist/models/userModel.d.ts +3 -2
- package/backend/dist/models/userModel.d.ts.map +1 -1
- package/backend/dist/models/userModel.js +5 -2
- package/backend/dist/models/userModel.js.map +1 -1
- package/backend/dist/routes/agentCli.d.ts.map +1 -1
- package/backend/dist/routes/agentCli.js +2 -2
- package/backend/dist/routes/agentCli.js.map +1 -1
- package/backend/dist/routes/auth.d.ts.map +1 -1
- package/backend/dist/routes/auth.js +73 -23
- package/backend/dist/routes/auth.js.map +1 -1
- package/backend/dist/routes/chat.d.ts.map +1 -1
- package/backend/dist/routes/chat.js +103 -2
- package/backend/dist/routes/chat.js.map +1 -1
- package/backend/dist/routes/documents.d.ts.map +1 -1
- package/backend/dist/routes/documents.js +130 -0
- package/backend/dist/routes/documents.js.map +1 -1
- package/backend/dist/routes/embeddings.d.ts.map +1 -1
- package/backend/dist/routes/huggingfaceHub.d.ts.map +1 -1
- package/backend/dist/routes/imageGen.d.ts.map +1 -1
- package/backend/dist/routes/libreClaw.d.ts.map +1 -1
- package/backend/dist/routes/media.d.ts.map +1 -1
- package/backend/dist/routes/notes.d.ts +3 -0
- package/backend/dist/routes/notes.d.ts.map +1 -0
- package/backend/dist/routes/notes.js +121 -0
- package/backend/dist/routes/notes.js.map +1 -0
- package/backend/dist/routes/ollama.d.ts.map +1 -1
- package/backend/dist/routes/ollama.js +2 -2
- package/backend/dist/routes/ollama.js.map +1 -1
- package/backend/dist/routes/personas.d.ts.map +1 -1
- package/backend/dist/routes/plugins.d.ts.map +1 -1
- package/backend/dist/routes/preferences.d.ts.map +1 -1
- package/backend/dist/routes/systemDiagnostics.d.ts.map +1 -1
- package/backend/dist/routes/tts.d.ts.map +1 -1
- package/backend/dist/routes/users.d.ts.map +1 -1
- package/backend/dist/routes/users.js +21 -0
- package/backend/dist/routes/users.js.map +1 -1
- package/backend/dist/routes/work.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.d.ts +37 -4
- package/backend/dist/services/agentCliService.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.js +229 -10
- package/backend/dist/services/agentCliService.js.map +1 -1
- package/backend/dist/services/assistantCompletionService.d.ts.map +1 -1
- package/backend/dist/services/authService.d.ts.map +1 -1
- package/backend/dist/services/authService.js +6 -1
- package/backend/dist/services/authService.js.map +1 -1
- package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
- package/backend/dist/services/chatGenerationService.js +3 -3
- package/backend/dist/services/chatGenerationService.js.map +1 -1
- package/backend/dist/services/chatRequestService.d.ts.map +1 -1
- package/backend/dist/services/chatService.d.ts +6 -1
- package/backend/dist/services/chatService.d.ts.map +1 -1
- package/backend/dist/services/chatService.js +54 -1
- package/backend/dist/services/chatService.js.map +1 -1
- package/backend/dist/services/codexOAuthService.d.ts +22 -0
- package/backend/dist/services/codexOAuthService.d.ts.map +1 -0
- package/backend/dist/services/codexOAuthService.js +176 -0
- package/backend/dist/services/codexOAuthService.js.map +1 -0
- package/backend/dist/services/documentService.d.ts +7 -1
- package/backend/dist/services/documentService.d.ts.map +1 -1
- package/backend/dist/services/documentService.js +24 -11
- package/backend/dist/services/documentService.js.map +1 -1
- package/backend/dist/services/embeddingService.d.ts.map +1 -1
- package/backend/dist/services/encryptionService.d.ts.map +1 -1
- package/backend/dist/services/encryptionService.js.map +1 -1
- package/backend/dist/services/followUpService.d.ts +44 -0
- package/backend/dist/services/followUpService.d.ts.map +1 -0
- package/backend/dist/services/followUpService.js +123 -0
- package/backend/dist/services/followUpService.js.map +1 -0
- package/backend/dist/services/galleryService.d.ts.map +1 -1
- package/backend/dist/services/galleryService.js.map +1 -1
- package/backend/dist/services/libreClawService.d.ts.map +1 -1
- package/backend/dist/services/mediaGenerationJobService.d.ts.map +1 -1
- package/backend/dist/services/mediaGenerationJobService.js.map +1 -1
- package/backend/dist/services/memoryService.d.ts.map +1 -1
- package/backend/dist/services/memoryService.js.map +1 -1
- package/backend/dist/services/mutationEngineService.d.ts.map +1 -1
- package/backend/dist/services/oauthSecurity.d.ts +14 -0
- package/backend/dist/services/oauthSecurity.d.ts.map +1 -0
- package/backend/dist/services/oauthSecurity.js +101 -0
- package/backend/dist/services/oauthSecurity.js.map +1 -0
- package/backend/dist/services/ollamaService.d.ts +8 -2
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +40 -2
- package/backend/dist/services/ollamaService.js.map +1 -1
- package/backend/dist/services/personaService.d.ts.map +1 -1
- package/backend/dist/services/personaService.js.map +1 -1
- package/backend/dist/services/pluginActivationService.d.ts.map +1 -1
- package/backend/dist/services/pluginActivationService.js.map +1 -1
- package/backend/dist/services/pluginAudioGenerationService.d.ts.map +1 -1
- package/backend/dist/services/pluginAudioGenerationService.js.map +1 -1
- package/backend/dist/services/pluginCapabilityRegistryService.d.ts.map +1 -1
- package/backend/dist/services/pluginCapabilityRegistryService.js.map +1 -1
- package/backend/dist/services/pluginCredentialsService.d.ts.map +1 -1
- package/backend/dist/services/pluginEmbeddingService.d.ts.map +1 -1
- package/backend/dist/services/pluginEmbeddingService.js.map +1 -1
- package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -1
- package/backend/dist/services/pluginImageGenerationService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts +5 -0
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +53 -4
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/pluginTTSService.d.ts.map +1 -1
- package/backend/dist/services/pluginTTSService.js.map +1 -1
- package/backend/dist/services/pluginUsageService.d.ts +18 -0
- package/backend/dist/services/pluginUsageService.d.ts.map +1 -1
- package/backend/dist/services/pluginUsageService.js +53 -0
- package/backend/dist/services/pluginUsageService.js.map +1 -1
- package/backend/dist/services/pluginVariablesService.d.ts.map +1 -1
- package/backend/dist/services/pluginVariablesService.js.map +1 -1
- package/backend/dist/services/pluginVideoGenerationService.d.ts.map +1 -1
- package/backend/dist/services/pluginVideoGenerationService.js.map +1 -1
- package/backend/dist/services/preferencesService.d.ts.map +1 -1
- package/backend/dist/services/preferencesService.js +1 -0
- package/backend/dist/services/preferencesService.js.map +1 -1
- package/backend/dist/services/registrationPolicy.d.ts +3 -3
- package/backend/dist/services/registrationPolicy.d.ts.map +1 -1
- package/backend/dist/services/registrationPolicy.js +4 -4
- package/backend/dist/services/registrationPolicy.js.map +1 -1
- package/backend/dist/services/simpleGitHubOAuth.d.ts +1 -1
- package/backend/dist/services/simpleGitHubOAuth.d.ts.map +1 -1
- package/backend/dist/services/simpleGitHubOAuth.js +5 -1
- package/backend/dist/services/simpleGitHubOAuth.js.map +1 -1
- package/backend/dist/services/simpleHuggingFaceOAuth.d.ts +1 -1
- package/backend/dist/services/simpleHuggingFaceOAuth.d.ts.map +1 -1
- package/backend/dist/services/simpleHuggingFaceOAuth.js +5 -5
- package/backend/dist/services/simpleHuggingFaceOAuth.js.map +1 -1
- package/backend/dist/services/systemDiagnosticsService.d.ts.map +1 -1
- package/backend/dist/services/systemDiagnosticsService.js.map +1 -1
- package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
- package/backend/dist/services/turnstileService.d.ts.map +1 -1
- package/backend/dist/services/userService.d.ts +1 -0
- package/backend/dist/services/userService.js +1 -1
- package/backend/dist/services/workAgentService.d.ts.map +1 -1
- package/backend/dist/services/workAgentService.js.map +1 -1
- package/backend/dist/services/workEventService.d.ts.map +1 -1
- package/backend/dist/services/workEventService.js.map +1 -1
- package/backend/dist/services/workHostWorkspaceService.d.ts.map +1 -1
- package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
- package/backend/dist/services/workModelProviderService.js +30 -6
- package/backend/dist/services/workModelProviderService.js.map +1 -1
- package/backend/dist/services/workPreviewProxyService.d.ts.map +1 -1
- package/backend/dist/services/workPreviewProxyService.js.map +1 -1
- package/backend/dist/services/workRuntimeService.d.ts +6 -6
- package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeService.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/services/workTerminalService.d.ts +1 -1
- package/backend/dist/services/workTerminalService.d.ts.map +1 -1
- package/backend/dist/services/workTerminalService.js.map +1 -1
- package/backend/dist/storage.d.ts +12 -1
- package/backend/dist/storage.d.ts.map +1 -1
- package/backend/dist/storage.js +183 -9
- package/backend/dist/storage.js.map +1 -1
- package/backend/dist/storageMappers.d.ts +13 -0
- package/backend/dist/storageMappers.d.ts.map +1 -1
- package/backend/dist/storageMappers.js +5 -0
- package/backend/dist/storageMappers.js.map +1 -1
- package/backend/dist/types/index.d.ts +29 -0
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/utils/chatContext.js.map +1 -1
- package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -1
- package/backend/dist/utils/chatDocumentContext.js +6 -1
- package/backend/dist/utils/chatDocumentContext.js.map +1 -1
- package/backend/dist/utils/chatProviderSelection.d.ts.map +1 -1
- package/backend/dist/utils/generationUtils.d.ts.map +1 -1
- package/backend/dist/utils/hash.d.ts.map +1 -1
- package/backend/dist/utils/hash.js +13 -2
- package/backend/dist/utils/hash.js.map +1 -1
- package/backend/dist/utils/logger.d.ts +1 -1
- package/backend/dist/utils/logger.d.ts.map +1 -1
- package/backend/dist/utils/ollamaStreaming.d.ts +6 -2
- package/backend/dist/utils/ollamaStreaming.d.ts.map +1 -1
- package/backend/dist/utils/ollamaStreaming.js +12 -2
- package/backend/dist/utils/ollamaStreaming.js.map +1 -1
- package/backend/dist/utils/openAIResponsesAdapter.js.map +1 -1
- package/backend/dist/utils/packagePaths.js.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.js +11 -4
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
- package/backend/dist/utils/pluginChatContext.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +1 -0
- package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
- package/backend/dist/utils/pluginStreamAdapter.d.ts +10 -1
- package/backend/dist/utils/pluginStreamAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginStreamAdapter.js +30 -23
- package/backend/dist/utils/pluginStreamAdapter.js.map +1 -1
- package/backend/dist/utils/pluginValidation.d.ts +1 -1
- package/backend/dist/utils/pluginValidation.d.ts.map +1 -1
- package/backend/dist/utils/pluginValidation.js +17 -0
- package/backend/dist/utils/pluginValidation.js.map +1 -1
- package/backend/dist/utils/resourceLimits.d.ts +10 -0
- package/backend/dist/utils/resourceLimits.d.ts.map +1 -0
- package/backend/dist/utils/resourceLimits.js +29 -0
- package/backend/dist/utils/resourceLimits.js.map +1 -0
- package/backend/dist/utils/thinkingPhaseTimer.d.ts +21 -0
- package/backend/dist/utils/thinkingPhaseTimer.d.ts.map +1 -0
- package/backend/dist/utils/thinkingPhaseTimer.js +84 -0
- package/backend/dist/utils/thinkingPhaseTimer.js.map +1 -0
- package/backend/dist/utils/webpageFetcher.d.ts +25 -0
- package/backend/dist/utils/webpageFetcher.d.ts.map +1 -0
- package/backend/dist/utils/webpageFetcher.js +231 -0
- package/backend/dist/utils/webpageFetcher.js.map +1 -0
- package/backend/dist/utils/websocketMessages.js.map +1 -1
- package/backend/dist/websocketServer.d.ts.map +1 -1
- package/backend/dist/websocketServer.js +2 -1
- package/backend/dist/websocketServer.js.map +1 -1
- package/backend/package.json +8 -7
- package/bin/cli.js +2 -2
- package/frontend/dist/assets/index-BA116EVY.js +11 -0
- package/frontend/dist/assets/index-CFhy8YLA.css +1 -0
- package/frontend/dist/assets/markdown-math-ClQbWekD.css +1 -0
- package/frontend/dist/assets/xterm-DHcfr8qj.css +1 -0
- package/frontend/dist/index.html +21 -16
- package/frontend/dist/js/ArtifactContainer-CBTr5mSK.js +1 -0
- package/frontend/dist/js/{ArtifactDemoPage-BWN0MWCx.js → ArtifactDemoPage-0BLd-m3N.js} +1 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-DjGIUKtP.js +1 -0
- package/frontend/dist/js/{Button-CRwzOaDZ.js → Button-X9TT9gTD.js} +1 -1
- package/frontend/dist/js/ChatPage-BgLadsgU.js +16 -0
- package/frontend/dist/js/FirstTimeSetup-CZKfjAkx.js +1 -0
- package/frontend/dist/js/GalleryPage-DH-KEeIZ.js +1 -0
- package/frontend/dist/js/HomePage-C4TJCwU6.js +1 -0
- package/frontend/dist/js/LibreClawPage-B_eC8oQo.js +1 -0
- package/frontend/dist/js/{ModelManagerModals-C2rwHd01.js → ModelManagerModals-D9j9RECi.js} +1 -1
- package/frontend/dist/js/ModelSelector-DwhKmtQx.js +1 -0
- package/frontend/dist/js/ModelsPage-DQm2DgF3.js +2 -0
- package/frontend/dist/js/NotesPage-pNuo3BZp.js +1 -0
- package/frontend/dist/js/{OptimizedSyntaxHighlighter-Ci9sRc78.js → OptimizedSyntaxHighlighter-CWYUn9Oe.js} +1 -1
- package/frontend/dist/js/PersonasPage-DpHCAyoD.js +13 -0
- package/frontend/dist/js/PluginUsagePage-Cd5MJbLi.js +1 -0
- package/frontend/dist/js/{RichMessageContent-nAEaPTpH.js → RichMessageContent-B1bidjA8.js} +3 -3
- package/frontend/dist/js/SettingsModal-ZbZKdZcC.js +1 -0
- package/frontend/dist/js/SystemPage-CUfqMR-l.js +1 -0
- package/frontend/dist/js/UserManagementPage-5ZGnsxNF.js +1 -0
- package/frontend/dist/js/WorkPage-ShAy19E2.js +5 -0
- package/frontend/dist/js/addon-fit-DIOBYJe3.js +1 -0
- package/frontend/dist/js/api-CI1Inz7g.js +19 -0
- package/frontend/dist/js/appStore-wGpPGj47.js +2 -0
- package/frontend/dist/js/ar-ONXFvOB1.js +2 -0
- package/frontend/dist/js/artifactHtml-C0Hu9I1u.js +41 -0
- package/frontend/dist/js/authStore-D-d7UIpv.js +3 -0
- package/frontend/dist/js/babel-CmENXdZw.js +16 -0
- package/frontend/dist/js/bn-BLhREPm6.js +2 -0
- package/frontend/dist/js/chatStore-BaX22w_g.js +2 -0
- package/frontend/dist/js/cs-Bg8E9fG5.js +2 -0
- package/frontend/dist/js/da-ODCU8w4x.js +2 -0
- package/frontend/dist/js/de-nuGHRJ5N.js +2 -0
- package/frontend/dist/js/es-DcN_cwum.js +2 -0
- package/frontend/dist/js/estree-vPoIgYRx.js +44 -0
- package/frontend/dist/js/fr-C-L_xGr5.js +2 -0
- package/frontend/dist/js/hi-DUEtwA9G.js +2 -0
- package/frontend/dist/js/html-_taODyXh.js +25 -0
- package/frontend/dist/js/i18n-xir4Zz7C.js +2 -0
- package/frontend/dist/js/i18next-DgmgtwsV.js +1 -0
- package/frontend/dist/js/id-DNTYhti_.js +2 -0
- package/frontend/dist/js/imageGenModels-Dx_QMLJQ.js +1 -0
- package/frontend/dist/js/is-Bx28ymbQ.js +2 -0
- package/frontend/dist/js/it-BjW-JLlS.js +2 -0
- package/frontend/dist/js/ja-uThj4Q1w.js +2 -0
- package/frontend/dist/js/ko-DqgmMYXK.js +2 -0
- package/frontend/dist/js/logger-DSXjF4ye.js +1 -0
- package/frontend/dist/js/markdown-CLKggXc3.js +70 -0
- package/frontend/dist/js/markdown-core-DHnR5Hw8.js +16 -0
- package/frontend/dist/js/markdown-math-B7FlYsmr.js +261 -0
- package/frontend/dist/js/messageCodeStyles-B0BoOSOR.js +2 -0
- package/frontend/dist/js/ms-R9kt_P0T.js +2 -0
- package/frontend/dist/js/nl-BjmtEgpK.js +2 -0
- package/frontend/dist/js/pl-C8_gU9r1.js +2 -0
- package/frontend/dist/js/postcss-B5WIGhAY.js +62 -0
- package/frontend/dist/js/pt-7BJForUD.js +2 -0
- package/frontend/dist/js/react-vendor-DPNXrO-8.js +9 -0
- package/frontend/dist/js/{rolldown-runtime-QTnfLwEv.js → rolldown-runtime-hePW80VL.js} +1 -1
- package/frontend/dist/js/router-vendor-Ca9zqOqT.js +1 -0
- package/frontend/dist/js/ru-D2HmhY6Y.js +2 -0
- package/frontend/dist/js/{standalone-C0NjJpWr.js → standalone-53qXRmN5.js} +8 -8
- package/frontend/dist/js/sv-zny3sDBM.js +2 -0
- package/frontend/dist/js/syntax-highlight-Ca9bHsaz.js +8 -0
- package/frontend/dist/js/th-CAzEKRz8.js +2 -0
- package/frontend/dist/js/tr-BmYgtmUo.js +2 -0
- package/frontend/dist/js/{typescript-d0TUM2-0.js → typescript-C6-ED_Fw.js} +10 -10
- package/frontend/dist/js/ui-BXTx1csA.js +2 -0
- package/frontend/dist/js/ui-vendor-D_pYT79f.js +177 -0
- package/frontend/dist/js/uk-eiYZ0uRq.js +2 -0
- package/frontend/dist/js/useTranslation-CdeLZqSW.js +1 -0
- package/frontend/dist/js/utils-BhpNrGnR.js +1 -0
- package/frontend/dist/js/utils-vendor-1zob7nK9.js +9 -0
- package/frontend/dist/js/vi-C7SVAWpO.js +2 -0
- package/frontend/dist/js/welcomePrompts-to5mv_gx.js +1 -0
- package/frontend/dist/js/xterm-Da5ppSVt.js +18 -0
- package/frontend/dist/js/{yaml-mLy9chOK.js → yaml-QD4znPfZ.js} +20 -20
- package/frontend/dist/js/zh-2Q3cQv3s.js +2 -0
- package/package.json +19 -12
- package/plugins/codex-oauth.json +19 -0
- package/frontend/dist/assets/index-ChhWhug2.css +0 -1
- package/frontend/dist/assets/index-CmZntyR1.js +0 -3
- package/frontend/dist/assets/markdown-math-CYlHEDRF.css +0 -1
- package/frontend/dist/assets/xterm-CmMoOwwu.css +0 -1
- package/frontend/dist/js/ArtifactContainer-CBAbdoIJ.js +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-D-AvYkfk.js +0 -1
- package/frontend/dist/js/ChatPage-w2FkF_fE.js +0 -16
- package/frontend/dist/js/FirstTimeSetup-CzBxl7UH.js +0 -1
- package/frontend/dist/js/GalleryPage-Cv8pniRW.js +0 -1
- package/frontend/dist/js/HomePage-Vyj4ndU4.js +0 -1
- package/frontend/dist/js/LibreClawPage-CYhLgQB-.js +0 -1
- package/frontend/dist/js/ModelSelector-D7kDjZV9.js +0 -1
- package/frontend/dist/js/ModelsPage-BnUddkrs.js +0 -2
- package/frontend/dist/js/PersonasPage-BL5XlrEm.js +0 -13
- package/frontend/dist/js/PluginUsagePage-BXqweCCs.js +0 -1
- package/frontend/dist/js/SettingsModal-DZYCI5-y.js +0 -1
- package/frontend/dist/js/SystemPage-jdHYfn9A.js +0 -1
- package/frontend/dist/js/UserManagementPage-BpOnt6os.js +0 -1
- package/frontend/dist/js/WorkPage-DAp1T1dl.js +0 -5
- package/frontend/dist/js/addon-fit-Cj0_dfHF.js +0 -1
- package/frontend/dist/js/api-BCqWXjZI.js +0 -19
- package/frontend/dist/js/appStore-CDM6V5ny.js +0 -2
- package/frontend/dist/js/ar-DS8gs8WK.js +0 -2
- package/frontend/dist/js/artifactHtml-B7Oy2e__.js +0 -27
- package/frontend/dist/js/authStore-Bl5ofD_h.js +0 -4
- package/frontend/dist/js/babel-BnLuavNv.js +0 -16
- package/frontend/dist/js/bn-CrMPJwTR.js +0 -2
- package/frontend/dist/js/cs-BL116Ezu.js +0 -2
- package/frontend/dist/js/da-TDNaKzqy.js +0 -2
- package/frontend/dist/js/de-DkIqdAB5.js +0 -2
- package/frontend/dist/js/demoMode-BhEpMVh5.js +0 -1
- package/frontend/dist/js/es-CHRXt6Fd.js +0 -2
- package/frontend/dist/js/estree-BFya-bSu.js +0 -44
- package/frontend/dist/js/fr-8715yUKq.js +0 -2
- package/frontend/dist/js/hi-C2O08SBU.js +0 -2
- package/frontend/dist/js/html-DJot0Wwf.js +0 -25
- package/frontend/dist/js/id-Dq7UXUEV.js +0 -2
- package/frontend/dist/js/is-B3dbbhSl.js +0 -2
- package/frontend/dist/js/it-CLSuu2K7.js +0 -2
- package/frontend/dist/js/ja-CthrqyCR.js +0 -2
- package/frontend/dist/js/ko-BJvFDJ82.js +0 -2
- package/frontend/dist/js/logger-DbNs3-DK.js +0 -1
- package/frontend/dist/js/markdown-CXwWsPYG.js +0 -70
- package/frontend/dist/js/markdown-core-GI9BPwrB.js +0 -16
- package/frontend/dist/js/markdown-math-E4O1gcxj.js +0 -261
- package/frontend/dist/js/ms-QV0202Mj.js +0 -2
- package/frontend/dist/js/nl-Dob1m1pV.js +0 -2
- package/frontend/dist/js/pl-urfOKnYI.js +0 -2
- package/frontend/dist/js/postcss-DSDkwgFE.js +0 -62
- package/frontend/dist/js/pt-D52Xkpi0.js +0 -2
- package/frontend/dist/js/react-vendor-DyG_ODzn.js +0 -9
- package/frontend/dist/js/router-vendor-BjDI9mRe.js +0 -1
- package/frontend/dist/js/ru-CwnW9Xe2.js +0 -2
- package/frontend/dist/js/sv-BNclj-Fo.js +0 -2
- package/frontend/dist/js/syntax-highlight-pM1xnNpY.js +0 -8
- package/frontend/dist/js/th-BlQ4PL57.js +0 -2
- package/frontend/dist/js/tr-B80aZ1px.js +0 -2
- package/frontend/dist/js/ui-vendor-ChfdHf5M.js +0 -177
- package/frontend/dist/js/uk-DZuuaI56.js +0 -2
- package/frontend/dist/js/useTranslation-Cs6iTP4m.js +0 -1
- package/frontend/dist/js/utils-DmZD5uA3.js +0 -1
- package/frontend/dist/js/utils-vendor-Cbaj0BC5.js +0 -9
- package/frontend/dist/js/vi-Bg42fPfF.js +0 -2
- package/frontend/dist/js/xterm-DKl1QLiw.js +0 -7
- package/frontend/dist/js/zh-BSt87zs6.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-GI9BPwrB.js";import{t as r}from"./useTranslation-Cs6iTP4m.js";import{A as i,At as a,B as o,D as s,E as c,Ht as l,J as u,L as d,Nt as f,O as p,P as m,Pt as h,St as g,T as _,Ut as v,X as y,Xt as b,Y as x,_ as S,a as C,bt as w,f as T,h as E,it as ee,n as te,ot as ne,pn as D,rn as O,rt as k,tn as A,tt as re,u as j,vt as ie,w as ae,xt as oe,yt as se}from"./ui-vendor-ChfdHf5M.js";import{t as ce}from"./logger-DbNs3-DK.js";import{C as M,E as le,S as ue,T as de,_ as N,a as fe,c as P,g as pe,i as me,l as he,n as ge,p as _e,r as ve,x as ye}from"./api-BCqWXjZI.js";import{t as F}from"./utils-DmZD5uA3.js";import{S as I,b as be,c as xe,d as Se,f as Ce,h as we,m as Te,n as L,u as Ee,v as De,x as Oe,y as ke}from"./authStore-Bl5ofD_h.js";import{a as Ae,n as je,o as Me,t as Ne}from"./appStore-CDM6V5ny.js";import{t as R}from"./Button-CRwzOaDZ.js";import{A as Pe,F as Fe,L as Ie,M as Le,N as Re,T as ze,o as Be,w as z}from"../assets/index-CmZntyR1.js";var B=e(n(),1),V=t(),Ve=[{href:`https://github.com/libre-webui/libre-webui`,icon:ne,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:ee,labelKey:`settings.about.links.gitlab`,descriptionKey:`settings.about.links.gitlabDescription`},{href:`https://librewebui.org`,icon:w,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:v,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://ollama.ai`,icon:l,labelKey:`settings.about.links.ollama`,descriptionKey:`settings.about.links.ollamaDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:o,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],He=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function Ue({appVersion:e}){let{t}=r();return(0,V.jsx)(`div`,{className:`space-y-6`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-4`,children:(0,V.jsx)(Be,{className:`text-gray-900 dark:text-gray-100`})}),(0,V.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,V.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,V.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,V.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:He.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,V.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,V.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Ve.map(e=>{let n=e.icon;return(0,V.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 p-3 bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg hover:bg-gray-50 dark:hover:bg-dark-200 hover:border-gray-300 dark:hover:border-dark-400 transition-all duration-200 group`,children:[(0,V.jsx)(n,{className:`h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,V.jsx)(w,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.href)})})]}),(0,V.jsx)(`div`,{className:`mt-6 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-gray-500 dark:text-gray-400`,children:[e.includes(`-dev`)?(0,V.jsx)(`span`,{children:t(`settings.about.version`,{version:e})}):(0,V.jsx)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${e}`,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:t(`settings.about.version`,{version:e})}),(0,V.jsxs)(`span`,{children:[t(`settings.about.openSourceBy`,{company:``}),(0,V.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:`Kroonen AI`})]})]})})]})})}var We=ce(`components:background-upload`),Ge=({className:e=``})=>{let{t}=r(),{preferences:n,setPreferences:i,backgroundImage:a,uploadBackgroundImage:o,removeBackgroundImage:s}=Ne(),c=(0,B.useRef)(null),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(!1),p=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},m=async e=>{if(!e.type.startsWith(`image/`)){D.error(`Please select a valid image file`);return}if(e.size>5*1024*1024){D.error(`Image file size must be less than 5MB`);return}u(!0);try{await o(e),D.success(`Background image uploaded successfully`)}catch(e){We.error(`Failed to upload background:`,e),D.error(`Failed to upload background image`)}finally{u(!1)}},h=e=>{let t=e.target.files?.[0];t&&m(t)},g=e=>{e.preventDefault(),f(!0)},_=e=>{e.preventDefault(),f(!1)},v=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files?.[0];t&&m(t)},b=()=>{s(),D.success(`Background image removed`)},x=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,enabled:e};if(i({backgroundSettings:n}),t||!e)try{await P.updatePreferences({backgroundSettings:n})}catch(e){We.error(`Failed to update preferences:`,e)}},S=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,blurAmount:e};if(i({backgroundSettings:n}),t)try{await P.updatePreferences({backgroundSettings:n})}catch(e){We.error(`Failed to update preferences:`,e)}},C=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,opacity:e};if(i({backgroundSettings:n}),t)try{await P.updatePreferences({backgroundSettings:n})}catch(e){We.error(`Failed to update preferences:`,e)}};return(0,V.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,V.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:p.enabled,onChange:e=>x(e.target.checked)}),(0,V.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,V.jsx)(`div`,{className:`relative`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0`,children:(0,V.jsx)(`img`,{src:a,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,V.jsx)(R,{variant:`ghost`,size:`sm`,onClick:b,className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,V.jsx)(te,{className:`h-4 w-4`})})]})}):(0,V.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${d?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:g,onDragLeave:_,onDrop:v,onClick:()=>c.current?.click(),children:[(0,V.jsx)(y,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,V.jsxs)(R,{variant:`outline`,size:`sm`,disabled:l,className:`mx-auto`,children:[(0,V.jsx)(j,{className:`h-4 w-4 me-2`}),t(l?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,V.jsx)(`input`,{ref:c,type:`file`,accept:`image/*`,onChange:h,className:`hidden`})]}),a&&(0,V.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.blur`),`:`,` `,p.blurAmount,`px`]}),(0,V.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:p.blurAmount,onChange:e=>S(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.opacity`),`:`,` `,Math.round(p.opacity*100),`%`]}),(0,V.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.1`,value:p.opacity,onChange:e=>C(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]})]})]})})},Ke=()=>{let{t:e,i18n:t}=r();return(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-gray-400`}),(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.appearance.language.title`)})]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.appearance.language.description`)}),(0,V.jsx)(`select`,{"data-testid":`language-switcher-select`,value:Le(t.language),onChange:e=>{let t=e.target.value;Pe(t)},className:`w-full px-3 py-2 text-sm border border-gray-200 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-primary-500`,children:Re.map(e=>(0,V.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))})]})};function qe({theme:e,preferences:t,onThemeChange:n,onAccentChange:i,onCustomAccentChange:a,onAdaptToAccentChange:o,onShowUsernameChange:s}){let{t:c}=r(),l=e.accent||`blue`,u=e.customAccent||`#2563eb`,f=Ae(e);return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(Ke,{}),(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:c(`settings.appearance.title`)})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`button`,{onClick:()=>n(`light`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`light`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,V.jsx)(E,{className:`h-4 w-4`}),c(`settings.appearance.theme.light`)]}),(0,V.jsxs)(`button`,{onClick:()=>n(`dark`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`dark`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,V.jsx)(d,{className:`h-4 w-4`}),c(`settings.appearance.theme.dark`)]})]}),(0,V.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-3`,children:[(0,V.jsx)(`div`,{children:(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:c(`settings.appearance.accent.title`,{defaultValue:`Accent color`})})}),(0,V.jsx)(`div`,{className:`h-9 w-9 rounded-full border border-gray-200 dark:border-dark-400 shadow-inner flex-shrink-0`,style:{backgroundColor:f},"aria-hidden":`true`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-5 xs:grid-cols-6 sm:grid-cols-9 gap-2`,children:[je.map(e=>{let t=l===e.id;return(0,V.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:`relative h-10 rounded-xl border transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${t?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,style:{backgroundColor:e.color},"aria-label":c(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,V.jsx)(h,{className:`absolute inset-0 m-auto h-4 w-4 drop-shadow`,style:{color:e.foreground}})},e.id)}),(0,V.jsxs)(`label`,{className:`relative h-10 rounded-xl border transition-all duration-200 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-500 focus-within:ring-offset-2 dark:focus-within:ring-offset-dark-50 overflow-hidden cursor-pointer ${l===`custom`?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,title:c(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":c(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,V.jsx)(`input`,{type:`color`,value:u,onInput:e=>a(e.currentTarget.value),onChange:e=>a(e.target.value),className:`absolute inset-0 h-full w-full cursor-pointer opacity-0`}),(0,V.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:u},"aria-hidden":`true`}),(0,V.jsx)(m,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),(0,V.jsxs)(`div`,{className:`mt-5 border-t border-gray-200 pt-5 dark:border-dark-300`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:c(`settings.appearance.accent.behaviorTitle`)}),(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.behaviorDescription`)}),(0,V.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":!e.adaptToAccent,onClick:()=>o(!1),className:`rounded-xl border p-3 text-start transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${e.adaptToAccent?`border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-100 dark:hover:border-dark-400 dark:hover:bg-dark-200`:`border-primary-500 bg-primary-50/70 shadow-sm dark:border-primary-400 dark:bg-primary-950/25`}`,children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:c(`settings.appearance.accent.defaultStyle`)}),(0,V.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":e.adaptToAccent===!0,onClick:()=>o(!0),className:`rounded-xl border p-3 text-start transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${e.adaptToAccent?`border-primary-500 bg-primary-50/70 shadow-sm dark:border-primary-400 dark:bg-primary-950/25`:`border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-100 dark:hover:border-dark-400 dark:hover:bg-dark-200`}`,children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:c(`settings.appearance.accent.adaptedStyle`)}),(0,V.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:c(`settings.appearance.chatInterface.title`)}),(0,V.jsx)(`div`,{className:`space-y-3`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:c(`settings.appearance.chatInterface.showUsername`)}),(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`settings.appearance.chatInterface.showUsernameDescription`)})]}),(0,V.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,V.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showUsername,onChange:e=>s(e.target.checked)}),(0,V.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]})})]}),(0,V.jsx)(Ge,{})]})}function Je({sessionCount:e,loading:t,importing:n,showImportOptions:i,mergeStrategy:a,importResult:o,importFileInputRef:s,onExportData:c,onImportFileSelect:l,onClearAllHistory:u,onMergeStrategyChange:d,onConfirmImport:f,onCancelImport:p,onDismissImportResult:m}){let{t:h}=r();return(0,V.jsx)(`div`,{className:`space-y-6`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.data.title`)}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.export`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.exportDescription`)}),(0,V.jsx)(R,{onClick:c,variant:`outline`,size:`sm`,className:`w-full`,children:h(`settings.data.exportAll`)})]}),(0,V.jsxs)(`div`,{className:`flex flex-col`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.import`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.importDescription`)}),(0,V.jsx)(`input`,{ref:s,type:`file`,accept:`.json`,onChange:l,className:`hidden`}),(0,V.jsx)(R,{onClick:()=>s.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,V.jsxs)(`div`,{className:`flex flex-col`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.clearSessions`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.clearSessionsDescription`)}),(0,V.jsx)(R,{onClick:u,variant:`outline`,size:`sm`,className:`w-full text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border-red-200 hover:border-red-300 dark:border-red-800 dark:hover:border-red-700`,disabled:e===0||t,children:t?h(`settings.data.clearing`):h(`settings.data.clearAll`,{count:e})})]})]}),i&&(0,V.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,V.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:h(`settings.data.importOptions`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:h(`settings.data.importOptionsDescription`)}),(0,V.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:a===`skip`,onChange:e=>d(e.target.value),className:`me-2`}),(0,V.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.skipDuplicates`)})]}),(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:a===`overwrite`,onChange:e=>d(e.target.value),className:`me-2`}),(0,V.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.overwrite`)})]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(R,{onClick:f,size:`sm`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.import`)}),(0,V.jsx)(R,{onClick:p,variant:`outline`,size:`sm`,children:h(`common.cancel`)})]})]}),o&&(0,V.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,V.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:h(`settings.data.importResults`)}),(0,V.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,V.jsxs)(`div`,{children:[h(`settings.data.preferences`),`:`,` `,o.preferences.imported?h(`settings.data.imported`):h(`settings.data.failed`)]}),(0,V.jsxs)(`div`,{children:[h(`settings.data.sessions`),`:`,` `,o.sessions.imported,` `,h(`settings.data.importedLabel`),`,`,o.sessions.skipped,` `,h(`settings.data.skipped`)]}),(0,V.jsxs)(`div`,{children:[h(`settings.data.documents`),`:`,` `,o.documents.imported,` `,h(`settings.data.importedLabel`),`,`,` `,o.documents.skipped,` `,h(`settings.data.skipped`)]}),(o.sessions.errors.length>0||o.documents.errors.length>0)&&(0,V.jsxs)(`div`,{className:`mt-2`,children:[(0,V.jsxs)(`p`,{className:`font-medium`,children:[h(`settings.data.errors`),`:`]}),o.sessions.errors.map((e,t)=>(0,V.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`session-${t}`)),o.documents.errors.map((e,t)=>(0,V.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`document-${t}`))]})]}),(0,V.jsx)(R,{onClick:m,variant:`outline`,size:`sm`,className:`mt-2`,children:h(`common.close`)})]})]})]})})}function H({checked:e,onChange:t,disabled:n=!1}){return(0,V.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),disabled:n,className:`sr-only`}),(0,V.jsx)(`div`,{className:F(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2`,n?`bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed`:e?`bg-primary-600 dark:bg-primary-500`:`bg-gray-200 dark:bg-dark-300`),children:(0,V.jsx)(`span`,{className:F(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})]})}function Ye({settings:e,effectiveSettings:t,modelOptions:n,status:i,regenerating:a,onSettingChange:o,onReset:s,onRegenerate:l,onSave:u}){let{t:d}=r();return(0,V.jsx)(`div`,{className:`space-y-6`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:d(`settings.documents.title`)}),(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 p-4 rounded-lg border border-gray-200 dark:border-dark-300 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`settings.documents.embeddings.title`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:d(`settings.documents.embeddings.enable`)})]}),(0,V.jsx)(H,{checked:e.enabled,onChange:e=>o(`enabled`,e)})]}),e.enabled&&(0,V.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:d(`settings.documents.embeddings.model`)}),(0,V.jsx)(z,{value:t.model,onChange:e=>o(`model`,e.target.value),options:n}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:d(`settings.documents.embeddings.modelDescription`)})]}),(0,V.jsx)(Xe,{label:d(`settings.documents.embeddings.chunkSize`),value:e.chunkSize,min:500,max:2e3,step:100,description:d(`settings.documents.embeddings.chunkSizeDescription`),onChange:e=>o(`chunkSize`,e)}),(0,V.jsx)(Xe,{label:d(`settings.documents.embeddings.chunkOverlap`),value:e.chunkOverlap,min:50,max:500,step:50,description:d(`settings.documents.embeddings.chunkOverlapDescription`),onChange:e=>o(`chunkOverlap`,e)}),(0,V.jsx)(Xe,{label:d(`settings.documents.embeddings.similarityThreshold`),value:e.similarityThreshold,min:.3,max:.9,step:.05,description:d(`settings.documents.embeddings.similarityDescription`),format:e=>e.toFixed(2),onChange:e=>o(`similarityThreshold`,e)})]})]}),i&&(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:d(`settings.documents.embeddings.status`)}),(0,V.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,V.jsxs)(`div`,{children:[d(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,V.jsx)(`span`,{className:i.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:i.available?d(`settings.documents.embeddings.available`):d(`settings.documents.embeddings.unavailable`)})]}),(0,V.jsxs)(`div`,{children:[d(`settings.documents.embeddings.model`),`:`,` `,(0,V.jsx)(`span`,{className:`font-medium`,children:i.model})]}),(0,V.jsxs)(`div`,{children:[d(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,V.jsxs)(`span`,{className:`font-medium`,children:[i.chunksWithEmbeddings,` / `,i.totalChunks]})]}),i.totalChunks>0&&(0,V.jsxs)(`div`,{children:[d(`settings.documents.embeddings.coverage`),`:`,` `,(0,V.jsxs)(`span`,{className:`font-medium`,children:[Math.round(i.chunksWithEmbeddings/i.totalChunks*100),`%`]})]})]})]}),(0,V.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(R,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,V.jsx)(c,{size:16}),d(`settings.generation.resetDefaults`)]}),e.enabled&&i&&i.totalChunks>0&&(0,V.jsxs)(R,{onClick:l,disabled:a,variant:`outline`,className:`flex items-center gap-2 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20`,children:[(0,V.jsx)(g,{size:16}),d(a?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,V.jsxs)(R,{onClick:u,className:`flex items-center gap-2`,children:[(0,V.jsx)(h,{size:16}),d(`settings.saveSettings`)]})]})]})})}function Xe({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,V.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full range-slider`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function Ze({generationOptions:e,embeddingSettings:t,effectiveEmbeddingSettings:n,embeddingModelOptions:i,embeddingStatus:a,onGenerationOptionChange:o,onEmbeddingSettingsChange:s,onResetGenerationOptions:l,onSaveGenerationOptions:u,onResetEmbeddingSettings:d,onSaveEmbeddingSettings:p}){let{t:m}=r(),[g,_]=(0,B.useState)(!1),v=(0,B.useId)();return(0,V.jsx)(`div`,{className:`space-y-6`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.generation.title`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:m(`settings.generation.description`)}),(0,V.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":g,"aria-controls":v,onClick:()=>_(e=>!e),className:`flex w-full items-center justify-between gap-4 p-4 text-left`,children:[(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.generation.advancedSettings`)}),(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-gray-500 dark:text-gray-400`,children:m(`settings.generation.advancedSettingsDescription`)})]}),(0,V.jsx)(f,{className:F(`h-4 w-4 flex-shrink-0 text-gray-500 transition-transform`,g&&`rotate-180`)})]}),g&&(0,V.jsxs)(`div`,{id:v,className:`space-y-6 border-t border-gray-200 p-4 dark:border-dark-300`,children:[(0,V.jsxs)(Qe,{title:m(`settings.generation.coreParameters`),children:[(0,V.jsx)(U,{label:m(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:m(`settings.generation.temperatureDescription`),onChange:e=>o(`temperature`,e)}),(0,V.jsx)(U,{label:m(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:m(`settings.generation.topPDescription`),onChange:e=>o(`top_p`,e)}),(0,V.jsx)(U,{label:m(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:m(`settings.generation.topKDescription`),onChange:e=>o(`top_k`,e)}),(0,V.jsx)(U,{label:m(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:m(`settings.generation.minPDescription`),onChange:e=>o(`min_p`,e)})]}),(0,V.jsxs)(Qe,{title:m(`settings.generation.generationControl`),children:[(0,V.jsx)(U,{label:m(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:m(`settings.generation.maxTokensDescription`),onChange:e=>o(`num_predict`,e)}),(0,V.jsx)(U,{label:m(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:m(`settings.generation.repeatPenaltyDescription`),onChange:e=>o(`repeat_penalty`,e)}),(0,V.jsx)(U,{label:m(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:m(`settings.generation.contextLengthDescription`),onChange:e=>o(`num_ctx`,e)}),(0,V.jsx)(U,{label:m(`settings.generation.seed`),hint:`(${m(`settings.generation.optional`)})`,value:e.seed,placeholder:m(`settings.generation.random`),integer:!0,description:m(`settings.generation.seedDescription`),onChange:e=>o(`seed`,e)})]}),(0,V.jsxs)(Qe,{title:m(`settings.generation.advancedOptions`),children:[(0,V.jsx)(U,{label:m(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:m(`settings.generation.presencePenaltyDescription`),onChange:e=>o(`presence_penalty`,e)}),(0,V.jsx)(U,{label:m(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:m(`settings.generation.frequencyPenaltyDescription`),onChange:e=>o(`frequency_penalty`,e)}),(0,V.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[m(`settings.generation.stopSequences`),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,m(`settings.generation.commaSeparated`),`)`]})]}),(0,V.jsx)(`input`,{type:`text`,value:e.stop?.join(`, `)??``,onChange:e=>o(`stop`,e.target.value?e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,placeholder:`\\\\n, ###, STOP`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.generation.stopSequencesDescription`)})]})]}),(0,V.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,V.jsxs)(R,{onClick:l,variant:`outline`,className:`flex items-center gap-2`,children:[(0,V.jsx)(c,{size:16}),m(`settings.generation.resetDefaults`)]}),(0,V.jsxs)(R,{onClick:u,className:`flex items-center gap-2`,children:[(0,V.jsx)(h,{size:16}),m(`settings.generation.saveOptions`)]})]})]})]}),(0,V.jsx)(`div`,{className:`mt-6`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:m(`settings.generation.embeddingSettings`)}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:m(`settings.generation.enableEmbeddings`)}),(0,V.jsx)(H,{checked:t.enabled,onChange:e=>s(`enabled`,e)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.documents.embeddings.model`)}),(0,V.jsx)(z,{value:n.model,onChange:e=>s(`model`,e.target.value),options:i,disabled:!t.enabled})]}),(0,V.jsx)($e,{label:m(`settings.documents.embeddings.chunkSize`),hint:m(`settings.documents.embeddings.chunkSizeInTokens`),value:t.chunkSize,min:1,disabled:!t.enabled,onChange:e=>s(`chunkSize`,e)}),(0,V.jsx)($e,{label:m(`settings.documents.embeddings.chunkOverlap`),hint:m(`settings.documents.embeddings.chunkOverlapInTokens`),value:t.chunkOverlap,min:0,disabled:!t.enabled,onChange:e=>s(`chunkOverlap`,e)}),(0,V.jsx)($e,{label:m(`settings.documents.embeddings.similarityThreshold`),value:t.similarityThreshold,min:0,max:1,step:.01,disabled:!t.enabled,onChange:e=>s(`similarityThreshold`,e)})]}),a&&(0,V.jsxs)(`div`,{className:`mt-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,V.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[m(`settings.documents.embeddings.status`),`:`]}),(0,V.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:a.available?m(`settings.documents.embeddings.available`):m(`settings.documents.embeddings.unavailable`)})]}),a.available&&(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,V.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[m(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,V.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[a.chunksWithEmbeddings,` /`,` `,a.totalChunks]})]})]}),(0,V.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,V.jsxs)(R,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,V.jsx)(c,{size:16}),m(`settings.generation.resetDefaults`)]}),(0,V.jsxs)(R,{onClick:p,className:`flex items-center gap-2`,children:[(0,V.jsx)(h,{size:16}),m(`settings.saveSettings`)]})]})]})})]})})}function Qe({title:e,children:t}){return(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function U({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,V.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,V.jsx)(`input`,{type:`number`,min:a,max:o,step:s,value:t??``,placeholder:n,onChange:e=>l(e.target.value?c?parseInt(e.target.value):parseFloat(e.target.value):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function $e({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,V.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,V.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,disabled:o})]})}function et({loading:e,settings:t,effectiveSettings:n,models:i,plugins:a,sizes:o,qualities:s,styles:l,onSettingChange:u,onModelChange:d,onReset:f,onSave:p}){let{t:m}=r(),g=N(i,n.model,n.pluginId);return(0,V.jsx)(`div`,{className:`space-y-6`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.imageGen.title`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:m(`settings.imageGen.description`)}),e?(0,V.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,V.jsx)(O,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,V.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:m(`settings.imageGen.loadingProviders`)})]}):i.length===0?(0,V.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.jsx)(y,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:m(`settings.imageGen.noProviders`)}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:m(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.imageGen.enable`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.imageGen.enableDescription`)})]}),(0,V.jsx)(H,{checked:t.enabled,onChange:e=>u(`enabled`,e)})]})}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.imageGen.configuration`)}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.model`)}),(0,V.jsx)(z,{value:g?ye(g):``,onChange:e=>{let t=i.find(t=>ye(t)===e.target.value);t&&d(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:m(`settings.model.selectModel`)},...i.map(e=>({value:ye(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.modelDescription`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g?.config?.size_label||m(`settings.imageGen.size`)}),(0,V.jsx)(z,{value:n.size,onChange:e=>u(`size`,e.target.value),disabled:!t.enabled||o.length===0,options:[...o.length>0?o.map(e=>({value:e,label:e})):[{value:`1024x1024`,label:`1024x1024`},{value:`1792x1024`,label:`1792x1024`},{value:`1024x1792`,label:`1024x1792`}]]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.sizeDescription`)})]}),s.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.quality`)}),(0,V.jsx)(z,{value:n.quality,onChange:e=>u(`quality`,e.target.value),disabled:!t.enabled,options:s.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.qualityDescription`)})]}),l.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.style`)}),(0,V.jsx)(z,{value:n.style,onChange:e=>u(`style`,e.target.value),disabled:!t.enabled,options:l.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.styleDescription`)})]})]})]}),a.length>0&&(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:m(`settings.imageGen.availableProviders`)}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,V.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,m(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,V.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,V.jsxs)(R,{onClick:f,variant:`outline`,className:`flex items-center gap-2`,children:[(0,V.jsx)(c,{size:16}),m(`common.reset`)]}),(0,V.jsxs)(R,{onClick:p,className:`flex items-center gap-2`,children:[(0,V.jsx)(h,{size:16}),m(`settings.saveSettings`)]})]})]})]})})}function tt({models:e,selectedModel:t,selectedProviderType:n,selectedProviderId:i,systemMessage:a,tempSystemMessage:o,loading:s,preferences:c,currentVisionModel:l,visionModelOptions:u,currentTaskModel:d,autoTitleTaskModelOptions:f,updatingAllModels:p,updateProgress:m,onModelChange:h,onSystemMessageChange:g,onSystemMessageSave:_,onAutoTitleChange:v,onAutoTitleTaskModelChange:y,onVisionModelChange:b,onUpdateAllModels:x}){let{t:S}=r(),C={model:t,providerType:n,providerId:i},w=De(e,C),T=t?Te(w,C):``,E=we(w,C);return(0,V.jsx)(`div`,{className:`space-y-6`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:S(`settings.model.title`)}),(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.defaultModel`)}),(0,V.jsx)(z,{value:T,onChange:h,options:[{value:``,label:S(`settings.model.selectModel`)},...w.map(e=>({value:Se(e),label:e.isLegacySelection?`${e.name} (provider not recorded${e.isUnavailable?`, unavailable`:``})`:e.isPersona?`${e.personaName} (${S(`settings.model.persona`)})`:e.isPlugin?`${e.name} (${e.pluginName||e.pluginId}${e.isUnavailable?`, unavailable`:``})`:`${e.name} (Ollama${e.isUnavailable?`, unavailable`:``})`}))]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.defaultModelDescription`)})]}),t&&(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.currentModelInfo`)}),(0,V.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,V.jsx)(nt,{label:`${S(`settings.model.name`)}:`,value:t,truncate:!0}),E?.details&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(nt,{label:`${S(`settings.model.size`)}:`,value:E.details.parameter_size}),(0,V.jsx)(nt,{label:`${S(`settings.model.family`)}:`,value:E.details.family}),(0,V.jsx)(nt,{label:`${S(`settings.model.format`)}:`,value:E.details.format})]})]})})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.systemMessage.title`)}),(0,V.jsx)(ze,{value:o,onChange:g,placeholder:S(`settings.systemMessage.placeholder`),className:`w-full min-h-[100px] bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,rows:4}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:S(`settings.systemMessage.description`)}),(0,V.jsx)(R,{onClick:_,size:`sm`,disabled:s||o===a,children:S(`common.save`)})]})]})]}),(0,V.jsx)(`div`,{className:`mt-6`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.specializedModels`,{defaultValue:`Specialized Models`})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 lg:grid-cols-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.visionModel`,{defaultValue:`Vision Model`})}),(0,V.jsx)(z,{"data-testid":`vision-model-select`,value:l,onChange:e=>b(e.target.value),options:u}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.visionModelDescription`,{defaultValue:`Used automatically whenever the outgoing chat context contains images. Choose a model that supports image input.`})})]}),(0,V.jsxs)(`div`,{className:`lg:border-s lg:border-gray-200 lg:ps-5 dark:lg:border-dark-300`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:S(`settings.model.autoTitle.enable`)}),(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:S(`settings.model.autoTitle.enableDescription`)})]}),(0,V.jsx)(H,{checked:c.titleSettings?.autoTitle||!1,onChange:v})]}),c.titleSettings?.autoTitle&&(0,V.jsxs)(`div`,{className:`mt-4`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.autoTitle.taskModel`)}),(0,V.jsx)(z,{value:d,onChange:e=>y(e.target.value),options:f}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.autoTitle.taskModelDescription`)})]})]})]})]})}),(0,V.jsx)(`div`,{className:`mt-6`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.bulkOperations`)}),(0,V.jsx)(`div`,{className:`space-y-3`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.updateAll`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:S(`settings.model.updateAllDescription`)}),p&&m&&(0,V.jsx)(rt,{progress:m}),(0,V.jsx)(R,{onClick:x,variant:`outline`,size:`sm`,className:`w-full`,disabled:p||s||e.length===0,children:p?S(`settings.model.updating`):S(`settings.model.updateAllButton`,{count:e.length})})]})})]})})]})})}function nt({label:e,value:t,truncate:n=!1}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-white dark:bg-dark-100 rounded-md border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,V.jsx)(`span`,{className:n?`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ms-2`:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t})]})}function rt({progress:e}){let{t}=r(),n=Math.round(e.current/e.total*100);return(0,V.jsxs)(`div`,{className:`mb-4 space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,V.jsx)(`span`,{className:`text-gray-600 dark:text-dark-600 font-medium`,children:t(`settings.model.updatingModel`,{name:e.modelName,current:e.current,total:e.total})}),(0,V.jsxs)(`span`,{className:`text-primary-600 dark:text-primary-400 font-semibold`,children:[n,`%`]})]}),(0,V.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-3 shadow-subtle`,children:(0,V.jsx)(`div`,{className:`bg-gradient-to-r from-primary-500 to-primary-600 dark:from-primary-400 dark:to-primary-500 h-3 rounded-full transition-all duration-500 ease-out shadow-glow`,style:{width:`${e.current/e.total*100}%`}})}),(0,V.jsxs)(`div`,{className:`text-xs flex items-center justify-between`,children:[(0,V.jsxs)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:[t(`settings.model.status`),`:`,` `,e.status===`starting`?(0,V.jsx)(`span`,{className:`text-accent-500 dark:text-accent-400`,children:t(`settings.model.statusStarting`)}):e.status===`success`?(0,V.jsx)(`span`,{className:`text-success-600 dark:text-success-500`,children:t(`settings.model.statusComplete`)}):e.status===`error`?(0,V.jsxs)(`span`,{className:`text-error-600 dark:text-error-500`,children:[t(`settings.model.statusError`),`: `,e.error]}):``]}),(0,V.jsx)(`span`,{className:`text-gray-400 dark:text-dark-600 text-[10px]`,children:t(`settings.model.modelsProgress`,{current:e.current,total:e.total})})]})]})}var it=8;function at(e,t){let n=e.trim();if(!n)return null;let r;try{r=new URL(n)}catch{return`invalid-url`}return r.protocol!==`http:`&&r.protocol!==`https:`?`insecure-url`:t?.toLowerCase().endsWith(`base_url`)&&(r.search||r.hash)?`query-or-fragment`:null}function ot(e){try{return new URL(e.trim()).protocol===`http:`}catch{return!1}}function st(e){let t=e.toLowerCase();return t===`endpoint`||t===`base_url`||t===`api_url`||t===`models_endpoint`||t.endsWith(`_endpoint`)||t.endsWith(`_base_url`)}function ct(e){let t=e.trim();if(!t.startsWith(`/`)||t.startsWith(`//`)||t.includes(`://`)||t.includes(`\\`)||t.includes(`?`)||t.includes(`#`))return!1;let n=t;for(let e=0;e<=it;e+=1){let t;try{t=decodeURIComponent(n)}catch{return!1}if(t===n)return!n.includes(`\\`)&&!n.includes(`?`)&&!n.includes(`#`)&&!n.split(`/`).some(e=>e===`.`||e===`..`);if(e===it)return!1;n=t}return!1}var lt=new Set([`api_mode`,`api_path`,`endpoint`,`base_url`,`api_url`,`image_endpoint`,`embedding_endpoint`,`tts_endpoint`,`model`,`model_id`,`models_endpoint`]);function ut(e){let t=new Set(lt),n=e?.capabilities;for(let e of Object.values(n||{})){let n=e?.config?.endpoint_variable??e?.endpoint_variable;typeof n==`string`&&n.trim()&&t.add(n)}return t}function dt(e,t){return ut(t).has(e)}function W(e,t){if(e.default!==void 0)return e.default;if(!t)return;if(e.name===`endpoint`||e.name===`api_url`)return t.endpoint||void 0;if(e.name===`base_url`)return t.base_url;if(e.name===`api_path`)return t.api_path;if(e.name===`api_mode`){if(t.api_mode)return t.api_mode;try{return new URL(t.endpoint).pathname.replace(/\/+$/,``).endsWith(`/responses`)?`responses`:`chat_completions`}catch{return`chat_completions`}}let n=t.capabilities;for(let t of Object.values(n||{}))if((t?.config?.endpoint_variable??t?.endpoint_variable)===e.name&&typeof t.endpoint==`string`)return t.endpoint}function ft(e,t){let n=[],r=[];for(let i of e)(dt(i.name,t)?n:r).push(i);return{connection:n,advanced:r}}function pt(e,t){let n={};for(let r of e){let e=t[r.name];n[r.name]=e?.has_value&&!e.is_sensitive?e.value:``}return n}function mt(e,t,n,r,i){let a=new Set(e.map(e=>e.name)),o={},s=[];for(let c of n){if(!a.has(c))continue;let n=e.find(e=>e.name===c);if(!n)continue;let l=t[c],u=r[c],d=typeof l==`string`&&l.trim().length===0,f=W(n,i),p=f!==void 0&&(typeof l==`string`&&typeof f==`string`?l.trim()===f.trim():Object.is(l,f));if(d||p){if(n.sensitive&&u?.has_value)continue;u?.has_value&&s.push(c);continue}o[c]=l}return{variables:o,unset:s}}ce(`components:hugging-face-model-browser`);var ht=({plugin:e})=>{let{t}=r(),n=L(e=>e.user),i=L(e=>e.systemInfo)?.requiresAuth===!1||n?.role===`admin`,{pluginVariables:a,fetchPluginVariables:o,updatePluginVariables:s,resetPluginVariables:l,loadPlugins:u}=xe(),[d,p]=(0,B.useState)({}),[m,h]=(0,B.useState)(!1),[g,v]=(0,B.useState)(!1),[y,x]=(0,B.useState)(new Set),[S,C]=(0,B.useState)({}),[w,T]=(0,B.useState)(new Set),[E,ee]=(0,B.useState)(!1),te=B.useId(),ne=B.useId(),O=(0,B.useMemo)(()=>e.variables||[],[e.variables]),k=(0,B.useMemo)(()=>ut(e),[e]),A=(0,B.useMemo)(()=>i?O:O.filter(e=>!k.has(e.name)),[i,k,O]),re=(0,B.useMemo)(()=>a[e.id]||{},[a,e.id]),j=(0,B.useMemo)(()=>ft(A,e),[e,A]);(0,B.useEffect)(()=>{o(e.id)},[o,e.id]);let ae=JSON.stringify(re),oe=(0,B.useRef)(null);(0,B.useEffect)(()=>{let t=A.map(e=>`${e.name}:${e.type}`).join(`|`),n=`${e.id}:${t}:${ae}`;if(oe.current===n)return;oe.current=n;let r=JSON.parse(ae);p(e=>{let t=pt(A,r);for(let n of w)n in e&&(t[n]=e[n]);return t})},[w,e.id,A,ae]);let ce=async()=>{let n={};for(let r of A){if(!w.has(r.name))continue;let i=d[r.name],a=typeof i==`string`&&i.trim().length===0,o=re[r.name],s=W(r,e);if(a&&r.required&&s===void 0&&!(r.sensitive&&o?.has_value)){n[r.name]=t(`pluginManager.variables.required`,`A value is required`);continue}if(st(r.name)&&typeof i==`string`&&!a){let e=at(i,r.name);e===`invalid-url`?n[r.name]=t(`pluginManager.variables.invalidUrl`,`Enter a valid full API endpoint URL, for example https://provider.example/v1/chat/completions`):e===`insecure-url`?n[r.name]=t(`pluginManager.variables.insecureUrl`,`API endpoints must use HTTP or HTTPS.`):e===`query-or-fragment`&&(n[r.name]=t(`pluginManager.variables.invalidBaseUrl`,`Base URLs cannot contain a query string or fragment.`))}if(r.name===`api_path`&&typeof i==`string`&&i.length>0&&!ct(i)&&(n[r.name]=t(`pluginManager.variables.invalidApiPath`,`Must start with / and contain no URL, query, fragment, or .. segment`)),r.type===`number`&&!a){let e=Number(i);r.min!==void 0&&e<r.min&&(n[r.name]=`Min: ${r.min}`),r.max!==void 0&&e>r.max&&(n[r.name]=`Max: ${r.max}`)}r.type===`string`&&typeof i==`string`&&i.length>2048&&(n[r.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(C(n),Object.keys(n).length>0)return;let r=mt(A,d,w,re,e),i=new Set(w),a=Object.fromEntries([...Object.keys(r.variables).map(e=>[e,!0]),...r.unset.map(e=>[e,!0])]);if(Object.keys(r.variables).length===0&&r.unset.length===0){T(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),C(e=>{let t={...e};for(let e of i)delete t[e];return t}),D.success(t(`pluginManager.variables.saved`,`Variables saved`));return}h(!0);try{await s(e.id,r.variables,r.unset)?(Object.keys(a).some(e=>k.has(e))&&await u(),p(e=>{let t={...e};for(let e of A)e.sensitive&&i.has(e.name)&&(t[e.name]=``);return t}),x(e=>{let t=new Set(e);for(let e of A)e.sensitive&&i.has(e.name)&&t.delete(e.name);return t}),T(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),C(e=>{let t={...e};for(let e of i)delete t[e];return t}),D.success(t(`pluginManager.variables.saved`,`Variables saved`))):D.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))}finally{h(!1)}},M=async()=>{v(!0);try{if(!await l(e.id)){D.error(t(`pluginManager.variables.resetFailed`,`Failed to reset variables`));return}A.some(e=>k.has(e.name))&&await u(),p(pt(A,{})),T(new Set),C({}),x(new Set),D.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))}finally{v(!1)}},le=(e,t)=>{p(n=>({...n,[e]:t})),T(t=>new Set(t).add(e)),C(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},ue=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},de=e=>{let t=`${ne}-${A.indexOf(e)}`;return{controlId:t,descriptionId:`${t}-description`,errorId:`${t}-error`,warningId:`${t}-http-warning`}},N=t=>{if(!st(t.name))return!1;let n=d[t.name],r=W(t,e),i=typeof n==`string`&&n.trim()?n:r;return typeof i==`string`&&ot(i)},fe=n=>{let r=d[n.name],i=n.sensitive??!1,a=y.has(n.name),o=re[n.name],{controlId:s,descriptionId:c,errorId:l,warningId:u}=de(n),f=!!S[n.name],p=N(n),h=n.name===`endpoint`||n.name===`api_url`,_=[n.description||h?c:void 0,p?u:void 0,f?l:void 0].filter(Boolean).join(` `)||void 0,v=W(n,e),b=v===void 0?t(`pluginManager.variables.inherited`,`Use provider default`):t(`pluginManager.variables.inheritedValue`,{defaultValue:`Use provider default ({{value}})`,value:String(v)}),x=F(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-white dark:bg-dark-100`,`border-gray-300 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-blue-500/20`);switch(n.type){case`boolean`:return(0,V.jsxs)(`select`,{id:s,value:r===``?``:String(!!r),onChange:e=>le(n.name,e.target.value===``?``:e.target.value===`true`),className:x,"aria-invalid":f,"aria-describedby":_,disabled:m||g,children:[(0,V.jsx)(`option`,{value:``,children:b}),(0,V.jsx)(`option`,{value:`true`,children:t(`pluginManager.variables.enabled`,`Enabled`)}),(0,V.jsx)(`option`,{value:`false`,children:t(`pluginManager.variables.disabled`,`Disabled`)})]});case`select`:return(0,V.jsxs)(`select`,{id:s,value:String(r??``),onChange:e=>le(n.name,e.target.value),className:x,"aria-invalid":f,"aria-describedby":_,disabled:m||g,children:[(0,V.jsx)(`option`,{value:``,children:b}),(n.options||[]).map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]});case`number`:return(0,V.jsx)(`input`,{id:s,type:`number`,value:r===``?``:Number(r),min:n.min,max:n.max,placeholder:b,onChange:e=>le(n.name,e.target.value===``?``:Number(e.target.value)),className:x,"aria-invalid":f,"aria-describedby":_,disabled:m||g});default:return(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(`input`,{id:s,type:i&&!a?`password`:`text`,value:i&&o?.has_value&&r===``?``:String(r??``),placeholder:i&&o?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):b,onChange:e=>le(n.name,e.target.value),className:F(x,i&&`pr-10`),"aria-invalid":f,"aria-describedby":_,disabled:m||g}),i&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>ue(n.name),"aria-controls":s,"aria-label":a?t(`pluginManager.variables.hideValue`,{defaultValue:`Hide {{label}} value`,label:n.label}):t(`pluginManager.variables.showValue`,{defaultValue:`Show {{label}} value`,label:n.label}),disabled:m||g,className:`absolute end-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:text-gray-300`,children:a?(0,V.jsx)(ie,{className:`w-4 h-4`}):(0,V.jsx)(se,{className:`w-4 h-4`})})]})}},P=e=>{let{controlId:n,descriptionId:r,errorId:i,warningId:a}=de(e),o=e.name===`endpoint`||e.name===`api_url`,s=N(e);return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{htmlFor:n,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[o?t(`pluginManager.variables.fullApiEndpoint`,`Full API endpoint URL`):e.label,e.required&&(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`text-red-500 ml-1`,children:`*`})]}),(e.description||o)&&(0,V.jsxs)(`p`,{id:r,className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:[e.description,e.description&&o&&` `,o&&t(`pluginManager.variables.endpointHelp`,`Enter the complete request URL, including its operation path (for example, /v1/chat/completions), not only the provider base URL.`)]}),fe(e),s&&(0,V.jsxs)(`p`,{id:a,role:`status`,className:`mt-1 flex items-start gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,V.jsx)(b,{"aria-hidden":`true`,className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,V.jsx)(`span`,{children:t(`pluginManager.variables.httpWarning`,`HTTP does not encrypt credentials or traffic. Use it only on a trusted network.`)})]}),S[e.name]&&(0,V.jsx)(`p`,{id:i,role:`alert`,className:`text-xs text-red-500 mt-1`,children:S[e.name]})]},e.name)};return(0,V.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[j.connection.length>0&&(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:t(`pluginManager.variables.connection`,`Connection`)}),j.connection.map(P)]}),j.advanced.length>0&&(0,V.jsxs)(`div`,{className:F(j.connection.length>0&&`mt-4 border-t pt-4`,`border-gray-200 dark:border-gray-700`),children:[(0,V.jsxs)(`button`,{type:`button`,"aria-expanded":E,"aria-controls":te,onClick:()=>ee(e=>!e),className:`flex w-full items-center justify-between rounded-md py-1 text-left text-sm font-medium text-gray-700 hover:text-gray-950 dark:text-gray-300 dark:hover:text-white`,children:[(0,V.jsxs)(`span`,{children:[t(`pluginManager.variables.advanced`,`Advanced parameters`),` (`,j.advanced.length,`)`]}),(0,V.jsx)(f,{className:F(`h-4 w-4 transition-transform`,E&&`rotate-180`)})]}),E&&(0,V.jsx)(`div`,{id:te,className:`mt-3 space-y-3`,children:j.advanced.map(P)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,V.jsxs)(R,{size:`sm`,onClick:ce,disabled:m||g||w.size===0,className:`gap-1.5`,children:[(0,V.jsx)(_,{className:`w-3.5 h-3.5`}),m?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,V.jsxs)(R,{variant:`outline`,size:`sm`,onClick:M,disabled:m||g,className:`gap-1.5`,children:[(0,V.jsx)(c,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function gt({plugins:e,loading:t,uploading:n,error:i,hasKeys:a,showUploadForm:o,showJsonForm:s,jsonInput:c,fileInputRef:l,expandedPluginId:u,pluginApiKeys:d,showApiKey:f,savingApiKey:m,refreshingPluginIds:h,onClearError:g,onShowUploadFormChange:_,onShowJsonFormChange:v,onJsonInputChange:y,onFileUpload:b,onJsonSubmit:x,onExpandedPluginChange:S,onPluginApiKeyChange:C,onShowApiKeyChange:w,onActivatePlugin:T,onDeletePlugin:E,onExportPlugin:ee,onSaveApiKey:ne,onDeleteApiKey:D,onRefreshModels:k}){let{t:A}=r(),re=L(e=>e.user),ie=L(e=>e.systemInfo)?.requiresAuth===!1||re?.role===`admin`,[oe,se]=(0,B.useState)(``),[ce,M]=(0,B.useState)(null),le=(0,B.useId)(),ue=(0,B.useMemo)(()=>e.filter(e=>Oe(e,oe)),[e,oe]),de=ce&&e.some(e=>e.id===ce)?ce:e[0]?.id??null,N=e.find(e=>e.id===de)??null,fe=e=>{e!==de&&(S(null),M(e))};return(0,V.jsx)(`div`,{className:`space-y-6`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:A(`settings.plugins.providerConnections`,{defaultValue:`Provider connections`})}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:A(`settings.plugins.providerConnectionsDescription`,{defaultValue:`Connect, configure, and inspect model providers through plugins.`})})]}),i&&(0,V.jsx)(`div`,{className:`p-4 bg-primary-50/80 dark:bg-primary-950/25 border border-primary-200 dark:border-primary-800/50 rounded-lg mb-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:i}),(0,V.jsx)(R,{variant:`ghost`,size:`sm`,onClick:g,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,V.jsx)(te,{className:`h-4 w-4`})})]})}),ie&&(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:A(`settings.plugins.addNew`)}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,V.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>_(!o),disabled:t||n,children:[(0,V.jsx)(j,{className:`h-4 w-4 me-2`}),A(`settings.plugins.upload`)]}),(0,V.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>v(!s),disabled:t,children:A(`settings.plugins.addJson`)})]})]}),o&&(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,V.jsx)(`input`,{ref:l,type:`file`,accept:`.json,.zip`,onChange:b,className:`flex-1 p-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 file:me-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 dark:file:bg-dark-200 dark:file:text-dark-700 hover:file:bg-gray-200 dark:hover:file:bg-dark-300`,disabled:n}),(0,V.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>_(!1),disabled:n,children:A(`common.cancel`)})]}),n&&(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:A(`settings.plugins.uploading`)})]}),s&&(0,V.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(`textarea`,{value:c,onChange:e=>y(e.target.value),placeholder:A(`settings.plugins.jsonPlaceholder`),className:`w-full h-32 p-3 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500 font-mono text-sm`,disabled:t}),(0,V.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,V.jsx)(R,{variant:`outline`,size:`sm`,onClick:()=>{v(!1),y(``)},children:A(`common.cancel`)}),(0,V.jsx)(R,{size:`sm`,onClick:x,disabled:!c.trim()||t,children:A(`settings.plugins.install`)})]})]})})]}),(0,V.jsx)(`div`,{"data-testid":`provider-workspace`,className:`overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:(0,V.jsxs)(`div`,{className:`grid min-h-[30rem] grid-cols-1 lg:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.6fr)]`,children:[(0,V.jsxs)(`section`,{"data-testid":`provider-list`,"aria-label":A(`settings.plugins.providers`,{defaultValue:`Providers`}),className:`border-b border-gray-200 dark:border-dark-300 lg:border-b-0 lg:border-e`,children:[(0,V.jsxs)(`div`,{className:`border-b border-gray-200 p-4 dark:border-dark-300`,children:[(0,V.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:A(`settings.plugins.providers`,{defaultValue:`Providers`})}),(0,V.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600 dark:bg-dark-200 dark:text-gray-300`,children:e.length})]}),(0,V.jsx)(`label`,{htmlFor:le,className:`sr-only`,children:A(`settings.plugins.searchProviders`,{defaultValue:`Search providers`})}),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(ae,{"aria-hidden":`true`,className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,V.jsx)(`input`,{id:le,type:`search`,value:oe,onChange:e=>se(e.target.value),placeholder:A(`settings.plugins.searchProviders`,{defaultValue:`Search providers`}),className:`w-full rounded-lg border border-gray-300 bg-white py-2 pe-3 ps-9 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]})]}),(0,V.jsx)(`div`,{className:`max-h-[32rem] space-y-2 overflow-y-auto p-3`,children:t&&e.length===0?(0,V.jsxs)(`div`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:[(0,V.jsx)(O,{className:`mx-auto mb-2 h-5 w-5 animate-spin`}),A(`settings.plugins.loading`)]}):e.length===0?(0,V.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,V.jsx)(p,{className:`mx-auto mb-3 h-9 w-9 text-gray-400`}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:A(`settings.plugins.noPlugins`)}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-gray-500`,children:A(`settings.plugins.noPluginsDescription`)})]}):ue.length===0?(0,V.jsx)(`p`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:A(`settings.plugins.noProvidersFound`,{defaultValue:`No providers match your search.`})}):ue.map(e=>{let t=de===e.id,n=be(e).length;return(0,V.jsx)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>fe(e.id),className:`w-full rounded-xl border p-3 text-start transition-colors ${t?`border-blue-500 bg-blue-50/70 dark:border-blue-500 dark:bg-blue-950/20`:`border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:hover:border-dark-400 dark:hover:bg-dark-50`}`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`span`,{className:`sr-only`,children:[e.active?A(`settings.plugins.activeLabel`):A(`settings.plugins.inactive`),`.`,` `]}),(0,V.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,V.jsxs)(`span`,{className:`mt-0.5 block text-xs capitalize text-gray-500 dark:text-gray-400`,children:[e.type,` · `,n,` `,A(`settings.plugins.models`)]})]})]})},e.id)})})]}),(0,V.jsx)(`section`,{"data-testid":`provider-detail`,className:`min-w-0 p-4 sm:p-5`,children:N?(0,V.jsx)(G,{plugin:N,loading:t,hasApiKey:a[N.id]||!1,expanded:u===N.id,apiKey:d[N.id]||``,showApiKey:f[N.id]||!1,savingApiKey:m===N.id,refreshingModels:!!h[N.id],canManagePlugin:ie,onExpand:()=>S(u===N.id?null:N.id),onActivate:()=>T(N.id),onExport:()=>ee(N.id),onDelete:()=>E(N.id),onRefreshModels:()=>k(N.id),onApiKeyChange:e=>C(N.id,e),onShowApiKeyChange:e=>w(N.id,e),onSaveApiKey:()=>ne(N.id),onDeleteApiKey:()=>D(N.id)}):(0,V.jsx)(`div`,{className:`flex min-h-[24rem] items-center justify-center text-center`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(p,{className:`mx-auto mb-3 h-10 w-10 text-gray-400`}),(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:A(`settings.plugins.selectProvider`,{defaultValue:`Select a provider`})}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:A(`settings.plugins.selectProviderDescription`,{defaultValue:`Choose a provider to inspect its connection and model catalog.`})})]})})})]})})]})})}function G({plugin:e,loading:t,hasApiKey:n,expanded:i,apiKey:o,showApiKey:s,savingApiKey:c,refreshingModels:l,canManagePlugin:d,onExpand:p,onActivate:m,onExport:g,onDelete:_,onRefreshModels:v,onApiKeyChange:y,onShowApiKeyChange:b,onSaveApiKey:x,onDeleteApiKey:S}){let{t:C}=r(),w=!!(e.auth?.header||e.auth?.key_env),E=ut(e),ee=d?e.variables||[]:(e.variables||[]).filter(e=>!E.has(e.name)),te=ee.length>0,ne=w||te,D=(0,B.useId)(),O=be(e),k=e.base_url||e.endpoint;return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-gray-200 pb-4 dark:border-dark-300`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,V.jsx)(`h4`,{className:`truncate text-lg font-semibold text-gray-900 dark:text-gray-100`,children:e.name})]}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e.id,` · `,(0,V.jsx)(`span`,{className:`capitalize`,children:e.type}),w&&n&&(0,V.jsxs)(`span`,{className:`text-green-600`,children:[` `,`· `,C(`settings.plugins.apiKeySet`)]})]})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[ne&&(0,V.jsxs)(R,{variant:`outline`,size:`sm`,onClick:p,"aria-expanded":i,"aria-controls":D,title:C(`settings.plugins.configure`),className:n?`text-green-600`:``,children:[w?(0,V.jsx)(u,{className:`h-4 w-4`}):(0,V.jsx)(A,{className:`h-4 w-4`}),C(`settings.plugins.configure`),i?(0,V.jsx)(a,{className:`h-3 w-3`}):(0,V.jsx)(f,{className:`h-3 w-3`})]}),(0,V.jsx)(R,{variant:`outline`,size:`sm`,onClick:m,disabled:t,className:e.active?`border-green-300 text-green-600`:``,children:e.active?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(h,{className:`h-4 w-4`}),C(`settings.plugins.deactivate`)]}):C(`settings.plugins.activate`)}),d&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(R,{variant:`ghost`,size:`sm`,onClick:g,disabled:t,title:C(`settings.plugins.exportPlugin`,`Export plugin`),className:`px-2`,children:(0,V.jsx)(oe,{className:`h-4 w-4`})}),(0,V.jsx)(R,{variant:`ghost`,size:`sm`,onClick:_,disabled:t,className:`px-2 text-red-600 hover:bg-red-50 hover:text-red-700`,title:C(`settings.plugins.deletePlugin`,`Delete plugin`),children:(0,V.jsx)(T,{className:`h-4 w-4`})})]})]})]}),(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,V.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:C(`settings.plugins.status`,{defaultValue:`Status`})}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:e.active?C(`settings.plugins.activeLabel`):C(`settings.plugins.inactive`)})]}),(0,V.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:C(`settings.plugins.models`)}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:O.length})]}),(0,V.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:C(`settings.plugins.defaultEndpoint`,{defaultValue:`Default endpoint`})}),(0,V.jsx)(`p`,{className:`mt-1 truncate text-sm text-gray-900 dark:text-gray-100`,title:k,children:k})]})]})]}),i&&ne&&(0,V.jsxs)(`div`,{id:D,children:[w&&(0,V.jsx)(vt,{plugin:e,hasApiKey:n,apiKey:o,showApiKey:s,savingApiKey:c,onApiKeyChange:y,onShowApiKeyChange:b,onSaveApiKey:x,onDeleteApiKey:S}),te&&(0,V.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-dark-300 dark:bg-dark-50`,children:[(0,V.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,V.jsx)(A,{className:`h-4 w-4 text-gray-500`}),(0,V.jsxs)(`h5`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[C(`settings.plugins.providerSettings`),` (`,ee.length,`)`]})]}),(0,V.jsx)(ht,{plugin:e},e.id)]})]}),(0,V.jsx)(_t,{catalog:O,canRefresh:I(e),refreshing:l,onRefresh:v})]})}function _t({catalog:e,canRefresh:t,refreshing:n,onRefresh:i}){let{t:a}=r();return(0,V.jsxs)(`section`,{"data-testid":`provider-model-catalog`,className:`mt-5`,children:[(0,V.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h5`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:a(`settings.plugins.modelCatalog`,{defaultValue:`Model catalog`})}),(0,V.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:a(`settings.plugins.modelCatalogDescription`,{defaultValue:`Discovered and configured models for this provider and its capabilities.`})})]}),t&&(0,V.jsxs)(R,{variant:`outline`,size:`sm`,onClick:i,disabled:n,"aria-busy":n,children:[n?(0,V.jsx)(O,{className:`h-4 w-4 animate-spin`}):(0,V.jsx)(s,{className:`h-4 w-4`}),a(`settings.plugins.refreshModels`,{defaultValue:`Refresh models`})]})]}),e.length===0?(0,V.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-dark-300 dark:text-gray-400`,children:a(`settings.plugins.noModelsConfigured`,{defaultValue:`No models are configured for this provider.`})}):(0,V.jsx)(`div`,{className:`max-h-[26rem] overflow-auto rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,V.jsxs)(`table`,{className:`w-full min-w-[24rem] text-start text-sm`,children:[(0,V.jsx)(`thead`,{className:`sticky top-0 z-10 bg-gray-50 text-xs uppercase tracking-wide text-gray-500 dark:bg-dark-50 dark:text-gray-400`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:a(`settings.plugins.modelId`,{defaultValue:`Model ID`})}),(0,V.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:a(`settings.plugins.capabilities`,{defaultValue:`Capabilities`})})]})}),(0,V.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-xs text-gray-900 dark:text-gray-100`,children:e.id}),(0,V.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,V.jsx)(`span`,{className:`rounded-md bg-blue-50 px-2 py-0.5 text-xs text-blue-700 dark:bg-blue-950/30 dark:text-blue-300`,children:a(`settings.plugins.capability.${e.toLowerCase()}`,{defaultValue:e})},e))})})]},e.id))})]})})]})}function vt({plugin:e,hasApiKey:t,apiKey:n,showApiKey:i,savingApiKey:a,onApiKeyChange:o,onShowApiKeyChange:s,onSaveApiKey:c,onDeleteApiKey:l}){let{t:d}=r(),f=(0,B.useId)();return(0,V.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,V.jsx)(u,{className:`h-4 w-4 text-gray-500`}),(0,V.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:d(`settings.plugins.apiKeyConfiguration`)})]}),(0,V.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[d(`settings.plugins.apiKeyDescription`,{name:e.name,defaultValue:`Store a personal API key for {{name}}.`}),e.auth?.key_env&&(0,V.jsxs)(`span`,{className:`block mt-1`,children:[d(`settings.plugins.apiKeyEnvAlternative`),` `,(0,V.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,d(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(h,{className:`h-4 w-4 text-green-600`}),(0,V.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:d(`settings.plugins.apiKeyConfigured`)})]}),(0,V.jsx)(R,{variant:`outline`,size:`sm`,onClick:l,disabled:a,className:`text-red-600 border-red-300 hover:bg-red-50`,children:a?(0,V.jsx)(O,{className:`h-4 w-4 animate-spin`}):d(`common.remove`)})]}):(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(`label`,{htmlFor:f,className:`sr-only`,children:d(`settings.plugins.apiKey.title`)}),(0,V.jsx)(`input`,{id:f,type:i?`text`:`password`,value:n,onChange:e=>o(e.target.value),placeholder:d(`settings.plugins.apiKeyPlaceholder`),disabled:a,className:`w-full p-2 pe-10 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>s(!i),"aria-controls":f,"aria-label":d(i?`settings.plugins.hideApiKey`:`settings.plugins.showApiKey`),disabled:a,className:`absolute end-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50`,children:i?(0,V.jsx)(ie,{className:`h-4 w-4`}):(0,V.jsx)(se,{className:`h-4 w-4`})})]}),(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsx)(R,{size:`sm`,onClick:c,disabled:a||!n.trim(),children:a?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(O,{className:`h-4 w-4 me-2 animate-spin`}),d(`common.saving`)]}):d(`settings.plugins.saveApiKey`)})})]})]})}function yt({loading:e,settings:t,effectiveSettings:n,models:a,plugins:o,voices:s,testing:l,onSettingChange:u,onModelChange:d,onReset:f,onTest:p,onSave:m}){let{t:g}=r(),_=a.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,V.jsx)(`div`,{className:`space-y-6`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:g(`settings.tts.title`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:g(`settings.tts.description`)}),e?(0,V.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,V.jsx)(O,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,V.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:g(`settings.tts.loadingProviders`)})]}):a.length===0?(0,V.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.jsx)(C,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:g(`settings.tts.noProviders`)}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:g(`settings.tts.noProvidersDescription`)})]})]})}):(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.tts.enable`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:g(`settings.tts.enableDescription`)})]}),(0,V.jsx)(H,{checked:t.enabled,onChange:e=>u(`enabled`,e)})]})}),(0,V.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.tts.autoPlay`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:g(`settings.tts.autoPlayDescription`)})]}),(0,V.jsx)(H,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>u(`autoPlay`,e)})]})}),(0,V.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.tts.streamSentences`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:g(`settings.tts.streamSentencesDescription`)})]}),(0,V.jsx)(H,{checked:t.streamSentences||!1,disabled:!t.enabled,onChange:e=>u(`streamSentences`,e)})]})}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:g(`settings.tts.voiceConfiguration`)}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.tts.model`)}),(0,V.jsx)(z,{"aria-label":g(`settings.tts.model`),value:_?ve(_):``,onChange:e=>{let t=a.find(t=>ve(t)===e.target.value);t&&d(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:g(`settings.model.selectModel`)},...a.map(e=>({value:ve(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.tts.modelDescription`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.tts.voice`)}),(0,V.jsx)(z,{"aria-label":g(`settings.tts.voice`),value:n.voice,onChange:e=>u(`voice`,e.target.value),disabled:!t.enabled||s.length===0,options:[{value:``,label:g(`settings.tts.selectVoice`)},...s.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.tts.voiceDescription`)})]})]})]}),o.length>0&&(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:g(`settings.tts.availableProviders`)}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:o.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,V.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,V.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,g(`settings.tts.models`),`)`]})]},e.id))})]}),(0,V.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(R,{onClick:f,variant:`outline`,className:`flex items-center gap-2`,children:[(0,V.jsx)(c,{size:16}),g(`common.reset`)]}),(0,V.jsx)(R,{onClick:p,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:l?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(S,{size:16}),g(`settings.tts.stop`)]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(i,{size:16}),g(`settings.tts.test`)]})})]}),(0,V.jsxs)(R,{onClick:m,className:`flex items-center gap-2`,children:[(0,V.jsx)(h,{size:16}),g(`settings.saveSettings`)]})]})]})]})})}function bt({preferences:e,sessions:t,loadPreferences:n,loadSessions:r}){let[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(`skip`),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(null),m=(0,B.useRef)(null),h=()=>{p(null),m.current&&(m.current.value=``)};return{importing:i,showImportOptions:o,mergeStrategy:c,setMergeStrategy:l,importResult:u,setImportResult:d,importFileInputRef:m,handleExportData:()=>{let n={format:`libre-webui-export`,version:`1.0`,preferences:e,sessions:t,documents:[],exportedAt:new Date().toISOString()},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`libre-webui-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),D.success(`Data exported successfully`)},handleImportFileSelect:e=>{let t=e.target.files?.[0];t&&(p(t),s(!0),d(null))},handleConfirmImport:async()=>{if(f){a(!0);try{let e=await f.text(),t=JSON.parse(e);if(!t.format||t.format!==`libre-webui-export`)throw Error(`Invalid export format. Please use a valid Libre WebUI export file.`);let i=await P.importData(t,c===`overwrite`?`replace`:`merge`);if(i.success&&i.data)d({preferences:{imported:!0,error:null},sessions:{imported:0,skipped:0,errors:[]},documents:{imported:0,skipped:0,errors:[]}}),D.success(`Data imported successfully`),await n(),await r();else throw Error(i.error||`Import failed`)}catch(e){D.error(e instanceof Error?e.message:`Import failed`),d(null)}finally{a(!1),s(!1),h()}}},handleCancelImport:()=>{s(!1),d(null),h()}}}var xt=`0.18.0`,St=`__current_running_model__`,Ct={enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},wt={enabled:!1,autoPlay:!1,model:``,voice:``,speed:1,pluginId:``,streamSentences:!1},Tt={enabled:!1,model:``,size:`1024x1024`,quality:`standard`,style:`vivid`,pluginId:``},Et=({isOpen:e,onClose:t})=>{let{models:n,selectedModel:i,selectedProviderType:a,selectedProviderId:o,setSelectedModel:s,systemMessage:c,setSystemMessage:u,clearAllSessions:d,loading:f,sessions:h,loadModels:_,loadSessions:v}=Ee(),{theme:b,updateTheme:S,preferences:w,setPreferences:T,loadPreferences:E}=Ne(),{plugins:ee,isLoading:ne,isUploading:O,error:k,loadPlugins:j,uploadPlugin:ie,deletePlugin:ae,activatePlugin:oe,deactivatePlugin:se,exportPlugin:ce,clearError:ve,installPlugin:ye}=xe(),{t:I}=r(),be=B.useId(),we=De(n,{model:i,providerType:a,providerId:o}),L={model:w.titleSettings?.taskModel||``,providerType:w.titleSettings?.taskProviderType,providerId:w.titleSettings?.taskProviderId},Oe=De(n,L),Ae=L.model===St?St:L.model?Te(Oe,L):``,je={model:w.visionModel||``,providerType:w.visionProviderType,providerId:w.visionProviderId},Pe=De(n,je),Le=je.model?Te(Pe,je):``,Re=[{value:``,label:I(`settings.model.selectVisionModel`,{defaultValue:`Use the current chat model`})},...Pe.map(e=>({value:Se(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:e.isAgent?`${e.name} · ${e.agentName||`Agent`}${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],ze=[{value:``,label:I(`settings.model.autoTitle.selectTaskModel`)},{value:St,label:`Use current running model`},...Oe.map(e=>({value:Se(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],[Be,z]=(0,B.useState)(`appearance`),[Ve,He]=(0,B.useState)(c),[We,Ge]=(0,B.useState)(!1),[Ke,H]=(0,B.useState)(null),[Xe,Qe]=(0,B.useState)(!1),[U,$e]=(0,B.useState)(!1),[nt,rt]=(0,B.useState)(``),it=(0,B.useRef)(null),[at,ot]=(0,B.useState)(null),[st,ct]=(0,B.useState)({}),[lt,ut]=(0,B.useState)({}),[dt,W]=(0,B.useState)(null),[ft,pt]=(0,B.useState)({}),[mt,ht]=(0,B.useState)(w.generationOptions||{}),[G,_t]=(0,B.useState)(w.embeddingSettings||Ct),[vt,Et]=(0,B.useState)(!1),[K,Dt]=(0,B.useState)(w.ttsSettings||wt),[Ot,kt]=(0,B.useState)(!1),At=(0,B.useRef)(null),[q,jt]=(0,B.useState)(w.imageGenSettings||Tt),{importing:Mt,showImportOptions:Nt,mergeStrategy:Pt,setMergeStrategy:Ft,importResult:It,setImportResult:Lt,importFileInputRef:Rt,handleExportData:zt,handleImportFileSelect:Bt,handleConfirmImport:Vt,handleCancelImport:Ht}=bt({preferences:w,sessions:h,loadPreferences:E,loadSessions:v}),J=Ie(),{data:Ut={}}=Fe({queryKey:[`plugin-credentials`],queryFn:async()=>{let e=await he.getCredentials();if(!e.success||!e.data)return{};let t={};for(let n of e.data)t[n.plugin_id]=n.has_api_key;return t},enabled:e}),{data:Wt=[]}=Fe({queryKey:[`embedding-models`],queryFn:async()=>{let e=await le.getModels();return e.success&&e.data?e.data:[]},enabled:e}),Y=(0,B.useMemo)(()=>{let e=Wt.find(e=>e.id===G.model||e.rawModel===G.model);return e&&e.id!==G.model?{...G,model:e.id}:G},[Wt,G]),{data:Gt=null}=Fe({queryKey:[`embedding-status`],queryFn:async()=>{let e=await de.getEmbeddingStatus();return e.success&&e.data?e.data:null},enabled:e}),{data:Kt,isLoading:qt}=Fe({queryKey:[`tts-data`],queryFn:async()=>{let[e,t]=await Promise.all([fe.getModels(),fe.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),X=(0,B.useMemo)(()=>Kt?.models??[],[Kt]),Jt=Kt?.plugins??[],Yt=(0,B.useMemo)(()=>me(X,K.model,K.pluginId),[X,K.model,K.pluginId]),Z=(0,B.useMemo)(()=>{if(!Yt)return K;let e=ge(X,K.model,K.pluginId);return e&&K.pluginId===e.plugin?K:{...K,model:Yt.model,pluginId:Yt.plugin,voice:Yt.config?.default_voice||``}},[Yt,X,K]),Xt=(0,B.useMemo)(()=>ge(X,Z.model,Z.pluginId)?.config?.voices??[],[Z,X]),{data:Zt,isLoading:Qt}=Fe({queryKey:[`image-gen-data`],queryFn:async()=>{let[e,t]=await Promise.all([pe.getModels(),pe.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Q=(0,B.useMemo)(()=>Zt?.models??[],[Zt]),$t=(0,B.useMemo)(()=>Zt?.plugins??[],[Zt]),$=(0,B.useMemo)(()=>ue(Q,q.model,q.pluginId),[Q,q.model,q.pluginId]),en=(0,B.useMemo)(()=>{if(!$)return q;let e=N(Q,q.model,q.pluginId);return e&&q.pluginId===e.plugin?q:{...q,model:$.model,pluginId:$.plugin,size:M($.config?.sizes,q.size,$.config?.default_size,`1024x1024`),quality:M($.config?.qualities,q.quality,$.config?.default_quality,`standard`),style:M($.config?.styles,q.style,$.config?.default_style,`vivid`)}},[Q,q,$]),tn=$?.config?.sizes??[],nn=$?.config?.qualities??[],rn=$?.config?.styles??[],an=(0,B.useRef)(!1),on=(0,B.useRef)(c);(0,B.useEffect)(()=>{if(!e){an.current=!1;return}an.current&&on.current===c||(an.current=!0,on.current=c,He(c),ht(w.generationOptions||{}),_t(w.embeddingSettings||Ct),Dt(w.ttsSettings||wt),jt(w.imageGenSettings||Tt))},[e,w.embeddingSettings,w.generationOptions,w.imageGenSettings,w.ttsSettings,c]);let sn=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if(!e){sn.current=!1;return}sn.current||(sn.current=!0,j(),_())},[e,j,_]),(0,B.useEffect)(()=>{if(!e)return;let n=document.body.style.overflow,r=e=>{e.key===`Escape`&&t()};return document.body.style.overflow=`hidden`,document.addEventListener(`keydown`,r),()=>{document.body.style.overflow=n,document.removeEventListener(`keydown`,r)}},[e,t]);let cn=async e=>{let t=st[e];if(!t?.trim()){D.error(`Please enter an API key`);return}W(e);try{let n=await he.setApiKey(e,t.trim());n.success?(D.success(`API key saved successfully`),await J.invalidateQueries({queryKey:[`plugin-credentials`]}),await j(),await J.invalidateQueries({queryKey:[`image-gen-data`]}),ct(t=>({...t,[e]:``})),ut(t=>({...t,[e]:!1}))):D.error(n.error||`Failed to save API key`)}catch{D.error(`Failed to save API key`)}finally{W(null)}},ln=async e=>{W(e);try{let t=await he.deleteApiKey(e);t.success?(D.success(`API key removed`),await J.invalidateQueries({queryKey:[`plugin-credentials`]}),await j(),await J.invalidateQueries({queryKey:[`image-gen-data`]}),ct(t=>({...t,[e]:``}))):D.error(t.error||`Failed to remove API key`)}catch{D.error(`Failed to remove API key`)}finally{W(null)}},un=(e,t)=>{let n=ge(X,e,t);n&&Dt(r=>({...r,model:e,pluginId:t,voice:n.config?.default_voice||r.voice}))},dn=(e,t)=>{let n=N(Q,e,t);n&&jt(t=>({...t,model:e,pluginId:n.plugin,size:M(n.config?.sizes,t.size,n.config?.default_size,`1024x1024`),quality:M(n.config?.qualities,t.quality,n.config?.default_quality,`standard`),style:M(n.config?.styles,t.style,n.config?.default_style,`vivid`)}))},fn=(e,t)=>{Dt(n=>({...n,[e]:t}))},pn=async()=>{try{let e=await P.updatePreferences({ttsSettings:Z});e.success&&e.data&&(T(e.data),D.success(`TTS settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`Failed to save TTS settings: `+t)}},mn=async()=>{if(Ot){let e=At.current;e&&(e.pause(),e.currentTime=0,At.current=null),kt(!1);return}kt(!0);try{let e=await fe.generateBase64({model:Z.model||`tts-1`,pluginId:Z.pluginId,input:`Hello! This is a test of the text-to-speech system.`,voice:Z.voice||`alloy`,speed:Z.speed||1,response_format:Yt?.config?.default_format});if(e.success&&e.data?.audio){let t=`data:${e.data.mimeType};base64,${e.data.audio}`,n=new Audio(t);At.current=n,n.onended=()=>{kt(!1),At.current=null},n.onerror=()=>{D.error(`Failed to play audio`),kt(!1),At.current=null},await n.play()}else throw Error(e.message||`Failed to generate speech`)}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`TTS test failed: `+t),kt(!1)}},hn=()=>{Dt({enabled:!1,autoPlay:!1,model:X[0]?.model||``,voice:X[0]?.config?.default_voice||``,speed:1,pluginId:X[0]?.plugin||``,streamSentences:!1})},gn=(e,t)=>{jt(n=>({...n,[e]:t}))},_n=async()=>{try{let e=await P.updatePreferences({imageGenSettings:en});e.success&&e.data&&(T(e.data),D.success(`Image generation settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`Failed to save image generation settings: `+t)}},vn=()=>{jt({enabled:!1,model:Q[0]?.model||``,size:Q[0]?.config?.default_size||`1024x1024`,quality:Q[0]?.config?.default_quality||`standard`,style:Q[0]?.config?.default_style||`vivid`,pluginId:Q[0]?.plugin||``})},yn=async()=>{try{Et(!0),(await de.regenerateEmbeddings()).success&&(D.success(`Embeddings regenerated successfully`),await J.invalidateQueries({queryKey:[`embedding-status`]}))}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`Failed to regenerate embeddings: `+t)}finally{Et(!1)}},bn=async e=>{try{let t=await P.updatePreferences(e);t.success&&t.data&&(T(t.data),D.success(`Settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`Failed to update settings: `+t)}},xn=async e=>{let t=e.target.files?.[0];t&&(await ie(t),Qe(!1),it.current&&(it.current.value=``),await _(),await J.invalidateQueries({queryKey:[`image-gen-data`]}))},Sn=async()=>{try{await ye(JSON.parse(nt)),$e(!1),rt(``),await _(),await J.invalidateQueries({queryKey:[`image-gen-data`]})}catch{ve(),D.error(`Invalid JSON format`)}},Cn=async e=>{ee.find(t=>t.id===e)?.active?await se(e):await oe(e),await _(),await J.invalidateQueries({queryKey:[`image-gen-data`]})},wn=async e=>{if(!ft[e]){pt(t=>({...t,[e]:!0}));try{let t=await he.discoverModels(e);if(!t.success||!t.data){D.error(t.error||I(`settings.plugins.modelCatalogRefreshFailed`));return}await Promise.all([j(),_()]);let{outcome:n,models:r,reason:i}=t.data;n===`updated`?D.success(I(`settings.plugins.modelCatalogUpdated`,{count:r.length})):n===`unchanged`?D.success(I(`settings.plugins.modelCatalogUnchanged`)):n===`missing_credentials`?D.error(i||I(`settings.plugins.modelCatalogNeedsApiKey`)):D.error(i?`${I(`settings.plugins.modelCatalogUnavailable`)} ${i}`:I(`settings.plugins.modelCatalogUnavailable`))}catch(e){D.error(ke(e,I(`settings.plugins.modelCatalogRefreshFailed`)))}finally{pt(t=>{let n={...t};return delete n[e],n})}}},Tn=async e=>{window.confirm(`Are you sure you want to delete this plugin?`)&&(await ae(e),await _(),await J.invalidateQueries({queryKey:[`image-gen-data`]}))},En=async e=>{await ce(e)};if(!e)return null;let Dn=e=>{let t=Ne.getState().theme;S(Me({...t,mode:e}))},On=e=>{let t=Ne.getState().theme;S(Me({...t,accent:e}))},kn=e=>{let t=Ne.getState().theme;S(Me({...t,accent:`custom`,customAccent:e}))},An=e=>{let t=Ne.getState().theme;S(Me({...t,adaptToAccent:e}))},jn=e=>{T({showUsername:e}),P.updatePreferences({showUsername:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);D.error(`Failed to update settings: `+t)})},Mn=e=>{if(!e.target.value){Ee.setState({selectedModel:``,selectedProviderType:null,selectedProviderId:null}),bn({defaultModel:``,defaultProviderType:null,defaultProviderId:null});return}let t=Ce(we,e.target.value);t&&(s(t.model,t.providerType,t.providerId),T({defaultModel:t.model,defaultProviderType:t.providerType,defaultProviderId:t.providerId}),D.success(`Default model updated`))},Nn=e=>{He(e.target.value)},Pn=()=>{u(Ve),bn({systemMessage:Ve}),D.success(`System message updated`)},Fn=async()=>{window.confirm(`Are you sure you want to delete all chat history? This action cannot be undone.`)&&(await d(),D.success(`All chat sessions deleted`))},In=async()=>{Ge(!0),H(null),_e.pullAllModelsStream(e=>{H(e)},()=>{Ge(!1),H(null),D.success(`All models updated successfully!`),_()},e=>{Ge(!1),H(null),D.error(`Failed to update models: `+e)})},Ln=e=>{let t={...w.titleSettings,autoTitle:e,taskModel:w.titleSettings?.taskModel||``};T({titleSettings:t}),P.updatePreferences({titleSettings:t})},Rn=e=>{if(!e){let e={visionModel:``,visionProviderType:null,visionProviderId:null};T(e),P.updatePreferences(e);return}let t=Ce(Pe,e);if(!t?.providerType){D.error(I(`settings.model.visionModelNoProvider`));return}let n={visionModel:t.model,visionProviderType:t.providerType,visionProviderId:t.providerId||null};T(n),P.updatePreferences(n).catch(e=>{let t=e instanceof Error?e.message:String(e);D.error(I(`settings.model.visionModelUpdateFailed`,{error:t}))})},zn=e=>{let t=e&&e!==St?Ce(Oe,e):null,n={...w.titleSettings,autoTitle:w.titleSettings?.autoTitle||!1,taskModel:t?.model||e,taskProviderType:t?.providerType||null,taskProviderId:t?.providerType===`plugin`&&t.providerId||null};T({titleSettings:n}),P.updatePreferences({titleSettings:n})},Bn=(e,t)=>{ct(n=>({...n,[e]:t}))},Vn=(e,t)=>{ut(n=>({...n,[e]:t}))},Hn=(e,t)=>{ht(n=>({...n,[e]:t}))},Un=async()=>{try{let e=await P.setGenerationOptions(mt);e.success&&e.data&&(T(e.data),D.success(`Generation options updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`Failed to update generation options: `+t)}},Wn=async()=>{try{let e=await P.resetGenerationOptions();e.success&&e.data&&(T(e.data),ht(e.data.generationOptions||{}),D.success(`Generation options reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`Failed to reset generation options: `+t)}},Gn=(e,t)=>{_t(n=>({...n,[e]:t}))},Kn=[...Wt.map(e=>({value:e.id,label:`${e.name} (${e.pluginName||e.provider})`})),...!Wt.find(e=>e.id===Y.model||e.rawModel===Y.model)&&Y.model?[{value:Y.model,label:`${Y.model} (current)`}]:[]],qn=async()=>{try{let e=await P.setEmbeddingSettings(Y);e.success&&e.data&&(T(e.data),D.success(`Embedding settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`Failed to update embedding settings: `+t)}},Jn=async()=>{try{let e=await P.resetEmbeddingSettings();e.success&&e.data&&(T(e.data),_t(e.data.embeddingSettings||{}),D.success(`Embedding settings reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);D.error(`Failed to reset embedding settings: `+t)}},Yn=[{id:`general`,label:I(`settings.groups.general`,`General`),tabs:[{id:`appearance`,label:I(`settings.tabs.appearance`),icon:m},{id:`data`,label:I(`settings.tabs.data`),icon:re},{id:`about`,label:I(`settings.tabs.about`),icon:x}]},{id:`chat`,label:I(`settings.groups.chat`,`Chat`),tabs:[{id:`models`,label:I(`settings.tabs.model`),icon:l},{id:`generation`,label:I(`settings.tabs.generation`),icon:A},{id:`documents`,label:I(`settings.tabs.documents`),icon:g}]},{id:`media`,label:I(`settings.groups.media`,`Speech & images`),tabs:[{id:`tts`,label:I(`settings.tabs.tts`),icon:C},{id:`image-gen`,label:I(`settings.tabs.imageGen`),icon:y}]},{id:`connections`,label:I(`settings.groups.connections`,`Connections`),tabs:[{id:`plugins`,label:I(`settings.tabs.plugins`),icon:p}]}];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,V.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-0 sm:p-4 lg:p-6`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":be,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,V.jsxs)(`div`,{"data-testid":`settings-modal-panel`,className:`flex h-full w-full flex-col overscroll-behavior-contain border border-gray-200/80 bg-surface/95 shadow-2xl backdrop-blur-xl animate-scale-in dark:border-white/10 dark:bg-dark-25/95 sm:max-h-[94vh] sm:max-w-6xl sm:rounded-3xl`,children:[(0,V.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-gray-200/70 px-4 py-4 dark:border-white/[0.08] sm:px-6 sm:py-5`,children:[(0,V.jsx)(`h2`,{id:be,className:`text-xl font-normal tracking-[-0.025em] text-gray-950 dark:text-dark-950 sm:text-2xl rtl:tracking-normal`,children:I(`settings.title`)}),(0,V.jsx)(R,{variant:`ghost`,size:`sm`,onClick:t,autoFocus:!0,className:`h-9 w-9 touch-manipulation p-0 hover:bg-gray-100 active:bg-gray-200 dark:hover:bg-white/[0.06] dark:active:bg-white/10`,title:I(`common.close`,{defaultValue:`Close`}),children:(0,V.jsx)(te,{className:`h-5 w-5 sm:h-4 sm:w-4`})})]}),(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overscroll-behavior-contain sm:flex-row`,children:[(0,V.jsx)(`div`,{className:`w-full shrink-0 overflow-x-auto border-b border-gray-200/70 p-2 scrollbar-thin dark:border-white/[0.08] sm:w-56 sm:overflow-x-hidden sm:overflow-y-auto sm:border-b-0 sm:border-e sm:p-3 lg:w-64`,style:{WebkitOverflowScrolling:`touch`},children:(0,V.jsx)(`nav`,{className:`flex gap-1 sm:flex-col sm:gap-0`,role:`tablist`,"aria-label":I(`settings.title`,`Settings`),children:Yn.map(e=>(0,V.jsxs)(`div`,{className:`flex shrink-0 gap-1 sm:flex-col sm:gap-0.5 sm:pb-2`,children:[(0,V.jsx)(`p`,{"aria-hidden":`true`,className:`hidden px-2.5 pb-1 pt-2 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-subtle sm:block`,children:e.label}),e.tabs.map(e=>{let t=e.icon,n=Be===e.id;return(0,V.jsxs)(`button`,{onClick:()=>z(e.id),className:F(`flex shrink-0 items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-start transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 sm:w-full`,n?`bg-black/[0.06] text-ink dark:bg-white/[0.08]`:`text-ink-muted hover:bg-black/[0.04] hover:text-ink dark:hover:bg-white/[0.05]`),role:`tab`,"aria-selected":n,"aria-controls":`settings-tab-panel`,children:[(0,V.jsx)(t,{className:`h-4 w-4 flex-shrink-0`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`truncate whitespace-nowrap text-[13px]`,children:e.label})]},e.id)})]},e.id))})}),(0,V.jsx)(`div`,{"data-testid":`settings-scroll-region`,className:`scroll-region min-h-0 flex-1 p-4 scrollbar-thin sm:p-6 lg:p-8`,id:`settings-tab-panel`,role:`tabpanel`,children:(()=>{switch(Be){case`appearance`:return(0,V.jsx)(qe,{theme:b,preferences:w,onThemeChange:Dn,onAccentChange:On,onCustomAccentChange:kn,onAdaptToAccentChange:An,onShowUsernameChange:jn});case`models`:return(0,V.jsx)(tt,{models:n,selectedModel:i,selectedProviderType:a,selectedProviderId:o,systemMessage:c,tempSystemMessage:Ve,loading:f,preferences:w,currentVisionModel:Le,visionModelOptions:Re,currentTaskModel:Ae,autoTitleTaskModelOptions:ze,updatingAllModels:We,updateProgress:Ke,onModelChange:Mn,onSystemMessageChange:Nn,onSystemMessageSave:Pn,onAutoTitleChange:Ln,onAutoTitleTaskModelChange:zn,onVisionModelChange:Rn,onUpdateAllModels:In});case`tts`:return(0,V.jsx)(yt,{loading:qt,settings:K,effectiveSettings:Z,models:X,plugins:Jt,voices:Xt,testing:Ot,onSettingChange:fn,onModelChange:un,onReset:hn,onTest:mn,onSave:pn});case`image-gen`:return(0,V.jsx)(et,{loading:Qt,settings:q,effectiveSettings:en,models:Q,plugins:$t,sizes:tn,qualities:nn,styles:rn,onSettingChange:gn,onModelChange:dn,onReset:vn,onSave:_n});case`documents`:return(0,V.jsx)(Ye,{settings:G,effectiveSettings:Y,modelOptions:Kn,status:Gt,regenerating:vt,onSettingChange:Gn,onReset:Jn,onRegenerate:yn,onSave:qn});case`plugins`:return(0,V.jsx)(gt,{plugins:ee,loading:ne,uploading:O,error:k,hasKeys:Ut,showUploadForm:Xe,showJsonForm:U,jsonInput:nt,fileInputRef:it,expandedPluginId:at,pluginApiKeys:st,showApiKey:lt,savingApiKey:dt,refreshingPluginIds:ft,onClearError:ve,onShowUploadFormChange:Qe,onShowJsonFormChange:$e,onJsonInputChange:rt,onFileUpload:xn,onJsonSubmit:Sn,onExpandedPluginChange:ot,onPluginApiKeyChange:Bn,onShowApiKeyChange:Vn,onActivatePlugin:Cn,onRefreshModels:wn,onDeletePlugin:Tn,onExportPlugin:En,onSaveApiKey:cn,onDeleteApiKey:ln});case`data`:return(0,V.jsx)(Je,{sessionCount:h.length,loading:f,importing:Mt,showImportOptions:Nt,mergeStrategy:Pt,importResult:It,importFileInputRef:Rt,onExportData:zt,onImportFileSelect:Bt,onClearAllHistory:Fn,onMergeStrategyChange:Ft,onConfirmImport:Vt,onCancelImport:Ht,onDismissImportResult:()=>Lt(null)});case`about`:return(0,V.jsx)(Ue,{appVersion:xt});case`generation`:return(0,V.jsx)(Ze,{generationOptions:mt,embeddingSettings:G,effectiveEmbeddingSettings:Y,embeddingModelOptions:Kn,embeddingStatus:Gt,onGenerationOptionChange:Hn,onEmbeddingSettingsChange:Gn,onResetGenerationOptions:Wn,onSaveGenerationOptions:Un,onResetEmbeddingSettings:Jn,onSaveEmbeddingSettings:qn});default:return null}})()})]})]})})]})};export{Et as SettingsModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./rolldown-runtime-QTnfLwEv.js";import{d as e,f as t}from"./markdown-core-GI9BPwrB.js";import{t as n}from"./useTranslation-Cs6iTP4m.js";import{D as r,I as i,S as a,Tt as o,V as s,Vt as c,Xt as l,kt as u,rn as d,tt as f,y as p}from"./ui-vendor-ChfdHf5M.js";import{s as m}from"./api-BCqWXjZI.js";import{t as h}from"./utils-DmZD5uA3.js";import{t as g}from"./Button-CRwzOaDZ.js";import{F as _,c as v,l as y}from"../assets/index-CmZntyR1.js";t();var b=e(),x=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),S=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),C=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),w=e=>{if(!Number.isFinite(e)||e<0)return`—`;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${x.format(e/1024**n)} ${t[n]}`},T=e=>{if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:i>0?`${i}m`:`${Math.floor(e)}s`},E=e=>Math.min(100,Math.max(0,Number.isFinite(e)?e:0)),D=e=>{switch(e.toLowerCase()){case`running`:return`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`;case`paused`:return`bg-amber-500/10 text-amber-700 dark:text-amber-300`;case`exited`:case`dead`:return`bg-gray-500/10 text-gray-600 dark:text-dark-600`;default:return`bg-primary-500/10 text-primary-700 dark:text-primary-300`}},O=({title:e,description:t,icon:n,className:r,action:i,children:a})=>(0,b.jsxs)(`section`,{className:h(`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,r),children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 rounded-xl bg-primary-500/10 p-1.5 text-primary-600 dark:text-primary-300`,children:(0,b.jsx)(n,{className:`h-4 w-4`})}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e}),t&&(0,b.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t})]})]}),i]}),a]}),k=({label:e,value:t,mono:n})=>(0,b.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-5 border-b border-gray-100 py-2 last:border-0 dark:border-white/[0.05]`,children:[(0,b.jsx)(`dt`,{className:`shrink-0 text-xs text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`dd`,{className:h(`min-w-0 break-words text-end text-xs font-medium text-gray-800 dark:text-dark-800`,n&&`font-mono text-[11px]`),children:t})]}),A=({value:e,tone:t=`primary`})=>(0,b.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(E(e)),children:(0,b.jsx)(`div`,{className:h(`h-full rounded-full transition-[width] duration-300`,t===`warning`?`bg-amber-500 dark:bg-amber-400`:`bg-primary-500 dark:bg-primary-400`),style:{width:`${E(e)}%`}})}),j=()=>{let{t:e}=n(),{data:t,error:i,isLoading:a,isFetching:o,refetch:s}=_({queryKey:[`system-diagnostics`],queryFn:async()=>{let t=await m.getDiagnostics();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1}),c=i?i instanceof Error?i.message:e(`systemPage.loadFailed`):null;return a&&!t?(0,b.jsx)(y,{width:`wide`,children:(0,b.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,b.jsx)(d,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,b.jsxs)(y,{width:`wide`,children:[(0,b.jsx)(v,{eyebrow:e(`systemPage.eyebrow`),title:e(`systemPage.title`),description:e(`systemPage.description`),actions:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,b.jsx)(`span`,{className:`hidden text-xs text-gray-500 dark:text-dark-500 sm:inline`,children:e(`systemPage.updated`,{date:C.format(t.generatedAt)})}),(0,b.jsxs)(g,{variant:`outline`,size:`sm`,onClick:()=>void s(),disabled:o,children:[(0,b.jsx)(r,{className:h(`h-4 w-4`,o&&`animate-spin`)}),(0,b.jsx)(`span`,{className:`sr-only`,children:e(`systemPage.refresh`)})]})]})}),c&&(0,b.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,b.jsx)(l,{className:`h-4 w-4 shrink-0`}),(0,b.jsx)(`span`,{children:c})]}),t&&(0,b.jsxs)(`div`,{"data-testid":`system-dashboard`,className:`space-y-4`,children:[(0,b.jsx)(M,{diagnostics:t}),(0,b.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,b.jsx)(N,{diagnostics:t}),(0,b.jsx)(P,{diagnostics:t})]}),(0,b.jsx)(F,{diagnostics:t}),(0,b.jsx)(I,{diagnostics:t}),(0,b.jsx)(R,{diagnostics:t}),(0,b.jsxs)(`div`,{className:`flex items-start gap-2 px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:[(0,b.jsx)(p,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary-500`}),(0,b.jsx)(`p`,{children:e(`systemPage.securityNote`)})]})]})]})},M=({diagnostics:e})=>{let{t}=n(),r=e.filesystems.find(e=>e.label===`Data directory`)??e.filesystems[0];return(0,b.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[{label:t(`systemPage.cards.uptime`),value:T(e.host.uptimeSeconds),detail:t(`systemPage.cards.uptimeDetail`,{date:C.format(e.host.bootedAt)}),icon:u},{label:t(`systemPage.cards.memory`),value:`${S.format(e.memory.usedPercent)}%`,detail:t(`systemPage.cards.memoryDetail`,{used:w(e.memory.usedBytes),total:w(e.memory.totalBytes)}),icon:s},{label:t(`systemPage.cards.freeSpace`),value:r?w(r.freeBytes):`—`,detail:r?t(`systemPage.cards.freeSpaceDetail`,{label:r.label,total:w(r.totalBytes)}):t(`systemPage.cards.unavailable`),icon:f},{label:t(`systemPage.cards.containers`),value:e.docker.available?String(e.docker.runningContainers):`—`,detail:e.docker.available?t(`systemPage.cards.containersDetail`,{total:e.docker.totalContainers}):t(`systemPage.cards.dockerUnavailable`),icon:o}].map(e=>{let t=e.icon;return(0,b.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,b.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,b.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,b.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})})},N=({diagnostics:e})=>{let{t}=n(),{host:r,runtime:i}=e;return(0,b.jsx)(O,{title:t(`systemPage.host.title`),description:t(`systemPage.host.description`),icon:a,action:(0,b.jsx)(`span`,{className:`rounded-full bg-primary-500/10 px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em] text-primary-700 dark:text-primary-300`,children:r.containerized?t(`systemPage.host.container`):t(`systemPage.host.native`)}),children:(0,b.jsxs)(`dl`,{className:`px-4 py-2 sm:px-5`,children:[(0,b.jsx)(k,{label:t(`systemPage.host.hostname`),value:r.hostname}),(0,b.jsx)(k,{label:t(`systemPage.host.operatingSystem`),value:`${r.platform} ${r.release} · ${r.architecture}`}),(0,b.jsx)(k,{label:t(`systemPage.host.processor`),value:`${r.cpuModel} · ${r.logicalCpus} ${t(`systemPage.host.logicalCpus`)}`}),(0,b.jsx)(k,{label:t(`systemPage.host.loadAverage`),value:r.loadAverage.map(e=>S.format(e)).join(` · `)}),(0,b.jsx)(k,{label:t(`systemPage.host.libreVersion`),value:i.appVersion}),(0,b.jsx)(k,{label:t(`systemPage.host.nodeVersion`),value:i.nodeVersion}),(0,b.jsx)(k,{label:t(`systemPage.host.process`),value:`PID ${i.processId} · ${T(i.processUptimeSeconds)}`}),(0,b.jsx)(k,{label:t(`systemPage.host.workingDirectory`),value:i.workingDirectory,mono:!0})]})})},P=({diagnostics:e})=>{let{t}=n(),{memory:r}=e;return(0,b.jsx)(O,{title:t(`systemPage.memory.title`),description:t(`systemPage.memory.description`),icon:s,children:(0,b.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`mb-2 flex items-end justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`text-2xl tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:[S.format(r.usedPercent),`%`]}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.usedOf`,{used:w(r.usedBytes),total:w(r.totalBytes)})})]}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.free`,{value:w(r.freeBytes)})})]}),(0,b.jsx)(A,{value:r.usedPercent,tone:r.usedPercent>=85?`warning`:`primary`})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[t(`systemPage.memory.processRss`),r.processRssBytes],[t(`systemPage.memory.heapUsed`),r.heapUsedBytes],[t(`systemPage.memory.heapTotal`),r.heapTotalBytes],[t(`systemPage.memory.external`),r.externalBytes]].map(([e,t])=>(0,b.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-lg text-gray-950 dark:text-dark-950`,children:w(Number(t))})]},String(e)))})]})})},F=({diagnostics:e})=>{let{t}=n();return(0,b.jsx)(O,{title:t(`systemPage.storage.title`),description:t(`systemPage.storage.description`),icon:f,children:e.filesystems.length===0?(0,b.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.storage.empty`)}):(0,b.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5`,children:e.filesystems.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e.label}),(0,b.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.path})]}),(0,b.jsxs)(`span`,{className:`shrink-0 text-sm tabular-nums text-gray-700 dark:text-dark-700`,children:[S.format(e.usedPercent),`%`]})]}),(0,b.jsx)(`div`,{className:`mt-4`,children:(0,b.jsx)(A,{value:e.usedPercent,tone:e.usedPercent>=85?`warning`:`primary`})}),(0,b.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,b.jsx)(`span`,{children:t(`systemPage.storage.used`,{value:w(e.usedBytes)})}),(0,b.jsx)(`span`,{children:t(`systemPage.storage.free`,{value:w(e.freeBytes)})})]})]},`${e.label}:${e.path}`))})})},I=({diagnostics:e})=>{let{t}=n(),{docker:r}=e;return(0,b.jsx)(O,{title:t(`systemPage.docker.title`),description:t(`systemPage.docker.description`),icon:o,action:(0,b.jsxs)(`span`,{className:h(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,r.available?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,b.jsx)(`span`,{className:h(`h-1.5 w-1.5 rounded-full`,r.available?`bg-emerald-500`:`bg-gray-400`)}),r.available?t(`systemPage.docker.connected`):t(`systemPage.docker.unavailable`)]}),children:r.available?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[t(`systemPage.docker.running`),r.runningContainers],[t(`systemPage.docker.stopped`),r.stoppedContainers],[t(`systemPage.docker.paused`),r.pausedContainers],[t(`systemPage.docker.total`),r.totalContainers]].map(([e,t])=>(0,b.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,b.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-4 sm:px-5`,children:[r.serverVersion&&(0,b.jsx)(L,{label:t(`systemPage.docker.version`),value:r.serverVersion}),r.operatingSystem&&(0,b.jsx)(L,{label:t(`systemPage.docker.host`),value:r.operatingSystem}),r.architecture&&(0,b.jsx)(L,{label:t(`systemPage.docker.architecture`),value:r.architecture}),r.logicalCpus!==void 0&&(0,b.jsx)(L,{label:t(`systemPage.docker.cpus`),value:String(r.logicalCpus)}),r.memoryBytes!==void 0&&(0,b.jsx)(L,{label:t(`systemPage.docker.memory`),value:w(r.memoryBytes)})]}),r.containers.length===0?(0,b.jsx)(`p`,{className:`px-5 pb-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.empty`)}):(0,b.jsx)(`div`,{className:`overflow-x-auto border-t border-gray-200/70 dark:border-white/[0.07]`,children:(0,b.jsxs)(`table`,{"data-testid":`system-docker-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,b.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,b.jsxs)(`tr`,{children:[(0,b.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:t(`systemPage.docker.container`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.image`)}),(0,b.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.state`)}),(0,b.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:t(`systemPage.docker.created`)})]})}),(0,b.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:r.containers.map(e=>(0,b.jsxs)(`tr`,{children:[(0,b.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,b.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.id})]}),(0,b.jsx)(`td`,{className:`max-w-[280px] px-4 py-2.5`,children:(0,b.jsx)(`div`,{className:`truncate font-mono text-[11px] text-gray-600 dark:text-dark-600`,title:e.image,children:e.image})}),(0,b.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,b.jsx)(`span`,{className:h(`inline-flex rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.08em]`,D(e.state)),children:e.state}),(0,b.jsx)(`div`,{className:`mt-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:e.status})]}),(0,b.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-500 dark:text-dark-500`,children:e.createdAt?C.format(e.createdAt):`—`})]},e.id))})]})})]}):(0,b.jsxs)(`div`,{className:`m-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:m-5`,children:[(0,b.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{children:r.reason||t(`systemPage.docker.unavailableDetail`)}),(0,b.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.socketStatus`,{status:r.socketMounted?t(`systemPage.docker.mounted`):t(`systemPage.docker.notMounted`)})})]})]})})},L=({label:e,value:t})=>(0,b.jsxs)(`span`,{className:`rounded-full border border-gray-200 bg-white px-3 py-1.5 text-[11px] text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/70 dark:text-dark-600`,children:[(0,b.jsx)(`span`,{className:`text-gray-400 dark:text-dark-500`,children:e}),` `,t]}),R=({diagnostics:e})=>{let{t}=n();return(0,b.jsx)(O,{title:t(`systemPage.network.title`),description:t(`systemPage.network.description`),icon:i,children:e.network.interfaces.length===0?(0,b.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.network.empty`)}):(0,b.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5 xl:grid-cols-3`,children:e.network.interfaces.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(c,{className:`h-4 w-4 text-primary-500`}),(0,b.jsx)(`h3`,{className:`font-mono text-xs font-medium text-gray-900 dark:text-dark-900`,children:e.name})]}),(0,b.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.addresses.map(e=>(0,b.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-white px-3 py-2 dark:bg-dark-100/80`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-gray-400 dark:text-dark-500`,children:e.family}),e.internal&&(0,b.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`systemPage.network.internal`)})]}),(0,b.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-gray-700 dark:text-dark-700`,children:e.cidr||e.address})]},`${e.family}:${e.address}`))}),(e.receivedBytes!==void 0||e.transmittedBytes!==void 0)&&(0,b.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[10px] text-gray-500 dark:text-dark-500`,children:[(0,b.jsxs)(`span`,{children:[`↓ `,w(e.receivedBytes??0)]}),(0,b.jsxs)(`span`,{children:[`↑ `,w(e.transmittedBytes??0)]})]})]},e.name))})})};export{j as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-GI9BPwrB.js";import{t as r}from"./useTranslation-Cs6iTP4m.js";import{$t as i,f as a,fn as o,k as s,kt as c,l,s as u,v as d}from"./ui-vendor-ChfdHf5M.js";import{t as f}from"./logger-DbNs3-DK.js";import{k as p}from"./api-BCqWXjZI.js";import{n as m}from"./authStore-Bl5ofD_h.js";import{t as h}from"./Button-CRwzOaDZ.js";import{E as g,F as _,L as v,c as y,d as b,f as x,h as S,l as C,m as w,p as T,u as E}from"../assets/index-CmZntyR1.js";var D=e(n(),1),O=t(),k=f(`components:user-manager`),A=()=>{let{t:e}=r(),t=v(),[n,f]=(0,D.useState)(!1),[y,C]=(0,D.useState)(null),[A,j]=(0,D.useState)({username:``,email:``,password:``,role:`user`}),{user:M}=m(),{data:N=[],isLoading:P}=_({queryKey:[`users`],queryFn:async()=>{let t=await p.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),F=()=>t.invalidateQueries({queryKey:[`users`]}),I=N.filter(e=>e.status===`pending`),L=N.filter(e=>e.status!==`pending`),R=async t=>{t.preventDefault();try{let t=await p.createUser(A);t.success&&t.data&&(await F(),j({username:``,email:``,password:``,role:`user`}),f(!1),o.success(e(`userManager.form.createSuccess`)))}catch(t){k.error(`Error creating user:`,t);let n=e(`userManager.form.createFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.createFailed`)),o.error(n)}},z=async t=>{if(t.preventDefault(),y)try{let t={username:A.username,email:A.email,role:A.role};A.password&&A.password.trim()!==``&&(t.password=A.password);let n=await p.updateUser(y.id,t);n.success&&n.data&&(await F(),C(null),j({username:``,email:``,password:``,role:`user`}),o.success(e(`userManager.form.updateSuccess`)))}catch(t){k.error(`Error updating user:`,t);let n=e(`userManager.form.updateFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.updateFailed`)),o.error(n)}},B=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await p.deleteUser(t)).success&&(await F(),o.success(e(`userManager.deleteSuccess`)))}catch(t){k.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),o.error(n)}},V=async t=>{try{let n=await p.approveUser(t.id);n.success&&n.data&&(await F(),o.success(e(`userManager.approval.approved`,{name:t.username,defaultValue:`{{name}} can now sign in.`})))}catch(t){k.error(`Error approving user:`,t);let n=t;o.error(n.response?.data?.message||e(`userManager.approval.failed`,`The account could not be approved.`))}},H=e=>{C(e),j({username:e.username,email:e.email||``,password:``,role:e.role})};return P?(0,O.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,O.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-gray-600 border-t-primary-500 rounded-full animate-spin`})}):(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,O.jsx)(`div`,{}),(0,O.jsxs)(h,{onClick:()=>f(!n),className:`flex items-center space-x-2 bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600`,children:[(0,O.jsx)(s,{size:16}),(0,O.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,O.jsxs)(E,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(T,{children:[(0,O.jsx)(w,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,O.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(b,{children:(0,O.jsxs)(`form`,{onSubmit:R,className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(S,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,O.jsx)(g,{id:`username`,value:A.username,onChange:e=>j({...A,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(S,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,O.jsx)(g,{id:`email`,type:`email`,value:A.email,onChange:e=>j({...A,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(S,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,O.jsx)(g,{id:`password`,type:`password`,value:A.password,onChange:e=>j({...A,password:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(S,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,O.jsxs)(`select`,{id:`role`,value:A.role,onChange:e=>j({...A,role:e.target.value}),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200`,children:[(0,O.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,O.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,O.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>{j({username:``,email:``,password:``,role:`user`}),f(!1)},children:e(`common.cancel`)})]})]})})]}),y&&(0,O.jsxs)(E,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(T,{children:[(0,O.jsxs)(w,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,y.username]}),(0,O.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(b,{children:(0,O.jsxs)(`form`,{onSubmit:z,className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(S,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,O.jsx)(g,{id:`edit-username`,value:A.username,onChange:e=>j({...A,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(S,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,O.jsx)(g,{id:`edit-email`,type:`email`,value:A.email,onChange:e=>j({...A,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(S,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,O.jsx)(g,{id:`edit-password`,type:`password`,value:A.password,onChange:e=>j({...A,password:e.target.value}),placeholder:e(`userManager.form.passwordHint`),className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(S,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,O.jsxs)(`select`,{id:`edit-role`,value:A.role,onChange:e=>j({...A,role:e.target.value}),disabled:y?.id===M?.id&&M?.role===`admin`,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,O.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,O.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),y?.id===M?.id&&M?.role===`admin`&&(0,O.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,O.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>{C(null),j({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),I.length>0&&(0,O.jsxs)(E,{"data-testid":`pending-user-approvals`,className:`border border-warning-500/30 bg-warning-500/[0.06] shadow-lg`,children:[(0,O.jsxs)(T,{children:[(0,O.jsxs)(w,{className:`flex items-center gap-2 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(c,{className:`h-5 w-5 text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`,`Pending approvals`),` (`,I.length,`)`]}),(0,O.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.approval.description`,`Review new registrations before allowing them into this instance.`)})]}),(0,O.jsx)(b,{children:(0,O.jsx)(`div`,{className:`space-y-3`,children:I.map(t=>(0,O.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-4 rounded-xl border border-warning-500/25 bg-surface p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h3`,{className:`truncate font-medium text-ink`,children:t.username}),(0,O.jsx)(`p`,{className:`truncate text-sm text-ink-muted`,children:t.email||e(`userManager.noEmail`)}),(0,O.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(`userManager.approval.registered`,`Registered`),`:`,` `,new Date(t.createdAt).toLocaleString()]})]}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(h,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void V(t),className:`gap-2`,children:[(0,O.jsx)(l,{size:16}),e(`userManager.approval.activate`,`Activate account`)]}),(0,O.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e(`userManager.approval.reject`,`Reject registration`),onClick:()=>void B(t.id,t.username),className:`text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-900/20 dark:hover:text-red-300`,children:(0,O.jsx)(a,{size:16})})]})]},t.id))})})]}),(0,O.jsxs)(E,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,O.jsxs)(T,{children:[(0,O.jsxs)(w,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,L.length,`)`]}),(0,O.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,O.jsx)(b,{children:(0,O.jsx)(`div`,{className:`space-y-3`,children:L.map(t=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,O.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,O.jsx)(d,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,O.jsx)(u,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===M?.id&&(0,O.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,O.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[t.email||e(`userManager.noEmail`),` •`,` `,t.role===`admin`?e(`userManager.roles.admin`):e(`userManager.roles.user`)]}),(0,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,O.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,O.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>H(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,O.jsx)(i,{size:16})}),(0,O.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>B(t.id,t.username),disabled:t.id===M?.id,className:`text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(a,{size:16})})]})]},t.id))})})]})]})},j=()=>{let{t:e}=r();return(0,O.jsxs)(C,{children:[(0,O.jsx)(y,{title:e(`userManager.title`),description:e(`userManager.pageDescription`)}),(0,O.jsx)(A,{})]})};export{j as UserManagementPage,j as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-BnLuavNv.js","js/router-vendor-BjDI9mRe.js","js/rolldown-runtime-QTnfLwEv.js","js/markdown-core-GI9BPwrB.js","js/estree-BFya-bSu.js","assets/index-CmZntyR1.js","js/react-vendor-DyG_ODzn.js","js/useTranslation-Cs6iTP4m.js","js/ui-vendor-ChfdHf5M.js","js/utils-vendor-Cbaj0BC5.js","js/demoMode-BhEpMVh5.js","js/logger-DbNs3-DK.js","js/api-BCqWXjZI.js","js/utils-DmZD5uA3.js","js/authStore-Bl5ofD_h.js","js/appStore-CDM6V5ny.js","js/Button-CRwzOaDZ.js","assets/index-ChhWhug2.css","js/typescript-d0TUM2-0.js","js/postcss-DSDkwgFE.js","js/html-DJot0Wwf.js","js/markdown-CXwWsPYG.js","js/yaml-mLy9chOK.js","js/standalone-C0NjJpWr.js","js/OptimizedSyntaxHighlighter-Ci9sRc78.js","js/syntax-highlight-pM1xnNpY.js","js/xterm-DKl1QLiw.js","js/addon-fit-Cj0_dfHF.js","assets/xterm-CmMoOwwu.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-GI9BPwrB.js";import{d as r,f as i,i as a,l as o,u as s}from"./router-vendor-BjDI9mRe.js";import{t as c}from"./useTranslation-Cs6iTP4m.js";import{A as l,B as u,Bt as d,C as f,D as p,Gt as m,Jt as h,Kt as g,Mt as _,Nt as v,Pt as y,Q as b,Qt as x,R as S,T as C,Yt as w,_ as T,at as E,bt as D,en as O,f as k,ft as ee,gt as te,k as A,lt as ne,n as re,ot as ie,pn as j,pt as ae,rn as M,s as N,sn as oe,tt as se,un as ce,ut as le,zt as P}from"./ui-vendor-ChfdHf5M.js";import{A as ue,c as de,o as F}from"./api-BCqWXjZI.js";import{t as I}from"./utils-DmZD5uA3.js";import{a as fe,i as pe,l as me,n as he,o as ge,s as _e,u as ve}from"./authStore-Bl5ofD_h.js";import{t as ye}from"./appStore-CDM6V5ny.js";import{t as L}from"./Button-CRwzOaDZ.js";import{_ as be,a as xe,j as Se}from"../assets/index-CmZntyR1.js";import{t as Ce}from"./RichMessageContent-nAEaPTpH.js";import{t as we}from"./ModelSelector-D7kDjZV9.js";import{n as Te,t as Ee}from"./work-DVgm81bJ.js";var R=e(n(),1),z=t(),B=e=>Te({model:e.name,providerType:e.isPlugin?`plugin`:`ollama`,providerId:e.isPlugin?e.pluginId:void 0}),De=e=>{let t=e.name.split(`/`).filter(Boolean),n=t[t.length-1]||e.name;return t.length>1?n.replace(/[-_]+/g,` `):n},V=e=>{let t=`${e.model} · `;return{name:e.model,model:e.model,size:0,digest:``,modified_at:``,details:{},isPlugin:e.providerType===`plugin`,pluginId:e.providerId,pluginName:e.providerType===`plugin`?e.label.startsWith(t)?e.label.slice(t.length):e.providerId:void 0}};function H({models:e,selectorModels:t,modelKey:n,running:r,loading:i,variant:a=`task`,disabled:o=!1,remoteDisclosureDismissed:s,remoteDisclosureSaving:l,onModelChange:u,onDismissRemoteDisclosure:d,onModelsRefresh:p,onSubmit:m,onCancel:h}){let{t:g}=c(),[_,v]=(0,R.useState)(``),y=(0,R.useRef)(null),b=(0,R.useRef)(null),x=(0,R.useRef)(null),S=e.find(e=>e.key===n),C=S?.remote===!0,w=a===`landing`,E=(0,R.useMemo)(()=>{let n=new Set(t.map(B)),r=e.filter(e=>!n.has(e.key)).map(V);return[...t,...r]},[e,t]);(0,R.useEffect)(()=>{let e=y.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[_]);let D=async()=>{await d()&&([b.current,x.current].find(e=>e&&e.offsetParent!==null)||b.current)?.focus()},O=t=>{let n=e.find(e=>e.key===t)||e.find(e=>e.providerType===`ollama`&&e.model===t);n&&u(n.key)},k=async()=>{let e=_.trim();!e||i||r||o||!S||await m(e)&&v(``)};return(0,z.jsxs)(`div`,{"data-testid":w?`work-landing-composer`:`work-task-composer`,"data-variant":a,className:I(`relative shrink-0`,w?`mt-10 w-full`:`border-t border-line bg-surface/95 px-3 py-3 backdrop-blur md:px-5`),children:[C&&!s&&(0,z.jsx)(`div`,{className:I(`absolute inset-x-3 z-30 mx-auto max-w-3xl md:inset-x-5`,`bottom-full mb-3`),children:(0,z.jsxs)(`aside`,{"data-testid":`work-provider-disclosure-popover`,"aria-labelledby":`work-provider-disclosure-title`,"aria-live":`polite`,className:`relative rounded-2xl border border-warning-500/40 bg-surface-overlay p-3 pe-10 shadow-overlay backdrop-blur dark:border-warning-500/45`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:l,className:`absolute end-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-warning-500/20 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-warning-500 disabled:cursor-wait disabled:opacity-50`,"aria-label":g(`work.composer.remoteDismissLabel`,{defaultValue:`Dismiss remote provider notice`}),children:(0,z.jsx)(re,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-warning-500/20`,children:(0,z.jsx)(ce,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:g(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,z.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-ink-muted`,children:g(`work.composer.remoteHint`,{defaultValue:`Conversation and tool output are sent to the configured service. One autonomous run can make multiple provider calls and may incur charges. Workspace files stay local unless a tool returns their contents.`})}),(0,z.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,z.jsx)(L,{"data-testid":`work-provider-disclosure-dismiss`,type:`button`,variant:`ghost`,size:`sm`,loading:l,className:`h-7 border-warning-500 bg-warning-500 px-2.5 text-xs text-[#3d120c] hover:bg-warning-500/90 hover:text-[#3d120c]`,onClick:()=>void D(),children:g(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,z.jsx)(`form`,{className:`mx-auto w-full max-w-3xl`,onSubmit:e=>{e.preventDefault(),k()},children:(0,z.jsxs)(`div`,{"data-testid":`work-composer-surface`,className:I(`flex items-end gap-2 rounded-[1.6rem] border p-2.5 transition-[border-color,box-shadow,background-color] duration-200 sm:p-3`,`border-black/[0.08] bg-surface/90 dark:border-white/[0.09] dark:bg-dark-200/90`,`shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_50px_rgba(15,23,42,0.08)] backdrop-blur-xl`,`focus-within:border-primary-500/35 focus-within:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_22px_65px_rgba(15,23,42,0.12)]`),children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(`textarea`,{ref:y,"data-testid":`work-composer-input`,dir:`auto`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),k())},disabled:o||r,rows:1,className:`m-0 block max-h-[160px] min-h-10 w-full resize-none overflow-y-auto rounded-none border-0 bg-transparent p-2 text-base leading-relaxed text-ink shadow-none outline-none placeholder:text-ink-subtle focus:border-0 focus:bg-transparent focus:ring-0 disabled:cursor-not-allowed disabled:opacity-60`,placeholder:g(`work.composer.placeholder`,{defaultValue:`Describe what you want to build or change…`})})}),(0,z.jsx)(`div`,{className:`hidden shrink-0 sm:block`,children:(0,z.jsx)(we,{models:E,selectedModel:n,onModelChange:e=>O(e.target.value),onModelsRefresh:()=>void p(),getModelValue:B,getModelLabel:De,getModelTitle:e=>e.name,triggerRef:b,triggerTestId:`work-model-selector-trigger`,selectTestId:`work-model-select`,ariaLabel:g(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`min-w-[150px] max-w-[230px]`,compact:!0})}),r?(0,z.jsx)(L,{"data-testid":`work-cancel-button`,type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full bg-error-500/15 p-0 text-error-600 transition-colors duration-150 hover:bg-error-500/25 dark:text-error-400 sm:h-10 sm:w-10`,title:g(`work.composer.cancel`,{defaultValue:`Stop`}),"aria-label":g(`work.composer.cancel`,{defaultValue:`Stop`}),onClick:()=>void h(),children:i?(0,z.jsx)(M,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(T,{className:`h-4 w-4 fill-current`})}):(0,z.jsx)(L,{"data-testid":`work-submit-button`,type:`submit`,variant:`ghost`,size:`sm`,disabled:i||o||!_.trim()||!S,className:I(`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors duration-150 sm:h-10 sm:w-10`,`bg-gray-950 text-white hover:bg-gray-800 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100`,`disabled:bg-gray-100 disabled:text-gray-400 disabled:hover:bg-gray-100 dark:disabled:bg-dark-300 dark:disabled:text-dark-500 dark:disabled:hover:bg-dark-300`,_.trim()&&S&&!o&&`shadow-sm`),title:g(`work.composer.send`,{defaultValue:`Run`}),"aria-label":g(`work.composer.send`,{defaultValue:`Run`}),children:i?(0,z.jsx)(M,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(f,{className:`h-4 w-4`})})]})}),(0,z.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-3xl sm:hidden`,children:(0,z.jsx)(we,{models:E,selectedModel:n,onModelChange:e=>O(e.target.value),onModelsRefresh:()=>void p(),getModelValue:B,getModelLabel:De,getModelTitle:e=>e.name,triggerRef:x,triggerTestId:`work-model-selector-trigger-mobile`,selectTestId:`work-model-select-mobile`,ariaLabel:g(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`w-full`,compact:!0})})]})}var Oe=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},ke=e=>{if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}`:`${r}s`},Ae=e=>{if(!e)return 0;let t=Array.from(e).length,n=e.trim()?e.trim().split(/\s+/u).length:0;return Math.max(n,Math.ceil(t/4))};function je({run:e}){let[t,n]=(0,R.useState)();if((0,R.useEffect)(()=>{if(e.terminal||!e.startedAt)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e.startedAt,e.terminal]),!e.startedAt)return null;let r=e.finishedAt||t;return r?(0,z.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:ke(r-e.startedAt)}):null}function Me({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,R.useState)(e.status),[i,a]=(0,R.useState)(null),o=(0,R.useMemo)(()=>Oe(e.arguments),[e.arguments]),s=e.output||null,l=!!(o||s),u=e.status===`error`,d=e.status===`running`,f=(0,R.useId)(),p=u?n(`work.activity.kinds.error`,{defaultValue:`Error`}):d?n(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}):n(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),m=i??(e.status===r?t:e.status===`error`);return(0,z.jsxs)(`div`,{"data-testid":`work-live-tool`,"data-tool-id":e.id,className:I(`overflow-hidden rounded-xl border bg-surface-raised transition-colors`,u?`border-error-500/30`:`border-line`),children:[(0,z.jsxs)(`button`,{type:`button`,disabled:!l,onClick:()=>{a(!m)},"aria-expanded":l?m:void 0,"aria-controls":l?f:void 0,"aria-label":`${p}: ${e.name}`,className:`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-start outline-none hover:bg-surface-subtle focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52] disabled:cursor-default disabled:hover:bg-transparent`,children:[(0,z.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:u?(0,z.jsx)(ce,{className:`h-3.5 w-3.5 text-error-500`}):d?(0,z.jsx)(M,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,z.jsx)(y,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,z.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-xs text-ink`,children:e.name}),e.durationMs!==void 0&&(0,z.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:ke(e.durationMs)}),l&&(0,z.jsx)(v,{"aria-hidden":`true`,className:I(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,m&&`rotate-180`)})]}),l&&m&&(0,z.jsxs)(`div`,{id:f,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,z.jsx)(`pre`,{dir:`ltr`,className:`max-h-48 overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:o}),s&&(0,z.jsx)(`pre`,{dir:`ltr`,className:I(`max-h-64 overflow-auto whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed`,u?`text-error-600`:`text-ink-muted`),children:s})]})]})}var Ne=e=>{let t=e.split(`
|
|
3
|
-
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n)return n}return``};function U({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,R.useState)(!1),a=t&&!r?Ne(e):``;return(0,z.jsxs)(`details`,{"data-testid":`work-live-reasoning`,open:r,onToggle:e=>i(e.currentTarget.open),className:`group overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,z.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-1 px-3 py-2 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-3 text-xs font-medium text-ink-muted`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(P,{className:I(`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`,t&&`animate-pulse-subtle motion-reduce:animate-none`)}),t?(0,z.jsxs)(`span`,{className:`animate-shimmer truncate bg-gradient-to-r from-ink-subtle via-ink to-ink-subtle bg-[length:200%_100%] bg-clip-text text-transparent motion-reduce:animate-none motion-reduce:bg-none motion-reduce:text-ink-muted`,children:[n(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),`…`]}):(0,z.jsx)(`span`,{className:`truncate`,children:n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,z.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),a&&(0,z.jsx)(`span`,{dir:`auto`,"data-testid":`work-live-reasoning-preview`,className:`block truncate text-[11px] leading-relaxed text-ink-subtle`,children:a})]}),(0,z.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,z.jsx)(be,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var W=(e,t,n)=>e===`queued`||e===`preparing`?t(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):e===`using_tool`?n?.name?`${t(`work.activity.toolActivity`,{defaultValue:`Tool activity`})} · ${n.name}`:t(`work.activity.toolActivity`,{defaultValue:`Tool activity`}):e===`completed`?t(`work.statusLabels.complete`,{defaultValue:`Complete`}):e===`needs_input`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`failed`?t(`work.statusLabels.error`,{defaultValue:`Error`}):e===`cancelled`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`responding`?t(`work.status.running`,{defaultValue:`Working in the local workspace…`}):t(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),Pe=(e,t)=>{if(e===`connecting`)return t(`work.live.connecting`,{defaultValue:`Connecting to live updates…`});if(e===`reconnecting`)return t(`work.live.reconnecting`,{defaultValue:`Reconnecting to live updates…`});if(e===`error`)return t(`work.live.unavailable`,{defaultValue:`Live updates unavailable`})};function Fe({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=Pe(e.connection,n)||W(e.phase,n,r),a=!e.terminal,o=e.usage?.outputTokens,s=e.reasoning+e.response,l=o!==void 0&&o>0?o:s?Ae(s):o,u=(o===void 0||o===0)&&!!s&&l!==void 0,d=e.usage?.tokensPerSecond;return(0,z.jsxs)(`section`,{"data-testid":`work-live-run`,"data-run-id":e.runId,"data-phase":e.phase,"aria-busy":a||void 0,className:I(`min-w-0`,t===`activity`&&`rounded-2xl border border-line bg-surface p-3 shadow-subtle`),children:[(0,z.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:I(`h-2 w-2 shrink-0 rounded-full`,e.phase===`failed`?`bg-[rgb(255,61,129)]`:e.phase===`completed`?`bg-[rgb(76,212,117)]`:e.phase===`needs_input`||e.phase===`cancelled`?`bg-[rgb(255,204,0)]`:e.connection===`error`?`bg-[rgb(255,61,129)]`:`bg-[rgb(48,121,255)]`,a&&`animate-pulse motion-reduce:animate-none`)}),(0,z.jsx)(`span`,{dir:`auto`,title:e.connectionError,className:`min-w-0 flex-1 truncate font-medium text-ink-muted`,children:i}),e.round!==void 0&&(0,z.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,z.jsx)(je,{run:e})]}),t===`conversation`&&(0,z.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,z.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,children:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line bg-surface-raised px-2 py-1 text-[10px] text-ink-muted`,children:[(0,z.jsx)(O,{className:`h-3 w-3 text-[#ff7b52]`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{dir:`auto`,children:n(`work.live.skillsLoaded`,{count:e.skills.length,defaultValue:`Workspace skills · {{count}}`})})]})}),t===`conversation`?e.timeline.length>0&&(0,z.jsx)(`div`,{"data-testid":`work-live-timeline`,className:`space-y-2`,children:e.timeline.map((t,n)=>{let r=n===e.timeline.length-1;if(t.kind===`reasoning`)return(0,z.jsx)(U,{content:t.text,streaming:a&&r},`segment-${n}`);if(t.kind===`tool`){let n=e.tools.find(e=>e.id===t.toolId);return n?(0,z.jsx)(Me,{tool:n,expandedByDefault:n.status===`error`},n.id):null}return(0,z.jsx)(be,{content:t.text,isStreaming:a&&r,className:`text-ink`},`segment-${n}`)})}):e.tools.length>0&&(0,z.jsx)(`div`,{"data-testid":`work-live-tools`,className:`space-y-1.5`,children:e.tools.map(e=>(0,z.jsx)(Me,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),e.error&&(0,z.jsxs)(`div`,{role:`alert`,dir:`auto`,className:`mt-3 flex items-start gap-2 rounded-xl border border-error-500/30 bg-error-500/10 px-3 py-2.5 text-xs leading-relaxed text-error-600`,children:[(0,z.jsx)(ce,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{children:e.error})]}),(l!==void 0||d!==void 0)&&(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-line pt-2 text-[10px] tabular-nums text-ink-subtle`,children:[l!==void 0&&(0,z.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,z.jsxs)(`bdi`,{dir:`ltr`,children:[u&&`≈`,l.toLocaleString()]})]}),d!==void 0&&(0,z.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,z.jsxs)(`bdi`,{dir:`ltr`,children:[d.toFixed(1),` t/s`]})]})]}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,z.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:320ms] motion-reduce:animate-none`})]}),t===`activity`&&e.tools.length===0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,z.jsx)(x,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}function G({role:e,user:t,size:n=`message`}){let[r,i]=(0,R.useState)(null);if(e===`assistant`)return(0,z.jsx)(`div`,{role:`img`,"aria-label":`Libre WebUI`,"data-testid":`work-assistant-avatar`,className:I(`flex shrink-0 items-center justify-center rounded-full border border-line bg-surface-raised shadow-subtle`,n===`empty`?`mx-auto mb-4 h-12 px-3`:`mt-0.5 h-8 px-2`),children:(0,z.jsx)(`span`,{"aria-hidden":`true`,className:I(`libre-brand text-ink`,n===`empty`?`text-sm`:`text-[11px]`),children:`Libre`})});let a=t?.username||`User`,o=t?.avatar?.trim()||``,s=!!o&&o!==r;return(0,z.jsx)(`div`,{role:s?void 0:`img`,"aria-label":s?void 0:a,"data-testid":`work-user-avatar`,className:I(`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full`,s?`border border-line bg-surface-raised`:`bg-ink text-ink-inverse`),title:a,children:s?(0,z.jsx)(`img`,{src:o,alt:a,className:`h-full w-full object-cover`,onError:()=>i(o)}):t?(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,z.jsx)(N,{"aria-hidden":`true`,className:`h-4 w-4`})})}var Ie=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t},Le=e=>{let t=e.metadata?.toolCallId;return typeof t==`string`&&t?t:null},Re=(e,t,n)=>{let r=e??t,i=t?.kind===`error`||t?.metadata?.isError===!0||!t&&r?.kind===`error`,a=t?.metadata?.durationMs;return{id:(e??t)?.id??`tool`,name:r?Ie(r,n):n,status:i?`error`:`completed`,arguments:e?.metadata,output:t?.content||(!t&&e?e.content:void 0),durationMs:typeof a==`number`?a:void 0}},K=(e,t)=>{let n=[],r=new Map,i=(e,t)=>{let r=n[n.length-1];return r?.item.type===`tools`?(r.item.tools.push(e),r.item.tools.length-1):(n.push({key:t,item:{type:`tools`,tools:[e]}}),0)};for(let a of e){if(a.kind===`reasoning`){n.push({key:a.id,item:{type:`reasoning`,message:a}});continue}if(a.role!==`tool`&&a.kind===`message`){n.push({key:a.id,item:{type:`message`,message:a}});continue}let e=Le(a);if(a.kind===`tool_call`&&e){let o=i(Re(a,void 0,t),a.id);r.set(e,{itemIndex:n.length-1,toolIndex:o,call:a});continue}if(a.kind===`tool_result`&&e){let i=r.get(e);if(i){let o=n[i.itemIndex];if(o.item.type===`tools`){o.item.tools[i.toolIndex]=Re(i.call,a,t),r.delete(e);continue}}}i(Re(a.kind===`tool_call`?a:void 0,a.kind===`tool_call`?void 0:a,t),a.id)}return n};function ze({message:e}){let{t}=c();return(0,z.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-14 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-ink-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(P,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,z.jsx)(`span`,{className:`truncate`,children:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,z.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,z.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-xs leading-relaxed text-ink-muted`,children:e.content})]})}function Be({task:e,user:t,loading:n,loadingOlder:r,liveRun:i,onLoadOlder:a}){let{t:o}=c(),s=(0,R.useRef)(null),l=(0,R.useRef)(!0),[u,d]=(0,R.useState)(!1),f=(0,R.useMemo)(()=>[...e.messages||[]].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id)),[e.messages]),p=i?.runId,m=(0,R.useMemo)(()=>K(f.filter(e=>!(p&&e.runId===p&&e.role!==`user`)),o(`work.activity.toolActivity`,{defaultValue:`Tool activity`})),[p,f,o]),h=[...f].reverse().find(e=>e.role===`assistant`&&e.kind===`message`)?.id;(0,R.useEffect)(()=>{l.current=!0;let e=s.current;e&&(e.scrollTop=e.scrollHeight);let t=window.requestAnimationFrame(()=>d(!1));return()=>window.cancelAnimationFrame(t)},[e.id]),(0,R.useEffect)(()=>{let e=s.current,t;return e&&l.current?(e.scrollTop=e.scrollHeight,t=window.requestAnimationFrame(()=>d(!1))):e&&i&&(t=window.requestAnimationFrame(()=>d(!0))),()=>{t!==void 0&&window.cancelAnimationFrame(t)}},[i,f,e.status]);let _=async()=>{let e=s.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;l.current=!1;try{await a(),requestAnimationFrame(()=>{let e=s.current;e&&(e.scrollTop=n+e.scrollHeight-t)})}catch{}};return n&&f.length===0?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,z.jsx)(M,{className:`h-6 w-6 animate-spin`})}):(0,z.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,z.jsx)(`div`,{ref:s,onScroll:e=>{let t=e.currentTarget;l.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,l.current&&d(!1)},className:`min-h-0 flex-1 overflow-y-auto`,children:(0,z.jsx)(`div`,{className:`mx-auto flex min-h-full max-w-3xl flex-col px-4 py-6 md:px-6`,children:f.length===0&&!i?(0,z.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,z.jsx)(G,{role:`assistant`,size:`empty`}),(0,z.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:o(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,z.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-ink-muted`,children:o(`work.conversation.empty`,{defaultValue:`Continue the task below. This conversation and its files stay attached to this workspace.`})})]}):(0,z.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,z.jsx)(`div`,{className:`flex justify-center`,children:(0,z.jsxs)(`button`,{type:`button`,"data-testid":`work-load-older-messages`,disabled:r,onClick:()=>void _(),className:`inline-flex items-center gap-2 rounded-lg border border-line bg-surface-raised px-3 py-1.5 text-xs font-medium text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink disabled:cursor-not-allowed disabled:opacity-60`,children:[r&&(0,z.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}),o(`work.conversation.loadOlder`,{defaultValue:`Load older messages`})]})}),m.map(({key:n,item:r})=>{if(r.type===`reasoning`)return(0,z.jsx)(ze,{message:r.message},n);if(r.type===`tools`)return(0,z.jsx)(`div`,{className:`ms-14 space-y-1.5`,children:r.tools.map(e=>(0,z.jsx)(Me,{tool:e,expandedByDefault:!1},e.id))},n);let i=r.message,a=i.role===`user`,o=!a&&e.status===`running`&&i.id===h&&i.runId===e.activeRun?.id;return(0,z.jsxs)(`article`,{className:I(`flex gap-3`,a&&`flex-row-reverse`),children:[(0,z.jsx)(G,{role:a?`user`:`assistant`,user:a?t:void 0}),(0,z.jsx)(`div`,{className:I(`min-w-0 max-w-[88%]`,a&&`rounded-2xl rounded-se-md bg-ink px-4 py-2.5 text-ink-inverse`),children:a?(0,z.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:i.content}):o?(0,z.jsx)(be,{content:i.content,className:`text-ink`}):(0,z.jsx)(Ce,{content:i.content,className:`text-sm text-ink`})})]},i.id)}),i&&(0,z.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,z.jsx)(G,{role:`assistant`}),(0,z.jsx)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:(0,z.jsx)(Fe,{run:i})})]}),!i&&(e.status===`preparing`||e.status===`running`)&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 ps-14 text-xs text-ink-muted`,children:[(0,z.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}),e.status===`preparing`?o(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):o(`work.status.running`,{defaultValue:`Working in the local workspace…`})]})]})})}),u&&(0,z.jsxs)(`button`,{type:`button`,"data-testid":`work-new-activity-button`,onClick:()=>{let e=s.current;e&&(e.scrollTop=e.scrollHeight),l.current=!0,d(!1)},className:`absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-line bg-surface-overlay/95 px-3 py-2 text-xs font-medium text-ink shadow-overlay backdrop-blur transition-colors hover:bg-surface-raised`,children:[(0,z.jsx)(g,{className:`h-3.5 w-3.5`}),o(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var q=45,Ve=30,He=70,Ue=360,We=480,Ge=9,J=2,Ke=10,qe=`libre-webui-work-split:`,Je=(e,t,n)=>Math.min(n,Math.max(t,e)),Ye=e=>`${qe}${encodeURIComponent(e||`local`)}`,Xe=e=>{if(typeof window>`u`)return q;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return q;let n=Number(t);return Number.isFinite(n)?Je(n,Ve,He):q}catch{return q}},Ze=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},Qe=e=>{let t=Math.max(0,e-Ge);if(t===0)return{min:Ve,max:He};let n=Math.max(Ve,Ue/t*100),r=Math.min(He,(t-We)/t*100);if(n<=r)return{min:n,max:r};let i=Je(Ue/840*100,Ve,He);return{min:i,max:i}},Y=(e,t)=>Je(e,t.min,t.max);function $e({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=Se(o.language),l=Ye(n),[u,d]=(0,R.useState)(()=>({storageKey:l,percent:Xe(l)})),[f,p]=(0,R.useState)(0),[m,h]=(0,R.useState)(!1),g=(0,R.useRef)(null),_=(0,R.useRef)(null),v=(0,R.useRef)(null),y=(0,R.useRef)(l),b=(0,R.useRef)(u.percent),x=(0,R.useRef)(null),S=u.storageKey===l?u.percent:Xe(l),C=(0,R.useMemo)(()=>Qe(f),[f]),w=Y(S,C),T=Math.round(w),E=100-T,D=(0,R.useCallback)(e=>{d({storageKey:l,percent:e})},[l]),O=(0,R.useCallback)(e=>{b.current=Y(e,Qe(g.current?.getBoundingClientRect().width??0)),x.current===null&&(x.current=window.requestAnimationFrame(()=>{x.current=null,D(b.current)}))},[D]),k=(0,R.useCallback)(()=>{if(v.current===null&&!m)return;x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null);let e=g.current?.getBoundingClientRect().width??0,t=Y(b.current,Qe(e));b.current=t,D(t),Ze(y.current,t);let n=v.current;v.current=null,n!==null&&_.current?.hasPointerCapture(n)&&_.current.releasePointerCapture(n),h(!1)},[m,D]),ee=(0,R.useCallback)(e=>{let t=g.current?.getBoundingClientRect();if(!t)return b.current;let n=Math.max(1,t.width-Ge);return((s?t.right-e:e-t.left)-Ge/2)/n*100},[s]),te=e=>{e.button!==0||!e.isPrimary||(e.preventDefault(),e.stopPropagation(),v.current=e.pointerId,y.current=l,b.current=w,e.currentTarget.setPointerCapture(e.pointerId),h(!0))},A=(0,R.useCallback)(e=>{let t=Y(e,C);b.current=t,D(t),Ze(l,t)},[C,D,l]),ne=(0,R.useCallback)(()=>{A(q)},[A]),re=e=>{let t=e.shiftKey?Ke:J,n=null;e.key===`ArrowLeft`?n=w+(s?t:-t):e.key===`ArrowRight`?n=w+(s?-t:t):e.key===`Home`?n=C.min:e.key===`End`?n=C.max:e.key===`Enter`&&(n=q),n!==null&&(e.preventDefault(),A(n))};(0,R.useEffect)(()=>{let e=g.current;if(!e)return;if(typeof ResizeObserver>`u`){let t=()=>p(e.getBoundingClientRect().width);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}let t=new ResizeObserver(e=>{let t=e[0];t&&p(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]),(0,R.useEffect)(()=>{if(!m)return;let e=document.body.style.cursor,t=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let n=e=>{e.pointerId===v.current&&(e.preventDefault(),O(ee(e.clientX)))},r=e=>{e.pointerId===v.current&&k()};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),window.addEventListener(`blur`,k),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`blur`,k),document.body.style.cursor=e,document.body.style.userSelect=t}},[k,m,ee,O]),(0,R.useEffect)(()=>()=>{x.current!==null&&window.cancelAnimationFrame(x.current),v.current!==null&&Ze(y.current,b.current)},[]);let ie={gridTemplateColumns:`minmax(0, ${w}fr) ${Ge}px minmax(0, ${100-w}fr)`};return(0,z.jsxs)(`div`,{ref:g,"data-testid":`work-split-pane`,"data-split-percent":w.toFixed(2),"data-resizing":m?`true`:`false`,className:I(`relative flex min-h-0 min-w-0 flex-1 overflow-hidden xl:grid`,i),style:ie,children:[(0,z.jsx)(`section`,{id:`work-conversation-panel`,"data-testid":`work-conversation-panel`,className:I(`min-h-0 min-w-0 flex-1 flex-col bg-transparent xl:flex`,r===`conversation`?`flex`:`hidden`),children:e}),(0,z.jsxs)(`div`,{ref:_,role:`separator`,"aria-orientation":`vertical`,"aria-controls":`work-conversation-panel work-workspace-panel`,"aria-label":a(`work.workspace.resize`,{defaultValue:`Resize conversation and workspace`}),"aria-valuemin":Math.round(C.min),"aria-valuemax":Math.round(C.max),"aria-valuenow":T,"aria-valuetext":a(`work.workspace.splitSize`,{conversation:T,workspace:E,defaultValue:`Conversation {{conversation}}%, workspace {{workspace}}%`}),title:a(`work.workspace.resizeHint`,{defaultValue:`Drag to resize. Use arrow keys for precise control. Double-click or press Enter to reset.`}),tabIndex:0,"data-testid":`work-split-resizer`,onPointerDown:te,onDoubleClick:ne,onKeyDown:re,className:I(`group relative z-40 hidden h-full cursor-col-resize touch-none select-none items-center justify-center outline-none xl:flex`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52]`),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:I(`pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-line transition-colors`,`group-hover:bg-[#ff7b52] group-focus-visible:bg-[#ff7b52]`,m&&`bg-[#ff7b52]`)}),(0,z.jsx)(`span`,{"aria-hidden":`true`,className:I(`pointer-events-none relative h-14 w-1 rounded-full bg-ink-subtle/50 opacity-60 transition-[height,background-color,opacity]`,`group-hover:h-20 group-hover:bg-[#ff7b52] group-hover:opacity-100`,`group-focus-visible:h-20 group-focus-visible:bg-[#ff7b52] group-focus-visible:opacity-100`,m&&`h-20 bg-[#ff7b52] opacity-100`)})]}),(0,z.jsx)(`section`,{id:`work-workspace-panel`,"data-testid":`work-workspace-panel`,className:I(`min-h-0 min-w-0 flex-1 flex-col bg-surface-raised/85 backdrop-blur-xl xl:flex`,r===`workspace`?`flex`:`hidden`),children:t}),m&&(0,z.jsx)(`div`,{"data-testid":`work-split-drag-shield`,"aria-hidden":`true`,className:`absolute inset-0 z-30 hidden cursor-col-resize select-none xl:block`})]})}var et=1e5,X=4e3,tt={bash:`bash`,c:`c`,cc:`cpp`,cjs:`javascript`,cpp:`cpp`,cs:`csharp`,csh:`bash`,css:`css`,cts:`typescript`,cxx:`cpp`,diff:`diff`,go:`go`,h:`c`,hpp:`cpp`,htm:`markup`,html:`markup`,java:`java`,js:`javascript`,json:`json`,json5:`json`,jsonc:`json`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`css`,md:`markdown`,mdx:`markdown`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,py:`python`,rb:`ruby`,rs:`rust`,scss:`css`,sh:`bash`,sql:`sql`,svg:`markup`,swift:`swift`,ts:`typescript`,tsx:`tsx`,xml:`markup`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},nt={".bashrc":`bash`,".zshrc":`bash`},rt={cjs:{family:`babel`,parser:`babel`},css:{family:`postcss`,parser:`css`},cts:{family:`typescript`,parser:`typescript`},htm:{family:`html`,parser:`html`},html:{family:`html`,parser:`html`},js:{family:`babel`,parser:`babel`},json:{family:`babel`,parser:`json`},json5:{family:`babel`,parser:`json5`},jsonc:{family:`babel`,parser:`json`},jsx:{family:`babel`,parser:`babel`},less:{family:`postcss`,parser:`less`},md:{family:`markdown`,parser:`markdown`},mdx:{family:`markdown`,parser:`mdx`},mjs:{family:`babel`,parser:`babel`},mts:{family:`typescript`,parser:`typescript`},scss:{family:`postcss`,parser:`scss`},ts:{family:`typescript`,parser:`typescript`},tsx:{family:`typescript`,parser:`typescript`},yaml:{family:`yaml`,parser:`yaml`},yml:{family:`yaml`,parser:`yaml`}},it=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,at=e=>{let t=it(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},ot=e=>nt[it(e)]??tt[at(e)]??`text`,st=e=>rt[at(e)],ct=e=>st(e)!==void 0,lt=e=>{if(e.length>1e5)return!1;let t=1;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10&&(t+=1,t>4e3))return!1;return!0},Z=async e=>(await e).default,ut=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),Z(a(()=>import(`./estree-BFya-bSu.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))]);case`typescript`:return Promise.all([Z(a(()=>import(`./typescript-d0TUM2-0.js`),__vite__mapDeps([18,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17]))),Z(a(()=>import(`./estree-BFya-bSu.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))]);case`postcss`:return[await Z(a(()=>import(`./postcss-DSDkwgFE.js`),__vite__mapDeps([19,1,2,3])))];case`html`:{let e=[await Z(a(()=>import(`./html-DJot0Wwf.js`),__vite__mapDeps([20,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))];return/<script\b/i.test(t)&&e.push(await Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),await Z(a(()=>import(`./estree-BFya-bSu.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))),/<script\b[^>]*\blang\s*=\s*["']?(?:ts|typescript)/i.test(t)&&e.push(await Z(a(()=>import(`./typescript-d0TUM2-0.js`),__vite__mapDeps([18,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))),/<style\b/i.test(t)&&e.push(await Z(a(()=>import(`./postcss-DSDkwgFE.js`),__vite__mapDeps([19,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await Z(a(()=>import(`./markdown-CXwWsPYG.js`),__vite__mapDeps([21,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))],r=e=>RegExp(`^(?: {0,3})(?:\`{3,}|~{3,})\\s*(?:${e})(?:\\s|$)`,`im`).test(t);return e.parser===`mdx`&&n.push(await Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),await Z(a(()=>import(`./estree-BFya-bSu.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))),r(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),await Z(a(()=>import(`./estree-BFya-bSu.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))),r(`ts|tsx|typescript`)&&n.push(await Z(a(()=>import(`./typescript-d0TUM2-0.js`),__vite__mapDeps([18,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17]))),await Z(a(()=>import(`./estree-BFya-bSu.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])))),r(`css|scss|less`)&&n.push(await Z(a(()=>import(`./postcss-DSDkwgFE.js`),__vite__mapDeps([19,1,2,3])))),r(`html`)&&n.push(await Z(a(()=>import(`./html-DJot0Wwf.js`),__vite__mapDeps([20,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17]))),await Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),await Z(a(()=>import(`./estree-BFya-bSu.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17]))),await Z(a(()=>import(`./typescript-d0TUM2-0.js`),__vite__mapDeps([18,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17]))),await Z(a(()=>import(`./postcss-DSDkwgFE.js`),__vite__mapDeps([19,1,2,3])))),r(`yaml|yml`)&&n.push(await Z(a(()=>import(`./yaml-mLy9chOK.js`),__vite__mapDeps([22,1,2,3])))),[...new Set(n)]}case`yaml`:return[await Z(a(()=>import(`./yaml-mLy9chOK.js`),__vite__mapDeps([22,1,2,3])))]}},dt=async(e,t)=>{let n=st(e);if(!n)throw Error(`Formatting is not supported for “${it(e)||e}”.`);if(!lt(t))throw Error(`Could not format “${it(e)||e}”: files are limited to ${et.toLocaleString()} characters and ${X.toLocaleString()} lines.`);try{let[{format:e},r]=await Promise.all([a(()=>import(`./standalone-C0NjJpWr.js`),__vite__mapDeps([23,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17])),ut(n,t)]);return await e(t,{parser:n.parser,plugins:r,tabWidth:2,useTabs:!1})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not format “${it(e)||e}”: ${n}`)}},ft=(0,R.lazy)(async()=>({default:(await a(()=>import(`./OptimizedSyntaxHighlighter-Ci9sRc78.js`).then(e=>e.n),__vite__mapDeps([24,2,3,25]))).OptimizedSyntaxHighlighter})),pt=8e3,mt=400,ht=500;function Q({path:e,value:t,ariaLabel:n,disabled:r=!1,onChange:i,onSaveShortcut:a,onFormatShortcut:o}){let{t:s}=c(),l=ye(e=>e.theme.mode===`dark`),u=(0,R.useRef)(null),d=(0,R.useRef)(null),[f,p]=(0,R.useState)(``),m=(0,R.useMemo)(()=>ot(e),[e]),h=(0,R.useMemo)(()=>{if(t.length>pt)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>mt));n+=1);return e},[t]),g=t.length>pt||h>mt,_=m!==`text`&&!g,v=_&&f===t;return(0,R.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>p(t),ht);return()=>window.clearTimeout(e)},[_,e,t]),(0,R.useLayoutEffect)(()=>{!v||!u.current||!d.current||(u.current.style.transform=`translate3d(${-d.current.scrollLeft}px, ${-d.current.scrollTop}px, 0)`)},[v,e]),(0,z.jsxs)(`div`,{dir:`ltr`,className:I(`relative min-h-0 flex-1 overflow-hidden bg-surface focus-within:ring-1 focus-within:ring-inset focus-within:ring-primary-500/60`,r&&`opacity-60`),"data-language":m,"data-highlighted":v?`true`:`false`,children:[v&&(0,z.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,z.jsx)(`div`,{ref:u,"data-testid":`work-file-highlight-content`,className:`min-h-full min-w-full origin-top-left will-change-transform`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`pre`,{className:`m-0 min-h-full min-w-full whitespace-pre p-4 text-left font-mono text-[12px] leading-5 text-ink`,children:t||``}),children:(0,z.jsx)(ft,{language:m,isDark:l,backgroundColor:`transparent`,borderRadius:0,customStyle:{margin:0,minHeight:`100%`,minWidth:`100%`,width:`max-content`,overflow:`visible`,padding:`1rem`,fontSize:`12px`,lineHeight:`20px`,tabSize:2,whiteSpace:`pre`},children:f||``})})})}),(0,z.jsx)(`textarea`,{ref:d,"data-testid":`work-file-editor`,"data-language":m,"aria-label":n,value:t,onChange:e=>i(e.target.value),onScroll:e=>{u.current&&(u.current.style.transform=`translate3d(${-e.currentTarget.scrollLeft}px, ${-e.currentTarget.scrollTop}px, 0)`)},onKeyDown:e=>{let t=e.key.toLowerCase();if((e.metaKey||e.ctrlKey)&&t===`s`){e.preventDefault(),a();return}e.altKey&&e.shiftKey&&t===`f`&&(e.preventDefault(),o())},disabled:r,spellCheck:!1,wrap:`off`,className:I(`absolute inset-0 z-10 h-full w-full resize-none overflow-auto whitespace-pre border-0 bg-transparent p-4 text-left font-mono text-[12px] leading-5 outline-none selection:bg-primary-500/25 disabled:cursor-not-allowed`,v?`text-transparent caret-ink`:`text-ink`),style:v?{WebkitTextFillColor:`transparent`,caretColor:`rgb(var(--color-ink))`,tabSize:2}:{tabSize:2}}),g&&(0,z.jsx)(`span`,{dir:`auto`,className:`pointer-events-none absolute bottom-2 end-3 z-20 rounded-md border border-line bg-surface-overlay/90 px-2 py-1 text-[10px] text-ink-muted shadow-subtle`,title:s(`work.files.highlightPaused`,{defaultValue:`Live highlighting is paused for large files to keep editing responsive.`}),children:s(`work.files.plainTextLarge`,{defaultValue:`Plain text · large file`})})]})}var gt=4e6,_t=e=>{if(e===``)return[];let t=e.split(`
|
|
4
|
-
`);return t[t.length-1]===``&&t.pop(),t},vt=(e,t)=>{let n=_t(e),r=_t(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=n.slice(i,n.length-a),s=r.slice(i,r.length-a),c=[];for(let e=0;e<i;e+=1)c.push({type:`context`,text:n[e],beforeLine:e+1,afterLine:e+1});let l=$(o,s);for(let e of l){let t={type:e.type,text:e.text};e.beforeLine!==void 0&&(t.beforeLine=e.beforeLine+i),e.afterLine!==void 0&&(t.afterLine=e.afterLine+i),c.push(t)}for(let e=0;e<a;e+=1){let t=n.length-a+e,i=r.length-a+e;c.push({type:`context`,text:n[t],beforeLine:t+1,afterLine:i+1})}return c},$=(e,t)=>{if(e.length===0&&t.length===0)return[];if(e.length>0&&t.length>0&&e.length*t.length>gt)return[...e.map((e,t)=>({type:`removed`,text:e,beforeLine:t+1})),...t.map((e,t)=>({type:`added`,text:e,afterLine:t+1}))];let n=e.length+1,r=t.length+1,i=new Uint32Array(n*r);for(let n=e.length-1;n>=0;--n)for(let a=t.length-1;a>=0;--a)i[n*r+a]=e[n]===t[a]?i[(n+1)*r+a+1]+1:Math.max(i[(n+1)*r+a],i[n*r+a+1]);let a=[],o=0,s=0;for(;o<e.length&&s<t.length;)e[o]===t[s]?(a.push({type:`context`,text:e[o],beforeLine:o+1,afterLine:s+1}),o+=1,s+=1):i[(o+1)*r+s]>=i[o*r+s+1]?(a.push({type:`removed`,text:e[o],beforeLine:o+1}),o+=1):(a.push({type:`added`,text:t[s],afterLine:s+1}),s+=1);for(;o<e.length;)a.push({type:`removed`,text:e[o],beforeLine:o+1}),o+=1;for(;s<t.length;)a.push({type:`added`,text:t[s],afterLine:s+1}),s+=1;return a},yt=e=>{let t=0,n=0;for(let r of e)r.type===`added`&&(t+=1),r.type===`removed`&&(n+=1);return{added:t,removed:n}},bt=3,xt=e=>{let t=Array(e.length).fill(!1);for(let n=0;n<e.length;n+=1){if(e[n].type===`context`)continue;let r=Math.max(0,n-bt),i=Math.min(e.length-1,n+bt);for(let e=r;e<=i;e+=1)t[e]=!0}let n=[],r=0;for(let i=0;i<e.length;i+=1){if(!t[i]){r+=1;continue}r>0&&(n.push({type:`fold`,count:r}),r=0),n.push({type:`line`,line:e[i]})}return r>0&&n.push({type:`fold`,count:r}),n};function St({lines:e,ariaLabel:t}){let{t:n}=c();return(0,z.jsx)(`div`,{dir:`ltr`,role:`region`,"aria-label":t,"data-testid":`work-file-diff`,className:`min-h-0 flex-1 overflow-auto bg-surface font-mono text-[12px] leading-5`,children:(0,z.jsx)(`table`,{className:`w-full border-collapse`,children:(0,z.jsx)(`tbody`,{children:(0,R.useMemo)(()=>xt(e),[e]).map((e,t)=>e.type===`fold`?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:3,className:`select-none border-y border-line bg-surface-subtle/70 px-4 py-1 text-center text-[11px] text-ink-subtle`,children:n(`work.files.diffFolded`,{count:e.count,defaultValue:`{{count}} unchanged lines`})})},`fold-${t}`):(0,z.jsxs)(`tr`,{className:I(e.line.type===`added`&&`bg-[rgb(76,212,117)]/[0.12] text-ink`,e.line.type===`removed`&&`bg-[rgb(255,61,129)]/[0.10] text-ink-muted`,e.line.type===`context`&&`text-ink-muted`),children:[(0,z.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.line.beforeLine??``}),(0,z.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.line.afterLine??``}),(0,z.jsxs)(`td`,{className:`w-full whitespace-pre-wrap break-all px-3 align-top`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:I(`me-2 inline-block w-3 select-none text-center`,e.line.type===`added`&&`text-[rgb(46,164,79)]`,e.line.type===`removed`&&`text-[rgb(255,61,129)]`),children:e.line.type===`added`?`+`:e.line.type===`removed`?`−`:``}),e.line.text||``]})]},`line-${t}`))})})})}var Ct=(e,t)=>{if(e.success&&e.data)return e.data;throw Error(e.error||t)},wt=(e,t)=>{let n=e?.response?.data?.error;return typeof n==`string`&&n?n:e instanceof Error&&e.message?e.message:t};function Tt({taskId:e,mutationsDisabled:t=!1,disabledReason:n}){let{t:r}=c(),[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(!0),[l,u]=(0,R.useState)(!1),[d,f]=(0,R.useState)(null),[m,h]=(0,R.useState)([]),[g,_]=(0,R.useState)(``),[v,x]=(0,R.useState)(``),[S,C]=(0,R.useState)(null),[w,T]=(0,R.useState)(!1),E=(0,R.useRef)(0),D=(0,R.useCallback)(async()=>{let t=++E.current;s(!0),f(null);try{let n=Ct(await F.getGitStatus(e),r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`}));if(t!==E.current)return;a(n),h([])}catch(e){if(t!==E.current)return;f(wt(e,r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})))}finally{t===E.current&&s(!1)}},[r,e]);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>void D(),0);return()=>{window.clearTimeout(e),E.current+=1}},[D]);let O=async(e,n)=>{if(t||l)return!1;u(!0),f(null);try{return a(Ct(await e(),r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}))),h([]),C(null),j.success(n),!0}catch(e){let t=wt(e,r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return f(t),j.error(t),!1}finally{u(!1)}},k=async t=>{T(!0),f(null);try{C(Ct(await F.getGitDiff(e,t),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}catch(e){f(wt(e,r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}finally{T(!1)}};if(o&&!i)return(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center text-ink-muted`,children:(0,z.jsx)(M,{className:`h-5 w-5 animate-spin`})});if(!i)return(0,z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,z.jsx)(ie,{className:`mb-3 h-8 w-8 text-error-500`}),(0,z.jsx)(`p`,{className:`max-w-sm text-xs leading-relaxed text-error-600`,children:d||r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})}),(0,z.jsxs)(L,{size:`sm`,variant:`secondary`,className:`mt-4`,onClick:()=>void D(),children:[(0,z.jsx)(p,{className:`h-3.5 w-3.5`}),r(`common.retry`,{defaultValue:`Retry`})]})]});if(!i.initialized)return(0,z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,z.jsx)(ie,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,z.jsx)(`h3`,{className:`text-sm font-medium text-ink`,children:r(`work.git.notInitialized`,{defaultValue:`Git is not initialized`})}),(0,z.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-relaxed text-ink-muted`,children:r(`work.git.initializeDescription`,{defaultValue:`Create a local repository for status, diffs, branches, and commits. No remote credentials are connected.`})}),d&&(0,z.jsx)(`p`,{className:`mt-3 text-xs text-error-600`,children:d}),(0,z.jsxs)(L,{"data-testid":`work-git-init-button`,size:`sm`,className:`mt-4 bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||l,onClick:()=>void O(()=>F.initializeGit(e),r(`work.git.initialized`,{defaultValue:`Git repository initialized.`})),children:[l?(0,z.jsx)(M,{className:`me-2 h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(A,{className:`me-2 h-3.5 w-3.5`}),r(`work.git.initialize`,{defaultValue:`Initialize Git`})]}),t&&n&&(0,z.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-subtle`,children:n})]});let ee=i.changes.filter(e=>e.staged).length,ne=i.changes.length>0;return(0,z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`work-git-panel`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-2`,children:[(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-lg bg-surface-subtle px-2 py-1 font-mono text-[11px] text-ink`,children:[(0,z.jsx)(ie,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate`,children:i.detached?r(`work.git.detached`,{defaultValue:`detached HEAD`}):i.branch||`main`})]}),(i.ahead>0||i.behind>0)&&(0,z.jsxs)(`span`,{className:`text-[10px] text-ink-muted`,children:[`↑`,i.ahead,` ↓`,i.behind]}),(0,z.jsxs)(`select`,{"data-testid":`work-git-branch-select`,"aria-label":r(`work.git.switchBranch`,{defaultValue:`Switch local branch`}),value:i.branch||``,disabled:t||l||ne,onChange:t=>{let n=t.target.value;!n||n===i.branch||O(()=>F.switchGitBranch(e,n),r(`work.git.branchSwitched`,{name:n,defaultValue:`Switched to {{name}}.`}))},className:`h-7 max-w-44 rounded-lg border border-line bg-surface px-2 text-[11px] text-ink outline-none disabled:opacity-50`,children:[i.detached&&(0,z.jsx)(`option`,{value:``,disabled:!0,children:r(`work.git.detached`,{defaultValue:`detached HEAD`})}),i.branches.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),(0,z.jsxs)(`div`,{className:`flex min-w-44 flex-1 items-center gap-1`,children:[(0,z.jsx)(`input`,{"data-testid":`work-git-branch-input`,value:v,maxLength:200,onChange:e=>x(e.target.value),placeholder:r(`work.git.newBranch`,{defaultValue:`New local branch`}),className:`h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,z.jsxs)(L,{"data-testid":`work-git-create-branch-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2`,disabled:t||l||!i.head||!v.trim(),onClick:()=>{let t=v.trim();O(()=>F.createGitBranch(e,t),r(`work.git.branchCreated`,{name:t,defaultValue:`Created {{name}}.`})).then(e=>{e&&x(``)})},children:[(0,z.jsx)(A,{className:`h-3.5 w-3.5`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:r(`work.git.createBranch`,{defaultValue:`Create`})})]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void D(),disabled:o||l,"aria-label":r(`common.refresh`,{defaultValue:`Refresh`}),className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink disabled:opacity-50`,children:(0,z.jsx)(p,{className:I(`h-3.5 w-3.5`,o&&`animate-spin`)})})]}),d&&(0,z.jsx)(`div`,{className:`border-b border-error-200 bg-error-50 px-3 py-2 text-xs text-error-700 dark:border-error-900/60 dark:bg-error-900/30 dark:text-error-300`,children:d}),t&&n&&(0,z.jsx)(`div`,{className:`border-b border-line px-3 py-1.5 text-[11px] text-ink-subtle`,children:n}),(0,z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[minmax(14rem,0.8fr)_minmax(18rem,1.2fr)_minmax(13rem,0.8fr)]`,children:[(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,z.jsxs)(`h3`,{className:`text-xs font-medium text-ink`,children:[r(`work.git.changes`,{defaultValue:`Changes`}),` `,(0,z.jsx)(`span`,{className:`text-ink-subtle`,children:i.changes.length})]}),(0,z.jsxs)(L,{"data-testid":`work-git-stage-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-[11px]`,disabled:t||l||m.length===0&&i.changes.length===0,onClick:()=>{let t=m.length>0?m:i.changes.map(e=>e.path);O(()=>F.stageGitPaths(e,t),r(`work.git.staged`,{defaultValue:`Changes staged.`}))},children:[(0,z.jsx)(y,{className:`h-3.5 w-3.5`}),m.length>0?r(`work.git.stageSelected`,{count:m.length,defaultValue:`Stage {{count}}`}):r(`work.git.stageAll`,{defaultValue:`Stage all`})]})]}),(0,z.jsx)(`div`,{className:`min-h-32 flex-1 overflow-y-auto px-2 pb-2`,children:i.changes.length===0?(0,z.jsx)(`p`,{className:`px-2 py-8 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):i.changes.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg hover:bg-surface-subtle`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":r(`work.git.selectPath`,{path:e.path,defaultValue:`Select {{path}}`}),checked:m.includes(e.path),onChange:t=>h(n=>t.target.checked?[...n,e.path]:n.filter(t=>t!==e.path)),className:`ms-2 h-3.5 w-3.5 accent-[#ff7b52]`}),(0,z.jsxs)(`button`,{type:`button`,"data-testid":`work-git-change`,onClick:()=>void k(e.path),className:`flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-start`,children:[(0,z.jsxs)(`span`,{dir:`ltr`,className:I(`w-5 shrink-0 font-mono text-[10px] font-semibold`,e.staged?`text-emerald-600`:`text-amber-600`),children:[e.indexStatus,e.workingTreeStatus]}),(0,z.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,title:e.path,children:e.path})]})]},`${e.path}:${e.originalPath||``}`))}),(0,z.jsxs)(`div`,{className:`border-t border-line p-2`,children:[(0,z.jsx)(`textarea`,{"data-testid":`work-git-commit-input`,value:g,maxLength:4e3,rows:2,onChange:e=>_(e.target.value),placeholder:r(`work.git.commitMessage`,{defaultValue:`Commit message`}),className:`w-full resize-none rounded-lg border border-line bg-surface px-2.5 py-2 text-xs text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,z.jsxs)(L,{"data-testid":`work-git-commit-button`,size:`sm`,className:`mt-1.5 w-full bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||l||ee===0||!g.trim(),onClick:()=>{let t=g.trim();O(()=>F.commitGit(e,t),r(`work.git.committed`,{defaultValue:`Commit created.`})).then(e=>{e&&_(``)})},children:[l&&(0,z.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}),r(`work.git.commit`,{defaultValue:`Commit staged changes`})]})]})]}),(0,z.jsxs)(`section`,{className:`flex min-h-48 min-w-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs font-medium text-ink`,children:[(0,z.jsx)(te,{className:`h-3.5 w-3.5`}),S?.path||r(`work.git.diff`,{defaultValue:`Diff preview`})]}),w?(0,z.jsx)(M,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):S?S.patch?(0,z.jsxs)(`pre`,{"data-testid":`work-git-diff`,dir:`ltr`,className:`min-h-0 flex-1 overflow-auto whitespace-pre p-3 text-left font-mono text-[11px] leading-relaxed text-ink`,children:[S.patch,S.truncated&&`
|
|
5
|
-
… diff truncated …`]}):(0,z.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.noDiff`,{defaultValue:`No textual diff is available yet. Untracked files appear after staging.`})}):(0,z.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.selectChange`,{defaultValue:`Select a changed file to inspect its diff.`})})]}),(0,z.jsxs)(`section`,{className:`min-h-36 overflow-y-auto p-3`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-ink`,children:[(0,z.jsx)(b,{className:`h-3.5 w-3.5`}),r(`work.git.history`,{defaultValue:`Local history`})]}),i.commits.length===0?(0,z.jsx)(`p`,{className:`py-6 text-center text-xs text-ink-muted`,children:r(`work.git.noCommits`,{defaultValue:`No commits yet.`})}):(0,z.jsx)(`ol`,{className:`space-y-2`,children:i.commits.map(e=>(0,z.jsxs)(`li`,{className:`rounded-lg border border-line bg-surface px-2.5 py-2`,children:[(0,z.jsx)(`p`,{dir:`auto`,className:`text-xs text-ink`,children:e.subject}),(0,z.jsxs)(`p`,{className:`mt-1 flex flex-wrap gap-x-2 text-[10px] text-ink-subtle`,children:[(0,z.jsx)(`span`,{dir:`ltr`,className:`font-mono`,children:e.shortHash}),(0,z.jsx)(`span`,{dir:`auto`,children:e.author}),(0,z.jsx)(`time`,{dateTime:e.authoredAt,children:new Date(e.authoredAt).toLocaleDateString()})]})]},e.hash))}),(0,z.jsx)(`p`,{className:`mt-4 border-t border-line pt-3 text-[10px] leading-relaxed text-ink-subtle`,children:r(`work.git.localOnly`,{defaultValue:`Local Git only. Push, pull, and pull requests require a separate trusted credential broker.`})})]})]})]})}var Et=`/ws/work-terminal`;function Dt(e,t){let n;if(t.protocol===`file:`)n=`ws://localhost:3001`;else if(t.apiBaseUrl)n=t.apiBaseUrl.replace(/\/api$/,``).replace(/^http:/,`ws:`).replace(/^https:/,`wss:`);else{let e=t.protocol===`https:`?`wss:`:`ws:`;n=t.production?`${e}//${t.host}`:`${e}//${t.hostname}:3001`}let r=new URL(`${n}${Et}`);return r.searchParams.set(`taskId`,e),t.token&&r.searchParams.set(`token`,t.token),r.toString()}function Ot(e){return Dt(e,{protocol:window.location.protocol,host:window.location.host,hostname:window.location.hostname,apiBaseUrl:void 0,production:!0,token:localStorage.getItem(`auth-token`)})}var kt={background:`#ffffff`,foreground:`#1f2328`,cursor:`#1f2328`,selectionBackground:`rgba(255, 123, 82, 0.28)`},At={background:`#0f1115`,foreground:`#e6e6e6`,cursor:`#ff7b52`,selectionBackground:`rgba(255, 123, 82, 0.32)`};function jt({taskId:t,active:n,disabledReason:r}){let{t:i}=c(),o=ye(e=>e.theme.mode===`dark`),s=(0,R.useRef)(null),l=(0,R.useRef)(null),u=(0,R.useRef)(null),d=(0,R.useRef)(null),[f,p]=(0,R.useState)(`idle`),[m,h]=(0,R.useState)(null),[g,_]=(0,R.useState)(0),v=(0,R.useCallback)(()=>{let e=d.current,t=u.current,n=l.current;if(!(!e||!t||!n||n.readyState!==WebSocket.OPEN)){try{e.fit()}catch{return}n.send(JSON.stringify({type:`resize`,cols:t.cols,rows:t.rows}))}},[]);(0,R.useEffect)(()=>{if(!n||r)return;let i=!1,c,f;return(async()=>{p(`connecting`),h(null);let[{Terminal:n},{FitAddon:r}]=await Promise.all([a(()=>import(`./xterm-DKl1QLiw.js`).then(t=>e(t.default,1)),__vite__mapDeps([26,2])),a(()=>import(`./addon-fit-Cj0_dfHF.js`).then(t=>e(t.default,1)),__vite__mapDeps([27,2]))]);if(await a(()=>Promise.resolve({}),__vite__mapDeps([28])),i||!s.current)return;c=new n({allowProposedApi:!0,convertEol:!1,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,fontSize:12,scrollback:5e3,theme:o?At:kt});let m=new r;c.loadAddon(m),c.open(s.current),u.current=c,d.current=m;try{m.fit()}catch{}f=new WebSocket(Ot(t)),f.binaryType=`arraybuffer`,l.current=f;let g=new TextDecoder;f.onmessage=e=>{if(typeof e.data!=`string`){c?.write(g.decode(new Uint8Array(e.data)));return}try{let t=JSON.parse(e.data);if(t.type===`ready`){p(`connected`),v(),c?.focus();return}if(t.type===`error`){p(`error`),h(t.message||null);return}t.type===`exit`&&p(`closed`)}catch{}},f.onclose=()=>{i||p(e=>e===`error`||e===`closed`?e:`closed`)},f.onerror=()=>{i||p(`error`)},c.onData(e=>{f?.readyState===WebSocket.OPEN&&f.send(JSON.stringify({type:`input`,data:e}))})})(),()=>{i=!0,f?.close(),l.current=null,c?.dispose(),u.current=null,d.current=null}},[n,r,g,o,v,t]),(0,R.useEffect)(()=>{let e=s.current;if(!e||!n)return;let t=new ResizeObserver(()=>v());return t.observe(e),()=>t.disconnect()},[n,v]);let y=()=>{l.current?.close(),_(e=>e+1)},b=r??(f===`error`?m??i(`work.terminal.failed`,{defaultValue:`The terminal session could not start.`}):f===`closed`?i(`work.terminal.closed`,{defaultValue:`Terminal session ended.`}):null);return(0,z.jsxs)(`div`,{"data-testid":`work-terminal-panel`,"data-status":r?`unavailable`:f,className:`relative flex min-h-0 flex-1 flex-col bg-surface`,children:[!r&&(0,z.jsx)(`div`,{ref:s,"data-testid":`work-terminal-surface`,dir:`ltr`,className:I(`min-h-0 flex-1 overflow-hidden p-2 text-left`,f!==`connected`&&`opacity-60`)}),f===`connecting`&&!r&&(0,z.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-xs text-ink-muted`,children:[(0,z.jsx)(M,{className:`h-4 w-4 animate-spin`}),i(`work.terminal.connecting`,{defaultValue:`Opening a shell in the sandbox…`})]}),b&&(0,z.jsxs)(`div`,{role:f===`error`?`alert`:void 0,className:`flex flex-col items-center gap-3 border-t border-line bg-surface-raised px-6 py-4 text-center`,children:[(0,z.jsx)(x,{className:`h-6 w-6 text-ink-subtle`}),(0,z.jsx)(`p`,{dir:`auto`,"data-testid":`work-terminal-status`,className:`max-w-md text-xs leading-relaxed text-ink-muted`,children:b}),!r&&(0,z.jsx)(L,{size:`sm`,"data-testid":`work-terminal-reconnect-button`,className:`h-8 rounded-lg bg-[#ff7b52] px-3 text-[#3d120c] hover:bg-[#ff7b52]/90`,onClick:y,children:i(`work.terminal.reconnect`,{defaultValue:`Reconnect`})})]})]})}var Mt=e=>{if(!e)return null;if(/^\/api\/work\/previews\/[A-Za-z0-9-]{1,100}\/\d{1,5}\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}\//.test(e))try{let t=new URL(ue,window.location.origin).origin;return new URL(e,`${t}/`).toString()}catch{return null}return null},Nt=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),t.join(`/`)},Pt=(e,t)=>{let n=e.metadata?.name??e.metadata?.toolName??e.metadata?.tool??e.metadata?.command;return typeof n==`string`&&n?n:t};function Ft({task:e,liveRun:t,files:n,selectedFile:r,loadingFiles:i,actionLoading:a,onLoadFiles:o,onLoadFile:s,onClearSelectedFile:u,onSaveFile:d,onStartPreview:f,onStopPreview:g,onDirtyChange:_,terminal:v}){let{t:y,i18n:b}=c(),O=Se(b.language),[k,te]=(0,R.useState)(`files`),[A,re]=(0,R.useState)(``),[N,oe]=(0,R.useState)(``),[se,ce]=(0,R.useState)(),[le,P]=(0,R.useState)(``),[ue,de]=(0,R.useState)(!1),[F,fe]=(0,R.useState)(!1),me=(0,R.useRef)(new Map),[he,ve]=(0,R.useState)(()=>new Map),ye=Mt(e.previewUrl),be=t?.runId,xe=t?.error,Ce=t?.tools,we=(0,R.useMemo)(()=>{let t=new Set(Ce?.map(e=>e.id)||[]);return(e.messages||[]).filter(e=>{if(e.kind===`reasoning`||e.role!==`tool`&&e.kind===`message`)return!1;if(!be||e.runId!==be)return!0;if(e.kind===`error`&&xe)return!1;let n=e.metadata?.toolCallId;return typeof n!=`string`||!t.has(n)})},[xe,be,Ce,e.messages]),Te=we.length+(Ce?.length||0),Ee=!!r&&N!==(r?.content??``),B=e.status===`preparing`||e.status===`running`,De=(0,R.useRef)(B),V=(0,R.useRef)(0),H=(0,R.useRef)(N),Oe=(0,R.useRef)(se),ke=(0,R.useRef)(r),Ae=(0,R.useRef)(e.id),je=(0,R.useRef)(o),Me=(0,R.useRef)(s),Ne=(0,R.useRef)(_),U=(0,R.useRef)(!0),W=r?he.get(r.path):void 0,Pe=(0,R.useMemo)(()=>r&&W!==void 0&&W!==r.content?vt(W,r.content):null,[W,r]),G=(0,R.useMemo)(()=>Pe?yt(Pe):null,[Pe]),Ie=!!(G&&(G.added>0||G.removed>0)),Le=r?ct(r.path):!1,Re=!r||lt(N),K=Le&ℜ(0,R.useEffect)(()=>{H.current=N,Oe.current=se,ke.current=r,Ae.current=e.id,Ne.current=_},[se,N,_,r,e.id]),(0,R.useEffect)(()=>{je.current=o,Me.current=s},[s,o]),(0,R.useEffect)(()=>(U.current=!0,()=>{U.current=!1,V.current+=1,Ne.current(!1)}),[]),(0,R.useEffect)(()=>{if(!De.current&&B&&ve(new Map(me.current)),De.current&&!B&&(je.current(A),r&&!Ee)){let e=++V.current,t=r.path,n=H.current,i=Oe.current;Me.current(t).then(r=>{if(!U.current||e!==V.current||r.path!==t||H.current!==n||Oe.current!==i)return;me.current.set(r.path,r.content);let a=he.get(r.path);a!==void 0&&a!==r.content&&fe(!0),H.current=r.content,Oe.current=r.updatedAt??r.modifiedAt,oe(r.content),ce(r.updatedAt??r.modifiedAt)}).catch(()=>void 0)}De.current=B},[A,Ee,r,B,he]);let ze=()=>!Ee||window.confirm(y(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),Be=()=>{r&&pe(e.id,r.path)},q=async e=>{ze()&&(V.current+=1,Be(),u(),_(!1),fe(!1),re(e),await o(e).catch(()=>void 0))},Ve=async t=>{if(!ze())return;let n=++V.current;Be();let r=await s(t).catch(()=>void 0);if(!U.current||!r||n!==V.current)return;me.current.set(r.path,r.content);let i=he.get(r.path);fe(i!==void 0&&i!==r.content);let a=ge(e.id,r.path),o=a?.content??r.content,c=a?.baseUpdatedAt??r.updatedAt??r.modifiedAt;H.current=o,Oe.current=c,oe(o),ce(c),_(a!==null&&a.content!==r.content)},He=()=>{ze()&&(V.current+=1,Be(),u(),_(!1),fe(!1))},Ue=t=>{r&&(H.current=t,oe(t),t===r.content?pe(e.id,r.path):_e(e.id,r.path,{content:t,baseUpdatedAt:se??r.updatedAt??r.modifiedAt}),_(t!==r.content))},We=async()=>{if(!r)return;let t=e.id,n=r.path,i=N,a=V.current,o=await d(n,i,se).catch(()=>!1);if(!U.current||o===!1||a!==V.current||Ae.current!==t||ke.current?.path!==n)return;let s=o.updatedAt??o.modifiedAt;me.current.set(n,typeof o.content==`string`?o.content:i),Oe.current=s,ce(s);let c=H.current;if(c===i){pe(t,n),_(!1);return}_e(t,n,{content:c,baseUpdatedAt:s}),_(!0)},Ge=async()=>{if(!r||B||ue||!K)return;de(!0);let e=V.current,t=r.path,n=H.current;try{let r=await dt(t,n);if(!U.current||e!==V.current||ke.current?.path!==t||H.current!==n)return;Ue(r),j.success(y(`work.files.formatted`,{defaultValue:`Code formatted.`}))}catch(r){if(!U.current||e!==V.current||ke.current?.path!==t||H.current!==n)return;j.error(r instanceof Error?r.message:y(`work.files.formatFailed`,{defaultValue:`Could not format this file.`}))}finally{U.current&&de(!1)}},J=[{id:`files`,label:y(`work.workspace.files`,{defaultValue:`Files`}),icon:ee,testId:`work-files-tab`},{id:`activity`,label:y(`work.workspace.activity`,{defaultValue:`Activity`}),icon:h,testId:`work-activity-tab`},{id:`git`,label:y(`work.workspace.git`,{defaultValue:`Git`}),icon:ie,testId:`work-git-tab`},{id:`terminal`,label:y(`work.workspace.terminal`,{defaultValue:`Terminal`}),icon:x,testId:`work-terminal-tab`},{id:`preview`,label:y(`work.workspace.preview`,{defaultValue:`Preview`}),icon:S,testId:`work-preview-tab`}],Ke=(e,t)=>{let n=null;if(e.key===`ArrowRight`&&(n=(t+(O?-1:1)+J.length)%J.length),e.key===`ArrowLeft`&&(n=(t+(O?1:-1)+J.length)%J.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=J.length-1),n===null)return;e.preventDefault();let r=J[n];te(r.id),e.currentTarget.parentElement?.querySelector(`#work-workspace-tab-${r.id}`)?.focus()};return(0,z.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-transparent`,children:[(0,z.jsxs)(`div`,{"data-testid":`work-workspace-toolbar`,className:`flex h-12 shrink-0 items-center gap-2 border-b border-line bg-surface-raised/75 px-2 backdrop-blur-xl`,children:[(0,z.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,"aria-label":y(`work.workspace.label`,{defaultValue:`Workspace views`}),className:`flex min-w-0 items-center overflow-x-auto rounded-xl border border-line bg-surface-subtle p-0.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:J.map((e,t)=>{let n=e.icon;return(0,z.jsxs)(`button`,{type:`button`,role:`tab`,id:`work-workspace-tab-${e.id}`,"aria-selected":k===e.id,"aria-controls":k===e.id?`work-workspace-panel-${e.id}`:void 0,"aria-label":e.label,tabIndex:k===e.id?0:-1,title:e.label,"data-testid":e.testId,onClick:()=>te(e.id),onKeyDown:e=>Ke(e,t),className:I(`flex h-7 items-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow]`,k===e.id?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:text-ink`),children:[(0,z.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`hidden xs:inline`,children:e.label}),e.id===`activity`&&Te>0&&(0,z.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-[10px] text-ink-muted`,children:Te})]},e.id)})}),k===`files`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[r&&(0,z.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink sm:hidden`,onClick:He,"aria-label":y(`work.files.back`,{defaultValue:`Back to files`}),children:(0,z.jsx)(m,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,z.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,title:r?.path??`/workspace${A?`/${A}`:``}`,children:[r?.path??`/workspace${A?`/${A}`:``}`,Ee&&` •`]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:!A,onClick:()=>void q(Nt(A)),className:I(`hidden h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink disabled:opacity-30 sm:inline-flex`,!r&&`inline-flex`),"aria-label":y(`work.files.up`,{defaultValue:`Parent folder`}),title:y(`work.files.up`,{defaultValue:`Parent folder`}),children:(0,z.jsx)(m,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,z.jsx)(`button`,{type:`button`,"data-testid":`work-refresh-files-button`,onClick:()=>void o(A).catch(()=>void 0),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink`,"aria-label":y(`common.refresh`,{defaultValue:`Refresh`}),title:y(`common.refresh`,{defaultValue:`Refresh`}),children:(0,z.jsx)(p,{className:I(`h-3.5 w-3.5`,i&&`animate-spin`)})}),r&&Ie&&G&&(0,z.jsxs)(`button`,{type:`button`,"data-testid":`work-diff-toggle-button`,"aria-pressed":F,onClick:()=>fe(e=>!e),title:y(`work.files.changesSince`,{defaultValue:`What changed since the last turn`}),className:I(`inline-flex h-8 items-center gap-1.5 rounded-lg border px-2 text-[11px] font-medium transition-colors`,F?`border-transparent bg-ink text-ink-inverse`:`border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`),children:[(0,z.jsx)(E,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:y(`work.files.changes`,{defaultValue:`Changes`})}),(0,z.jsxs)(`span`,{dir:`ltr`,className:`tabular-nums`,children:[(0,z.jsxs)(`span`,{className:F?void 0:`text-[rgb(46,164,79)]`,children:[`+`,G.added]}),` `,(0,z.jsxs)(`span`,{className:F?void 0:`text-[rgb(255,61,129)]`,children:[`−`,G.removed]})]})]}),r&&!F&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(L,{"data-testid":`work-format-file-button`,size:`sm`,variant:`ghost`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:B||ue||!K,onClick:()=>void Ge(),"aria-busy":ue||void 0,title:K?y(`work.files.formatShortcut`,{defaultValue:`Format (Shift+Alt+F)`}):Le?y(`work.files.formatTooLarge`,{defaultValue:`Formatting is limited to files under 100,000 characters and 4,000 lines.`}):y(`work.files.formatUnsupported`,{defaultValue:`Formatting is not available for this file type.`}),"aria-label":y(`work.files.format`,{defaultValue:`Format file`}),children:[ue?(0,z.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(w,{className:`h-3.5 w-3.5`}),(0,z.jsx)(`span`,{className:`hidden 2xl:inline`,children:y(`work.files.format`,{defaultValue:`Format`})})]}),(0,z.jsxs)(L,{"data-testid":`work-save-file-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:!Ee||B||ue||a,onClick:()=>void We(),"aria-busy":a||void 0,title:y(`work.files.saveShortcut`,{defaultValue:`Save (⌘/Ctrl+S)`}),"aria-label":y(`common.save`),children:[a?(0,z.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(C,{className:`h-3.5 w-3.5`}),(0,z.jsx)(`span`,{className:`hidden 2xl:inline`,children:y(`common.save`)})]})]})]})]}),(k===`activity`||k===`git`)&&(0,z.jsx)(`div`,{className:`min-w-0 flex-1`}),k===`terminal`&&(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,z.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,children:`/workspace`}),B&&(0,z.jsx)(`span`,{className:`shrink-0 text-[10px] text-ink-subtle`,children:y(`work.terminal.taskRunning`,{defaultValue:`Model turn in progress`})})]}),k===`preview`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{dir:`auto`,value:le,onChange:e=>P(e.target.value),placeholder:y(`work.preview.command`,{defaultValue:`Optional start command`}),"aria-label":y(`work.preview.command`,{defaultValue:`Optional start command`}),className:`h-8 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2.5 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.previewStatus===`running`||e.previewStatus===`starting`?(0,z.jsxs)(L,{"data-testid":`work-stop-preview-button`,variant:`danger`,size:`sm`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void g(),"aria-busy":a||void 0,"aria-label":y(`work.preview.stop`,{defaultValue:`Stop preview`}),children:[a?(0,z.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(T,{className:`h-3.5 w-3.5 fill-current`}),(0,z.jsx)(`span`,{className:`hidden 2xl:inline`,children:y(`work.preview.stop`,{defaultValue:`Stop preview`})})]}):(0,z.jsxs)(L,{"data-testid":`work-start-preview-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void f(le.trim()||void 0),"aria-busy":a||void 0,"aria-label":y(`work.preview.start`,{defaultValue:`Start preview`}),children:[a?(0,z.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(l,{className:`h-3.5 w-3.5 fill-current`}),(0,z.jsx)(`span`,{className:`hidden 2xl:inline`,children:y(`work.preview.start`,{defaultValue:`Start preview`})})]}),ye&&(0,z.jsx)(`a`,{href:ye,target:`_blank`,rel:`noopener noreferrer`,"aria-label":y(`work.preview.open`,{defaultValue:`Open`}),title:y(`work.preview.open`,{defaultValue:`Open`}),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`,children:(0,z.jsx)(D,{className:`h-3.5 w-3.5`})})]})]})]}),k===`files`&&(0,z.jsxs)(`div`,{id:`work-workspace-panel-files`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-files`,className:`flex min-h-0 flex-1`,children:[(0,z.jsx)(`div`,{className:I(`flex min-h-0 w-full flex-col border-e border-line bg-surface-raised`,r?`hidden sm:flex sm:w-52 xl:w-60`:`flex`),children:(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:i&&n.length===0?(0,z.jsx)(`div`,{className:`flex justify-center py-8 text-ink-muted`,children:(0,z.jsx)(M,{className:`h-5 w-5 animate-spin`})}):n.length===0?(0,z.jsx)(`p`,{className:`px-3 py-8 text-center text-xs text-ink-muted`,children:y(`work.files.empty`,{defaultValue:`No files in this folder yet.`})}):[...n].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1).map(e=>(0,z.jsxs)(`button`,{type:`button`,"data-testid":`work-file-item`,"data-path":e.path,onClick:()=>{e.type===`directory`?q(e.path):Ve(e.path)},className:I(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-xs hover:bg-surface-subtle`,r?.path===e.path?`bg-surface-subtle text-ink`:`text-ink-muted`),children:[e.type===`directory`?(0,z.jsx)(ne,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}):(0,z.jsx)(ae,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{dir:`auto`,className:`truncate`,children:e.name})]},e.path))})}),(0,z.jsx)(`div`,{className:I(`min-h-0 min-w-0 flex-1 flex-col`,r?`flex`:`hidden sm:flex`),children:r&&F&&Pe?(0,z.jsx)(St,{lines:Pe,ariaLabel:y(`work.files.diffLabel`,{path:r.path,defaultValue:`Changes since the last turn: {{path}}`})}):r?(0,z.jsx)(Q,{path:r.path,value:N,ariaLabel:y(`work.files.editorLabel`,{path:r.path,defaultValue:`File editor: {{path}}`}),onChange:Ue,onSaveShortcut:()=>{Ee&&!B&&!a&&!ue&&We()},onFormatShortcut:()=>void Ge(),disabled:B||ue}):(0,z.jsxs)(`div`,{className:`m-auto px-6 text-center text-xs text-ink-muted`,children:[(0,z.jsx)(ae,{className:`mx-auto mb-3 h-7 w-7 text-ink-subtle`}),y(`work.files.select`,{defaultValue:`Select a file to inspect and edit it.`})]})})]}),k===`activity`&&(0,z.jsxs)(`div`,{id:`work-workspace-panel-activity`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-activity`,className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[t&&(0,z.jsx)(`div`,{className:`mb-3`,children:(0,z.jsx)(Fe,{run:t,variant:`activity`})}),we.length===0&&!t?(0,z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center text-xs text-ink-muted`,children:[(0,z.jsx)(x,{className:`mb-3 h-7 w-7 text-ink-subtle`}),y(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]}):(0,z.jsx)(`div`,{className:`space-y-2`,children:we.map(e=>(0,z.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{dir:`auto`,className:`truncate font-mono text-xs font-medium text-ink`,children:Pt(e,y(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,z.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-ink-subtle rtl:tracking-normal`,children:{message:y(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:y(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:y(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:y(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:y(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind]})]}),e.content&&(0,z.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap break-words text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:e.content})]},e.id))})]}),k===`git`&&(0,z.jsx)(`div`,{id:`work-workspace-panel-git`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-git`,className:`min-h-0 flex-1`,children:(0,z.jsx)(Tt,{taskId:e.id,mutationsDisabled:B||e.previewStatus===`starting`||e.previewStatus===`running`,disabledReason:B?y(`work.git.blockedByRun`,{defaultValue:`Git write actions unlock when the model turn finishes.`}):e.previewStatus===`starting`||e.previewStatus===`running`?y(`work.git.blockedByPreview`,{defaultValue:`Stop the preview before changing Git state.`}):void 0})}),k===`terminal`&&(0,z.jsx)(`div`,{id:`work-workspace-panel-terminal`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-terminal`,className:`flex min-h-0 flex-1 flex-col`,children:(0,z.jsx)(jt,{taskId:e.id,active:k===`terminal`,disabledReason:v&&!v.available?v.reason??y(`work.terminal.unavailable`,{defaultValue:`The interactive terminal is not available in this deployment.`}):B?y(`work.terminal.blockedByRun`,{defaultValue:`The model is using this container. The terminal opens when the turn finishes.`}):void 0})}),k===`preview`&&(0,z.jsx)(`div`,{id:`work-workspace-panel-preview`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-preview`,className:`flex min-h-0 flex-1 flex-col`,children:e.previewStatus===`starting`?(0,z.jsxs)(`div`,{className:`m-auto flex items-center gap-2 text-xs text-ink-muted`,children:[(0,z.jsx)(M,{className:`h-4 w-4 animate-spin`}),y(`work.preview.starting`,{defaultValue:`Starting preview…`})]}):ye&&e.previewStatus===`running`?(0,z.jsx)(`iframe`,{"data-testid":`work-preview-frame`,title:y(`work.preview.frameTitle`,{defaultValue:`Workspace preview`}),src:ye,sandbox:`allow-scripts allow-forms allow-modals allow-downloads`,referrerPolicy:`no-referrer`,className:`min-h-0 flex-1 border-0 bg-white`}):(0,z.jsxs)(`div`,{className:`m-auto max-w-sm px-6 text-center text-xs leading-relaxed text-ink-muted`,children:[(0,z.jsx)(S,{className:`mx-auto mb-3 h-8 w-8 text-ink-subtle`}),e.previewStatus===`failed`?y(`work.preview.failed`,{defaultValue:`The preview could not start. Check Activity, then try another command.`}):y(`work.preview.empty`,{defaultValue:`Start the app inside this workspace to inspect it here.`})]})})]})}var It=e=>{let t=e.trim().toLowerCase();return!!t&&!t.includes(`embed`)},Lt=(e,t)=>e instanceof Error&&e.message?e.message:t,Rt=(e,t)=>new Promise(n=>{if(t.aborted){n();return}let r,i=()=>{r!==void 0&&window.clearTimeout(r),t.removeEventListener(`abort`,i),n()};r=window.setTimeout(i,e),t.addEventListener(`abort`,i,{once:!0})});function zt(){let{t:e}=c(),t=s(),n=r(),{taskId:a}=i(),l=ye(e=>e.preferences),f=ye(e=>e.setPreferences),p=he(e=>e.user),m=p?.id??null,[h,g]=(0,R.useState)(!1),v=ve(e=>e.models),y=ve(e=>e.selectedModel),b=ve(e=>e.selectedProviderType),x=ve(e=>e.selectedProviderId),C=ve(e=>e.loadModels),{capabilities:w,tasks:T,selectedTask:E,files:D,selectedFile:O,liveRuns:ee,loadingTask:te,loadingOlderMessages:A,loadingFiles:ne,actionLoading:re,error:ie,loadCapabilities:ae,loadTasks:M,selectTask:N,loadTask:P,loadOlderMessages:ue,createTask:ge,updateTask:_e,deleteTask:L,startRun:be,cancelRun:Se,beginLiveRun:Ce,applyRunEvents:we,setLiveRunConnection:B,clearLiveRun:De,loadFiles:V,loadFile:Oe,clearSelectedFile:ke,saveFile:Ae,startPreview:je,stopPreview:Me,clearError:Ne}=me(),U=(0,R.useMemo)(()=>v.filter(e=>!e.isPersona&&It(e.name)&&(!e.isPlugin||!!e.pluginId)),[v]),W=(0,R.useMemo)(()=>U.flatMap(e=>{if(e.isPlugin&&!e.pluginId)return[];let t=e.isPlugin?`plugin`:`ollama`,n=e.isPlugin?e.pluginId:void 0,r=e.name.trim().toLowerCase(),i={model:e.name,providerType:t,providerId:n};return[{...i,key:Te(i),label:e.isPlugin&&e.pluginName?`${e.name} · ${e.pluginName}`:e.name,remote:e.isPlugin||r.endsWith(`:cloud`)||r.endsWith(`-cloud`)}]}),[U]),[Pe,Fe]=(0,R.useState)(``),[G,Ie]=(0,R.useState)({locationKey:t.key,value:`conversation`}),Le=G.locationKey===t.key?G.value:`conversation`,Re=e=>Ie({locationKey:t.key,value:e}),[K,ze]=(0,R.useState)(!1),[q,Ve]=(0,R.useState)(``),He=w?.hostWorkspaces?.enabled===!0,Ue=w?.hostWorkspaces?.roots??[],[We,Ge]=(0,R.useState)({taskId:null,open:!1}),J=We.open&&We.taskId===E?.id,Ke=(0,R.useRef)(null),qe=(0,R.useRef)(null),Je=(0,R.useRef)(null),Ye=(0,R.useCallback)((e=!1)=>{Ge(e=>({...e,open:!1})),e&&window.requestAnimationFrame(()=>qe.current?.focus())},[]);(0,R.useEffect)(()=>{if(!J)return;let e=window.requestAnimationFrame(()=>{Je.current?.querySelector(`[role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!Ke.current?.contains(e.target)&&Ye()},n=e=>{e.key===`Escape`&&(e.preventDefault(),Ye(!0))};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[Ye,J]);let Xe=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Ye(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=[...Je.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]];if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowUp`?(n-1+t.length)%t.length:(n+1)%t.length]?.focus()};(0,R.useEffect)(()=>{ae(),M()},[ae,M]),(0,R.useEffect)(()=>{if(!a){N(null);return}N(a),P(a).catch(()=>void 0),V(a,``).catch(()=>void 0)},[a,V,P,N]);let Ze=W.find(e=>e.key===Pe)||W.find(e=>e.model===y&&(b===`plugin`?e.providerType===`plugin`&&e.providerId===x:e.providerType===`ollama`))||W[0],Qe=a?T.find(e=>e.id===a):void 0,Y=Qe?.status??E?.status,et=E?.activeRun??Qe?.activeRun??null,X=et?.id,tt=et?.status===`queued`||et?.status===`preparing`||et?.status===`running`,nt=a&&ee[a]?.runId===X?ee[a]:void 0,rt=Y===`preparing`||Y===`running`?1e3:4e3;(0,R.useEffect)(()=>{let e,t=!1,n=async()=>{await M(!0),t||(e=setTimeout(n,rt))};return e=setTimeout(n,rt),()=>{t=!0,e&&clearTimeout(e)}},[M,rt]);let it=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!a||!Y){it.current=null;return}let e=it.current;it.current={taskId:a,status:Y},e?.taskId===a&&(e.status===`preparing`||e.status===`running`)&&Y!==`preparing`&&Y!==`running`&&(P(a,!0).catch(()=>void 0),V(a,``).catch(()=>void 0))},[V,P,Y,a]),(0,R.useEffect)(()=>{if(!a||!X||!tt)return;let e=new AbortController,t=!1,n=0,r=me.getState().liveRuns[a]?.runId===X&&me.getState().liveRuns[a]?.lastEventId||0,i=!1,o=[],s=null,c=()=>{if(s!==null&&(window.cancelAnimationFrame(s),s=null),o.length===0)return;let e=o;o=[],we(e)},l=e=>{if(e.type!==`snapshot`&&(n=0),r=Math.max(r,e.id),o.push(e),e.type===`done`||e.type===`error`&&e.data.terminal!==!1){i=!0,c();return}s===null&&(s=window.requestAnimationFrame(c))};return Ce(a,X,et?.startedAt||void 0),(async()=>{for(;!t&&!e.signal.aborted&&!i;){B(a,X,n>=3?`error`:n===0?`connecting`:`reconnecting`);let o=Date.now();try{if(await F.streamRunEvents({taskId:a,runId:X,after:r,signal:e.signal,onEvent:l}),c(),i||t||e.signal.aborted)break;throw Error(`The live Work connection closed.`)}catch(r){if(c(),t||e.signal.aborted)return;Date.now()-o>=5e3&&(n=0),n+=1,B(a,X,n>=3?`error`:`reconnecting`,n>=3?Lt(r,`Live updates are reconnecting in the background.`):void 0),await Rt(Math.min(4e3,250*2**Math.min(n,4)),e.signal)}}if(c(),!(!i||e.signal.aborted)){B(a,X,`closed`);try{await Promise.all([P(a,!0),V(a,``),M(!0)])}catch{}finally{De(a,X)}}})(),()=>{t=!0,e.abort(),c()}},[we,Ce,De,V,P,M,et?.startedAt,tt,X,B,a]),(0,R.useEffect)(()=>{if(!K)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[K]);let at=(0,R.useCallback)(()=>!K||window.confirm(e(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),[e,K]),ot=(0,R.useCallback)(()=>!K||window.confirm(e(`work.files.leaveWithDraft`,{defaultValue:`Leave this file? Your unsaved edit will remain as a browser draft.`})),[e,K]),st=()=>{E&&O&&pe(E.id,O.path)},ct=o(({currentLocation:e,nextLocation:t})=>{let n=t.state;return K&&n?.deletedWorkTaskId!==a&&`${e.pathname}${e.search}${e.hash}`!=`${t.pathname}${t.search}${t.hash}`});(0,R.useEffect)(()=>{if(ct.state!==`blocked`)return;if(!ot()){ct.reset();return}let e=ct.proceed,t=window.setTimeout(()=>{ze(!1),window.setTimeout(e,0)},0);return()=>window.clearTimeout(t)},[ot,ct]);let lt=()=>{Ne(),Re(`conversation`),n(`/work`)},Z=async t=>{if(E&&!at())return!1;E&&K&&(st(),ke(),ze(!1));try{if(E)await be(E.id,{message:t,model:E.model,providerType:E.providerType,providerId:E.providerId||void 0});else{if(!Ze)throw Error(e(`work.composer.noModelSelected`,{defaultValue:`No Work-compatible model is selected.`}));n(`/work/${(await ge({message:t,model:Ze.model,providerType:Ze.providerType,providerId:Ze.providerId,networkEnabled:!0,...He&&q.trim()?{hostPath:q.trim()}:{}})).id}`)}return!0}catch(t){return j.error(Lt(t,e(`work.toasts.runFailed`,{defaultValue:`Could not start the Work task.`}))),!1}},ut=async t=>{let n=xt.find(e=>e.key===t);if(n){if(!E){Fe(t);return}try{await _e(E.id,{model:n.model,providerType:n.providerType,providerId:n.providerId})}catch(t){j.error(Lt(t,e(`work.toasts.updateFailed`,{defaultValue:`Could not update this task.`})))}}},dt=async()=>{if(E)try{await Se(E.id),j.success(e(`work.toasts.cancelled`,{defaultValue:`Work run stopped.`}))}catch(t){j.error(Lt(t,e(`work.toasts.cancelFailed`,{defaultValue:`Could not stop the Work run.`})))}},ft=async t=>{let r=T.find(e=>e.id===t);if(!window.confirm(e(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:r?.title||e(`work.tasks.untitled`,{defaultValue:`Untitled task`})})))return;let i=a===t&&K;i&&ze(!1);try{await L(t),fe(t),a===t&&n(`/work`)}catch(t){i&&ze(!0),j.error(Lt(t,e(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`})))}},pt=async t=>{if(!E)return!1;let n=t.trim();if(!n||n===E.title)return!!n;try{return await _e(E.id,{title:n}),!0}catch(t){return j.error(Lt(t,e(`work.toasts.renameFailed`,{defaultValue:`Could not rename this task.`}))),!1}},mt=async(e,t,n)=>{try{return await e(),n&&j.success(n),!0}catch(e){return j.error(Lt(e,t)),!1}},ht=async(t,n,r)=>{if(!E)return!1;let i=E.id;try{let a=await Ae(i,t,n,r);return me.getState().selectedTaskId===i&&j.success(e(`work.toasts.saved`,{defaultValue:`File saved.`})),a}catch(t){return me.getState().selectedTaskId===i&&j.error(Lt(t,e(`work.toasts.saveFailed`,{defaultValue:`Could not save this file.`}))),!1}},Q=w?.available===!1,gt=w?.pluginAvailable?w.ollamaAvailable?e(`work.runtime.readyHybrid`,{defaultValue:`Docker + models ready`}):e(`work.runtime.readyPlugin`,{defaultValue:`Docker + plugin ready`}):e(`work.runtime.readyOllama`,{defaultValue:`Docker ready`}),_t=e(`work.runtime.ready`,{defaultValue:`Runtime ready`}),vt=E?Ee(E):!1,$=E?{model:E.model,providerType:E.providerType,providerId:E.providerId||void 0}:void 0,yt=$?Te($):Ze?.key||``,bt=$&&!W.some(e=>e.key===yt)?{...$,key:yt,label:`${$.model} · ${$.providerType===`plugin`?$.providerId||`plugin`:`Ollama`}`,remote:$.providerType===`plugin`||$.model.toLowerCase().endsWith(`:cloud`)||$.model.toLowerCase().endsWith(`-cloud`)}:void 0,xt=bt?[bt,...W]:W,St=xe[E?.status??`idle`],Ct=e(St.labelKey,{defaultValue:St.label}),wt=async()=>{if(l.workRemoteProviderDisclosureDismissed||h)return!1;let t=m;g(!0);try{let n=await de.updatePreferences({workRemoteProviderDisclosureDismissed:!0});if(!n.success)throw Error(n.error||e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`}));return(he.getState().user?.id??null)===t?(f({workRemoteProviderDisclosureDismissed:!0}),!0):!1}catch{return j.error(e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`})),!1}finally{g(!1)}};return(0,z.jsx)(`div`,{"data-testid":`work-page`,className:`relative flex h-full min-h-0 overflow-hidden bg-transparent`,children:(0,z.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3 border-b border-line bg-surface/55 px-3 backdrop-blur-xl md:px-4`,children:[E?(0,z.jsx)(`input`,{"data-testid":`work-task-title`,dir:`auto`,defaultValue:E.title,onBlur:e=>{let t=e.currentTarget;if(!t.value.trim()){t.value=E.title;return}pt(t.value).then(e=>{e||(t.value=E.title)})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=E.title,e.currentTarget.blur())},className:`min-w-0 max-w-sm flex-1 truncate rounded-lg border border-transparent bg-transparent px-2 py-1 text-sm font-semibold text-ink outline-none hover:border-line focus:border-primary-500 focus:bg-surface`,"aria-label":e(`work.tasks.rename`,{defaultValue:`Task title`})},`${E.id}:${E.title}`):(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(`h1`,{className:`truncate text-sm font-semibold text-ink`,children:e(`work.title`,{defaultValue:`Work`})})}),E?.hostPath&&(0,z.jsxs)(`span`,{"data-testid":`work-host-path-chip`,title:E.hostPath,className:`hidden h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 font-mono text-[11px] text-ink-muted sm:inline-flex`,children:[(0,z.jsx)(le,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,z.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:E.hostPath})]}),E&&(0,z.jsxs)(`span`,{"data-testid":`work-compact-status`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2 text-[11px] font-medium text-ink-muted xl:hidden`,"aria-label":e(`work.tasks.status`,{status:Ct,defaultValue:`Status: {{status}}`}),title:e(`work.tasks.status`,{status:Ct,defaultValue:`Status: {{status}}`}),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-compact-status-indicator`,className:I(`h-1.5 w-1.5 rounded-full`,St.animated&&`animate-pulse`,E.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:St.color}}),(0,z.jsx)(`span`,{className:`hidden md:inline`,children:Ct})]}),E&&(0,z.jsxs)(`div`,{className:`ms-auto inline-flex h-9 shrink-0 items-center rounded-xl border border-line bg-surface-subtle p-1 shadow-subtle xl:hidden`,role:`group`,"aria-label":e(`work.mobile.surface`,{defaultValue:`Task surface`}),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Re(`conversation`),"aria-label":e(`work.mobile.conversation`,{defaultValue:`Conversation`}),"aria-pressed":Le===`conversation`,className:I(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,Le===`conversation`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,z.jsx)(u,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.conversation`,{defaultValue:`Conversation`})})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Re(`workspace`),"aria-label":e(`work.mobile.workspace`,{defaultValue:`Workspace`}),"aria-pressed":Le===`workspace`,className:I(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,Le===`workspace`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,z.jsx)(S,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.workspace`,{defaultValue:`Workspace`})})]})]}),(0,z.jsxs)(`div`,{className:I(`ms-auto hidden min-w-0 items-center gap-2`,E?`xl:flex`:`sm:flex`),children:[E&&(0,z.jsxs)(`span`,{"data-testid":`work-status`,className:`inline-flex h-7 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-status-indicator`,className:I(`h-1.5 w-1.5 rounded-full`,St.animated&&`animate-pulse`,E.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:St.color}}),Ct]}),(0,z.jsxs)(`span`,{"data-testid":`work-runtime-status`,className:I(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-[11px] font-medium`,Q?`border-transparent bg-error-500 text-[#0D0D0C]`:`border-transparent bg-success-500 text-[#0D0D0C]`),title:Q?w?.reason||e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):w?.image?`${gt} · ${w.image}`:gt,children:[(0,z.jsx)(d,{className:`h-3.5 w-3.5`}),Q?e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):_t]}),E&&(0,z.jsxs)(`span`,{className:`hidden h-7 max-w-44 items-center gap-1.5 truncate rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted md:inline-flex`,children:[(0,z.jsx)(se,{className:`h-3.5 w-3.5 shrink-0`}),(0,z.jsx)(`span`,{dir:`ltr`,className:`truncate`,children:E.model})]})]}),E&&(0,z.jsxs)(`div`,{ref:Ke,className:`relative shrink-0`,children:[(0,z.jsx)(`button`,{ref:qe,id:`work-task-actions-trigger`,type:`button`,"data-testid":`work-task-actions-button`,onClick:()=>Ge(e=>({taskId:E.id,open:e.taskId===E.id?!e.open:!0})),onKeyDown:e=>{e.key!==`ArrowDown`&&e.key!==`ArrowUp`||(e.preventDefault(),Ge({taskId:E.id,open:!0}))},className:`inline-flex h-9 w-9 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink`,"aria-label":e(`work.tasks.actions`,{defaultValue:`Task actions`}),"aria-haspopup":`menu`,"aria-expanded":J,"aria-controls":J?`work-task-actions-menu`:void 0,children:(0,z.jsx)(oe,{className:`h-4 w-4`})}),J&&(0,z.jsx)(`div`,{ref:Je,id:`work-task-actions-menu`,role:`menu`,"aria-labelledby":`work-task-actions-trigger`,onKeyDown:Xe,className:`absolute end-0 top-10 z-40 min-w-44 rounded-xl border border-line bg-surface-overlay p-1.5 shadow-overlay`,children:(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`work-delete-task-button`,onClick:()=>{Ye(!0),ft(E.id)},className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-start text-xs font-medium text-error-600 transition-colors hover:bg-error-500/10`,children:[(0,z.jsx)(k,{className:`h-3.5 w-3.5`}),e(`work.tasks.delete`,{defaultValue:`Delete task`})]})})]})]}),(Q||ie)&&(0,z.jsxs)(`div`,{className:I(`flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs`,Q?`border-error-500/20 bg-error-500/10 text-error-700`:`border-amber-500/20 bg-amber-500/10 text-ink`),children:[(0,z.jsx)(ce,{className:`h-4 w-4 shrink-0`}),(0,z.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1`,children:Q?w?.reason||e(`work.runtime.reason`,{defaultValue:`Docker and an available Ollama or plugin model provider are required.`}):ie}),ie&&!Q&&(0,z.jsx)(`button`,{type:`button`,className:`rounded-md p-1 hover:bg-black/5`,onClick:Ne,"aria-label":e(`common.close`),children:`×`})]}),a?E?(0,z.jsx)($e,{userId:m,mobileSurface:Le,conversation:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Be,{task:E,user:p,liveRun:nt,loading:te,loadingOlder:A,onLoadOlder:()=>ue(E.id)}),(0,z.jsx)(H,{models:xt,selectorModels:U,modelKey:yt,running:vt,loading:re,disabled:Q,remoteDisclosureDismissed:l.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:h,onModelChange:ut,onDismissRemoteDisclosure:wt,onModelsRefresh:C,onSubmit:Z,onCancel:dt},E.id)]}),workspace:(0,z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,z.jsx)(Ft,{task:E,liveRun:nt,files:D,selectedFile:O,loadingFiles:ne,actionLoading:re,onLoadFiles:e=>V(E.id,e),onLoadFile:e=>Oe(E.id,e),onClearSelectedFile:ke,onSaveFile:ht,onStartPreview:t=>mt(()=>je(E.id,t),e(`work.toasts.previewFailed`,{defaultValue:`Could not start the preview.`})),onStopPreview:()=>mt(()=>Me(E.id),e(`work.toasts.previewStopFailed`,{defaultValue:`Could not stop the preview.`})),onDirtyChange:ze,terminal:w?.terminal},E.id)})}):(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:te?(0,z.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`work.tasks.loading`,{defaultValue:`Loading task…`})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ce,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,z.jsx)(`h2`,{className:`text-lg font-semibold text-ink`,children:e(`work.tasks.notFound`,{defaultValue:`This Work task is unavailable`})}),(0,z.jsxs)(`button`,{type:`button`,onClick:lt,className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-primary-600 hover:text-primary-700`,children:[(0,z.jsx)(_,{className:`h-4 w-4 rtl:rotate-180`}),e(`work.tasks.back`,{defaultValue:`Start a new task`})]})]})}):(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,z.jsxs)(`section`,{"data-testid":`work-landing`,className:`mx-auto flex min-h-full w-full max-w-3xl flex-col items-center justify-center px-4 py-20 sm:px-8 sm:py-24`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,z.jsx)(`h2`,{className:`max-w-3xl text-balance text-[clamp(2.65rem,7vw,5.25rem)] font-light leading-[0.98] tracking-[-0.055em] text-ink rtl:leading-[1.12] rtl:tracking-normal`,children:e(`work.landing.title`,{defaultValue:`Start a new Work task`})}),(0,z.jsx)(`p`,{className:`mt-4 max-w-xl text-balance text-base leading-relaxed text-ink-muted sm:text-lg`,children:e(`work.landing.description`,{defaultValue:`Give a local model a durable, isolated workspace. It can inspect files, run tools, and continue where it left off when you return.`})})]}),He&&(0,z.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,z.jsx)(`label`,{htmlFor:`work-host-path`,className:`mb-1.5 block text-xs font-medium text-ink-muted`,children:e(`work.hostWorkspace.label`,{defaultValue:`Workspace folder (optional)`})}),(0,z.jsx)(`input`,{id:`work-host-path`,"data-testid":`work-host-path`,value:q,onChange:e=>Ve(e.target.value),spellCheck:!1,placeholder:Ue[0]?`${Ue[0]}/my-project`:`/path/to/folder`,className:`w-full rounded-xl border border-line bg-surface px-3 py-2 font-mono text-[13px] text-ink outline-none transition-colors placeholder:text-ink-subtle focus:border-line-strong focus-visible:ring-2 focus-visible:ring-primary-500/30`}),(0,z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:q.trim()?e(`work.hostWorkspace.warning`,{defaultValue:`The task can read and write this folder directly. Leave blank to use an isolated workspace instead.`}):e(`work.hostWorkspace.hint`,{defaultValue:`Leave blank for an isolated workspace, or point the task at a folder on this machine.`})})]}),(0,z.jsx)(H,{variant:`landing`,models:W,selectorModels:U,modelKey:Ze?.key||``,running:!1,loading:re,disabled:Q,remoteDisclosureDismissed:l.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:h,onModelChange:ut,onDismissRemoteDisclosure:wt,onModelsRefresh:C,onSubmit:Z,onCancel:dt}),(0,z.jsxs)(`div`,{"data-testid":`work-workspace-note`,role:`note`,className:`mt-4 flex max-w-2xl flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center text-[10px] leading-relaxed text-ink-subtle`,children:[(0,z.jsx)(d,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,z.jsx)(`span`,{children:e(`work.composer.hint`,{defaultValue:`Each task keeps its own files and history. Review model output before using it.`})})]})]})})]})})}export{zt as default};
|