libre-webui 0.21.1 → 0.21.3
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/backend/dist/routes/documents.d.ts.map +1 -1
- package/backend/dist/routes/documents.js +2 -0
- package/backend/dist/routes/documents.js.map +1 -1
- package/backend/dist/services/ollamaService.d.ts +11 -1
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +101 -3
- package/backend/dist/services/ollamaService.js.map +1 -1
- package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
- package/backend/dist/services/titleGenerationService.js +14 -3
- package/backend/dist/services/titleGenerationService.js.map +1 -1
- package/backend/package.json +1 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/assets/index-BBpNbfKW.js +16 -0
- package/frontend/dist/assets/index-BLATyFmD.css +1 -0
- package/frontend/dist/index.html +41 -16
- package/frontend/dist/js/ArtifactContainer-Dy2Q0iIL.js +1 -0
- package/frontend/dist/js/{ArtifactDemoPage-DQBTKgzC.js → ArtifactDemoPage-K79dWshB.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-CpblpEf4.js → ArtifactSandboxFrame-DhqLNUtY.js} +2 -2
- package/frontend/dist/js/ArtifactSlideOutPanel-Cl8JG7bz.js +1 -0
- package/frontend/dist/js/{Button-X9TT9gTD.js → Button-CTXHujOd.js} +1 -1
- package/frontend/dist/js/ChatPage-BBayfMLS.js +16 -0
- package/frontend/dist/js/{FirstTimeSetup-C3ldEPmK.js → FirstTimeSetup-kHhRzGJ8.js} +1 -1
- package/frontend/dist/js/{GalleryPage-DrrOhli8.js → GalleryPage-By8VI39Q.js} +1 -1
- package/frontend/dist/js/HomePage-C1L8WAXL.js +1 -0
- package/frontend/dist/js/LibreClawPage-Dyua8IUu.js +1 -0
- package/frontend/dist/js/{ModelManagerModals-D-NxeVvV.js → ModelManagerModals-CuMRGUd-.js} +1 -1
- package/frontend/dist/js/ModelSelector-CqHc-Ln4.js +1 -0
- package/frontend/dist/js/ModelsPage-ODeXhDDk.js +2 -0
- package/frontend/dist/js/{NotesPage-D10aWpVj.js → NotesPage-CApzDjOq.js} +1 -1
- package/frontend/dist/js/{PersonasPage-BvCPzwx2.js → PersonasPage-D_6WBCH5.js} +2 -2
- package/frontend/dist/js/{PluginUsagePage-B9YgizW8.js → PluginUsagePage-kutS6SOd.js} +1 -1
- package/frontend/dist/js/{RichMessageContent-2L-mHp9Q.js → RichMessageContent-g6WT75Te.js} +1 -1
- package/frontend/dist/js/SettingsModal-B7z51BCx.js +1 -0
- package/frontend/dist/js/{SettingsToggle-bZ5W4CCf.js → SettingsToggle-DLHlCDBl.js} +1 -1
- package/frontend/dist/js/{SystemPage-CKnhy0Fr.js → SystemPage-BMWEet9e.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-B3gA_Zx8.js → UserManagementPage-D08lM51c.js} +1 -1
- package/frontend/dist/js/WorkPage-DdVLefsK.js +6 -0
- package/frontend/dist/js/{api-DjQINB7B.js → api-CLEmGcEh.js} +1 -1
- package/frontend/dist/js/{appStore-CIV0DhiE.js → appStore-CGdhvp9P.js} +2 -2
- package/frontend/dist/js/ar-BTmB2WVm.js +2 -0
- package/frontend/dist/js/{authStore-pmXfK_qt.js → authStore-Dh3beEOq.js} +3 -3
- package/frontend/dist/js/{bn-C7CHC42H.js → bn-CQnH7YVT.js} +2 -2
- package/frontend/dist/js/chatStore-CDeYWL_q.js +3 -0
- package/frontend/dist/js/{config-DF-g5uwS.js → config-DkV1ka7I.js} +1 -1
- package/frontend/dist/js/{cs-zGEtwQn_.js → cs-oTTZkQXr.js} +2 -2
- package/frontend/dist/js/{da-B-0sHNTu.js → da-Br0gB6J6.js} +2 -2
- package/frontend/dist/js/{de-UZNE6t2h.js → de-DE2iztTF.js} +2 -2
- package/frontend/dist/js/{es-CPLnFYIw.js → es-DgthfVtl.js} +2 -2
- package/frontend/dist/js/{estree-livw6QLA.js → estree-D5KP-qbw.js} +1 -1
- package/frontend/dist/js/{fr-Br1o0WVz.js → fr-BjxjFwPh.js} +2 -2
- package/frontend/dist/js/{hi-BcEvNEpb.js → hi-D1q7E-9N.js} +2 -2
- package/frontend/dist/js/{html-CWlKlrlk.js → html-Cm9c2akd.js} +1 -1
- package/frontend/dist/js/{id-C30L2DoT.js → id-CDJZqLTF.js} +2 -2
- package/frontend/dist/js/{is-BAEhfi5Z.js → is-BU7Um_Tq.js} +2 -2
- package/frontend/dist/js/{it-HWnfQXZY.js → it-CdAxr8P_.js} +2 -2
- package/frontend/dist/js/ja-BLbQwz9u.js +2 -0
- package/frontend/dist/js/{ko-agDQ__KP.js → ko-CY5lpkAe.js} +2 -2
- package/frontend/dist/js/{markdown-BM75gisb.js → markdown-B2u7CnKN.js} +1 -1
- package/frontend/dist/js/{messageCodeStyles-DxPb6SKm.js → messageCodeStyles-DalG2j6U.js} +2 -2
- package/frontend/dist/js/{ms-aNRa2QX7.js → ms-tQ8AYXEQ.js} +2 -2
- package/frontend/dist/js/{nl-BtkiDUn-.js → nl-CRNi2oWT.js} +2 -2
- package/frontend/dist/js/{pl-SEO0lBnX.js → pl-CWtFRS_W.js} +2 -2
- package/frontend/dist/js/{pt-BYtjmvq1.js → pt-C7SPoLF8.js} +2 -2
- package/frontend/dist/js/{ru-B-ynj2hU.js → ru-Dz4AX8xc.js} +2 -2
- package/frontend/dist/js/{standalone-h0KNQ5yy.js → standalone-Dwm1daef.js} +1 -1
- package/frontend/dist/js/{sv-CliKR15U.js → sv-ETy5-boa.js} +2 -2
- package/frontend/dist/js/{th-DJQyDr9J.js → th-DpuMqvxU.js} +2 -2
- package/frontend/dist/js/{tr-BBGKZ1la.js → tr-C-1AYAqg.js} +2 -2
- package/frontend/dist/js/{typescript-CPI0lY4n.js → typescript-CwieSptM.js} +1 -1
- package/frontend/dist/js/{ui-ovAoLjDQ.js → ui-BnDZpjfc.js} +2 -2
- package/frontend/dist/js/{uk-C1GcFWxE.js → uk-CyS680gr.js} +2 -2
- package/frontend/dist/js/useTranslation-CXY69qNk.js +1 -0
- package/frontend/dist/js/utils-BM0_0iFj.js +1 -0
- package/frontend/dist/js/{vi-CIxgICOQ.js → vi-BG8HuiTz.js} +2 -2
- package/frontend/dist/js/{workApi-CCHIEahA.js → workApi-BOS7crs9.js} +2 -2
- package/frontend/dist/js/{zh-Cm7vsQ9s.js → zh-NCs2mkHj.js} +2 -2
- package/package.json +3 -20
- package/electron/main.js +0 -560
- package/frontend/dist/assets/index-BN-WAt2j.js +0 -2
- package/frontend/dist/assets/index-D7m1zWWg.css +0 -1
- package/frontend/dist/js/ArtifactContainer-BD20LheX.js +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-BVgr8Cv6.js +0 -1
- package/frontend/dist/js/ChatPage-D2EWlzO4.js +0 -16
- package/frontend/dist/js/HomePage-D21Haon_.js +0 -1
- package/frontend/dist/js/LibreClawPage-CEf9ws8z.js +0 -1
- package/frontend/dist/js/ModelSelector-whWBlN-S.js +0 -1
- package/frontend/dist/js/ModelsPage-CL2t9qNT.js +0 -2
- package/frontend/dist/js/SettingsModal-BK05P_rU.js +0 -1
- package/frontend/dist/js/WorkPage-Bj3UVrmb.js +0 -5
- package/frontend/dist/js/ar-Bm27TCMQ.js +0 -2
- package/frontend/dist/js/chatStore-D76rdaV6.js +0 -2
- package/frontend/dist/js/i18n-DJTg6xWw.js +0 -2
- package/frontend/dist/js/ja-Dvux1mon.js +0 -2
- package/frontend/dist/js/useTranslation-CdeLZqSW.js +0 -1
- package/frontend/dist/js/utils-BhpNrGnR.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CXY69qNk.js";import{a as i,n as a,r as o,t as s}from"./utils-BM0_0iFj.js";import{a as c,d as l,f as u,h as d,l as f,n as p,o as m,p as h,r as g,t as _,u as v,v as y,y as b}from"./chatStore-CDeYWL_q.js";import{$ as x,Bt as S,Ct as C,E as w,En as T,F as E,Ft as D,I as O,P as ee,R as k,Sn as te,St as A,Tn as j,Tt as ne,Ut as M,V as N,Vt as re,Wt as ie,Y as ae,_n as P,bt as oe,d as se,f as ce,ft as F,gn as le,ht as ue,lt as de,m as fe,mt as pe,n as me,o as he,on as ge,pt as I,rn as _e,rt as ve,sn as L,x as ye,y as be,z as xe,zt as Se}from"./ui-vendor-xUzKqAXI.js";import{t as Ce}from"./logger-DSXjF4ye.js";import{a as we,b as R,c as Te,g as Ee,i as De,n as Oe,p as ke,r as Ae,s as z,v as je,x as Me}from"./api-CLEmGcEh.js";import{a as Ne,o as Pe,s as Fe,t as Ie}from"./imageGenModels-Dx_QMLJQ.js";import{c as Le,n as Re}from"./authStore-Dh3beEOq.js";import{a as ze,n as Be,o as Ve,t as He}from"./appStore-CGdhvp9P.js";import{l as Ue}from"./messageCodeStyles-DalG2j6U.js";import{t as B}from"./Button-CTXHujOd.js";import{d as V,f as We,p as Ge}from"./ui-BnDZpjfc.js";import{f as Ke,l as qe,m as Je,t as Ye,u as Xe}from"../assets/index-BBpNbfKW.js";import{t as H}from"./SettingsToggle-DLHlCDBl.js";var U=e(n(),1),W=t(),Ze=[{href:`https://github.com/libre-webui/libre-webui`,icon:ne,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:C,labelKey:`settings.about.links.gitlab`,descriptionKey:`settings.about.links.gitlabDescription`},{href:`https://librewebui.org`,icon:re,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:P,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://ollama.ai`,icon:le,labelKey:`settings.about.links.ollama`,descriptionKey:`settings.about.links.ollamaDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:ve,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],Qe=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function $e({appVersion:e}){let{t}=r();return(0,W.jsx)(`div`,{className:`space-y-6`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-4 flex items-center gap-2.5 text-gray-900 dark:text-gray-100`,children:[(0,W.jsx)(qe,{size:`md`,label:null}),(0,W.jsx)(Xe,{})]}),(0,W.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,W.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,W.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,W.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:Qe.map(e=>(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,W.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,W.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Ze.map(e=>{let n=e.icon;return(0,W.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 p-3 bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg hover:bg-gray-50 dark:hover:bg-dark-200 hover:border-gray-300 dark:hover:border-dark-400 transition-all duration-200 group`,children:[(0,W.jsx)(n,{className:`h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,W.jsx)(re,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.href)})})]}),(0,W.jsx)(`div`,{className:`mt-6 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-gray-500 dark:text-gray-400`,children:[e.includes(`-dev`)?(0,W.jsx)(`span`,{children:t(`settings.about.version`,{version:e})}):(0,W.jsx)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${e}`,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:t(`settings.about.version`,{version:e})}),(0,W.jsxs)(`span`,{children:[t(`settings.about.openSourceBy`,{company:``}),(0,W.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:`Kroonen AI`})]})]})})]})})}var et=Ce(`components:background-upload`),tt=({className:e=``})=>{let{t}=r(),{preferences:n,setPreferences:i,backgroundImage:a,uploadBackgroundImage:o,removeBackgroundImage:s}=He(),c=(0,U.useRef)(null),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(!1),p=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},m=async e=>{if(!e.type.startsWith(`image/`)){T.error(`Please select a valid image file`);return}if(e.size>5242880){T.error(`Image file size must be less than 5MB`);return}u(!0);try{await o(e),T.success(`Background image uploaded successfully`)}catch(e){et.error(`Failed to upload background:`,e),T.error(`Failed to upload background image`)}finally{u(!1)}},h=e=>{let t=e.target.files?.[0];t&&m(t)},g=e=>{e.preventDefault(),f(!0)},_=e=>{e.preventDefault(),f(!1)},v=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files?.[0];t&&m(t)},y=()=>{s(),T.success(`Background image removed`)},b=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,enabled:e};if(i({backgroundSettings:n}),t||!e)try{await z.updatePreferences({backgroundSettings:n})}catch(e){et.error(`Failed to update preferences:`,e)}},x=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,blurAmount:e};if(i({backgroundSettings:n}),t)try{await z.updatePreferences({backgroundSettings:n})}catch(e){et.error(`Failed to update preferences:`,e)}},S=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,opacity:e};if(i({backgroundSettings:n}),t)try{await z.updatePreferences({backgroundSettings:n})}catch(e){et.error(`Failed to update preferences:`,e)}};return(0,W.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,W.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,W.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:p.enabled,onChange:e=>b(e.target.checked)}),(0,W.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,W.jsx)(`div`,{className:`relative`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,W.jsx)(`div`,{className:`flex-shrink-0`,children:(0,W.jsx)(`img`,{src:a,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,W.jsx)(B,{variant:`ghost`,size:`sm`,onClick:y,className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,W.jsx)(me,{className:`h-4 w-4`})})]})}):(0,W.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${d?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:g,onDragLeave:_,onDrop:v,onClick:()=>c.current?.click(),children:[(0,W.jsx)(ue,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,W.jsxs)(B,{variant:`outline`,size:`sm`,disabled:l,className:`mx-auto`,children:[(0,W.jsx)(se,{className:`h-4 w-4 me-2`}),t(l?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,W.jsx)(`input`,{ref:c,type:`file`,accept:`image/*`,onChange:h,className:`hidden`})]}),a&&(0,W.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.blur`),`:`,` `,p.blurAmount,`px`]}),(0,W.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:p.blurAmount,onChange:e=>x(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.opacity`),`:`,` `,Math.round(p.opacity*100),`%`]}),(0,W.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.1`,value:p.opacity,onChange:e=>S(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]})]})]})})},nt=()=>{let{t:e,i18n:t}=r();return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(A,{className:`h-4 w-4 text-gray-500 dark:text-gray-400`}),(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.appearance.language.title`)})]}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.appearance.language.description`)}),(0,W.jsx)(`select`,{"data-testid":`language-switcher-select`,value:y(t.language),onChange:e=>{let t=e.target.value;d(t)},className:`w-full px-3 py-2 text-sm border border-gray-200 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-primary-500`,children:b.map(e=>(0,W.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))})]})};function rt({theme:e,preferences:t,onThemeChange:n,onAccentChange:i,onCustomAccentChange:a,onAdaptToAccentChange:o,onShowUsernameChange:s,onShowFollowUpsChange:c,onHapticFeedbackChange:l}){let{t:u}=r(),d=e.accent||`blue`,f=e.customAccent||`#2563eb`,p=ze(e);return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsx)(nt,{}),(0,W.jsx)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.appearance.title`)})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(`button`,{onClick:()=>n(`light`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`light`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,W.jsx)(be,{className:`h-4 w-4`}),u(`settings.appearance.theme.light`)]}),(0,W.jsxs)(`button`,{onClick:()=>n(`dark`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`dark`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,W.jsx)(x,{className:`h-4 w-4`}),u(`settings.appearance.theme.dark`)]})]}),(0,W.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-3`,children:[(0,W.jsx)(`div`,{children:(0,W.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:u(`settings.appearance.accent.title`,{defaultValue:`Accent color`})})}),(0,W.jsx)(`div`,{className:`h-9 w-9 rounded-full border border-gray-200 dark:border-dark-400 shadow-inner flex-shrink-0`,style:{backgroundColor:p},"aria-hidden":`true`})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-5 xs:grid-cols-6 sm:grid-cols-9 gap-2`,children:[Be.map(e=>{let t=d===e.id;return(0,W.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),className:`relative h-10 rounded-xl border transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${t?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,style:{backgroundColor:e.color},"aria-label":u(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,W.jsx)(L,{className:`absolute inset-0 m-auto h-4 w-4 drop-shadow`,style:{color:e.foreground}})},e.id)}),(0,W.jsxs)(`label`,{className:`relative h-10 rounded-xl border transition-all duration-200 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-500 focus-within:ring-offset-2 dark:focus-within:ring-offset-dark-50 overflow-hidden cursor-pointer ${d===`custom`?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,title:u(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":u(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,W.jsx)(`input`,{type:`color`,value:f,onInput:e=>a(e.currentTarget.value),onChange:e=>a(e.target.value),className:`absolute inset-0 h-full w-full cursor-pointer opacity-0`}),(0,W.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:f},"aria-hidden":`true`}),(0,W.jsx)(ae,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 border-t border-gray-200 pt-5 dark:border-dark-300`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:u(`settings.appearance.accent.behaviorTitle`)}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.behaviorDescription`)}),(0,W.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":!e.adaptToAccent,onClick:()=>o(!1),className:`rounded-xl border p-3 text-start transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${e.adaptToAccent?`border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-100 dark:hover:border-dark-400 dark:hover:bg-dark-200`:`border-primary-500 bg-primary-50/70 shadow-sm dark:border-primary-400 dark:bg-primary-950/25`}`,children:[(0,W.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:u(`settings.appearance.accent.defaultStyle`)}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e.adaptToAccent===!0,onClick:()=>o(!0),className:`rounded-xl border p-3 text-start transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${e.adaptToAccent?`border-primary-500 bg-primary-50/70 shadow-sm dark:border-primary-400 dark:bg-primary-950/25`:`border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-100 dark:hover:border-dark-400 dark:hover:bg-dark-200`}`,children:[(0,W.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:u(`settings.appearance.accent.adaptedStyle`)}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:u(`settings.appearance.chatInterface.title`)}),(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.showUsername`)}),(0,W.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.showUsernameDescription`)})]}),(0,W.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showUsername,onChange:e=>s(e.target.checked)}),(0,W.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.followUpSuggestions`)}),(0,W.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.followUpSuggestionsDescription`)})]}),(0,W.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showFollowUpSuggestions!==!1,onChange:e=>c(e.target.checked)}),(0,W.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`})}),(0,W.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.hapticFeedbackDescription`,{defaultValue:`Use subtle vibration for important mobile actions`})})]}),(0,W.jsxs)(`label`,{className:`relative inline-flex shrink-0 cursor-pointer items-center`,children:[(0,W.jsx)(`input`,{type:`checkbox`,"data-testid":`haptic-feedback-toggle`,"aria-label":u(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),className:`peer sr-only`,checked:t.hapticFeedbackEnabled===!0,onChange:e=>l(e.target.checked)}),(0,W.jsx)(`div`,{className:`peer h-6 w-11 rounded-full bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 peer-checked:bg-primary-600 after:absolute after:start-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:content-[''] after:transition-all peer-checked:after:translate-x-full peer-checked:after:border-white dark:border-gray-600 dark:bg-gray-700 dark:peer-focus:ring-primary-800 rtl:peer-checked:after:-translate-x-full`})]})]})]})]}),(0,W.jsx)(tt,{})]})}function it(){let{t:e,i18n:t}=r(),{sessions:n,setSessionArchived:i,deleteSession:a}=_(),s=n.filter(e=>e.archived);return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:e(`settings.data.archivedChats.title`)}),s.length===0?(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.data.archivedChats.empty`)}):(0,W.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:s.map(n=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,W.jsx)(`p`,{className:`text-[11px] tabular-nums text-gray-400 dark:text-dark-500`,children:o(n.updatedAt,t.language)})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsxs)(B,{variant:`ghost`,size:`sm`,onClick:()=>i(n.id,!1),className:`h-8 gap-1.5 px-2 text-xs`,title:e(`settings.data.archivedChats.unarchive`),children:[(0,W.jsx)(te,{className:`h-3.5 w-3.5`}),e(`settings.data.archivedChats.unarchive`)]}),(0,W.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>{window.confirm(e(`chat.session.deleteConfirm`))&&a(n.id)},className:`h-8 w-8 p-0 text-red-500 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20`,title:e(`chat.session.deleteChat`),children:(0,W.jsx)(fe,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function at({sessionCount:e,loading:t,importing:n,showImportOptions:i,mergeStrategy:a,importResult:o,importFileInputRef:s,onExportData:c,onImportFileSelect:l,onClearAllHistory:u,onMergeStrategyChange:d,onConfirmImport:f,onCancelImport:p,onDismissImportResult:m}){let{t:h}=r();return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.data.title`)}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.export`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.exportDescription`)}),(0,W.jsx)(B,{onClick:c,variant:`outline`,size:`sm`,className:`w-full`,children:h(`settings.data.exportAll`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.import`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.importDescription`)}),(0,W.jsx)(`input`,{ref:s,type:`file`,accept:`.json`,onChange:l,className:`hidden`}),(0,W.jsx)(B,{onClick:()=>s.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-col`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.clearSessions`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.clearSessionsDescription`)}),(0,W.jsx)(B,{onClick:u,variant:`outline`,size:`sm`,className:`w-full text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border-red-200 hover:border-red-300 dark:border-red-800 dark:hover:border-red-700`,disabled:e===0||t,children:t?h(`settings.data.clearing`):h(`settings.data.clearAll`,{count:e})})]})]}),i&&(0,W.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,W.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:h(`settings.data.importOptions`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:h(`settings.data.importOptionsDescription`)}),(0,W.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:a===`skip`,onChange:e=>d(e.target.value),className:`me-2`}),(0,W.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.skipDuplicates`)})]}),(0,W.jsxs)(`label`,{className:`flex items-center`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:a===`overwrite`,onChange:e=>d(e.target.value),className:`me-2`}),(0,W.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.overwrite`)})]})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(B,{onClick:f,size:`sm`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.import`)}),(0,W.jsx)(B,{onClick:p,variant:`outline`,size:`sm`,children:h(`common.cancel`)})]})]}),o&&(0,W.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,W.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:h(`settings.data.importResults`)}),(0,W.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,W.jsxs)(`div`,{children:[h(`settings.data.preferences`),`:`,` `,o.preferences.imported?h(`settings.data.imported`):h(`settings.data.failed`)]}),(0,W.jsxs)(`div`,{children:[h(`settings.data.sessions`),`:`,` `,o.sessions.imported,` `,h(`settings.data.importedLabel`),`,`,o.sessions.skipped,` `,h(`settings.data.skipped`)]}),(0,W.jsxs)(`div`,{children:[h(`settings.data.documents`),`:`,` `,o.documents.imported,` `,h(`settings.data.importedLabel`),`,`,` `,o.documents.skipped,` `,h(`settings.data.skipped`)]}),(o.sessions.errors.length>0||o.documents.errors.length>0)&&(0,W.jsxs)(`div`,{className:`mt-2`,children:[(0,W.jsxs)(`p`,{className:`font-medium`,children:[h(`settings.data.errors`),`:`]}),o.sessions.errors.map((e,t)=>(0,W.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`session-${t}`)),o.documents.errors.map((e,t)=>(0,W.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`document-${t}`))]})]}),(0,W.jsx)(B,{onClick:m,variant:`outline`,size:`sm`,className:`mt-2`,children:h(`common.close`)})]})]})]}),(0,W.jsx)(it,{})]})}function ot({settings:e,effectiveSettings:t,modelOptions:n,status:i,regenerating:a,onSettingChange:o,onReset:s,onRegenerate:c,onSave:l}){let{t:u}=r();return(0,W.jsx)(`div`,{className:`space-y-6`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.documents.title`)}),(0,W.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 p-4 rounded-lg border border-gray-200 dark:border-dark-300 space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u(`settings.documents.embeddings.title`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:u(`settings.documents.embeddings.enable`)})]}),(0,W.jsx)(H,{checked:e.enabled,onChange:e=>o(`enabled`,e)})]}),e.enabled&&(0,W.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:u(`settings.documents.embeddings.model`)}),(0,W.jsx)(V,{value:t.model,onChange:e=>o(`model`,e.target.value),options:n}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:u(`settings.documents.embeddings.modelDescription`)})]}),(0,W.jsx)(ct,{label:u(`settings.documents.embeddings.chunkSize`),value:e.chunkSize,min:500,max:2e3,step:100,description:u(`settings.documents.embeddings.chunkSizeDescription`),onChange:e=>o(`chunkSize`,e)}),(0,W.jsx)(ct,{label:u(`settings.documents.embeddings.chunkOverlap`),value:e.chunkOverlap,min:50,max:500,step:50,description:u(`settings.documents.embeddings.chunkOverlapDescription`),onChange:e=>o(`chunkOverlap`,e)}),(0,W.jsx)(ct,{label:u(`settings.documents.embeddings.similarityThreshold`),value:e.similarityThreshold,min:.3,max:.9,step:.05,description:u(`settings.documents.embeddings.similarityDescription`),format:e=>e.toFixed(2),onChange:e=>o(`similarityThreshold`,e)})]})]}),i&&(0,W.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:u(`settings.documents.embeddings.status`)}),(0,W.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,W.jsxs)(`div`,{children:[u(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,W.jsx)(`span`,{className:i.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:i.available?u(`settings.documents.embeddings.available`):u(`settings.documents.embeddings.unavailable`)})]}),(0,W.jsxs)(`div`,{children:[u(`settings.documents.embeddings.model`),`:`,` `,(0,W.jsx)(`span`,{className:`font-medium`,children:i.model})]}),(0,W.jsxs)(`div`,{children:[u(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,W.jsxs)(`span`,{className:`font-medium`,children:[i.chunksWithEmbeddings,` / `,i.totalChunks]})]}),i.totalChunks>0&&(0,W.jsxs)(`div`,{children:[u(`settings.documents.embeddings.coverage`),`:`,` `,(0,W.jsxs)(`span`,{className:`font-medium`,children:[Math.round(i.chunksWithEmbeddings/i.totalChunks*100),`%`]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(B,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,W.jsx)(O,{size:16}),u(`settings.generation.resetDefaults`)]}),e.enabled&&i&&i.totalChunks>0&&(0,W.jsxs)(B,{onClick:c,disabled:a,variant:`outline`,className:`flex items-center gap-2 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20`,children:[(0,W.jsx)(ie,{size:16}),u(a?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,W.jsxs)(B,{onClick:l,className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{size:16}),u(`settings.saveSettings`)]})]}),(0,W.jsx)(st,{})]})})}function st(){let{t:e}=r(),t=Je(),[n,i]=(0,U.useState)(``),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(null),{data:u}=Ke({queryKey:[`knowledge-collections`],queryFn:async()=>{let[e,t]=await Promise.all([R.getCollections(),R.getDocuments()]);return{collections:e.success&&e.data?e.data:[],documents:t.success&&t.data?t.data:[]}}}),{collections:d=[],documents:f=[]}=u??{},p=()=>t.invalidateQueries({queryKey:[`knowledge-collections`]}),m=async()=>{let t=n.trim();if(t){i(``);try{let e=await R.createCollection(t);if(!e.success)throw Error(e.error);await p()}catch{j.error(e(`settings.documents.collections.createFailed`))}}},h=async t=>{s(null);try{let e=await R.deleteCollection(t);if(!e.success)throw Error(e.error);await p()}catch{j.error(e(`settings.documents.collections.deleteFailed`))}},g=async t=>{l(null);try{let e=await R.deleteDocument(t);if(!e.success)throw Error(e.error);window.dispatchEvent(new Event(`libre:documents-updated`)),await p()}catch{j.error(e(`settings.documents.library.deleteFailed`))}},_=async(t,n)=>{try{let e=await R.setDocumentCollection(t,n);if(!e.success)throw Error(e.error);await p()}catch{j.error(e(`settings.documents.collections.assignFailed`))}};return(0,W.jsxs)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.collections.title`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.collections.description`)}),(0,W.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,W.jsx)(`input`,{value:n,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m()},placeholder:e(`settings.documents.collections.namePlaceholder`),className:`flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-900`}),(0,W.jsx)(B,{size:`sm`,onClick:()=>void m(),disabled:!n.trim(),children:e(`settings.documents.collections.create`)})]}),d.length>0&&(0,W.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:d.map(t=>o===t.id?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-red-200 bg-red-50 px-2.5 py-1 text-xs text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300`,children:[e(`settings.documents.collections.deleteConfirm`),(0,W.jsx)(`button`,{onClick:()=>void h(t.id),className:`font-medium underline decoration-red-400 underline-offset-2 hover:text-red-800 dark:hover:text-red-200`,children:e(`common.delete`)}),(0,W.jsx)(`button`,{onClick:()=>s(null),className:`text-red-400 hover:text-red-600 dark:hover:text-red-300`,title:e(`common.cancel`),children:(0,W.jsx)(me,{className:`h-3 w-3`})})]},t.id):(0,W.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-200 dark:text-dark-800`,children:[(0,W.jsx)(P,{className:`h-3 w-3`}),t.name,(0,W.jsx)(`span`,{className:`tabular-nums text-gray-400 dark:text-dark-500`,children:t.documentCount??0}),(0,W.jsx)(`button`,{onClick:()=>s(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,W.jsx)(me,{className:`h-3 w-3`})})]},t.id))}),(0,W.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.library.title`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.library.description`)}),f.length===0?(0,W.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.documents.library.empty`)}):(0,W.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:f.map(t=>(0,W.jsx)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:c===t.id?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-red-700 dark:text-red-300`,children:e(`settings.documents.library.deleteConfirm`,{name:t.filename})}),(0,W.jsx)(B,{size:`sm`,variant:`outline`,className:`text-red-600 border-red-200 hover:bg-red-50 dark:text-red-400 dark:border-red-800 dark:hover:bg-red-900/20`,onClick:()=>void g(t.id),children:e(`common.delete`)}),(0,W.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>l(null),children:e(`common.cancel`)})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(D,{className:`h-4 w-4 shrink-0 text-gray-400 dark:text-dark-500`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-dark-900`,children:t.filename}),(0,W.jsxs)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:[a(t.size),` · `,t.sessionId?e(`settings.documents.library.chatScope`):e(`settings.documents.library.everyChatScope`)]})]}),d.length>0&&(0,W.jsxs)(`select`,{value:t.collectionId??``,onChange:e=>void _(t.id,e.target.value||null),className:`rounded-lg border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,W.jsx)(`option`,{value:``,children:e(`settings.documents.collections.none`)}),d.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,W.jsx)(`button`,{onClick:()=>l(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,W.jsx)(fe,{className:`h-4 w-4`})})]})},t.id))})]})}function ct({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,W.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full range-slider`}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function lt({generationOptions:e,generationScope:t,scopedModel:n,onGenerationScopeChange:i,embeddingSettings:a,effectiveEmbeddingSettings:o,embeddingModelOptions:c,embeddingStatus:l,onGenerationOptionChange:u,onEmbeddingSettingsChange:d,onResetGenerationOptions:f,onSaveGenerationOptions:p,onResetEmbeddingSettings:m,onSaveEmbeddingSettings:h}){let{t:g}=r(),[_,v]=(0,U.useState)(!1),y=(0,U.useId)(),b=(0,U.useId)(),x=[{value:`global`,label:g(`settings.generation.scopeAll`)},...n?[{value:`model`,label:g(`settings.generation.scopeModel`,{model:n})}]:[]];return(0,W.jsx)(`div`,{className:`space-y-6`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:g(`settings.generation.title`)}),(0,W.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:g(`settings.generation.description`)}),(0,W.jsxs)(`div`,{className:`mb-6 rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,children:[(0,W.jsx)(`label`,{htmlFor:b,className:`mb-2 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.generation.scopeLabel`)}),(0,W.jsx)(V,{id:b,value:t,onChange:e=>i(e.target.value),options:x}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:g(t===`model`?`settings.generation.scopeModelHint`:`settings.generation.scopeAllHint`)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":_,"aria-controls":y,onClick:()=>v(e=>!e),className:`flex w-full items-center justify-between gap-4 p-4 text-left`,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.generation.advancedSettings`)}),(0,W.jsx)(`span`,{className:`mt-1 block text-xs text-gray-500 dark:text-gray-400`,children:g(`settings.generation.advancedSettingsDescription`)})]}),(0,W.jsx)(ge,{className:s(`h-4 w-4 flex-shrink-0 text-gray-500 transition-transform`,_&&`rotate-180`)})]}),_&&(0,W.jsxs)(`div`,{id:y,className:`space-y-6 border-t border-gray-200 p-4 dark:border-dark-300`,children:[(0,W.jsxs)(ut,{title:g(`settings.generation.coreParameters`),children:[(0,W.jsx)(G,{label:g(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:g(`settings.generation.temperatureDescription`),onChange:e=>u(`temperature`,e)}),(0,W.jsx)(G,{label:g(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:g(`settings.generation.topPDescription`),onChange:e=>u(`top_p`,e)}),(0,W.jsx)(G,{label:g(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:g(`settings.generation.topKDescription`),onChange:e=>u(`top_k`,e)}),(0,W.jsx)(G,{label:g(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:g(`settings.generation.minPDescription`),onChange:e=>u(`min_p`,e)})]}),(0,W.jsxs)(ut,{title:g(`settings.generation.generationControl`),children:[(0,W.jsx)(G,{label:g(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:g(`settings.generation.maxTokensDescription`),onChange:e=>u(`num_predict`,e)}),(0,W.jsx)(G,{label:g(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:g(`settings.generation.repeatPenaltyDescription`),onChange:e=>u(`repeat_penalty`,e)}),(0,W.jsx)(G,{label:g(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:g(`settings.generation.contextLengthDescription`),onChange:e=>u(`num_ctx`,e)}),(0,W.jsx)(G,{label:g(`settings.generation.seed`),hint:`(${g(`settings.generation.optional`)})`,value:e.seed,placeholder:g(`settings.generation.random`),integer:!0,description:g(`settings.generation.seedDescription`),onChange:e=>u(`seed`,e)})]}),(0,W.jsxs)(ut,{title:g(`settings.generation.advancedOptions`),children:[(0,W.jsx)(G,{label:g(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:g(`settings.generation.presencePenaltyDescription`),onChange:e=>u(`presence_penalty`,e)}),(0,W.jsx)(G,{label:g(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:g(`settings.generation.frequencyPenaltyDescription`),onChange:e=>u(`frequency_penalty`,e)}),(0,W.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,W.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[g(`settings.generation.stopSequences`),(0,W.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,g(`settings.generation.commaSeparated`),`)`]})]}),(0,W.jsx)(`input`,{type:`text`,value:e.stop?.join(`, `)??``,onChange:e=>u(`stop`,e.target.value?e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,placeholder:`\\\\n, ###, STOP`}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.generation.stopSequencesDescription`)})]})]}),(0,W.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,W.jsxs)(B,{onClick:f,variant:`outline`,className:`flex items-center gap-2`,children:[(0,W.jsx)(O,{size:16}),g(`settings.generation.resetDefaults`)]}),(0,W.jsxs)(B,{onClick:p,className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{size:16}),g(`settings.generation.saveOptions`)]})]})]})]}),(0,W.jsx)(`div`,{className:`mt-6`,children:(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:g(`settings.generation.embeddingSettings`)}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:g(`settings.generation.enableEmbeddings`)}),(0,W.jsx)(H,{checked:a.enabled,onChange:e=>d(`enabled`,e)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.documents.embeddings.model`)}),(0,W.jsx)(V,{value:o.model,onChange:e=>d(`model`,e.target.value),options:c,disabled:!a.enabled})]}),(0,W.jsx)(dt,{label:g(`settings.documents.embeddings.chunkSize`),hint:g(`settings.documents.embeddings.chunkSizeInTokens`),value:a.chunkSize,min:1,disabled:!a.enabled,onChange:e=>d(`chunkSize`,e)}),(0,W.jsx)(dt,{label:g(`settings.documents.embeddings.chunkOverlap`),hint:g(`settings.documents.embeddings.chunkOverlapInTokens`),value:a.chunkOverlap,min:0,disabled:!a.enabled,onChange:e=>d(`chunkOverlap`,e)}),(0,W.jsx)(dt,{label:g(`settings.documents.embeddings.similarityThreshold`),value:a.similarityThreshold,min:0,max:1,step:.01,disabled:!a.enabled,onChange:e=>d(`similarityThreshold`,e)})]}),l&&(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[g(`settings.documents.embeddings.status`),`:`]}),(0,W.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:l.available?g(`settings.documents.embeddings.available`):g(`settings.documents.embeddings.unavailable`)})]}),l.available&&(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,W.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[g(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,W.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[l.chunksWithEmbeddings,` /`,` `,l.totalChunks]})]})]}),(0,W.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,W.jsxs)(B,{onClick:m,variant:`outline`,className:`flex items-center gap-2`,children:[(0,W.jsx)(O,{size:16}),g(`settings.generation.resetDefaults`)]}),(0,W.jsxs)(B,{onClick:h,className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{size:16}),g(`settings.saveSettings`)]})]})]})})]})})}function ut({title:e,children:t}){return(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function G({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,W.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,W.jsx)(`input`,{type:`number`,min:a,max:o,step:s,value:t??``,placeholder:n,onChange:e=>l(e.target.value?c?parseInt(e.target.value):parseFloat(e.target.value):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function dt({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,W.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,W.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,disabled:o})]})}function ft({loading:e,settings:t,effectiveSettings:n,models:i,plugins:a,sizes:o,qualities:s,styles:c,onSettingChange:l,onModelChange:u,onReset:d,onSave:f}){let{t:p}=r(),m=Ie(i,n.model,n.pluginId);return(0,W.jsx)(`div`,{className:`space-y-6`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.title`)}),(0,W.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.imageGen.description`)}),e?(0,W.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,W.jsx)(de,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,W.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:p(`settings.imageGen.loadingProviders`)})]}):i.length===0?(0,W.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(ue,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:p(`settings.imageGen.noProviders`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:p(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.imageGen.enable`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.imageGen.enableDescription`)})]}),(0,W.jsx)(H,{checked:t.enabled,onChange:e=>l(`enabled`,e)})]})}),(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.configuration`)}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.model`)}),(0,W.jsx)(V,{value:m?Ne(m):``,onChange:e=>{let t=i.find(t=>Ne(t)===e.target.value);t&&u(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:p(`settings.model.selectModel`)},...i.map(e=>({value:Ne(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.modelDescription`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m?.config?.size_label||p(`settings.imageGen.size`)}),(0,W.jsx)(V,{value:n.size,onChange:e=>l(`size`,e.target.value),disabled:!t.enabled||o.length===0,options:[...o.length>0?o.map(e=>({value:e,label:e})):[{value:`1024x1024`,label:`1024x1024`},{value:`1792x1024`,label:`1792x1024`},{value:`1024x1792`,label:`1024x1792`}]]}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.sizeDescription`)})]}),s.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.quality`)}),(0,W.jsx)(V,{value:n.quality,onChange:e=>l(`quality`,e.target.value),disabled:!t.enabled,options:s.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.qualityDescription`)})]}),c.length>0&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.style`)}),(0,W.jsx)(V,{value:n.style,onChange:e=>l(`style`,e.target.value),disabled:!t.enabled,options:c.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.styleDescription`)})]})]})]}),a.length>0&&(0,W.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.imageGen.availableProviders`)}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,W.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,W.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,p(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,W.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,W.jsxs)(B,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,W.jsx)(O,{size:16}),p(`common.reset`)]}),(0,W.jsxs)(B,{onClick:f,className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{size:16}),p(`settings.saveSettings`)]})]})]})]})})}function pt({models:e,selectedModel:t,selectedProviderType:n,selectedProviderId:i,systemMessage:a,tempSystemMessage:o,loading:s,preferences:l,currentVisionModel:u,visionModelOptions:d,currentTaskModel:h,autoTitleTaskModelOptions:g,updatingAllModels:_,updateProgress:v,onModelChange:y,onSystemMessageChange:b,onSystemMessageSave:x,onAutoTitleChange:S,onAutoTitleTaskModelChange:C,onVisionModelChange:w,onUpdateAllModels:T}){let{t:E}=r(),D={model:t,providerType:n,providerId:i},O=f(e,D),ee=t?c(O,D):``,k=m(O,D);return(0,W.jsx)(`div`,{className:`space-y-6`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:E(`settings.model.title`)}),(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.defaultModel`)}),(0,W.jsx)(V,{value:ee,onChange:y,options:[{value:``,label:E(`settings.model.selectModel`)},...O.map(e=>({value:p(e),label:e.isLegacySelection?`${e.name} (provider not recorded${e.isUnavailable?`, unavailable`:``})`:e.isPersona?`${e.personaName} (${E(`settings.model.persona`)})`:e.isPlugin?`${e.name} (${e.pluginName||e.pluginId}${e.isUnavailable?`, unavailable`:``})`:`${e.name} (Ollama${e.isUnavailable?`, unavailable`:``})`}))]}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.defaultModelDescription`)})]}),t&&(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.currentModelInfo`)}),(0,W.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,W.jsx)(mt,{label:`${E(`settings.model.name`)}:`,value:t,truncate:!0}),k?.details&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(mt,{label:`${E(`settings.model.size`)}:`,value:k.details.parameter_size}),(0,W.jsx)(mt,{label:`${E(`settings.model.family`)}:`,value:k.details.family}),(0,W.jsx)(mt,{label:`${E(`settings.model.format`)}:`,value:k.details.format})]})]})})]}),(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.systemMessage.title`)}),(0,W.jsx)(We,{value:o,onChange:b,placeholder:E(`settings.systemMessage.placeholder`),className:`w-full min-h-[100px] bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,rows:4}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:E(`settings.systemMessage.description`)}),(0,W.jsx)(B,{onClick:x,size:`sm`,disabled:s||o===a,children:E(`common.save`)})]})]})]}),(0,W.jsx)(`div`,{className:`mt-6`,children:(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.specializedModels`,{defaultValue:`Specialized Models`})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 lg:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.visionModel`,{defaultValue:`Vision Model`})}),(0,W.jsx)(V,{"data-testid":`vision-model-select`,value:u,onChange:e=>w(e.target.value),options:d}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.visionModelDescription`,{defaultValue:`Used automatically whenever the outgoing chat context contains images. Choose a model that supports image input.`})})]}),(0,W.jsxs)(`div`,{className:`lg:border-s lg:border-gray-200 lg:ps-5 dark:lg:border-dark-300`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:E(`settings.model.autoTitle.enable`)}),(0,W.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:E(`settings.model.autoTitle.enableDescription`)})]}),(0,W.jsx)(H,{checked:l.titleSettings?.autoTitle||!1,onChange:S})]}),l.titleSettings?.autoTitle&&(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.autoTitle.taskModel`)}),(0,W.jsx)(V,{value:h,onChange:e=>C(e.target.value),options:g}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.autoTitle.taskModelDescription`)})]})]})]})]})}),(0,W.jsx)(`div`,{className:`mt-6`,children:(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.bulkOperations`)}),(0,W.jsx)(`div`,{className:`space-y-3`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.updateAll`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:E(`settings.model.updateAllDescription`)}),_&&v&&(0,W.jsx)(ht,{progress:v}),(0,W.jsx)(B,{onClick:T,variant:`outline`,size:`sm`,className:`w-full`,disabled:_||s||e.length===0,children:_?E(`settings.model.updating`):E(`settings.model.updateAllButton`,{count:e.length})})]})})]})})]})})}function mt({label:e,value:t,truncate:n=!1}){return(0,W.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-white dark:bg-dark-100 rounded-md border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,W.jsx)(`span`,{className:n?`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ms-2`:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t})]})}function ht({progress:e}){let{t}=r(),n=Math.round(e.current/e.total*100);return(0,W.jsxs)(`div`,{className:`mb-4 space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,W.jsx)(`span`,{className:`text-gray-600 dark:text-dark-600 font-medium`,children:t(`settings.model.updatingModel`,{name:e.modelName,current:e.current,total:e.total})}),(0,W.jsxs)(`span`,{className:`text-primary-600 dark:text-primary-400 font-semibold`,children:[n,`%`]})]}),(0,W.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-3 shadow-subtle`,children:(0,W.jsx)(`div`,{className:`bg-gradient-to-r from-primary-500 to-primary-600 dark:from-primary-400 dark:to-primary-500 h-3 rounded-full transition-all duration-500 ease-out shadow-glow`,style:{width:`${e.current/e.total*100}%`}})}),(0,W.jsxs)(`div`,{className:`text-xs flex items-center justify-between`,children:[(0,W.jsxs)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:[t(`settings.model.status`),`:`,` `,e.status===`starting`?(0,W.jsx)(`span`,{className:`text-accent-500 dark:text-accent-400`,children:t(`settings.model.statusStarting`)}):e.status===`success`?(0,W.jsx)(`span`,{className:`text-success-600 dark:text-success-500`,children:t(`settings.model.statusComplete`)}):e.status===`error`?(0,W.jsxs)(`span`,{className:`text-error-600 dark:text-error-500`,children:[t(`settings.model.statusError`),`: `,e.error]}):``]}),(0,W.jsx)(`span`,{className:`text-gray-400 dark:text-dark-600 text-[10px]`,children:t(`settings.model.modelsProgress`,{current:e.current,total:e.total})})]})]})}var gt=[{titleKey:`keyboard.groups.general`,rows:[{labelKey:`keyboard.openPalette`,keys:[`mod`,`K`]},{labelKey:`keyboard.openSettings`,keys:[`mod`,`,`]},{labelKey:`keyboard.toggleDarkMode`,keys:[`mod`,`D`]},{labelKey:`keyboard.showShortcuts`,keys:[`?`]},{labelKey:`keyboard.closeModals`,keys:[`Esc`]}]},{titleKey:`keyboard.groups.navigation`,rows:[{labelKey:`keyboard.toggleSidebar`,keys:[`mod`,`B`]},{labelKey:`keyboard.newChat`,keys:[`mod`,`⇧`,`O`]},{labelKey:`keyboard.newWork`,keys:[`mod`,`⇧`,`U`]}]},{titleKey:`keyboard.groups.chat`,rows:[{labelKey:`keyboard.actions.sendMessage`,keys:[`↩`]},{labelKey:`keyboard.actions.newLine`,keys:[`⇧`,`↩`]},{labelKey:`keyboard.actions.saveEdit`,keys:[`↩`]},{labelKey:`keyboard.actions.cancelEdit`,keys:[`Esc`]}]},{titleKey:`keyboard.groups.workspace`,rows:[{labelKey:`keyboard.actions.saveFile`,keys:[`mod`,`S`]},{labelKey:`keyboard.actions.formatCode`,keys:[`⌥`,`⇧`,`F`]}]}];function _t(){let{t:e}=r(),t=i()?`⌘`:`Ctrl`,n=i()?`⌥`:`Alt`,a=e=>e===`mod`?t:e===`⌥`?n:e;return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:e(`keyboard.title`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`keyboard.description`)})]}),gt.map(t=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:e(t.titleKey)}),(0,W.jsx)(`div`,{className:`divide-y divide-gray-200 overflow-hidden rounded-lg border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:t.rows.map(n=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4 bg-white px-4 py-2.5 dark:bg-dark-100`,children:[(0,W.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e(n.labelKey)}),(0,W.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:n.keys.map((e,t)=>(0,W.jsx)(`kbd`,{className:`rounded border border-gray-300 bg-gray-100 px-2 py-1 font-mono text-xs text-gray-700 dark:border-dark-400 dark:bg-dark-200 dark:text-gray-300`,children:a(e)},`${n.labelKey}-${e}-${t}`))})]},`${t.titleKey}-${n.labelKey}`))})]},t.titleKey))]})}var vt=8;function yt(e,t){let n=e.trim();if(!n)return null;let r;try{r=new URL(n)}catch{return`invalid-url`}return r.protocol!==`http:`&&r.protocol!==`https:`?`insecure-url`:t?.toLowerCase().endsWith(`base_url`)&&(r.search||r.hash)?`query-or-fragment`:null}function bt(e){try{return new URL(e.trim()).protocol===`http:`}catch{return!1}}function xt(e){let t=e.toLowerCase();return t===`endpoint`||t===`base_url`||t===`api_url`||t===`models_endpoint`||t.endsWith(`_endpoint`)||t.endsWith(`_base_url`)}function St(e){let t=e.trim();if(!t.startsWith(`/`)||t.startsWith(`//`)||t.includes(`://`)||t.includes(`\\`)||t.includes(`?`)||t.includes(`#`))return!1;let n=t;for(let e=0;e<=vt;e+=1){let t;try{t=decodeURIComponent(n)}catch{return!1}if(t===n)return!n.includes(`\\`)&&!n.includes(`?`)&&!n.includes(`#`)&&!n.split(`/`).some(e=>e===`.`||e===`..`);if(e===vt)return!1;n=t}return!1}var Ct=new Set([`api_mode`,`api_path`,`endpoint`,`base_url`,`api_url`,`image_endpoint`,`embedding_endpoint`,`tts_endpoint`,`model`,`model_id`,`models_endpoint`]);function wt(e){let t=new Set(Ct),n=e?.capabilities;for(let e of Object.values(n||{})){let n=e?.config?.endpoint_variable??e?.endpoint_variable;typeof n==`string`&&n.trim()&&t.add(n)}return t}function Tt(e,t){return wt(t).has(e)}function Et(e,t){if(e.default!==void 0)return e.default;if(!t)return;if(e.name===`endpoint`||e.name===`api_url`)return t.endpoint||void 0;if(e.name===`base_url`)return t.base_url;if(e.name===`api_path`)return t.api_path;if(e.name===`api_mode`){if(t.api_mode)return t.api_mode;try{return new URL(t.endpoint).pathname.replace(/\/+$/,``).endsWith(`/responses`)?`responses`:`chat_completions`}catch{return`chat_completions`}}let n=t.capabilities;for(let t of Object.values(n||{}))if((t?.config?.endpoint_variable??t?.endpoint_variable)===e.name&&typeof t.endpoint==`string`)return t.endpoint}function Dt(e,t){let n=[],r=[];for(let i of e)(Tt(i.name,t)?n:r).push(i);return{connection:n,advanced:r}}function Ot(e,t){let n={};for(let r of e){let e=t[r.name];n[r.name]=e?.has_value&&!e.is_sensitive?e.value:``}return n}function kt(e,t,n,r,i){let a=new Set(e.map(e=>e.name)),o={},s=[];for(let c of n){if(!a.has(c))continue;let n=e.find(e=>e.name===c);if(!n)continue;let l=t[c],u=r[c],d=typeof l==`string`&&l.trim().length===0,f=Et(n,i),p=f!==void 0&&(typeof l==`string`&&typeof f==`string`?l.trim()===f.trim():Object.is(l,f));if(d||p){if(n.sensitive&&u?.has_value)continue;u?.has_value&&s.push(c);continue}o[c]=l}return{variables:o,unset:s}}Ce(`components:hugging-face-model-browser`);var K=({plugin:e})=>{let{t}=r(),n=Re(e=>e.user),i=Re(e=>e.systemInfo)?.requiresAuth===!1||n?.role===`admin`,{pluginVariables:a,fetchPluginVariables:o,updatePluginVariables:c,resetPluginVariables:l,loadPlugins:u}=Le(),[d,f]=(0,U.useState)({}),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(new Set),[y,b]=(0,U.useState)({}),[x,C]=(0,U.useState)(new Set),[w,D]=(0,U.useState)(!1),ee=U.useId(),k=U.useId(),te=(0,U.useMemo)(()=>e.variables||[],[e.variables]),A=(0,U.useMemo)(()=>wt(e),[e]),j=(0,U.useMemo)(()=>i?te:te.filter(e=>!A.has(e.name)),[i,A,te]),ne=(0,U.useMemo)(()=>a[e.id]||{},[a,e.id]),M=(0,U.useMemo)(()=>Dt(j,e),[e,j]);(0,U.useEffect)(()=>{o(e.id)},[o,e.id]);let N=JSON.stringify(ne),re=(0,U.useRef)(null);(0,U.useEffect)(()=>{let t=j.map(e=>`${e.name}:${e.type}`).join(`|`),n=`${e.id}:${t}:${N}`;if(re.current===n)return;re.current=n;let r=JSON.parse(N);f(e=>{let t=Ot(j,r);for(let n of x)n in e&&(t[n]=e[n]);return t})},[x,e.id,j,N]);let ie=async()=>{let n={};for(let r of j){if(!x.has(r.name))continue;let i=d[r.name],a=typeof i==`string`&&i.trim().length===0,o=ne[r.name],s=Et(r,e);if(a&&r.required&&s===void 0&&!(r.sensitive&&o?.has_value)){n[r.name]=t(`pluginManager.variables.required`,`A value is required`);continue}if(xt(r.name)&&typeof i==`string`&&!a){let e=yt(i,r.name);e===`invalid-url`?n[r.name]=t(`pluginManager.variables.invalidUrl`,`Enter a valid full API endpoint URL, for example https://provider.example/v1/chat/completions`):e===`insecure-url`?n[r.name]=t(`pluginManager.variables.insecureUrl`,`API endpoints must use HTTP or HTTPS.`):e===`query-or-fragment`&&(n[r.name]=t(`pluginManager.variables.invalidBaseUrl`,`Base URLs cannot contain a query string or fragment.`))}if(r.name===`api_path`&&typeof i==`string`&&i.length>0&&!St(i)&&(n[r.name]=t(`pluginManager.variables.invalidApiPath`,`Must start with / and contain no URL, query, fragment, or .. segment`)),r.type===`number`&&!a){let e=Number(i);r.min!==void 0&&e<r.min&&(n[r.name]=`Min: ${r.min}`),r.max!==void 0&&e>r.max&&(n[r.name]=`Max: ${r.max}`)}r.type===`string`&&typeof i==`string`&&i.length>2048&&(n[r.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(b(n),Object.keys(n).length>0)return;let r=kt(j,d,x,ne,e),i=new Set(x),a=Object.fromEntries([...Object.keys(r.variables).map(e=>[e,!0]),...r.unset.map(e=>[e,!0])]);if(Object.keys(r.variables).length===0&&r.unset.length===0){C(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),b(e=>{let t={...e};for(let e of i)delete t[e];return t}),T.success(t(`pluginManager.variables.saved`,`Variables saved`));return}m(!0);try{await c(e.id,r.variables,r.unset)?(Object.keys(a).some(e=>A.has(e))&&await u(),f(e=>{let t={...e};for(let e of j)e.sensitive&&i.has(e.name)&&(t[e.name]=``);return t}),v(e=>{let t=new Set(e);for(let e of j)e.sensitive&&i.has(e.name)&&t.delete(e.name);return t}),C(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),b(e=>{let t={...e};for(let e of i)delete t[e];return t}),T.success(t(`pluginManager.variables.saved`,`Variables saved`))):T.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))}finally{m(!1)}},ae=async()=>{g(!0);try{if(!await l(e.id)){T.error(t(`pluginManager.variables.resetFailed`,`Failed to reset variables`));return}j.some(e=>A.has(e.name))&&await u(),f(Ot(j,{})),C(new Set),b({}),v(new Set),T.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))}finally{g(!1)}},P=(e,t)=>{f(n=>({...n,[e]:t})),C(t=>new Set(t).add(e)),b(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},oe=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},se=e=>{let t=j.indexOf(e),n=`${k}-${t}`;return{controlId:n,descriptionId:`${n}-description`,errorId:`${n}-error`,warningId:`${n}-http-warning`}},F=t=>{if(!xt(t.name))return!1;let n=d[t.name],r=Et(t,e),i=typeof n==`string`&&n.trim()?n:r;return typeof i==`string`&&bt(i)},le=n=>{let r=d[n.name],i=n.sensitive??!1,a=_.has(n.name),o=ne[n.name],{controlId:c,descriptionId:l,errorId:u,warningId:f}=se(n),m=!!y[n.name],g=F(n),v=n.name===`endpoint`||n.name===`api_url`,b=[n.description||v?l:void 0,g?f:void 0,m?u:void 0].filter(Boolean).join(` `)||void 0,x=Et(n,e),C=x===void 0?t(`pluginManager.variables.inherited`,`Use provider default`):t(`pluginManager.variables.inheritedValue`,{defaultValue:`Use provider default ({{value}})`,value:String(x)}),w=s(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-white dark:bg-dark-100`,`border-gray-300 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-blue-500/20`);switch(n.type){case`boolean`:return(0,W.jsxs)(`select`,{id:c,value:r===``?``:String(!!r),onChange:e=>P(n.name,e.target.value===``?``:e.target.value===`true`),className:w,"aria-invalid":m,"aria-describedby":b,disabled:p||h,children:[(0,W.jsx)(`option`,{value:``,children:C}),(0,W.jsx)(`option`,{value:`true`,children:t(`pluginManager.variables.enabled`,`Enabled`)}),(0,W.jsx)(`option`,{value:`false`,children:t(`pluginManager.variables.disabled`,`Disabled`)})]});case`select`:return(0,W.jsxs)(`select`,{id:c,value:String(r??``),onChange:e=>P(n.name,e.target.value),className:w,"aria-invalid":m,"aria-describedby":b,disabled:p||h,children:[(0,W.jsx)(`option`,{value:``,children:C}),(n.options||[]).map(e=>(0,W.jsx)(`option`,{value:e,children:e},e))]});case`number`:return(0,W.jsx)(`input`,{id:c,type:`number`,value:r===``?``:Number(r),min:n.min,max:n.max,placeholder:C,onChange:e=>P(n.name,e.target.value===``?``:Number(e.target.value)),className:w,"aria-invalid":m,"aria-describedby":b,disabled:p||h});default:return(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`input`,{id:c,type:i&&!a?`password`:`text`,value:i&&o?.has_value&&r===``?``:String(r??``),placeholder:i&&o?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):C,onChange:e=>P(n.name,e.target.value),className:s(w,i&&`pr-10`),"aria-invalid":m,"aria-describedby":b,disabled:p||h}),i&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>oe(n.name),"aria-controls":c,"aria-label":a?t(`pluginManager.variables.hideValue`,{defaultValue:`Hide {{label}} value`,label:n.label}):t(`pluginManager.variables.showValue`,{defaultValue:`Show {{label}} value`,label:n.label}),disabled:p||h,className:`absolute end-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:text-gray-300`,children:a?(0,W.jsx)(S,{className:`w-4 h-4`}):(0,W.jsx)(Se,{className:`w-4 h-4`})})]})}},ue=e=>{let{controlId:n,descriptionId:r,errorId:i,warningId:a}=se(e),o=e.name===`endpoint`||e.name===`api_url`,s=F(e);return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{htmlFor:n,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[o?t(`pluginManager.variables.fullApiEndpoint`,`Full API endpoint URL`):e.label,e.required&&(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`text-red-500 ml-1`,children:`*`})]}),(e.description||o)&&(0,W.jsxs)(`p`,{id:r,className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:[e.description,e.description&&o&&` `,o&&t(`pluginManager.variables.endpointHelp`,`Enter the complete request URL, including its operation path (for example, /v1/chat/completions), not only the provider base URL.`)]}),le(e),s&&(0,W.jsxs)(`p`,{id:a,role:`status`,className:`mt-1 flex items-start gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,W.jsx)(ce,{"aria-hidden":`true`,className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{children:t(`pluginManager.variables.httpWarning`,`HTTP does not encrypt credentials or traffic. Use it only on a trusted network.`)})]}),y[e.name]&&(0,W.jsx)(`p`,{id:i,role:`alert`,className:`text-xs text-red-500 mt-1`,children:y[e.name]})]},e.name)};return(0,W.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[M.connection.length>0&&(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:t(`pluginManager.variables.connection`,`Connection`)}),M.connection.map(ue)]}),M.advanced.length>0&&(0,W.jsxs)(`div`,{className:s(M.connection.length>0&&`mt-4 border-t pt-4`,`border-gray-200 dark:border-gray-700`),children:[(0,W.jsxs)(`button`,{type:`button`,"aria-expanded":w,"aria-controls":ee,onClick:()=>D(e=>!e),className:`flex w-full items-center justify-between rounded-md py-1 text-left text-sm font-medium text-gray-700 hover:text-gray-950 dark:text-gray-300 dark:hover:text-white`,children:[(0,W.jsxs)(`span`,{children:[t(`pluginManager.variables.advanced`,`Advanced parameters`),` (`,M.advanced.length,`)`]}),(0,W.jsx)(ge,{className:s(`h-4 w-4 transition-transform`,w&&`rotate-180`)})]}),w&&(0,W.jsx)(`div`,{id:ee,className:`mt-3 space-y-3`,children:M.advanced.map(ue)})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,W.jsxs)(B,{size:`sm`,onClick:ie,disabled:p||h||x.size===0,className:`gap-1.5`,children:[(0,W.jsx)(E,{className:`w-3.5 h-3.5`}),p?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,W.jsxs)(B,{variant:`outline`,size:`sm`,onClick:ae,disabled:p||h,className:`gap-1.5`,children:[(0,W.jsx)(O,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function At({plugins:e,loading:t,uploading:n,error:i,hasKeys:a,showUploadForm:o,showJsonForm:s,jsonInput:c,fileInputRef:d,expandedPluginId:f,pluginApiKeys:p,showApiKey:m,savingApiKey:h,refreshingPluginIds:g,onClearError:_,onShowUploadFormChange:v,onShowJsonFormChange:y,onJsonInputChange:b,onFileUpload:x,onJsonSubmit:S,onExpandedPluginChange:C,onPluginApiKeyChange:w,onShowApiKeyChange:T,onActivatePlugin:E,onDeletePlugin:D,onExportPlugin:O,onSaveApiKey:k,onDeleteApiKey:te,onRefreshModels:A}){let{t:j}=r(),ne=Re(e=>e.user),M=Re(e=>e.systemInfo)?.requiresAuth===!1||ne?.role===`admin`,[N,re]=(0,U.useState)(``),[ie,ae]=(0,U.useState)(null),P=(0,U.useId)(),oe=(0,U.useMemo)(()=>e.filter(e=>u(e,N)),[e,N]),ce=ie&&e.some(e=>e.id===ie)?ie:e[0]?.id??null,F=e.find(e=>e.id===ce)??null,le=e=>{e!==ce&&(C(null),ae(e))};return(0,W.jsx)(`div`,{className:`space-y-6`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:j(`settings.plugins.providerConnections`,{defaultValue:`Provider connections`})}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:j(`settings.plugins.providerConnectionsDescription`,{defaultValue:`Connect, configure, and inspect model providers through plugins.`})})]}),i&&(0,W.jsx)(`div`,{className:`p-4 bg-primary-50/80 dark:bg-primary-950/25 border border-primary-200 dark:border-primary-800/50 rounded-lg mb-4`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:i}),(0,W.jsx)(B,{variant:`ghost`,size:`sm`,onClick:_,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,W.jsx)(me,{className:`h-4 w-4`})})]})}),M&&(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:j(`settings.plugins.addNew`)}),(0,W.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,W.jsxs)(B,{variant:`outline`,size:`sm`,onClick:()=>v(!o),disabled:t||n,children:[(0,W.jsx)(se,{className:`h-4 w-4 me-2`}),j(`settings.plugins.upload`)]}),(0,W.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>y(!s),disabled:t,children:j(`settings.plugins.addJson`)})]})]}),o&&(0,W.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,W.jsx)(`input`,{ref:d,type:`file`,accept:`.json,.zip`,onChange:x,className:`flex-1 p-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 file:me-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 dark:file:bg-dark-200 dark:file:text-dark-700 hover:file:bg-gray-200 dark:hover:file:bg-dark-300`,disabled:n}),(0,W.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>v(!1),disabled:n,children:j(`common.cancel`)})]}),n&&(0,W.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:j(`settings.plugins.uploading`)})]}),s&&(0,W.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(`textarea`,{value:c,onChange:e=>b(e.target.value),placeholder:j(`settings.plugins.jsonPlaceholder`),className:`w-full h-32 p-3 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500 font-mono text-sm`,disabled:t}),(0,W.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,W.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>{y(!1),b(``)},children:j(`common.cancel`)}),(0,W.jsx)(B,{size:`sm`,onClick:S,disabled:!c.trim()||t,children:j(`settings.plugins.install`)})]})]})})]}),(0,W.jsx)(`div`,{"data-testid":`provider-workspace`,className:`overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:(0,W.jsxs)(`div`,{className:`grid min-h-[30rem] grid-cols-1 lg:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.6fr)]`,children:[(0,W.jsxs)(`section`,{"data-testid":`provider-list`,"aria-label":j(`settings.plugins.providers`,{defaultValue:`Providers`}),className:`border-b border-gray-200 dark:border-dark-300 lg:border-b-0 lg:border-e`,children:[(0,W.jsxs)(`div`,{className:`border-b border-gray-200 p-4 dark:border-dark-300`,children:[(0,W.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:j(`settings.plugins.providers`,{defaultValue:`Providers`})}),(0,W.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600 dark:bg-dark-200 dark:text-gray-300`,children:e.length})]}),(0,W.jsx)(`label`,{htmlFor:P,className:`sr-only`,children:j(`settings.plugins.searchProviders`,{defaultValue:`Search providers`})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(ee,{"aria-hidden":`true`,className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,W.jsx)(`input`,{id:P,type:`search`,value:N,onChange:e=>re(e.target.value),placeholder:j(`settings.plugins.searchProviders`,{defaultValue:`Search providers`}),className:`w-full rounded-lg border border-gray-300 bg-white py-2 pe-3 ps-9 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]})]}),(0,W.jsx)(`div`,{className:`max-h-[32rem] space-y-2 overflow-y-auto p-3`,children:t&&e.length===0?(0,W.jsxs)(`div`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:[(0,W.jsx)(de,{className:`mx-auto mb-2 h-5 w-5 animate-spin`}),j(`settings.plugins.loading`)]}):e.length===0?(0,W.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,W.jsx)(xe,{className:`mx-auto mb-3 h-9 w-9 text-gray-400`}),(0,W.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:j(`settings.plugins.noPlugins`)}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-gray-500`,children:j(`settings.plugins.noPluginsDescription`)})]}):oe.length===0?(0,W.jsx)(`p`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:j(`settings.plugins.noProvidersFound`,{defaultValue:`No providers match your search.`})}):oe.map(e=>{let t=ce===e.id,n=l(e).length;return(0,W.jsx)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>le(e.id),className:`w-full rounded-xl border p-3 text-start transition-colors ${t?`border-blue-500 bg-blue-50/70 dark:border-blue-500 dark:bg-blue-950/20`:`border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:hover:border-dark-400 dark:hover:bg-dark-50`}`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`span`,{className:`sr-only`,children:[e.active?j(`settings.plugins.activeLabel`):j(`settings.plugins.inactive`),`.`,` `]}),(0,W.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,W.jsxs)(`span`,{className:`mt-0.5 block text-xs capitalize text-gray-500 dark:text-gray-400`,children:[e.type,` · `,n,` `,j(`settings.plugins.models`)]})]})]})},e.id)})})]}),(0,W.jsx)(`section`,{"data-testid":`provider-detail`,className:`min-w-0 p-4 sm:p-5`,children:F?(0,W.jsx)(jt,{plugin:F,loading:t,hasApiKey:a[F.id]||!1,expanded:f===F.id,apiKey:p[F.id]||``,showApiKey:m[F.id]||!1,savingApiKey:h===F.id,refreshingModels:!!g[F.id],canManagePlugin:M,onExpand:()=>C(f===F.id?null:F.id),onActivate:()=>E(F.id),onExport:()=>O(F.id),onDelete:()=>D(F.id),onRefreshModels:()=>A(F.id),onApiKeyChange:e=>w(F.id,e),onShowApiKeyChange:e=>T(F.id,e),onSaveApiKey:()=>k(F.id),onDeleteApiKey:()=>te(F.id)}):(0,W.jsx)(`div`,{className:`flex min-h-[24rem] items-center justify-center text-center`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(xe,{className:`mx-auto mb-3 h-10 w-10 text-gray-400`}),(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:j(`settings.plugins.selectProvider`,{defaultValue:`Select a provider`})}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:j(`settings.plugins.selectProviderDescription`,{defaultValue:`Choose a provider to inspect its connection and model catalog.`})})]})})})]})})]})})}function jt({plugin:e,loading:t,hasApiKey:n,expanded:i,apiKey:a,showApiKey:o,savingApiKey:s,refreshingModels:c,canManagePlugin:u,onExpand:d,onActivate:f,onExport:p,onDelete:m,onRefreshModels:g,onApiKeyChange:_,onShowApiKeyChange:v,onSaveApiKey:y,onDeleteApiKey:b}){let{t:x}=r(),S=!!(e.auth?.header||e.auth?.key_env),C=wt(e),T=u?e.variables||[]:(e.variables||[]).filter(e=>!C.has(e.name)),E=T.length>0,D=S||E,O=(0,U.useId)(),ee=l(e),k=e.base_url||e.endpoint;return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-gray-200 pb-4 dark:border-dark-300`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,W.jsx)(`h4`,{className:`truncate text-lg font-semibold text-gray-900 dark:text-gray-100`,children:e.name})]}),(0,W.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e.id,` · `,(0,W.jsx)(`span`,{className:`capitalize`,children:e.type}),S&&n&&(0,W.jsxs)(`span`,{className:`text-green-600`,children:[` `,`· `,x(`settings.plugins.apiKeySet`)]})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[D&&(0,W.jsxs)(B,{variant:`outline`,size:`sm`,onClick:d,"aria-expanded":i,"aria-controls":O,title:x(`settings.plugins.configure`),className:n?`text-green-600`:``,children:[S?(0,W.jsx)(I,{className:`h-4 w-4`}):(0,W.jsx)(w,{className:`h-4 w-4`}),x(`settings.plugins.configure`),i?(0,W.jsx)(_e,{className:`h-3 w-3`}):(0,W.jsx)(ge,{className:`h-3 w-3`})]}),(0,W.jsx)(B,{variant:`outline`,size:`sm`,onClick:f,disabled:t,className:e.active?`border-green-300 text-green-600`:``,children:e.active?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(L,{className:`h-4 w-4`}),x(`settings.plugins.deactivate`)]}):x(`settings.plugins.activate`)}),u&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(B,{variant:`ghost`,size:`sm`,onClick:p,disabled:t,title:x(`settings.plugins.exportPlugin`,`Export plugin`),className:`px-2`,children:(0,W.jsx)(M,{className:`h-4 w-4`})}),(0,W.jsx)(B,{variant:`ghost`,size:`sm`,onClick:m,disabled:t,className:`px-2 text-red-600 hover:bg-red-50 hover:text-red-700`,title:x(`settings.plugins.deletePlugin`,`Delete plugin`),children:(0,W.jsx)(fe,{className:`h-4 w-4`})})]})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:x(`settings.plugins.status`,{defaultValue:`Status`})}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:e.active?x(`settings.plugins.activeLabel`):x(`settings.plugins.inactive`)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:x(`settings.plugins.models`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:ee.length})]}),(0,W.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:x(`settings.plugins.defaultEndpoint`,{defaultValue:`Default endpoint`})}),(0,W.jsx)(`p`,{className:`mt-1 truncate text-sm text-gray-900 dark:text-gray-100`,title:k,children:k})]})]})]}),i&&D&&(0,W.jsxs)(`div`,{id:O,children:[S&&(0,W.jsx)(Nt,{plugin:e,hasApiKey:n,apiKey:a,showApiKey:o,savingApiKey:s,onApiKeyChange:_,onShowApiKeyChange:v,onSaveApiKey:y,onDeleteApiKey:b}),E&&(0,W.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-dark-300 dark:bg-dark-50`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,W.jsx)(w,{className:`h-4 w-4 text-gray-500`}),(0,W.jsxs)(`h5`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[x(`settings.plugins.providerSettings`),` (`,T.length,`)`]})]}),(0,W.jsx)(K,{plugin:e},e.id)]})]}),(0,W.jsx)(Mt,{catalog:ee,canRefresh:h(e),refreshing:c,onRefresh:g})]})}function Mt({catalog:e,canRefresh:t,refreshing:n,onRefresh:i}){let{t:a}=r();return(0,W.jsxs)(`section`,{"data-testid":`provider-model-catalog`,className:`mt-5`,children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h5`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:a(`settings.plugins.modelCatalog`,{defaultValue:`Model catalog`})}),(0,W.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:a(`settings.plugins.modelCatalogDescription`,{defaultValue:`Discovered and configured models for this provider and its capabilities.`})})]}),t&&(0,W.jsxs)(B,{variant:`outline`,size:`sm`,onClick:i,disabled:n,"aria-busy":n,children:[n?(0,W.jsx)(de,{className:`h-4 w-4 animate-spin`}):(0,W.jsx)(k,{className:`h-4 w-4`}),a(`settings.plugins.refreshModels`,{defaultValue:`Refresh models`})]})]}),e.length===0?(0,W.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-dark-300 dark:text-gray-400`,children:a(`settings.plugins.noModelsConfigured`,{defaultValue:`No models are configured for this provider.`})}):(0,W.jsx)(`div`,{className:`max-h-[26rem] overflow-auto rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`table`,{className:`w-full min-w-[24rem] text-start text-sm`,children:[(0,W.jsx)(`thead`,{className:`sticky top-0 z-10 bg-gray-50 text-xs uppercase tracking-wide text-gray-500 dark:bg-dark-50 dark:text-gray-400`,children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:a(`settings.plugins.modelId`,{defaultValue:`Model ID`})}),(0,W.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:a(`settings.plugins.capabilities`,{defaultValue:`Capabilities`})})]})}),(0,W.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-xs text-gray-900 dark:text-gray-100`,children:e.id}),(0,W.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,W.jsx)(`span`,{className:`rounded-md bg-blue-50 px-2 py-0.5 text-xs text-blue-700 dark:bg-blue-950/30 dark:text-blue-300`,children:a(`settings.plugins.capability.${e.toLowerCase()}`,{defaultValue:e})},e))})})]},e.id))})]})})]})}function Nt({plugin:e,hasApiKey:t,apiKey:n,showApiKey:i,savingApiKey:a,onApiKeyChange:o,onShowApiKeyChange:s,onSaveApiKey:c,onDeleteApiKey:l}){let{t:u}=r(),d=(0,U.useId)();return(0,W.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,W.jsx)(I,{className:`h-4 w-4 text-gray-500`}),(0,W.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.plugins.apiKeyConfiguration`)})]}),(0,W.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[u(`settings.plugins.apiKeyDescription`,{name:e.name,defaultValue:`Store a personal API key for {{name}}.`}),e.auth?.key_env&&(0,W.jsxs)(`span`,{className:`block mt-1`,children:[u(`settings.plugins.apiKeyEnvAlternative`),` `,(0,W.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,u(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,W.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{className:`h-4 w-4 text-green-600`}),(0,W.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:u(`settings.plugins.apiKeyConfigured`)})]}),(0,W.jsx)(B,{variant:`outline`,size:`sm`,onClick:l,disabled:a,className:`text-red-600 border-red-300 hover:bg-red-50`,children:a?(0,W.jsx)(de,{className:`h-4 w-4 animate-spin`}):u(`common.remove`)})]}):(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`label`,{htmlFor:d,className:`sr-only`,children:u(`settings.plugins.apiKey.title`)}),(0,W.jsx)(`input`,{id:d,type:i?`text`:`password`,value:n,onChange:e=>o(e.target.value),placeholder:u(`settings.plugins.apiKeyPlaceholder`),disabled:a,className:`w-full p-2 pe-10 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>s(!i),"aria-controls":d,"aria-label":u(i?`settings.plugins.hideApiKey`:`settings.plugins.showApiKey`),disabled:a,className:`absolute end-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50`,children:i?(0,W.jsx)(S,{className:`h-4 w-4`}):(0,W.jsx)(Se,{className:`h-4 w-4`})})]}),(0,W.jsx)(`div`,{className:`flex justify-end`,children:(0,W.jsx)(B,{size:`sm`,onClick:c,disabled:a||!n.trim(),children:a?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(de,{className:`h-4 w-4 me-2 animate-spin`}),u(`common.saving`)]}):u(`settings.plugins.saveApiKey`)})})]})]})}var Pt=()=>{let{t:e}=r(),[t,n]=(0,U.useState)(!1),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(`6`),[c,l]=(0,U.useState)(!0),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(!1);(0,U.useEffect)(()=>{let e=!1;return je.getConfig().then(t=>{e||!t.success||!t.data||(n(t.data.enabled),a(t.data.url??``),typeof t.data.maxResults==`number`&&s(String(t.data.maxResults)),typeof t.data.safeSearch==`boolean`&&l(t.data.safeSearch),d(!0))}).catch(()=>{}),()=>{e=!0}},[]);let g=async(r=t)=>{let u=Number(o);if(!Number.isInteger(u)||u<1||u>10){j.error(e(`settings.search.maxResultsInvalid`));return}p(!0);try{let t=await je.setConfig(r,i.trim(),{maxResults:u,safeSearch:c});if(!t.success||!t.data)throw Error(t.error||`Search settings update failed.`);n(t.data.enabled),a(t.data.url??``),typeof t.data.maxResults==`number`&&s(String(t.data.maxResults)),typeof t.data.safeSearch==`boolean`&&l(t.data.safeSearch),j.success(e(`settings.search.saved`))}catch(t){j.error(t instanceof Error&&t.message?t.message:e(`settings.search.saveFailed`))}finally{p(!1)}},_=async()=>{h(!0);try{let t=await je.test();if(!t.success||!t.data?.ok)throw Error(t.error||e(`settings.search.testFailed`));j.success(e(`settings.search.testOk`,{results:t.data.results}))}catch(t){j.error(t instanceof Error&&t.message?t.message:e(`settings.search.testFailed`))}finally{h(!1)}};return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,W.jsx)(A,{className:`h-5 w-5 text-primary-500`}),e(`settings.search.title`)]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.search.description`)})]}),(0,W.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.enableLabel`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.search.enableDescription`)})]}),(0,W.jsx)(H,{checked:t,onChange:e=>{n(e),g(e)},disabled:f||!u||!t&&!i.trim()})]})}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,W.jsxs)(`label`,{className:`block`,children:[(0,W.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.urlLabel`)}),(0,W.jsx)(`span`,{className:`mb-2 block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.urlDescription`)}),(0,W.jsx)(Ge,{value:i,onChange:e=>a(e.target.value),placeholder:`http://searxng:8080`,spellCheck:!1,dir:`ltr`})]}),(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`label`,{className:`block`,children:[(0,W.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.maxResultsLabel`)}),(0,W.jsx)(`span`,{className:`mb-2 block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.maxResultsDescription`)}),(0,W.jsx)(Ge,{type:`number`,min:1,max:10,value:o,onChange:e=>s(e.target.value),dir:`ltr`})]}),(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4 sm:pt-1`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.safeSearchLabel`)}),(0,W.jsx)(`span`,{className:`block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.safeSearchDescription`)})]}),(0,W.jsx)(H,{checked:c,onChange:l,disabled:f||!u})]})]}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>void _(),disabled:m||f||!t,children:e(m?`settings.search.testing`:`settings.search.test`)}),(0,W.jsx)(B,{size:`sm`,onClick:()=>void g(),disabled:f||!u,children:e(`settings.search.save`)})]})]})]})};function Ft({loading:e,settings:t,effectiveSettings:n,models:i,plugins:a,voices:o,testing:s,onSettingChange:c,onModelChange:l,onReset:u,onTest:d,onSave:f}){let{t:p}=r(),m=i.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,W.jsx)(`div`,{className:`space-y-6`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.tts.title`)}),(0,W.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.tts.description`)}),e?(0,W.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,W.jsx)(de,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,W.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:p(`settings.tts.loadingProviders`)})]}):i.length===0?(0,W.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(he,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:p(`settings.tts.noProviders`)}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:p(`settings.tts.noProvidersDescription`)})]})]})}):(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.tts.enable`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.tts.enableDescription`)})]}),(0,W.jsx)(H,{checked:t.enabled,onChange:e=>c(`enabled`,e)})]})}),(0,W.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.tts.autoPlay`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.tts.autoPlayDescription`)})]}),(0,W.jsx)(H,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>c(`autoPlay`,e)})]})}),(0,W.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.tts.streamSentences`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.tts.streamSentencesDescription`)})]}),(0,W.jsx)(H,{checked:t.streamSentences||!1,disabled:!t.enabled,onChange:e=>c(`streamSentences`,e)})]})}),(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.tts.voiceConfiguration`)}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.tts.model`)}),(0,W.jsx)(V,{"aria-label":p(`settings.tts.model`),value:m?Ae(m):``,onChange:e=>{let t=i.find(t=>Ae(t)===e.target.value);t&&l(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:p(`settings.model.selectModel`)},...i.map(e=>({value:Ae(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.tts.modelDescription`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.tts.voice`)}),(0,W.jsx)(V,{"aria-label":p(`settings.tts.voice`),value:n.voice,onChange:e=>c(`voice`,e.target.value),disabled:!t.enabled||o.length===0,options:[{value:``,label:p(`settings.tts.selectVoice`)},...o.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))]}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.tts.voiceDescription`)})]})]})]}),a.length>0&&(0,W.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.tts.availableProviders`)}),(0,W.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,W.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,W.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,p(`settings.tts.models`),`)`]})]},e.id))})]}),(0,W.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(B,{onClick:u,variant:`outline`,className:`flex items-center gap-2`,children:[(0,W.jsx)(O,{size:16}),p(`common.reset`)]}),(0,W.jsx)(B,{onClick:d,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ye,{size:16}),p(`settings.tts.stop`)]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(N,{size:16}),p(`settings.tts.test`)]})})]}),(0,W.jsxs)(B,{onClick:f,className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{size:16}),p(`settings.saveSettings`)]})]})]})]})})}function It({preferences:e,sessions:t,loadPreferences:n,loadSessions:r}){let[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(`skip`),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(null),m=(0,U.useRef)(null),h=()=>{p(null),m.current&&(m.current.value=``)};return{importing:i,showImportOptions:o,mergeStrategy:c,setMergeStrategy:l,importResult:u,setImportResult:d,importFileInputRef:m,handleExportData:()=>{let n={format:`libre-webui-export`,version:`1.0`,preferences:e,sessions:t,documents:[],exportedAt:new Date().toISOString()},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`libre-webui-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),T.success(`Data exported successfully`)},handleImportFileSelect:e=>{let t=e.target.files?.[0];t&&(p(t),s(!0),d(null))},handleConfirmImport:async()=>{if(f){a(!0);try{let e=await f.text(),t=JSON.parse(e);if(!t.format||t.format!==`libre-webui-export`)throw Error(`Invalid export format. Please use a valid Libre WebUI export file.`);let i=await z.importData(t,c===`overwrite`?`replace`:`merge`);if(i.success&&i.data)d({preferences:{imported:!0,error:null},sessions:{imported:0,skipped:0,errors:[]},documents:{imported:0,skipped:0,errors:[]}}),T.success(`Data imported successfully`),await n(),await r();else throw Error(i.error||`Import failed`)}catch(e){T.error(e instanceof Error?e.message:`Import failed`),d(null)}finally{a(!1),s(!1),h()}}},handleCancelImport:()=>{s(!1),d(null),h()}}}var Lt=Ye()||`0.0.0`,Rt=`__current_running_model__`,zt={enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},Bt={enabled:!1,autoPlay:!1,model:``,voice:``,speed:1,pluginId:``,streamSentences:!1},Vt={enabled:!1,model:``,size:`1024x1024`,quality:`standard`,style:`vivid`,pluginId:``},q=({isOpen:e,onClose:t,initialTab:n})=>{let{models:i,selectedModel:a,selectedProviderType:o,selectedProviderId:l,setSelectedModel:u,systemMessage:d,setSystemMessage:m,clearAllSessions:h,loading:y,sessions:b,loadModels:x,loadSessions:S}=_(),{theme:C,updateTheme:E,preferences:D,setPreferences:O,loadPreferences:k}=He(),{plugins:te,isLoading:j,isUploading:ne,error:M,loadPlugins:N,uploadPlugin:re,deletePlugin:P,activatePlugin:se,deactivatePlugin:ce,exportPlugin:de,clearError:fe,installPlugin:ge}=Le(),{t:I}=r(),_e=U.useId(),ve=f(i,{model:a,providerType:o,providerId:l}),L={model:D.titleSettings?.taskModel||``,providerType:D.titleSettings?.taskProviderType,providerId:D.titleSettings?.taskProviderId},ye=f(i,L),be=L.model===Rt?Rt:L.model?c(ye,L):``,Se={model:D.visionModel||``,providerType:D.visionProviderType,providerId:D.visionProviderId},Ce=f(i,Se),Ae=Se.model?c(Ce,Se):``,je=[{value:``,label:I(`settings.model.selectVisionModel`,{defaultValue:`Use the current chat model`})},...Ce.map(e=>({value:p(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:e.isAgent?`${e.agentName||e.name} · Agent CLI${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],Ne=[{value:``,label:I(`settings.model.autoTitle.selectTaskModel`)},{value:Rt,label:`Use current running model`},...ye.map(e=>({value:p(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],ze=Re(e=>e.user),Be=Re(e=>e.systemInfo),V=ze?.role===`admin`||Be?.requiresAuth===!1,[We,Ge]=(0,U.useState)(n??`appearance`),[qe,Ye]=(0,U.useState)(`global`),[Xe,H]=(0,U.useState)(``),[Ze,Qe]=(0,U.useState)(d),[et,tt]=(0,U.useState)(!1),[nt,it]=(0,U.useState)(null),[st,ct]=(0,U.useState)(!1),[ut,G]=(0,U.useState)(!1),[dt,mt]=(0,U.useState)(``),ht=(0,U.useRef)(null),[gt,vt]=(0,U.useState)(null),[yt,bt]=(0,U.useState)({}),[xt,St]=(0,U.useState)({}),[Ct,wt]=(0,U.useState)(null),[Tt,Et]=(0,U.useState)({}),[Dt,Ot]=(0,U.useState)(D.generationOptions||{}),kt=(0,U.useCallback)(async e=>{try{let t=await ke.getModelDefaults(e);return t.success?t.data?.options??{}:{}}catch{return{}}},[]);(0,U.useEffect)(()=>{if(!e)return;let t=qe===`model`&&!!a,n=!1;return(t?kt(a):Promise.resolve({})).then(e=>{n||Ot(t?{...D.generationOptions||{},...e,...D.modelGenerationOptions?.[a]||{}}:{...D.generationOptions||{}})}),()=>{n=!0}},[e,qe,a,kt,D.generationOptions,D.modelGenerationOptions]);let[K,jt]=(0,U.useState)(D.embeddingSettings||zt),[Mt,Nt]=(0,U.useState)(!1),[q,Ht]=(0,U.useState)(D.ttsSettings||Bt),[Ut,Wt]=(0,U.useState)(!1),Gt=(0,U.useRef)(null),[J,Kt]=(0,U.useState)(D.imageGenSettings||Vt),{importing:qt,showImportOptions:Jt,mergeStrategy:Yt,setMergeStrategy:Xt,importResult:Zt,setImportResult:Qt,importFileInputRef:$t,handleExportData:en,handleImportFileSelect:tn,handleConfirmImport:nn,handleCancelImport:rn}=It({preferences:D,sessions:b,loadPreferences:k,loadSessions:S}),Y=Je(),{data:an={}}=Ke({queryKey:[`plugin-credentials`],queryFn:async()=>{let e=await Te.getCredentials();if(!e.success||!e.data)return{};let t={};for(let n of e.data)t[n.plugin_id]=n.has_api_key;return t},enabled:e}),{data:on=[]}=Ke({queryKey:[`embedding-models`],queryFn:async()=>{let e=await Me.getModels();return e.success&&e.data?e.data:[]},enabled:e}),sn=(0,U.useMemo)(()=>{let e=on.find(e=>e.id===K.model||e.rawModel===K.model);return e&&e.id!==K.model?{...K,model:e.id}:K},[on,K]),{data:cn=null}=Ke({queryKey:[`embedding-status`],queryFn:async()=>{let e=await R.getEmbeddingStatus();return e.success&&e.data?e.data:null},enabled:e}),{data:ln,isLoading:un}=Ke({queryKey:[`tts-data`],queryFn:async()=>{let[e,t]=await Promise.all([we.getModels(),we.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),X=(0,U.useMemo)(()=>ln?.models??[],[ln]),dn=ln?.plugins??[],fn=(0,U.useMemo)(()=>De(X,q.model,q.pluginId),[X,q.model,q.pluginId]),Z=(0,U.useMemo)(()=>{if(!fn)return q;let e=Oe(X,q.model,q.pluginId);return e&&q.pluginId===e.plugin?q:{...q,model:fn.model,pluginId:fn.plugin,voice:fn.config?.default_voice||``}},[fn,X,q]),pn=(0,U.useMemo)(()=>Oe(X,Z.model,Z.pluginId)?.config?.voices??[],[Z,X]),{data:mn,isLoading:hn}=Ke({queryKey:[`image-gen-data`],queryFn:async()=>{let[e,t]=await Promise.all([Ee.getModels(),Ee.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Q=(0,U.useMemo)(()=>mn?.models??[],[mn]),gn=(0,U.useMemo)(()=>mn?.plugins??[],[mn]),$=(0,U.useMemo)(()=>Pe(Q,J.model,J.pluginId),[Q,J.model,J.pluginId]),_n=(0,U.useMemo)(()=>{if(!$)return J;let e=Ie(Q,J.model,J.pluginId);return e&&J.pluginId===e.plugin?J:{...J,model:$.model,pluginId:$.plugin,size:Fe($.config?.sizes,J.size,$.config?.default_size,`1024x1024`),quality:Fe($.config?.qualities,J.quality,$.config?.default_quality,`standard`),style:Fe($.config?.styles,J.style,$.config?.default_style,`vivid`)}},[Q,J,$]),vn=$?.config?.sizes??[],yn=$?.config?.qualities??[],bn=$?.config?.styles??[],xn=(0,U.useRef)(!1),Sn=(0,U.useRef)(d);(0,U.useEffect)(()=>{if(!e){xn.current=!1;return}xn.current&&Sn.current===d||(xn.current=!0,Sn.current=d,Qe(d),Ot(D.generationOptions||{}),jt(D.embeddingSettings||zt),Ht(D.ttsSettings||Bt),Kt(D.imageGenSettings||Vt))},[e,D.embeddingSettings,D.generationOptions,D.imageGenSettings,D.ttsSettings,d]);let Cn=(0,U.useRef)(!1);(0,U.useEffect)(()=>{if(!e){Cn.current=!1;return}Cn.current||(Cn.current=!0,N(),x())},[e,N,x]),(0,U.useEffect)(()=>{if(!e)return;let n=document.body.style.overflow,r=e=>{e.key===`Escape`&&t()};return document.body.style.overflow=`hidden`,document.addEventListener(`keydown`,r),()=>{document.body.style.overflow=n,document.removeEventListener(`keydown`,r)}},[e,t]);let wn=async e=>{let t=yt[e];if(!t?.trim()){T.error(`Please enter an API key`);return}wt(e);try{let n=await Te.setApiKey(e,t.trim());n.success?(T.success(`API key saved successfully`),await Y.invalidateQueries({queryKey:[`plugin-credentials`]}),await N(),await Y.invalidateQueries({queryKey:[`image-gen-data`]}),bt(t=>({...t,[e]:``})),St(t=>({...t,[e]:!1}))):T.error(n.error||`Failed to save API key`)}catch{T.error(`Failed to save API key`)}finally{wt(null)}},Tn=async e=>{wt(e);try{let t=await Te.deleteApiKey(e);t.success?(T.success(`API key removed`),await Y.invalidateQueries({queryKey:[`plugin-credentials`]}),await N(),await Y.invalidateQueries({queryKey:[`image-gen-data`]}),bt(t=>({...t,[e]:``}))):T.error(t.error||`Failed to remove API key`)}catch{T.error(`Failed to remove API key`)}finally{wt(null)}},En=(e,t)=>{let n=Oe(X,e,t);n&&Ht(r=>({...r,model:e,pluginId:t,voice:n.config?.default_voice||r.voice}))},Dn=(e,t)=>{let n=Ie(Q,e,t);n&&Kt(t=>({...t,model:e,pluginId:n.plugin,size:Fe(n.config?.sizes,t.size,n.config?.default_size,`1024x1024`),quality:Fe(n.config?.qualities,t.quality,n.config?.default_quality,`standard`),style:Fe(n.config?.styles,t.style,n.config?.default_style,`vivid`)}))},On=(e,t)=>{Ht(n=>({...n,[e]:t}))},kn=async()=>{try{let e=await z.updatePreferences({ttsSettings:Z});e.success&&e.data&&(O(e.data),T.success(`TTS settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`Failed to save TTS settings: `+t)}},An=async()=>{if(Ut){let e=Gt.current;e&&(e.pause(),e.currentTime=0,Gt.current=null),Wt(!1);return}Wt(!0);try{let e=await we.generateBase64({model:Z.model||`tts-1`,pluginId:Z.pluginId,input:`Hello! This is a test of the text-to-speech system.`,voice:Z.voice||`alloy`,speed:Z.speed||1,response_format:fn?.config?.default_format});if(e.success&&e.data?.audio){let t=`data:${e.data.mimeType};base64,${e.data.audio}`,n=new Audio(t);Gt.current=n,n.onended=()=>{Wt(!1),Gt.current=null},n.onerror=()=>{T.error(`Failed to play audio`),Wt(!1),Gt.current=null},await n.play()}else throw Error(e.message||`Failed to generate speech`)}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`TTS test failed: `+t),Wt(!1)}},jn=()=>{Ht({enabled:!1,autoPlay:!1,model:X[0]?.model||``,voice:X[0]?.config?.default_voice||``,speed:1,pluginId:X[0]?.plugin||``,streamSentences:!1})},Mn=(e,t)=>{Kt(n=>({...n,[e]:t}))},Nn=async()=>{try{let e=await z.updatePreferences({imageGenSettings:_n});e.success&&e.data&&(O(e.data),T.success(`Image generation settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`Failed to save image generation settings: `+t)}},Pn=()=>{Kt({enabled:!1,model:Q[0]?.model||``,size:Q[0]?.config?.default_size||`1024x1024`,quality:Q[0]?.config?.default_quality||`standard`,style:Q[0]?.config?.default_style||`vivid`,pluginId:Q[0]?.plugin||``})},Fn=async()=>{try{Nt(!0),(await R.regenerateEmbeddings()).success&&(T.success(`Embeddings regenerated successfully`),await Y.invalidateQueries({queryKey:[`embedding-status`]}))}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`Failed to regenerate embeddings: `+t)}finally{Nt(!1)}},In=async e=>{try{let t=await z.updatePreferences(e);t.success&&t.data&&(O(t.data),T.success(`Settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`Failed to update settings: `+t)}},Ln=async e=>{let t=e.target.files?.[0];t&&(await re(t),ct(!1),ht.current&&(ht.current.value=``),await x(),await Y.invalidateQueries({queryKey:[`image-gen-data`]}))},Rn=async()=>{try{let e=JSON.parse(dt);await ge(e),G(!1),mt(``),await x(),await Y.invalidateQueries({queryKey:[`image-gen-data`]})}catch{fe(),T.error(`Invalid JSON format`)}},zn=async e=>{te.find(t=>t.id===e)?.active?await ce(e):await se(e),await x(),await Y.invalidateQueries({queryKey:[`image-gen-data`]})},Bn=async e=>{if(!Tt[e]){Et(t=>({...t,[e]:!0}));try{let t=await Te.discoverModels(e);if(!t.success||!t.data){T.error(t.error||I(`settings.plugins.modelCatalogRefreshFailed`));return}await Promise.all([N(),x()]);let{outcome:n,models:r,reason:i}=t.data;n===`updated`?T.success(I(`settings.plugins.modelCatalogUpdated`,{count:r.length})):n===`unchanged`?T.success(I(`settings.plugins.modelCatalogUnchanged`)):n===`missing_credentials`?T.error(i||I(`settings.plugins.modelCatalogNeedsApiKey`)):T.error(i?`${I(`settings.plugins.modelCatalogUnavailable`)} ${i}`:I(`settings.plugins.modelCatalogUnavailable`))}catch(e){T.error(v(e,I(`settings.plugins.modelCatalogRefreshFailed`)))}finally{Et(t=>{let n={...t};return delete n[e],n})}}},Vn=async e=>{window.confirm(`Are you sure you want to delete this plugin?`)&&(await P(e),await x(),await Y.invalidateQueries({queryKey:[`image-gen-data`]}))},Hn=async e=>{await de(e)};if(!e)return null;let Un=e=>{let t=He.getState().theme,n=Ve({...t,mode:e});E(n)},Wn=e=>{let t=He.getState().theme,n=Ve({...t,accent:e});E(n)},Gn=e=>{let t=He.getState().theme,n=Ve({...t,accent:`custom`,customAccent:e});E(n)},Kn=e=>{let t=He.getState().theme,n=Ve({...t,adaptToAccent:e});E(n)},qn=e=>{O({showUsername:e}),z.updatePreferences({showUsername:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);T.error(`Failed to update settings: `+t)})},Jn=e=>{O({showFollowUpSuggestions:e}),z.updatePreferences({showFollowUpSuggestions:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);T.error(`Failed to update settings: `+t)})},Yn=e=>{O({hapticFeedbackEnabled:e}),e&&Ue(`selection`),z.updatePreferences({hapticFeedbackEnabled:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);T.error(`Failed to update settings: `+t)})},Xn=e=>{if(!e.target.value){_.setState({selectedModel:``,selectedProviderType:null,selectedProviderId:null}),In({defaultModel:``,defaultProviderType:null,defaultProviderId:null});return}let t=g(ve,e.target.value);t&&(u(t.model,t.providerType,t.providerId),O({defaultModel:t.model,defaultProviderType:t.providerType,defaultProviderId:t.providerId}),T.success(`Default model updated`))},Zn=e=>{Qe(e.target.value)},Qn=()=>{m(Ze),In({systemMessage:Ze}),T.success(`System message updated`)},$n=async()=>{window.confirm(`Are you sure you want to delete all chat history? This action cannot be undone.`)&&(await h(),T.success(`All chat sessions deleted`))},er=async()=>{tt(!0),it(null),ke.pullAllModelsStream(e=>{it(e)},()=>{tt(!1),it(null),T.success(`All models updated successfully!`),x()},e=>{tt(!1),it(null),T.error(`Failed to update models: `+e)})},tr=e=>{let t={...D.titleSettings,autoTitle:e,taskModel:D.titleSettings?.taskModel||``};O({titleSettings:t}),z.updatePreferences({titleSettings:t})},nr=e=>{if(!e){let e={visionModel:``,visionProviderType:null,visionProviderId:null};O(e),z.updatePreferences(e);return}let t=g(Ce,e);if(!t?.providerType){T.error(I(`settings.model.visionModelNoProvider`));return}let n={visionModel:t.model,visionProviderType:t.providerType,visionProviderId:t.providerId||null};O(n),z.updatePreferences(n).catch(e=>{let t=e instanceof Error?e.message:String(e);T.error(I(`settings.model.visionModelUpdateFailed`,{error:t}))})},rr=e=>{let t=e&&e!==Rt?g(ye,e):null,n={...D.titleSettings,autoTitle:D.titleSettings?.autoTitle||!1,taskModel:t?.model||e,taskProviderType:t?.providerType||null,taskProviderId:t?.providerType===`plugin`&&t.providerId||null};O({titleSettings:n}),z.updatePreferences({titleSettings:n})},ir=(e,t)=>{bt(n=>({...n,[e]:t}))},ar=(e,t)=>{St(n=>({...n,[e]:t}))},or=(e,t)=>{Ot(n=>({...n,[e]:t}))},sr=async()=>{try{let e=qe===`model`&&a?await z.setModelGenerationOptions(a,Dt):await z.setGenerationOptions(Dt);e.success&&e.data&&(O(e.data),T.success(`Generation options updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`Failed to update generation options: `+t)}},cr=async()=>{try{let e=qe===`model`&&a?await z.setModelGenerationOptions(a,{}):await z.resetGenerationOptions();if(e.success&&e.data){O(e.data);let t=qe===`model`&&a,n=t?await kt(a):{};Ot({...e.data.generationOptions||{},...n}),T.success(t?`Loaded the settings ${a} recommends`:`Generation options reset to defaults`)}}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`Failed to reset generation options: `+t)}},lr=(e,t)=>{jt(n=>({...n,[e]:t}))},ur=[...on.map(e=>({value:e.id,label:`${e.name} (${e.pluginName||e.provider})`})),...!on.find(e=>e.id===sn.model||e.rawModel===sn.model)&&sn.model?[{value:sn.model,label:`${sn.model} (current)`}]:[]],dr=async()=>{try{let e=await z.setEmbeddingSettings(sn);e.success&&e.data&&(O(e.data),T.success(`Embedding settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`Failed to update embedding settings: `+t)}},fr=async()=>{try{let e=await z.resetEmbeddingSettings();e.success&&e.data&&(O(e.data),jt(e.data.embeddingSettings||{}),T.success(`Embedding settings reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);T.error(`Failed to reset embedding settings: `+t)}},pr={appearance:`theme dark light accent color language username follow-up background interface`,data:`export import backup clear history sessions`,about:`version license update`,models:`default model system prompt title vision auto`,generation:`temperature top_p top_k seed tokens context penalty embedding chunk similarity`,documents:`upload pdf rag document embedding`,tts:`voice speech audio speak read aloud`,"image-gen":`image generation size quality style`,plugins:`api key provider connection openai anthropic groq gemini`,search:`web search searxng internet browse sources`,shortcuts:`keyboard keys hotkeys shortcut command palette`},mr=Xe.trim().toLowerCase(),hr=e=>!mr||e.label.toLowerCase().includes(mr)||(pr[e.id]||``).includes(mr),gr=[{id:`general`,label:I(`settings.groups.general`,`General`),tabs:[{id:`appearance`,label:I(`settings.tabs.appearance`),icon:ae},{id:`data`,label:I(`settings.tabs.data`),icon:oe},{id:`shortcuts`,label:I(`settings.tabs.shortcuts`),icon:F},{id:`about`,label:I(`settings.tabs.about`),icon:pe}]},{id:`chat`,label:I(`settings.groups.chat`,`Chat`),tabs:[{id:`models`,label:I(`settings.tabs.model`),icon:le},{id:`generation`,label:I(`settings.tabs.generation`),icon:w},{id:`documents`,label:I(`settings.tabs.documents`),icon:ie}]},{id:`media`,label:I(`settings.groups.media`,`Speech & images`),tabs:[{id:`tts`,label:I(`settings.tabs.tts`),icon:he},{id:`image-gen`,label:I(`settings.tabs.imageGen`),icon:ue}]},{id:`connections`,label:I(`settings.groups.connections`,`Connections`),tabs:[{id:`plugins`,label:I(`settings.tabs.plugins`),icon:xe},...V?[{id:`search`,label:I(`settings.tabs.search`),icon:A}]:[]]}];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-0 sm:p-4 lg:p-6`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":_e,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`div`,{"data-testid":`settings-modal-panel`,className:`flex h-full w-full flex-col overscroll-behavior-contain border border-gray-200/80 bg-surface/95 shadow-2xl backdrop-blur-xl animate-scale-in dark:border-white/10 dark:bg-dark-25/95 sm:max-h-[94vh] sm:max-w-6xl sm:rounded-3xl`,children:[(0,W.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-gray-200/70 px-4 py-4 dark:border-white/[0.08] sm:px-6 sm:py-5`,children:[(0,W.jsx)(`h2`,{id:_e,className:`text-xl font-normal tracking-[-0.025em] text-gray-950 dark:text-dark-950 sm:text-2xl rtl:tracking-normal`,children:I(`settings.title`)}),(0,W.jsx)(B,{variant:`ghost`,size:`sm`,onClick:t,autoFocus:!0,className:`h-9 w-9 touch-manipulation p-0 hover:bg-gray-100 active:bg-gray-200 dark:hover:bg-white/[0.06] dark:active:bg-white/10`,title:I(`common.close`,{defaultValue:`Close`}),children:(0,W.jsx)(me,{className:`h-5 w-5 sm:h-4 sm:w-4`})})]}),(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overscroll-behavior-contain sm:flex-row`,children:[(0,W.jsxs)(`div`,{className:`w-full shrink-0 overflow-x-auto border-b border-gray-200/70 p-2 scrollbar-thin dark:border-white/[0.08] sm:w-56 sm:overflow-x-hidden sm:overflow-y-auto sm:border-b-0 sm:border-e sm:p-3 lg:w-64`,style:{WebkitOverflowScrolling:`touch`},children:[(0,W.jsxs)(`div`,{className:`relative mb-1 hidden sm:block`,children:[(0,W.jsx)(ee,{className:`pointer-events-none absolute start-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-subtle`}),(0,W.jsx)(`input`,{type:`search`,value:Xe,onChange:e=>{let t=e.target.value;H(t);let n=t.trim().toLowerCase();if(!n)return;let r=gr.flatMap(e=>e.tabs).filter(e=>e.label.toLowerCase().includes(n)||(pr[e.id]||``).includes(n));r.length>0&&!r.some(e=>e.id===We)&&Ge(r[0].id)},placeholder:I(`common.search`),className:`w-full rounded-lg border border-transparent bg-black/[0.04] py-1.5 pe-2.5 ps-8 text-[13px] text-ink placeholder:text-ink-subtle focus:border-primary-500/40 focus:outline-none dark:bg-white/[0.05]`})]}),(0,W.jsx)(`nav`,{className:`flex gap-1 sm:flex-col sm:gap-0`,role:`tablist`,"aria-label":I(`settings.title`,`Settings`),children:gr.map(e=>({...e,tabs:e.tabs.filter(hr)})).filter(e=>e.tabs.length>0).map(e=>(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-1 sm:flex-col sm:gap-0.5 sm:pb-2`,children:[(0,W.jsx)(`p`,{"aria-hidden":`true`,className:`hidden px-2.5 pb-1 pt-2 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-subtle sm:block`,children:e.label}),e.tabs.map(e=>{let t=e.icon,n=We===e.id;return(0,W.jsxs)(`button`,{onClick:()=>Ge(e.id),className:s(`flex shrink-0 items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-start transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 sm:w-full`,n?`bg-black/[0.06] text-ink dark:bg-white/[0.08]`:`text-ink-muted hover:bg-black/[0.04] hover:text-ink dark:hover:bg-white/[0.05]`),role:`tab`,"aria-selected":n,"aria-controls":`settings-tab-panel`,children:[(0,W.jsx)(t,{className:`h-4 w-4 flex-shrink-0`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`truncate whitespace-nowrap text-[13px]`,children:e.label})]},e.id)})]},e.id))})]}),(0,W.jsx)(`div`,{"data-testid":`settings-scroll-region`,className:`scroll-region min-h-0 flex-1 p-4 scrollbar-thin sm:p-6 lg:p-8`,id:`settings-tab-panel`,role:`tabpanel`,children:(()=>{switch(We){case`appearance`:return(0,W.jsx)(rt,{theme:C,preferences:D,onThemeChange:Un,onAccentChange:Wn,onCustomAccentChange:Gn,onAdaptToAccentChange:Kn,onShowUsernameChange:qn,onShowFollowUpsChange:Jn,onHapticFeedbackChange:Yn});case`models`:return(0,W.jsx)(pt,{models:i,selectedModel:a,selectedProviderType:o,selectedProviderId:l,systemMessage:d,tempSystemMessage:Ze,loading:y,preferences:D,currentVisionModel:Ae,visionModelOptions:je,currentTaskModel:be,autoTitleTaskModelOptions:Ne,updatingAllModels:et,updateProgress:nt,onModelChange:Xn,onSystemMessageChange:Zn,onSystemMessageSave:Qn,onAutoTitleChange:tr,onAutoTitleTaskModelChange:rr,onVisionModelChange:nr,onUpdateAllModels:er});case`tts`:return(0,W.jsx)(Ft,{loading:un,settings:q,effectiveSettings:Z,models:X,plugins:dn,voices:pn,testing:Ut,onSettingChange:On,onModelChange:En,onReset:jn,onTest:An,onSave:kn});case`image-gen`:return(0,W.jsx)(ft,{loading:hn,settings:J,effectiveSettings:_n,models:Q,plugins:gn,sizes:vn,qualities:yn,styles:bn,onSettingChange:Mn,onModelChange:Dn,onReset:Pn,onSave:Nn});case`documents`:return(0,W.jsx)(ot,{settings:K,effectiveSettings:sn,modelOptions:ur,status:cn,regenerating:Mt,onSettingChange:lr,onReset:fr,onRegenerate:Fn,onSave:dr});case`search`:return(0,W.jsx)(Pt,{});case`plugins`:return(0,W.jsx)(At,{plugins:te,loading:j,uploading:ne,error:M,hasKeys:an,showUploadForm:st,showJsonForm:ut,jsonInput:dt,fileInputRef:ht,expandedPluginId:gt,pluginApiKeys:yt,showApiKey:xt,savingApiKey:Ct,refreshingPluginIds:Tt,onClearError:fe,onShowUploadFormChange:ct,onShowJsonFormChange:G,onJsonInputChange:mt,onFileUpload:Ln,onJsonSubmit:Rn,onExpandedPluginChange:vt,onPluginApiKeyChange:ir,onShowApiKeyChange:ar,onActivatePlugin:zn,onRefreshModels:Bn,onDeletePlugin:Vn,onExportPlugin:Hn,onSaveApiKey:wn,onDeleteApiKey:Tn});case`data`:return(0,W.jsx)(at,{sessionCount:b.length,loading:y,importing:qt,showImportOptions:Jt,mergeStrategy:Yt,importResult:Zt,importFileInputRef:$t,onExportData:en,onImportFileSelect:tn,onClearAllHistory:$n,onMergeStrategyChange:Xt,onConfirmImport:nn,onCancelImport:rn,onDismissImportResult:()=>Qt(null)});case`shortcuts`:return(0,W.jsx)(_t,{});case`about`:return(0,W.jsx)($e,{appVersion:Lt});case`generation`:return(0,W.jsx)(lt,{generationOptions:Dt,generationScope:qe,scopedModel:a||void 0,onGenerationScopeChange:Ye,embeddingSettings:K,effectiveEmbeddingSettings:sn,embeddingModelOptions:ur,embeddingStatus:cn,onGenerationOptionChange:or,onEmbeddingSettingsChange:lr,onResetGenerationOptions:cr,onSaveGenerationOptions:sr,onResetEmbeddingSettings:fr,onSaveEmbeddingSettings:dr});default:return null}})()})]})]})})]})};export{q as SettingsModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e}from"./markdown-core-DHnR5Hw8.js";import{t}from"./utils-
|
|
1
|
+
import{d as e}from"./markdown-core-DHnR5Hw8.js";import{t}from"./utils-BM0_0iFj.js";var n=e();function r({checked:e,onChange:r,disabled:i=!1}){return(0,n.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>r(e.target.checked),disabled:i,className:`sr-only`}),(0,n.jsx)(`div`,{className:t(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2`,i?`bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed`:e?`bg-primary-600 dark:bg-primary-500`:`bg-gray-200 dark:bg-dark-300`),children:(0,n.jsx)(`span`,{className:t(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})]})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-hePW80VL.js";import{d as e,f as t}from"./markdown-core-DHnR5Hw8.js";import{t as n}from"./useTranslation-CdeLZqSW.js";import{M as r,Q as i,Qt as a,R as o,bt as s,f as c,hn as l,it as u,k as d,lt as f,mn as p,qt as m}from"./ui-vendor-xUzKqAXI.js";import{t as h}from"./workApi-CCHIEahA.js";import{o as g}from"./api-DjQINB7B.js";import{t as _}from"./utils-BhpNrGnR.js";import{t as v}from"./Button-X9TT9gTD.js";import{n as y,t as b}from"./ui-ovAoLjDQ.js";import{f as x}from"../assets/index-BN-WAt2j.js";t();var S=e(),C=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),w=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),T=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),E=e=>{if(!Number.isFinite(e)||e<0)return`—`;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${C.format(e/1024**n)} ${t[n]}`},D=e=>{if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:i>0?`${i}m`:`${Math.floor(e)}s`},O=e=>Math.min(100,Math.max(0,Number.isFinite(e)?e:0)),k=e=>{switch(e.toLowerCase()){case`running`:return`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`;case`paused`:return`bg-amber-500/10 text-amber-700 dark:text-amber-300`;case`exited`:case`dead`:return`bg-gray-500/10 text-gray-600 dark:text-dark-600`;default:return`bg-primary-500/10 text-primary-700 dark:text-primary-300`}},A=({title:e,description:t,icon:n,className:r,action:i,children:a})=>(0,S.jsxs)(`section`,{className:_(`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,r),children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,S.jsx)(`div`,{className:`mt-0.5 rounded-xl bg-primary-500/10 p-1.5 text-primary-600 dark:text-primary-300`,children:(0,S.jsx)(n,{className:`h-4 w-4`})}),(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e}),t&&(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t})]})]}),i]}),a]}),j=({label:e,value:t,mono:n})=>(0,S.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-5 border-b border-gray-100 py-2 last:border-0 dark:border-white/[0.05]`,children:[(0,S.jsx)(`dt`,{className:`shrink-0 text-xs text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`dd`,{className:_(`min-w-0 break-words text-end text-xs font-medium text-gray-800 dark:text-dark-800`,n&&`font-mono text-[11px]`),children:t})]}),M=({value:e,tone:t=`primary`})=>(0,S.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(O(e)),children:(0,S.jsx)(`div`,{className:_(`h-full rounded-full transition-[width] duration-300`,t===`warning`?`bg-amber-500 dark:bg-amber-400`:`bg-primary-500 dark:bg-primary-400`),style:{width:`${O(e)}%`}})}),N=()=>{let{t:e}=n(),{data:t,error:r,isFetching:i,refetch:a}=x({queryKey:[`work-admin-overview`],queryFn:async()=>{let t=await h.adminOverview();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1});if(!t)return r?(0,S.jsx)(A,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:p,children:(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-4 sm:px-5`,children:[(0,S.jsxs)(`div`,{className:`flex items-start gap-3 text-sm text-red-700 dark:text-red-300`,children:[(0,S.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsx)(`p`,{children:r instanceof Error&&r.message?r.message:e(`systemPage.loadFailed`)})]}),(0,S.jsx)(v,{variant:`outline`,size:`sm`,onClick:()=>void a(),disabled:i,children:e(`common.retry`)})]})}):null;let o=t=>e(t===null?`systemPage.work.stateUnknown`:t?`systemPage.work.stateRunning`:`systemPage.work.stateStopped`),s=t=>t===`running`?e(`systemPage.work.stateRunning`):t===`starting`?e(`systemPage.work.stateStarting`):`—`;return(0,S.jsxs)(A,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:p,action:(0,S.jsxs)(`span`,{className:_(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,t.runtimeAvailable?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,S.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,t.runtimeAvailable?`bg-emerald-500`:`bg-gray-400`)}),t.runtimeAvailable?e(`systemPage.work.runtimeAvailable`):e(`systemPage.work.runtimeUnavailable`)]}),children:[(0,S.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[e(`systemPage.work.access`),t.accessMode===`all-users`?e(`systemPage.work.accessAllUsers`):e(`systemPage.work.accessAdmins`)],[e(`systemPage.work.activeRuntimes`),`${t.admission.activeGlobal} / ${t.admission.maxGlobal}`],[e(`systemPage.work.pendingCleanups`),t.recoveryPending],[e(`systemPage.work.orphans`),t.orphanContainers.length]].map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),!t.runtimeAvailable&&t.runtimeReason&&(0,S.jsxs)(`div`,{className:`mx-4 mt-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:mx-5`,children:[(0,S.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsx)(`p`,{children:t.runtimeReason})]}),t.tasks.length===0?(0,S.jsx)(`p`,{className:`px-4 py-4 text-sm text-gray-500 dark:text-dark-500 sm:px-5`,children:e(`systemPage.work.noTasks`)}):(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{"data-testid":`system-work-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,S.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`systemPage.work.owner`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.task`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.state`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.preview`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.terminals`)}),(0,S.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`systemPage.work.updated`)})]})}),(0,S.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:t.tasks.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-gray-800 dark:text-dark-800`,children:e.ownerUsername}),(0,S.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,S.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.title}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.model})]}),(0,S.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,S.jsxs)(`span`,{className:_(`inline-flex items-center gap-1.5 text-xs`,e.running?`text-emerald-700 dark:text-emerald-300`:`text-gray-600 dark:text-dark-600`),children:[(0,S.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,e.running===null?`bg-amber-400`:e.running?`bg-emerald-500`:`bg-gray-400`)}),o(e.running)]})}),(0,S.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:s(e.previewStatus)}),(0,S.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:e.terminalSessions}),(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-600 dark:text-dark-600`,children:T.format(e.updatedAt)})]},e.id))})]})})]})},P=()=>{let{t:e}=n(),{data:t,error:r,isLoading:i,isFetching:a,refetch:s}=x({queryKey:[`system-diagnostics`],queryFn:async()=>{let t=await g.getDiagnostics();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1}),l=r?r instanceof Error?r.message:e(`systemPage.loadFailed`):null;return i&&!t?(0,S.jsx)(y,{width:`wide`,children:(0,S.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,S.jsx)(f,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,S.jsxs)(y,{width:`wide`,children:[(0,S.jsx)(b,{eyebrow:e(`systemPage.eyebrow`),title:e(`systemPage.title`),description:e(`systemPage.description`),actions:(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,S.jsx)(`span`,{className:`hidden text-xs text-gray-500 dark:text-dark-500 sm:inline`,children:e(`systemPage.updated`,{date:T.format(t.generatedAt)})}),(0,S.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>void s(),disabled:a,children:[(0,S.jsx)(o,{className:_(`h-4 w-4`,a&&`animate-spin`)}),(0,S.jsx)(`span`,{className:`sr-only`,children:e(`systemPage.refresh`)})]})]})}),l&&(0,S.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,S.jsx)(c,{className:`h-4 w-4 shrink-0`}),(0,S.jsx)(`span`,{children:l})]}),t&&(0,S.jsxs)(`div`,{"data-testid":`system-dashboard`,className:`space-y-4`,children:[(0,S.jsx)(F,{diagnostics:t}),(0,S.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,S.jsx)(I,{diagnostics:t}),(0,S.jsx)(L,{diagnostics:t})]}),(0,S.jsx)(R,{diagnostics:t}),(0,S.jsx)(z,{diagnostics:t}),(0,S.jsx)(N,{}),(0,S.jsx)(V,{diagnostics:t}),(0,S.jsxs)(`div`,{className:`flex items-start gap-2 px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:[(0,S.jsx)(d,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary-500`}),(0,S.jsx)(`p`,{children:e(`systemPage.securityNote`)})]})]})]})},F=({diagnostics:e})=>{let{t}=n(),r=e.filesystems.find(e=>e.label===`Data directory`)??e.filesystems[0],i=[{label:t(`systemPage.cards.uptime`),value:D(e.host.uptimeSeconds),detail:t(`systemPage.cards.uptimeDetail`,{date:T.format(e.host.bootedAt)}),icon:a},{label:t(`systemPage.cards.memory`),value:`${w.format(e.memory.usedPercent)}%`,detail:t(`systemPage.cards.memoryDetail`,{used:E(e.memory.usedBytes),total:E(e.memory.totalBytes)}),icon:u},{label:t(`systemPage.cards.freeSpace`),value:r?E(r.freeBytes):`—`,detail:r?t(`systemPage.cards.freeSpaceDetail`,{label:r.label,total:E(r.totalBytes)}):t(`systemPage.cards.unavailable`),icon:s},{label:t(`systemPage.cards.containers`),value:e.docker.available?String(e.docker.runningContainers):`—`,detail:e.docker.available?t(`systemPage.cards.containersDetail`,{total:e.docker.totalContainers}):t(`systemPage.cards.dockerUnavailable`),icon:m}];return(0,S.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:i.map(e=>{let t=e.icon;return(0,S.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,S.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,S.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,S.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})})},I=({diagnostics:e})=>{let{t}=n(),{host:i,runtime:a}=e;return(0,S.jsx)(A,{title:t(`systemPage.host.title`),description:t(`systemPage.host.description`),icon:r,action:(0,S.jsx)(`span`,{className:`rounded-full bg-primary-500/10 px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em] text-primary-700 dark:text-primary-300`,children:i.containerized?t(`systemPage.host.container`):t(`systemPage.host.native`)}),children:(0,S.jsxs)(`dl`,{className:`px-4 py-2 sm:px-5`,children:[(0,S.jsx)(j,{label:t(`systemPage.host.hostname`),value:i.hostname}),(0,S.jsx)(j,{label:t(`systemPage.host.operatingSystem`),value:`${i.platform} ${i.release} · ${i.architecture}`}),(0,S.jsx)(j,{label:t(`systemPage.host.processor`),value:`${i.cpuModel} · ${i.logicalCpus} ${t(`systemPage.host.logicalCpus`)}`}),(0,S.jsx)(j,{label:t(`systemPage.host.loadAverage`),value:i.loadAverage.map(e=>w.format(e)).join(` · `)}),(0,S.jsx)(j,{label:t(`systemPage.host.libreVersion`),value:a.appVersion}),(0,S.jsx)(j,{label:t(`systemPage.host.nodeVersion`),value:a.nodeVersion}),(0,S.jsx)(j,{label:t(`systemPage.host.process`),value:`PID ${a.processId} · ${D(a.processUptimeSeconds)}`}),(0,S.jsx)(j,{label:t(`systemPage.host.workingDirectory`),value:a.workingDirectory,mono:!0})]})})},L=({diagnostics:e})=>{let{t}=n(),{memory:r}=e;return(0,S.jsx)(A,{title:t(`systemPage.memory.title`),description:t(`systemPage.memory.description`),icon:u,children:(0,S.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-2 flex items-end justify-between gap-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`text-2xl tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:[w.format(r.usedPercent),`%`]}),(0,S.jsx)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.usedOf`,{used:E(r.usedBytes),total:E(r.totalBytes)})})]}),(0,S.jsx)(`span`,{className:`text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.free`,{value:E(r.freeBytes)})})]}),(0,S.jsx)(M,{value:r.usedPercent,tone:r.usedPercent>=85?`warning`:`primary`})]}),(0,S.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[t(`systemPage.memory.processRss`),r.processRssBytes],[t(`systemPage.memory.heapUsed`),r.heapUsedBytes],[t(`systemPage.memory.heapTotal`),r.heapTotalBytes],[t(`systemPage.memory.external`),r.externalBytes]].map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-lg text-gray-950 dark:text-dark-950`,children:E(Number(t))})]},String(e)))})]})})},R=({diagnostics:e})=>{let{t}=n();return(0,S.jsx)(A,{title:t(`systemPage.storage.title`),description:t(`systemPage.storage.description`),icon:s,children:e.filesystems.length===0?(0,S.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.storage.empty`)}):(0,S.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5`,children:e.filesystems.map(e=>(0,S.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e.label}),(0,S.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.path})]}),(0,S.jsxs)(`span`,{className:`shrink-0 text-sm tabular-nums text-gray-700 dark:text-dark-700`,children:[w.format(e.usedPercent),`%`]})]}),(0,S.jsx)(`div`,{className:`mt-4`,children:(0,S.jsx)(M,{value:e.usedPercent,tone:e.usedPercent>=85?`warning`:`primary`})}),(0,S.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,S.jsx)(`span`,{children:t(`systemPage.storage.used`,{value:E(e.usedBytes)})}),(0,S.jsx)(`span`,{children:t(`systemPage.storage.free`,{value:E(e.freeBytes)})})]})]},`${e.label}:${e.path}`))})})},z=({diagnostics:e})=>{let{t}=n(),{docker:r}=e;return(0,S.jsx)(A,{title:t(`systemPage.docker.title`),description:t(`systemPage.docker.description`),icon:m,action:(0,S.jsxs)(`span`,{className:_(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,r.available?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,S.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,r.available?`bg-emerald-500`:`bg-gray-400`)}),r.available?t(`systemPage.docker.connected`):t(`systemPage.docker.unavailable`)]}),children:r.available?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[t(`systemPage.docker.running`),r.runningContainers],[t(`systemPage.docker.stopped`),r.stoppedContainers],[t(`systemPage.docker.paused`),r.pausedContainers],[t(`systemPage.docker.total`),r.totalContainers]].map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),(0,S.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-4 sm:px-5`,children:[r.serverVersion&&(0,S.jsx)(B,{label:t(`systemPage.docker.version`),value:r.serverVersion}),r.operatingSystem&&(0,S.jsx)(B,{label:t(`systemPage.docker.host`),value:r.operatingSystem}),r.architecture&&(0,S.jsx)(B,{label:t(`systemPage.docker.architecture`),value:r.architecture}),r.logicalCpus!==void 0&&(0,S.jsx)(B,{label:t(`systemPage.docker.cpus`),value:String(r.logicalCpus)}),r.memoryBytes!==void 0&&(0,S.jsx)(B,{label:t(`systemPage.docker.memory`),value:E(r.memoryBytes)})]}),r.containers.length===0?(0,S.jsx)(`p`,{className:`px-5 pb-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.empty`)}):(0,S.jsx)(`div`,{className:`overflow-x-auto border-t border-gray-200/70 dark:border-white/[0.07]`,children:(0,S.jsxs)(`table`,{"data-testid":`system-docker-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,S.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:t(`systemPage.docker.container`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.image`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.state`)}),(0,S.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:t(`systemPage.docker.created`)})]})}),(0,S.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:r.containers.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,S.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.id})]}),(0,S.jsx)(`td`,{className:`max-w-[280px] px-4 py-2.5`,children:(0,S.jsx)(`div`,{className:`truncate font-mono text-[11px] text-gray-600 dark:text-dark-600`,title:e.image,children:e.image})}),(0,S.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,S.jsx)(`span`,{className:_(`inline-flex rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.08em]`,k(e.state)),children:e.state}),(0,S.jsx)(`div`,{className:`mt-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:e.status})]}),(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-500 dark:text-dark-500`,children:e.createdAt?T.format(e.createdAt):`—`})]},e.id))})]})})]}):(0,S.jsxs)(`div`,{className:`m-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:m-5`,children:[(0,S.jsx)(c,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{children:r.reason||t(`systemPage.docker.unavailableDetail`)}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.socketStatus`,{status:r.socketMounted?t(`systemPage.docker.mounted`):t(`systemPage.docker.notMounted`)})})]})]})})},B=({label:e,value:t})=>(0,S.jsxs)(`span`,{className:`rounded-full border border-gray-200 bg-white px-3 py-1.5 text-[11px] text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/70 dark:text-dark-600`,children:[(0,S.jsx)(`span`,{className:`text-gray-400 dark:text-dark-500`,children:e}),` `,t]}),V=({diagnostics:e})=>{let{t}=n();return(0,S.jsx)(A,{title:t(`systemPage.network.title`),description:t(`systemPage.network.description`),icon:i,children:e.network.interfaces.length===0?(0,S.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.network.empty`)}):(0,S.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5 xl:grid-cols-3`,children:e.network.interfaces.map(e=>(0,S.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(l,{className:`h-4 w-4 text-primary-500`}),(0,S.jsx)(`h3`,{className:`font-mono text-xs font-medium text-gray-900 dark:text-dark-900`,children:e.name})]}),(0,S.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.addresses.map(e=>(0,S.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-white px-3 py-2 dark:bg-dark-100/80`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-gray-400 dark:text-dark-500`,children:e.family}),e.internal&&(0,S.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`systemPage.network.internal`)})]}),(0,S.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-gray-700 dark:text-dark-700`,children:e.cidr||e.address})]},`${e.family}:${e.address}`))}),(e.receivedBytes!==void 0||e.transmittedBytes!==void 0)&&(0,S.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[10px] text-gray-500 dark:text-dark-500`,children:[(0,S.jsxs)(`span`,{children:[`↓ `,E(e.receivedBytes??0)]}),(0,S.jsxs)(`span`,{children:[`↑ `,E(e.transmittedBytes??0)]})]})]},e.name))})})};export{P as default};
|
|
1
|
+
import"./rolldown-runtime-hePW80VL.js";import{d as e,f as t}from"./markdown-core-DHnR5Hw8.js";import{t as n}from"./useTranslation-CXY69qNk.js";import{t as r}from"./utils-BM0_0iFj.js";import{M as i,Q as a,Qt as o,R as s,bt as c,f as l,hn as u,it as d,k as f,lt as p,mn as m,qt as h}from"./ui-vendor-xUzKqAXI.js";import{t as g}from"./workApi-BOS7crs9.js";import{o as _}from"./api-CLEmGcEh.js";import{t as v}from"./Button-CTXHujOd.js";import{n as y,t as b}from"./ui-BnDZpjfc.js";import{f as x}from"../assets/index-BBpNbfKW.js";t();var S=e(),C=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),w=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),T=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),E=e=>{if(!Number.isFinite(e)||e<0)return`—`;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${C.format(e/1024**n)} ${t[n]}`},D=e=>{if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:i>0?`${i}m`:`${Math.floor(e)}s`},O=e=>Math.min(100,Math.max(0,Number.isFinite(e)?e:0)),k=e=>{switch(e.toLowerCase()){case`running`:return`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`;case`paused`:return`bg-amber-500/10 text-amber-700 dark:text-amber-300`;case`exited`:case`dead`:return`bg-gray-500/10 text-gray-600 dark:text-dark-600`;default:return`bg-primary-500/10 text-primary-700 dark:text-primary-300`}},A=({title:e,description:t,icon:n,className:i,action:a,children:o})=>(0,S.jsxs)(`section`,{className:r(`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,i),children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,S.jsx)(`div`,{className:`mt-0.5 rounded-xl bg-primary-500/10 p-1.5 text-primary-600 dark:text-primary-300`,children:(0,S.jsx)(n,{className:`h-4 w-4`})}),(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e}),t&&(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t})]})]}),a]}),o]}),j=({label:e,value:t,mono:n})=>(0,S.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-5 border-b border-gray-100 py-2 last:border-0 dark:border-white/[0.05]`,children:[(0,S.jsx)(`dt`,{className:`shrink-0 text-xs text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`dd`,{className:r(`min-w-0 break-words text-end text-xs font-medium text-gray-800 dark:text-dark-800`,n&&`font-mono text-[11px]`),children:t})]}),M=({value:e,tone:t=`primary`})=>(0,S.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(O(e)),children:(0,S.jsx)(`div`,{className:r(`h-full rounded-full transition-[width] duration-300`,t===`warning`?`bg-amber-500 dark:bg-amber-400`:`bg-primary-500 dark:bg-primary-400`),style:{width:`${O(e)}%`}})}),N=()=>{let{t:e}=n(),{data:t,error:i,isFetching:a,refetch:o}=x({queryKey:[`work-admin-overview`],queryFn:async()=>{let t=await g.adminOverview();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1});if(!t)return i?(0,S.jsx)(A,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:m,children:(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-4 sm:px-5`,children:[(0,S.jsxs)(`div`,{className:`flex items-start gap-3 text-sm text-red-700 dark:text-red-300`,children:[(0,S.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsx)(`p`,{children:i instanceof Error&&i.message?i.message:e(`systemPage.loadFailed`)})]}),(0,S.jsx)(v,{variant:`outline`,size:`sm`,onClick:()=>void o(),disabled:a,children:e(`common.retry`)})]})}):null;let s=t=>e(t===null?`systemPage.work.stateUnknown`:t?`systemPage.work.stateRunning`:`systemPage.work.stateStopped`),c=t=>t===`running`?e(`systemPage.work.stateRunning`):t===`starting`?e(`systemPage.work.stateStarting`):`—`;return(0,S.jsxs)(A,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:m,action:(0,S.jsxs)(`span`,{className:r(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,t.runtimeAvailable?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,S.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,t.runtimeAvailable?`bg-emerald-500`:`bg-gray-400`)}),t.runtimeAvailable?e(`systemPage.work.runtimeAvailable`):e(`systemPage.work.runtimeUnavailable`)]}),children:[(0,S.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[e(`systemPage.work.access`),t.accessMode===`all-users`?e(`systemPage.work.accessAllUsers`):e(`systemPage.work.accessAdmins`)],[e(`systemPage.work.activeRuntimes`),`${t.admission.activeGlobal} / ${t.admission.maxGlobal}`],[e(`systemPage.work.pendingCleanups`),t.recoveryPending],[e(`systemPage.work.orphans`),t.orphanContainers.length]].map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),!t.runtimeAvailable&&t.runtimeReason&&(0,S.jsxs)(`div`,{className:`mx-4 mt-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:mx-5`,children:[(0,S.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsx)(`p`,{children:t.runtimeReason})]}),t.tasks.length===0?(0,S.jsx)(`p`,{className:`px-4 py-4 text-sm text-gray-500 dark:text-dark-500 sm:px-5`,children:e(`systemPage.work.noTasks`)}):(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{"data-testid":`system-work-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,S.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`systemPage.work.owner`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.task`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.state`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.preview`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.terminals`)}),(0,S.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`systemPage.work.updated`)})]})}),(0,S.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:t.tasks.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-gray-800 dark:text-dark-800`,children:e.ownerUsername}),(0,S.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,S.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.title}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.model})]}),(0,S.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,S.jsxs)(`span`,{className:r(`inline-flex items-center gap-1.5 text-xs`,e.running?`text-emerald-700 dark:text-emerald-300`:`text-gray-600 dark:text-dark-600`),children:[(0,S.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,e.running===null?`bg-amber-400`:e.running?`bg-emerald-500`:`bg-gray-400`)}),s(e.running)]})}),(0,S.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:c(e.previewStatus)}),(0,S.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:e.terminalSessions}),(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-600 dark:text-dark-600`,children:T.format(e.updatedAt)})]},e.id))})]})})]})},P=()=>{let{t:e}=n(),{data:t,error:i,isLoading:a,isFetching:o,refetch:c}=x({queryKey:[`system-diagnostics`],queryFn:async()=>{let t=await _.getDiagnostics();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1}),u=i?i instanceof Error?i.message:e(`systemPage.loadFailed`):null;return a&&!t?(0,S.jsx)(y,{width:`wide`,children:(0,S.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,S.jsx)(p,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,S.jsxs)(y,{width:`wide`,children:[(0,S.jsx)(b,{eyebrow:e(`systemPage.eyebrow`),title:e(`systemPage.title`),description:e(`systemPage.description`),actions:(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,S.jsx)(`span`,{className:`hidden text-xs text-gray-500 dark:text-dark-500 sm:inline`,children:e(`systemPage.updated`,{date:T.format(t.generatedAt)})}),(0,S.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>void c(),disabled:o,children:[(0,S.jsx)(s,{className:r(`h-4 w-4`,o&&`animate-spin`)}),(0,S.jsx)(`span`,{className:`sr-only`,children:e(`systemPage.refresh`)})]})]})}),u&&(0,S.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,S.jsx)(l,{className:`h-4 w-4 shrink-0`}),(0,S.jsx)(`span`,{children:u})]}),t&&(0,S.jsxs)(`div`,{"data-testid":`system-dashboard`,className:`space-y-4`,children:[(0,S.jsx)(F,{diagnostics:t}),(0,S.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,S.jsx)(I,{diagnostics:t}),(0,S.jsx)(L,{diagnostics:t})]}),(0,S.jsx)(R,{diagnostics:t}),(0,S.jsx)(z,{diagnostics:t}),(0,S.jsx)(N,{}),(0,S.jsx)(V,{diagnostics:t}),(0,S.jsxs)(`div`,{className:`flex items-start gap-2 px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:[(0,S.jsx)(f,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary-500`}),(0,S.jsx)(`p`,{children:e(`systemPage.securityNote`)})]})]})]})},F=({diagnostics:e})=>{let{t}=n(),r=e.filesystems.find(e=>e.label===`Data directory`)??e.filesystems[0],i=[{label:t(`systemPage.cards.uptime`),value:D(e.host.uptimeSeconds),detail:t(`systemPage.cards.uptimeDetail`,{date:T.format(e.host.bootedAt)}),icon:o},{label:t(`systemPage.cards.memory`),value:`${w.format(e.memory.usedPercent)}%`,detail:t(`systemPage.cards.memoryDetail`,{used:E(e.memory.usedBytes),total:E(e.memory.totalBytes)}),icon:d},{label:t(`systemPage.cards.freeSpace`),value:r?E(r.freeBytes):`—`,detail:r?t(`systemPage.cards.freeSpaceDetail`,{label:r.label,total:E(r.totalBytes)}):t(`systemPage.cards.unavailable`),icon:c},{label:t(`systemPage.cards.containers`),value:e.docker.available?String(e.docker.runningContainers):`—`,detail:e.docker.available?t(`systemPage.cards.containersDetail`,{total:e.docker.totalContainers}):t(`systemPage.cards.dockerUnavailable`),icon:h}];return(0,S.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:i.map(e=>{let t=e.icon;return(0,S.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,S.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,S.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,S.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})})},I=({diagnostics:e})=>{let{t}=n(),{host:r,runtime:a}=e;return(0,S.jsx)(A,{title:t(`systemPage.host.title`),description:t(`systemPage.host.description`),icon:i,action:(0,S.jsx)(`span`,{className:`rounded-full bg-primary-500/10 px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em] text-primary-700 dark:text-primary-300`,children:r.containerized?t(`systemPage.host.container`):t(`systemPage.host.native`)}),children:(0,S.jsxs)(`dl`,{className:`px-4 py-2 sm:px-5`,children:[(0,S.jsx)(j,{label:t(`systemPage.host.hostname`),value:r.hostname}),(0,S.jsx)(j,{label:t(`systemPage.host.operatingSystem`),value:`${r.platform} ${r.release} · ${r.architecture}`}),(0,S.jsx)(j,{label:t(`systemPage.host.processor`),value:`${r.cpuModel} · ${r.logicalCpus} ${t(`systemPage.host.logicalCpus`)}`}),(0,S.jsx)(j,{label:t(`systemPage.host.loadAverage`),value:r.loadAverage.map(e=>w.format(e)).join(` · `)}),(0,S.jsx)(j,{label:t(`systemPage.host.libreVersion`),value:a.appVersion}),(0,S.jsx)(j,{label:t(`systemPage.host.nodeVersion`),value:a.nodeVersion}),(0,S.jsx)(j,{label:t(`systemPage.host.process`),value:`PID ${a.processId} · ${D(a.processUptimeSeconds)}`}),(0,S.jsx)(j,{label:t(`systemPage.host.workingDirectory`),value:a.workingDirectory,mono:!0})]})})},L=({diagnostics:e})=>{let{t}=n(),{memory:r}=e;return(0,S.jsx)(A,{title:t(`systemPage.memory.title`),description:t(`systemPage.memory.description`),icon:d,children:(0,S.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-2 flex items-end justify-between gap-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`text-2xl tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:[w.format(r.usedPercent),`%`]}),(0,S.jsx)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.usedOf`,{used:E(r.usedBytes),total:E(r.totalBytes)})})]}),(0,S.jsx)(`span`,{className:`text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.free`,{value:E(r.freeBytes)})})]}),(0,S.jsx)(M,{value:r.usedPercent,tone:r.usedPercent>=85?`warning`:`primary`})]}),(0,S.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[t(`systemPage.memory.processRss`),r.processRssBytes],[t(`systemPage.memory.heapUsed`),r.heapUsedBytes],[t(`systemPage.memory.heapTotal`),r.heapTotalBytes],[t(`systemPage.memory.external`),r.externalBytes]].map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-lg text-gray-950 dark:text-dark-950`,children:E(Number(t))})]},String(e)))})]})})},R=({diagnostics:e})=>{let{t}=n();return(0,S.jsx)(A,{title:t(`systemPage.storage.title`),description:t(`systemPage.storage.description`),icon:c,children:e.filesystems.length===0?(0,S.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.storage.empty`)}):(0,S.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5`,children:e.filesystems.map(e=>(0,S.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e.label}),(0,S.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.path})]}),(0,S.jsxs)(`span`,{className:`shrink-0 text-sm tabular-nums text-gray-700 dark:text-dark-700`,children:[w.format(e.usedPercent),`%`]})]}),(0,S.jsx)(`div`,{className:`mt-4`,children:(0,S.jsx)(M,{value:e.usedPercent,tone:e.usedPercent>=85?`warning`:`primary`})}),(0,S.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,S.jsx)(`span`,{children:t(`systemPage.storage.used`,{value:E(e.usedBytes)})}),(0,S.jsx)(`span`,{children:t(`systemPage.storage.free`,{value:E(e.freeBytes)})})]})]},`${e.label}:${e.path}`))})})},z=({diagnostics:e})=>{let{t}=n(),{docker:i}=e;return(0,S.jsx)(A,{title:t(`systemPage.docker.title`),description:t(`systemPage.docker.description`),icon:h,action:(0,S.jsxs)(`span`,{className:r(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,i.available?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,S.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,i.available?`bg-emerald-500`:`bg-gray-400`)}),i.available?t(`systemPage.docker.connected`):t(`systemPage.docker.unavailable`)]}),children:i.available?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[t(`systemPage.docker.running`),i.runningContainers],[t(`systemPage.docker.stopped`),i.stoppedContainers],[t(`systemPage.docker.paused`),i.pausedContainers],[t(`systemPage.docker.total`),i.totalContainers]].map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),(0,S.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-4 sm:px-5`,children:[i.serverVersion&&(0,S.jsx)(B,{label:t(`systemPage.docker.version`),value:i.serverVersion}),i.operatingSystem&&(0,S.jsx)(B,{label:t(`systemPage.docker.host`),value:i.operatingSystem}),i.architecture&&(0,S.jsx)(B,{label:t(`systemPage.docker.architecture`),value:i.architecture}),i.logicalCpus!==void 0&&(0,S.jsx)(B,{label:t(`systemPage.docker.cpus`),value:String(i.logicalCpus)}),i.memoryBytes!==void 0&&(0,S.jsx)(B,{label:t(`systemPage.docker.memory`),value:E(i.memoryBytes)})]}),i.containers.length===0?(0,S.jsx)(`p`,{className:`px-5 pb-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.empty`)}):(0,S.jsx)(`div`,{className:`overflow-x-auto border-t border-gray-200/70 dark:border-white/[0.07]`,children:(0,S.jsxs)(`table`,{"data-testid":`system-docker-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,S.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:t(`systemPage.docker.container`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.image`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.state`)}),(0,S.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:t(`systemPage.docker.created`)})]})}),(0,S.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:i.containers.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,S.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.id})]}),(0,S.jsx)(`td`,{className:`max-w-[280px] px-4 py-2.5`,children:(0,S.jsx)(`div`,{className:`truncate font-mono text-[11px] text-gray-600 dark:text-dark-600`,title:e.image,children:e.image})}),(0,S.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,S.jsx)(`span`,{className:r(`inline-flex rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.08em]`,k(e.state)),children:e.state}),(0,S.jsx)(`div`,{className:`mt-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:e.status})]}),(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-500 dark:text-dark-500`,children:e.createdAt?T.format(e.createdAt):`—`})]},e.id))})]})})]}):(0,S.jsxs)(`div`,{className:`m-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:m-5`,children:[(0,S.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{children:i.reason||t(`systemPage.docker.unavailableDetail`)}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.socketStatus`,{status:i.socketMounted?t(`systemPage.docker.mounted`):t(`systemPage.docker.notMounted`)})})]})]})})},B=({label:e,value:t})=>(0,S.jsxs)(`span`,{className:`rounded-full border border-gray-200 bg-white px-3 py-1.5 text-[11px] text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/70 dark:text-dark-600`,children:[(0,S.jsx)(`span`,{className:`text-gray-400 dark:text-dark-500`,children:e}),` `,t]}),V=({diagnostics:e})=>{let{t}=n();return(0,S.jsx)(A,{title:t(`systemPage.network.title`),description:t(`systemPage.network.description`),icon:a,children:e.network.interfaces.length===0?(0,S.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.network.empty`)}):(0,S.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5 xl:grid-cols-3`,children:e.network.interfaces.map(e=>(0,S.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(u,{className:`h-4 w-4 text-primary-500`}),(0,S.jsx)(`h3`,{className:`font-mono text-xs font-medium text-gray-900 dark:text-dark-900`,children:e.name})]}),(0,S.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.addresses.map(e=>(0,S.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-white px-3 py-2 dark:bg-dark-100/80`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-gray-400 dark:text-dark-500`,children:e.family}),e.internal&&(0,S.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`systemPage.network.internal`)})]}),(0,S.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-gray-700 dark:text-dark-700`,children:e.cidr||e.address})]},`${e.family}:${e.address}`))}),(e.receivedBytes!==void 0||e.transmittedBytes!==void 0)&&(0,S.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[10px] text-gray-500 dark:text-dark-500`,children:[(0,S.jsxs)(`span`,{children:[`↓ `,E(e.receivedBytes??0)]}),(0,S.jsxs)(`span`,{children:[`↑ `,E(e.transmittedBytes??0)]})]})]},e.name))})})};export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CdeLZqSW.js";import{B as i,O as a,Qt as o,Tn as s,W as c,c as l,m as u,u as d,w as f}from"./ui-vendor-xUzKqAXI.js";import{t as p}from"./logger-DSXjF4ye.js";import{t as m}from"./workApi-CCHIEahA.js";import{h,p as g,v as _,w as v}from"./api-DjQINB7B.js";import{n as y}from"./authStore-pmXfK_qt.js";import{t as b}from"./Button-X9TT9gTD.js";import{a as x,c as S,i as C,n as w,o as T,p as E,r as D,s as O,t as k}from"./ui-ovAoLjDQ.js";import{f as A,m as j}from"../assets/index-BN-WAt2j.js";import{t as M}from"./SettingsToggle-bZ5W4CCf.js";var N=e(n(),1),P=t(),F=p(`components:user-manager`),I=()=>{let{t:e}=r(),t=j(),[n,c]=(0,N.useState)(!1),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)({username:``,email:``,password:``,role:`user`}),{user:_}=y(),{data:w=[],isLoading:k}=A({queryKey:[`users`],queryFn:async()=>{let t=await v.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),M=()=>t.invalidateQueries({queryKey:[`users`]}),I=w.filter(e=>e.status===`pending`),L=w.filter(e=>e.status!==`pending`),R=async t=>{t.preventDefault();try{let t=await v.createUser(h);t.success&&t.data&&(await M(),g({username:``,email:``,password:``,role:`user`}),c(!1),s.success(e(`userManager.form.createSuccess`)))}catch(t){F.error(`Error creating user:`,t);let n=e(`userManager.form.createFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.createFailed`)),s.error(n)}},z=async t=>{if(t.preventDefault(),p)try{let t={username:h.username,email:h.email,role:h.role};h.password&&h.password.trim()!==``&&(t.password=h.password);let n=await v.updateUser(p.id,t);n.success&&n.data&&(await M(),m(null),g({username:``,email:``,password:``,role:`user`}),s.success(e(`userManager.form.updateSuccess`)))}catch(t){F.error(`Error updating user:`,t);let n=e(`userManager.form.updateFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.updateFailed`)),s.error(n)}},B=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await v.deleteUser(t)).success&&(await M(),s.success(e(`userManager.deleteSuccess`)))}catch(t){F.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),s.error(n)}},V=async t=>{try{let n=await v.approveUser(t.id);n.success&&n.data&&(await M(),s.success(e(`userManager.approval.approved`,{name:t.username,defaultValue:`{{name}} can now sign in.`})))}catch(t){F.error(`Error approving user:`,t);let n=t;s.error(n.response?.data?.message||e(`userManager.approval.failed`,`The account could not be approved.`))}},H=e=>{m(e),g({username:e.username,email:e.email||``,password:``,role:e.role})};return k?(0,P.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,P.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-gray-600 border-t-primary-500 rounded-full animate-spin`})}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,P.jsx)(`div`,{}),(0,P.jsxs)(b,{onClick:()=>c(!n),className:`flex items-center space-x-2 bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600`,children:[(0,P.jsx)(i,{size:16}),(0,P.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,P.jsxs)(D,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,P.jsxs)(T,{children:[(0,P.jsx)(O,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,P.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,P.jsx)(C,{children:(0,P.jsxs)(`form`,{onSubmit:R,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,P.jsx)(E,{id:`username`,value:h.username,onChange:e=>g({...h,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,P.jsx)(E,{id:`email`,type:`email`,value:h.email,onChange:e=>g({...h,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,P.jsx)(E,{id:`password`,type:`password`,value:h.password,onChange:e=>g({...h,password:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,P.jsxs)(`select`,{id:`role`,value:h.role,onChange:e=>g({...h,role:e.target.value}),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200`,children:[(0,P.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,P.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,P.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,P.jsx)(b,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,P.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>{g({username:``,email:``,password:``,role:`user`}),c(!1)},children:e(`common.cancel`)})]})]})})]}),p&&(0,P.jsxs)(D,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,P.jsxs)(T,{children:[(0,P.jsxs)(O,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,p.username]}),(0,P.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,P.jsx)(C,{children:(0,P.jsxs)(`form`,{onSubmit:z,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,P.jsx)(E,{id:`edit-username`,value:h.username,onChange:e=>g({...h,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,P.jsx)(E,{id:`edit-email`,type:`email`,value:h.email,onChange:e=>g({...h,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(S,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,P.jsx)(E,{id:`edit-password`,type:`password`,value:h.password,onChange:e=>g({...h,password:e.target.value}),placeholder:e(`userManager.form.passwordHint`),className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,P.jsxs)(`select`,{id:`edit-role`,value:h.role,onChange:e=>g({...h,role:e.target.value}),disabled:p?.id===_?.id&&_?.role===`admin`,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,P.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),p?.id===_?.id&&_?.role===`admin`&&(0,P.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,P.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,P.jsx)(b,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,P.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>{m(null),g({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),I.length>0&&(0,P.jsxs)(D,{"data-testid":`pending-user-approvals`,className:`border border-warning-500/30 bg-warning-500/[0.06] shadow-lg`,children:[(0,P.jsxs)(T,{children:[(0,P.jsxs)(O,{className:`flex items-center gap-2 text-gray-900 dark:text-gray-100`,children:[(0,P.jsx)(o,{className:`h-5 w-5 text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`,`Pending approvals`),` (`,I.length,`)`]}),(0,P.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.approval.description`,`Review new registrations before allowing them into this instance.`)})]}),(0,P.jsx)(C,{children:(0,P.jsx)(`div`,{className:`space-y-3`,children:I.map(t=>(0,P.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-4 rounded-xl border border-warning-500/25 bg-surface p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`h3`,{className:`truncate font-medium text-ink`,children:t.username}),(0,P.jsx)(`p`,{className:`truncate text-sm text-ink-muted`,children:t.email||e(`userManager.noEmail`)}),(0,P.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(`userManager.approval.registered`,`Registered`),`:`,` `,new Date(t.createdAt).toLocaleString()]})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,P.jsxs)(b,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void V(t),className:`gap-2`,children:[(0,P.jsx)(d,{size:16}),e(`userManager.approval.activate`,`Activate account`)]}),(0,P.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e(`userManager.approval.reject`,`Reject registration`),onClick:()=>void B(t.id,t.username),className:`text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-900/20 dark:hover:text-red-300`,children:(0,P.jsx)(u,{size:16})})]})]},t.id))})})]}),(0,P.jsxs)(D,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,P.jsxs)(T,{children:[(0,P.jsxs)(O,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,L.length,`)`]}),(0,P.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,P.jsx)(C,{children:(0,P.jsx)(`div`,{className:`space-y-3`,children:L.map(t=>(0,P.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,P.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,P.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,P.jsx)(a,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,P.jsx)(l,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===_?.id&&(0,P.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,P.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[t.email||e(`userManager.noEmail`),` •`,` `,t.role===`admin`?e(`userManager.roles.admin`):e(`userManager.roles.user`)]}),(0,P.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,P.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,P.jsx)(b,{variant:`outline`,size:`sm`,onClick:()=>H(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,P.jsx)(f,{size:16})}),(0,P.jsx)(b,{variant:`outline`,size:`sm`,onClick:()=>B(t.id,t.username),disabled:t.id===_?.id,className:`text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,P.jsx)(u,{size:16})})]})]},t.id))})})]})]})},L=()=>{let{t:e}=r(),t=y(e=>e.systemInfo),n=y(e=>e.setSystemInfo),[i,a]=(0,N.useState)(null),[o,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let e=!1;return h.access().then(t=>{e||(t.success&&t.data?(a(t.data.enabled),c(t.data.lockedByEnv)):f(!0))}).catch(()=>{e||f(!0)}),()=>{e=!0}},[p]),(0,P.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.agentAccess.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.agentAccess.description`)}),o&&(0,P.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.agentAccess.lockedByEnv`)})]}),i===null&&d?(0,P.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>{f(!1),m(e=>e+1)},children:e(`common.retry`)}):(0,P.jsx)(M,{checked:i===!0,onChange:async r=>{u(!0);try{let i=await h.setAccess(r);if(!i.success||!i.data)throw Error(i.error||`Agent access update failed.`);a(i.data.enabled),t&&n({...t,agentsEnabled:i.data.enabled}),s.success(e(`userManager.agentAccess.saved`))}catch{s.error(e(`userManager.agentAccess.saveFailed`))}finally{u(!1)}},disabled:l||i===null||o})]})})},R=()=>{let{t:e}=r(),[t,n]=(0,N.useState)(null),[i,a]=(0,N.useState)(!1),[o,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let e=!1;return g.getModelAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,P.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.modelAccess.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.modelAccess.description`)})]}),t===null&&o?(0,P.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,P.jsx)(M,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;a(!0);try{if(!(await g.setModelAccess(r)).success)throw Error(`Model download access update failed.`);n(r),s.success(e(`userManager.modelAccess.saved`))}catch{s.error(e(`userManager.modelAccess.saveFailed`))}finally{a(!1)}},disabled:i||t===null})]})})},z=()=>{let{t:e}=r(),[t,n]=(0,N.useState)(null),[i,a]=(0,N.useState)(!1),[o,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let e=!1;return _.getAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,P.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.webSearchAccess.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.webSearchAccess.description`)})]}),t===null&&o?(0,P.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,P.jsx)(M,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;a(!0);try{if(!(await _.setAccess(r)).success)throw Error(`Web search access update failed.`);n(r),s.success(e(`userManager.webSearchAccess.saved`))}catch{s.error(e(`userManager.webSearchAccess.saveFailed`))}finally{a(!1)}},disabled:i||t===null})]})})},B=()=>{let{t:e}=r(),t=y(e=>e.refreshWorkAccess),[n,i]=(0,N.useState)(null),[a,o]=(0,N.useState)(!1),[c,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let e=!1;return m.access().then(t=>{e||(t.success&&t.data?i(t.data.mode):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]),(0,P.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAccess.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAccess.description`)})]}),n===null&&c?(0,P.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),d(e=>e+1)},children:e(`common.retry`)}):(0,P.jsx)(M,{checked:n===`all-users`,onChange:async n=>{let r=n?`all-users`:`admins`;o(!0);try{if(!(await m.setAccess(r)).success)throw Error(`Work access update failed.`);i(r),await t(),s.success(e(`userManager.workAccess.saved`))}catch{s.error(e(`userManager.workAccess.saveFailed`))}finally{o(!1)}},disabled:a||n===null})]})})},V={name:``,image:``,memoryLimit:``,cpuLimit:``,pidsLimit:``,workspaceSize:``,idleMinutes:``,networkDefault:`inherit`},H=e=>({name:e.name,image:e.image??``,memoryLimit:e.memoryLimit??``,cpuLimit:e.cpuLimit??``,pidsLimit:e.pidsLimit===void 0?``:String(e.pidsLimit),workspaceSize:e.workspaceSize??``,idleMinutes:e.idleTimeoutMs===void 0?``:String(e.idleTimeoutMs/6e4),networkDefault:e.networkDefault===void 0?`inherit`:e.networkDefault?`on`:`off`}),U=e=>[e.pidsLimit,e.idleMinutes].some(e=>e.trim()!==``&&!Number.isFinite(Number(e))),W=e=>({name:e.name.trim(),image:e.image.trim()||null,memoryLimit:e.memoryLimit.trim()||null,cpuLimit:e.cpuLimit.trim()||null,pidsLimit:e.pidsLimit.trim()?Number(e.pidsLimit):null,workspaceSize:e.workspaceSize.trim()||null,idleTimeoutMs:e.idleMinutes.trim()?Math.round(Number(e.idleMinutes)*6e4):null,networkDefault:e.networkDefault===`inherit`?null:e.networkDefault===`on`}),G=()=>{let{t:e}=r(),[t,n]=(0,N.useState)([]),[a,o]=(0,N.useState)(null),[l,d]=(0,N.useState)(V),[f,p]=(0,N.useState)(!1),h=async()=>{try{let e=await m.listPolicies();e.success&&e.data&&n(e.data)}catch{}};(0,N.useEffect)(()=>{let e=!1;return m.listPolicies().then(t=>{!e&&t.success&&t.data&&n(t.data)}).catch(()=>{}),()=>{e=!0}},[]);let g=e=>({value:l[e],onChange:t=>d(n=>({...n,[e]:t.target.value}))}),_=async()=>{if(U(l)){s.error(e(`userManager.workPolicies.invalidNumber`));return}p(!0);try{let t=W(l),n=a===`new`?await m.createPolicy(t):await m.updatePolicy(a,t);if(!n.success)throw Error(n.error||`Policy save failed.`);s.success(e(`userManager.workPolicies.saved`)),o(null),d(V),await h()}catch(t){s.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}finally{p(!1)}},v=async t=>{if(window.confirm(e(`userManager.workPolicies.deleteConfirm`)))try{let n=await m.deletePolicy(t.id);if(!n.success)throw Error(n.error||`Policy delete failed.`);s.success(e(`userManager.workPolicies.deleted`)),await h()}catch(t){s.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}},y=(e,t,n)=>(0,P.jsxs)(`label`,{className:`block text-xs`,children:[(0,P.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:t}),(0,P.jsx)(`input`,{...g(e),placeholder:n,spellCheck:!1,className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-none focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]});return(0,P.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workPolicies.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workPolicies.description`)})]}),a===null&&(0,P.jsxs)(b,{size:`sm`,variant:`outline`,className:`shrink-0 whitespace-nowrap`,onClick:()=>{d(V),o(`new`)},children:[(0,P.jsx)(i,{size:14,className:`shrink-0`}),(0,P.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.add`)})]})]}),t.length===0&&a===null&&(0,P.jsx)(`p`,{className:`mt-3 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.empty`)}),t.length>0&&(0,P.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-100 dark:divide-dark-300`,children:t.map(t=>(0,P.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,P.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-gray-500 dark:text-gray-400`,children:[t.memoryLimit,t.cpuLimit&&`cpu ${t.cpuLimit}`,t.pidsLimit&&`pids ${t.pidsLimit}`,t.workspaceSize,t.idleTimeoutMs!==void 0&&`idle ${Math.round(t.idleTimeoutMs/6e4)}m`,t.networkDefault!==void 0&&`net ${t.networkDefault?`on`:`off`}`,t.image].filter(Boolean).join(` · `)||`—`})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,P.jsx)(b,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.edit`),onClick:()=>{d(H(t)),o(t.id)},children:(0,P.jsx)(c,{size:14})}),(0,P.jsx)(b,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.delete`),onClick:()=>void v(t),children:(0,P.jsx)(u,{size:14})})]})]},t.id))}),a!==null&&(0,P.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 p-3 dark:border-dark-300`,children:[(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[y(`name`,e(`userManager.workPolicies.name`),`heavy`),y(`memoryLimit`,e(`userManager.workPolicies.memory`),`4g`),y(`cpuLimit`,e(`userManager.workPolicies.cpu`),`4`),y(`pidsLimit`,e(`userManager.workPolicies.pids`),`512`),y(`workspaceSize`,e(`userManager.workPolicies.workspaceSize`),`20Gi`),y(`idleMinutes`,e(`userManager.workPolicies.idleMinutes`),`30`),(0,P.jsxs)(`label`,{className:`block text-xs`,children:[(0,P.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.networkDefault`)}),(0,P.jsxs)(`select`,{...g(`networkDefault`),className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-none focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,children:[(0,P.jsx)(`option`,{value:`inherit`,children:e(`userManager.workPolicies.networkInherit`)}),(0,P.jsx)(`option`,{value:`on`,children:e(`userManager.workPolicies.networkOn`)}),(0,P.jsx)(`option`,{value:`off`,children:e(`userManager.workPolicies.networkOff`)})]})]}),y(`image`,e(`userManager.workPolicies.image`),`node:22-bookworm@sha256:…`)]}),(0,P.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,P.jsx)(b,{size:`sm`,variant:`ghost`,disabled:f,onClick:()=>{o(null),d(V)},children:e(`userManager.workPolicies.cancel`)}),(0,P.jsx)(b,{size:`sm`,disabled:f||!l.name.trim(),onClick:()=>void _(),children:e(`userManager.workPolicies.save`)})]})]})]})},K=()=>{let{t:e}=r();return(0,P.jsxs)(w,{children:[(0,P.jsx)(k,{title:e(`userManager.title`),description:e(`userManager.pageDescription`)}),(0,P.jsxs)(`div`,{className:`mb-4 space-y-4`,children:[(0,P.jsx)(B,{}),(0,P.jsx)(G,{}),(0,P.jsx)(R,{}),(0,P.jsx)(z,{}),(0,P.jsx)(L,{})]}),(0,P.jsx)(I,{})]})};export{K as UserManagementPage,K as default};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CXY69qNk.js";import{B as i,O as a,Qt as o,Tn as s,W as c,c as l,m as u,u as d,w as f}from"./ui-vendor-xUzKqAXI.js";import{t as p}from"./logger-DSXjF4ye.js";import{t as m}from"./workApi-BOS7crs9.js";import{h,p as g,v as _,w as v}from"./api-CLEmGcEh.js";import{n as y}from"./authStore-Dh3beEOq.js";import{t as b}from"./Button-CTXHujOd.js";import{a as x,c as S,i as C,n as w,o as T,p as E,r as D,s as O,t as k}from"./ui-BnDZpjfc.js";import{f as A,m as j}from"../assets/index-BBpNbfKW.js";import{t as M}from"./SettingsToggle-DLHlCDBl.js";var N=e(n(),1),P=t(),F=p(`components:user-manager`),I=()=>{let{t:e}=r(),t=j(),[n,c]=(0,N.useState)(!1),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)({username:``,email:``,password:``,role:`user`}),{user:_}=y(),{data:w=[],isLoading:k}=A({queryKey:[`users`],queryFn:async()=>{let t=await v.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),M=()=>t.invalidateQueries({queryKey:[`users`]}),I=w.filter(e=>e.status===`pending`),L=w.filter(e=>e.status!==`pending`),R=async t=>{t.preventDefault();try{let t=await v.createUser(h);t.success&&t.data&&(await M(),g({username:``,email:``,password:``,role:`user`}),c(!1),s.success(e(`userManager.form.createSuccess`)))}catch(t){F.error(`Error creating user:`,t);let n=e(`userManager.form.createFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.createFailed`)),s.error(n)}},z=async t=>{if(t.preventDefault(),p)try{let t={username:h.username,email:h.email,role:h.role};h.password&&h.password.trim()!==``&&(t.password=h.password);let n=await v.updateUser(p.id,t);n.success&&n.data&&(await M(),m(null),g({username:``,email:``,password:``,role:`user`}),s.success(e(`userManager.form.updateSuccess`)))}catch(t){F.error(`Error updating user:`,t);let n=e(`userManager.form.updateFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.updateFailed`)),s.error(n)}},B=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await v.deleteUser(t)).success&&(await M(),s.success(e(`userManager.deleteSuccess`)))}catch(t){F.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),s.error(n)}},V=async t=>{try{let n=await v.approveUser(t.id);n.success&&n.data&&(await M(),s.success(e(`userManager.approval.approved`,{name:t.username,defaultValue:`{{name}} can now sign in.`})))}catch(t){F.error(`Error approving user:`,t);let n=t;s.error(n.response?.data?.message||e(`userManager.approval.failed`,`The account could not be approved.`))}},H=e=>{m(e),g({username:e.username,email:e.email||``,password:``,role:e.role})};return k?(0,P.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,P.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-gray-600 border-t-primary-500 rounded-full animate-spin`})}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,P.jsx)(`div`,{}),(0,P.jsxs)(b,{onClick:()=>c(!n),className:`flex items-center space-x-2 bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600`,children:[(0,P.jsx)(i,{size:16}),(0,P.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,P.jsxs)(D,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,P.jsxs)(T,{children:[(0,P.jsx)(O,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,P.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,P.jsx)(C,{children:(0,P.jsxs)(`form`,{onSubmit:R,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,P.jsx)(E,{id:`username`,value:h.username,onChange:e=>g({...h,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,P.jsx)(E,{id:`email`,type:`email`,value:h.email,onChange:e=>g({...h,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,P.jsx)(E,{id:`password`,type:`password`,value:h.password,onChange:e=>g({...h,password:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,P.jsxs)(`select`,{id:`role`,value:h.role,onChange:e=>g({...h,role:e.target.value}),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200`,children:[(0,P.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,P.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,P.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,P.jsx)(b,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,P.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>{g({username:``,email:``,password:``,role:`user`}),c(!1)},children:e(`common.cancel`)})]})]})})]}),p&&(0,P.jsxs)(D,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,P.jsxs)(T,{children:[(0,P.jsxs)(O,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,p.username]}),(0,P.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,P.jsx)(C,{children:(0,P.jsxs)(`form`,{onSubmit:z,className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,P.jsx)(E,{id:`edit-username`,value:h.username,onChange:e=>g({...h,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,P.jsx)(E,{id:`edit-email`,type:`email`,value:h.email,onChange:e=>g({...h,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(S,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,P.jsx)(E,{id:`edit-password`,type:`password`,value:h.password,onChange:e=>g({...h,password:e.target.value}),placeholder:e(`userManager.form.passwordHint`),className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(S,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,P.jsxs)(`select`,{id:`edit-role`,value:h.role,onChange:e=>g({...h,role:e.target.value}),disabled:p?.id===_?.id&&_?.role===`admin`,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,P.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,P.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),p?.id===_?.id&&_?.role===`admin`&&(0,P.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,P.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,P.jsx)(b,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,P.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>{m(null),g({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),I.length>0&&(0,P.jsxs)(D,{"data-testid":`pending-user-approvals`,className:`border border-warning-500/30 bg-warning-500/[0.06] shadow-lg`,children:[(0,P.jsxs)(T,{children:[(0,P.jsxs)(O,{className:`flex items-center gap-2 text-gray-900 dark:text-gray-100`,children:[(0,P.jsx)(o,{className:`h-5 w-5 text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`,`Pending approvals`),` (`,I.length,`)`]}),(0,P.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.approval.description`,`Review new registrations before allowing them into this instance.`)})]}),(0,P.jsx)(C,{children:(0,P.jsx)(`div`,{className:`space-y-3`,children:I.map(t=>(0,P.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-4 rounded-xl border border-warning-500/25 bg-surface p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`h3`,{className:`truncate font-medium text-ink`,children:t.username}),(0,P.jsx)(`p`,{className:`truncate text-sm text-ink-muted`,children:t.email||e(`userManager.noEmail`)}),(0,P.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(`userManager.approval.registered`,`Registered`),`:`,` `,new Date(t.createdAt).toLocaleString()]})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,P.jsxs)(b,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void V(t),className:`gap-2`,children:[(0,P.jsx)(d,{size:16}),e(`userManager.approval.activate`,`Activate account`)]}),(0,P.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e(`userManager.approval.reject`,`Reject registration`),onClick:()=>void B(t.id,t.username),className:`text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-900/20 dark:hover:text-red-300`,children:(0,P.jsx)(u,{size:16})})]})]},t.id))})})]}),(0,P.jsxs)(D,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,P.jsxs)(T,{children:[(0,P.jsxs)(O,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,L.length,`)`]}),(0,P.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,P.jsx)(C,{children:(0,P.jsx)(`div`,{className:`space-y-3`,children:L.map(t=>(0,P.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,P.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,P.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,P.jsx)(a,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,P.jsx)(l,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===_?.id&&(0,P.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,P.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[t.email||e(`userManager.noEmail`),` •`,` `,t.role===`admin`?e(`userManager.roles.admin`):e(`userManager.roles.user`)]}),(0,P.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,P.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,P.jsx)(b,{variant:`outline`,size:`sm`,onClick:()=>H(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,P.jsx)(f,{size:16})}),(0,P.jsx)(b,{variant:`outline`,size:`sm`,onClick:()=>B(t.id,t.username),disabled:t.id===_?.id,className:`text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,P.jsx)(u,{size:16})})]})]},t.id))})})]})]})},L=()=>{let{t:e}=r(),t=y(e=>e.systemInfo),n=y(e=>e.setSystemInfo),[i,a]=(0,N.useState)(null),[o,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let e=!1;return h.access().then(t=>{e||(t.success&&t.data?(a(t.data.enabled),c(t.data.lockedByEnv)):f(!0))}).catch(()=>{e||f(!0)}),()=>{e=!0}},[p]),(0,P.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.agentAccess.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.agentAccess.description`)}),o&&(0,P.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.agentAccess.lockedByEnv`)})]}),i===null&&d?(0,P.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>{f(!1),m(e=>e+1)},children:e(`common.retry`)}):(0,P.jsx)(M,{checked:i===!0,onChange:async r=>{u(!0);try{let i=await h.setAccess(r);if(!i.success||!i.data)throw Error(i.error||`Agent access update failed.`);a(i.data.enabled),t&&n({...t,agentsEnabled:i.data.enabled}),s.success(e(`userManager.agentAccess.saved`))}catch{s.error(e(`userManager.agentAccess.saveFailed`))}finally{u(!1)}},disabled:l||i===null||o})]})})},R=()=>{let{t:e}=r(),[t,n]=(0,N.useState)(null),[i,a]=(0,N.useState)(!1),[o,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let e=!1;return g.getModelAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,P.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.modelAccess.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.modelAccess.description`)})]}),t===null&&o?(0,P.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,P.jsx)(M,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;a(!0);try{if(!(await g.setModelAccess(r)).success)throw Error(`Model download access update failed.`);n(r),s.success(e(`userManager.modelAccess.saved`))}catch{s.error(e(`userManager.modelAccess.saveFailed`))}finally{a(!1)}},disabled:i||t===null})]})})},z=()=>{let{t:e}=r(),[t,n]=(0,N.useState)(null),[i,a]=(0,N.useState)(!1),[o,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let e=!1;return _.getAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,P.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.webSearchAccess.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.webSearchAccess.description`)})]}),t===null&&o?(0,P.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,P.jsx)(M,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;a(!0);try{if(!(await _.setAccess(r)).success)throw Error(`Web search access update failed.`);n(r),s.success(e(`userManager.webSearchAccess.saved`))}catch{s.error(e(`userManager.webSearchAccess.saveFailed`))}finally{a(!1)}},disabled:i||t===null})]})})},B=()=>{let{t:e}=r(),t=y(e=>e.refreshWorkAccess),[n,i]=(0,N.useState)(null),[a,o]=(0,N.useState)(!1),[c,l]=(0,N.useState)(!1),[u,d]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let e=!1;return m.access().then(t=>{e||(t.success&&t.data?i(t.data.mode):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]),(0,P.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAccess.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAccess.description`)})]}),n===null&&c?(0,P.jsx)(b,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),d(e=>e+1)},children:e(`common.retry`)}):(0,P.jsx)(M,{checked:n===`all-users`,onChange:async n=>{let r=n?`all-users`:`admins`;o(!0);try{if(!(await m.setAccess(r)).success)throw Error(`Work access update failed.`);i(r),await t(),s.success(e(`userManager.workAccess.saved`))}catch{s.error(e(`userManager.workAccess.saveFailed`))}finally{o(!1)}},disabled:a||n===null})]})})},V={name:``,image:``,memoryLimit:``,cpuLimit:``,pidsLimit:``,workspaceSize:``,idleMinutes:``,networkDefault:`inherit`},H=e=>({name:e.name,image:e.image??``,memoryLimit:e.memoryLimit??``,cpuLimit:e.cpuLimit??``,pidsLimit:e.pidsLimit===void 0?``:String(e.pidsLimit),workspaceSize:e.workspaceSize??``,idleMinutes:e.idleTimeoutMs===void 0?``:String(e.idleTimeoutMs/6e4),networkDefault:e.networkDefault===void 0?`inherit`:e.networkDefault?`on`:`off`}),U=e=>[e.pidsLimit,e.idleMinutes].some(e=>e.trim()!==``&&!Number.isFinite(Number(e))),W=e=>({name:e.name.trim(),image:e.image.trim()||null,memoryLimit:e.memoryLimit.trim()||null,cpuLimit:e.cpuLimit.trim()||null,pidsLimit:e.pidsLimit.trim()?Number(e.pidsLimit):null,workspaceSize:e.workspaceSize.trim()||null,idleTimeoutMs:e.idleMinutes.trim()?Math.round(Number(e.idleMinutes)*6e4):null,networkDefault:e.networkDefault===`inherit`?null:e.networkDefault===`on`}),G=()=>{let{t:e}=r(),[t,n]=(0,N.useState)([]),[a,o]=(0,N.useState)(null),[l,d]=(0,N.useState)(V),[f,p]=(0,N.useState)(!1),h=async()=>{try{let e=await m.listPolicies();e.success&&e.data&&n(e.data)}catch{}};(0,N.useEffect)(()=>{let e=!1;return m.listPolicies().then(t=>{!e&&t.success&&t.data&&n(t.data)}).catch(()=>{}),()=>{e=!0}},[]);let g=e=>({value:l[e],onChange:t=>d(n=>({...n,[e]:t.target.value}))}),_=async()=>{if(U(l)){s.error(e(`userManager.workPolicies.invalidNumber`));return}p(!0);try{let t=W(l),n=a===`new`?await m.createPolicy(t):await m.updatePolicy(a,t);if(!n.success)throw Error(n.error||`Policy save failed.`);s.success(e(`userManager.workPolicies.saved`)),o(null),d(V),await h()}catch(t){s.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}finally{p(!1)}},v=async t=>{if(window.confirm(e(`userManager.workPolicies.deleteConfirm`)))try{let n=await m.deletePolicy(t.id);if(!n.success)throw Error(n.error||`Policy delete failed.`);s.success(e(`userManager.workPolicies.deleted`)),await h()}catch(t){s.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}},y=(e,t,n)=>(0,P.jsxs)(`label`,{className:`block text-xs`,children:[(0,P.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:t}),(0,P.jsx)(`input`,{...g(e),placeholder:n,spellCheck:!1,className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-none focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]});return(0,P.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workPolicies.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workPolicies.description`)})]}),a===null&&(0,P.jsxs)(b,{size:`sm`,variant:`outline`,className:`shrink-0 whitespace-nowrap`,onClick:()=>{d(V),o(`new`)},children:[(0,P.jsx)(i,{size:14,className:`shrink-0`}),(0,P.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.add`)})]})]}),t.length===0&&a===null&&(0,P.jsx)(`p`,{className:`mt-3 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.empty`)}),t.length>0&&(0,P.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-100 dark:divide-dark-300`,children:t.map(t=>(0,P.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,P.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-gray-500 dark:text-gray-400`,children:[t.memoryLimit,t.cpuLimit&&`cpu ${t.cpuLimit}`,t.pidsLimit&&`pids ${t.pidsLimit}`,t.workspaceSize,t.idleTimeoutMs!==void 0&&`idle ${Math.round(t.idleTimeoutMs/6e4)}m`,t.networkDefault!==void 0&&`net ${t.networkDefault?`on`:`off`}`,t.image].filter(Boolean).join(` · `)||`—`})]}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,P.jsx)(b,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.edit`),onClick:()=>{d(H(t)),o(t.id)},children:(0,P.jsx)(c,{size:14})}),(0,P.jsx)(b,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.delete`),onClick:()=>void v(t),children:(0,P.jsx)(u,{size:14})})]})]},t.id))}),a!==null&&(0,P.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 p-3 dark:border-dark-300`,children:[(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[y(`name`,e(`userManager.workPolicies.name`),`heavy`),y(`memoryLimit`,e(`userManager.workPolicies.memory`),`4g`),y(`cpuLimit`,e(`userManager.workPolicies.cpu`),`4`),y(`pidsLimit`,e(`userManager.workPolicies.pids`),`512`),y(`workspaceSize`,e(`userManager.workPolicies.workspaceSize`),`20Gi`),y(`idleMinutes`,e(`userManager.workPolicies.idleMinutes`),`30`),(0,P.jsxs)(`label`,{className:`block text-xs`,children:[(0,P.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.networkDefault`)}),(0,P.jsxs)(`select`,{...g(`networkDefault`),className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-none focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,children:[(0,P.jsx)(`option`,{value:`inherit`,children:e(`userManager.workPolicies.networkInherit`)}),(0,P.jsx)(`option`,{value:`on`,children:e(`userManager.workPolicies.networkOn`)}),(0,P.jsx)(`option`,{value:`off`,children:e(`userManager.workPolicies.networkOff`)})]})]}),y(`image`,e(`userManager.workPolicies.image`),`node:22-bookworm@sha256:…`)]}),(0,P.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,P.jsx)(b,{size:`sm`,variant:`ghost`,disabled:f,onClick:()=>{o(null),d(V)},children:e(`userManager.workPolicies.cancel`)}),(0,P.jsx)(b,{size:`sm`,disabled:f||!l.name.trim(),onClick:()=>void _(),children:e(`userManager.workPolicies.save`)})]})]})]})},K=()=>{let{t:e}=r();return(0,P.jsxs)(w,{children:[(0,P.jsx)(k,{title:e(`userManager.title`),description:e(`userManager.pageDescription`)}),(0,P.jsxs)(`div`,{className:`mb-4 space-y-4`,children:[(0,P.jsx)(B,{}),(0,P.jsx)(G,{}),(0,P.jsx)(R,{}),(0,P.jsx)(z,{}),(0,P.jsx)(L,{})]}),(0,P.jsx)(I,{})]})};export{K as UserManagementPage,K as default};
|