libre-webui 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -61
- package/backend/dist/db.d.ts.map +1 -1
- package/backend/dist/db.js +21 -19
- package/backend/dist/db.js.map +1 -1
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +39 -908
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/middleware/auth.d.ts.map +1 -1
- package/backend/dist/middleware/auth.js +4 -2
- package/backend/dist/middleware/auth.js.map +1 -1
- package/backend/dist/middleware/index.d.ts.map +1 -1
- package/backend/dist/middleware/index.js +4 -2
- package/backend/dist/middleware/index.js.map +1 -1
- package/backend/dist/models/personaModel.d.ts.map +1 -1
- package/backend/dist/models/personaModel.js +11 -9
- package/backend/dist/models/personaModel.js.map +1 -1
- package/backend/dist/routes/auth.d.ts.map +1 -1
- package/backend/dist/routes/auth.js +36 -14
- 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 +61 -249
- 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 +10 -8
- package/backend/dist/routes/documents.js.map +1 -1
- package/backend/dist/routes/imageGen.d.ts.map +1 -1
- package/backend/dist/routes/imageGen.js +9 -7
- package/backend/dist/routes/imageGen.js.map +1 -1
- package/backend/dist/routes/libreClaw.d.ts +3 -0
- package/backend/dist/routes/libreClaw.d.ts.map +1 -0
- package/backend/dist/routes/libreClaw.js +156 -0
- package/backend/dist/routes/libreClaw.js.map +1 -0
- package/backend/dist/routes/ollama.d.ts.map +1 -1
- package/backend/dist/routes/ollama.js +7 -247
- package/backend/dist/routes/ollama.js.map +1 -1
- package/backend/dist/routes/plugins.d.ts.map +1 -1
- package/backend/dist/routes/plugins.js +7 -105
- package/backend/dist/routes/plugins.js.map +1 -1
- package/backend/dist/routes/tts.d.ts.map +1 -1
- package/backend/dist/routes/tts.js +7 -5
- package/backend/dist/routes/tts.js.map +1 -1
- package/backend/dist/routes/users.d.ts.map +1 -1
- package/backend/dist/routes/users.js +7 -5
- package/backend/dist/routes/users.js.map +1 -1
- package/backend/dist/services/assistantCompletionService.d.ts +26 -0
- package/backend/dist/services/assistantCompletionService.d.ts.map +1 -0
- package/backend/dist/services/assistantCompletionService.js +53 -0
- package/backend/dist/services/assistantCompletionService.js.map +1 -0
- package/backend/dist/services/authService.d.ts +2 -0
- package/backend/dist/services/authService.d.ts.map +1 -1
- package/backend/dist/services/authService.js +9 -5
- package/backend/dist/services/authService.js.map +1 -1
- package/backend/dist/services/chatGenerationService.d.ts +32 -0
- package/backend/dist/services/chatGenerationService.d.ts.map +1 -0
- package/backend/dist/services/chatGenerationService.js +118 -0
- package/backend/dist/services/chatGenerationService.js.map +1 -0
- package/backend/dist/services/chatRequestService.d.ts +55 -0
- package/backend/dist/services/chatRequestService.d.ts.map +1 -0
- package/backend/dist/services/chatRequestService.js +103 -0
- package/backend/dist/services/chatRequestService.js.map +1 -0
- package/backend/dist/services/chatService.d.ts +0 -1
- package/backend/dist/services/chatService.d.ts.map +1 -1
- package/backend/dist/services/chatService.js +13 -27
- package/backend/dist/services/chatService.js.map +1 -1
- package/backend/dist/services/documentService.d.ts.map +1 -1
- package/backend/dist/services/documentService.js +21 -19
- package/backend/dist/services/documentService.js.map +1 -1
- package/backend/dist/services/embeddingService.d.ts.map +1 -1
- package/backend/dist/services/embeddingService.js +3 -1
- package/backend/dist/services/embeddingService.js.map +1 -1
- package/backend/dist/services/encryptionService.d.ts.map +1 -1
- package/backend/dist/services/encryptionService.js +26 -24
- package/backend/dist/services/encryptionService.js.map +1 -1
- package/backend/dist/services/galleryService.d.ts.map +1 -1
- package/backend/dist/services/galleryService.js +8 -6
- package/backend/dist/services/galleryService.js.map +1 -1
- package/backend/dist/services/libreClawService.d.ts +105 -0
- package/backend/dist/services/libreClawService.d.ts.map +1 -0
- package/backend/dist/services/libreClawService.js +169 -0
- package/backend/dist/services/libreClawService.js.map +1 -0
- package/backend/dist/services/memoryService.d.ts +2 -13
- package/backend/dist/services/memoryService.d.ts.map +1 -1
- package/backend/dist/services/memoryService.js +37 -198
- package/backend/dist/services/memoryService.js.map +1 -1
- package/backend/dist/services/memoryUtils.d.ts +29 -0
- package/backend/dist/services/memoryUtils.d.ts.map +1 -0
- package/backend/dist/services/memoryUtils.js +165 -0
- package/backend/dist/services/memoryUtils.js.map +1 -0
- package/backend/dist/services/mutationEngineService.d.ts.map +1 -1
- package/backend/dist/services/mutationEngineService.js +3 -1
- package/backend/dist/services/mutationEngineService.js.map +1 -1
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +36 -34
- 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 +3 -1
- package/backend/dist/services/personaService.js.map +1 -1
- package/backend/dist/services/pluginCapabilityRegistryService.d.ts +11 -0
- package/backend/dist/services/pluginCapabilityRegistryService.d.ts.map +1 -0
- package/backend/dist/services/pluginCapabilityRegistryService.js +70 -0
- package/backend/dist/services/pluginCapabilityRegistryService.js.map +1 -0
- package/backend/dist/services/pluginCredentialsService.d.ts.map +1 -1
- package/backend/dist/services/pluginCredentialsService.js +13 -11
- package/backend/dist/services/pluginCredentialsService.js.map +1 -1
- package/backend/dist/services/pluginEmbeddingService.d.ts +26 -0
- package/backend/dist/services/pluginEmbeddingService.d.ts.map +1 -0
- package/backend/dist/services/pluginEmbeddingService.js +159 -0
- package/backend/dist/services/pluginEmbeddingService.js.map +1 -0
- package/backend/dist/services/pluginImageGenerationService.d.ts +29 -0
- package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -0
- package/backend/dist/services/pluginImageGenerationService.js +402 -0
- package/backend/dist/services/pluginImageGenerationService.js.map +1 -0
- package/backend/dist/services/pluginService.d.ts +9 -18
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +118 -1469
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/pluginTTSService.d.ts +28 -0
- package/backend/dist/services/pluginTTSService.d.ts.map +1 -0
- package/backend/dist/services/pluginTTSService.js +286 -0
- package/backend/dist/services/pluginTTSService.js.map +1 -0
- package/backend/dist/services/pluginVariablesService.d.ts.map +1 -1
- package/backend/dist/services/pluginVariablesService.js +7 -5
- package/backend/dist/services/pluginVariablesService.js.map +1 -1
- package/backend/dist/services/preferencesService.d.ts.map +1 -1
- package/backend/dist/services/preferencesService.js +9 -7
- package/backend/dist/services/preferencesService.js.map +1 -1
- package/backend/dist/services/simpleGitHubOAuth.d.ts.map +1 -1
- package/backend/dist/services/simpleGitHubOAuth.js +10 -8
- package/backend/dist/services/simpleGitHubOAuth.js.map +1 -1
- package/backend/dist/services/simpleHuggingFaceOAuth.d.ts.map +1 -1
- package/backend/dist/services/simpleHuggingFaceOAuth.js +11 -9
- package/backend/dist/services/simpleHuggingFaceOAuth.js.map +1 -1
- package/backend/dist/services/systemSettingsService.d.ts.map +1 -1
- package/backend/dist/services/systemSettingsService.js +4 -2
- package/backend/dist/services/systemSettingsService.js.map +1 -1
- package/backend/dist/services/titleGenerationService.d.ts +55 -0
- package/backend/dist/services/titleGenerationService.d.ts.map +1 -0
- package/backend/dist/services/titleGenerationService.js +121 -0
- package/backend/dist/services/titleGenerationService.js.map +1 -0
- package/backend/dist/services/turnstileService.d.ts +13 -0
- package/backend/dist/services/turnstileService.d.ts.map +1 -0
- package/backend/dist/services/turnstileService.js +79 -0
- package/backend/dist/services/turnstileService.js.map +1 -0
- package/backend/dist/storage.d.ts +2 -22
- package/backend/dist/storage.d.ts.map +1 -1
- package/backend/dist/storage.js +22 -170
- package/backend/dist/storage.js.map +1 -1
- package/backend/dist/storageMappers.d.ts +82 -0
- package/backend/dist/storageMappers.d.ts.map +1 -0
- package/backend/dist/storageMappers.js +85 -0
- package/backend/dist/storageMappers.js.map +1 -0
- package/backend/dist/test-encryption.js +20 -18
- package/backend/dist/test-encryption.js.map +1 -1
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/utils/assistantBranching.d.ts +8 -0
- package/backend/dist/utils/assistantBranching.d.ts.map +1 -0
- package/backend/dist/utils/assistantBranching.js +30 -0
- package/backend/dist/utils/assistantBranching.js.map +1 -0
- package/backend/dist/utils/chatContext.d.ts +17 -0
- package/backend/dist/utils/chatContext.d.ts.map +1 -0
- package/backend/dist/utils/chatContext.js +82 -0
- package/backend/dist/utils/chatContext.js.map +1 -0
- package/backend/dist/utils/chatDocumentContext.d.ts +7 -0
- package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -0
- package/backend/dist/utils/chatDocumentContext.js +51 -0
- package/backend/dist/utils/chatDocumentContext.js.map +1 -0
- package/backend/dist/utils/logger.d.ts +12 -0
- package/backend/dist/utils/logger.d.ts.map +1 -0
- package/backend/dist/utils/logger.js +82 -0
- package/backend/dist/utils/logger.js.map +1 -0
- package/backend/dist/utils/ollamaLibrary.d.ts +17 -0
- package/backend/dist/utils/ollamaLibrary.d.ts.map +1 -0
- package/backend/dist/utils/ollamaLibrary.js +253 -0
- package/backend/dist/utils/ollamaLibrary.js.map +1 -0
- package/backend/dist/utils/ollamaStreaming.d.ts +19 -0
- package/backend/dist/utils/ollamaStreaming.d.ts.map +1 -0
- package/backend/dist/utils/ollamaStreaming.js +67 -0
- package/backend/dist/utils/ollamaStreaming.js.map +1 -0
- package/backend/dist/utils/pluginChatAdapter.d.ts +32 -0
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -0
- package/backend/dist/utils/pluginChatAdapter.js +308 -0
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -0
- package/backend/dist/utils/pluginChatContext.d.ts +23 -0
- package/backend/dist/utils/pluginChatContext.d.ts.map +1 -0
- package/backend/dist/utils/pluginChatContext.js +77 -0
- package/backend/dist/utils/pluginChatContext.js.map +1 -0
- package/backend/dist/utils/pluginResponse.d.ts +6 -0
- package/backend/dist/utils/pluginResponse.d.ts.map +1 -0
- package/backend/dist/utils/pluginResponse.js +70 -0
- package/backend/dist/utils/pluginResponse.js.map +1 -0
- package/backend/dist/utils/pluginStreamAdapter.d.ts +16 -0
- package/backend/dist/utils/pluginStreamAdapter.d.ts.map +1 -0
- package/backend/dist/utils/pluginStreamAdapter.js +141 -0
- package/backend/dist/utils/pluginStreamAdapter.js.map +1 -0
- package/backend/dist/utils/pluginStreaming.d.ts +24 -0
- package/backend/dist/utils/pluginStreaming.d.ts.map +1 -0
- package/backend/dist/utils/pluginStreaming.js +106 -0
- package/backend/dist/utils/pluginStreaming.js.map +1 -0
- package/backend/dist/utils/pluginUpload.d.ts +8 -0
- package/backend/dist/utils/pluginUpload.d.ts.map +1 -0
- package/backend/dist/utils/pluginUpload.js +51 -0
- package/backend/dist/utils/pluginUpload.js.map +1 -0
- package/backend/dist/utils/pluginValidation.d.ts +9 -0
- package/backend/dist/utils/pluginValidation.d.ts.map +1 -0
- package/backend/dist/utils/pluginValidation.js +84 -0
- package/backend/dist/utils/pluginValidation.js.map +1 -0
- package/backend/dist/utils/pluginVariableValidation.d.ts +10 -0
- package/backend/dist/utils/pluginVariableValidation.d.ts.map +1 -0
- package/backend/dist/utils/pluginVariableValidation.js +80 -0
- package/backend/dist/utils/pluginVariableValidation.js.map +1 -0
- package/backend/dist/utils/websocketMessages.d.ts +26 -0
- package/backend/dist/utils/websocketMessages.d.ts.map +1 -0
- package/backend/dist/utils/websocketMessages.js +74 -0
- package/backend/dist/utils/websocketMessages.js.map +1 -0
- package/backend/dist/websocketServer.d.ts +3 -0
- package/backend/dist/websocketServer.d.ts.map +1 -0
- package/backend/dist/websocketServer.js +332 -0
- package/backend/dist/websocketServer.js.map +1 -0
- package/backend/package.json +2 -2
- package/frontend/dist/assets/index-Dc8Q4dJZ.css +1 -0
- package/frontend/dist/assets/index-ONn9VIq7.js +5 -0
- package/frontend/dist/assets/markdown-math-CYlHEDRF.css +1 -0
- package/frontend/dist/index.html +11 -10
- package/frontend/dist/js/ArtifactContainer-CqKsiKz0.js +1 -0
- package/frontend/dist/js/ArtifactDemoPage-Dd5BjIu2.js +200 -0
- package/frontend/dist/js/ArtifactSlideOutPanel-Yc7ttIaY.js +1 -0
- package/frontend/dist/js/Button-BUjLpHmR.js +1 -0
- package/frontend/dist/js/ChatPage-Cpy7lQ0D.js +16 -0
- package/frontend/dist/js/FirstTimeSetup-DcGhm0H0.js +1 -0
- package/frontend/dist/js/GalleryPage-DNI2Evvf.js +1 -0
- package/frontend/dist/js/LibreClawPage-CmTiROsJ.js +1 -0
- package/frontend/dist/js/ModelManagerModals-CfvSeNsT.js +1 -0
- package/frontend/dist/js/ModelsPage-CeTGqx4q.js +2 -0
- package/frontend/dist/js/OptimizedSyntaxHighlighter-CNjLqj1Z.js +1 -0
- package/frontend/dist/js/PersonasPage-BUqu7gJ3.js +13 -0
- package/frontend/dist/js/RichMessageContent-B0JO8vkR.js +3 -0
- package/frontend/dist/js/SettingsModal-B5aJ5vfV.js +1 -0
- package/frontend/dist/js/UserManagementPage-BqIIWX2M.js +1 -0
- package/frontend/dist/js/api-CbmZzKBu.js +15 -0
- package/frontend/dist/js/ar-BAOdgn6O.js +2 -0
- package/frontend/dist/js/artifactHtml-B7Oy2e__.js +27 -0
- package/frontend/dist/js/bn-Bp2KS5mx.js +2 -0
- package/frontend/dist/js/cs-DOgJ0c5p.js +2 -0
- package/frontend/dist/js/da-BCKTkC35.js +2 -0
- package/frontend/dist/js/de-BXyECph5.js +2 -0
- package/frontend/dist/js/demoMode-BhEpMVh5.js +1 -0
- package/frontend/dist/js/es-Db4bDYIF.js +2 -0
- package/frontend/dist/js/fr-BPIkf6zH.js +2 -0
- package/frontend/dist/js/hi-Bm8D_Aux.js +2 -0
- package/frontend/dist/js/id-DiWaH74_.js +2 -0
- package/frontend/dist/js/is-DLgJywtZ.js +2 -0
- package/frontend/dist/js/it-lldrM8pE.js +2 -0
- package/frontend/dist/js/ja-Cfe9uZmQ.js +2 -0
- package/frontend/dist/js/ko-BhChO3MQ.js +2 -0
- package/frontend/dist/js/logger-BmpKNkls.js +1 -0
- package/frontend/dist/js/markdown-core-fkbHPd-g.js +16 -0
- package/frontend/dist/js/markdown-math-Ci4QOsf-.js +261 -0
- package/frontend/dist/js/ms-SWtmetXo.js +2 -0
- package/frontend/dist/js/nl-CUO6I3nO.js +2 -0
- package/frontend/dist/js/pl-BUAu96P6.js +2 -0
- package/frontend/dist/js/pt-DCHwoWiE.js +2 -0
- package/frontend/dist/js/{react-vendor-Dh6nfvM2.js → react-vendor-Co1u1rWb.js} +2 -2
- package/frontend/dist/js/ru-Ciz053N7.js +2 -0
- package/frontend/dist/js/sv-D38ZHjv-.js +2 -0
- package/frontend/dist/js/syntax-highlight-D5wpTVgr.js +8 -0
- package/frontend/dist/js/th-D2cAucvn.js +2 -0
- package/frontend/dist/js/tr-Go355oDu.js +2 -0
- package/frontend/dist/js/ui-vendor-BJAeWL11.js +177 -0
- package/frontend/dist/js/uk-cdzjhgya.js +2 -0
- package/frontend/dist/js/useBaseQuery-6OJiOiyu.js +1 -0
- package/frontend/dist/js/useQuery-DfkI6VAv.js +1 -0
- package/frontend/dist/js/utils-BaPYjs_z.js +1 -0
- package/frontend/dist/js/utils-vendor-BX3ZwoIK.js +9 -0
- package/frontend/dist/js/vi-BSOpE423.js +2 -0
- package/frontend/dist/js/zh-BFh6sHZG.js +2 -0
- package/package.json +12 -8
- package/backend/dist/services/openclawSessionService.d.ts +0 -63
- package/backend/dist/services/openclawSessionService.d.ts.map +0 -1
- package/backend/dist/services/openclawSessionService.js +0 -307
- package/backend/dist/services/openclawSessionService.js.map +0 -1
- package/frontend/dist/assets/index-cOuIFv6G.js +0 -314
- package/frontend/dist/assets/index-tuVjvNle.css +0 -1
- package/frontend/dist/js/ArtifactContainer-DXa2t8GS.js +0 -24
- package/frontend/dist/js/ArtifactDemoPage-Dms7P2gI.js +0 -98
- package/frontend/dist/js/ChatPage-C6hOVIAS.js +0 -15
- package/frontend/dist/js/GalleryPage-CGKPECJV.js +0 -1
- package/frontend/dist/js/ModelsPage-CNB-c-JM.js +0 -1
- package/frontend/dist/js/PersonasPage-hDiS0Rvl.js +0 -13
- package/frontend/dist/js/UserManagementPage-1H9kcHeR.js +0 -1
- package/frontend/dist/js/api-MQ7bONaU.js +0 -3
- package/frontend/dist/js/appStore-BpzQfKOd.js +0 -2
- package/frontend/dist/js/authStore-Cn_WS6Kb.js +0 -2
- package/frontend/dist/js/demoMode-PKHbba1m.js +0 -1
- package/frontend/dist/js/markdown-vendor-DLzJCMRQ.js +0 -22
- package/frontend/dist/js/ui-vendor-ClcVY3m-.js +0 -177
- package/frontend/dist/js/utils-vendor-BCQRX-0Q.js +0 -9
- package/plugins/openclaw-agent.json +0 -69
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-fkbHPd-g.js";import{n as r}from"./react-vendor-Co1u1rWb.js";import{t as i}from"./useQuery-DfkI6VAv.js";import{t as a}from"./logger-BmpKNkls.js";import{A as o,At as s,Bt as c,C as l,Ct as u,D as d,G as f,H as p,Mt as m,N as h,Nt as g,P as _,Q as v,Rt as y,S as b,St as x,T as S,Tt as C,U as w,Vt as T,Y as E,Z as D,_t as O,a as k,c as A,ct as j,dt as M,et as N,f as ee,ft as P,h as te,ht as ne,i as re,lt as F,mt as I,n as L,o as ie,ot as ae,q as oe,r as se,st as R,t as ce,tt as z,ut as B,v as le,vt as V,x as ue,xt as de,y as H,z as fe}from"./ui-vendor-BJAeWL11.js";import{n as pe}from"./demoMode-BhEpMVh5.js";import{a as U,c as me,d as he,f as ge,m as _e,n as ve,o as ye,s as be,u as xe}from"./api-CbmZzKBu.js";import{i as Se,n as Ce,r as we,t as W}from"./utils-BaPYjs_z.js";import{t as G}from"./Button-BUjLpHmR.js";import{B as Te,T as K,V as Ee,_ as q,f as De,g as Oe,k as J,p as ke,u as Ae,y as je,z as Me}from"../assets/index-ONn9VIq7.js";import{a as Ne,i as Pe}from"./artifactHtml-B7Oy2e__.js";import{t as Fe}from"./ArtifactContainer-CqKsiKz0.js";var Ie=r(),Y=e(n(),1),X=t(),Le=({statistics:e,className:t=``})=>{let[n,r]=(0,Y.useState)(!1),{t:i}=J(),a=e=>{if(e==null)return`N/A`;let t=e/1e6;return t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(2)}s`},o=e=>e?`${e.toFixed(1)} t/s`:`N/A`,s=e.prompt_eval_count||0,c=e.eval_count||0,l=s+c,u=a(e.total_duration),d=o(e.tokens_per_second);return(0,X.jsxs)(`div`,{className:`text-xs text-gray-500 dark:text-dark-500 mt-2 ${t}`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-4 mb-1`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-gray-600 dark:text-dark-600`,children:[(0,X.jsx)(p,{size:12,className:`text-primary-500`}),c,` tokens`]}),(0,X.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:d}),(0,X.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:u}),e.model&&(0,X.jsx)(`span`,{className:`text-gray-400 dark:text-dark-400 bg-gray-100 dark:bg-dark-200 px-2 py-0.5 rounded-full truncate max-w-32 sm:max-w-48`,title:e.model,children:e.model})]}),(0,X.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-1 text-gray-400 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-600 transition-colors`,children:[n?(0,X.jsx)(O,{size:12}):(0,X.jsx)(I,{size:12}),(0,X.jsx)(`span`,{children:i(`generationStats.details`)})]}),n&&(0,X.jsxs)(`div`,{className:`mt-2 p-3 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg text-xs space-y-2`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2`,children:[(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.promptTokens`)}),` `,s]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generatedTokens`)}),` `,c]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.totalTokens`)}),` `,l]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.speed`)}),` `,d]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.promptEval`)}),` `,a(e.prompt_eval_duration)]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generation`)}),` `,a(e.eval_duration)]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.modelLoad`)}),` `,a(e.load_duration)]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.totalTime`)}),` `,u]})]}),e.created_at&&(0,X.jsxs)(`div`,{className:`pt-2 border-t border-gray-200 dark:border-dark-300 text-gray-600 dark:text-dark-600`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generatedAt`)}),` `,new Date(e.created_at).toLocaleTimeString()]})]})]})},Re=a(`components:ttsbutton`),ze=null,Be=null,Ve=0,He=300*1e3;async function Ue(){let e=Date.now();return ze!==null&&e-Ve<He?ze:Be||(Be=(async()=>{try{let t=await ve.getModels();return t.success&&t.data&&t.data.length>0?(ze=t.data,Ve=e,t.data):(ze=[],Ve=e,[])}catch{return ze=[],Ve=e,[]}finally{Be=null}})(),Be)}function We(e){return e.split(/(?<=[.!?]["']?\s)|(?<=[.!?]["']?$)/).map(e=>e.trim()).filter(e=>e.length>0)}var Ge=({text:e,className:t,size:n=`sm`})=>{let{t:r}=J(),{preferences:i}=je(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)(null),h=(0,Y.useRef)(null),_=(0,Y.useRef)(!1),v=(0,Y.useRef)([]),y=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{let e=!0;return Ue().then(t=>{e&&(f(t),m(t.length>0))}),()=>{e=!1}},[]);let b=(0,Y.useCallback)(async(e,t,n,i)=>{let a=await ve.generateBase64({model:t,input:e,voice:n,speed:i,response_format:`mp3`});if(!a.success||!a.data?.audio)throw Error(a.message||r(`ttsButton.generateFailed`));let o=`data:${a.data.mimeType};base64,${a.data.audio}`,s=new Audio(o);return h.current=s,new Promise((e,t)=>{s.onended=()=>{h.current=null,e()},s.onerror=()=>{h.current=null,t(Error(r(`ttsButton.playbackFailed`)))},s.play().catch(t)})},[r]),x=(0,Y.useCallback)(async(e,t,n,r)=>{v.current=e,y.current=0,_.current=!1;let i=null,a=async e=>{try{let i=await ve.generateBase64({model:t,input:e,voice:n,speed:r,response_format:`mp3`});return!i.success||!i.data?.audio?null:{audioUrl:`data:${i.data.mimeType};base64,${i.data.audio}`,mimeType:i.data.mimeType}}catch{return null}};e.length>0&&(i=a(e[0]));for(let t=0;t<e.length&&!_.current;t++){y.current=t;try{let n=await i;if(_.current)break;if(i=t+1<e.length?a(e[t+1]):null,!n){Re.warn(`Failed to generate audio for sentence ${t+1}, skipping`);continue}let r=new Audio(n.audioUrl);h.current=r,await new Promise((e,t)=>{r.onended=()=>{h.current=null,e()},r.onerror=()=>{h.current=null,e()},r.play().catch(()=>{e()})})}catch(e){Re.error(`Error playing sentence ${t+1}:`,e)}}},[]),S=(0,Y.useCallback)(()=>{_.current=!0,h.current&&(h.current.pause(),h.current.currentTime=0,h.current=null),o(!1),c(!1)},[]),C=async()=>{if(!s){if(a){S();return}c(!0),u(null),_.current=!1;try{let t=i.ttsSettings,n=t?.model||d[0]?.model||`tts-1`,a=t?.voice||d[0]?.config?.default_voice||`alloy`,s=t?.speed||1;if(t?.streamSentences){let t=We(e);if(t.length===0)throw Error(r(`ttsButton.generateFailed`));c(!1),o(!0),await x(t,n,a,s),_.current||o(!1)}else await b(e,n,a,s),c(!1),o(!0),h.current&&(h.current.onended=()=>{o(!1),h.current=null},h.current.onerror=()=>{u(r(`ttsButton.playbackFailed`)),o(!1),h.current=null})}catch(e){u(e instanceof Error?e.message:r(`ttsButton.generateFailed`)),Re.error(`TTS error:`,e),o(!1),c(!1)}}};if((0,Y.useEffect)(()=>()=>{_.current=!0,h.current&&(h.current.pause(),h.current=null)},[]),p===!1||p===null)return null;let w={sm:`h-6 w-6 p-1`,md:`h-8 w-8 p-1.5`,lg:`h-10 w-10 p-2`},T={sm:`h-3.5 w-3.5`,md:`h-4 w-4`,lg:`h-5 w-5`};return(0,X.jsx)(`button`,{onClick:C,disabled:s||!e,title:l||r(a?`ttsButton.stopSpeaking`:s?`ttsButton.generatingSpeech`:`ttsButton.readAloud`),className:W(`rounded-full transition-all duration-200`,`hover:bg-gray-100 dark:hover:bg-dark-200`,`focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-1`,`disabled:opacity-50 disabled:cursor-not-allowed`,l?`text-red-500 dark:text-red-400`:a?`text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-gray-400`,w[n],t),children:s?(0,X.jsx)(g,{className:W(T[n],`animate-spin`)}):a?(0,X.jsx)(te,{className:T[n]}):l?(0,X.jsx)(re,{className:T[n]}):(0,X.jsx)(k,{className:T[n]})})},Ke=/```([^\n`]*)\n([\s\S]*?)\n```/g,qe=/[\w@./-]+\.(?:html?|css|mjs|js|jsx|ts|tsx|svg|json|py)/i,Je=[`html`,`react`,`svg`,`mermaid`,`chart`,`code`,`text`,`json`],Ye=[{regex:/<artifact\s+type="([^"]+)"\s+title="([^"]+)"[^>]*>([\s\S]*?)<\/artifact>/gi,extract:e=>({type:rt(e[1]),title:Xe(e[2]).trim()||`Artifact`,content:e[3].trim()})},{regex:/<artifact\s+type="([^"]+)"[^>]*>([\s\S]*?)<\/artifact>/gi,extract:e=>{let t=rt(e[1]);return{type:t,title:`${t.toUpperCase()} Artifact`,content:e[2].trim()}}}];function Xe(e){if(typeof document<`u`){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent||t.innerText||``}return Qe(Ze(e))}function Ze(e){return e.replace(/&(lt|gt|quot|apos|#39);/gi,(e,t)=>{switch(t.toLowerCase()){case`lt`:return`<`;case`gt`:return`>`;case`quot`:return`"`;case`apos`:case`#39`:return`'`;default:return``}}).replace(/&/gi,`&`)}function Qe(e){let t=``,n=!1,r=null;for(let i=0;i<e.length;i+=1){let a=e[i];if(n){if(r){a===r&&(r=null);continue}if(a===`"`||a===`'`){r=a;continue}a===`>`&&(n=!1);continue}if(a===`<`){let t=e[i+1];if(t&&/[!/A-Za-z?]/.test(t)){n=!0;continue}}t+=a}return t}function $e(e){let t=e.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(t)return Xe(t[1]).trim()||null;let n=e.match(/<h1[^>]*>([\s\S]*?)<\/h1>/i);return n&&Xe(n[1]).trim()||null}function et(e){let t=e.match(/(?:function|const)\s+(\w+)/);if(t)return t[1];let n=e.match(/class\s+(\w+)/);return n?n[1]:null}function tt(e){if(e.includes(`def main(`))return`Python Script`;let t=e.match(/class\s+(\w+)/);if(t)return`${t[1]} Class`;let n=e.match(/def\s+(\w+)/);return n&&n[1]!==`__init__`?`${n[1]} Function`:null}function nt(e){let t=e.match(/function\s+(\w+)/);if(t)return`${t[1]} Function`;let n=e.match(/(?:const|let)\s+(\w+)\s*=/);return n?n[1]:null}function rt(e){let t=e.trim().toLowerCase();return Je.includes(t)?t:`text`}function Z(e){if(!e)return;let t=e.trim().toLowerCase().replace(/^\./,``).replace(/[,:;]+$/,``);switch(t){case`htm`:case`html`:return`html`;case`js`:case`mjs`:case`javascript`:return`javascript`;case`jsx`:case`tsx`:case`react`:return`react`;case`ts`:case`typescript`:return`typescript`;case`py`:case`python`:return`python`;case`css`:case`svg`:case`json`:return t;default:return t||void 0}}function it(e){let t=[],n=new RegExp(Ke),r;for(;(r=n.exec(e))!==null;){let n=r[1].trim(),i=at(n,st(e,r.index));t.push({raw:r[0],info:n,content:r[2].trim(),start:r.index,end:r.index+r[0].length,language:i.language,fileName:i.fileName})}return t}function at(e,t){let n=ot(e)||t,r=e.split(/\s+/).filter(Boolean)[0]?.replace(/[{}[\]()]/g,``);return{language:(r&&!qe.test(r)&&!r.includes(`=`)?Z(r):void 0)||Z(lt(n)),fileName:n}}function ot(e){let t=e.match(/(?:file(?:name)?|path|name)\s*=\s*["']?([^"'\s]+)["']?/i);if(t&&qe.test(t[1]))return ct(t[1]);let n=e.match(qe);return n?ct(n[0]):void 0}function st(e,t){let n=e.slice(Math.max(0,t-180),t).split(`
|
|
2
|
+
`).slice(-3).reverse();for(let e of n){let t=e.trim().replace(/^#{1,6}\s*/,``).replace(/^[-*]\s*/,``).replace(/[::]\s*$/,``).match(qe);if(t)return ct(t[0])}}function ct(e){return e.replace(/^["'`]+|["'`:]+$/g,``)}function lt(e){return e?.match(/\.([a-z0-9]+)$/i)?.[1]}function ut(e){return e?.split(/[\\/]/).pop()}function Q(e){let t=ut(e);if(!t)return null;let n=t.replace(/\.[^.]+$/,``);return/^(index|main|app)$/i.test(n)?null:n.replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function dt(e){let t=Date.now();return{...e,id:`artifact-${t}-${Math.random().toString(36).slice(2,11)}`,createdAt:t,updatedAt:t}}function ft(e){let t=Z(e.language)||Z(lt(e.fileName));switch(t){case`html`:return{type:`html`,title:$e(e.content)||Q(e.fileName)||`HTML Document`};case`svg`:return{type:`svg`,title:Q(e.fileName)||`SVG Image`};case`react`:return{type:`react`,title:et(e.content)||Q(e.fileName)||`React Component`,language:`jsx`};case`json`:return{type:`json`,title:Q(e.fileName)||`JSON Data`};case`python`:return{type:`code`,title:tt(e.content)||Q(e.fileName)||`Python Code`,language:`python`};case`css`:return{type:`code`,title:Q(e.fileName)||`CSS Styles`,language:`css`};case`javascript`:return{type:`code`,title:nt(e.content)||Q(e.fileName)||`JavaScript Code`,language:`javascript`};case`typescript`:return{type:`code`,title:Q(e.fileName)||`TypeScript Code`,language:`typescript`};default:return t?{type:`code`,title:Q(e.fileName)||`${t.toUpperCase()} Code`,language:t}:null}}function pt(e){return(Z(e.language)||Z(lt(e.fileName)))===`html`}function mt(e){return(Z(e.language)||Z(lt(e.fileName)))===`css`}function ht(e){return(Z(e.language)||Z(lt(e.fileName)))===`javascript`}function gt(e){let t=it(e),n=t.filter(pt);if(n.length===0)return null;let r=t.filter(mt),i=t.filter(ht);if(r.length===0&&i.length===0)return null;let a=n.find(e=>/(^|[/\\])index\.html?$/i.test(e.fileName||``))||n[0],o=Ne(_t(a.content,r,i),r.map(e=>e.content),i.map(e=>e.content));return St(o,`html`)?{artifact:dt({type:`html`,title:$e(o)||Q(a.fileName)||`Interactive HTML App`,description:`Bundled generated HTML, CSS, and JavaScript files into one runnable artifact.`,content:o}),ranges:[a,...r,...i]}:null}function _t(e,t,n){let r=e;for(let e of t){let t=ut(e.fileName);t&&(r=r.replace(RegExp(`<link\\b[^>]*href=["'][^"']*${xt(t)}["'][^>]*>`,`gi`),``))}for(let e of n){let t=ut(e.fileName);t&&(r=r.replace(RegExp(`<script\\b[^>]*src=["'][^"']*${xt(t)}["'][^>]*>\\s*<\\/script>`,`gi`),``))}return r}function vt(e){let t=/<!doctype\s+html|<html[\s>]/i.exec(e);if(!t||t.index===void 0)return null;let n=it(e);if(yt(t.index,n))return null;let r=t.index,i=/<\/html>/gi;i.lastIndex=r;let a=i.exec(e),o=a?a.index+a[0].length:e.length,s=e.slice(r,o).trim();return St(s,`html`)?{artifact:dt({type:`html`,title:$e(s)||`HTML Document`,content:s}),ranges:[{start:r,end:o}]}:null}function yt(e,t){return t.some(t=>e>=t.start&&e<=t.end)}function bt(e,t){return[...t].sort((e,t)=>t.start-e.start).reduce((e,t)=>`${e.slice(0,t.start)}${e.slice(t.end)}`,e)}function xt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function St(e,t){if(t===`html`){let t=e.trim(),n=/<[^>]+>/.test(t),r=/<(canvas|script|style|button|form|input|select|textarea|video|audio)\b/i.test(t)||/\bon(?:click|input|submit|keydown|keyup|mousemove)=/i.test(t);return n&&(Pe(t)||t.length>160||r)}if(t===`svg`)return/<svg[^>]*>/.test(e);if(t===`react`)return/<[A-Z][^>]*>/.test(e)||/return\s*\(/.test(e);if(t===`json`)try{return JSON.parse(e),e.trim().length>100}catch{return!1}if(t===`code`){let t=e.split(`
|
|
3
|
+
`).length,n=e.trim().length,r=/function|class|def |import |from |const |let |var |if |for |while |try |catch/.test(e);return(n>500||t>15)&&r}return e.trim().length>200}function Ct(e){let t=[],n=e;for(let e of Ye){e.regex.lastIndex=0;let r=[],i;for(;(i=e.regex.exec(n))!==null;){let n=e.extract(i);St(n.content,n.type)&&(t.push(dt({type:n.type,title:n.title,content:n.content})),r.push({start:i.index,end:i.index+i[0].length}))}n=bt(n,r)}let r=gt(n);for(;r;)t.push(r.artifact),n=bt(n,r.ranges),r=gt(n);let i=vt(n);i&&(t.push(i.artifact),n=bt(n,i.ranges));let a=it(n),o=[];for(let e of a){let n=ft(e);!n||!St(e.content,n.type)||(t.push(dt({type:n.type,title:n.title,content:e.content,language:n.language})),o.push(e))}return n=bt(n,o),{content:n.trim(),artifacts:t}}var wt=a(`components:chat-message`),Tt=({message:e,isStreaming:t=!1,className:n,isLastAssistantMessage:r=!1,onRegenerate:i})=>{let{t:a}=J(),o=e.role===`user`,s=e.role===`system`,{preferences:c}=je(),{user:u}=Oe(),{setSystemMessage:d,getCurrentPersona:f}=K(),p=f(),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(e.content),[y,b]=(0,Y.useState)(null),[x,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(!1),N=(0,Y.useRef)(null),ee=(0,Y.useRef)(t),P=(0,Y.useRef)(!1),te=async()=>{try{await navigator.clipboard.writeText(e.content),M(!0),setTimeout(()=>M(!1),2e3)}catch(e){wt.error(`Failed to copy message:`,e)}},{thinkingContent:re,parsedContent:F,artifacts:I}=(0,Y.useMemo)(()=>{if(o||s||!e.content)return{thinkingContent:null,parsedContent:e.content,artifacts:e.artifacts||[]};let n=Se(e.content),r=n.content;if(e.artifacts&&e.artifacts.length>0)return{thinkingContent:n.thinking,parsedContent:r,artifacts:e.artifacts};if(!t){let e=Ct(r);return{thinkingContent:n.thinking,parsedContent:e.content,artifacts:e.artifacts}}return{thinkingContent:n.thinking,parsedContent:r,artifacts:[]}},[e.content,e.artifacts,o,s,t]);(0,Y.useEffect)(()=>{let e=ee.current&&!t;return ee.current=t,e&&!P.current&&!o&&!s&&F&&c.ttsSettings?.enabled&&c.ttsSettings?.autoPlay&&(P.current=!0,(async()=>{A(!0);try{let e=await ve.generateBase64({model:c.ttsSettings?.model||`tts-1`,input:F,voice:c.ttsSettings?.voice||`alloy`,speed:c.ttsSettings?.speed||1,response_format:`mp3`});if(e.success&&e.data?.audio){let t=`data:${e.data.mimeType};base64,${e.data.audio}`,n=new Audio(t);N.current=n,n.onended=()=>{A(!1),N.current=null},n.onerror=()=>{A(!1),N.current=null},await n.play()}}catch(e){wt.error(`Auto-play TTS failed:`,e),A(!1)}})()),()=>{N.current&&(N.current.pause(),N.current=null)}},[t,o,s,F,c.ttsSettings]);let ae=()=>s?a(`chatMessage.system`):o?c.showUsername&&u?.username?u.username:a(`chatMessage.you`):p?.name?p.name:e.model||a(`chatMessage.assistant`),oe=()=>{g(!0),v(e.content)},se=async()=>{C(!0);try{d(_),g(!1),wt.debug(`✅ System message updated:`,_)}catch(e){wt.error(`Failed to save system message:`,e)}finally{C(!1)}},R=()=>{g(!1),v(e.content)},ce=(e,t=100)=>e.length<=t?e:e.substring(0,t)+`...`,z=s&&e.content.length>100;return(0,X.jsxs)(`div`,{className:W(`flex transition-colors group my-2`,o?`justify-end`:`justify-start`,n),children:[(0,X.jsxs)(`div`,{className:W(`flex gap-3 sm:gap-4`,o?`flex-row-reverse max-w-[85%] sm:max-w-[75%]`:s?`w-full`:`max-w-[85%] sm:max-w-[75%]`),children:[!s&&(0,X.jsx)(`div`,{className:W(`flex shrink-0 items-center justify-center shadow-sm overflow-hidden mt-1`,o?`h-8 w-8 rounded-full bg-primary-600 text-white`:p?.avatar?`h-8 w-8 rounded-full bg-white dark:bg-dark-100`:`h-8 px-2 rounded-full bg-white dark:bg-dark-100`),children:o?u?.avatar?(0,X.jsx)(`img`,{src:u.avatar,alt:u.username,className:`w-full h-full object-cover`}):(0,X.jsx)(ie,{className:`h-4 w-4`}):p?.avatar?(0,X.jsx)(`img`,{src:p.avatar,alt:p.name||`Assistant`,className:`w-full h-full object-cover`}):(0,X.jsx)(`span`,{className:`libre-brand text-xs text-gray-700 dark:text-gray-200`,children:`Libre`})}),(0,X.jsxs)(`div`,{className:W(`flex-1 min-w-0 rounded-2xl sm:rounded-3xl p-4 sm:p-5`,o?`bg-primary-600/90 dark:bg-primary-700/90 text-white`:s?`bg-transparent p-2 py-3`:`bg-white/95 dark:bg-dark-100/95 backdrop-blur-md shadow-sm border border-gray-200/50 dark:border-dark-300/50`),children:[!s&&(0,X.jsxs)(`div`,{className:W(`flex items-center gap-3 mb-2`,o&&`flex-row-reverse`),children:[(0,X.jsx)(`span`,{className:W(`text-sm font-semibold`,o?`text-white/90`:`text-gray-900 dark:text-dark-800`),children:ae()}),e.model&&!o&&p?.name&&(0,X.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-dark-600 bg-gray-100 dark:bg-dark-200 px-2 py-0.5 rounded-full truncate max-w-32 sm:max-w-48`,title:e.model,children:e.model}),(0,X.jsx)(`span`,{className:W(`text-xs`,o?`text-white/60`:`text-gray-400 dark:text-dark-500`),children:Ce(e.timestamp)}),!o&&!s&&!t&&F&&(0,X.jsx)(Ge,{text:F,size:`sm`,className:W(`transition-opacity`,k?`opacity-100 text-primary-600 dark:text-primary-400`:`opacity-0 group-hover:opacity-100`)}),!s&&!t&&(0,X.jsx)(`button`,{onClick:te,className:`p-1 rounded hover:bg-gray-100 dark:hover:bg-dark-200 transition-opacity opacity-0 group-hover:opacity-100`,title:a(j?`chatMessage.copied`:`chatMessage.copyMessage`),children:j?(0,X.jsx)(V,{className:`h-3.5 w-3.5 text-green-500 dark:text-green-400`}):(0,X.jsx)(B,{className:`h-3.5 w-3.5 text-gray-500 dark:text-gray-400`})}),!o&&!s&&!t&&r&&i&&(0,X.jsx)(`button`,{onClick:i,className:`p-1 rounded hover:bg-gray-100 dark:hover:bg-dark-200 transition-opacity opacity-0 group-hover:opacity-100`,title:a(`chatMessage.regenerateResponse`),children:(0,X.jsx)(S,{className:`h-3.5 w-3.5 text-gray-500 dark:text-gray-400`})})]}),(0,X.jsxs)(`div`,{className:W(o?`text-white`:`text-gray-700 dark:text-dark-700`),children:[e.images&&e.images.length>0&&(0,X.jsx)(`div`,{className:`mb-3 grid grid-cols-2 sm:grid-cols-3 gap-2 max-w-lg`,children:e.images.map((e,t)=>(0,X.jsx)(`div`,{className:`aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:(0,X.jsx)(`img`,{src:e,alt:`Uploaded image ${t+1}`,className:`w-full h-full object-cover cursor-pointer hover:opacity-90 transition-opacity`,onClick:()=>b(e)})},t))}),o?(0,X.jsx)(`p`,{className:`whitespace-pre-wrap leading-relaxed`,children:e.content}):s?(0,X.jsxs)(`div`,{className:`bg-gray-50/30 dark:bg-dark-50/30 rounded-md p-2 border border-gray-100/50 dark:border-dark-200/50 relative z-0`,children:[(0,X.jsxs)(`div`,{className:`text-xs font-medium mb-1 text-gray-500 dark:text-gray-400 flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(H,{className:`h-2.5 w-2.5 opacity-50`}),a(`chatMessage.system`)]}),(0,X.jsx)(`div`,{className:`flex items-center gap-1`,children:h?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{onClick:se,disabled:x,className:`p-1 hover:bg-gray-100 dark:hover:bg-dark-200 rounded transition-colors disabled:opacity-50`,title:a(`chatMessage.saveChanges`),children:(0,X.jsx)(l,{className:`h-3 w-3 text-green-600 dark:text-green-400`})}),(0,X.jsx)(`button`,{onClick:R,disabled:x,className:`p-1 hover:bg-gray-100 dark:hover:bg-dark-200 rounded transition-colors disabled:opacity-50`,title:a(`chatMessage.cancelEditing`),children:(0,X.jsx)(L,{className:`h-3 w-3 text-red-600 dark:text-red-400`})})]}):(0,X.jsx)(`button`,{onClick:oe,className:`p-1 hover:bg-gray-100 dark:hover:bg-dark-200 rounded transition-colors`,title:a(`chatMessage.editSystemMessage`),children:(0,X.jsx)(m,{className:`h-3 w-3 text-gray-600 dark:text-gray-400`})})})]}),h?(0,X.jsx)(`textarea`,{value:_,onChange:e=>v(e.target.value),className:`w-full min-h-[100px] p-3 text-sm text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:border-transparent`,placeholder:a(`chatMessage.systemMessagePlaceholder`),disabled:x}):(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`whitespace-pre-wrap leading-relaxed text-xs text-gray-500 dark:text-gray-400`,children:w?e.content:ce(e.content)}),z&&(0,X.jsx)(`button`,{onClick:()=>T(!w),className:`mt-1 flex items-center gap-1 text-xs text-gray-400 dark:text-gray-500 hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:w?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{className:`h-3 w-3`}),a(`chatMessage.showLess`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{className:`h-3 w-3`}),a(`chatMessage.showMore`)]})})]})]}):(0,X.jsxs)(`div`,{className:`relative`,children:[re&&(0,X.jsxs)(`div`,{className:`mb-3`,children:[(0,X.jsxs)(`button`,{onClick:()=>D(!E),className:`flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:[(0,X.jsx)(de,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`font-medium`,children:a(`chatMessage.thinking`)}),E?(0,X.jsx)(ne,{className:`h-4 w-4`}):(0,X.jsx)(O,{className:`h-4 w-4`})]}),E&&(0,X.jsx)(`div`,{className:`mt-2 p-3 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,X.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-300 whitespace-pre-wrap leading-relaxed`,children:re})})]}),(0,X.jsx)(Ae,{content:F,isStreaming:t}),t&&!F.includes("```")&&(0,X.jsx)(`div`,{className:`inline-block w-2 h-5 bg-primary-500 animate-pulse ml-1 rounded-sm`})]}),!o&&!s&&I.length>0&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Fe,{artifacts:I})}),!o&&!s&&e.statistics&&(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(Le,{statistics:e.statistics})})]})]})]}),y&&(0,Ie.createPortal)((0,X.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm`,onClick:()=>b(null),children:[(0,X.jsx)(`button`,{className:`absolute top-6 right-6 p-3 bg-white/20 hover:bg-white/40 rounded-full text-white transition-all shadow-lg border border-white/30`,onClick:e=>{e.stopPropagation(),b(null)},children:(0,X.jsx)(L,{className:`h-7 w-7`})}),(0,X.jsx)(`img`,{src:y,alt:a(`chatMessage.fullSizeImage`),className:`max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl`,onClick:e=>e.stopPropagation()})]}),document.body)]})},Et=({messages:e,isStreaming:t=!1,streamingMessage:n,streamingMessageId:r,isLastAssistantMessage:i=!1,onRegenerate:a,onSelectBranch:o,className:s})=>{if(e.length===1){let o=e[0],c=t&&r===o.id;return(0,X.jsx)(Tt,{message:c&&n?{...o,content:n}:o,isStreaming:c,isLastAssistantMessage:i,onRegenerate:a,className:s})}return(0,X.jsxs)(`div`,{className:W(`relative py-1`,s),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 px-4 pb-2 text-[10px] text-gray-400 dark:text-gray-500`,children:[(0,X.jsx)(D,{className:`h-3 w-3`}),(0,X.jsxs)(`span`,{children:[e.length,` variants`]})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 px-4`,children:e.map((e,s)=>{let c=e.isActive!==!1,l=t&&r===e.id,u=l&&n?{...e,content:n}:e;return(0,X.jsxs)(`div`,{className:W(`relative rounded-lg overflow-hidden transition-all duration-200`,`border shadow-sm`,c||l?`border-primary-300 dark:border-primary-600 shadow-primary-100 dark:shadow-primary-900/20`:`border-gray-200 dark:border-dark-300 hover:border-gray-300 dark:hover:border-dark-400`,!c&&!l&&`cursor-pointer hover:shadow-md`),onClick:()=>!c&&!l&&o?.(e.id),children:[(0,X.jsxs)(`div`,{className:W(`flex items-center justify-between px-2.5 py-1 text-[11px]`,c||l?`bg-primary-50/80 dark:bg-primary-900/20 text-primary-600 dark:text-primary-400`:`bg-gray-50/80 dark:bg-dark-100/80 text-gray-500 dark:text-gray-500`),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:s+1}),l&&(0,X.jsx)(`span`,{className:`text-[10px] opacity-70 animate-pulse`,children:`generating...`})]}),c&&!l&&(0,X.jsx)(V,{className:`h-3 w-3`}),!c&&!l&&(0,X.jsx)(`span`,{className:`text-[10px] opacity-50`,children:`select`})]}),(0,X.jsx)(`div`,{className:W(`bg-white dark:bg-dark-50`,!c&&!l&&`opacity-80`),children:(0,X.jsx)(Tt,{message:u,isStreaming:l,isLastAssistantMessage:i&&(c||l),onRegenerate:c&&!t?a:void 0,className:`!bg-transparent !p-3 !text-sm`})})]},e.id)})})]})},Dt={web_search:b,web_fetch:E,exec:ee,browser:E,Read:z,Write:z,Edit:z,image:w,memory_search:j,memory_get:j,working:se,thinking:se,default:se},Ot={web_search:`Searching the web`,web_fetch:`Fetching page`,exec:`Running command`,browser:`Using browser`,Read:`Reading file`,Write:`Writing file`,Edit:`Editing file`,image:`Analyzing image`,memory_search:`Searching memory`,memory_get:`Reading memory`,cron:`Managing schedule`,message:`Sending message`,tts:`Generating speech`,nodes:`Checking devices`,sessions_spawn:`Spawning agent`,canvas:`Rendering canvas`,process:`Managing process`,working:`Using tools`,thinking:`Thinking`},kt=({tools:e,className:t})=>{if(e.length===0)return null;let n=e.filter(e=>e.phase!==`result`&&e.phase!==`done`);return n.length===0?null:(0,X.jsx)(`div`,{className:W(`flex flex-col gap-1 py-2 px-1`,t),children:n.map(e=>{let t=Dt[e.name]||Dt.default,n=Ot[e.name]||`Using ${e.name}`,r=e.phase===`result`;return(0,X.jsxs)(`div`,{className:W(`flex items-center gap-2 text-sm transition-all duration-300`,r?`text-green-600 dark:text-green-400 opacity-60`:`text-gray-500 dark:text-gray-400`),children:[(0,X.jsx)(`div`,{className:W(`flex items-center justify-center w-5 h-5`,!r&&`animate-spin-slow`),children:(0,X.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-xs font-medium`,children:r?`✓ ${n}`:`${n}…`}),!r&&(0,X.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,X.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`0ms`}}),(0,X.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`150ms`}}),(0,X.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`300ms`}})]})]},e.toolCallId)})})};a(`components:chat-messages`);var At=({messages:e,streamingMessage:t,streamingMessageId:n,isStreaming:r=!1,toolActivities:i=[],className:a,onRegenerate:o,onSelectBranch:s})=>{let{t:c}=J(),l=(0,Y.useRef)(null),u=(0,Y.useRef)(),d=(0,Y.useRef)(null),f=(0,Y.useRef)(!1),[p,m]=(0,Y.useState)(!1),h=(0,Y.useMemo)(()=>{let t=[],n=new Set,r=[...e].sort((e,t)=>e.role===`system`&&t.role!==`system`?-1:t.role===`system`&&e.role!==`system`?1:e.parentId===t.parentId?(e.branchIndex||0)-(t.branchIndex||0):e.timestamp-t.timestamp);for(let i of r){if(n.has(i.id))continue;let r=i.parentId;if(r){let a=t.findIndex(e=>e.id===r);if(a>=0)t[a].messages.push(i);else{let a=e.find(e=>e.id===r);a&&!n.has(r)?(t.push({id:r,messages:[a,i],messageIndex:t.length}),n.add(r)):t.push({id:i.id,messages:[i],messageIndex:t.length})}n.add(i.id)}else{let r=e.filter(e=>e.parentId===i.id);r.length>0?(t.push({id:i.id,messages:[i,...r],messageIndex:t.length}),n.add(i.id),r.forEach(e=>n.add(e.id))):(t.push({id:i.id,messages:[i],messageIndex:t.length}),n.add(i.id))}}return t.sort((e,t)=>{let n=e.messages[0],r=t.messages[0];return n.role===`system`&&r.role!==`system`?-1:r.role===`system`&&n.role!==`system`?1:n.timestamp-r.timestamp})},[e]),g=(0,Y.useCallback)((e=!1)=>{f.current&&!e||l.current?.scrollIntoView({behavior:`smooth`})},[]),_=(0,Y.useCallback)(()=>{let t=d.current;if(!t)return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t,a=r-n-i<100;f.current=!a,m(!a&&e.length>0)},[e.length]),v=(0,Y.useRef)(e.length);if((0,Y.useEffect)(()=>{e.length>v.current&&!f.current&&g(),v.current=e.length},[e.length,g]),(0,Y.useEffect)(()=>{r&&t&&!f.current&&requestAnimationFrame(()=>{let e=d.current;e&&(e.scrollTop=e.scrollHeight)})},[r,t]),(0,Y.useEffect)(()=>{let e=u.current;return()=>{e&&clearTimeout(e)}},[]),e.length===0&&!r)return(0,X.jsx)(`div`,{className:W(`flex-1 flex items-center justify-center p-4 sm:p-8`,a),children:(0,X.jsxs)(`div`,{className:`text-center text-gray-500 dark:text-dark-600 max-w-md`,children:[(0,X.jsx)(`div`,{className:`text-5xl sm:text-7xl mb-4 sm:mb-6 opacity-60`,children:`💬`}),(0,X.jsx)(`h3`,{className:`text-lg sm:text-xl font-semibold mb-2 sm:mb-3 text-gray-700 dark:text-dark-700`,children:c(`chatMessage.startConversation`)}),(0,X.jsx)(`p`,{className:`text-sm leading-relaxed px-4`,children:c(`chatMessage.startConversationDescription`)})]})});let y=-1;for(let e=h.length-1;e>=0;e--)if(h[e].messages.some(e=>e.role===`assistant`)){y=e;break}return(0,X.jsxs)(`div`,{ref:d,onScroll:_,className:W(`relative flex-1 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600`,`scrollbar-track-transparent hover:scrollbar-thumb-gray-400 dark:hover:scrollbar-thumb-gray-500`,`overscroll-behavior-y-contain`,`[-webkit-overflow-scrolling:touch]`,a),style:{WebkitOverflowScrolling:`touch`,overscrollBehaviorY:`contain`,WebkitAppRegion:`no-drag`},children:[(0,X.jsxs)(`div`,{className:`max-w-5xl mx-auto px-3 sm:px-4 md:px-6 w-full min-w-0`,children:[h.map((e,i)=>{let a=i===y,c=r&&e.messages.some(e=>e.id===n);if(e.messages.length===1){let s=e.messages[0],c=r&&s.id===n;return(0,X.jsx)(Tt,{message:c&&t?{...s,content:t}:s,isStreaming:c,isLastAssistantMessage:a,onRegenerate:a?o:void 0,className:i===0?`mt-3 sm:mt-4 md:mt-6`:``},s.id)}return(0,X.jsx)(Et,{messages:e.messages,isStreaming:c,streamingMessage:t,streamingMessageId:n||void 0,isLastAssistantMessage:a,onRegenerate:a?o:void 0,onSelectBranch:s,className:i===0?`mt-3 sm:mt-4 md:mt-6`:``},e.id)}),r&&i.length>0&&(0,X.jsx)(kt,{tools:i,className:`ml-10 sm:ml-12`}),(0,X.jsx)(`div`,{ref:l,className:`h-3 sm:h-4 md:h-6`})]}),p&&(0,X.jsxs)(`button`,{onClick:()=>{f.current=!1,l.current?.scrollIntoView({behavior:`smooth`}),m(!1)},className:W(`absolute bottom-4 left-1/2 -translate-x-1/2 z-10`,`flex items-center justify-center gap-1.5`,`px-3 py-2 rounded-full`,`bg-white/95 dark:bg-dark-100/95`,`border border-gray-200/50 dark:border-dark-300/50`,`shadow-lg backdrop-blur-sm`,`text-gray-600 dark:text-dark-600`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`hover:text-gray-900 dark:hover:text-dark-800`,`transition-all duration-200`,`hover:shadow-xl hover:scale-105 active:scale-95`),title:c(`chatMessage.scrollToBottom`),children:[(0,X.jsx)(C,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-xs font-medium`,children:c(`chatMessage.newMessages`)})]})]})};function jt(e){let t=(e.match(/```/g)||[]).length,n=t%2==1,r=null;if(n){let t=e.lastIndexOf("```");if(t!==-1){let n=e.slice(t+3).match(/^(\w+)/);n&&(r=n[1])}}return{hasCodeBlocks:t>0,isInCodeBlock:n,language:r}}var Mt=Y.forwardRef(({value:e,onChange:t,className:n,placeholder:r,disabled:i,onKeyDown:a,...o},s)=>{let{hasCodeBlocks:c,isInCodeBlock:l,language:u}=(0,Y.useMemo)(()=>jt(e),[e]);return(0,X.jsxs)(`div`,{className:`relative w-full`,children:[(0,X.jsx)(`textarea`,{ref:s,value:e,onChange:t,onKeyDown:a,placeholder:r,disabled:i,className:W(`w-full resize-none transition-all duration-200`,l&&[`font-mono text-[13px]`,`bg-gray-50 dark:bg-dark-100/50`,`rounded-lg`],n),...o}),c&&(0,X.jsx)(`div`,{className:`absolute right-0 top-0 pointer-events-none flex items-center gap-1`,children:(0,X.jsxs)(`div`,{className:W(`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-500 dark:text-gray-400`,`border border-gray-200/50 dark:border-dark-300/50`,l&&`animate-pulse`),children:[(0,X.jsx)(y,{className:`h-3 w-3`}),u&&(0,X.jsx)(`span`,{children:u}),!u&&l&&(0,X.jsx)(`span`,{children:`code`})]})})]})});Mt.displayName=`CodeAwareTextarea`;var Nt=a(`components:media-upload`),Pt=({images:e,onImagesChange:t,maxImages:n=5,sessionId:r,onDocumentUploaded:i,disabled:a=!1,className:o})=>{let{t:s}=J(),c=(0,Y.useRef)(null),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)([]),h=async e=>{if(!(!e||a))for(let t=0;t<e.length;t++){let n=e[t];n.type.startsWith(`image/`)?await _(n):n.type.includes(`pdf`)||n.type.includes(`text`)?await v(n):T.error(`File type not supported: ${n.name}`)}},_=async r=>{if(n-e.length<=0){T.error(`Maximum ${n} images allowed`);return}if(r.size>10*1024*1024){T.error(`Image ${r.name} is too large (max 10MB)`);return}let i=new FileReader;i.onload=n=>{n.target?.result&&t([...e,n.target.result])},i.readAsDataURL(r)},v=async e=>{if(e.size>10*1024*1024){T.error(`File size must be less than 10MB`);return}f(!0);try{let t=await ge.uploadDocument(e,r);if(t.success&&t.data){let n=t.data;m(e=>[...e,n]),i?.(n),T.success(`Document "${e.name}" uploaded`)}else T.error(t.error||`Failed to upload document`)}catch(e){Nt.error(`Document upload error:`,e),T.error(`Failed to upload document`)}finally{f(!1)}},y=e=>{e.preventDefault(),a||u(!0)},b=e=>{e.preventDefault(),u(!1)},x=e=>{e.preventDefault(),u(!1),a||h(e.dataTransfer.files)},S=n=>{t(e.filter((e,t)=>t!==n))},C=async e=>{try{let t=await ge.deleteDocument(e);t.success?(m(t=>t.filter(t=>t.id!==e)),T.success(`Document removed`)):T.error(t.error||`Failed to remove document`)}catch(e){Nt.error(`Error removing document:`,e),T.error(`Failed to remove document`)}},w=e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(1))+` `+n[r]},E=e.length>0||p.length>0;return(0,X.jsxs)(`div`,{className:W(`space-y-3`,o),children:[(0,X.jsxs)(`div`,{className:W(`border-2 border-dashed rounded-xl p-6 transition-all duration-200 cursor-pointer`,`border-gray-300 dark:border-gray-600`,`hover:border-primary-400 dark:hover:border-primary-500`,l&&`border-primary-500 dark:border-primary-400 bg-primary-50/50 dark:bg-primary-900/10`,a&&`opacity-50 cursor-not-allowed`),onDragOver:y,onDragLeave:b,onDrop:x,onClick:()=>!a&&c.current?.click(),children:[(0,X.jsx)(`input`,{ref:c,type:`file`,multiple:!0,accept:`image/*,.pdf,.txt`,onChange:e=>{h(e.target.files),e.target.value=``},className:`hidden`,disabled:a}),(0,X.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[d?(0,X.jsx)(g,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2 animate-spin`}):(0,X.jsx)(A,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2`}),(0,X.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:[s(`chat.mediaUpload.dropImagesHere`),` `,(0,X.jsx)(`span`,{className:`text-primary-600 dark:text-primary-400 font-medium`,children:s(`chat.mediaUpload.browse`)})]}),(0,X.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:s(`chat.mediaUpload.supportedFormats`)})]})]}),E&&(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.map((e,t)=>(0,X.jsxs)(`div`,{className:`relative group w-16 h-16 rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[(0,X.jsx)(`img`,{src:e,alt:`Upload ${t+1}`,className:`w-full h-full object-cover`}),(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S(t)},className:`absolute top-0.5 right-0.5 p-0.5 rounded-full bg-black/60 hover:bg-black/80 text-white opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,X.jsx)(L,{className:`h-3 w-3`})})]},`img-${t}`)),p.map(e=>(0,X.jsxs)(`div`,{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[e.fileType===`pdf`?(0,X.jsx)(z,{className:`w-4 h-4 text-red-500 flex-shrink-0`}):(0,X.jsx)(N,{className:`w-4 h-4 text-blue-500 flex-shrink-0`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-gray-900 dark:text-gray-100 truncate max-w-[100px]`,children:e.filename}),(0,X.jsx)(`p`,{className:`text-[10px] text-gray-500 dark:text-gray-400`,children:w(e.size)})]}),(0,X.jsx)(`button`,{onClick:t=>{t.stopPropagation(),C(e.id)},className:`p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-red-500 transition-colors`,children:(0,X.jsx)(L,{className:`h-3 w-3`})})]},e.id))]})]})},Ft=a(`components:document-indicator`),It=({sessionId:e,className:t=``})=>{let[n,r]=(0,Y.useState)([]);if((0,Y.useEffect)(()=>{e&&(async()=>{try{let t=await ge.getDocuments(e);t.success&&t.data&&r(t.data)}catch(e){Ft.error(`Failed to load documents:`,e)}})()},[e]),!e||n.length===0)return null;let i=n.reduce((e,t)=>e+t.size,0);return(0,X.jsxs)(`div`,{className:`
|
|
4
|
+
inline-flex items-center space-x-1 px-2 py-1
|
|
5
|
+
bg-blue-50 dark:bg-blue-900/20
|
|
6
|
+
border border-blue-200 dark:border-blue-800
|
|
7
|
+
rounded-md text-xs
|
|
8
|
+
${t}
|
|
9
|
+
`,title:`${n.length} document(s) available for context - Total: ${(e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(1))+` `+n[r]})(i)}`,children:[(0,X.jsx)(u,{className:`w-3 h-3 text-blue-600 dark:text-blue-400`}),(0,X.jsxs)(`span`,{className:`text-blue-700 dark:text-blue-300 font-medium`,children:[n.length,` doc`,n.length===1?``:`s`]})]})},Lt=a(`components:structured-output`),Rt=[{key:`none`,value:null},{key:`json`,value:`json`},{key:`list`,value:{type:`object`,properties:{items:{type:`array`,items:{type:`string`}}},required:[`items`]}},{key:`summary`,value:{type:`object`,properties:{title:{type:`string`},summary:{type:`string`},key_points:{type:`array`,items:{type:`string`}}},required:[`title`,`summary`,`key_points`]}},{key:`analysis`,value:{type:`object`,properties:{analysis:{type:`string`},pros:{type:`array`,items:{type:`string`}},cons:{type:`array`,items:{type:`string`}},recommendation:{type:`string`}},required:[`analysis`,`pros`,`cons`,`recommendation`]}},{key:`custom`,value:`custom`}],zt=({format:e,onFormatChange:t,className:n})=>{let{t:r}=J(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(``),c=()=>Rt.map(e=>({key:e.key,label:r(`chat.structuredOutput.${e.key}`),value:e.value,description:r(`chat.structuredOutput.${e.key}Description`)})),l=()=>{let t=c();return e===null?t[0]:e===`json`?t[1]:typeof e==`object`?t.find(t=>typeof t.value==`object`&&JSON.stringify(t.value)===JSON.stringify(e))||{key:`customSchema`,label:r(`chat.structuredOutput.custom`),value:e,description:r(`chat.structuredOutput.customSchema`)}:t[0]},u=e=>{let n=c().find(t=>t.label===e);if(n){if(n.value===`custom`){a(!0);return}a(!1),t(n.value)}};return(0,X.jsxs)(`div`,{className:W(`space-y-3`,n),children:[(0,X.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsx)(H,{className:`h-4 w-4 text-gray-500 mr-2`}),(0,X.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`chat.structuredOutput.title`)})]})}),(0,X.jsx)(De,{value:l().label,onChange:e=>u(e.target.value),options:c().map(e=>({value:e.label,label:e.label}))}),(0,X.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:l().description}),i&&(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(ke,{value:o,onChange:e=>s(e.target.value),placeholder:`{
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"field1": { "type": "string" },
|
|
13
|
+
"field2": { "type": "number" }
|
|
14
|
+
},
|
|
15
|
+
"required": ["field1"]
|
|
16
|
+
}`,rows:8,className:`font-mono text-sm`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(G,{onClick:()=>{try{t(JSON.parse(o)),a(!1)}catch(e){Lt.error(`Invalid JSON schema:`,e)}},size:`sm`,disabled:!o.trim(),children:r(`chat.structuredOutput.applySchema`)}),(0,X.jsx)(G,{onClick:()=>{a(!1),s(``)},variant:`outline`,size:`sm`,children:r(`chat.structuredOutput.cancel`)})]})]}),(()=>{let e=l();return!e.value||e.value===`json`?null:(0,X.jsxs)(`div`,{className:`mt-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md`,children:[(0,X.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,X.jsx)(M,{className:`h-4 w-4 text-gray-500 mr-2`}),(0,X.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`chat.structuredOutput.schemaPreview`)})]}),(0,X.jsx)(`pre`,{className:`text-xs text-gray-700 dark:text-gray-300 overflow-x-auto`,children:JSON.stringify(e.value,null,2)})]})})(),e&&(0,X.jsxs)(`div`,{className:`flex items-center text-xs text-green-600 dark:text-green-400`,children:[(0,X.jsx)(z,{className:`h-3 w-3 mr-1`}),r(`chat.structuredOutput.enabled`)]})]})};function Bt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Vt({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:a,hfGgufFiles:o,loadingGguf:s,pullingModel:c,pullProgress:l,setHfTask:u,setHfSort:d,onToggleHfModel:p,onPullHfGguf:m,onCancelPull:h,onRefreshHfModels:g}){let{t:_}=J();return(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(`select`,{value:e,onChange:e=>u(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,X.jsx)(`option`,{value:`text-generation`,children:_(`modelManager.huggingface.taskTextGeneration`)}),(0,X.jsx)(`option`,{value:`text-to-speech`,children:_(`modelManager.huggingface.taskTextToSpeech`)}),(0,X.jsx)(`option`,{value:`text-to-image`,children:_(`modelManager.huggingface.taskTextToImage`)}),(0,X.jsx)(`option`,{value:`automatic-speech-recognition`,children:_(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,X.jsxs)(`select`,{value:t,onChange:e=>d(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,X.jsx)(`option`,{value:`downloads`,children:_(`modelManager.huggingface.sortDownloads`)}),(0,X.jsx)(`option`,{value:`likes`,children:_(`modelManager.huggingface.sortLikes`)}),(0,X.jsx)(`option`,{value:`lastModified`,children:_(`modelManager.huggingface.sortRecent`)})]})]})}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[!n&&(0,X.jsx)(`div`,{className:`mx-3 mt-3 mb-1 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300`,children:_(`modelSelector.pullRestricted`)}),r?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(fe,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,X.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,X.jsx)(ce,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,X.jsx)(`p`,{className:`text-sm`,children:_(`modelManager.huggingface.noModelsFound`)})]}):(0,X.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=a===e.id,r=o[e.id]||[],i=s===e.id;return(0,X.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,X.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),p(e.id)},children:(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`p-2 rounded-lg bg-yellow-100 dark:bg-yellow-900/30 flex-shrink-0`,children:(0,X.jsx)(ce,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-400`,children:`Gated`})]}),(0,X.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(R,{className:`h-3 w-3`}),Bt(e.downloads)]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(f,{className:`h-3 w-3`}),Bt(e.likes)]}),e.pipeline_tag&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,X.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,X.jsx)(ae,{className:`h-4 w-4 text-gray-400`})}),(0,X.jsx)(O,{className:W(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,X.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,X.jsx)(fe,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,X.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:_(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,X.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:_(`modelManager.huggingface.noGgufAvailable`)}):(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:_(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=c===e.ollamaCommand;return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,X.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:l?.percent===void 0?`...`:`${l.percent}%`}),(0,X.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),h()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,X.jsx)(L,{className:`h-4 w-4`})})]}):n?(0,X.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),m(e.ollamaCommand,e.filename)},disabled:!!c,className:W(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,X.jsx)(R,{className:`h-3 w-3 inline mr-1`}),_(`models.pull`)]}):(0,X.jsx)(`span`,{className:`px-2 py-1 rounded text-[11px] font-medium bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300`,children:_(`modelSelector.adminOnlyPull`)})]},e.filename)}),c?.startsWith(`hf.co/`)&&c.includes(e.id)&&l?.percent!==void 0&&(0,X.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,X.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${l.percent}%`}})})]})})]},e.id)})})]}),(0,X.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,X.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,X.jsx)(ae,{className:`h-3 w-3`}),_(`modelManager.huggingface.browseAllLink`)]}),(0,X.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),g()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,X.jsx)(S,{className:W(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function Ht({filteredGroups:e,selectedModel:t,showImageGen:n,getModelIcon:r,getModelLabel:i,getModelSubLabel:a,onModelSelect:o,onOpenGallery:s}){let{t:c}=J();return(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>(0,X.jsx)(`div`,{onMouseDown:t=>{t.preventDefault(),o(e.name)},className:W(`px-3 py-3 cursor-pointer border-b border-gray-100 dark:border-dark-200 last:border-b-0`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,t===e.name&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r(e),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:i(e)}),a(e)&&(0,X.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:a(e)})]}),t===e.name&&(0,X.jsx)(V,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},e.name))]},e.type)):(0,X.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,X.jsx)(F,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,X.jsx)(`p`,{className:`text-sm`,children:c(`models.noModelsFound`)})]}),n&&(0,X.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(d,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),c(`modelSelector.actions`)]})}),(0,X.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),s()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(w,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,X.jsxs)(`div`,{className:`flex-1`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:c(`gallery.generate`)}),(0,X.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`gallery.generateDescription`)})]})]})})]})]})}function Ut({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:a,pullProgress:o,setLibraryCategory:s,isModelInstalled:c,onModelSelect:l,onPullModel:u,onCancelPull:d,onRefreshLibrary:f}){let{t:p}=J();return(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,X.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(e)},className:W(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[!n&&(0,X.jsx)(`div`,{className:`mx-3 mt-3 mb-1 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300`,children:p(`modelSelector.pullRestricted`)}),r?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(fe,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,X.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,X.jsx)(P,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,X.jsx)(`p`,{className:`text-sm`,children:p(`models.noModelsFound`)})]}):(0,X.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.slice(0,50).map(e=>{let t=c(e.name),r=a===e.name;return(0,X.jsxs)(`div`,{className:W(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,X.jsx)(P,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:p(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,X.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,X.jsx)(P,{className:`h-3 w-3`}),`Cloud`]})]}),(0,X.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,X.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,X.jsx)(R,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,X.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:o?.percent===void 0?`...`:`${o.percent}%`}),(0,X.jsx)(`button`,{onClick:d,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,X.jsx)(L,{className:`h-4 w-4`})})]}):t?(0,X.jsx)(`button`,{onClick:()=>l(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:p(`modelSelector.use`)}):n?(0,X.jsxs)(`button`,{onClick:()=>u(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,X.jsx)(R,{className:`h-3 w-3 inline mr-1`}),p(`modelSelector.pull`)]}):(0,X.jsx)(`span`,{className:`px-2 py-1 rounded text-[11px] font-medium bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300`,children:p(`modelSelector.adminOnlyPull`)})})]}),r&&o?.percent!==void 0&&(0,X.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${o.percent}%`}})})]},e.name)})})]}),(0,X.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,X.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,X.jsx)(ae,{className:`h-3 w-3`}),p(`modelManager.huggingface.browseAllLink`)]}),(0,X.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),f()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,X.jsx)(S,{className:W(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var Wt=a(`components:model-selector`),Gt=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:a,disabled:o=!1,compact:c=!1,showImageGen:l=!1,onModelsRefresh:u})=>{let{t:d}=J(),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(`installed`),v=(0,Y.useRef)(null),y=(0,Y.useRef)(null),S=Te(),{user:C,systemInfo:w}=Oe(),E=C?.role===`admin`||(w?.allowUserModelPull??!0),[D,k]=(0,Y.useState)(`all`),[A,j]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(`text-generation`),[ee,te]=(0,Y.useState)(`downloads`),[ne,re]=(0,Y.useState)(``),[F,I]=(0,Y.useState)(null),[L,ae]=(0,Y.useState)({}),[se,R]=(0,Y.useState)(null),[z,B]=(0,Y.useState)(null),[le,V]=(0,Y.useState)(null),[ue,H]=(0,Y.useState)(null),fe=[`all`,`popular`,`chat`,`code`,`vision`,`embedding`,`cloud`],pe=[{type:`personas`,label:d(`modelSelector.personas`),icon:(0,X.jsx)(ie,{className:`h-4 w-4 text-purple-600 dark:text-purple-400`}),models:e.filter(e=>e.isPersona),color:`purple`},{type:`ollama`,label:d(`modelSelector.ollamaModels`),icon:(0,X.jsx)(x,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),models:e.filter(e=>!e.isPersona&&!e.isPlugin&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:d(`modelSelector.pluginModels`),icon:(0,X.jsx)(ce,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),models:e.filter(e=>e.isPlugin),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(m.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(m.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(m.toLowerCase()))})).filter(e=>e.models.length>0),U=e.find(e=>e.name===t||t.startsWith(`persona:`)&&e.name===t),{data:ge=[],isLoading:_e,refetch:ve}=i({queryKey:[`ollama-library-selector`,A,D],queryFn:async()=>{let e=await me.getLibraryModels({search:A||void 0,sort:`popular`,category:D===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:f&&g===`ollama`}),{data:ye=[],isLoading:be,refetch:xe}=i({queryKey:[`hf-models-selector`,M,ne,ee],queryFn:async()=>{let e=await he.getModels({task:M,search:ne||void 0,sort:ee,limit:30});return e.success&&e.data?e.data:[]},enabled:f&&g===`huggingface`}),Se=ge.filter(e=>{let t=!m||e.name.toLowerCase().includes(m.toLowerCase())||e.description.toLowerCase().includes(m.toLowerCase()),n=D===`all`||e.category===D;return t&&n}),Ce=(0,Y.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){R(e);try{let r=await he.getGgufFiles(t,n);r.success&&r.data&&ae(t=>({...t,[e]:r.data}))}catch(e){Wt.error(`Failed to load GGUF files:`,e)}finally{R(null)}}},[]),we=(0,Y.useCallback)(e=>{F===e?I(null):(I(e),L[e]||Ce(e))},[F,L,Ce]),G=(0,Y.useCallback)((e,t)=>{if(!E){T.error(d(`modelSelector.pullRestricted`));return}if(!z){B(e),V({status:`starting`});try{let n=me.pullModelStream(e,e=>{V(e)},()=>{V(null),B(null),H(null),T.success(`Downloaded ${t}`),u?.()},e=>{V(null),B(null),H(null),T.error(`Failed to download: ${e}`)});H(()=>n)}catch{V(null),B(null),T.error(`Failed to start download`)}}},[E,u,z,d]);(0,Y.useEffect)(()=>{let e=setTimeout(()=>{g===`huggingface`?re(m):g===`ollama`&&j(m)},300);return()=>clearTimeout(e)},[m,g]),(0,Y.useEffect)(()=>{let e=e=>{v.current&&!v.current.contains(e.target)&&(p(!1),h(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,Y.useEffect)(()=>{f&&y.current&&y.current.focus()},[f]);let K=async e=>{p(!1),h(``);try{let t=await me.listRunningModels();if(t.success&&t.data){let n=t.data;n.length>0&&(n.some(t=>t.name===e||e.startsWith(`persona:`))||await me.unloadAllModels())}}catch(e){Wt.warn(`Failed to unload models before switch:`,e)}n({target:{value:e}})},Ee=async e=>{if(!E){T.error(d(`modelSelector.pullRestricted`));return}if(!z){B(e),V({status:`starting`});try{let t=me.pullModelStream(e,e=>{V(e)},()=>{V(null),B(null),H(null),T.success(`Downloaded ${e}`),u?.()},e=>{V(null),B(null),H(null),T.error(`Failed to download: ${e}`)});H(()=>t)}catch{V(null),B(null),T.error(`Failed to start download`)}}},q=()=>{ue&&(ue(),H(null),B(null),V(null),T.success(`Download cancelled`))},De=t=>e.some(e=>e.name===t||e.name.startsWith(t+`:`)),ke=e=>e.isPersona?(0,X.jsx)(ie,{className:`h-4 w-4 text-purple-600 dark:text-purple-400`}):e.isPlugin?(0,X.jsx)(ce,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,X.jsx)(x,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),Ae=e=>e.isPersona?e.personaName||e.name:e.isPlugin?`${e.name}`:e.name,je=e=>e.isPersona?`via ${e.model}`:e.isPlugin?`via ${e.pluginName}`:null;return(0,X.jsxs)(`div`,{className:W(`relative`,a),ref:v,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>!o&&p(!f),disabled:o,className:W(c?`h-[44px] sm:h-[52px] px-3 flex items-center justify-between text-left w-full `:`w-full flex items-center justify-between gap-2 px-3 py-2 text-left `,`bg-gray-50 dark:bg-dark-200 border border-gray-200 dark:border-dark-300`,`rounded-lg text-sm hover:bg-gray-100 dark:hover:bg-dark-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500`,o?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:c?U?Ae(U):d(`modelSelector.selectModel`):void 0,children:[(()=>{if(!U)return c?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,X.jsx)(x,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-gray-400 dark:text-gray-500 truncate`,children:d(`modelSelector.selectModel`)})]}):d(`modelSelector.selectModel`);if(c){let e=Ae(U);return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[ke(U),(0,X.jsx)(`span`,{className:`text-xs font-medium text-gray-700 dark:text-gray-200 truncate`,children:e})]})}let e=Ae(U),t=je(U);return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[ke(U),(0,X.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e}),t&&(0,X.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),U.isPersona&&r&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[(0,X.jsx)(de,{className:`h-3 w-3 text-purple-600 dark:text-purple-400`}),r.embedding_model&&(0,X.jsx)(s,{className:`h-3 w-3 text-purple-500 dark:text-purple-300`})]})]})})(),(0,X.jsx)(O,{className:W(c?`h-3 w-3`:`h-4 w-4`,`text-gray-400 flex-shrink-0`,f&&`rotate-180`)})]}),f&&(0,Ie.createPortal)((0,X.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-start sm:items-center justify-center p-2 sm:p-4`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>p(!1)}),(0,X.jsxs)(`div`,{className:W(`relative bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 shadow-2xl`,`w-full max-w-md sm:w-[480px] sm:max-w-[90vw]`,`mt-2 sm:mt-0 rounded-xl`,`h-[85vh] sm:h-[600px] flex flex-col`),onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,X.jsx)(`div`,{className:`p-3 border-b border-gray-200 dark:border-dark-200`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(b,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,X.jsx)(`input`,{ref:y,type:`text`,placeholder:d(g===`installed`?`modelSelector.searchInstalled`:g===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:m,onChange:e=>h(e.target.value),className:W(`w-full pl-10 pr-4 py-2.5 text-sm bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300 rounded-lg`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]})}),(0,X.jsxs)(`div`,{className:`flex border-b border-gray-200 dark:border-dark-300`,children:[(0,X.jsxs)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_(`installed`)},className:W(`flex-1 px-4 py-2.5 text-sm font-medium transition-colors`,g===`installed`?`text-primary-600 dark:text-primary-400 border-b-2 border-primary-500`:`text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300`),children:[(0,X.jsx)(oe,{className:`h-4 w-4 inline mr-1.5`}),d(`modelSelector.installed`)]}),(0,X.jsxs)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_(`ollama`)},className:W(`flex-1 px-4 py-2.5 text-sm font-medium transition-colors`,g===`ollama`?`text-primary-600 dark:text-primary-400 border-b-2 border-primary-500`:`text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300`),children:[(0,X.jsx)(P,{className:`h-4 w-4 inline mr-1.5`}),`Ollama`]}),(0,X.jsxs)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_(`huggingface`)},className:W(`flex-1 px-4 py-2.5 text-sm font-medium transition-colors`,g===`huggingface`?`text-primary-600 dark:text-primary-400 border-b-2 border-primary-500`:`text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300`),children:[(0,X.jsx)(ce,{className:`h-4 w-4 inline mr-1.5`}),`HuggingFace`]})]})]}),g===`installed`&&(0,X.jsx)(Ht,{filteredGroups:pe,selectedModel:t,showImageGen:l,getModelIcon:ke,getModelLabel:Ae,getModelSubLabel:je,onModelSelect:K,onOpenGallery:()=>{p(!1),S(`/gallery`)}}),g===`ollama`&&(0,X.jsx)(Ut,{libraryCategories:fe,libraryCategory:D,canInstallModels:E,loadingLibrary:_e,filteredLibraryModels:Se,pullingModel:z,pullProgress:le,setLibraryCategory:k,isModelInstalled:De,onModelSelect:K,onPullModel:Ee,onCancelPull:q,onRefreshLibrary:()=>{ve()}}),g===`huggingface`&&(0,X.jsx)(Vt,{hfTask:M,hfSort:ee,canInstallModels:E,loadingHf:be,hfModels:ye,expandedHfModel:F,hfGgufFiles:L,loadingGguf:se,pullingModel:z,pullProgress:le,setHfTask:N,setHfSort:te,onToggleHfModel:we,onPullHfGguf:G,onCancelPull:q,onRefreshHfModels:()=>{xe()}})]})]}),document.body),(0,X.jsx)(`select`,{value:t,onChange:n,className:`sr-only`,tabIndex:-1,children:e.map(e=>(0,X.jsx)(`option`,{value:e.name,children:Ae(e)},e.name))})]})},Kt=a(`components:chat-input`),qt=({onSendMessage:e,onStopGeneration:t,disabled:n=!1})=>{let{t:r}=J(),[i,a]=(0,Y.useState)(``),[s,l]=(0,Y.useState)([]),[u,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),{isGenerating:b,setBackgroundImage:x}=je(),{currentSession:S,models:C}=K(),w=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{(async()=>{try{let e=await xe.getPlugins();y(!!(e.success&&e.data&&e.data.length>0))}catch{y(!1)}})()},[]);let T=t=>{t.preventDefault(),!(!i.trim()||b)&&(e(i.trim(),s.length>0?s:void 0,u||void 0),a(``),l([]))},E=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),T(e))},D=()=>{t()};(0,Y.useEffect)(()=>{let e=w.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,200)+`px`)},[i]),(0,Y.useEffect)(()=>{(async()=>{if(S?.personaId)try{let e=await U.getPersona(S.personaId);if(e.success&&e.data)_(e.data);else{Kt.warn(`Persona ${S.personaId} not found, clearing reference`),_(null);let{setCurrentSession:e}=K.getState();e({...S,personaId:void 0})}}catch(e){if(Kt.error(`Failed to load current persona:`,e),_(null),S){let{setCurrentSession:e}=K.getState();e({...S,personaId:void 0})}}else _(null)})()},[S?.personaId]);let O=async e=>{let t=e.target.value;if(S)try{if(t.startsWith(`persona:`)){let e=t.replace(`persona:`,``),n=await U.getPersona(e);if(!n.success||!n.data){c.error(`Failed to load persona details`);return}let i=n.data,a=await _e.updateSession(S.id,{personaId:e,model:t});if(a.success&&a.data){let{sessions:e}=K.getState(),t=e.map(e=>e.id===S.id?a.data:e);K.setState({sessions:t,currentSession:a.data}),i.background&&x(i.background),c.success(r(`chat.persona.applied`))}}else{let e=await _e.updateSession(S.id,{model:t,personaId:void 0});if(e.success&&e.data){let{sessions:t}=K.getState(),n=t.map(t=>t.id===S.id?e.data:t);K.setState({sessions:n,currentSession:e.data}),x(null),c.success(r(`chat.model.updated`))}}}catch(e){Kt.error(`Failed to update session:`,e),c.error(`Failed to update session`)}},k=s.length>0||u!==null;return(0,X.jsx)(`div`,{className:`pointer-events-none`,children:(0,X.jsxs)(`div`,{className:`max-w-5xl mx-auto px-3 sm:px-4 md:px-6 w-full pointer-events-auto`,children:[p&&(0,X.jsxs)(`div`,{className:`mb-2 p-3 rounded-2xl bg-white/95 dark:bg-dark-100/95 backdrop-blur-md border border-gray-200/50 dark:border-dark-300/50 shadow-lg`,children:[(0,X.jsx)(Pt,{images:s,onImagesChange:l,maxImages:5,sessionId:S?.id,disabled:n}),(0,X.jsx)(zt,{format:u,onFormatChange:f})]}),(0,X.jsxs)(`div`,{className:`py-2 sm:py-3`,children:[(0,X.jsx)(`form`,{onSubmit:T,children:(0,X.jsxs)(`div`,{className:W(`flex items-center gap-2 p-2 sm:p-3 rounded-2xl sm:rounded-3xl border transition-all duration-300 ease-out shadow-lg`,`bg-white/95 dark:bg-dark-100/95 backdrop-blur-md`,`border-gray-200/50 dark:border-dark-300/50`,`hover:border-gray-300/70 dark:hover:border-dark-400/70`,`focus-within:border-primary-400/70 dark:focus-within:border-primary-500/70`,`focus-within:shadow-xl`),children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>m(!p),className:W(`h-8 w-8 sm:h-9 sm:w-9 !p-0 rounded-full flex-shrink-0`,`hover:bg-gray-100 dark:hover:bg-dark-200/80`,`transition-all duration-200 touch-manipulation`,`hover:scale-105 active:scale-95`,k&&`text-primary-600 dark:text-primary-400`,p&&`bg-gray-100 dark:bg-dark-200/80`),title:r(`chat.input.attachments`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`},children:k?(0,X.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,X.jsx)(o,{className:`h-4 w-4`}),(0,X.jsx)(`div`,{className:`absolute -top-0.5 -right-0.5 h-2 w-2 bg-primary-500 dark:bg-primary-400 rounded-full ring-2 ring-white dark:ring-dark-50`})]}):p?(0,X.jsx)(h,{className:`h-4 w-4`}):(0,X.jsx)(d,{className:`h-4 w-4`})}),(0,X.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,X.jsx)(Mt,{ref:w,value:i,onChange:e=>a(e.target.value),onKeyDown:E,placeholder:r(`chat.input.placeholder`),disabled:n,className:`!border-0 !bg-transparent !shadow-none !p-0 !m-0 !rounded-none !focus:ring-0 !focus:border-0 !focus:shadow-none !focus:bg-transparent min-h-[32px] sm:min-h-[36px] max-h-[120px] resize-none scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400 focus:outline-none placeholder:text-gray-500 dark:placeholder:text-dark-500 text-base sm:text-sm leading-none touch-manipulation`,rows:1,style:{boxShadow:`none !important`,border:`none !important`,outline:`none !important`,padding:`0 !important`,margin:`0 !important`,lineHeight:`1.2 !important`,verticalAlign:`middle`}})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 flex-shrink-0`,children:[S&&C.length>0&&(0,X.jsx)(`div`,{className:`hidden sm:block`,children:(0,X.jsx)(Gt,{models:C,selectedModel:S.personaId?`persona:${S.personaId}`:S.model,onModelChange:O,currentPersona:g,className:`min-w-[160px] max-w-[240px] border-0 bg-gray-100/80 dark:bg-dark-100/80 rounded-xl text-sm hover:bg-gray-200/80 dark:hover:bg-dark-200/60 transition-colors duration-200`,compact:!0,showImageGen:v})}),b?(0,X.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:D,className:W(`h-8 w-8 sm:h-9 sm:w-9 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`bg-red-50 dark:bg-red-900/20`,`text-red-500 dark:text-red-400`,`hover:bg-red-100 dark:hover:bg-red-900/30`,`transition-all duration-200 touch-manipulation`,`hover:scale-105 active:scale-95`),title:r(`chat.input.stopGeneration`),children:(0,X.jsx)(te,{className:`h-4 w-4`})}):(0,X.jsx)(G,{type:`submit`,variant:`ghost`,size:`sm`,disabled:!i.trim()||n,className:W(`h-8 w-8 sm:h-9 sm:w-9 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`text-gray-400 dark:text-dark-500`,`disabled:opacity-40 disabled:hover:bg-transparent disabled:cursor-not-allowed`,`transition-all duration-200 touch-manipulation`,i.trim()&&!n&&[`bg-primary-500 dark:bg-primary-600`,`text-white dark:text-white`,`hover:bg-primary-600 dark:hover:bg-primary-500`,`shadow-md hover:shadow-lg`,`hover:scale-105 active:scale-95`]),title:r(`chat.input.sendMessage`),children:(0,X.jsx)(ue,{className:`h-4 w-4`})})]})]})}),S&&C.length>0&&(0,X.jsx)(`div`,{className:`sm:hidden mt-3`,children:(0,X.jsx)(Gt,{models:C,selectedModel:S.personaId?`persona:${S.personaId}`:S.model,onModelChange:O,currentPersona:g,className:`w-full rounded-xl bg-gray-100/80 dark:bg-dark-100/80 border-0 transition-colors duration-200`,compact:!0,showImageGen:v})}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center justify-center gap-2 text-xs text-gray-500 dark:text-dark-600`,children:[(0,X.jsx)(It,{sessionId:S?.id}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsxs)(`a`,{href:`https://librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`libre-brand underline hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,style:{fontSize:`1.1em`,lineHeight:1},children:[`Libre `,(0,X.jsx)(`span`,{children:`WebUI`})]}),` `,(0,X.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,style:{fontSize:`0.55rem`},children:[`v`,`0.12.0`]}),` `,(0,X.jsx)(`span`,{className:`text-gray-300 dark:text-gray-600 opacity-50`,children:`•`}),` `,(0,X.jsx)(`span`,{className:`text-gray-400 dark:text-gray-500`,style:{fontSize:`0.55rem`},children:r(`chat.footer.disclaimer`)}),k&&(0,X.jsxs)(`span`,{className:`ml-2 text-primary-600 dark:text-primary-400`,children:[`•`,` `,s.length>0&&r(`chat.footer.images`,{count:s.length}),s.length>0&&u&&` • `,u&&r(`chat.footer.structuredOutput`)]})]})]})]})]})})},Jt=({persona:e,onClear:t,className:n})=>{let[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(null),[o,c]=(0,Y.useState)({top:0,left:0});(0,Y.useEffect)(()=>{if(r&&a.current){let e=a.current.getBoundingClientRect();c({top:e.bottom+8,left:e.left})}},[r]);let l=!!(e.memory_settings?.enabled||e.mutation_settings?.enabled),u=()=>ye(e,64),d=t=>{be(t.currentTarget,e.name,64)};return(0,X.jsxs)(`div`,{className:W(`relative`,n),children:[(0,X.jsxs)(`button`,{ref:a,onClick:()=>i(!r),className:W(`flex items-center gap-2 px-3 py-1.5 rounded-full transition-all duration-200`,`bg-primary-50 dark:bg-primary-900/30`,`border border-primary-200 dark:border-primary-700/50`,`hover:bg-primary-100 dark:hover:bg-primary-900/40`,`text-primary-700 dark:text-primary-300`),children:[(0,X.jsx)(`img`,{src:u(),alt:e.name,className:`w-5 h-5 rounded-full object-cover`,onError:d}),(0,X.jsx)(`span`,{className:`text-sm font-medium max-w-[120px] truncate`,children:e.name}),l&&(0,X.jsx)(s,{className:`h-3 w-3 text-purple-500 dark:text-purple-400`}),(0,X.jsx)(O,{className:W(`h-3.5 w-3.5 transition-transform duration-200`,r&&`rotate-180`)})]}),r&&(0,Ie.createPortal)((0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-[9998]`,onClick:()=>i(!1)}),(0,X.jsx)(`div`,{className:`fixed w-72 z-[9999]`,style:{top:o.top,left:o.left},children:(0,X.jsxs)(`div`,{className:W(`rounded-xl overflow-hidden shadow-xl`,`bg-white dark:bg-dark-100`,`border border-gray-200 dark:border-dark-300`),children:[(0,X.jsxs)(`div`,{className:`relative h-16`,children:[e.background?(0,X.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${e.background})`}}):(0,X.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-primary-400 via-primary-500 to-purple-600 dark:from-primary-600 dark:via-primary-700 dark:to-purple-800`}),(0,X.jsx)(`div`,{className:`absolute inset-0 bg-black/10`}),t&&(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t(),i(!1)},className:`absolute top-2 right-2 p-1 rounded-full bg-white/20 hover:bg-white/30 backdrop-blur-sm transition-colors`,title:`Remove persona`,children:(0,X.jsx)(L,{className:`h-3.5 w-3.5 text-white`})}),l&&(0,X.jsxs)(`div`,{className:`absolute top-2 left-2 flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/20 backdrop-blur-sm text-white text-[10px] font-medium`,children:[(0,X.jsx)(de,{className:`h-3 w-3`}),`Enhanced`]})]}),(0,X.jsx)(`div`,{className:`relative px-4 -mt-6`,children:(0,X.jsx)(`img`,{src:u(),alt:e.name,className:`w-12 h-12 rounded-lg object-cover ring-3 ring-white dark:ring-dark-100 shadow-md`,onError:d})}),(0,X.jsxs)(`div`,{className:`px-4 pt-2 pb-4`,children:[(0,X.jsx)(`h4`,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:e.name}),(0,X.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 flex items-center gap-1 mt-0.5`,children:[(0,X.jsx)(le,{className:`h-3 w-3`}),e.model]}),e.description&&(0,X.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-400 mt-2 line-clamp-2`,children:e.description}),e.parameters.system_prompt&&(0,X.jsxs)(`div`,{className:`mt-3 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-100 dark:border-dark-200`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 mb-1`,children:[(0,X.jsx)(_,{className:`h-2.5 w-2.5 text-gray-400`}),(0,X.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider font-medium text-gray-400`,children:`System`})]}),(0,X.jsxs)(`p`,{className:`text-[11px] text-gray-600 dark:text-gray-400 line-clamp-2 italic`,children:[`“`,e.parameters.system_prompt,`”`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-3`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:[(0,X.jsx)(ce,{className:`h-2.5 w-2.5`}),e.parameters.temperature?.toFixed(1)||`0.7`]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:[`Top-P `,e.parameters.top_p?.toFixed(1)||`0.9`]}),e.memory_settings?.enabled&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300`,children:[(0,X.jsx)(de,{className:`h-2.5 w-2.5`}),`Memory`]})]})]})]})})]}),document.body)]})},Yt=({images:e,onImagesChange:t,maxImages:n=5,className:r})=>{let{t:i}=J(),a=(0,Y.useRef)(null),[o,s]=(0,Y.useState)(!1),c=r=>{if(!r)return;let i=[],a=n-e.length;for(let n=0;n<Math.min(r.length,a);n++){let o=r[n];if(!o.type.startsWith(`image/`)){T.error(`File ${o.name} is not an image`);continue}if(o.size>10*1024*1024){T.error(`Image ${o.name} is too large (max 10MB)`);continue}let s=new FileReader;s.onload=n=>{n.target?.result&&(i.push(n.target.result),i.length===Math.min(r.length,a)&&t([...e,...i]))},s.readAsDataURL(o)}r.length>a&&T.error(`Only ${a} more images can be added`)},l=e=>{e.preventDefault(),s(!0)},u=e=>{e.preventDefault(),s(!1)},d=e=>{e.preventDefault(),s(!1),c(e.dataTransfer.files)},f=n=>{t(e.filter((e,t)=>t!==n))},p=e.length<n;return(0,X.jsxs)(`div`,{className:W(`space-y-3`,r),children:[p&&(0,X.jsxs)(`div`,{className:W(`border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-4 transition-colors`,`hover:border-primary-400 dark:hover:border-primary-500`,o&&`border-primary-500 bg-primary-50 dark:bg-primary-900/20`),onDragOver:l,onDragLeave:u,onDrop:d,children:[(0,X.jsx)(`input`,{ref:a,type:`file`,multiple:!0,accept:`image/*`,onChange:e=>c(e.target.files),className:`hidden`}),(0,X.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,X.jsx)(A,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2`}),(0,X.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-2`,children:[i(`chat.mediaUpload.dropImagesHere`),` `,(0,X.jsx)(`button`,{onClick:()=>a.current?.click(),className:`text-primary-600 dark:text-primary-400 hover:underline font-medium`,children:i(`chat.mediaUpload.browse`)})]}),(0,X.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:i(`chat.mediaUpload.supportedFormats`)})]})]}),e.length>0&&(0,X.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3`,children:e.map((e,t)=>(0,X.jsxs)(`div`,{className:`relative group aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[(0,X.jsx)(`img`,{src:e,alt:`Upload ${t+1}`,className:`w-full h-full object-cover`}),(0,X.jsx)(`div`,{className:`absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-50 transition-all duration-200 flex items-center justify-center`,children:(0,X.jsx)(G,{variant:`ghost`,size:`sm`,onClick:()=>f(t),className:`opacity-0 group-hover:opacity-100 transition-opacity bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-red-100 dark:hover:bg-red-900/20 hover:text-red-600 dark:hover:text-red-400 p-1 rounded-full`,children:(0,X.jsx)(L,{className:`h-4 w-4`})})})]},t))}),p&&e.length>0&&(0,X.jsxs)(G,{variant:`outline`,size:`sm`,onClick:()=>a.current?.click(),className:`w-full sm:w-auto`,children:[(0,X.jsx)(w,{className:`h-4 w-4 mr-2`}),`Add More Images (`,e.length,`/`,n,`)`]})]})},$=a(`use-chat`),Xt=new Set([`New Chat`,`New Demo Session`]),Zt=e=>!e||Xt.has(e),Qt=e=>{let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)([]),{addMessage:l,updateMessage:u,updateMessageWithStatistics:d,updateSessionTitle:f,setGeneratingTitleForSession:p}=K(),{setIsGenerating:m,preferences:h}=je(),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(!1),y=(0,Y.useRef)(null),b=(0,Y.useRef)(``),x=(0,Y.useRef)(0),S=(0,Y.useRef)(),C=(0,Y.useRef)(null),w=(0,Y.useRef)(``),E=(0,Y.useCallback)(()=>{C.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(C.current),C.current=null},[]),D=(0,Y.useCallback)((e,t=!1)=>{if(w.current=e,t||typeof window>`u`){E(),n(e);return}C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,n(w.current)}))},[E]),O=(0,Y.useCallback)(()=>{E(),w.current=``,n(``)},[E]),k=(0,Y.useCallback)(()=>{_.current=null,v.current=!1,y.current=null},[]),A=(0,Y.useCallback)(e=>{let t=je.getState().preferences.titleSettings,n=_.current,r=v.current&&y.current===e;$.debug(`Auto-title check:`,{firstMessage:n,autoTitle:t?.autoTitle,taskModel:t?.taskModel,shouldGenerateTitle:r}),n&&r&&t?.autoTitle&&t?.taskModel&&($.debug(`Triggering auto-title generation...`),p(e),_e.generateTitle(e,t.taskModel,n).then(t=>{$.debug(`Title generation response:`,t),t.success&&t.data?.title&&f(e,t.data.title)}).catch(e=>{$.error(`Failed to generate title:`,e)}).finally(()=>{p(null)})),k()},[k,p,f]);return(0,Y.useEffect)(()=>()=>{q.offMessage(`user_message`),q.offMessage(`assistant_chunk`),q.offMessage(`assistant_complete`),q.offMessage(`tool_status`),q.offMessage(`error`)},[e]),(0,Y.useEffect)(()=>{if(!e){q.offMessage(`user_message`),q.offMessage(`assistant_chunk`),q.offMessage(`assistant_complete`),q.offMessage(`tool_status`),q.offMessage(`error`);return}return q.onMessage(`user_message`,()=>{}),q.onMessage(`assistant_chunk`,t=>{let n=t,r=n.messageId||g.current;r&&(b.current=n.total,D(n.total,n.done),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{u(e,r,b.current),x.current=Date.now()},n.done?0:200))}),q.onMessage(`tool_status`,e=>{let t=e;c(e=>e.find(e=>e.toolCallId===t.toolCallId)?e.map(e=>e.toolCallId===t.toolCallId?{...e,phase:t.phase}:e):[...e,{toolCallId:t.toolCallId,name:t.name,phase:t.phase,startedAt:Date.now()}])}),q.onMessage(`assistant_complete`,t=>{let n=t;$.debug(`Hook: Received assistant_complete for session:`,e,`messageId:`,n.messageId,`with statistics:`,!!n.statistics),o(!1),O(),m(!1),c([]);let r=n.messageId||g.current;n&&r&&d(e,r,b.current||n.content,n.statistics),A(e),g.current=null,b.current=``,S.current&&clearTimeout(S.current),x.current=0}),q.onMessage(`error`,e=>{let t=e;if(o(!1),O(),m(!1),g.current=null,t.code===`SESSION_NOT_FOUND`){$.warn(`Session not found, redirecting to create new session...`),T.error(`Session not found. Creating a new session...`),window.location.href=`/`;return}T.error(t.error),k()}),o(!1),O(),g.current=null,()=>{S.current&&clearTimeout(S.current),E()}},[e,u,d,m,D,O,E,A,k]),{sendMessage:(0,Y.useCallback)(async(t,n,r)=>{if(!(!e||!t.trim()&&(!n||n.length===0)))try{m(!0),o(!0),O(),S.current&&clearTimeout(S.current),x.current=Date.now();let a=K.getState().currentSession,s=a?.isPrivate===!0,c=a?.messages?.some(e=>e.role===`user`);!s&&!c&&Zt(a?.title)?(_.current=t.trim(),v.current=!0,y.current=e):(_.current=null,v.current=!1,y.current=null),l(e,{role:`user`,content:t.trim(),images:n});let d=we();if(g.current=d,i(d),l(e,{role:`assistant`,content:``,id:d}),pe()){let n=`Demo response for: ${t.trim()}`;window.setTimeout(()=>{u(e,d,n),o(!1),O(),i(null),m(!1),A(e),g.current=null,b.current=``},500);return}q.isConnected||await q.connect();let f=s?a?.messages?.filter(e=>e.role!==`system`&&e.id!==d).map(e=>({role:e.role,content:e.content,images:e.images})):void 0;q.send({type:`chat_stream`,data:{sessionId:e,content:t.trim(),images:n,format:r,options:h.generationOptions,assistantMessageId:d,isPrivate:s,model:s?a?.model:void 0,messageHistory:f}})}catch(e){$.error(`Failed to send message:`,e),o(!1),O(),i(null),m(!1),g.current=null,T.error(`Failed to send message`)}},[e,l,u,m,O,A,h.generationOptions]),stopGeneration:(0,Y.useCallback)(()=>{o(!1),O(),i(null),m(!1),g.current=null},[m,O]),regenerateLastMessage:(0,Y.useCallback)(async()=>{let t=K.getState().currentSession;if(!t||!e)return;let n=t.messages,r=-1,a=-1;for(let e=n.length-1;e>=0;e--)if(n[e].role===`assistant`){a=e;break}if(a>0){for(let e=a-1;e>=0;e--)if(n[e].role===`user`){r=e;break}}if(r===-1||a===-1){T.error(`No message to regenerate`);return}let s=n[r],c=n[a];try{m(!0),o(!0),O(),S.current&&clearTimeout(S.current),x.current=Date.now();let t=we();g.current=t,i(t),l(e,{role:`assistant`,content:``,id:t,parentId:c.parentId||c.id,branchIndex:c.siblingCount||1,isActive:!0}),q.isConnected||await q.connect(),q.send({type:`chat_stream`,data:{sessionId:e,content:s.content,images:s.images,options:h.generationOptions,assistantMessageId:t,regenerate:!0,originalMessageId:c.id}})}catch(e){$.error(`Failed to regenerate message:`,e),o(!1),O(),i(null),m(!1),g.current=null,T.error(`Failed to regenerate message`)}},[e,m,O,l,h.generationOptions]),selectBranch:(0,Y.useCallback)(async t=>{let n=K.getState().currentSession;if(!n||!e)return;let r=n.messages.find(e=>e.id===t);if(!r){T.error(`Message not found`);return}if(r.isActive!==!1)return;let i=r.parentId||r.id,a=r.branchIndex||0;try{let r=await _e.switchMessageBranch(e,t,a);if(r.success&&r.data){let r=n.messages.map(e=>e.id===i||e.parentId===i?{...e,isActive:e.id===t}:e),o={...n,messages:r,updatedAt:Date.now()};K.setState(t=>({sessions:t.sessions.map(t=>t.id===e?o:t),currentSession:o})),T.success(`Switched to variant ${a+1}`)}else T.error(r.error||`Failed to select branch`)}catch(e){$.error(`Failed to select branch:`,e),T.error(`Failed to select branch`)}},[e]),isStreaming:a,streamingMessage:t,streamingMessageId:r,toolActivities:s}},$t=a(`pages:chat-page`),en=(e,t)=>{let n=new Date().getHours(),r=e?`, ${e}`:``;return n>=5&&n<12?{greeting:`${t?t(`chat.greeting.morning`):`Good morning`}${r}`,timeSuffix:`today`}:n>=12&&n<17?{greeting:`${t?t(`chat.greeting.afternoon`):`Good afternoon`}${r}`,timeSuffix:`today`}:n>=17&&n<21?{greeting:`${t?t(`chat.greeting.evening`):`Good evening`}${r}`,timeSuffix:`tonight`}:{greeting:`${t?t(`chat.greeting.night`):`Good night`}${r}`,timeSuffix:`tonight`}},tn=()=>{let{t:e}=J(),{sessionId:t}=Ee(),n=Te(),r=Me(),{currentSession:i,sessions:a,models:s,selectedModel:c,setSelectedModel:l,createSession:u,setCurrentSession:f,loadSessions:p,getCurrentPersona:m}=K(),{user:g}=Oe(),{sendMessage:_,stopGeneration:y,regenerateLastMessage:b,selectBranch:x,isStreaming:S,streamingMessage:C,streamingMessageId:w,toolActivities:T}=Qt(i?.id||``),E=m(),{greeting:D,timeSuffix:O}=(0,Y.useMemo)(()=>en(g?.username,e),[g?.username,e]),[k,A]=(0,Y.useState)(``),[j,M]=(0,Y.useState)([]),[N,ee]=(0,Y.useState)(!1),P=(0,Y.useRef)(null),[te,ne]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{a.length===0&&p()},[p,a.length]),(0,Y.useEffect)(()=>{(async()=>{try{let e=await xe.getPlugins();ne(!!(e.success&&e.data&&e.data.length>0))}catch{ne(!1)}})()},[]),(0,Y.useEffect)(()=>{(()=>{if(sessionStorage.getItem(`forceWelcomeScreen`)){sessionStorage.removeItem(`forceWelcomeScreen`);return}if(!i?.isPrivate&&a.length!==0)if(t){let e=a.find(e=>e.id===t);e&&e.id!==i?.id?f(e):e||($t.warn(`Session ${t} not found for current user, redirecting...`),a.length>0?n(`/c/${a[0].id}`,{replace:!0}):n(`/`,{replace:!0}))}else!t&&a.length>0&&r.pathname===`/`&&n(`/c/${a[0].id}`,{replace:!0})})()},[t,a,f,n,i?.id,i?.isPrivate,r.pathname]),(0,Y.useEffect)(()=>{if(i?.id){let e=sessionStorage.getItem(`pendingMessage`);if(e){sessionStorage.removeItem(`pendingMessage`);try{let t=JSON.parse(e);setTimeout(()=>{_(t.content,t.images)},100)}catch(e){$t.error(`Failed to parse pending message:`,e)}}}},[i?.id,_]),(0,Y.useEffect)(()=>{let e=P.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,200)+`px`)},[k]);let re=async e=>{if(e.preventDefault(),!k.trim()||!c)return;let t={content:k.trim(),images:j.length>0?j:void 0};sessionStorage.setItem(`pendingMessage`,JSON.stringify(t)),A(``),M([]);let r=await u(c);r&&n(`/c/${r.id}`,{replace:!0})},F=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),re(e))},I=async e=>{let t=e.target.value;l(t)},L=(e,t,n)=>{i&&_(e,t,n)};if(!i){let t=j.length>0;return(0,X.jsxs)(`div`,{className:`h-full flex-1 flex flex-col items-center justify-center p-4 sm:p-8 relative`,children:[(0,X.jsxs)(`button`,{onClick:()=>{if(!c&&s.length===0)return;let t=Date.now();f({id:`private-${t}`,title:e(`chat.session.private`),model:c||s[0]?.name||``,messages:[],createdAt:t,updatedAt:t,isPrivate:!0})},disabled:!c&&s.length===0,className:`absolute top-4 right-4 flex items-center gap-2 px-3 py-1.5 rounded-full border border-gray-300 dark:border-dark-400 bg-transparent hover:bg-gray-100 dark:hover:bg-dark-200 text-gray-500 dark:text-gray-400 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,title:e(`chat.session.privateTooltip`),children:[(0,X.jsx)(v,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-sm`,children:e(`chat.session.private`)})]}),(0,X.jsxs)(`div`,{className:`w-full max-w-2xl mx-auto flex flex-col items-center justify-center`,children:[(0,X.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-medium text-gray-800 dark:text-gray-100 mb-2 text-center`,style:{fontWeight:400},children:D}),(0,X.jsx)(`p`,{className:`text-base sm:text-lg text-gray-500 dark:text-gray-400 mb-8 text-center`,children:e(O===`today`?`chat.welcome.helpToday`:`chat.welcome.helpTonight`)}),s.length>0?(0,X.jsxs)(`div`,{className:`w-full`,children:[N&&(0,X.jsx)(`div`,{className:`mb-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-2xl`,children:(0,X.jsx)(Yt,{images:j,onImagesChange:M,maxImages:5})}),(0,X.jsx)(`form`,{onSubmit:re,children:(0,X.jsxs)(`div`,{className:W(`flex items-center gap-2 p-2 sm:p-3 rounded-2xl sm:rounded-3xl border transition-all duration-200`,`bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300`,`hover:border-gray-300 dark:hover:border-dark-400`,`focus-within:border-primary-400 dark:focus-within:border-primary-500 focus-within:bg-white dark:focus-within:bg-dark-50`,`shadow-sm hover:shadow-md focus-within:shadow-lg`),children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>ee(!N),className:W(`h-8 w-8 sm:h-9 sm:w-9 !p-0 rounded-full flex-shrink-0`,`hover:bg-gray-200 dark:hover:bg-dark-200 transition-colors touch-manipulation`,t&&`text-primary-600 dark:text-primary-400`,N&&`bg-gray-200 dark:bg-dark-200`),title:e(`chat.input.attachImages`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`},children:t?(0,X.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,X.jsx)(o,{className:`h-4 w-4`}),(0,X.jsx)(`div`,{className:`absolute -top-0.5 -right-0.5 h-1.5 w-1.5 bg-primary-500 rounded-full`})]}):N?(0,X.jsx)(h,{className:`h-4 w-4`}):(0,X.jsx)(d,{className:`h-4 w-4`})}),(0,X.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,X.jsx)(Mt,{ref:P,value:k,onChange:e=>A(e.target.value),onKeyDown:F,placeholder:e(`chat.input.messagePlaceholder`),className:`!border-0 !bg-transparent !shadow-none !p-0 !m-0 !rounded-none !focus:ring-0 !focus:border-0 !focus:shadow-none !focus:bg-transparent min-h-[32px] sm:min-h-[36px] max-h-[120px] resize-none scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400 focus:outline-none placeholder:text-gray-500 dark:placeholder:text-dark-500 text-base sm:text-sm leading-none touch-manipulation`,rows:1,style:{boxShadow:`none !important`,border:`none !important`,outline:`none !important`,padding:`0 !important`,margin:`0 !important`,lineHeight:`1.2 !important`,verticalAlign:`middle`}})}),(0,X.jsx)(`div`,{className:`hidden sm:block`,children:(0,X.jsx)(Gt,{models:s,selectedModel:c,onModelChange:I,className:`min-w-[140px] max-w-[200px] border-0 bg-gray-100 dark:bg-dark-100 rounded-xl text-sm`,compact:!0,showImageGen:te})}),(0,X.jsx)(G,{type:`submit`,variant:`ghost`,size:`sm`,disabled:!k.trim()||!c,className:W(`h-8 w-8 sm:h-9 sm:w-9 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`hover:bg-primary-100 dark:hover:bg-primary-900/30 text-primary-600 dark:text-primary-400`,`disabled:text-gray-400 dark:disabled:text-dark-500 disabled:hover:bg-transparent`,`transition-all duration-150 touch-manipulation`,k.trim()&&c&&`hover:scale-105 active:scale-95`),title:e(`chat.input.sendMessage`),children:(0,X.jsx)(ue,{className:`h-4 w-4`})})]})}),(0,X.jsx)(`div`,{className:`sm:hidden mt-4`,children:(0,X.jsx)(Gt,{models:s,selectedModel:c,onModelChange:I,className:`w-full rounded-xl bg-gray-100 dark:bg-dark-100 border-0`,compact:!0,showImageGen:te})}),(0,X.jsxs)(`div`,{className:`mt-4 text-center`,children:[(0,X.jsxs)(`a`,{href:`https://librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`libre-brand underline hover:text-primary-600 dark:hover:text-primary-400 transition-colors text-gray-500 dark:text-gray-400`,style:{fontSize:`0.75rem`,lineHeight:1},children:[`Libre `,(0,X.jsx)(`span`,{children:`WebUI`})]}),` `,(0,X.jsxs)(`span`,{className:`text-gray-400 dark:text-gray-500`,style:{fontSize:`0.55rem`},children:[`v`,`0.12.0`]}),` `,(0,X.jsx)(`span`,{className:`text-gray-300 dark:text-gray-600 opacity-50`,children:`•`}),` `,(0,X.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:e(`chat.footer.disclaimer`)})]})]}):(0,X.jsx)(`div`,{className:`w-full max-w-md`,children:(0,X.jsxs)(`div`,{className:`p-6 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-xl`,children:[(0,X.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-dark-700 mb-4`,children:e(`chat.model.noModelsDescription`)}),(0,X.jsx)(`code`,{className:`block text-xs bg-gray-100 dark:bg-dark-200 p-3 rounded-lg font-mono text-gray-800 dark:text-dark-600`,children:e(`chat.model.pullCommand`)})]})})]})]})}return(0,X.jsxs)(`div`,{className:`flex flex-col h-full relative`,style:E?.background?{backgroundImage:`url(${E.background})`,backgroundSize:`cover`,backgroundPosition:`center`,backgroundRepeat:`no-repeat`}:void 0,children:[E?.background&&(0,X.jsx)(`div`,{className:`absolute inset-0 bg-white/80 dark:bg-black/80 backdrop-blur-sm`}),(0,X.jsxs)(`div`,{className:`flex flex-col h-full relative z-10`,children:[i?.isPrivate&&(0,X.jsx)(`div`,{className:`flex-shrink-0 px-4 py-2 border-b border-gray-200 dark:border-dark-300 bg-gray-50/80 dark:bg-dark-100/80 backdrop-blur-sm`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-gray-600 dark:text-gray-400`,children:[(0,X.jsx)(v,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`chat.session.privateMode`)}),(0,X.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[`— `,e(`chat.session.privateDescription`)]})]})}),E&&!i?.isPrivate&&(0,X.jsx)(`div`,{className:`flex-shrink-0 px-4 py-2 border-b border-gray-100 dark:border-dark-200 bg-white/50 dark:bg-dark-100/50 backdrop-blur-sm`,children:(0,X.jsx)(Jt,{persona:E,onClear:()=>{if(i){let{sessions:e}=K.getState(),t={...i,model:E.model,personaId:void 0},n=e.map(e=>e.id===i.id?t:e);K.setState({sessions:n,currentSession:t})}}})}),(0,X.jsx)(At,{messages:i.messages,streamingMessage:C,streamingMessageId:w,isStreaming:S,toolActivities:T,onRegenerate:b,onSelectBranch:x,className:`flex-1`}),(0,X.jsx)(qt,{onSendMessage:L,onStopGeneration:y,disabled:!i})]})]})};export{tn as ChatPage,tn as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-fkbHPd-g.js";import{t as r}from"./logger-BmpKNkls.js";import{Bt as i,Ot as a,V as o,Y as s,at as c,g as l,it as u,s as d,t as f,ut as p,vt as m,wt as h}from"./ui-vendor-BJAeWL11.js";import{h as g}from"./api-CbmZzKBu.js";import{g as _,k as v,n as y,t as b}from"../assets/index-ONn9VIq7.js";var x=e(n(),1),S=t(),C=r(`components:first-time-setup`),w=({onComplete:e})=>{let{t}=v(),[n,r]=(0,x.useState)(`welcome`),[w,T]=(0,x.useState)(``),[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(``),[A,j]=(0,x.useState)(!1),[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(!1),[I,L]=(0,x.useState)(null),[R,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(!1),[H,U]=(0,x.useState)(``),{login:W,systemInfo:G}=_(),K=G?.turnstile?.siteKey,q=!!(G?.turnstile?.enabled&&K),J=(0,x.useCallback)(e=>{U(e)},[]),Y=(0,x.useMemo)(()=>P||q&&!H,[P,q,H]);(0,x.useEffect)(()=>{n===`encryption-key`&&!I&&g.getEncryptionKey().then(e=>{e.success&&e.data&&L(e.data.encryptionKey)})},[n,I]);let X=async e=>{if(e.preventDefault(),!w.trim()||!E.trim()||!O.trim()){i.error(t(`setup.admin.fillAllFields`));return}if(E!==O){i.error(t(`auth.signup.passwordMismatch`));return}if(E.length<6){i.error(t(`auth.signup.passwordTooShort`));return}if(q&&!H){i.error(t(`auth.signup.tryAgain`));return}F(!0);try{let e=await g.signup({username:w,password:E,email:``,turnstileToken:H});e.success&&e.data?(W(e.data.user,e.data.token,e.data.systemInfo),i.success(t(`setup.admin.success`)),r(`encryption-key`)):i.error(e.message||t(`setup.admin.failed`))}catch(e){C.error(`Admin creation error:`,e),i.error(t(`setup.admin.failed`))}finally{U(``),F(!1)}},Z=async()=>{if(I)try{await navigator.clipboard.writeText(I),z(!0),i.success(t(`setup.encryptionKey.copied`)),setTimeout(()=>z(!1),3e3)}catch{i.error(t(`setup.encryptionKey.copyFailed`))}},Q=()=>{if(!B){i.error(t(`setup.encryptionKey.confirmRequired`));return}e?.()},$=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return n===`welcome`?(0,S.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,S.jsx)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:(0,S.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,S.jsx)(y,{className:`text-gray-900 dark:text-gray-100`})})}),(0,S.jsx)(`div`,{className:`mt-8 sm:mx-auto sm:w-full sm:max-w-md`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-md mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200`,children:[(0,S.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2`,children:t(`setup.welcome.subtitle`)}),(0,S.jsx)(`p`,{className:`text-gray-600 dark:text-dark-500`,children:t(`setup.welcome.description`)})]}),(0,S.jsxs)(`div`,{className:`space-y-4 mb-6`,children:[(0,S.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,S.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,S.jsx)(l,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-950`,children:t(`setup.welcome.features.secure.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:t(`setup.welcome.features.secure.description`)})]})]}),(0,S.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,S.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,S.jsx)(f,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-950`,children:t(`setup.welcome.features.fast.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:t(`setup.welcome.features.fast.description`)})]})]}),(0,S.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,S.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,S.jsx)(s,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-950`,children:t(`setup.welcome.features.openSource.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:t(`setup.welcome.features.openSource.description`)})]})]})]}),(0,S.jsx)(`button`,{onClick:()=>r(`create-admin`),className:`w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-colors duration-200`,children:(0,S.jsxs)(`div`,{className:`flex items-center`,children:[(0,S.jsx)(`span`,{children:t(`setup.welcome.createAdmin`)}),(0,S.jsx)(h,{size:16,className:`ml-2`})]})})]})})]}):n===`encryption-key`?(0,S.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,S.jsxs)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:[(0,S.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,S.jsx)(y,{className:`text-gray-900 dark:text-gray-100`})}),(0,S.jsx)(`h2`,{className:`libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100`,style:{fontWeight:300,letterSpacing:0},children:t(`setup.encryptionKey.title`)})]}),(0,S.jsx)(`div`,{className:`mt-8 sm:mx-auto sm:w-full sm:max-w-lg`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-lg mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200`,children:[(0,S.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,S.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,S.jsx)(`div`,{className:`p-3 bg-amber-100 dark:bg-amber-900/30 rounded-full`,children:(0,S.jsx)(o,{className:`h-8 w-8 text-amber-600 dark:text-amber-400`})})}),(0,S.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2`,children:t(`setup.encryptionKey.subtitle`)}),(0,S.jsx)(`p`,{className:`text-gray-600 dark:text-dark-500`,children:t(`setup.encryptionKey.description`)})]}),(0,S.jsx)(`div`,{className:`mb-6 p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg`,children:(0,S.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,S.jsx)(a,{className:`h-5 w-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5`}),(0,S.jsxs)(`div`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:[(0,S.jsx)(`p`,{className:`font-medium mb-1`,children:t(`setup.encryptionKey.warning`)}),(0,S.jsx)(`p`,{children:t(`setup.encryptionKey.warningText`)})]})]})}),(0,S.jsxs)(`div`,{className:`mb-6`,children:[(0,S.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:t(`setup.encryptionKey.label`)}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`div`,{className:`w-full px-3 py-3 pr-12 border border-gray-300 dark:border-dark-300 rounded-lg bg-gray-50 dark:bg-dark-100 font-mono text-sm text-gray-900 dark:text-dark-800 break-all`,children:I||t(`setup.encryptionKey.loading`)}),(0,S.jsx)(`button`,{type:`button`,onClick:Z,disabled:!I,className:`absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-500 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-700 disabled:opacity-50`,title:t(`setup.encryptionKey.copyToClipboard`),children:R?(0,S.jsx)(m,{className:`h-5 w-5 text-green-500`}):(0,S.jsx)(p,{className:`h-5 w-5`})})]}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`setup.encryptionKey.envNote`)})]}),(0,S.jsx)(`div`,{className:`mb-6`,children:(0,S.jsxs)(`label`,{className:`flex items-start space-x-3 cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:B,onChange:e=>V(e.target.checked),className:`mt-1 h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-dark-300 rounded`}),(0,S.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-dark-700`,children:t(`setup.encryptionKey.acknowledgment`)})]})}),(0,S.jsx)(`button`,{onClick:Q,disabled:!B,className:`w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200`,children:(0,S.jsxs)(`div`,{className:`flex items-center`,children:[(0,S.jsx)(`span`,{children:t(`setup.encryptionKey.continue`)}),(0,S.jsx)(h,{size:16,className:`ml-2`})]})})]})})]}):(0,S.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,S.jsxs)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:[(0,S.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,S.jsx)(y,{className:`text-gray-900 dark:text-gray-100`})}),(0,S.jsx)(`h2`,{className:`libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100`,style:{fontWeight:300,letterSpacing:0},children:t(`setup.admin.title`)})]}),(0,S.jsx)(`div`,{className:`mt-8 sm:mx-auto sm:w-full sm:max-w-md`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-md mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200`,children:[(0,S.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2`,children:t(`setup.admin.subtitle`)}),(0,S.jsx)(`p`,{className:`text-gray-600 dark:text-dark-500`,children:t(`setup.admin.description`)})]}),(0,S.jsxs)(`form`,{onSubmit:X,className:`space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`username`,className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:t(`auth.login.username`)}),(0,S.jsx)(`input`,{id:`username`,type:`text`,value:w,onChange:e=>T(e.target.value),onKeyDown:$,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200`,placeholder:t(`setup.admin.usernamePlaceholder`),required:!0,disabled:P})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`password`,className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:t(`auth.login.password`)}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`input`,{id:`password`,type:A?`text`:`password`,value:E,onChange:e=>D(e.target.value),onKeyDown:$,className:`w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200`,placeholder:t(`setup.admin.passwordPlaceholder`),required:!0,disabled:P}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>j(!A),className:`absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700`,disabled:P,children:A?(0,S.jsx)(c,{size:20}):(0,S.jsx)(u,{size:20})})]})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`confirmPassword`,className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:t(`auth.signup.confirmPassword`)}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`input`,{id:`confirmPassword`,type:M?`text`:`password`,value:O,onChange:e=>k(e.target.value),onKeyDown:$,className:`w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200`,placeholder:t(`setup.admin.confirmPlaceholder`),required:!0,disabled:P}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>N(!M),className:`absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700`,disabled:P,children:M?(0,S.jsx)(c,{size:20}):(0,S.jsx)(u,{size:20})})]})]}),q&&K&&(0,S.jsx)(b,{siteKey:K,disabled:P,errorMessage:t(`auth.signup.tryAgain`),onTokenChange:J}),(0,S.jsxs)(`div`,{className:`flex space-x-3`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>r(`welcome`),disabled:P,className:`flex-1 px-4 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm text-sm font-medium text-gray-700 dark:text-dark-700 bg-white dark:bg-dark-100 hover:bg-gray-50 dark:hover:bg-dark-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200`,children:t(`common.back`)}),(0,S.jsx)(`button`,{type:`submit`,disabled:Y,className:`flex-1 flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200`,children:P?(0,S.jsxs)(`div`,{className:`flex items-center`,children:[(0,S.jsx)(`div`,{className:`animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2`}),t(`setup.admin.creating`)]}):(0,S.jsxs)(`div`,{className:`flex items-center`,children:[(0,S.jsx)(d,{size:16,className:`mr-2`}),t(`setup.admin.createAdmin`)]})})]})]}),(0,S.jsx)(`div`,{className:`mt-6 text-center`,children:(0,S.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:t(`setup.admin.note`)})})]})})]})};export{w as FirstTimeSetup};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-fkbHPd-g.js";import{n as r}from"./react-vendor-Co1u1rWb.js";import{n as i,t as a}from"./useBaseQuery-6OJiOiyu.js";import{t as o}from"./logger-BmpKNkls.js";import{At as s,Bt as c,D as l,I as u,Nt as d,U as f,W as p,lt as m,n as h,pt as g,st as _,u as v}from"./ui-vendor-BJAeWL11.js";import{u as y}from"./api-CbmZzKBu.js";import{t as b}from"./utils-BaPYjs_z.js";import{t as x}from"./Button-BUjLpHmR.js";import{G as S,H as C,K as w,k as T}from"../assets/index-ONn9VIq7.js";var E=class extends i{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:S(t,n.data),hasPreviousPage:w(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function D(e,t){return a(e,E,t)}var O=e(n(),1),k=r(),A=t(),j=({image:e,onClose:t,onDelete:n,onDownload:r})=>{let{t:i}=T();return(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=``}},[t]),(0,k.createPortal)((0,A.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center`,onClick:t,children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/90 backdrop-blur-sm`}),(0,A.jsxs)(`div`,{className:`relative flex flex-col lg:flex-row max-w-7xl max-h-[95vh] w-full mx-4 gap-4`,onClick:e=>e.stopPropagation(),children:[(0,A.jsx)(`button`,{onClick:t,className:b(`absolute -top-12 right-0 lg:top-0 lg:-right-12 z-10`,`p-2 rounded-full`,`bg-white/10 hover:bg-white/20`,`transition-colors`),children:(0,A.jsx)(h,{className:`h-6 w-6 text-white`})}),(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-0`,children:(0,A.jsx)(`img`,{src:e.imageData,alt:e.prompt,className:`max-w-full max-h-[70vh] lg:max-h-[90vh] object-contain rounded-lg`})}),(0,A.jsxs)(`div`,{className:b(`w-full lg:w-80 flex-shrink-0`,`bg-white dark:bg-dark-100`,`rounded-xl p-4 lg:p-5`,`overflow-y-auto max-h-[25vh] lg:max-h-[90vh]`),children:[(0,A.jsxs)(`div`,{className:`mb-4`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400 mb-1`,children:i(`gallery.prompt`)}),(0,A.jsx)(`p`,{className:`text-gray-900 dark:text-gray-100 text-sm leading-relaxed`,children:e.prompt})]}),(0,A.jsxs)(`div`,{className:`space-y-3 mb-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(m,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,A.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.model`),`:`]}),(0,A.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:e.model})]}),e.size&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(u,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,A.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.size`),`:`]}),(0,A.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:e.size})]}),e.quality&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(`span`,{className:`w-4 h-4 flex items-center justify-center text-gray-400 dark:text-gray-500 text-xs font-bold`,children:`Q`}),(0,A.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.quality`),`:`]}),(0,A.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100 capitalize`,children:e.quality})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(g,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,A.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.created`),`:`]}),(0,A.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:(e=>new Date(e).toLocaleString(void 0,{year:`numeric`,month:`long`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}))(e.createdAt)})]})]}),(0,A.jsxs)(`div`,{className:`flex gap-2 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,A.jsxs)(`button`,{onClick:()=>{if(r)r(e);else{let t=document.createElement(`a`);t.href=e.imageData,t.download=`generated-${e.id}.png`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}},className:b(`flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg`,`bg-primary-600 dark:bg-primary-600`,`hover:bg-primary-700 dark:hover:bg-primary-500`,`text-white font-medium text-sm`,`transition-colors`),children:[(0,A.jsx)(_,{className:`h-4 w-4`}),i(`gallery.download`)]}),n&&(0,A.jsx)(`button`,{onClick:()=>n(e.id),className:b(`p-2.5 rounded-lg`,`bg-gray-100 dark:bg-dark-200`,`hover:bg-red-100 dark:hover:bg-red-900/30`,`text-gray-600 dark:text-gray-300`,`hover:text-red-600 dark:hover:text-red-400`,`transition-colors`),title:`Delete image`,children:(0,A.jsx)(v,{className:`h-4 w-4`})})]})]})]})]}),document.body)},M=o(`components:image-gallery`),N=({onImageCountChange:e})=>{let{t}=T(),n=C(),[r,i]=(0,O.useState)(null),[a,o]=(0,O.useState)(null),{data:s,fetchNextPage:l,hasNextPage:u,isFetchingNextPage:f,isLoading:m}=D({queryKey:[`image-gallery`],queryFn:async({pageParam:e})=>{let n=await y.getGallery({limit:20,offset:e});if(!n.success||!n.data)throw Error(t(`imageGallery.loadFailed`));return n.data},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.images.length,0);return n<e.total?n:void 0}}),h=(0,O.useMemo)(()=>s?.pages.flatMap(e=>e.images)??[],[s]),g=s?.pages[0]?.total??0,x=f;(0,O.useEffect)(()=>{e?.(g)},[g,e]);let S=()=>{l()},w=async(e,s)=>{if(s.stopPropagation(),!a){o(e);try{(await y.deleteGalleryImage(e)).success?(await n.invalidateQueries({queryKey:[`image-gallery`]}),c.success(t(`imageGallery.deleteSuccess`)),r?.id===e&&i(null)):c.error(t(`imageGallery.deleteFailed`))}catch(e){M.error(`Failed to delete image:`,e),c.error(t(`imageGallery.deleteFailed`))}finally{o(null)}}},E=(e,t)=>{t.stopPropagation();let n=document.createElement(`a`);n.href=e.imageData,n.download=`generated-${e.id}.png`,document.body.appendChild(n),n.click(),document.body.removeChild(n)},k=e=>new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`});return m?(0,A.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,A.jsx)(d,{className:`h-8 w-8 animate-spin text-gray-400 dark:text-gray-500`})}):h.length===0?(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 text-center`,children:[(0,A.jsx)(p,{className:`h-16 w-16 text-gray-300 dark:text-gray-600 mb-4`}),(0,A.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`imageGallery.noImages`)}),(0,A.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 max-w-sm`,children:t(`imageGallery.noImagesHint`)})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:b(`columns-1 sm:columns-2 lg:columns-3 xl:columns-4`,`gap-4 space-y-4`),children:h.map(e=>(0,A.jsxs)(`div`,{className:b(`break-inside-avoid group relative cursor-pointer`,`rounded-xl overflow-hidden`,`bg-gray-100 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`hover:border-gray-300 dark:hover:border-dark-400`,`transition-all duration-200`,`hover:shadow-lg dark:hover:shadow-dark-400/20`),onClick:()=>i(e),children:[(0,A.jsx)(`img`,{src:e.imageData,alt:e.prompt,className:`w-full h-auto object-cover`,loading:`lazy`}),(0,A.jsxs)(`div`,{className:b(`absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent`,`opacity-0 group-hover:opacity-100 transition-opacity duration-200`,`flex flex-col justify-end p-3`),children:[(0,A.jsx)(`p`,{className:`text-white text-sm line-clamp-2 mb-2`,children:e.prompt}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(`span`,{className:`text-white/70 text-xs`,children:k(e.createdAt)}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(`button`,{onClick:t=>E(e,t),className:b(`p-1.5 rounded-lg`,`bg-white/20 hover:bg-white/30`,`transition-colors`),title:t(`imageGallery.download`),children:(0,A.jsx)(_,{className:`h-4 w-4 text-white`})}),(0,A.jsx)(`button`,{onClick:t=>w(e.id,t),disabled:a===e.id,className:b(`p-1.5 rounded-lg`,`bg-white/20 hover:bg-red-500/80`,`transition-colors`,a===e.id&&`opacity-50 cursor-not-allowed`),title:t(`imageGallery.delete`),children:a===e.id?(0,A.jsx)(d,{className:`h-4 w-4 text-white animate-spin`}):(0,A.jsx)(v,{className:`h-4 w-4 text-white`})})]})]})]})]},e.id))}),u&&(0,A.jsx)(`div`,{className:`flex justify-center mt-8`,children:(0,A.jsx)(`button`,{onClick:S,disabled:x,className:b(`px-6 py-2.5 rounded-xl font-medium`,`bg-gray-100 dark:bg-dark-200`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`text-gray-700 dark:text-gray-200`,`border border-gray-200 dark:border-dark-300`,`transition-colors`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:x?(0,A.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(d,{className:`h-4 w-4 animate-spin`}),t(`common.loading`)]}):t(`imageGallery.loadMore`,{current:h.length,total:g})})}),r&&(0,A.jsx)(j,{image:r,onClose:()=>i(null),onDelete:e=>{w(e,{stopPropagation:()=>{}})},onDownload:e=>{E(e,{stopPropagation:()=>{}})}})]})},P=o(`components:image-generation-panel`),F=({isOpen:e,onClose:t,onImageGenerated:n})=>{let{t:r}=T(),[i,a]=(0,O.useState)([]),[o,l]=(0,O.useState)(``),[u,p]=(0,O.useState)(``),[m,g]=(0,O.useState)(``),[v,S]=(0,O.useState)(`1024x1024`),[C,w]=(0,O.useState)(`standard`),[E,D]=(0,O.useState)(!1),[j,M]=(0,O.useState)(null),[N,F]=(0,O.useState)([`512x512`,`768x768`,`1024x1024`]),[I,L]=(0,O.useState)([`standard`,`high`]),[R,z]=(0,O.useState)(null);(0,O.useEffect)(()=>{e&&(async()=>{try{let e=await y.getPlugins();if(e.success&&e.data&&(a(e.data),e.data.length>0)){let t=e.data[0];l(t.id),t.models.length>0&&p(t.models[0]),t.config?.sizes&&(F(t.config.sizes),S(t.config.default_size||t.config.sizes[0]||`1024x1024`)),t.config?.qualities&&(L(t.config.qualities),w(t.config.default_quality||t.config.qualities[0]||`standard`)),z(t.config?.max_prompt_length??null)}}catch(e){P.error(`Failed to load image generation plugins:`,e)}})()},[e]);let[B,V]=(0,O.useState)(o);if(o!==B){V(o);let e=i.find(e=>e.id===o);e&&(e.models.length>0&&!e.models.includes(u)&&p(e.models[0]),e.config?.sizes&&(F(e.config.sizes),e.config.sizes.includes(v)||S(e.config.default_size||e.config.sizes[0])),e.config?.qualities&&(L(e.config.qualities),e.config.qualities.includes(C)||w(e.config.default_quality||e.config.qualities[0])),z(e.config?.max_prompt_length??null))}let H=async()=>{if(!u||!m.trim()){c.error(r(`imageGeneration.enterPrompt`));return}if(R&&m.length>R){c.error(r(`imageGeneration.promptTooLong`,{max:R.toLocaleString()}));return}D(!0),M(null);try{let e=await y.generate({model:u,prompt:m.trim(),size:v,quality:C});if(e.success&&e.data?.images&&e.data.images.length>0){let i=e.data.images[0],a=null;i.b64_json?a=`data:image/png;base64,${i.b64_json}`:i.url&&(a=i.url),a&&(c.success(r(`imageGeneration.success`)),n?(n(a,m.trim(),u),g(``),M(null),t()):M(a))}else c.error(r(`imageGeneration.failed`))}catch(e){P.error(`Image generation failed:`,e);let t=e instanceof Error?e.message:r(`imageGeneration.failed`);c.error(t)}finally{D(!1)}},U=()=>{if(!j)return;let e=document.createElement(`a`);e.href=j,e.download=`generated-image-${Date.now()}.png`,document.body.appendChild(e),e.click(),document.body.removeChild(e)};if(!e)return null;let W=i.find(e=>e.id===o);return(0,k.createPortal)((0,A.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center p-4`,children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,A.jsxs)(`div`,{className:b(`relative bg-white dark:bg-dark-100`,`border border-gray-200 dark:border-dark-300`,`rounded-2xl shadow-2xl`,`w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col`),onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-dark-300`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(f,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}),(0,A.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:r(`imageGeneration.title`)})]}),(0,A.jsx)(`button`,{onClick:t,className:`p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,children:(0,A.jsx)(h,{className:`h-5 w-5 text-gray-500 dark:text-gray-400`})})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:i.length===0?(0,A.jsxs)(`div`,{className:`text-center py-8`,children:[(0,A.jsx)(f,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,A.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:r(`imageGeneration.noModels`)}),(0,A.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mt-1`,children:r(`imageGeneration.configurePlugin`)})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`settings.plugins.title`)}),(0,A.jsx)(`select`,{value:o,onChange:e=>l(e.target.value),className:b(`w-full px-3 py-2 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:i.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.model`)}),(0,A.jsx)(`select`,{value:u,onChange:e=>p(e.target.value),className:b(`w-full px-3 py-2 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:W?.models.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.size`)}),(0,A.jsx)(`select`,{value:v,onChange:e=>S(e.target.value),className:b(`w-full px-3 py-2 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:N.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.quality`)}),(0,A.jsx)(`select`,{value:C,onChange:e=>w(e.target.value),className:b(`w-full px-3 py-2 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:I.map(e=>(0,A.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.prompt`)}),(0,A.jsx)(`textarea`,{value:m,onChange:e=>g(e.target.value),placeholder:r(`imageGeneration.promptPlaceholder`),rows:5,className:b(`w-full px-3 py-2 rounded-lg text-sm resize-none`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,R&&m.length>R&&`border-red-500 dark:border-red-500`)}),R&&(0,A.jsxs)(`div`,{className:b(`text-xs mt-1 text-right`,m.length>R?`text-red-500`:`text-gray-500 dark:text-gray-400`),children:[m.length.toLocaleString(),` /`,` `,R.toLocaleString()]})]}),j&&(0,A.jsxs)(`div`,{className:`relative rounded-xl overflow-hidden border border-gray-200 dark:border-dark-300`,children:[(0,A.jsx)(`img`,{src:j,alt:`Generated`,className:`w-full h-auto`}),(0,A.jsx)(`button`,{onClick:U,className:b(`absolute bottom-3 right-3 p-2 rounded-lg`,`bg-white/90 dark:bg-dark-100/90`,`hover:bg-white dark:hover:bg-dark-100`,`border border-gray-200 dark:border-dark-300`,`transition-colors`),title:r(`imageGallery.download`),children:(0,A.jsx)(_,{className:`h-5 w-5 text-gray-700 dark:text-gray-200`})})]})]})}),i.length>0&&(0,A.jsx)(`div`,{className:`p-4 border-t border-gray-200 dark:border-dark-300`,children:(0,A.jsx)(x,{onClick:H,disabled:E||!m.trim()||!u,className:b(`w-full py-2.5 rounded-xl font-medium`,`bg-primary-600 dark:bg-primary-600`,`hover:bg-primary-700 dark:hover:bg-primary-500`,`text-white`,`disabled:opacity-50 disabled:cursor-not-allowed`,`transition-colors`),children:E?(0,A.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,A.jsx)(d,{className:`h-4 w-4 animate-spin`}),r(`imageGeneration.generating`)]}):(0,A.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,A.jsx)(s,{className:`h-4 w-4`}),r(`imageGeneration.generate`)]})})})]})]}),document.body)},I=()=>{let{t:e}=T(),[t,n]=(0,O.useState)(null),[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(0),s=(0,O.useCallback)(()=>{o(e=>e+1)},[]);return(0,A.jsxs)(`div`,{className:`h-full overflow-auto`,children:[(0,A.jsxs)(`div`,{className:`max-w-7xl mx-auto p-6`,children:[(0,A.jsxs)(`div`,{className:`text-center max-w-md mx-auto mb-8`,children:[(0,A.jsx)(`h2`,{className:`libre-brand text-4xl sm:text-5xl font-normal text-gray-900 dark:text-dark-800 mb-3`,style:{fontWeight:300,letterSpacing:0},children:e(`sidebar.navigation.imagine`)}),(0,A.jsxs)(`p`,{className:`text-gray-600 dark:text-dark-600 leading-relaxed`,children:[e(`gallery.subtitle`),t!==null&&t>0&&(0,A.jsxs)(`span`,{className:`text-gray-400 dark:text-gray-500`,children:[` `,`· `,e(`gallery.imageCount`,{count:t})]})]}),(0,A.jsxs)(x,{onClick:()=>i(!0),className:b(`mt-4 px-6 py-2.5 rounded-xl font-medium`,`bg-primary-600 dark:bg-primary-600`,`hover:bg-primary-700 dark:hover:bg-primary-500`,`text-white`,`transition-colors`),children:[(0,A.jsx)(l,{className:`h-4 w-4 mr-2`}),e(`gallery.generate`)]})]}),(0,A.jsx)(N,{onImageCountChange:n},a)]}),(0,A.jsx)(F,{isOpen:r,onClose:()=>i(!1),onImageGenerated:s})]})};export{I as GalleryPage,I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{d as n,f as r}from"./markdown-core-fkbHPd-g.js";import{t as i}from"./logger-BmpKNkls.js";import{Dt as a,Nt as o,O as s,St as c,T as l,Vt as u,Z as d,_ as f,bt as p,f as m,h,k as g,n as _,ot as v,pt as y,u as b,vt as x}from"./ui-vendor-BJAeWL11.js";import{l as S}from"./api-CbmZzKBu.js";import{t as C}from"./utils-BaPYjs_z.js";import{t as w}from"./Button-BUjLpHmR.js";import{A as T,F as E,I as D,L as ee,M as O,N as k,P as A,R as te,j as ne,k as re}from"../assets/index-ONn9VIq7.js";var j=e(t(((e,t)=>{t.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}}))()),M=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function N(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(j.default[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){var r=e.indexOf(`-->`);return{type:`comment`,comment:r===-1?``:e.slice(4,r)}}for(var i=new RegExp(M),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var o=a[1].trim(),s=[o,``];o.indexOf(`=`)>-1&&(s=o.split(`=`)),t.attrs[s[0]]=s[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var P=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,F=/^\s*$/,I=Object.create(null);function L(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:return e+=`<`+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+`="`+e[n]+`"`);return t.length?` `+t.join(` `):``}(t.attrs):``)+(t.voidElement?`/>`:`>`),t.voidElement?e:e+t.children.reduce(L,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var ie={parse:function(e,t){t||(t={}),t.components||(t.components=I);var n,r=[],i=[],a=-1,o=!1;if(e.indexOf(`<`)!==0){var s=e.indexOf(`<`);r.push({type:`text`,content:s===-1?e:e.substring(0,s)})}return e.replace(P,function(s,c){if(o){if(s!==`</`+n.name+`>`)return;o=!1}var l,u=s.charAt(1)!==`/`,d=s.startsWith(`<!--`),f=c+s.length,p=e.charAt(f);if(d){var m=N(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=N(s)).type===`tag`&&t.components[n.name]&&(n.type=`component`,o=!0),n.voidElement||o||!p||p===`<`||n.children.push({type:`text`,content:e.slice(f,e.indexOf(`<`,f))}),a===0&&r.push(n),(l=i[a-1])&&l.children.push(n),i[a]=n),(!u||n.voidElement)&&(a>-1&&(n.voidElement||n.name===s.slice(2,-1))&&(a--,n=a===-1?r:i[a]),!o&&p!==`<`&&p)){l=a===-1?r:i[a].children;var h=e.indexOf(`<`,f),g=e.slice(f,h===-1?void 0:h);F.test(g)&&(g=` `),(h>-1&&a+l.length>=0||g!==` `)&&l.push({type:`text`,content:g})}}),r},stringify:function(e){return e.reduce(function(e,t){return e+L(``,t)},``)}},R=e(r()),z=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},B=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?V(t):t},ae=e=>Array.isArray(e)&&e.every(R.isValidElement),V=e=>Array.isArray(e)?e:[e],oe=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},H=e=>{let t={};if(!e)return t;let n=e=>{V(e).forEach(e=>{E(e)||(z(e)?n(B(e)):A(e)&&!(0,R.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},U=(e,t,n,r)=>{if(!e)return``;let i=``,a=V(e),o=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return a.forEach((e,a)=>{if(E(e)){i+=`${e}`;return}if((0,R.isValidElement)(e)){let{props:s,type:c}=e,l=Object.keys(s).length,u=o.indexOf(c)>-1,d=s.children;if(!d&&u&&!l){i+=`<${c}/>`;return}if(!d&&(!u||l)||s.i18nIsDynamicList){i+=`<${a}></${a}>`;return}if(u&&l<=1){let e=E(d)?d:U(d,t,n,r);i+=`<${c}>${e}</${c}>`;return}let f=U(d,t,n,r);i+=`<${a}>${f}</${a}>`;return}if(e===null){D(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(A(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}D(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}D(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},se=(e,t=[],n={})=>{if(!e)return e;let r=Object.keys(n),i=[...t,...r],a=``,o=0;for(;o<e.length;)if(e[o]===`<`){let t=!1,n=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}if(!t){let n=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}}t||(a+=`<`,o+=1)}else a+=e[o],o+=1;return a},ce=(e,t,n,r,i,a,o)=>{if(n===``)return[];let s=i.transKeepBasicHtmlNodesFor||[],c=n&&new RegExp(s.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!c&&!o)return[n];let l=t??{},u=e=>{V(e).forEach(e=>{E(e)||(z(e)?u(B(e)):A(e)&&!(0,R.isValidElement)(e)&&Object.assign(l,e))})};u(e);let d=se(n,s,l),f=ie.parse(`<0>${d}</0>`),p={...l,...a},m=(e,t,n)=>{let r=B(e),i=g(r,t.children,n);return ae(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},h=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,R.cloneElement)(e,{key:r},i?void 0:t))):n.push(...R.Children.map([e],e=>{if(e.type===R.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),(0,R.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),(0,R.cloneElement)(e,n,i?null:t)}))},g=(e,n,a)=>{let l=V(e),u=V(n),d={};return u.reduce((e,n,u)=>{let f=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,p,r.language);if(n.type===`tag`){let _=l[parseInt(n.name,10)];!_&&t&&(_=t[n.name]),a.length===1&&!_&&(_=a[0][n.name]),_||(_={});let v={...n.attrs};o&&Object.keys(v).forEach(e=>{let t=v[e];E(t)&&(v[e]=k(t))});let y=Object.keys(v).length===0?_:oe({props:v},_),b=(0,R.isValidElement)(y),x=b&&z(n,!0)&&!n.voidElement,S=c&&A(y)&&y.dummy&&!b,C=A(t)&&Object.hasOwnProperty.call(t,n.name);if(E(y)){let t=r.services.interpolator.interpolate(y,p,r.language);e.push(t)}else if(z(y)||x)h(y,m(y,n,a),e,u);else if(S)h(y,g(l,n.children,a),e,u);else if(Number.isNaN(parseFloat(n.name)))if(C)h(y,m(y,n,a),e,u,n.voidElement);else if(i.transSupportBasicHtmlNodes&&s.indexOf(n.name)>-1)if(n.voidElement)e.push((0,R.createElement)(n.name,{key:`${n.name}-${u}`}));else{let t=d[n.name]||0;d[n.name]=t+1;let r,i=0;for(let e=0;e<l.length;e+=1){let a=l[e];if((0,R.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let o=g(r?V(B(r)):l,n.children,a);e.push((0,R.createElement)(n.name,{key:`${n.name}-${u}`},o))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=g(l,n.children,a);e.push(`<${n.name}>${t}</${n.name}>`)}else if(A(y)&&!b){let t=n.children[0]?f:null;t&&e.push(t)}else h(y,f,e,u,n.children.length!==1||!f)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:O().unescape,s=o?a(r.services.interpolator.interpolate(n.content,p,r.language)):r.services.interpolator.interpolate(n.content,p,r.language);t?e.push((0,R.createElement)(t,{key:`${n.name}-${u}`},s)):e.push(s)}return e},[])};return B(g([{dummy:!0,children:e||[]}],f,V(e||[]))[0])},W=(e,t,n)=>{let r=e.key||t,i=(0,R.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,R.createElement)(R.Fragment,null,i)}return(0,R.createElement)(a,{key:r})},le=(e,t)=>e.map((e,n)=>W(e,n,t)),ue=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:W(e[r],r,t)})}),n},de=(e,t,n,r)=>e?Array.isArray(e)?le(e,t):A(e)?ue(e,t):(ee(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,fe=e=>!A(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function pe({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:c,ns:l,i18n:u,t:d,shouldUnescape:f,...p}){let m=u||ne();if(!m)return ee(m,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using i18nextReactModule`,{i18nKey:r}),e;let h=d||m.t.bind(m)||(e=>e),g={...O(),...m.options?.react},_=l||h.ns||m.options?.defaultNS;_=E(_)?[_]:_||[`translation`];let{transDefaultProps:v}=g,y=v?.tOptions?{...v.tOptions,...a}:a,b=f??v?.shouldUnescape,x=v?.values?{...v.values,...o}:o,S=v?.components?{...v.components,...c}:c,C=U(e,g,m,r),w=s||y?.defaultValue||C||g.transEmptyNodeValue||(typeof r==`function`?te(r):r),{hashTransKey:T}=g,D=r||(T?T(C||w):C||w);o=m.options?.interpolation?.defaultVariables?x&&Object.keys(x).length>0?{...x,...m.options.interpolation.defaultVariables}:{...m.options.interpolation.defaultVariables}:x;let k=H(e);k&&typeof k.count==`number`&&t===void 0&&(t=k.count);let A=o||t!==void 0&&!m.options?.interpolation?.alwaysFormat||!e?y.interpolation:{interpolation:{...y.interpolation,prefix:`#$?`,suffix:`?$#`}},re={...y,context:i||y.context,count:t,...o,...A,defaultValue:w,ns:_},j=D?h(D,re):w;j===D&&w&&(j=w);let M=de(S,j,m,r),N=M||e,P=null;fe(M)&&(P=M,N=e);let F=ce(N,P,j,m,g,re,b),I=n??g.defaultTransParent;return I?(0,R.createElement)(I,p,F):F}function me({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:c,ns:l,i18n:u,t:d,shouldUnescape:f,...p}){let{i18n:m,defaultNS:h}=(0,R.useContext)(T)||{},g=u||m||ne(),_=d||g?.t.bind(g);return pe({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:c,ns:l||_?.ns||h||g?.options?.defaultNS,i18n:g,t:d,shouldUnescape:f,...p})}var G=n(),K=i(`pages:libre-claw`),q={queued:`bg-gray-100 text-gray-700 dark:bg-dark-200 dark:text-dark-700`,running:`bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300`,blocked:`bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300`,done:`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`,failed:`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300`,cancelled:`bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300`},he={assistant_message:`text-blue-600 dark:text-blue-300`,assistant_delta:`text-blue-600 dark:text-blue-300`,user_message:`text-gray-700 dark:text-dark-700`,permission_request:`text-amber-600 dark:text-amber-300`,permission_response:`text-emerald-600 dark:text-emerald-300`,tool_call:`text-purple-600 dark:text-purple-300`,tool_result:`text-emerald-600 dark:text-emerald-300`,usage:`text-cyan-600 dark:text-cyan-300`,error:`text-red-600 dark:text-red-300`,run_finished:`text-emerald-600 dark:text-emerald-300`},ge=[[`lobster`,`Lobster`],[`lobster-light`,`Lobster Light`],[`github-dark`,`GitHub Dark`],[`github-light`,`GitHub Light`],[`monokai-pro`,`Monokai Pro`],[`night-owl`,`Night Owl`],[`tokyo-night`,`Tokyo Night`],[`ayu`,`Ayu`],[`dracula`,`Dracula`],[`catppuccin-mocha`,`Catppuccin Mocha`],[`catppuccin-latte`,`Catppuccin Latte`],[`gruvbox-dark`,`Gruvbox Dark`],[`nord`,`Nord`],[`solarized-dark`,`Solarized Dark`],[`solarized-light`,`Solarized Light`],[`one-dark-pro`,`One Dark Pro`],[`rose-pine`,`Rose Pine`],[`kanagawa`,`Kanagawa`],[`matrix`,`Matrix`]],_e=()=>{let{t:e}=re(),[t,n]=(0,R.useState)(null),[r,i]=(0,R.useState)([]),[T,E]=(0,R.useState)([]),[D,ee]=(0,R.useState)([]),[O,k]=(0,R.useState)(null),[A,te]=(0,R.useState)(null),[ne,j]=(0,R.useState)(``),[M,N]=(0,R.useState)(null),[P,F]=(0,R.useState)(!0),[I,L]=(0,R.useState)(!1),[ie,z]=(0,R.useState)(!1),[B,ae]=(0,R.useState)(!1),[V,oe]=(0,R.useState)(!1),[H,U]=(0,R.useState)(``),[se,ce]=(0,R.useState)(`chat`),[W,le]=(0,R.useState)(``),[ue,de]=(0,R.useState)(``),[fe,pe]=(0,R.useState)(``),[q,he]=(0,R.useState)(``),[_e,Se]=(0,R.useState)(!1),[Ce,we]=(0,R.useState)(`lobster`),[Y,Te]=(0,R.useState)(!0),[ke,Ae]=(0,R.useState)(``),[je,X]=(0,R.useState)(``),[Z,Me]=(0,R.useState)(``),[Ne,Pe]=(0,R.useState)(`report`),Q=(0,R.useMemo)(()=>r.find(e=>e.run_id===M)||null,[r,M]),Fe=(0,R.useMemo)(()=>{let e=new Set(T.filter(e=>e.type===`permission_response`).map(e=>String(e.data.tool_call_id||``)));return T.filter(t=>{if(t.type!==`permission_request`)return!1;let n=String(t.data.tool_call_id||``);return n&&!e.has(n)})},[T]),Ie=(0,R.useMemo)(()=>Oe(T,e),[T,e]),$=(0,R.useCallback)(async()=>{try{let[e,t,r,a,o,s]=await Promise.all([S.status(),S.listRuns(30),S.currentModel(),S.currentFallback(),S.usage(``,100),S.listAutomations(50)]);e.success&&e.data&&n(e.data),t.success&&t.data&&(i(t.data.runs),N(e=>e||t.data?.runs[0]?.run_id||null)),r.success&&r.data&&(k(r.data),pe(String(r.data.provider||``)),he(String(r.data.model||``))),a.success&&a.data&&te(a.data),o.success&&o.data&&j(String(o.data.text||``)),s.success&&s.data&&ee(s.data.automations)}catch(t){K.error(`Failed to load Libre Claw overview:`,t),u.error(e(`libreClaw.toasts.loadStatusFailed`))}finally{F(!1)}},[e]),Le=(0,R.useCallback)(async(e,t=!1)=>{let n=t?0:T.length>0&&T[T.length-1]?.event_id||0;try{let r=await S.getEvents(e,n);r.success&&r.data&&E(e=>t?r.data?.events||[]:[...e,...r.data?.events||[]])}catch(e){K.error(`Failed to load Libre Claw events:`,e)}},[T]);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>{$()},0);return()=>window.clearTimeout(e)},[$]),(0,R.useEffect)(()=>{if(!M){let e=window.setTimeout(()=>{E([])},0);return()=>window.clearTimeout(e)}let e=M;S.getEvents(e,0).then(e=>{e.success&&e.data&&E(e.data.events)}).catch(e=>{K.error(`Failed to load Libre Claw events:`,e)})},[M]),(0,R.useEffect)(()=>{if(!M||!Q||![`queued`,`running`,`blocked`].includes(Q.state))return;let e=window.setInterval(()=>{Le(M),S.listRuns(30).then(e=>{e.success&&e.data&&i(e.data.runs)})},1500);return()=>window.clearInterval(e)},[Le,Q,M]);let Re=async()=>{if(!H.trim()){u.error(e(`libreClaw.toasts.enterTask`));return}L(!0);try{let t=await S.startRun({message:H,kind:se,provider:W||void 0,model:ue||void 0});if(t.success&&t.data){let n=t.data.run;i(e=>[n,...e.filter(e=>e.run_id!==n.run_id)]),N(n.run_id),U(``),u.success(e(`libreClaw.toasts.runStarted`))}else u.error(t.error||e(`libreClaw.toasts.startRunFailed`))}catch(t){K.error(`Failed to start Libre Claw run:`,t),u.error(e(`libreClaw.toasts.startRunFailed`))}finally{L(!1)}},ze=async t=>{try{await S.cancelRun(t),await $(),u.success(e(`libreClaw.toasts.runCancelled`))}catch(t){K.error(`Failed to cancel Libre Claw run:`,t),u.error(e(`libreClaw.toasts.cancelRunFailed`))}},Be=async(t,n)=>{if(!M)return;let r=String(t.data.tool_call_id||``);if(r)try{await S.resolvePermission(M,r,n),await Le(M,!0),u.success(e(n===`deny`?`libreClaw.toasts.denied`:`libreClaw.toasts.approved`))}catch(t){K.error(`Failed to resolve Libre Claw permission:`,t),u.error(e(`libreClaw.toasts.resolvePermissionFailed`))}},Ve=async()=>{if(!fe.trim()||!q.trim()){u.error(e(`libreClaw.toasts.providerModelRequired`));return}z(!0);try{let t=await S.updateModel(fe,q,_e);t.success&&t.data?(k(t.data),u.success(e(`libreClaw.toasts.modelUpdated`))):u.error(t.error||e(`libreClaw.toasts.updateModelFailed`))}catch(t){K.error(`Failed to update Libre Claw model:`,t),u.error(e(`libreClaw.toasts.updateModelFailed`))}finally{z(!1)}},He=async()=>{ae(!0);try{let t=await S.updateTheme(Ce,Y);t.success?u.success(e(`libreClaw.toasts.themeUpdated`)):u.error(t.error||e(`libreClaw.toasts.updateThemeFailed`))}catch(t){K.error(`Failed to update Libre Claw theme:`,t),u.error(e(`libreClaw.toasts.updateThemeFailed`))}finally{ae(!1)}},Ue=async()=>{if(!ke.trim()||!je.trim()||!Z.trim()){u.error(e(`libreClaw.toasts.automationRequired`));return}oe(!0);try{let t=await S.createAutomation({name:ke,schedule:je,prompt:Z,route:Ne});t.success?(Ae(``),X(``),Me(``),await $(),u.success(e(`libreClaw.toasts.automationCreated`))):u.error(t.error||e(`libreClaw.toasts.createAutomationFailed`))}catch(t){K.error(`Failed to create Libre Claw automation:`,t),u.error(e(`libreClaw.toasts.createAutomationFailed`))}finally{oe(!1)}},We=async(t,n)=>{try{n===`pause`&&await S.pauseAutomation(t),n===`resume`&&await S.resumeAutomation(t),n===`run`&&await S.runAutomationNow(t),n===`delete`&&await S.deleteAutomation(t),await $(),u.success(e(`libreClaw.toasts.automationUpdated`))}catch(t){K.error(`Failed to update Libre Claw automation:`,t),u.error(e(`libreClaw.toasts.updateAutomationFailed`))}};return(0,G.jsxs)(`div`,{className:`h-full overflow-y-auto bg-gray-50 dark:bg-dark-100`,children:[(0,G.jsxs)(`div`,{className:`mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8 space-y-6`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between`,children:[(0,G.jsx)(`div`,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-xl bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300`,children:(0,G.jsx)(c,{className:`h-5 w-5`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold text-gray-950 dark:text-gray-100`,children:e(`libreClaw.title`)}),(0,G.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:e(`libreClaw.subtitle`)})]})]})}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(ve,{status:t,t:e}),(0,G.jsxs)(w,{variant:`secondary`,size:`sm`,onClick:$,children:[(0,G.jsx)(l,{className:`h-4 w-4`}),e(`common.refresh`)]}),(0,G.jsxs)(`a`,{href:t?.dashboardUrl||`http://127.0.0.1:8766/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded-xl border border-gray-200 bg-white px-3 py-1.5 text-sm font-medium text-gray-700 shadow-sm transition-colors hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-700 dark:hover:bg-dark-100`,children:[(0,G.jsx)(v,{className:`h-4 w-4`}),e(`libreClaw.dashboard`)]})]})]}),!t?.connected&&!P&&(0,G.jsx)(`section`,{className:`rounded-xl border border-amber-200 bg-amber-50 p-4 text-amber-900 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-200`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(m,{className:`mt-0.5 h-5 w-5 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`font-semibold`,children:e(`libreClaw.connection.disconnectedTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-sm opacity-90`,children:(0,G.jsx)(me,{i18nKey:`libreClaw.connection.disconnectedDescription`,components:{command:(0,G.jsx)(`code`,{}),env:(0,G.jsx)(`code`,{})}})}),t?.error&&(0,G.jsx)(`p`,{className:`mt-2 text-xs opacity-80`,children:t.error})]})]})}),(0,G.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,G.jsx)(J,{title:e(`libreClaw.startRun.title`),icon:(0,G.jsx)(s,{className:`h-4 w-4`}),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(`textarea`,{value:H,onChange:e=>U(e.target.value),placeholder:e(`libreClaw.startRun.placeholder`),className:`min-h-32 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-100 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800 dark:focus:border-primary-500 dark:focus:ring-primary-900/30`}),(0,G.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,G.jsxs)(`select`,{value:se,onChange:e=>ce(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,G.jsx)(`option`,{value:`chat`,children:e(`libreClaw.startRun.chatRun`)}),(0,G.jsx)(`option`,{value:`goal`,children:e(`libreClaw.startRun.goalMode`)})]}),(0,G.jsx)(`input`,{value:W,onChange:e=>le(e.target.value),placeholder:e(`libreClaw.startRun.providerOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,G.jsx)(`input`,{value:ue,onChange:e=>de(e.target.value),placeholder:e(`libreClaw.startRun.modelOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,G.jsxs)(w,{onClick:Re,loading:I,children:[(0,G.jsx)(c,{className:`h-4 w-4`}),e(`libreClaw.startRun.run`)]})]})]})}),(0,G.jsx)(J,{title:e(`libreClaw.modelRoute.title`),icon:(0,G.jsx)(d,{className:`h-4 w-4`}),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-1`,children:[(0,G.jsx)(`input`,{value:fe,onChange:e=>pe(e.target.value),placeholder:e(`libreClaw.modelRoute.providerPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,G.jsx)(`input`,{value:q,onChange:e=>he(e.target.value),placeholder:e(`libreClaw.modelRoute.modelPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>Se(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]}),(0,G.jsx)(w,{variant:`secondary`,onClick:Ve,loading:ie,children:e(`libreClaw.modelRoute.saveModel`)}),(0,G.jsxs)(`div`,{className:`border-t border-gray-100 pt-3 dark:border-dark-200`,children:[(0,G.jsx)(`label`,{className:`mb-1 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-500`,children:e(`libreClaw.modelRoute.theme`)}),(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] lg:grid-cols-1`,children:[(0,G.jsx)(`select`,{value:Ce,onChange:e=>we(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:ge.map(([e,t])=>(0,G.jsx)(`option`,{value:e,children:t},e))}),(0,G.jsx)(w,{variant:`secondary`,onClick:He,loading:B,children:e(`libreClaw.modelRoute.saveTheme`)})]}),(0,G.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>Te(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]})]}),O&&(0,G.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(O,null,2)})]})})]}),(0,G.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,G.jsx)(J,{title:e(`libreClaw.runs.title`),icon:(0,G.jsx)(a,{className:`h-4 w-4`}),children:(0,G.jsxs)(`div`,{className:`space-y-2`,children:[r.length===0&&(0,G.jsx)(Ee,{text:e(`libreClaw.runs.empty`)}),r.map(t=>(0,G.jsxs)(`button`,{onClick:()=>N(t.run_id),className:C(`w-full rounded-xl border p-3 text-left transition`,M===t.run_id?`border-primary-300 bg-primary-50 dark:border-primary-700 dark:bg-primary-900/20`:`border-gray-200 bg-white hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-50 dark:hover:bg-dark-100`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,G.jsx)(ye,{state:t.state,t:e})]}),(0,G.jsxs)(`div`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-dark-500`,children:[t.provider,`:`,t.model]}),(0,G.jsx)(`div`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:De(t.updated_at)})]},t.run_id))]})}),(0,G.jsxs)(J,{title:Q?Q.title:e(`libreClaw.timeline.title`),icon:(0,G.jsx)(y,{className:`h-4 w-4`}),actions:Q&&[`queued`,`running`,`blocked`].includes(Q.state)?(0,G.jsxs)(w,{variant:`danger`,size:`sm`,onClick:()=>ze(Q.run_id),children:[(0,G.jsx)(h,{className:`h-4 w-4`}),e(`common.cancel`)]}):null,children:[Fe.length>0&&(0,G.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-xl border border-amber-200 bg-amber-50 p-3 dark:border-amber-800 dark:bg-amber-900/20`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-amber-800 dark:text-amber-200`,children:[(0,G.jsx)(f,{className:`h-4 w-4`}),e(`libreClaw.approvals.needed`)]}),Fe.map(t=>(0,G.jsxs)(`div`,{className:`rounded-lg bg-white/70 p-3 dark:bg-dark-50/70`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(t.data.name||e(`libreClaw.fallbacks.tool`))}),(0,G.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto rounded bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(t.data.arguments||{},null,2)}),(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,G.jsxs)(w,{size:`sm`,onClick:()=>Be(t,`allow_once`),children:[(0,G.jsx)(x,{className:`h-4 w-4`}),e(`libreClaw.approvals.allowOnce`)]}),(0,G.jsx)(w,{size:`sm`,variant:`secondary`,onClick:()=>Be(t,`always_allow_tool`),children:e(`libreClaw.approvals.alwaysAllowTool`)}),(0,G.jsxs)(w,{size:`sm`,variant:`danger`,onClick:()=>Be(t,`deny`),children:[(0,G.jsx)(_,{className:`h-4 w-4`}),e(`libreClaw.approvals.deny`)]})]})]},t.event_id))]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[T.length===0&&(0,G.jsx)(Ee,{text:e(`libreClaw.timeline.empty`)}),Ie.map(t=>(0,G.jsx)(xe,{item:t,t:e},t.key))]})]})]}),(0,G.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,G.jsx)(J,{title:e(`libreClaw.automations.title`),icon:(0,G.jsx)(p,{className:`h-4 w-4`}),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,G.jsx)(`input`,{value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`libreClaw.automations.namePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,G.jsx)(`input`,{value:je,onChange:e=>X(e.target.value),placeholder:e(`libreClaw.automations.schedulePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,G.jsxs)(`select`,{value:Ne,onChange:e=>Pe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,G.jsx)(`option`,{value:`report`,children:e(`libreClaw.automations.routes.report`)}),(0,G.jsx)(`option`,{value:`telegram`,children:e(`libreClaw.automations.routes.telegram`)})]}),(0,G.jsx)(w,{onClick:Ue,loading:V,children:e(`libreClaw.automations.create`)})]}),(0,G.jsx)(`textarea`,{value:Z,onChange:e=>Me(e.target.value),placeholder:e(`libreClaw.automations.promptPlaceholder`),className:`min-h-24 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[D.length===0&&(0,G.jsx)(Ee,{text:e(`libreClaw.automations.empty`)}),D.map(t=>(0,G.jsx)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-3 dark:border-dark-300 dark:bg-dark-50`,children:(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.name}),(0,G.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[t.schedule,` ·`,` `,e(`libreClaw.automations.routes.${t.route}`,{defaultValue:t.route}),` `,`·`,` `,e(`libreClaw.automations.status.${t.status}`,{defaultValue:t.status})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,G.jsx)(be,{title:e(`libreClaw.automations.runNow`),onClick:()=>We(t.automation_id,`run`),children:(0,G.jsx)(s,{className:`h-4 w-4`})}),(0,G.jsx)(be,{title:t.status===`paused`?e(`libreClaw.automations.resume`):e(`libreClaw.automations.pause`),onClick:()=>We(t.automation_id,t.status===`paused`?`resume`:`pause`),children:t.status===`paused`?(0,G.jsx)(s,{className:`h-4 w-4`}):(0,G.jsx)(g,{className:`h-4 w-4`})}),(0,G.jsx)(be,{title:e(`common.delete`),danger:!0,onClick:()=>We(t.automation_id,`delete`),children:(0,G.jsx)(b,{className:`h-4 w-4`})})]})]})},t.automation_id))]})]})}),(0,G.jsx)(J,{title:e(`libreClaw.usageFallback.title`),icon:(0,G.jsx)(a,{className:`h-4 w-4`}),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.usage`)}),(0,G.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:ne||e(`libreClaw.usageFallback.noUsage`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.fallbackRoute`)}),(0,G.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(A||{},null,2)})]})]})})]})]}),P&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-white/60 backdrop-blur-sm dark:bg-dark-50/60`,children:(0,G.jsx)(o,{className:`h-7 w-7 animate-spin text-primary-600`})})]})},ve=({status:e,t})=>{let n=!!e?.connected;return(0,G.jsxs)(`span`,{className:C(`inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium`,n?`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`:`bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300`),children:[(0,G.jsx)(`span`,{className:C(`h-2 w-2 rounded-full`,n?`bg-emerald-500`:`bg-amber-500`)}),t(n?`libreClaw.status.connected`:`libreClaw.status.disconnected`),e?.health?.active_runs!==void 0&&(0,G.jsxs)(`span`,{className:`opacity-70`,children:[`·`,` `,t(`libreClaw.status.activeRuns`,{count:e.health.active_runs})]})]})},ye=({state:e,t})=>(0,G.jsx)(`span`,{className:C(`rounded-full px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,q[e]||q.queued),children:t(`libreClaw.states.${e}`,{defaultValue:e})}),J=({title:e,icon:t,actions:n,children:r})=>(0,G.jsxs)(`section`,{className:`rounded-xl border border-gray-200 bg-white shadow-sm dark:border-dark-300 dark:bg-dark-25`,children:[(0,G.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-gray-100 px-4 py-3 dark:border-dark-200`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:[(0,G.jsx)(`span`,{className:`text-primary-600 dark:text-primary-300`,children:t}),e]}),n]}),(0,G.jsx)(`div`,{className:`p-4`,children:r})]}),be=({title:e,danger:t,onClick:n,children:r})=>(0,G.jsx)(`button`,{type:`button`,title:e,onClick:n,className:C(`inline-flex h-8 w-8 items-center justify-center rounded-lg transition-colors`,t?`text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`:`text-gray-500 hover:bg-gray-100 dark:text-dark-500 dark:hover:bg-dark-200`),children:r}),xe=({item:e,t})=>(0,G.jsxs)(`article`,{className:C(`rounded-xl border p-3 transition-colors`,e.eventType===`assistant_message`?`border-primary-200 bg-primary-50/60 dark:border-primary-900/60 dark:bg-primary-900/10`:(e.eventType,`border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-50`)),children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:C(`text-xs font-semibold uppercase tracking-wide`,he[e.eventType]||`text-gray-500 dark:text-dark-500`),children:e.label}),(0,G.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-400 dark:text-dark-500`,children:[je(e),` · `,De(e.timestamp)]})]}),(0,G.jsx)(Se,{item:e,t})]}),Se=({item:e,t})=>{if(e.kind===`assistant_message`)return(0,G.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-gray-900 dark:text-dark-900`,children:ke(e.events)||t(`libreClaw.timeline.streaming`)});let n=e.events[0];return n?n.type===`assistant_delta`?(0,G.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.text||``)}):n.type===`user_message`?(0,G.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.content||``)}):n.type===`tool_call`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.fallbacks.tool`))}),(0,G.jsx)(Te,{value:n.data.arguments||{}})]}):n.type===`tool_result`?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:[String(n.data.name||t(`libreClaw.fallbacks.tool`)),` ·`,` `,n.data.is_error?t(`libreClaw.timeline.resultError`):t(`libreClaw.timeline.resultOk`)]}),(0,G.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:String(n.data.content||``)})]}):n.type===`permission_request`?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.approvals.toolApprovalRequested`))}),(0,G.jsx)(Te,{value:n.data.arguments||{}})]}):n.type===`permission_response`?(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Y,{label:t(`libreClaw.metrics.tool`),value:String(n.data.name||n.data.tool_call_id||t(`libreClaw.fallbacks.tool`))}),(0,G.jsx)(Y,{label:t(`libreClaw.metrics.resolution`),value:String(n.data.resolution||t(`libreClaw.fallbacks.resolved`))})]}):n.type===`usage`?(0,G.jsx)(Ce,{data:n.data,t}):n.type===`run_finished`?(0,G.jsx)(we,{data:n.data,t}):n.type===`error`?(0,G.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-300`,children:String(n.data.message||t(`libreClaw.fallbacks.unknownError`))}):(0,G.jsx)(Te,{value:n.data}):null},Ce=({data:e,t})=>(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Y,{label:t(`libreClaw.metrics.provider`),value:String(e.provider||t(`libreClaw.fallbacks.unknown`))}),(0,G.jsx)(Y,{label:t(`libreClaw.metrics.model`),value:String(e.model||t(`libreClaw.fallbacks.unknown`))}),(0,G.jsx)(Y,{label:t(`libreClaw.metrics.input`),value:t(`libreClaw.metrics.tokens`,{count:X(e.input_tokens),formatted:Z(e.input_tokens)})}),(0,G.jsx)(Y,{label:t(`libreClaw.metrics.output`),value:t(`libreClaw.metrics.tokens`,{count:X(e.output_tokens),formatted:Z(e.output_tokens)})}),X(e.cached_tokens)>0&&(0,G.jsx)(Y,{label:t(`libreClaw.metrics.cached`),value:t(`libreClaw.metrics.tokens`,{count:X(e.cached_tokens),formatted:Z(e.cached_tokens)})}),X(e.reasoning_tokens)>0&&(0,G.jsx)(Y,{label:t(`libreClaw.metrics.reasoning`),value:t(`libreClaw.metrics.tokens`,{count:X(e.reasoning_tokens),formatted:Z(e.reasoning_tokens)})}),(0,G.jsx)(Y,{label:t(`libreClaw.metrics.cost`),value:Me(e.cost)})]}),we=({data:e,t})=>(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Y,{label:t(`libreClaw.metrics.state`),value:t(`libreClaw.states.${String(e.state||`done`)}`,{defaultValue:String(e.state||`done`)})}),e.stop_reason!==void 0&&(0,G.jsx)(Y,{label:t(`libreClaw.metrics.stopReason`),value:String(e.stop_reason)})]}),Y=({label:e,value:t})=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-100 dark:text-dark-700`,children:[(0,G.jsx)(`span`,{className:`font-semibold text-gray-500 dark:text-dark-500`,children:e}),(0,G.jsx)(`span`,{children:t})]}),Te=({value:e})=>(0,G.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(e,null,2)}),Ee=({text:e})=>(0,G.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-200 bg-gray-50 px-4 py-8 text-center text-sm text-gray-500 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-500`,children:e}),De=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},Oe=(e,t)=>{let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;if(i.type===`assistant_delta`){let i=[];for(;e[r]?.type===`assistant_delta`;){let t=e[r];t&&i.push(t),r+=1}let a=i[0],o=i[i.length-1]||a;a&&o&&n.push({key:`assistant-${a.event_id}-${o.event_id}`,kind:`assistant_message`,eventType:`assistant_message`,label:t(`libreClaw.timeline.assistantResponse`),firstEventId:a.event_id,lastEventId:o.event_id,timestamp:a.timestamp,events:i});continue}n.push({key:`${i.type}-${i.event_id}`,kind:`event`,eventType:i.type,label:Ae(i.type,t),firstEventId:i.event_id,lastEventId:i.event_id,timestamp:i.timestamp,events:[i]}),r+=1}return n},ke=e=>e.map(e=>String(e.data.text||``)).join(``),Ae=(e,t)=>({user_message:t(`libreClaw.timeline.labels.userMessage`),tool_call:t(`libreClaw.timeline.labels.toolCall`),tool_result:t(`libreClaw.timeline.labels.toolResult`),permission_request:t(`libreClaw.timeline.labels.approvalRequest`),permission_response:t(`libreClaw.timeline.labels.approvalResponse`),run_started:t(`libreClaw.timeline.labels.runStarted`),run_finished:t(`libreClaw.timeline.labels.runFinished`),usage:t(`libreClaw.timeline.labels.usage`),error:t(`libreClaw.timeline.labels.error`)})[e]||e.replace(/_/g,` `),je=e=>e.firstEventId===e.lastEventId?`#${e.firstEventId}`:`#${e.firstEventId}-#${e.lastEventId}`,X=e=>{let t=Number(e);return Number.isFinite(t)?t:0},Z=e=>new Intl.NumberFormat().format(X(e)),Me=e=>{let t=X(e);return t<=0?`$0.00`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`};export{_e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-QTnfLwEv.js";import{d as e,f as t}from"./markdown-core-fkbHPd-g.js";import{n}from"./react-vendor-Co1u1rWb.js";import{T as r,d as i,n as a,rt as o,ut as s}from"./ui-vendor-BJAeWL11.js";import{t as c}from"./utils-BaPYjs_z.js";import{t as l}from"./Button-BUjLpHmR.js";import{k as u}from"../assets/index-ONn9VIq7.js";t();var d=n(),f=e(),p=({models:e,showDetailsModal:t,setShowDetailsModal:n,selectedModelName:p,selectedModelDetails:m,loadingDetails:h,showCopyModal:g,setShowCopyModal:_,copySource:v,setCopySource:y,copyDestination:b,setCopyDestination:x,copying:S,handleCopyModel:C,showCreateModal:w,setShowCreateModal:T,createModelName:E,setCreateModelName:D,createModelfile:O,setCreateModelfile:k,creating:A,handleCreateModel:j,showEmbeddingsModal:M,setShowEmbeddingsModal:N,embeddingsModel:P,setEmbeddingsModel:F,embeddingsInput:I,setEmbeddingsInput:L,embeddingsResult:R,generatingEmbeddings:z,handleGenerateEmbeddings:B})=>{let{t:V}=u();return(0,f.jsxs)(f.Fragment,{children:[t&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>n(!1)}),(0,f.jsxs)(`div`,{className:c(`relative w-full max-w-2xl max-h-[85vh] overflow-hidden rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:c(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[V(`modelManager.modals.details.title`),`: `,p]}),(0,f.jsx)(`button`,{onClick:()=>n(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(a,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsx)(`div`,{className:`overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4`,children:h?(0,f.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,f.jsx)(r,{className:`h-6 w-6 animate-spin text-gray-400`})}):m?(0,f.jsxs)(f.Fragment,{children:[m.details&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.info`)}),(0,f.jsx)(`div`,{className:c(`p-3 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-50`),children:(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[m.details.family&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.family`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.family})]}),m.details.parameter_size&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.parameters`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.parameter_size})]}),m.details.quantization_level&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.quantization`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.quantization_level})]}),m.details.format&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.format`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.format})]})]})})]}),m.system&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.systemPrompt`)}),(0,f.jsx)(`pre`,{className:c(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.system})]}),m.template&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.template`)}),(0,f.jsx)(`pre`,{className:c(`p-3 rounded-lg text-xs overflow-x-auto max-h-40`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.template})]}),m.parameters&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.parameters`)}),(0,f.jsx)(`pre`,{className:c(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.parameters})]}),m.license&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.license`)}),(0,f.jsx)(`pre`,{className:c(`p-3 rounded-lg text-xs overflow-x-auto max-h-32`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.license})]}),m.modelfile&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.modelfile`)}),(0,f.jsx)(`pre`,{className:c(`p-3 rounded-lg text-xs overflow-x-auto max-h-60`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.modelfile})]})]}):(0,f.jsx)(`p`,{className:`text-center text-gray-500`,children:V(`modelManager.modals.details.noDetails`)})})]})]}),document.body),g&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>_(!1)}),(0,f.jsxs)(`div`,{className:c(`relative w-full max-w-md rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:c(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.copy.title`)}),(0,f.jsx)(`button`,{onClick:()=>_(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(a,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.source`)}),(0,f.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),className:c(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`),children:[(0,f.jsx)(`option`,{value:``,children:V(`modelManager.modals.copy.selectModel`)}),e.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.newName`)}),(0,f.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:V(`modelManager.modals.copy.placeholder`),className:c(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]}),(0,f.jsxs)(l,{onClick:C,disabled:!v.trim()||!b.trim()||S,className:c(`w-full gap-2`,``),children:[S?(0,f.jsx)(r,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(s,{className:`h-4 w-4`}),V(S?`modelManager.modals.copy.copying`:`modelManager.modals.copy.button`)]})]})]})]}),document.body),w&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>T(!1)}),(0,f.jsxs)(`div`,{className:c(`relative w-full max-w-lg rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:c(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.create.title`)}),(0,f.jsx)(`button`,{onClick:()=>T(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(a,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.name`)}),(0,f.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:V(`modelManager.modals.create.namePlaceholder`),className:c(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.modelfile`)}),(0,f.jsx)(`textarea`,{value:O,onChange:e=>k(e.target.value),placeholder:V(`modelManager.modals.create.modelfilePlaceholder`),rows:8,className:c(`w-full px-3 py-2 rounded-lg border text-sm font-mono`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`,`resize-none`)}),(0,f.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500`,children:[V(`modelManager.modals.create.see`),` `,(0,f.jsx)(`a`,{href:`https://github.com/ollama/ollama/blob/main/docs/modelfile.md`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 hover:underline`,children:V(`modelManager.modals.create.docs`)}),` `,V(`modelManager.modals.create.docsLink`)]})]}),(0,f.jsxs)(l,{onClick:j,disabled:!E.trim()||!O.trim()||A,className:c(`w-full gap-2`,``),children:[A?(0,f.jsx)(r,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(o,{className:`h-4 w-4`}),V(A?`modelManager.modals.create.creating`:`modelManager.modals.create.button`)]})]})]})]}),document.body),M&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>N(!1)}),(0,f.jsxs)(`div`,{className:c(`relative w-full max-w-lg rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:c(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.embeddings.title`)}),(0,f.jsx)(`button`,{onClick:()=>N(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(a,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.model`)}),(0,f.jsxs)(`select`,{value:P,onChange:e=>F(e.target.value),className:c(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`),children:[(0,f.jsx)(`option`,{value:``,children:V(`modelManager.modals.embeddings.selectModel`)}),e.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,f.jsx)(`p`,{className:`mt-1 text-xs text-gray-500`,children:V(`modelManager.modals.embeddings.recommended`)})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.input`)}),(0,f.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:V(`modelManager.modals.embeddings.placeholder`),rows:3,className:c(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`,`resize-none`)})]}),(0,f.jsxs)(l,{onClick:B,disabled:!P.trim()||!I.trim()||z,className:c(`w-full gap-2`,``),children:[z?(0,f.jsx)(r,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(i,{className:`h-4 w-4`}),V(z?`modelManager.modals.embeddings.generating`:`modelManager.modals.embeddings.button`)]}),R&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.result`,{count:R.length})}),(0,f.jsxs)(`pre`,{className:c(`p-3 rounded-lg text-xs overflow-x-auto max-h-32`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:[`[`,R.slice(0,10).join(`, `),R.length>10&&`, ...`,` ]`]})]})]})]})]}),document.body)]})};export{p as ModelManagerModals,p as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/ModelManagerModals-CfvSeNsT.js","js/rolldown-runtime-QTnfLwEv.js","js/markdown-core-fkbHPd-g.js","js/react-vendor-Co1u1rWb.js","js/ui-vendor-BJAeWL11.js","js/utils-BaPYjs_z.js","js/utils-vendor-BX3ZwoIK.js","js/Button-BUjLpHmR.js","assets/index-ONn9VIq7.js","js/logger-BmpKNkls.js","js/demoMode-BhEpMVh5.js","js/api-CbmZzKBu.js","assets/index-Dc8Q4dJZ.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-fkbHPd-g.js";import{t as r}from"./useQuery-DfkI6VAv.js";import{r as i,t as a}from"./logger-BmpKNkls.js";import{$ as o,Dt as s,F as c,G as l,H as u,It as d,K as f,Pt as p,S as m,T as h,Vt as g,_t as _,b as ee,d as te,ft as v,ht as y,lt as b,n as x,ot as S,pt as C,q as w,rt as ne,st as T,t as re,u as E,ut as ie,vt as ae,y as oe,z as se}from"./ui-vendor-BJAeWL11.js";import{c as D,d as ce}from"./api-CbmZzKBu.js";import{t as O}from"./utils-BaPYjs_z.js";import{t as k}from"./Button-BUjLpHmR.js";import{H as le,g as ue,k as A}from"../assets/index-ONn9VIq7.js";var j=e(n(),1),M=t();function de({expanded:e,models:t,search:n,task:r,sort:i,loadingModels:a,canInstallModels:o,expandedModelId:s,loadingGgufModelId:c,ggufFiles:l,pullingModel:u,pullProgress:d,setSearch:f,setTask:p,setSort:g,onToggle:ee,onToggleModel:te,onPullGguf:v,onCancelPull:b,onRefresh:x}){let{t:C}=A();return(0,M.jsxs)(`div`,{className:O(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsxs)(`button`,{onClick:ee,className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(`div`,{className:O(`p-2 rounded-lg`,`bg-yellow-100 dark:bg-yellow-900/30`),children:(0,M.jsx)(re,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400`})}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:C(`modelManager.sections.huggingface`,`HuggingFace Hub`)}),t.length>0&&(0,M.jsxs)(`span`,{className:O(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,C(`modelManager.library.available`,`available`)]})]}),e?(0,M.jsx)(y,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(_,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,M.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(m,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,M.jsx)(`input`,{type:`text`,value:n,onChange:e=>f(e.target.value),placeholder:C(`modelManager.huggingface.search`,`Search HuggingFace models...`),className:O(`w-full pl-10 pr-4 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,M.jsxs)(`select`,{value:r,onChange:e=>p(e.target.value),className:O(`px-3 py-2 rounded-lg border text-sm min-w-[160px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,M.jsx)(`option`,{value:`text-generation`,children:C(`modelManager.huggingface.tasks.textGen`,`Text Generation`)}),(0,M.jsx)(`option`,{value:`text-to-speech`,children:C(`modelManager.huggingface.tasks.tts`,`Text to Speech`)}),(0,M.jsx)(`option`,{value:`text-to-image`,children:C(`modelManager.huggingface.tasks.image`,`Text to Image`)}),(0,M.jsx)(`option`,{value:`automatic-speech-recognition`,children:C(`modelManager.huggingface.tasks.stt`,`Speech Recognition`)})]}),(0,M.jsxs)(`select`,{value:i,onChange:e=>g(e.target.value),className:O(`px-3 py-2 rounded-lg border text-sm min-w-[140px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,M.jsx)(`option`,{value:`downloads`,children:C(`modelManager.huggingface.sort.downloads`,`Most Downloads`)}),(0,M.jsx)(`option`,{value:`likes`,children:C(`modelManager.huggingface.sort.likes`,`Most Liked`)}),(0,M.jsx)(`option`,{value:`lastModified`,children:C(`modelManager.huggingface.sort.recent`,`Recently Updated`)})]})]}),!o&&(0,M.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:C(`modelManager.pull.restricted`)}),a?(0,M.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,M.jsx)(se,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,M.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:C(`modelManager.huggingface.noResults`,`No models found. Try adjusting your search or filters.`)}):(0,M.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:t.map(e=>(0,M.jsx)(fe,{model:e,expanded:s===e.id,loadingGguf:c===e.id,ggufFiles:l[e.id]||[],pullingModel:u,pullProgress:d,canInstallModels:o,onToggle:()=>te(e.id),onPullGguf:v,onCancelPull:b},e.id))}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,M.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,className:O(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,M.jsx)(S,{className:`h-3 w-3`}),C(`modelManager.huggingface.browseAll`,`Browse all on HuggingFace`)]}),(0,M.jsxs)(k,{onClick:x,variant:`outline`,size:`sm`,disabled:a,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(h,{className:O(`h-3.5 w-3.5`,a&&`animate-spin`)}),C(`modelManager.library.refresh`,`Refresh`)]})]})]})]})}function fe({model:e,expanded:t,loadingGguf:n,ggufFiles:r,pullingModel:i,pullProgress:a,canInstallModels:o,onToggle:s,onPullGguf:c,onCancelPull:u}){let{t:d}=A();return(0,M.jsxs)(`div`,{className:O(`rounded-lg border transition-all overflow-hidden`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,M.jsxs)(`div`,{className:`p-4 cursor-pointer`,onClick:s,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,M.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800 truncate`,children:e.id}),e.gated&&(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded text-xs`,`bg-yellow-100 dark:bg-yellow-900/30`,`text-yellow-700 dark:text-yellow-400`),children:d(`modelManager.huggingface.gated`,`Gated`)})]}),(0,M.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-0.5`,children:[d(`modelManager.huggingface.by`,`by`),` `,e.author]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,M.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 transition-colors`,title:d(`modelManager.huggingface.viewOnHF`,`View on HuggingFace`),children:(0,M.jsx)(S,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`})}),(0,M.jsx)(_,{className:O(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(T,{className:`h-3.5 w-3.5`}),P(e.downloads)]}),(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(l,{className:`h-3.5 w-3.5`}),P(e.likes)]}),e.pipeline_tag&&(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded`,`bg-gray-200 dark:bg-dark-300`),children:e.pipeline_tag})]})]}),t&&(0,M.jsx)(pe,{modelId:e.id,loading:n,files:r,pullingModel:i,pullProgress:a,canInstallModels:o,onPullGguf:c,onCancelPull:u})]})}function pe({modelId:e,loading:t,files:n,pullingModel:r,pullProgress:i,canInstallModels:a,onPullGguf:o,onCancelPull:s}){let{t:c}=A();return(0,M.jsx)(`div`,{className:`px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100`,children:t?(0,M.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,M.jsx)(se,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,M.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:c(`modelManager.huggingface.checkingGguf`)})]}):n.length===0?(0,M.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:c(`modelManager.huggingface.noGgufAvailable`)}):(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:c(`modelManager.huggingface.ggufFilesCount`,{count:n.length})}),n.map(e=>(0,M.jsx)(N,{file:e,pulling:r===e.ollamaCommand,pullProgress:i,canInstallModels:a,disabled:!!r||!a,onPullGguf:o,onCancelPull:s},e.filename)),r?.startsWith(`hf.co/`)&&r.includes(e)&&i?.percent!==void 0&&(0,M.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,M.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${i.percent}%`}})})]})})}function N({file:e,pulling:t,disabled:n,pullProgress:r,onPullGguf:i,onCancelPull:a}){let{t:o}=A();return(0,M.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300`,children:[(0,M.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,M.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,M.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:r?.percent===void 0?`...`:`${r.percent}%`}),(0,M.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,M.jsx)(x,{className:`h-4 w-4`})})]}):(0,M.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(e.ollamaCommand,e.filename)},disabled:n,className:O(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,M.jsx)(T,{className:`h-3 w-3 inline mr-1`}),o(`models.pull`)]})]})}function P(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e}function me({expanded:e,models:t,onToggle:n,isModelRunning:r,formatSize:i,onShowModel:a,onCopyModel:o,onDeleteModel:s}){let{t:c}=A();return(0,M.jsxs)(`div`,{className:O(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsxs)(`button`,{onClick:n,className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(`div`,{className:O(`p-2 rounded-lg`,`bg-blue-100 dark:bg-blue-900/30`),children:(0,M.jsx)(w,{className:`h-5 w-5 text-blue-600 dark:text-blue-400`})}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:c(`modelManager.sections.local`)}),(0,M.jsxs)(`span`,{className:O(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,c(`modelManager.local.installed`)]})]}),e?(0,M.jsx)(y,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(_,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,M.jsx)(`div`,{className:`p-4 pt-0`,children:t.length===0?(0,M.jsxs)(`div`,{className:O(`text-center py-12 rounded-lg border-2 border-dashed`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsx)(w,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,M.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-2`,children:c(`modelManager.local.noModels`)}),(0,M.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:c(`modelManager.local.pullToStart`)})]}):(0,M.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,M.jsx)(he,{model:e,running:r(e.name),formatSize:i,onShowModel:a,onCopyModel:o,onDeleteModel:s},e.name))})})]})}function he({model:e,running:t,formatSize:n,onShowModel:r,onCopyModel:i,onDeleteModel:a}){let{t:o}=A();return(0,M.jsx)(`div`,{className:O(`p-4 rounded-lg border transition-colors`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:bg-gray-100 dark:hover:bg-dark-200`),children:(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,M.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,M.jsxs)(`span`,{className:O(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse`}),o(`modelManager.local.running`)]})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 mt-2`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(w,{className:`h-3.5 w-3.5`}),n(e.size)]}),e.details?.parameter_size&&(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(b,{className:`h-3.5 w-3.5`}),e.details.parameter_size]}),e.details?.quantization_level&&(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e.details.quantization_level}),e.details?.family&&(0,M.jsx)(`span`,{className:`text-gray-500 dark:text-gray-500`,children:e.details.family})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 mt-2`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(C,{className:`h-3 w-3`}),new Date(e.modified_at).toLocaleDateString()]}),(0,M.jsxs)(`span`,{className:`flex items-center gap-1 font-mono truncate max-w-[200px]`,title:e.digest,children:[(0,M.jsx)(f,{className:`h-3 w-3`}),e.digest.slice(0,12),`...`]})]})]}),(0,M.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,M.jsxs)(k,{onClick:()=>r(e.name),variant:`outline`,size:`sm`,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(u,{className:`h-3.5 w-3.5`}),o(`modelManager.local.info`)]}),(0,M.jsxs)(k,{onClick:()=>i(e.name),variant:`outline`,size:`sm`,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(ie,{className:`h-3.5 w-3.5`}),o(`modelManager.local.copy`)]}),(0,M.jsxs)(k,{onClick:()=>a(e.name),variant:`outline`,size:`sm`,className:O(`gap-1.5`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,M.jsx)(E,{className:`h-3.5 w-3.5`}),o(`modelManager.local.delete`)]})]})]})})}function ge({expanded:e,models:t,totalAvailable:n,categories:r,filter:i,search:a,loading:o,pulling:s,canInstallModels:c,pullSectionExpanded:l,setFilter:u,setSearch:f,isModelInstalled:p,normalizeCloudPullName:g,onToggle:ee,onTogglePullSection:te,onPullModel:b,onRefresh:x}){let{t:S}=A();return(0,M.jsxs)(`div`,{className:O(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsxs)(`button`,{onClick:ee,className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(`div`,{className:O(`p-2 rounded-lg`,`bg-blue-100 dark:bg-blue-900/30`),children:(0,M.jsx)(v,{className:`h-5 w-5 text-blue-600 dark:text-blue-400`})}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:S(`modelManager.sections.library`)}),(0,M.jsxs)(`span`,{className:O(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[n,` `,S(`modelManager.library.available`)]})]}),e?(0,M.jsx)(y,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(_,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,M.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(m,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,M.jsx)(`input`,{type:`text`,value:a,onChange:e=>f(e.target.value),placeholder:S(`modelManager.library.search`),className:O(`w-full pl-10 pr-4 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(d,{className:`h-4 w-4 text-gray-400`}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,M.jsx)(`button`,{onClick:()=>u(e),className:O(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,i===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),o?(0,M.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,M.jsx)(h,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,M.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:S(`modelManager.library.noResults`)}):(0,M.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.category===`cloud`?g(e.name):e.name;return(0,M.jsx)(_e,{model:e,installed:p(e.name)||p(t),pulling:s,canInstallModels:c,pullSectionExpanded:l,onTogglePullSection:te,onPullModel:b},e.name)})}),(0,M.jsx)(`div`,{className:`flex justify-center`,children:(0,M.jsxs)(k,{onClick:x,variant:`outline`,size:`sm`,disabled:o,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(h,{className:O(`h-3.5 w-3.5`,o&&`animate-spin`)}),S(`modelManager.library.refresh`)]})})]})]})}function _e({model:e,installed:t,pulling:n,canInstallModels:r,pullSectionExpanded:i,onTogglePullSection:a,onPullModel:o}){let{t:s}=A();return(0,M.jsxs)(`div`,{"data-testid":`library-model-card-${e.name}`,className:O(`p-4 rounded-lg border transition-all`,`bg-gray-50 dark:bg-dark-50`,t?`border-green-200 dark:border-green-800/50`:`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,M.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,M.jsxs)(`span`,{className:O(`flex items-center gap-1 px-1.5 py-0.5 rounded text-xs`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,M.jsx)(ae,{className:`h-3 w-3`}),s(`modelManager.library.installed`)]})]}),(0,M.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-dark-600 mb-3 line-clamp-2`,children:e.description}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.sizes.slice(0,4).map(e=>(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e},e)),e.sizes.length>4&&(0,M.jsx)(`span`,{className:`text-xs text-gray-400`,children:s(`modelManager.library.more`,{count:e.sizes.length-4})})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[e.pulls&&(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(T,{className:`h-3 w-3`}),e.pulls]}),(0,M.jsx)(`span`,{className:O(`px-1.5 py-0.5 rounded capitalize`,e.category===`cloud`?`bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400`:`bg-gray-100 dark:bg-dark-200`),children:e.category})]}),(0,M.jsxs)(k,{"data-testid":`library-model-pull-${e.name}`,onClick:()=>{i||a(),o(e.name,e.category)},variant:`outline`,size:`sm`,disabled:n||!r,className:O(`gap-1 text-xs`,``,``),children:[(0,M.jsx)(T,{className:`h-3 w-3`}),s(`modelManager.pull.button`)]})]})]})}function ve({expanded:e,modelName:t,setModelName:n,pulling:r,progress:i,canInstallModels:a,popularModels:o,onToggle:s,onPull:c,onCancelPull:l,formatSize:u}){let{t:d}=A();return(0,M.jsxs)(`div`,{className:O(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsxs)(`button`,{onClick:s,className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(`div`,{className:O(`p-2 rounded-lg`,`bg-primary-100 dark:bg-primary-900/30`),children:(0,M.jsx)(T,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:d(`modelManager.sections.pull`)})]}),e?(0,M.jsx)(y,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(_,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,M.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsxs)(`div`,{className:`relative flex-1`,children:[(0,M.jsx)(m,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,M.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:d(`modelManager.pull.placeholder`),className:O(`w-full pl-10 pr-4 py-2.5 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`),disabled:r||!a,onKeyDown:e=>{e.key===`Enter`&&!r&&a&&c()}})]}),r?(0,M.jsxs)(k,{onClick:l,variant:`outline`,className:O(`px-4 py-2.5 gap-2`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,M.jsx)(x,{className:`h-4 w-4`}),d(`modelManager.pull.cancel`)]}):(0,M.jsxs)(k,{onClick:c,disabled:!t.trim()||!a,className:O(`px-4 py-2.5 gap-2`,``),children:[(0,M.jsx)(T,{className:`h-4 w-4`}),d(`modelManager.pull.button`)]})]}),r&&i&&(0,M.jsx)(ye,{progress:i,formatSize:u}),!a&&(0,M.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:d(`modelManager.pull.restricted`)}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 mb-2`,children:d(`modelManager.pull.popular`)}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.map(e=>(0,M.jsxs)(`button`,{onClick:()=>n(e.name),disabled:r||!a,className:O(`px-3 py-1.5 rounded-full text-xs font-medium transition-colors`,`bg-gray-100 dark:bg-dark-200`,`text-gray-700 dark:text-gray-300`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`border border-gray-200 dark:border-dark-300`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[e.name,(0,M.jsx)(`span`,{className:`ml-1 text-gray-400 dark:text-gray-500`,children:e.size})]},e.name))})]}),(0,M.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,className:O(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,M.jsx)(S,{className:`h-3 w-3`}),d(`modelManager.pull.browseAll`)]})]})]})}function ye({progress:e,formatSize:t}){let{t:n}=A(),r=e.status===`starting`?n(`modelManager.progress.starting`):e.status.startsWith(`pulling`)?`${n(`modelManager.progress.pullingLayer`)} ${e.status.replace(`pulling `,``)}`:e.status.startsWith(`verifying sha256`)?n(`modelManager.progress.verifyingDigest`):e.status===`writing manifest`?n(`modelManager.progress.writing`):e.status===`removing any unused layers`?n(`modelManager.progress.cleaning`):e.status;return(0,M.jsxs)(`div`,{className:O(`p-4 rounded-lg border`,`bg-gray-50 dark:bg-dark-200`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,M.jsx)(`span`,{className:`text-sm font-medium text-gray-800 dark:text-dark-700`,children:r}),e.percent!==void 0&&(0,M.jsxs)(`span`,{className:`text-sm font-mono text-gray-600 dark:text-dark-600`,children:[e.percent,`%`]})]}),e.percent!==void 0&&(0,M.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-400 rounded-full h-2 overflow-hidden`,children:(0,M.jsx)(`div`,{className:O(`h-2 rounded-full transition-all duration-300`,`bg-primary-500 dark:bg-primary-400`),style:{width:`${e.percent}%`}})}),e.total&&e.completed&&(0,M.jsxs)(`div`,{className:`mt-2 text-xs text-gray-600 dark:text-dark-600`,children:[t(e.completed),` / `,t(e.total)]})]})}var be=a(`components:model-manager`),xe=j.lazy(()=>i(()=>import(`./ModelManagerModals-CfvSeNsT.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),F=e=>{let t=e.split(`:`).pop()?.toLowerCase();return t===`cloud`||t?.endsWith(`-cloud`)===!0},Se=e=>{let t=e.trim();if(!t||F(t))return t;let n=t.lastIndexOf(`:`);return n===-1?`${t}:cloud`:`${t.slice(0,n)}:${t.slice(n+1)}-cloud`},I=()=>{let{t:e}=A(),{user:t,systemInfo:n}=ue(),i=t?.role===`admin`||(n?.allowUserModelPull??!0),a=le(),[l,u]=(0,j.useState)(`all`),[d,f]=(0,j.useState)(``),[m,v]=(0,j.useState)(``),[b,x]=(0,j.useState)(!1),[S,C]=(0,j.useState)(null),[T,E]=(0,j.useState)(null),[ae,se]=(0,j.useState)(null),[fe,pe]=(0,j.useState)(``),[N,P]=(0,j.useState)(!1),[he,_e]=(0,j.useState)(!1),[ye,F]=(0,j.useState)(!1),[I,L]=(0,j.useState)(``),[R,Ce]=(0,j.useState)(``),[we,Te]=(0,j.useState)(!1),[Ee,De]=(0,j.useState)(!1),[z,Oe]=(0,j.useState)(``),[ke,Ae]=(0,j.useState)(``),[je,Me]=(0,j.useState)(!1),[Ne,Pe]=(0,j.useState)(!1),[Fe,Ie]=(0,j.useState)(``),[Le,Re]=(0,j.useState)(``),[ze,Be]=(0,j.useState)(null),[Ve,He]=(0,j.useState)(!1),[Ue,We]=(0,j.useState)(``),[Ge,Ke]=(0,j.useState)(``),[B,qe]=(0,j.useState)(`text-generation`),[V,Je]=(0,j.useState)(`downloads`),[Ye,Xe]=(0,j.useState)(null),[Ze,Qe]=(0,j.useState)({}),[$e,et]=(0,j.useState)(null),[tt,H]=(0,j.useState)(null),[nt,U]=(0,j.useState)(null),[rt,W]=(0,j.useState)(null),[G,it]=(0,j.useState)(new Set([`pull`,`local`])),K=e=>{it(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},{data:q,isLoading:at,refetch:J}=r({queryKey:[`ollama-state`],queryFn:async()=>{let[e,t,n,r]=await Promise.all([D.getModels(),D.listRunningModels(),D.getVersion(),D.checkHealth()]);return{models:e.success&&e.data||[],runningModels:t.success&&Array.isArray(t.data)?t.data:[],ollamaVersion:n.success&&n.data?n.data.version:null,isHealthy:r.success}}}),Y=q?.models??[],X=q?.runningModels??[],ot=q?.ollamaVersion??null,st=q?.isHealthy??null,Z=(0,j.useCallback)(async()=>{await J()},[J]),{data:Q=[],isLoading:ct}=r({queryKey:[`ollama-library`],queryFn:async()=>{let e=await D.getLibraryModels();return e.success&&e.data?e.data:[]}}),{data:lt=[],isLoading:ut}=r({queryKey:[`ollama-library`,`cloud`],queryFn:async()=>{let e=await D.getLibraryModels({category:`cloud`});return e.success&&e.data?e.data:[]},enabled:l===`cloud`}),dt=()=>a.invalidateQueries({queryKey:[`ollama-library`]});(0,j.useEffect)(()=>{let e=setTimeout(()=>{Ke(Ue)},300);return()=>clearTimeout(e)},[Ue]);let ft=G.has(`huggingface`),{data:pt=[],isLoading:mt}=r({queryKey:[`hf-models`,B,Ge,V],queryFn:async()=>{let e=await ce.getModels({task:B,search:Ge||void 0,sort:V,limit:30});return e.success&&e.data?e.data:[]},enabled:ft}),ht=()=>a.invalidateQueries({queryKey:[`hf-models`,B,Ge,V]}),gt=(0,j.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){et(e);try{let r=await ce.getGgufFiles(t,n);r.success&&r.data&&Qe(t=>({...t,[e]:r.data}))}catch(e){be.error(`Failed to load GGUF files:`,e)}finally{et(null)}}},[]),_t=(0,j.useCallback)(e=>{Ye===e?Xe(null):(Xe(e),Ze[e]||gt(e))},[Ye,Ze,gt]),vt=(0,j.useCallback)((t,n)=>{if(!i){g.error(e(`modelManager.pull.restricted`));return}if(!tt){H(t),U({status:`starting`});try{let e=D.pullModelStream(t,e=>{U(e)},()=>{U(null),H(null),W(null),g.success(`Downloaded ${n}`),Z()},e=>{U(null),H(null),W(null),g.error(`Failed to download: ${e}`)});W(()=>e)}catch{U(null),H(null),g.error(`Failed to start download`)}}},[i,tt,Z,e]),yt=(0,j.useCallback)(()=>{rt&&(rt(),W(null),H(null),U(null))},[rt]),bt=async(t,n)=>{if(!i){g.error(e(`modelManager.pull.restricted`));return}let r=t||m.trim(),a=n===`cloud`||!t&&l===`cloud`?Se(r):r;if(!a){g.error(e(`modelManager.pull.enterName`));return}t&&v(a),x(!0),C({status:`starting`});try{let t=D.pullModelStream(a,e=>{C(e)},()=>{C(null),x(!1),E(null),g.success(e(`modelManager.pull.success`,{name:a})),v(``),Z()},t=>{C(null),x(!1),E(null),g.error(e(`modelManager.pull.failed`)+`: `+t)});E(()=>t)}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.pull.failed`)+`: `+n),C(null),x(!1),E(null)}},xt=()=>{T&&(T(),E(null),x(!1),C(null),g.success(e(`modelManager.pull.cancelled`)))},St=async t=>{if(confirm(e(`modelManager.local.deleteConfirm`,{name:t})))try{await D.deleteModel(t),g.success(e(`modelManager.local.deleteSuccess`,{name:t})),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.local.deleteFailed`)+`: `+n)}},Ct=async t=>{_e(!0),pe(t),P(!0);try{let n=await D.showModel(t,!0);n.success&&n.data?se(n.data):g.error(e(`modelManager.modals.details.noDetails`))}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.modals.details.noDetails`)+`: `+n)}finally{_e(!1)}},wt=async()=>{if(!I.trim()||!R.trim()){g.error(e(`modelManager.modals.copy.enterBoth`));return}Te(!0);try{await D.copyModel(I.trim(),R.trim()),g.success(e(`modelManager.modals.copy.success`,{name:R})),F(!1),L(``),Ce(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.modals.copy.failed`)+`: `+n)}finally{Te(!1)}},Tt=async()=>{if(!z.trim()||!ke.trim()){g.error(e(`modelManager.modals.create.enterBoth`));return}Me(!0);try{await D.createModel({model:z.trim(),modelfile:ke.trim()}),g.success(e(`modelManager.modals.create.success`,{name:z})),De(!1),Oe(``),Ae(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.modals.create.failed`)+`: `+n)}finally{Me(!1)}},Et=async()=>{if(!Fe.trim()||!Le.trim()){g.error(e(`modelManager.modals.embeddings.enterBoth`));return}He(!0),Be(null);try{let t=await D.generateEmbeddings({model:Fe.trim(),input:Le.trim()});if(t.success&&t.data){let n=t.data.embeddings?.[0]||[];Be(n),g.success(e(`modelManager.modals.embeddings.success`,{count:n.length}))}}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.modals.embeddings.failed`)+`: `+n)}finally{He(!1)}},$=e=>{let t=e/(1024*1024*1024);return t>=1?`${t.toFixed(2)} GB`:`${(e/(1024*1024)).toFixed(1)} MB`},Dt=e=>Array.isArray(X)&&X.some(t=>t.name===e),Ot=()=>Y.reduce((e,t)=>e+t.size,0),kt=()=>X.reduce((e,t)=>e+(t.size_vram||0),0),At=e=>Y.some(t=>t.name===e||t.name.startsWith(e+`:`)),jt=(l===`cloud`?lt:Q).filter(e=>{let t=l===`all`||l===`cloud`||e.category===l,n=!d||e.name.toLowerCase().includes(d.toLowerCase())||e.description.toLowerCase().includes(d.toLowerCase());return t&&n}),Mt=[`all`,...new Set([...Q.map(e=>e.category),`cloud`])],Nt=(0,j.useMemo)(()=>Q.length>0?Q.slice(0,10).map(e=>({name:e.name,category:e.category,size:e.sizes?.[0]||``})):[{name:`deepseek-r1`,category:`reasoning`,size:`7B`},{name:`llama3.2`,category:`general`,size:`3B`},{name:`gemma3`,category:`general`,size:`4B`},{name:`qwen2.5`,category:`general`,size:`7B`},{name:`mistral`,category:`general`,size:`7B`},{name:`codellama`,category:`coding`,size:`7B`},{name:`nomic-embed-text`,category:`embedding`,size:`137M`},{name:`llava`,category:`vision`,size:`7B`},{name:`phi3`,category:`general`,size:`3.8B`},{name:`gemma2`,category:`general`,size:`9B`}],[Q]),Pt=N||ye||Ee||Ne;return at?(0,M.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-gray-600 dark:text-dark-600`,children:[(0,M.jsx)(h,{className:`h-5 w-5 animate-spin`}),e(`modelManager.loading`)]})}):(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(`div`,{className:O(`rounded-xl p-4 border`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`div`,{className:O(`w-2.5 h-2.5 rounded-full`,st?`bg-green-500`:`bg-red-500`)}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(st?`modelManager.systemStatus.online`:`modelManager.systemStatus.offline`)})]}),ot&&(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,M.jsx)(ee,{className:`h-4 w-4`}),(0,M.jsxs)(`span`,{children:[`v`,ot]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,M.jsx)(w,{className:`h-4 w-4`}),(0,M.jsxs)(`span`,{children:[Y.length,` `,Y.length===1?e(`modelManager.systemStatus.models`):e(`modelManager.systemStatus.models_plural`)]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,M.jsx)(p,{className:`h-4 w-4`}),(0,M.jsx)(`span`,{children:$(Ot())})]}),X.length>0&&(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,M.jsx)(s,{className:`h-4 w-4`}),(0,M.jsxs)(`span`,{children:[X.length,` `,e(`modelManager.systemStatus.running`),` (`,$(kt()),` `,e(`modelManager.systemStatus.vram`),`)`]})]})]}),(0,M.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,M.jsxs)(k,{onClick:Z,variant:`outline`,size:`sm`,className:O(`gap-1.5`,``,``),children:[(0,M.jsx)(h,{className:`h-3.5 w-3.5`}),e(`common.refresh`)]})})]})}),(0,M.jsx)(ve,{expanded:G.has(`pull`),modelName:m,setModelName:v,pulling:b,progress:S,canInstallModels:i,popularModels:Nt,onToggle:()=>K(`pull`),onPull:()=>bt(),onCancelPull:xt,formatSize:$}),(0,M.jsx)(ge,{expanded:G.has(`library`),models:jt,totalAvailable:Q.length,categories:Mt,filter:l,search:d,loading:ct||ut,pulling:b,canInstallModels:i,pullSectionExpanded:G.has(`pull`),setFilter:u,setSearch:f,isModelInstalled:At,normalizeCloudPullName:Se,onToggle:()=>K(`library`),onTogglePullSection:()=>K(`pull`),onPullModel:bt,onRefresh:dt}),(0,M.jsx)(de,{expanded:G.has(`huggingface`),models:pt,search:Ue,task:B,sort:V,loadingModels:mt,canInstallModels:i,expandedModelId:Ye,loadingGgufModelId:$e,ggufFiles:Ze,pullingModel:tt,pullProgress:nt,setSearch:We,setTask:qe,setSort:Je,onToggle:()=>K(`huggingface`),onToggleModel:_t,onPullGguf:vt,onCancelPull:yt,onRefresh:ht}),Array.isArray(X)&&X.length>0&&(0,M.jsxs)(`div`,{className:O(`rounded-xl p-4 border`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,M.jsx)(`div`,{className:O(`p-2 rounded-lg`,`bg-green-100 dark:bg-green-900/30`),children:(0,M.jsx)(s,{className:`h-5 w-5 text-green-600 dark:text-green-400`})}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.running`)}),(0,M.jsxs)(`span`,{className:O(`ml-auto px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[X.length,` `,e(`modelManager.systemStatus.running`)]})]}),(0,M.jsx)(`div`,{className:`space-y-2`,children:X.map(t=>(0,M.jsxs)(`div`,{className:O(`flex items-center justify-between p-4 rounded-lg border`,`bg-green-50 dark:bg-green-900/10`,`border-green-200 dark:border-green-800/50`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(`div`,{className:O(`w-2 h-2 rounded-full animate-pulse`,`bg-green-500`)}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`font-medium text-green-800 dark:text-green-400`,children:t.name}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-green-600 dark:text-green-500`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(c,{className:`h-3 w-3`}),e(`modelManager.systemStatus.vram`),`:`,` `,$(t.size_vram||0)]}),t.size&&(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,M.jsx)(w,{className:`h-3 w-3`}),e(`models.size`),`: `,$(t.size)]})]})]})]}),(0,M.jsxs)(`div`,{className:O(`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,M.jsx)(re,{className:`h-3 w-3`}),e(`modelManager.local.running`)]})]},t.name))})]}),(0,M.jsx)(me,{expanded:G.has(`local`),models:Y,onToggle:()=>K(`local`),isModelRunning:Dt,formatSize:$,onShowModel:Ct,onCopyModel:e=>{L(e),F(!0)},onDeleteModel:St}),(0,M.jsxs)(`div`,{className:O(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,M.jsxs)(`button`,{onClick:()=>K(`advanced`),className:O(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsx)(`div`,{className:O(`p-2 rounded-lg`,`bg-amber-100 dark:bg-amber-900/30`),children:(0,M.jsx)(oe,{className:`h-5 w-5 text-amber-600 dark:text-amber-400`})}),(0,M.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.advanced`)})]}),G.has(`advanced`)?(0,M.jsx)(y,{className:`h-5 w-5 text-gray-500`}):(0,M.jsx)(_,{className:`h-5 w-5 text-gray-500`})]}),G.has(`advanced`)&&(0,M.jsx)(`div`,{className:`p-4 pt-0`,children:(0,M.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,M.jsxs)(k,{onClick:()=>De(!0),variant:`outline`,className:O(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,M.jsx)(ne,{className:`h-5 w-5 text-purple-500`}),(0,M.jsxs)(`div`,{className:`text-left`,children:[(0,M.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.createModel`)}),(0,M.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.fromModelfile`)})]})]}),(0,M.jsxs)(k,{onClick:()=>F(!0),variant:`outline`,className:O(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,M.jsx)(ie,{className:`h-5 w-5 text-blue-500`}),(0,M.jsxs)(`div`,{className:`text-left`,children:[(0,M.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.copyModel`)}),(0,M.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.duplicateExisting`)})]})]}),(0,M.jsxs)(k,{onClick:()=>Pe(!0),variant:`outline`,className:O(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,M.jsx)(te,{className:`h-5 w-5 text-green-500`}),(0,M.jsxs)(`div`,{className:`text-left`,children:[(0,M.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.testEmbeddings`)}),(0,M.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.generateVectors`)})]})]}),(0,M.jsxs)(k,{onClick:async()=>{try{(await D.checkHealth()).success&&(await J(),g.success(e(`modelManager.advanced.healthy`)))}catch{await J(),g.error(e(`modelManager.systemStatus.offline`))}},variant:`outline`,className:O(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,M.jsx)(o,{className:`h-5 w-5 text-rose-500`}),(0,M.jsxs)(`div`,{className:`text-left`,children:[(0,M.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.healthCheck`)}),(0,M.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.testConnection`)})]})]})]})})]}),Pt&&(0,M.jsx)(j.Suspense,{fallback:null,children:(0,M.jsx)(xe,{models:Y,showDetailsModal:N,setShowDetailsModal:P,selectedModelName:fe,selectedModelDetails:ae,loadingDetails:he,showCopyModal:ye,setShowCopyModal:F,copySource:I,setCopySource:L,copyDestination:R,setCopyDestination:Ce,copying:we,handleCopyModel:wt,showCreateModal:Ee,setShowCreateModal:De,createModelName:z,setCreateModelName:Oe,createModelfile:ke,setCreateModelfile:Ae,creating:je,handleCreateModel:Tt,showEmbeddingsModal:Ne,setShowEmbeddingsModal:Pe,embeddingsModel:Fe,setEmbeddingsModel:Ie,embeddingsInput:Le,setEmbeddingsInput:Re,embeddingsResult:ze,generatingEmbeddings:Ve,handleGenerateEmbeddings:Et})})]})},L=()=>{let{t:e}=A();return(0,M.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,M.jsxs)(`div`,{className:`max-w-6xl mx-auto p-6`,children:[(0,M.jsxs)(`div`,{className:`text-center max-w-md mx-auto mb-8`,children:[(0,M.jsx)(`h2`,{className:`libre-brand text-4xl sm:text-5xl font-normal text-gray-900 dark:text-dark-800 mb-3`,style:{fontWeight:300,letterSpacing:0},children:e(`models.title`)}),(0,M.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 leading-relaxed`,children:e(`models.subtitle`)})]}),(0,M.jsx)(I,{})]})})};export{L as ModelsPage,L as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-fkbHPd-g.js";import{_ as r,a as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b}from"./syntax-highlight-D5wpTVgr.js";var x=e({OptimizedSyntaxHighlighter:()=>E,default:()=>E});n();var S=t(),C={js:`javascript`,ts:`typescript`,py:`python`,sh:`bash`,shell:`bash`,zsh:`bash`,terminal:`shell-session`,console:`shell-session`,html:`markup`,xml:`markup`,svg:`markup`,"c++":`cpp`},w={bash:r,c,cpp:l,css:f,diff:h,java:s,javascript:o,json:y,jsx:d,markdown:a,markup:_,python:m,"shell-session":i,tsx:u,typescript:g};Object.entries(w).forEach(([e,t])=>{b.registerLanguage(e,t)}),b.alias(`markup`,[`html`,`xml`,`svg`]);var T=new Set(Object.keys(w)),E=({children:e,language:t,isDark:n=!1,className:r=``})=>{let i=C[t.toLowerCase()]||t.toLowerCase();return T.has(i)?(0,S.jsx)(b,{language:i,style:n?p:v,className:r,customStyle:{margin:0,padding:`0.75rem`,borderRadius:`0.5rem`,fontSize:`0.875rem`},showLineNumbers:!1,children:e}):(0,S.jsx)(`pre`,{className:`bg-gray-100 dark:bg-dark-200 p-3 rounded-lg overflow-x-auto text-sm font-mono ${r}`,children:(0,S.jsx)(`code`,{className:``,children:e})})};export{x as n,E as t};
|