libre-webui 0.34.2 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/dist/persistence/extensionTypes.d.ts +2 -0
- package/backend/dist/persistence/extensionTypes.d.ts.map +1 -1
- package/backend/dist/persistence/extensionTypes.js.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresExtensionRepositories.js +26 -0
- package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteExtensionRepositories.js +28 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
- package/backend/dist/platform/jobs/durableJobRuntime.d.ts.map +1 -1
- package/backend/dist/platform/jobs/durableJobRuntime.js +3 -1
- package/backend/dist/platform/jobs/durableJobRuntime.js.map +1 -1
- package/backend/dist/platform/storage/s3EncryptedBlobStore.js +1 -1
- package/backend/dist/platform/storage/s3EncryptedBlobStore.js.map +1 -1
- package/backend/dist/routes/chat.d.ts.map +1 -1
- package/backend/dist/routes/chat.js +49 -0
- package/backend/dist/routes/chat.js.map +1 -1
- package/backend/dist/routes/plugins.d.ts.map +1 -1
- package/backend/dist/routes/plugins.js +29 -2
- package/backend/dist/routes/plugins.js.map +1 -1
- package/backend/dist/services/calendarService.js +1 -1
- package/backend/dist/services/calendarService.js.map +1 -1
- package/backend/dist/services/chatService.d.ts.map +1 -1
- package/backend/dist/services/chatService.js +5 -2
- package/backend/dist/services/chatService.js.map +1 -1
- package/backend/dist/services/documentService.d.ts.map +1 -1
- package/backend/dist/services/documentService.js +4 -5
- package/backend/dist/services/documentService.js.map +1 -1
- package/backend/dist/services/followUpService.js +1 -1
- package/backend/dist/services/followUpService.js.map +1 -1
- package/backend/dist/services/galleryService.d.ts.map +1 -1
- package/backend/dist/services/galleryService.js +5 -2
- package/backend/dist/services/galleryService.js.map +1 -1
- package/backend/dist/services/legacyCiphertextIntegrity.js +2 -2
- package/backend/dist/services/legacyCiphertextIntegrity.js.map +1 -1
- package/backend/dist/services/pluginCacheInvalidation.d.ts.map +1 -1
- package/backend/dist/services/pluginCacheInvalidation.js +3 -2
- package/backend/dist/services/pluginCacheInvalidation.js.map +1 -1
- package/backend/dist/services/pluginUsageService.d.ts +5 -1
- package/backend/dist/services/pluginUsageService.d.ts.map +1 -1
- package/backend/dist/services/pluginUsageService.js +37 -14
- package/backend/dist/services/pluginUsageService.js.map +1 -1
- package/backend/dist/services/thinkingSummaryService.d.ts +48 -0
- package/backend/dist/services/thinkingSummaryService.d.ts.map +1 -0
- package/backend/dist/services/thinkingSummaryService.js +170 -0
- package/backend/dist/services/thinkingSummaryService.js.map +1 -0
- package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeService.js +5 -2
- package/backend/dist/services/workRuntimeService.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js +5 -2
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/utils/pluginStreamAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginStreamAdapter.js +2 -7
- package/backend/dist/utils/pluginStreamAdapter.js.map +1 -1
- package/backend/package.json +1 -1
- package/bin/cli.js +0 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/assets/index-B8CRGFpq.css +1 -0
- package/frontend/dist/assets/index-D34e2tgI.js +92 -0
- package/frontend/dist/index.html +17 -17
- package/frontend/dist/js/{ArtifactContainer-CQjqR9G1.js → ArtifactContainer-DxNTcOvH.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-DbbqglMU.js → ArtifactDemoPage-Bzb07rM8.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-DI2b9BW5.js → ArtifactSandboxFrame-DP_4rZwQ.js} +1 -1
- package/frontend/dist/js/{ArtifactSlideOutPanel-B_UX92CK.js → ArtifactSlideOutPanel-DkuFYmTf.js} +1 -1
- package/frontend/dist/js/{AutomationModal-CNiy1Dxm.js → AutomationModal-Dh_l3_KV.js} +1 -1
- package/frontend/dist/js/{AutomationsPage-CeAsldk_.js → AutomationsPage-BZqRE_iS.js} +1 -1
- package/frontend/dist/js/{AvatarUpload-xCWQm3_w.js → AvatarUpload-CM537pyV.js} +1 -1
- package/frontend/dist/js/{CalendarPage-Cwk0X00z.js → CalendarPage-CNovVIyJ.js} +1 -1
- package/frontend/dist/js/{ChannelsPage-BG3n4ElV.js → ChannelsPage-B24ElGbY.js} +1 -1
- package/frontend/dist/js/ChatPage-YD9iS6Kh.js +14 -0
- package/frontend/dist/js/{ConnectModels-D7ZTGihA.js → ConnectModels-Dwih31mg.js} +1 -1
- package/frontend/dist/js/{EvaluationsPage-C795TI_6.js → EvaluationsPage-fd4Bzfet.js} +1 -1
- package/frontend/dist/js/{FirstTimeSetup-C4C5GLjW.js → FirstTimeSetup-Bf6VF-W2.js} +1 -1
- package/frontend/dist/js/{GalleryPage-DVWl3LaC.js → GalleryPage-BiHsiQXa.js} +1 -1
- package/frontend/dist/js/HomePage-QmyVNWCW.js +1 -0
- package/frontend/dist/js/LanguageSwitcher-DjCF4n-n.js +1 -0
- package/frontend/dist/js/{LibreClawPage-OD6iZtiy.js → LibreClawPage-BgWhUlqz.js} +1 -1
- package/frontend/dist/js/{NotesPage-rqL0zS8z.js → NotesPage-Di2Bg-aA.js} +1 -1
- package/frontend/dist/js/{PersonasPage-Babix8IA.js → PersonasPage-BdJO364O.js} +1 -1
- package/frontend/dist/js/PluginUsagePage-Cg8eqMsE.js +1 -0
- package/frontend/dist/js/RichMessageContent-C8qt0Aa7.js +1 -0
- package/frontend/dist/js/{RichMessageContent-CcKn_kcQ.js → RichMessageContent-CUbm43PQ.js} +1 -1
- package/frontend/dist/js/{SettingsModal-CXU60RIf.js → SettingsModal-BxEuHSvE.js} +3 -3
- package/frontend/dist/js/{ShareDialog-CnU4ptx7.js → ShareDialog-DTGlwdvx.js} +1 -1
- package/frontend/dist/js/{SystemPage-BzpTjdQY.js → SystemPage-wOjktp6W.js} +1 -1
- package/frontend/dist/js/UserManagementPanel-KLgquEZv.js +1 -0
- package/frontend/dist/js/{WhatsNewModal-TuDrBWKj.js → WhatsNewModal-B-8T7RFf.js} +1 -1
- package/frontend/dist/js/{WorkPage-DCeqm0BN.js → WorkPage-5YiyDil1.js} +2 -2
- package/frontend/dist/js/api-C4tAvZc2.js +14 -0
- package/frontend/dist/js/api-vKAlaBw8.js +1 -0
- package/frontend/dist/js/{appNavigation-DySHcEGS.js → appNavigation-DXgSn83Q.js} +1 -1
- package/frontend/dist/js/{appStore-DrTsJPfh.js → appStore-CmY86Gzn.js} +2 -2
- package/frontend/dist/js/appVersion-Nzg0IWED.js +1 -0
- package/frontend/dist/js/ar-DtoEKcvZ.js +2 -0
- package/frontend/dist/js/authStore-Cq6ASMHJ.js +1 -0
- package/frontend/dist/js/{authStore-CieFdk4S.js → authStore-DzKajX63.js} +3 -3
- package/frontend/dist/js/bn-DP2AKHj6.js +2 -0
- package/frontend/dist/js/chatStore-Bp-tan20.js +3 -0
- package/frontend/dist/js/{composerStyles-BjJm_BgC.js → composerStyles-nggBKICR.js} +1 -1
- package/frontend/dist/js/{config-D7WLbWrW.js → config-Cg4OZeHO.js} +1 -1
- package/frontend/dist/js/cs-BYiysC42.js +2 -0
- package/frontend/dist/js/da-CjvZwl21.js +2 -0
- package/frontend/dist/js/de-BKI2vbyb.js +2 -0
- package/frontend/dist/js/es-Bd_rGARS.js +2 -0
- package/frontend/dist/js/{evaluationsApi-Dn-WNzzH.js → evaluationsApi-BKkwm4WQ.js} +1 -1
- package/frontend/dist/js/fr-MJPX-cfk.js +2 -0
- package/frontend/dist/js/hi-i1pFIKuq.js +2 -0
- package/frontend/dist/js/id-Cx2UmvDs.js +2 -0
- package/frontend/dist/js/is-BhoLtzfO.js +2 -0
- package/frontend/dist/js/it-DBSOFUQF.js +2 -0
- package/frontend/dist/js/ja-tt90GfPo.js +2 -0
- package/frontend/dist/js/ko-CuQjGSbu.js +2 -0
- package/frontend/dist/js/{messageCodeStyles-C0pbLr0L.js → messageCodeStyles-CNMdqZf-.js} +1 -1
- package/frontend/dist/js/ms-B1IgAOxc.js +2 -0
- package/frontend/dist/js/nl-KC1T6ODd.js +2 -0
- package/frontend/dist/js/pl-BELaieBr.js +2 -0
- package/frontend/dist/js/pt-BcNdTKuY.js +2 -0
- package/frontend/dist/js/ru-BY36Y8EF.js +2 -0
- package/frontend/dist/js/sv-Df0qJdhZ.js +2 -0
- package/frontend/dist/js/{teamEventStream-CI_GSbae.js → teamEventStream-CjWlYJh3.js} +1 -1
- package/frontend/dist/js/th-BQogE70C.js +2 -0
- package/frontend/dist/js/tr-CE2ShLd6.js +2 -0
- package/frontend/dist/js/ui-DzVF9vZ5.js +2 -0
- package/frontend/dist/js/uk-DuVduqlS.js +2 -0
- package/frontend/dist/js/useChat-DubO9MWm.js +10 -0
- package/frontend/dist/js/vi-DABvOoXL.js +2 -0
- package/frontend/dist/js/workApi-mPLHmuyT.js +1 -0
- package/frontend/dist/js/{workApi-C-WfyZSs.js → workApi-oO8srJWT.js} +3 -3
- package/frontend/dist/js/zh-D2B1N9vW.js +2 -0
- package/package.json +2 -2
- package/frontend/dist/assets/index-C59a0tht.css +0 -1
- package/frontend/dist/assets/index-Cyi10ekV.js +0 -43
- package/frontend/dist/js/ChatPage-wSRfAOeh.js +0 -14
- package/frontend/dist/js/HomePage-BljB9ZMN.js +0 -1
- package/frontend/dist/js/LanguageSwitcher-BuS3i6u5.js +0 -1
- package/frontend/dist/js/PluginUsagePage-CudDkMxy.js +0 -1
- package/frontend/dist/js/RichMessageContent-B-U0EcyW.js +0 -1
- package/frontend/dist/js/UserManagementPanel-pbtLqF8X.js +0 -1
- package/frontend/dist/js/api-BIVGtaZy.js +0 -1
- package/frontend/dist/js/api-CgnEj5Jc.js +0 -14
- package/frontend/dist/js/appVersion-CAidQlBP.js +0 -1
- package/frontend/dist/js/ar-DNI77Stn.js +0 -2
- package/frontend/dist/js/authStore-GaOHAAsM.js +0 -1
- package/frontend/dist/js/bn-u6oyZr4U.js +0 -2
- package/frontend/dist/js/chatStore-BvZkd8Un.js +0 -3
- package/frontend/dist/js/cs-BIkJ6jwb.js +0 -2
- package/frontend/dist/js/da-DV3V6XJ_.js +0 -2
- package/frontend/dist/js/de-DdcTQ-vn.js +0 -2
- package/frontend/dist/js/es-Cw-ozFaX.js +0 -2
- package/frontend/dist/js/fr-Y2NfnlYR.js +0 -2
- package/frontend/dist/js/hi-BKU62_1Y.js +0 -2
- package/frontend/dist/js/id-q6wo4InR.js +0 -2
- package/frontend/dist/js/is-_B6QblCu.js +0 -2
- package/frontend/dist/js/it-NUupXhzK.js +0 -2
- package/frontend/dist/js/ja-BUvl9RXq.js +0 -2
- package/frontend/dist/js/ko-df4leR83.js +0 -2
- package/frontend/dist/js/ms-CN-7Q9S2.js +0 -2
- package/frontend/dist/js/nl-OEm4uNIo.js +0 -2
- package/frontend/dist/js/pl-B9pHpjg7.js +0 -2
- package/frontend/dist/js/pt-D3uaEKud.js +0 -2
- package/frontend/dist/js/ru-z9H07lhi.js +0 -2
- package/frontend/dist/js/sv-GkQDA4wx.js +0 -2
- package/frontend/dist/js/th-0hzCkDzt.js +0 -2
- package/frontend/dist/js/tr-CZDobfHQ.js +0 -2
- package/frontend/dist/js/ui-CgokQU6I.js +0 -2
- package/frontend/dist/js/uk-BwspIPCI.js +0 -2
- package/frontend/dist/js/useChat-DIGuMg5j.js +0 -10
- package/frontend/dist/js/vi-Dipdv5ta.js +0 -2
- package/frontend/dist/js/workApi-CApikuye.js +0 -1
- package/frontend/dist/js/zh-CgdWmtP_.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{C as r,t as i}from"./useQuery-BKulzCS7.js";import{a,t as o}from"./logger-DnuT4jgB.js";import{t as s}from"./useTranslation-rdLmo6zV.js";import{t as c}from"./utils-CKWltgs8.js";import{E as l,I as u,In as d,Jn as f,K as p,Kn as m,R as h,T as g,Z as _,_t as v,br as y,c as b,d as x,f as ee,j as S,ot as C,s as te,tt as w,v as T,vt as E,xt as D}from"./ui-vendor-Dt9hfsGD.js";import{n as O,r as k,t as A}from"./workApi-C-WfyZSs.js";import{I as j,P as M,R as N,d as P,s as F,w as I,x as L,y as R}from"./api-CgnEj5Jc.js";import{t as z}from"./authStore-CieFdk4S.js";import{c as ne,t as re}from"./appStore-DrTsJPfh.js";import{t as B}from"./Button-BxwbQ5xw.js";import{c as V,d as H,f as U,g as W,l as G,p as K,u as q,v as J}from"./ui-CgokQU6I.js";import{t as ie}from"./PasswordStrengthMeter-H0Os6XbX.js";import{t as Y}from"./SettingsToggle-DdhWCK7-.js";var X=e(t(),1),Z=n(),Q=o(`components:user-manager`),ae=()=>{let{t:e}=s(),t=r(),[n,a]=(0,X.useState)(!1),[o,c]=(0,X.useState)(null),[l,f]=(0,X.useState)({username:``,email:``,password:``,role:`user`}),{user:p}=z(),{data:m=[],isLoading:g}=i({queryKey:[`users`],queryFn:async()=>{let t=await N.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),_=()=>t.invalidateQueries({queryKey:[`users`]}),v=m.filter(e=>e.status===`pending`),x=m.filter(e=>e.status!==`pending`),C=async t=>{t.preventDefault();try{let t=await N.createUser(l);t.success&&t.data&&(await _(),f({username:``,email:``,password:``,role:`user`}),a(!1),y.success(e(`userManager.form.createSuccess`)))}catch(t){Q.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`)),y.error(n)}},te=async t=>{if(t.preventDefault(),o)try{let t={username:l.username,email:l.email,role:l.role};l.password&&l.password.trim()!==``&&(t.password=l.password);let n=await N.updateUser(o.id,t);n.success&&n.data&&(await _(),c(null),f({username:``,email:``,password:``,role:`user`}),y.success(e(`userManager.form.updateSuccess`)))}catch(t){Q.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`)),y.error(n)}},E=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await N.deleteUser(t)).success&&(await _(),y.success(e(`userManager.deleteSuccess`)))}catch(t){Q.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),y.error(n)}},D=async(t,n)=>{if(confirm(e(`userManager.mfaResetConfirm`,{name:n})))try{let r=await N.resetUserMfa(t);r.success&&r.data?.removed?y.success(e(`userManager.mfaResetSuccess`,{name:n})):r.success?y.success(e(`userManager.mfaResetNothing`,{name:n})):y.error(r.message||e(`userManager.mfaResetFailed`))}catch(t){Q.error(`Error resetting MFA:`,t);let n=t;y.error(n.response?.data?.message||e(`userManager.mfaResetFailed`))}},O=async t=>{try{let n=await N.approveUser(t.id);n.success&&n.data&&(await _(),y.success(e(`userManager.approval.approved`,{name:t.username,defaultValue:`{{name}} can now sign in.`})))}catch(t){Q.error(`Error approving user:`,t);let n=t;y.error(n.response?.data?.message||e(`userManager.approval.failed`,`The account could not be approved.`))}},k=e=>{c(e),f({username:e.username,email:e.email||``,password:``,role:e.role})};return g?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,Z.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,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Z.jsx)(`div`,{}),(0,Z.jsxs)(B,{onClick:()=>a(!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,Z.jsx)(w,{size:16}),(0,Z.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,Z.jsxs)(V,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,Z.jsxs)(H,{children:[(0,Z.jsx)(U,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,Z.jsx)(q,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(K,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,Z.jsx)(J,{id:`username`,value:l.username,onChange:e=>f({...l,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,Z.jsxs)(`div`,{children:[(0,Z.jsx)(K,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,Z.jsx)(J,{id:`email`,type:`email`,value:l.email,onChange:e=>f({...l,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,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(K,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,Z.jsx)(J,{id:`password`,type:`password`,value:l.password,onChange:e=>f({...l,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,Z.jsx)(ie,{password:l.password})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(K,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,Z.jsxs)(`select`,{id:`role`,value:l.role,onChange:e=>f({...l,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,Z.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,Z.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,Z.jsx)(B,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,Z.jsx)(B,{type:`button`,variant:`outline`,onClick:()=>{f({username:``,email:``,password:``,role:`user`}),a(!1)},children:e(`common.cancel`)})]})]})})]}),o&&(0,Z.jsxs)(V,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,Z.jsxs)(H,{children:[(0,Z.jsxs)(U,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,o.username]}),(0,Z.jsx)(q,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(`form`,{onSubmit:te,className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(K,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,Z.jsx)(J,{id:`edit-username`,value:l.username,onChange:e=>f({...l,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,Z.jsxs)(`div`,{children:[(0,Z.jsx)(K,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,Z.jsx)(J,{id:`edit-email`,type:`email`,value:l.email,onChange:e=>f({...l,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,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(K,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,Z.jsx)(J,{id:`edit-password`,type:`password`,value:l.password,onChange:e=>f({...l,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,Z.jsx)(ie,{password:l.password})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(K,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,Z.jsxs)(`select`,{id:`edit-role`,value:l.role,onChange:e=>f({...l,role:e.target.value}),disabled:o?.id===p?.id&&p?.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,Z.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,Z.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),o?.id===p?.id&&p?.role===`admin`&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,Z.jsx)(B,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,Z.jsx)(B,{type:`button`,variant:`outline`,onClick:()=>{c(null),f({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),v.length>0&&(0,Z.jsxs)(V,{"data-testid":`pending-user-approvals`,className:`border border-warning-500/30 bg-warning-500/[0.06] shadow-lg`,children:[(0,Z.jsxs)(H,{children:[(0,Z.jsxs)(U,{className:`flex items-center gap-2 text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(d,{className:`h-5 w-5 text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`,`Pending approvals`),` (`,v.length,`)`]}),(0,Z.jsx)(q,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.approval.description`,`Review new registrations before allowing them into this instance.`)})]}),(0,Z.jsx)(G,{children:(0,Z.jsx)(`div`,{className:`space-y-3`,children:v.map(t=>(0,Z.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,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`truncate font-medium text-ink`,children:t.username}),(0,Z.jsx)(`p`,{className:`truncate text-sm text-ink-muted`,children:t.email||e(`userManager.noEmail`)}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(`userManager.approval.registered`,`Registered`),`:`,` `,new Date(t.createdAt).toLocaleString()]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(B,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void O(t),className:`gap-2`,children:[(0,Z.jsx)(ee,{size:16}),e(`userManager.approval.activate`,`Activate account`)]}),(0,Z.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e(`userManager.approval.reject`,`Reject registration`),onClick:()=>void E(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,Z.jsx)(T,{size:16})})]})]},t.id))})})]}),(0,Z.jsxs)(V,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,Z.jsxs)(H,{children:[(0,Z.jsxs)(U,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,x.length,`)`]}),(0,Z.jsx)(q,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,Z.jsx)(G,{children:(0,Z.jsx)(`div`,{className:`space-y-3`,children:x.map(t=>(0,Z.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,Z.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,Z.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,Z.jsx)(u,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,Z.jsx)(b,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===p?.id&&(0,Z.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,Z.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,Z.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,Z.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,Z.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>k(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,Z.jsx)(S,{size:16})}),(0,Z.jsx)(B,{variant:`outline`,size:`sm`,"data-testid":`reset-mfa-button`,"aria-label":e(`userManager.mfaReset`),title:e(`userManager.mfaReset`),onClick:()=>D(t.id,t.username),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,Z.jsx)(h,{size:16})}),(0,Z.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>E(t.id,t.username),disabled:t.id===p?.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,Z.jsx)(T,{size:16})})]})]},t.id))})})]})]})},oe=()=>{let{t:e}=s(),t=z(e=>e.systemInfo),n=z(e=>e.setSystemInfo),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return L.access().then(t=>{e||(t.success&&t.data?(i(t.data.enabled),o(t.data.lockedByEnv)):d(!0))}).catch(()=>{e||d(!0)}),()=>{e=!0}},[f]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.agentAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.agentAccess.description`)}),a&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.agentAccess.lockedByEnv`)})]}),r===null&&u?(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{d(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:r===!0,onChange:async r=>{l(!0);try{let a=await L.setAccess(r);if(!a.success||!a.data)throw Error(a.error||`Agent access update failed.`);i(a.data.enabled),t&&n({...t,agentsEnabled:a.data.enabled}),y.success(e(`userManager.agentAccess.saved`))}catch{y.error(e(`userManager.agentAccess.saveFailed`))}finally{l(!1)}},disabled:c||r===null||a})]})})},se=[{mode:`light`,icon:l,key:`settings.appearance.theme.light`},{mode:`dark`,icon:v,key:`settings.appearance.theme.dark`},{mode:`amoled`,icon:E,key:`settings.appearance.theme.amoled`},{mode:`celestial`,icon:g,key:`settings.appearance.theme.celestial`}],ce=()=>{let{t:e}=s(),t=z(e=>e.systemInfo),n=z(e=>e.setSystemInfo),r=re(e=>e.applyInstanceTheme),[i,a]=(0,X.useState)(null),[o,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return F.getDefaultTheme().then(t=>{e||(t.success&&t.data?a(ne(t.data.theme)):d(!0))}).catch(()=>{e||d(!0)}),()=>{e=!0}},[f]);let m=async o=>{if(!(!i||i.mode===o)){l(!0);try{let s=await F.setDefaultTheme({...i,mode:o});if(!s.success||!s.data)throw Error(s.error||`Default theme update failed.`);let c=ne(s.data.theme);a(c),t&&n({...t,defaultTheme:c}),r(c),y.success(e(`userManager.defaultTheme.saved`))}catch{y.error(e(`userManager.defaultTheme.saveFailed`))}finally{l(!1)}}};return(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.defaultTheme.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.defaultTheme.description`)})]}),i===null&&u?(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{d(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`userManager.defaultTheme.title`),className:`flex flex-wrap gap-2`,children:se.map(({mode:t,icon:n,key:r})=>{let a=i?.mode===t;return(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":a,disabled:o||i===null,onClick:()=>void m(t),className:c(`flex items-center gap-2 rounded-lg border px-3 py-2 text-sm text-ink transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 disabled:cursor-not-allowed disabled:opacity-60`,a?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Z.jsx)(n,{className:`h-4 w-4`,"aria-hidden":`true`}),e(r)]},t)})})]})})},le=()=>{let{t:e}=s(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return P.getAccessMode().then(t=>{e||(t.success&&t.data?(n(t.data.mode),i(t.data.lockedByEnv)):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.tools.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.tools.description`)}),r&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.tools.lockedByEnv`)})]}),t===null&&c?(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),d(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;o(!0);try{let t=await P.setAccessMode(r);if(!t.success)throw Error(t.error||`Tool access update failed.`);n(r),y.success(e(`userManager.tools.saved`))}catch{y.error(e(`userManager.tools.saveFailed`))}finally{o(!1)}},disabled:a||t===null||r})]})})},ue={stt:{mode:`all-users`,lockedByEnv:!1},tts:{mode:`all-users`,lockedByEnv:!1},"voice-mode":{mode:`all-users`,lockedByEnv:!1},"voice-cloning":{mode:`all-users`,lockedByEnv:!1}},de={getModes:async()=>a()?k(ue):(await O.get(`/voice-access`)).data,setMode:async(e,t)=>a()?k({feature:e,mode:t}):(await O.put(`/voice-access/${encodeURIComponent(e)}`,{mode:t})).data},fe=[{key:`stt`,labelKey:`userManager.voice.features.stt`},{key:`tts`,labelKey:`userManager.voice.features.tts`},{key:`voice-mode`,labelKey:`userManager.voice.features.voiceMode`},{key:`voice-cloning`,labelKey:`userManager.voice.features.voiceCloning`}],pe=()=>{let{t:e}=s(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return de.getModes().then(t=>{e||(t.success&&t.data?n(t.data):o(!0))}).catch(()=>{e||o(!0)}),()=>{e=!0}},[c]);let u=async(t,r)=>{let a=r?`all-users`:`admins`;i(t);try{let r=await de.setMode(t,a);if(!r.success)throw Error(r.error||`Voice access update failed.`);n(e=>e&&{...e,[t]:{...e[t],mode:a}}),y.success(e(`userManager.voice.saved`))}catch{y.error(e(`userManager.voice.saveFailed`))}finally{i(null)}};return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.voice.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.voice.description`)})]}),t===null&&a&&(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{o(!1),l(e=>e+1)},children:e(`common.retry`)})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:fe.map(n=>{let i=t?.[n.key];return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:e(n.labelKey)}),i?.lockedByEnv&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:e(`userManager.voice.lockedByEnv`)})]}),(0,Z.jsx)(Y,{checked:i?.mode===`all-users`,onChange:e=>u(n.key,e),disabled:i===void 0||r===n.key||i.lockedByEnv})]},n.key)})})]})},me=()=>{let{t:e}=s(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return j.getMfaPolicy().then(t=>{e||(t.success&&t.data?n(t.data):o(!0))}).catch(()=>{e||o(!0)}),()=>{e=!0}},[c]),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.mfaPolicy.description`)})]}),t===null&&a&&(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{o(!1),l(e=>e+1)},children:e(`common.retry`)})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.requireAll`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t?.locked?e(`userManager.mfaPolicy.lockedByEnv`):e(`userManager.mfaPolicy.requireAllHint`)})]}),(0,Z.jsx)(Y,{checked:t?.mode===`required`,disabled:t===null||t.locked||r,onChange:async t=>{let r=t?`required`:`optional`;i(!0);try{let t=await j.setMfaPolicy(r);if(!t.success||!t.data)throw Error(t.error||`MFA policy update failed.`);n(t.data),y.success(e(`userManager.mfaPolicy.saved`))}catch{y.error(e(`userManager.mfaPolicy.saveFailed`))}finally{i(!1)}}})]})]})},he=()=>{let{t:e}=s(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!0),[u,d]=(0,X.useState)(!1),[p,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,b]=(0,X.useState)(!1),[ee,S]=(0,X.useState)(null),[C,E]=(0,X.useState)(``),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(``),[j,P]=(0,X.useState)(null),[F,I]=(0,X.useState)(!1),L=(0,X.useMemo)(()=>{let e=new Map;return r.forEach(t=>e.set(t.id,t.username)),e},[r]),R=(0,X.useCallback)(async()=>{l(!0),o(!1);try{let[e,t]=await Promise.all([M.getGroups(),N.getUsers()]);if(!e.success||!e.data)throw Error(e.error||`Failed to load groups.`);n(e.data),t.success&&t.data&&i(t.data)}catch{o(!0)}finally{l(!1)}},[]);(0,X.useEffect)(()=>{let e=setTimeout(()=>void R(),0);return()=>clearTimeout(e)},[R]);let z=async t=>{if(t.preventDefault(),!p.trim()){y.error(e(`userManager.groups.nameRequired`,`Give the group a name.`));return}b(!0);try{let t=await M.createGroup({name:p.trim(),description:g.trim()||void 0});if(!t.success)throw Error(t.error||`Group creation failed.`);h(``),_(``),d(!1),y.success(e(`userManager.groups.created`,`Group created.`)),await R()}catch(t){y.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.createFailed`,`The group could not be created.`))}finally{b(!1)}},ne=async t=>{O(t.id);try{let n=await M.deleteGroup(t.id);if(!n.success)throw Error(n.error||`Group delete failed.`);y.success(e(`userManager.groups.deleted`,`Group deleted.`)),ee===t.id&&S(null),await R()}catch(t){y.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.deleteFailed`,`The group could not be deleted.`))}finally{O(null)}},re=async t=>{if(C){O(t.id);try{let n=await M.addGroupMember(t.id,C);if(!n.success)throw Error(n.error||`Member add failed.`);E(``),y.success(e(`userManager.groups.memberAdded`,`Member added.`)),await R()}catch(t){y.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberAddFailed`,`The member could not be added.`))}finally{O(null)}}},V=async(t,n)=>{O(t.id);try{let r=await M.removeGroupMember(t.id,n);if(!r.success)throw Error(r.error||`Member remove failed.`);y.success(e(`userManager.groups.memberRemoved`,`Member removed.`)),await R()}catch(t){y.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberRemoveFailed`,`The member could not be removed.`))}finally{O(null)}},H=async t=>{if(A(t),P(null),t){I(!0);try{let e=await M.getEffectiveAccess(t);if(!e.success||!e.data)throw Error(e.error||`Access lookup failed.`);P(e.data)}catch(t){y.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.accessLookupFailed`,`The effective access could not be loaded.`))}finally{I(!1)}}},U=e=>e.map(e=>({value:e.id,label:e.username}));return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(te,{className:`h-4 w-4 text-primary-500`}),e(`userManager.groups.title`,`Groups`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.groups.description`,`Group accounts to manage shared access, and inspect what any account can effectively do.`)})]}),a?(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>void R(),children:e(`common.retry`)}):(0,Z.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>d(e=>!e),className:`gap-1.5`,children:[(0,Z.jsx)(w,{size:14}),e(`userManager.groups.newGroup`,`New group`)]})]}),u&&(0,Z.jsxs)(`form`,{onSubmit:z,className:`mt-4 rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50 p-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.nameLabel`,`Name`)}),(0,Z.jsx)(J,{value:p,onChange:e=>h(e.target.value)})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.descriptionLabel`,`Description (optional)`)}),(0,Z.jsx)(J,{value:g,onChange:e=>_(e.target.value)})]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(B,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>d(!1),children:e(`common.cancel`)}),(0,Z.jsx)(B,{type:`submit`,size:`sm`,disabled:v,children:v?e(`userManager.groups.creating`,`Creating…`):e(`userManager.groups.create`,`Create group`)})]})]}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-3`,children:c?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):a?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.loadFailed`,`The groups could not be loaded.`)}):t.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.empty`,`No groups yet.`)}):t.map(t=>{let n=ee===t.id,i=new Set(t.members.map(e=>e.user_id)),a=r.filter(e=>!i.has(e.id));return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-100`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-4`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-start`,onClick:()=>{S(n?null:t.id),E(``)},"aria-expanded":n,children:[n?(0,Z.jsx)(f,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(m,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:[t.name,(0,Z.jsx)(`span`,{className:`ms-2 text-xs font-normal text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberCount`,{count:t.members.length,defaultValue:`Members: {{count}}`})})]}),t.description&&(0,Z.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:t.description})]})]}),(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>void ne(t),disabled:D===t.id,"aria-label":e(`userManager.groups.deleteGroup`,`Delete group`),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,Z.jsx)(T,{size:16})})]}),n&&(0,Z.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 p-4 space-y-3`,children:[t.members.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.noMembers`,`No members yet.`)}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:t.members.map(n=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-50 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:L.get(n.user_id)||n.user_id}),(0,Z.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`userManager.groups.addedAt`,`Added`),`:`,` `,new Date(n.added_at).toLocaleDateString()]})]}),(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>void V(t,n.user_id),disabled:D===t.id,"aria-label":e(`userManager.groups.removeMember`,`Remove member`),children:(0,Z.jsx)(x,{size:16})})]},n.user_id))}),a.length>0&&(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex-1`,children:(0,Z.jsx)(W,{label:e(`userManager.groups.addMember`,`Add member`),value:C,onChange:e=>E(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...U(a)]})}),(0,Z.jsx)(B,{size:`sm`,onClick:()=>void re(t),disabled:!C||D===t.id,className:`mb-0.5`,children:e(`userManager.groups.add`,`Add`)})]})]})]},t.id)})}),(0,Z.jsxs)(`div`,{className:`mt-6 border-t border-gray-200 dark:border-dark-300 pt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.effectiveTitle`,`Effective access`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.groups.effectiveDescription`,`Pick an account to see the access it ends up with across role, groups, and grants.`)})]}),(0,Z.jsx)(W,{value:k,onChange:e=>void H(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...U(r)]}),F&&(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}),j&&!F&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50 p-4 space-y-3`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:j.username}),(0,Z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[` · `,e(`userManager.groups.roleLabel`,`Role`),`: `,j.role,` · `,e(`userManager.groups.statusLabel`,`Status`),`: `,j.status]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberOf`,`Groups`)}),j.groups.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:j.groups.map(e=>(0,Z.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs text-primary-700 dark:text-primary-300`,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.featuresLabel`,`Feature access`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(j.features).map(([t,n])=>(0,Z.jsxs)(`span`,{className:n?`rounded-full bg-green-100 dark:bg-green-900/30 px-2 py-0.5 text-xs text-green-700 dark:text-green-300`:`rounded-full bg-gray-100 dark:bg-dark-200 px-2 py-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[t,`: `,e(n?`common.yes`:`common.no`)]},t))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.grantsLabel`,`Grants`)}),j.grants.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Z.jsx)(`div`,{className:`space-y-1`,children:j.grants.map(t=>(0,Z.jsxs)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[t.resourceType,`/`,t.resourceId,` ·`,` `,t.permission,` `,(0,Z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[`(`,e(`userManager.groups.grantVia`,`via`),` `,t.via,`)`]})]},t.id))})]})]})]})]})},ge={success:`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300`,denied:`bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300`,failure:`bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300`},_e=()=>{let{t:e}=s(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(!0),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[v,y]=(0,X.useState)(`50`),b=(0,X.useCallback)(async()=>{i(!0),o(!1);try{let e=Number(v),t=await M.getAuditEvents({action:u.trim()||void 0,result:h||void 0,limit:Number.isInteger(e)&&e>0?e:void 0});if(!t.success||!t.data)throw Error(t.error||`Failed to load audit events.`);n(t.data)}catch{o(!0)}finally{i(!1)}},[u,h,v]);(0,X.useEffect)(()=>{let e=setTimeout(()=>void b(),0);return()=>clearTimeout(e)},[]);let x=t=>{switch(t){case`success`:return e(`userManager.audit.resultSuccess`,`Success`);case`denied`:return e(`userManager.audit.resultDenied`,`Denied`);case`failure`:return e(`userManager.audit.resultFailure`,`Failure`);default:return t}};return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(p,{className:`h-4 w-4 text-primary-500`}),e(`userManager.audit.title`,`Security audit log`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.audit.description`,`Recent sign-ins, permission checks, and administrative changes on this instance.`)})]}),(0,Z.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:r,className:`gap-1.5`,children:[(0,Z.jsx)(_,{size:14,className:r?`animate-spin`:void 0}),e(`common.refresh`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.actionFilter`,`Action`)}),(0,Z.jsx)(J,{value:u,onChange:e=>d(e.target.value),placeholder:e(`userManager.audit.actionPlaceholder`,`e.g. auth.login`),spellCheck:!1,dir:`ltr`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.resultFilter`,`Result`)}),(0,Z.jsx)(W,{value:h,onChange:e=>g(e.target.value),options:[{value:``,label:e(`common.all`)},{value:`success`,label:e(`userManager.audit.resultSuccess`,`Success`)},{value:`denied`,label:e(`userManager.audit.resultDenied`,`Denied`)},{value:`failure`,label:e(`userManager.audit.resultFailure`,`Failure`)}]})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.limitFilter`,`Limit`)}),(0,Z.jsx)(J,{type:`number`,min:1,max:500,value:v,onChange:e=>y(e.target.value),dir:`ltr`})]})]}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-2`,children:r?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):a?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.loadFailed`,`The audit log could not be loaded.`)}),(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>void b(),children:e(`common.retry`)})]}):t.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.empty`,`No audit events recorded yet.`)}):t.map(t=>{let n=c===t.id,r=t.details&&Object.keys(t.details).length>0;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 px-3 py-2 text-start`,onClick:()=>l(n?null:t.id),"aria-expanded":n,children:[r?n?(0,Z.jsx)(f,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(m,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(`span`,{className:`h-4 w-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.action}),(0,Z.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${ge[t.result]||`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-300`}`,children:x(t.result)})]}),(0,Z.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-gray-500 dark:text-gray-400`,children:[new Date(t.occurredAt).toLocaleString(),` · `,e(`userManager.audit.actor`,`Actor`),`:`,` `,t.actorUserId||t.actorKind,t.targetType&&(0,Z.jsxs)(Z.Fragment,{children:[` · `,e(`userManager.audit.target`,`Target`),`:`,` `,t.targetType,t.targetId?`/${t.targetId}`:``]})]})]})]}),n&&r&&(0,Z.jsx)(`pre`,{dir:`ltr`,className:`mx-3 mb-3 overflow-x-auto rounded-md bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 p-3 text-xs text-gray-700 dark:text-gray-300`,children:JSON.stringify(t.details,null,2)})]},t.id)})})]})},ve=()=>{let{t:e}=s(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return R.getModelAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):o(!0))}).catch(()=>{e||o(!0)}),()=>{e=!0}},[c]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.modelAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.modelAccess.description`)})]}),t===null&&a?(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{o(!1),l(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;i(!0);try{if(!(await R.setModelAccess(r)).success)throw Error(`Model download access update failed.`);n(r),y.success(e(`userManager.modelAccess.saved`))}catch{y.error(e(`userManager.modelAccess.saveFailed`))}finally{i(!1)}},disabled:r||t===null})]})})},ye=()=>{let{t:e}=s(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return R.getSettings().then(t=>{e||(t.success&&t.data?(n(t.data),i(t.data.baseUrl)):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]);let f=async t=>{o(!0);try{let r=await R.updateSettings(t);if(!r.success||!r.data)throw Error(r.message||`update failed`);n(r.data),i(r.data.baseUrl),y.success(e(`userManager.ollamaProvider.saved`))}catch{y.error(e(`userManager.ollamaProvider.saveFailed`))}finally{o(!1)}},p=t!==null&&r.trim()!==t.baseUrl;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.ollamaProvider.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.ollamaProvider.description`)})]}),t===null&&c?(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),d(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:t?.enabled===!0,onChange:e=>void f({enabled:e}),disabled:a||t===null})]}),t!==null&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 font-mono text-xs text-gray-900 focus:border-primary-400 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,value:r,onChange:e=>i(e.target.value),placeholder:`http://localhost:11434`,spellCheck:!1,"aria-label":e(`userManager.ollamaProvider.baseUrlLabel`)}),(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>void f({baseUrl:r.trim()}),disabled:a||!p||!r.trim(),children:e(`common.save`)})]})]})},be=()=>{let{t:e}=s(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return I.getAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):o(!0))}).catch(()=>{e||o(!0)}),()=>{e=!0}},[c]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.webSearchAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.webSearchAccess.description`)})]}),t===null&&a?(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{o(!1),l(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;i(!0);try{if(!(await I.setAccess(r)).success)throw Error(`Web search access update failed.`);n(r),y.success(e(`userManager.webSearchAccess.saved`))}catch{y.error(e(`userManager.webSearchAccess.saveFailed`))}finally{i(!1)}},disabled:r||t===null})]})})},xe=()=>{let{t:e}=s(),t=z(e=>e.refreshWorkAccess),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!1),[o,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return A.access().then(t=>{e||(t.success&&t.data?r(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAccess.description`)})]}),n===null&&o?(0,Z.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:n===`all-users`,onChange:async n=>{let i=n?`all-users`:`admins`;a(!0);try{if(!(await A.setAccess(i)).success)throw Error(`Work access update failed.`);r(i),await t(),y.success(e(`userManager.workAccess.saved`))}catch{y.error(e(`userManager.workAccess.saveFailed`))}finally{a(!1)}},disabled:i||n===null})]})})},$={name:``,image:``,memoryLimit:``,cpuLimit:``,pidsLimit:``,workspaceSize:``,idleMinutes:``,networkDefault:`inherit`,guiEnabled:!1,takeoverEnabled:!0,approvalsRequired:!1},Se={...$,name:`Work Computer`,image:`libre-work-computer:latest`,memoryLimit:`4g`,networkDefault:`on`,guiEnabled:!0},Ce=e=>({name:e.name,guiEnabled:e.guiEnabled===!0,takeoverEnabled:e.takeoverEnabled!==!1,approvalsRequired:e.approvalsRequired===!0,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`}),we=e=>[e.pidsLimit,e.idleMinutes].some(e=>e.trim()!==``&&!Number.isFinite(Number(e))),Te=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`,guiEnabled:e.guiEnabled?!0:null,takeoverEnabled:e.takeoverEnabled?null:!1,approvalsRequired:e.approvalsRequired?!0:null}),Ee=()=>{let{t:e}=s(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)($),[c,l]=(0,X.useState)(!1),u=async()=>{try{let e=await A.listPolicies();e.success&&e.data&&n(e.data)}catch{}};(0,X.useEffect)(()=>{let e=!1;return A.listPolicies().then(t=>{!e&&t.success&&t.data&&n(t.data)}).catch(()=>{}),()=>{e=!0}},[]);let d=e=>({value:a[e],onChange:t=>o(n=>({...n,[e]:t.target.value}))}),f=async()=>{if(we(a)){y.error(e(`userManager.workPolicies.invalidNumber`));return}l(!0);try{let t=Te(a),n=r===`new`?await A.createPolicy(t):await A.updatePolicy(r,t);if(!n.success)throw Error(n.error||`Policy save failed.`);y.success(e(`userManager.workPolicies.saved`)),i(null),o($),await u()}catch(t){y.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}finally{l(!1)}},p=async t=>{if(window.confirm(e(`userManager.workPolicies.deleteConfirm`)))try{let n=await A.deletePolicy(t.id);if(!n.success)throw Error(n.error||`Policy delete failed.`);y.success(e(`userManager.workPolicies.deleted`)),await u()}catch(t){y.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}},m=(e,t,n)=>(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:t}),(0,Z.jsx)(`input`,{...d(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,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workPolicies.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workPolicies.description`)})]}),r===null&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(B,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,"data-testid":`work-policy-computer-preset`,onClick:()=>{o(Se),i(`new`)},children:[(0,Z.jsx)(D,{size:14,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.computerPreset`)})]}),(0,Z.jsxs)(B,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,onClick:()=>{o($),i(`new`)},children:[(0,Z.jsx)(w,{size:14,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.add`)})]})]})]}),t.length===0&&r===null&&(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.empty`)}),t.length>0&&(0,Z.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-100 dark:divide-dark-300`,children:t.map(t=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,Z.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,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(B,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.edit`),onClick:()=>{o(Ce(t)),i(t.id)},children:(0,Z.jsx)(C,{size:14})}),(0,Z.jsx)(B,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.delete`),onClick:()=>void p(t),children:(0,Z.jsx)(T,{size:14})})]})]},t.id))}),r!==null&&(0,Z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 p-3 dark:border-dark-300`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[m(`name`,e(`userManager.workPolicies.name`),`heavy`),m(`memoryLimit`,e(`userManager.workPolicies.memory`),`4g`),m(`cpuLimit`,e(`userManager.workPolicies.cpu`),`4`),m(`pidsLimit`,e(`userManager.workPolicies.pids`),`512`),m(`workspaceSize`,e(`userManager.workPolicies.workspaceSize`),`20Gi`),m(`idleMinutes`,e(`userManager.workPolicies.idleMinutes`),`30`),(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.networkDefault`)}),(0,Z.jsxs)(`select`,{...d(`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,Z.jsx)(`option`,{value:`inherit`,children:e(`userManager.workPolicies.networkInherit`)}),(0,Z.jsx)(`option`,{value:`on`,children:e(`userManager.workPolicies.networkOn`)}),(0,Z.jsx)(`option`,{value:`off`,children:e(`userManager.workPolicies.networkOff`)})]})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-gui`,checked:a.guiEnabled,onChange:e=>o(t=>({...t,guiEnabled:e.target.checked})),className:`h-3.5 w-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.guiEnabled`)})]}),a.guiEnabled&&(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-takeover`,checked:a.takeoverEnabled,onChange:e=>o(t=>({...t,takeoverEnabled:e.target.checked})),className:`h-3.5 w-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.takeoverEnabled`)})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-approvals`,checked:a.approvalsRequired,onChange:e=>o(t=>({...t,approvalsRequired:e.target.checked})),className:`h-3.5 w-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.approvalsRequired`)})]}),m(`image`,e(`userManager.workPolicies.image`),`node:22-bookworm@sha256:…`)]}),a.guiEnabled&&(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.computerPresetHint`)}),(0,Z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Z.jsx)(B,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>{i(null),o($)},children:e(`userManager.workPolicies.cancel`)}),(0,Z.jsx)(B,{size:`sm`,disabled:c||!a.name.trim(),onClick:()=>void f(),children:e(`userManager.workPolicies.save`)})]})]})]})},De=()=>(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(ce,{}),(0,Z.jsx)(xe,{}),(0,Z.jsx)(Ee,{}),(0,Z.jsx)(ye,{}),(0,Z.jsx)(ve,{}),(0,Z.jsx)(be,{}),(0,Z.jsx)(oe,{}),(0,Z.jsx)(le,{}),(0,Z.jsx)(pe,{}),(0,Z.jsx)(me,{}),(0,Z.jsx)(he,{}),(0,Z.jsx)(_e,{}),(0,Z.jsx)(ae,{})]});export{De as UserManagementPanel,De as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./workApi-C-WfyZSs.js";import{m as e,s as t,z as n}from"./api-CgnEj5Jc.js";import"./imageGenModels-Dx_QMLJQ.js";export{n as agentCliApi,e as personaApi,t as preferencesApi};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./logger-DnuT4jgB.js";import{t}from"./config-D7WLbWrW.js";import{i as n,n as r,r as i}from"./workApi-C-WfyZSs.js";var a={getModels:()=>e()?i([]):r.get(`/agent-clis/models`).then(e=>e.data)},o=[{name:`llama3.2:3b`,size:2048e6,digest:`demo-digest-1`,modified_at:new Date().toISOString(),details:{format:`gguf`,family:`llama`,families:[`llama`],parameter_size:`3B`,quantization_level:`Q4_0`}},{name:`qwen2.5:7b`,size:4096e6,digest:`demo-digest-2`,modified_at:new Date().toISOString(),details:{format:`gguf`,family:`qwen`,families:[`qwen`],parameter_size:`7B`,quantization_level:`Q4_0`}}],s=()=>[{id:`demo-session-1`,title:`Demo Chat Session`,model:o[0].name,providerType:`ollama`,providerId:null,messages:[{id:`demo-msg-1`,role:`user`,content:`Hello! Can you tell me about this demo?`,timestamp:Date.now()},{id:`demo-msg-2`,role:`assistant`,content:`This is a demo of Libre WebUI! In a real deployment, I would be powered by Ollama running locally on your machine. This demo shows the beautiful interface and features without the backend connection.`,timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()}],c=s(),l={theme:{mode:`celestial`,adaptToAccent:!1,accent:`blue`,customAccent:`#2563eb`},defaultModel:`llama3.2:3b`,defaultProviderType:`ollama`,defaultProviderId:null,visionModel:``,visionProviderType:null,visionProviderId:null,systemMessage:`You are a helpful assistant.`,generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},titleSettings:{autoTitle:!1,taskModel:``,taskProviderType:null,taskProviderId:null},showUsername:!1,hapticFeedbackEnabled:!1,workRemoteProviderDisclosureDismissed:!1,backgroundSettings:{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6}},u={...l,theme:{...l.theme},generationOptions:{...l.generationOptions},embeddingSettings:{...l.embeddingSettings},titleSettings:{...l.titleSettings},backgroundSettings:{...l.backgroundSettings}},d=()=>u,f=e=>{let t=u.backgroundSettings||l.backgroundSettings;return u={...u,...e,theme:{...u.theme,...e.theme},generationOptions:{...u.generationOptions,...e.generationOptions},embeddingSettings:{...u.embeddingSettings,...e.embeddingSettings},titleSettings:e.titleSettings?{...u.titleSettings||l.titleSettings,...e.titleSettings}:u.titleSettings,backgroundSettings:e.backgroundSettings?{...t,...e.backgroundSettings}:u.backgroundSettings},u},p=`0.34.2`,m=[`chat`,`models`,`documents`,`notes`,`personas`,`media`,`work`,`admin`],h=e=>!!e&&e.mfaRequired===!0,ee={login:t=>e()?i({user:{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:p}}):r.post(`/auth/login`,t).then(e=>e.data),signup:t=>e()?i({user:{id:`demo-user-new`,username:t.username,email:t.email||``,role:`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token-new`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:p,turnstile:{enabled:!1}}}):r.post(`/auth/signup`,t).then(e=>e.data),logout:()=>e()?i(void 0):r.post(`/auth/logout`).then(e=>e.data),getSystemInfo:()=>(n.debug(`getSystemInfo called, demo mode:`,e()),e()?i({requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:p,turnstile:{enabled:!1},defaultTheme:l.theme}):(n.debug(`Making API call to:`,t+`/auth/system-info`),n.debug(`Full URL from:`,window.location.origin,`-> API:`,t+`/auth/system-info`),r.get(`/auth/system-info`).then(e=>(n.debug(`getSystemInfo response:`,e.data),e.data)).catch(e=>{throw n.debug(`getSystemInfo error:`,e),e.response&&(n.debug(`Error response data:`,e.response.data),n.debug(`Error status:`,e.response.status),n.debug(`Error headers:`,e.response.headers)),e.request&&n.debug(`Network error - no response received:`,e.request),n.debug(`Error config:`,e.config),e}))),verifyToken:()=>e()?i({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):r.get(`/auth/verify`).then(e=>e.data),getEncryptionKey:()=>e()?i({encryptionKey:`demo-encryption-key-not-real`}):r.get(`/auth/encryption-key`).then(e=>e.data),getSessions:()=>e()?i([{id:`demo-session`,kind:`password`,userAgent:navigator.userAgent,createdAt:new Date().toISOString(),lastSeenAt:new Date().toISOString(),expiresAt:null,revokedAt:null,current:!0}]):r.get(`/auth/sessions`).then(e=>e.data),revokeSession:t=>e()?i(void 0):r.delete(`/auth/sessions/${t}`).then(e=>e.data),revokeOtherSessions:()=>e()?i({revokedCount:0}):r.post(`/auth/sessions/revoke-others`).then(e=>e.data),listApiTokens:()=>e()?i([]):r.get(`/auth/tokens`).then(e=>e.data),createApiToken:t=>e()?i({token:`lwui_demo_not_a_real_token`,record:{id:`demo-token-`+Date.now(),name:t.name,tokenPrefix:`lwui_demo`,scopes:t.scopes,createdAt:new Date().toISOString(),expiresAt:null,lastUsedAt:null,revokedAt:null}}):r.post(`/auth/tokens`,t).then(e=>e.data),revokeApiToken:t=>e()?i(void 0):r.delete(`/auth/tokens/${t}`).then(e=>e.data),mfaVerify:e=>r.post(`/auth/mfa/verify`,e).then(e=>e.data),mfaEnrollChallenge:e=>r.post(`/auth/mfa/enroll-challenge`,e).then(e=>e.data),mfaActivateChallenge:e=>r.post(`/auth/mfa/activate-challenge`,e).then(e=>e.data),getMfaStatus:()=>e()?i({totpEnabled:!1,totpPending:!1,recoveryCodesRemaining:0,required:!1,requiredModeLocked:!1,passkeys:[]}):r.get(`/auth/mfa`).then(e=>e.data),mfaEnroll:()=>r.post(`/auth/mfa/enroll`).then(e=>e.data),mfaActivate:e=>r.post(`/auth/mfa/activate`,e).then(e=>e.data),mfaRegenerateRecoveryCodes:e=>r.post(`/auth/mfa/recovery-codes`,e).then(e=>e.data),mfaDisable:e=>r.post(`/auth/mfa/disable`,e).then(e=>e.data),getMfaPolicy:()=>e()?i({mode:`optional`,locked:!1}):r.get(`/auth/mfa/policy`).then(e=>e.data),setMfaPolicy:e=>r.put(`/auth/mfa/policy`,{mode:e}).then(e=>e.data),passkeyRegisterOptions:()=>r.post(`/auth/passkeys/register-options`).then(e=>e.data),passkeyRegister:e=>r.post(`/auth/passkeys/register`,e).then(e=>e.data),listPasskeys:()=>e()?i([]):r.get(`/auth/passkeys`).then(e=>e.data),deletePasskey:e=>r.delete(`/auth/passkeys/${e}`).then(e=>e.data),passkeyLoginOptions:()=>r.post(`/auth/passkeys/login-options`).then(e=>e.data),passkeyLogin:e=>r.post(`/auth/passkeys/login`,e).then(e=>e.data)},te={getUsers:()=>e()?i([{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]):r.get(`/users`).then(e=>e.data),createUser:t=>e()?i({id:`new-user-`+Date.now(),username:t.username,email:t.email,role:t.role,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):r.post(`/users`,t).then(e=>e.data),updateUser:(t,n)=>e()?i({id:t,username:n.username||`demo`,email:n.email||`demo@example.com`,role:n.role||`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):r.patch(`/users/${t}`,n).then(e=>e.data),deleteUser:t=>e()?i(void 0):r.delete(`/users/${t}`).then(e=>e.data),getPendingApprovals:()=>e()?i({count:0,latestCreatedAt:null}):r.get(`/users/pending-approvals`).then(e=>e.data),approveUser:t=>e()?i({id:t,username:`demo-user`,email:`demo@example.com`,role:`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):r.patch(`/users/${t}/approve`).then(e=>e.data),resetUserMfa:e=>r.post(`/users/${e}/mfa/reset`).then(e=>e.data),updateMyAvatar:t=>e()?i({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,avatar:t,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):r.patch(`/users/me/avatar`,{avatar:t}).then(e=>e.data)},ne={getGroups:()=>e()?i([]):r.get(`/groups`).then(e=>e.data),createGroup:t=>e()?i({id:`demo-group-`+Date.now(),name:t.name,description:t.description??null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),members:[]}):r.post(`/groups`,t).then(e=>e.data),updateGroup:(t,n)=>e()?i({id:t,name:n.name??`demo-group`,description:n.description??null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),members:[]}):r.patch(`/groups/${t}`,n).then(e=>e.data),deleteGroup:t=>e()?i(void 0):r.delete(`/groups/${t}`).then(e=>e.data),addGroupMember:(t,n)=>e()?i({id:t,name:`demo-group`,description:null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),members:[]}):r.post(`/groups/${t}/members`,{userId:n}).then(e=>e.data),removeGroupMember:(t,n)=>e()?i(void 0):r.delete(`/groups/${t}/members/${n}`).then(e=>e.data),getEffectiveAccess:t=>e()?i({userId:t,username:`demo`,role:`admin`,status:`active`,groups:[],features:{work:!0,"model-download":!0,"web-search":!0,agents:!0},grants:[]}):r.get(`/groups/effective/${t}`).then(e=>e.data),getAuditEvents:(t={})=>{if(e())return i([]);let n=new URLSearchParams;t.action&&n.set(`action`,t.action),t.actor&&n.set(`actor`,t.actor),t.result&&n.set(`result`,t.result),t.limit&&n.set(`limit`,String(t.limit));let a=n.toString()?`?${n.toString()}`:``;return r.get(`/audit${a}`).then(e=>e.data)}},g={getSessions:()=>r.get(`/chat/sessions`).then(e=>e.data),createSession:(e,t,n,i,a)=>r.post(`/chat/sessions`,{model:e,title:t,personaId:n,providerType:i,providerId:a}).then(e=>e.data),getSession:t=>{if(e()){let e=s().find(e=>e.id===t);return e?i(e):Promise.resolve({success:!1,error:`Session not found in demo mode`})}return r.get(`/chat/sessions/${t}`).then(e=>e.data)},updateSession:(t,n)=>{if(e()){let e=c.findIndex(e=>e.id===t),r=c[e];if(r){let t={...r,...n,updatedAt:Date.now()};return c[e]=t,i(t)}return Promise.resolve({success:!1,error:`Session not found in demo mode`})}return r.put(`/chat/sessions/${t}`,n).then(e=>e.data)},forkSession:(e,t={})=>r.post(`/chat/sessions/${e}/fork`,t).then(e=>e.data),enqueuePrompt:(e,t)=>r.post(`/chat/sessions/${e}/queue`,{content:t}).then(e=>e.data),updateQueuedPrompt:(e,t,n)=>r.put(`/chat/sessions/${e}/queue/${t}`,{content:n}).then(e=>e.data),reorderPromptQueue:(e,t)=>r.put(`/chat/sessions/${e}/queue`,{order:t}).then(e=>e.data),claimQueuedPrompt:(e,t)=>r.delete(`/chat/sessions/${e}/queue/${t}`).then(e=>e.data),truncateMessagesFrom:(t,n)=>{if(e()){let e=c.find(e=>e.id===t);if(e){let t=e.messages.findIndex(e=>e.id===n);return t===-1?Promise.resolve({success:!1,error:`Message not found in demo mode`}):(e.messages=e.messages.slice(0,t),e.updatedAt=Date.now(),i(e))}return Promise.resolve({success:!1,error:`Session not found in demo mode`})}return r.post(`/chat/sessions/${t}/messages/${n}/truncate`).then(e=>e.data)},deleteSession:t=>e()?i(null):r.delete(`/chat/sessions/${t}`).then(e=>e.data),clearAllSessions:()=>r.delete(`/chat/sessions`).then(e=>e.data),generateTitle:(t,n,a,o,s)=>{if(e()){let e=a.substring(0,30)+(a.length>30?`...`:``);return i({title:e,source:`fallback`,updatedAt:Date.now()})}return r.post(`/chat/sessions/${t}/generate-title`,{model:n,message:a,providerType:o,providerId:s}).then(e=>e.data)},getFolders:()=>e()?i([]):r.get(`/chat/folders`).then(e=>e.data),createFolder:e=>r.post(`/chat/folders`,{name:e}).then(e=>e.data),renameFolder:(e,t)=>r.put(`/chat/folders/${e}`,{name:t}).then(e=>e.data),deleteFolder:e=>r.delete(`/chat/folders/${e}`).then(e=>e.data),generateFollowUps:t=>e()?i({suggestions:[]}):r.post(`/chat/sessions/${t}/followups`).then(e=>e.data),sendMessage:(e,t,n)=>r.post(`/chat/sessions/${e}/messages`,{content:t,options:n}).then(e=>e.data),saveMessage:(e,t)=>r.post(`/chat/sessions/${e}/messages`,t).then(e=>e.data),updateMessage:(t,n,a)=>e()?i({}):r.put(`/chat/sessions/${t}/messages/${n}`,a).then(e=>e.data),generateChatResponse:(e,t,n)=>r.post(`/chat/sessions/${e}/generate`,{message:t,options:n}).then(e=>e.data),generateChatStreamResponse:(e,r,i)=>({subscribe:async(a,o,s)=>{try{let c=await fetch(`${t}/chat/sessions/${e}/generate/stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:r,options:i})});if(!c.ok)throw Error(`HTTP error! status: ${c.status}`);let l=c.body?.getReader();if(!l)throw Error(`No response body reader available`);let u=new TextDecoder,d=``,f=()=>{l.read().then(({done:e,value:t})=>{if(e){s?.();return}d+=u.decode(t,{stream:!0});let r=d.split(`
|
|
2
|
-
`);d=r.pop()||``;for(let e of r){let t=e.trim();if(t.startsWith(`data: `)){let e=t.slice(6);if(e===`[DONE]`){s?.();return}try{let t=JSON.parse(e);if(a(t),t.type===`done`||t.type===`error`){t.type===`error`?o?.(t.error):s?.();return}}catch(e){n.error(`Failed to parse SSE data:`,e)}}}f()}).catch(e=>{o?.(e instanceof Error?e:Error(String(e)))})};return f(),()=>l.cancel()}catch(e){return o?.(e instanceof Error?e:Error(String(e))),()=>{}}}}),getMessageBranches:(t,n)=>e()?i([]):r.get(`/chat/sessions/${t}/messages/${n}/branches`).then(e=>e.data),switchMessageBranch:(t,n,a)=>e()?i({}):r.post(`/chat/sessions/${t}/messages/${n}/branch`,{branchIndex:a}).then(e=>e.data),createMessageBranch:(t,n,a)=>e()?i({}):r.post(`/chat/sessions/${t}/messages/${n}/branches`,{...a}).then(e=>e.data),restoreCompaction:(e,t)=>r.post(`/chat/sessions/${e}/compaction/${t}/restore`).then(e=>e.data),getContextPolicy:()=>e()?i({windowMessages:10}):r.get(`/chat/context-policy`).then(e=>e.data),getCompactionConfig:()=>e()?i({enabled:!1,thresholdTokens:8e3,keepRecentMessages:8,model:``,prompt:``}):r.get(`/chat/compaction-config`).then(e=>e.data),setCompactionConfig:t=>e()?i({enabled:!1,thresholdTokens:8e3,keepRecentMessages:8,model:``,prompt:``},!1):r.put(`/chat/compaction-config`,t).then(e=>e.data)},_={uploadDocument:(t,n)=>{if(e())return i({id:`demo-doc-`+Date.now(),filename:t.name,fileType:t.name.endsWith(`.pdf`)?`pdf`:`txt`,size:t.size,sessionId:n,uploadedAt:Date.now()});let a=new FormData;return a.append(`document`,t),n&&a.append(`sessionId`,n),r.post(`/documents/upload`,a).then(e=>e.data)},getCollections:()=>e()?i([]):r.get(`/documents/collections`).then(e=>e.data),createCollection:e=>r.post(`/documents/collections`,{name:e}).then(e=>e.data),deleteCollection:e=>r.delete(`/documents/collections/${e}`).then(e=>e.data),setDocumentCollection:(e,t)=>r.put(`/documents/${e}/collection`,{collectionId:t}).then(e=>e.data),fetchWebpage:(t,n)=>e()?i({id:`demo-doc-`+Date.now(),filename:`demo-webpage.txt`,fileType:`txt`,size:0,sessionId:n,uploadedAt:Date.now()}):r.post(`/documents/fetch-url`,{url:t,sessionId:n}).then(e=>e.data),getDocuments:t=>{if(e())return i([]);let n=t?`/documents/session/${t}`:`/documents`;return r.get(n).then(e=>e.data)},getDocument:t=>e()?i({id:t,filename:`demo-document.pdf`,fileType:`pdf`,size:1024,content:`Demo document content...`,uploadedAt:Date.now()}):r.get(`/documents/${t}`).then(e=>e.data),searchDocuments:(t,n,a)=>e()?i([]):r.post(`/documents/search`,{query:t,sessionId:n,limit:a}).then(e=>e.data),deleteDocument:t=>e()?i(void 0):r.delete(`/documents/${t}`).then(e=>e.data),getEmbeddingStatus:()=>e()?i({available:!1,model:`nomic-embed-text`,chunksWithEmbeddings:0,totalChunks:0}):r.get(`/documents/embeddings/status`).then(e=>e.data),regenerateEmbeddings:()=>e()?i({documentsTotal:0,documentsRegenerated:0,documentsSkipped:0,chunksTotal:0,chunksEmbedded:0,model:`nomic-embed-text`,version:`v1`}):r.post(`/documents/embeddings/regenerate`).then(e=>e.data)},v={getModels:()=>e()?i([{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]):r.get(`/embeddings/models`).then(e=>e.data)},y={getNotes:()=>e()?i([]):r.get(`/notes`).then(e=>e.data),getNote:e=>r.get(`/notes/${e}`).then(e=>e.data),createNote:(e,t)=>r.post(`/notes`,{title:e,content:t}).then(e=>e.data),updateNote:(e,t)=>r.put(`/notes/${e}`,t).then(e=>e.data),deleteNote:e=>r.delete(`/notes/${e}`).then(e=>e.data),getRevisions:e=>r.get(`/notes/${e}/revisions`).then(e=>e.data),restoreRevision:(e,t)=>r.post(`/notes/${e}/revisions/${t}/restore`).then(e=>e.data),getAttachments:e=>r.get(`/notes/${e}/attachments`).then(e=>e.data),uploadAttachment:(e,t)=>{let n=new FormData;return n.append(`attachment`,t),r.post(`/notes/${e}/attachments`,n,{headers:{"Content-Type":`multipart/form-data`}}).then(e=>e.data)},downloadAttachment:(e,t)=>r.get(`/notes/${e}/attachments/${t}`,{responseType:`blob`}).then(e=>e.data),deleteAttachment:(e,t)=>r.delete(`/notes/${e}/attachments/${t}`).then(e=>e.data),assist:(e,t)=>r.post(`/notes/${e}/assist`,t).then(e=>e.data)},b={listGrants:(e,t)=>r.get(`/access/grants`,{params:{type:e,id:t}}).then(e=>e.data),createGrant:e=>r.post(`/access/grants`,e).then(e=>e.data),deleteGrant:e=>r.delete(`/access/grants/${e}`).then(e=>e.data),resolvePrincipal:e=>r.get(`/access/principals`,{params:{username:e}}).then(e=>e.data),resolveGroup:e=>r.get(`/access/principals/groups`,{params:{name:e}}).then(e=>e.data)},x={getEvents:(t,n)=>e()?i([]):r.get(`/calendar/events?from=${t}&to=${n}`).then(e=>e.data),createEvent:e=>r.post(`/calendar/events`,e).then(e=>e.data),updateEvent:(e,t)=>r.put(`/calendar/events/${e}`,t).then(e=>e.data),deleteEvent:e=>r.delete(`/calendar/events/${e}`).then(e=>e.data),getCalendars:()=>e()?i([]):r.get(`/calendar/calendars`).then(e=>e.data),createCalendar:e=>r.post(`/calendar/calendars`,e).then(e=>e.data),updateCalendar:(e,t)=>r.put(`/calendar/calendars/${e}`,t).then(e=>e.data),deleteCalendar:e=>r.delete(`/calendar/calendars/${e}`).then(e=>e.data),exportIcs:e=>r.get(e?`/calendar/export?calendarId=${encodeURIComponent(e)}`:`/calendar/export`,{responseType:`blob`}).then(e=>e.data),importIcs:(e,t)=>r.post(`/calendar/import`,{ics:e,...t?{calendarId:t}:{}}).then(e=>e.data)},S={listMine:()=>e()?i([]):r.get(`/channels`).then(e=>e.data),listPublic:()=>e()?i([]):r.get(`/channels/public`).then(e=>e.data),create:e=>r.post(`/channels`,e).then(e=>e.data),openDm:e=>r.post(`/channels/dm`,{userId:e}).then(e=>e.data),get:e=>r.get(`/channels/${e}`).then(e=>e.data),update:(e,t)=>r.patch(`/channels/${e}`,t).then(e=>e.data),delete:e=>r.delete(`/channels/${e}`).then(e=>e.data),join:e=>r.post(`/channels/${e}/join`).then(e=>e.data),listMembers:e=>r.get(`/channels/${e}/members`).then(e=>e.data),addMember:(e,t)=>r.post(`/channels/${e}/members`,{userId:t}).then(e=>e.data),removeMember:(e,t)=>r.delete(`/channels/${e}/members/${encodeURIComponent(t)}`).then(e=>e.data),listMessages:(e,t={})=>{let n=new URLSearchParams;t.before&&n.set(`before`,t.before),t.after&&n.set(`after`,t.after),t.limit&&n.set(`limit`,String(t.limit));let i=n.size>0?`?${n.toString()}`:``;return r.get(`/channels/${e}/messages${i}`).then(e=>e.data)},postMessage:(e,t)=>r.post(`/channels/${e}/messages`,t).then(e=>e.data),listPins:e=>r.get(`/channels/${e}/pins`).then(e=>e.data),markRead:e=>r.post(`/channels/${e}/read`,{}).then(e=>e.data),thread:e=>r.get(`/channels/messages/${e}/thread`).then(e=>e.data),editMessage:(e,t)=>r.patch(`/channels/messages/${e}`,{content:t}).then(e=>e.data),deleteMessage:e=>r.delete(`/channels/messages/${e}`).then(e=>e.data),setPinned:(e,t)=>r.post(`/channels/messages/${e}/pin`,{pinned:t}).then(e=>e.data),addReaction:(e,t)=>r.post(`/channels/messages/${e}/reactions`,{emoji:t}).then(e=>e.data),removeReaction:(e,t)=>r.delete(`/channels/messages/${e}/reactions/${encodeURIComponent(t)}`).then(e=>e.data),uploadAttachment:(e,t)=>{let n=new FormData;return n.append(`attachment`,t),r.post(`/channels/${e}/attachments`,n,{headers:{"Content-Type":`multipart/form-data`}}).then(e=>e.data)},downloadAttachment:e=>r.get(`/channels/attachments/${e}`,{responseType:`blob`}).then(e=>e.data)},C={list:(t={})=>{if(e())return i([]);let n=new URLSearchParams;t.before&&n.set(`before`,String(t.before)),t.limit&&n.set(`limit`,String(t.limit));let a=n.size>0?`?${n.toString()}`:``;return r.get(`/notifications${a}`).then(e=>e.data)},unreadCount:()=>e()?i({count:0}):r.get(`/notifications/unread-count`).then(e=>e.data),markRead:e=>r.post(`/notifications/${e}/read`).then(e=>e.data),markAllRead:()=>r.post(`/notifications/read-all`).then(e=>e.data),delete:e=>r.delete(`/notifications/${e}`).then(e=>e.data)},re={getAutomations:()=>e()?i([]):r.get(`/automations`).then(e=>e.data),createAutomation:e=>r.post(`/automations`,e).then(e=>e.data),updateAutomation:(e,t)=>r.put(`/automations/${e}`,t).then(e=>e.data),deleteAutomation:e=>r.delete(`/automations/${e}`).then(e=>e.data),pauseAutomation:e=>r.post(`/automations/${e}/pause`).then(e=>e.data),resumeAutomation:e=>r.post(`/automations/${e}/resume`).then(e=>e.data),runAutomationNow:e=>r.post(`/automations/${e}/run`).then(e=>e.data),rotateWebhookSecret:e=>r.post(`/automations/${e}/webhook-secret`).then(e=>e.data),disableWebhook:e=>r.delete(`/automations/${e}/webhook-secret`).then(e=>e.data),getOccurrences:(t,n)=>e()?i([]):r.get(`/automations/occurrences?from=${t}&to=${n}`).then(e=>e.data),getRuns:t=>{if(e())return i([]);let n=new URLSearchParams;t?.automationId&&n.set(`automationId`,t.automationId),t?.from!==void 0&&n.set(`from`,String(t.from)),t?.to!==void 0&&n.set(`to`,String(t.to));let a=n.size>0?`?${n.toString()}`:``;return r.get(`/automations/runs${a}`).then(e=>e.data)},getRunsSummary:()=>e()?i({unseenCount:0,days:Array.from({length:30},()=>({succeeded:0,failed:0}))}):r.get(`/automations/runs/summary`).then(e=>e.data),markRunsSeen:()=>r.post(`/automations/runs/seen`).then(e=>e.data)},ie={getConfig:()=>e()?i({enabled:!1,available:!1,allowed:!1}):r.get(`/search/config`).then(e=>e.data),getAccess:()=>e()?i({mode:`admins`,allowed:!1}):r.get(`/search/access`).then(e=>e.data),setAccess:t=>e()?i({mode:t}):r.put(`/search/access`,{mode:t}).then(e=>e.data),setConfig:(t,n,a)=>e()?i({enabled:t,available:t,allowed:!1,url:n}):r.put(`/search/config`,{enabled:t,url:n,...a??{}}).then(e=>e.data),searchApp:t=>e()?i({sessions:[],notes:[],documents:[]}):r.get(`/search/app`,{params:{q:t}}).then(e=>e.data),test:()=>e()?i({ok:!1,results:0},!1):r.post(`/search/test`).then(e=>e.data)},w={getModels:t=>e()?i([{id:`meta-llama/Llama-3.3-70B-Instruct`,modelId:`meta-llama/Llama-3.3-70B-Instruct`,author:`meta-llama`,downloads:1e6,likes:5e3,tags:[`text-generation`,`llama`],pipeline_tag:`text-generation`,gated:!1}]):r.get(`/huggingface-hub/models`,{params:t}).then(e=>e.data),getTrending:t=>e()?i([]):r.get(`/huggingface-hub/trending`,{params:t}).then(e=>e.data),getModel:(t,n)=>e()?i({id:`${t}/${n}`,modelId:`${t}/${n}`,author:t,downloads:0,likes:0,tags:[],gated:!1}):r.get(`/huggingface-hub/models/${t}/${n}`).then(e=>e.data),getTasks:()=>e()?i([`text-generation`,`text-to-speech`,`text-to-image`]):r.get(`/huggingface-hub/tasks`).then(e=>e.data),clearCache:()=>e()?i(!0):r.post(`/huggingface-hub/cache/clear`).then(e=>e.data),getGgufFiles:(t,n)=>e()?i([{filename:`model-Q4_K_M.gguf`,size:45e8,sizeFormatted:`4.19 GB`,quantization:`Q4_K_M`,url:`https://huggingface.co/${t}/${n}/resolve/main/model-Q4_K_M.gguf`,ollamaCommand:`hf.co/${t}/${n}:Q4_K_M`}]):r.get(`/huggingface-hub/models/${t}/${n}/gguf`).then(e=>e.data),hasGgufFiles:(t,n)=>e()?i({hasGguf:!1,count:0}):r.get(`/huggingface-hub/models/${t}/${n}/has-gguf`).then(e=>e.data)};function T(e,t){return t?t.aborted?Promise.reject(t.reason??new DOMException(`The operation was aborted`,`AbortError`)):new Promise((n,r)=>{let i=()=>{r(t.reason??new DOMException(`The operation was aborted`,`AbortError`))};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})}):e}var E={getModels:()=>e()?i([{model:`gpt-image-2`,plugin:`openai`,config:{sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}}]):r.get(`/image-gen/models`).then(e=>e.data),getPlugins:()=>e()?i([{id:`openai`,name:`OpenAI GPT Image`,models:[`gpt-image-2`,`gpt-image-1.5`,`gpt-image-1`,`gpt-image-1-mini`],config:{sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}}]):r.get(`/image-gen/plugins`).then(e=>e.data),getConfig:t=>e()?i({sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}):r.get(`/image-gen/config/${t}`).then(e=>e.data),generate:(t,n)=>e()?T(i({images:[{url:`https://placehold.co/1024x1024/purple/white?text=Demo+Image`,revised_prompt:t.prompt}],model:t.model,pluginId:t.pluginId}),n):r.post(`/image-gen/generate`,t,{signal:n}).then(e=>e.data),getGallery:t=>e()?i({images:[],total:0}):r.get(`/image-gen/gallery`,{params:t}).then(e=>e.data),getGalleryImage:t=>e()?i({id:t,userId:`demo`,prompt:`Demo image prompt`,model:`dall-e-3`,imageData:`https://placehold.co/1024x1024/purple/white?text=Demo`,createdAt:Date.now()}):r.get(`/image-gen/gallery/${t}`).then(e=>e.data),deleteGalleryImage:t=>e()?i(void 0):r.delete(`/image-gen/gallery/${t}`).then(e=>e.data)},D={connected:!1,baseUrl:`http://127.0.0.1:8766`,dashboardUrl:`http://127.0.0.1:8766/dashboard`,error:`Libre Claw daemon is not connected in demo mode.`},O={access:()=>e()?i({enabled:!1,lockedByEnv:!1}):r.get(`/libre-claw/access`).then(e=>e.data),setAccess:t=>e()?i({enabled:t,lockedByEnv:!1}):r.put(`/libre-claw/access`,{enabled:t}).then(e=>e.data),status:()=>e()?i(D):r.get(`/libre-claw/status`).then(e=>e.data),dashboard:()=>e()?i({url:D.dashboardUrl}):r.get(`/libre-claw/dashboard`).then(e=>e.data),currentModel:()=>e()?i({provider:`openrouter`,model:`openrouter/auto`}):r.get(`/libre-claw/config/model`).then(e=>e.data),updateModel:(t,n,a=!1)=>e()?i({provider:t,model:n,persist_global:a}):r.patch(`/libre-claw/config/model`,{provider:t,model:n,persist_global:a}).then(e=>e.data),currentFallback:()=>e()?i({enabled:!1,routes:[]}):r.get(`/libre-claw/config/fallback`).then(e=>e.data),updateFallback:t=>e()?i(t):r.patch(`/libre-claw/config/fallback`,t).then(e=>e.data),updateTheme:(t,n=!0)=>e()?i({theme:t,label:t,persist_global:n}):r.patch(`/libre-claw/config/theme`,{theme:t,persist_global:n}).then(e=>e.data),usage:(t=``,n=250)=>{let a=new URLSearchParams({limit:String(n)});return t&&a.set(`provider`,t),e()?i({summary:{},records:[],text:``}):r.get(`/libre-claw/usage?${a.toString()}`).then(e=>e.data)},listRuns:(t=20)=>e()?i({runs:[]}):r.get(`/libre-claw/runs?limit=${t}`).then(e=>e.data),startRun:t=>{if(e()){let e=new Date().toISOString();return i({run:{run_id:`demo-${Date.now()}`,state:`queued`,title:t.message.slice(0,80)||`Libre Claw demo run`,kind:t.kind||`chat`,provider:t.provider||`openrouter`,model:t.model||`openrouter/auto`,working_directory:``,created_at:e,updated_at:e}})}return r.post(`/libre-claw/runs`,t).then(e=>e.data)},getRun:t=>e()?i({run_id:t}):r.get(`/libre-claw/runs/${encodeURIComponent(t)}`).then(e=>e.data),getEvents:(t,n=0)=>e()?i({events:[]}):r.get(`/libre-claw/runs/${encodeURIComponent(t)}/events?after=${n}`).then(e=>e.data),cancelRun:t=>e()?i({run_id:t,cancelled:!0}):r.post(`/libre-claw/runs/${encodeURIComponent(t)}/cancel`).then(e=>e.data),resolvePermission:(t,n,a)=>e()?i({run_id:t,tool_call_id:n,resolution:a}):r.post(`/libre-claw/runs/${encodeURIComponent(t)}/permissions/${encodeURIComponent(n)}`,{resolution:a}).then(e=>e.data),listAutomations:(t=50)=>e()?i({automations:[]}):r.get(`/libre-claw/automations?limit=${t}`).then(e=>e.data),createAutomation:t=>e()?i({...t,automation_id:`demo-${Date.now()}`}):r.post(`/libre-claw/automations`,t).then(e=>e.data),updateAutomation:(t,n)=>e()?i({...n,automation_id:t}):r.patch(`/libre-claw/automations/${encodeURIComponent(t)}`,n).then(e=>e.data),pauseAutomation:t=>e()?i({automation_id:t,status:`paused`}):r.post(`/libre-claw/automations/${encodeURIComponent(t)}/pause`).then(e=>e.data),resumeAutomation:t=>e()?i({automation_id:t,status:`active`}):r.post(`/libre-claw/automations/${encodeURIComponent(t)}/resume`).then(e=>e.data),runAutomationNow:t=>e()?i({automation_id:t,run:!0}):r.post(`/libre-claw/automations/${encodeURIComponent(t)}/run`).then(e=>e.data),deleteAutomation:t=>e()?i({automation_id:t,deleted:!0}):r.delete(`/libre-claw/automations/${encodeURIComponent(t)}`).then(e=>e.data)},k={getModels:()=>r.get(`/media/models`).then(e=>e.data),generateAudio:(e,t)=>r.post(`/media/audio/generate`,e,{signal:t}).then(e=>e.data),cloneVoice:(e,t)=>{let n=new FormData;return n.set(`model`,e.model),n.set(`pluginId`,e.pluginId),n.set(`input`,e.input),n.set(`reference_audio`,e.referenceAudio),e.referenceText&&n.set(`reference_text`,e.referenceText),e.responseFormat&&n.set(`response_format`,e.responseFormat),e.saveVoiceName&&n.set(`saveVoiceName`,e.saveVoiceName),e.consentToStore&&n.set(`consentToStore`,`true`),e.consentTtlDays!==void 0&&n.set(`consentTtlDays`,String(e.consentTtlDays)),r.post(`/media/audio/voice-clone`,n,{signal:t}).then(e=>e.data)},generateSound:(e,t)=>r.post(`/media/sound/generate`,e,{signal:t}).then(e=>e.data),generateVideo:(e,t)=>r.post(`/media/video/generate`,e,{signal:t}).then(e=>e.data),getVideoJob:(e,t)=>r.get(`/media/video/jobs/${e}`,{signal:t}).then(e=>e.data),listVideoJobs:e=>r.get(`/media/video/jobs`,{params:e}).then(e=>e.data),resumeVideoJob:(e,t)=>r.post(`/media/video/jobs/${encodeURIComponent(e)}/resume`,void 0,{signal:t}).then(e=>e.data),cancelVideoJob:e=>r.delete(`/media/video/jobs/${encodeURIComponent(e)}`).then(e=>e.data),getGallery:e=>r.get(`/media/gallery`,{params:e}).then(e=>e.data),deleteGalleryItem:e=>r.delete(`/media/gallery/${e}`).then(e=>e.data),editImage:(e,t)=>{let n=new FormData;n.set(`model`,e.model),n.set(`pluginId`,e.pluginId),n.set(`prompt`,e.prompt),e.size&&n.set(`size`,e.size),e.sourceMediaId&&n.set(`sourceMediaId`,e.sourceMediaId);for(let t of e.images??[])n.append(`images`,t);return e.mask&&n.append(`mask`,e.mask,`mask.png`),r.post(`/media/image/edit`,n,{signal:t}).then(e=>e.data)},getGalleryContent:e=>r.get(`/media/gallery/${e}/content`,{responseType:`blob`}).then(e=>e.data)},A=(e,t,n)=>{let r=new AbortController,i=localStorage.getItem(`auth-token`);return(async()=>{try{let n=await fetch(e,{headers:{Accept:`text/event-stream`,...i?{Authorization:`Bearer ${i}`}:{}},cache:`no-store`,credentials:`same-origin`,signal:r.signal});if(!n.ok){let e=`Request failed with status ${n.status}`;try{let t=await n.json();typeof t.error==`string`?e=t.error:typeof t.message==`string`&&(e=t.message)}catch{}throw Error(e)}if(!n.body)throw Error(`Response stream is unavailable`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;!r.signal.aborted;){let{done:e,value:n}=await a.read();s+=o.decode(n,{stream:!e});let r=s.split(/\r?\n\r?\n/);s=r.pop()||``;for(let e of r){let n=e.split(/\r?\n/).find(e=>e.startsWith(`data:`));n&&t(JSON.parse(n.slice(5).trim()))}if(e)break}}finally{a.releaseLock()}}catch(e){r.signal.aborted||n(e instanceof Error?e.message:`Connection lost`)}})(),()=>r.abort()},j=`libre:models-changed`,M=()=>{window.dispatchEvent(new Event(j))},N={checkHealth:()=>e()?i({status:`offline`},!1):r.get(`/ollama/health`).then(e=>e.data),getSettings:()=>e()?i({enabled:!0,baseUrl:`http://localhost:11434`}):r.get(`/ollama/settings`).then(e=>e.data),updateSettings:t=>e()?i({enabled:!0,baseUrl:`http://localhost:11434`}):r.put(`/ollama/settings`,t).then(e=>e.data),getModels:()=>e()?i(o):r.get(`/ollama/models`).then(e=>e.data),getModelAccess:()=>e()?i({mode:`admins`,allowed:!1}):r.get(`/ollama/models/access`).then(e=>e.data),setModelAccess:t=>e()?i({mode:t}):r.put(`/ollama/models/access`,{mode:t}).then(e=>e.data),getModelVisibility:()=>e()?i({hidden:[],order:[],starred:[],metadata:{}}):r.get(`/ollama/models/visibility`).then(e=>e.data),setModelVisibility:t=>e()?i({hidden:t.hidden??[],order:t.order??[],starred:t.starred??[],metadata:t.metadata??{}}):r.put(`/ollama/models/visibility`,t).then(e=>e.data),pullModel:t=>e()?i(null,!1):r.post(`/ollama/models/pull`,{name:t}).then(e=>(M(),e.data)),pullModelStream:(n,r,i,a)=>{if(e()){let e=0,t=setInterval(()=>{e+=Math.random()*20,e>=100?(e=100,r({status:`success`,total:100,completed:100,percent:100}),clearInterval(t),setTimeout(()=>{M(),i()},500)):r({status:`pulling`,total:100,completed:e,percent:Math.round(e)})},1e3);return()=>clearInterval(t)}let o=new URLSearchParams({model:n});return A(`${t}/ollama/pull/stream?${o.toString()}`,e=>{switch(e.type){case`progress`:r({status:typeof e.status==`string`?e.status:`pulling`,digest:typeof e.digest==`string`?e.digest:void 0,total:typeof e.total==`number`?e.total:void 0,completed:typeof e.completed==`number`?e.completed:void 0,percent:typeof e.percent==`number`?e.percent:void 0});break;case`complete`:M(),i();break;case`error`:a(String(e.error||`Model pull failed`))}},a)},deleteModel:t=>e()?i(null,!1):r.delete(`/ollama/models`,{params:{name:t}}).then(e=>(M(),e.data)),getModelDefaults:e=>r.get(`/ollama/models/${encodeURIComponent(e)}/defaults`).then(e=>e.data),showModel:(t,n=!1)=>{if(e()){let e=o.find(e=>e.name===t);return i(e||null,!!e)}return r.get(`/ollama/models/show`,{params:{name:t,verbose:n}}).then(e=>e.data)},createModel:t=>e()?i(null,!1):r.post(`/ollama/models`,t).then(e=>(M(),e.data)),copyModel:(t,n)=>e()?i(null,!1):r.post(`/ollama/models/copy`,{source:t,destination:n}).then(e=>(M(),e.data)),pushModel:t=>e()?i(null,!1):r.post(`/ollama/models/push`,{name:t}).then(e=>e.data),pullAllModels:()=>e()?i(null,!1):r.post(`/ollama/models/pull-all`).then(e=>e.data),pullAllModelsStream:(n,r,i)=>{if(e()){let e=o,t=0,i=setInterval(()=>{t++,t<=e.length&&n({current:t,total:e.length,modelName:e[t-1]?.name||`demo-model`,status:Math.random()>.1?`success`:`error`,error:Math.random()>.1?void 0:`Demo error`}),t>=e.length&&(clearInterval(i),setTimeout(()=>{M(),r()},500))},1e3);return}A(`${t}/ollama/models/pull-all/stream`,e=>{switch(e.type){case`progress`:{let t=e.status===`success`||e.status===`error`?e.status:`starting`;n({current:typeof e.current==`number`?e.current:0,total:typeof e.total==`number`?e.total:0,modelName:typeof e.modelName==`string`?e.modelName:`unknown`,status:t,error:typeof e.error==`string`?e.error:void 0});break}case`complete`:M(),r();break;case`error`:i(String(e.error||`Model update failed`))}},i)},generateEmbeddings:t=>e()?i({embeddings:[[]]},!1):r.post(`/ollama/embed`,t).then(e=>e.data),listRunningModels:()=>e()?i([]):r.get(`/ollama/running`).then(e=>e.data),unloadModel:t=>e()?i(null):r.post(`/ollama/models/unload`,{name:t}).then(e=>e.data),unloadAllModels:()=>e()?i(null):r.post(`/ollama/models/unload-all`).then(e=>e.data),getVersion:()=>e()?i({version:`demo-mode`},!1):r.get(`/ollama/version`).then(e=>e.data),chatCompletion:t=>e()?i({message:{content:`Demo response`,role:`assistant`}},!1):r.post(`/ollama/chat`,t).then(e=>e.data),checkBlobExists:t=>e()?Promise.resolve(!1):r.head(`/ollama/blobs/${t}`).then(()=>!0).catch(()=>!1),pushBlob:(t,n)=>e()?i(null,!1):r.post(`/ollama/blobs/${t}`,n,{headers:{"Content-Type":`application/octet-stream`}}).then(e=>e.data),generateLegacyEmbeddings:t=>e()?i({embedding:[]},!1):r.post(`/ollama/embeddings`,t).then(e=>e.data),getLibraryModels:t=>{if(e())return t?.category===`cloud`?i([{name:`gpt-oss:cloud`,description:`Demo cloud model using Ollama cloud naming`,category:`cloud`,sizes:[`cloud`],pulls:`Cloud`,tags:[`cloud`]}]):i([{name:`llama3.2`,description:`Meta's latest Llama model`,category:`general`,sizes:[`1b`,`3b`],pulls:`50M+`,tags:[`general`]},{name:`deepseek-r1`,description:`Open reasoning model`,category:`reasoning`,sizes:[`7b`,`14b`,`32b`],pulls:`200M+`,tags:[`reasoning`]}]);let n=new URLSearchParams;t?.search&&n.set(`search`,t.search),t?.sort&&n.set(`sort`,t.sort),t?.category&&n.set(`category`,t.category);let a=n.toString();return r.get(`/ollama/library${a?`?${a}`:``}`).then(e=>e.data)}},P=[[`#2563eb`,`#7c3aed`],[`#0891b2`,`#2563eb`],[`#0f766e`,`#2563eb`],[`#be123c`,`#7c3aed`],[`#ff7b52`,`#dc2626`]],F=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)},I=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`),L=e=>{let t=e.trim().split(/[\s._-]+/).filter(Boolean);return t.length===0?`AI`:t.slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`AI`},R=(e,t=128)=>{let n=e.trim()||`AI Persona`,r=F(n),[i,a]=P[r%P.length],o=I(L(n)),s=`persona-avatar-${r}-${t}`,c=t>=96?44:24,l=`
|
|
3
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}" role="img" aria-label="${I(n)} avatar">
|
|
4
|
-
<defs>
|
|
5
|
-
<linearGradient id="${s}" x1="0" y1="0" x2="1" y2="1">
|
|
6
|
-
<stop offset="0%" stop-color="${i}" />
|
|
7
|
-
<stop offset="100%" stop-color="${a}" />
|
|
8
|
-
</linearGradient>
|
|
9
|
-
</defs>
|
|
10
|
-
<rect width="${t}" height="${t}" rx="${Math.round(t*.22)}" fill="url(#${s})" />
|
|
11
|
-
<circle cx="${t*.22}" cy="${t*.22}" r="${t*.26}" fill="rgba(255,255,255,0.16)" />
|
|
12
|
-
<text x="50%" y="52%" dominant-baseline="middle" text-anchor="middle" fill="white" font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="${c}" font-weight="700">${o}</text>
|
|
13
|
-
</svg>
|
|
14
|
-
`;return`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(l)}`},z=(e,t=128)=>e.avatar?.trim()||R(e.name,t),B=(e,t,n=128)=>{e.onerror=null,e.src=R(t,n)},V={getPersonas:()=>{if(e()){let e=[{id:`demo-1`,user_id:`default`,name:`Creative Assistant`,description:`Helpful assistant for creative tasks`,model:`llama3.3:latest`,parameters:{temperature:.8,top_p:.9,context_window:4096,system_prompt:`You are a creative and helpful assistant. Provide thoughtful and engaging responses.`},avatar:R(`Creative Assistant`,128),created_at:Date.now()-864e5,updated_at:Date.now()-864e5},{id:`demo-2`,user_id:`default`,name:`Research Assistant`,description:`Academic assistant for research and learning`,model:`qwen3:7b`,parameters:{temperature:.3,top_p:.8,context_window:8192,system_prompt:`You are a knowledgeable research assistant. Provide detailed, informative explanations.`},avatar:R(`Research Assistant`,128),created_at:Date.now()-1728e5,updated_at:Date.now()-1728e5}];return i(e)}return r.get(`/personas`).then(e=>e.data)},getPersona:t=>e()?i({id:t,user_id:`default`,name:`Sample Assistant`,description:`A sample assistant for demonstration`,model:`llama3.2:latest`,parameters:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},created_at:Date.now(),updated_at:Date.now()}):r.get(`/personas/${t}`).then(e=>e.data),createPersona:t=>{if(e()){let e={id:`demo-`+Date.now(),user_id:`default`,...t,created_at:Date.now(),updated_at:Date.now()};return i(e)}return r.post(`/personas`,t).then(e=>e.data)},updatePersona:(t,n)=>{if(e()){let e={id:t,user_id:`default`,name:n.name||`Updated Sample Assistant`,description:n.description,model:n.model||`llama3.2:latest`,parameters:n.parameters||{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},avatar:n.avatar,background:n.background,created_at:Date.now()-864e5,updated_at:Date.now()};return i(e)}return r.put(`/personas/${t}`,n).then(e=>e.data)},deletePersona:t=>e()?i(void 0):r.delete(`/personas/${t}`).then(e=>e.data),exportPersona:t=>{if(e()){let e={name:`Sample Assistant`,description:`A sample assistant for demonstration`,model:`llama3.2:latest`,params:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},exportedAt:Date.now(),version:`1.0.0`};return Promise.resolve(e)}return r.get(`/personas/${t}/export`).then(e=>e.data)},importPersona:t=>{if(e()){let e={id:`demo-imported-`+Date.now(),user_id:`default`,name:t.name,description:t.description,model:t.model,parameters:t.params,avatar:t.avatar,background:t.background,created_at:Date.now(),updated_at:Date.now(),embedding_model:t.embedding_model,memory_settings:t.memory_settings,mutation_settings:t.mutation_settings};return i(e)}return r.post(`/personas/import`,t).then(e=>e.data)},getPersonasCount:()=>e()?i({count:2}):r.get(`/personas/stats/count`).then(e=>e.data),getDefaultParameters:()=>e()?i({temperature:.7,top_p:.9,top_k:40,context_window:4096,max_tokens:1024,system_prompt:``,repeat_penalty:1.1,presence_penalty:0,frequency_penalty:0}):r.get(`/personas/defaults/parameters`).then(e=>e.data),getMemoryStatus:t=>e()?i({status:`active`,memory_count:42,last_backup:Date.now()-864e5,size_mb:2.3}):r.get(`/personas/${t}/memory/status`).then(e=>e.data),wipeMemories:t=>e()?i({deleted_count:42}):r.delete(`/personas/${t}/memory`).then(e=>e.data),backupPersona:t=>{if(e()){let e=JSON.stringify({persona_id:t,backup_date:new Date().toISOString(),data:`demo backup data`});return Promise.resolve(new Blob([e],{type:`application/json`}))}return r.get(`/personas/${t}/backup`,{responseType:`blob`}).then(e=>e.data)},exportPersonaDNA:t=>{if(e()){let e=JSON.stringify({persona_id:t,export_date:new Date().toISOString(),dna:`demo DNA data`,memories:[],learned_behaviors:{}});return Promise.resolve(new Blob([e],{type:`application/json`}))}return r.get(`/personas/${t}/export/dna`,{responseType:`blob`}).then(e=>e.data)},importPersonaDNA:t=>{if(e()){let e={id:`demo-dna-`+Date.now(),user_id:`default`,name:`Imported Persona`,description:`Persona imported from DNA`,model:`llama3.2:latest`,parameters:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},created_at:Date.now(),updated_at:Date.now()};return i(e)}let n=new FormData;return n.append(`dnaFile`,t),r.post(`/personas/import/dna`,n).then(e=>e.data)},downloadPersona:async(e,t)=>{try{let n=await V.exportPersona(e),r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${t}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch(e){throw n.error(`Error while downloading persona:`,e),Error(`Failed to download persona: ${e instanceof Error?e.message:String(e)}`)}}},H={list:()=>e()?i([]):r.get(`/prompts`).then(e=>e.data),get:e=>r.get(`/prompts/${e}`).then(e=>e.data),create:e=>r.post(`/prompts`,e).then(e=>e.data),update:(e,t)=>r.put(`/prompts/${e}`,t).then(e=>e.data),remove:e=>r.delete(`/prompts/${e}`).then(e=>e.data),versions:e=>r.get(`/prompts/${e}/versions`).then(e=>e.data),rollback:(e,t)=>r.post(`/prompts/${e}/rollback`,{version:t}).then(e=>e.data),export:e=>r.get(`/prompts/${e}/export`).then(e=>e.data),import:(e,t)=>r.post(`/prompts/import`,{prompt:e,overwriteSlug:t?.overwriteSlug===!0}).then(e=>e.data)},ae={list:()=>e()?i([]):r.get(`/skills`).then(e=>e.data),get:e=>r.get(`/skills/${e}`).then(e=>e.data),create:e=>r.post(`/skills`,e).then(e=>e.data),update:(e,t)=>r.put(`/skills/${e}`,t).then(e=>e.data),remove:e=>r.delete(`/skills/${e}`).then(e=>e.data),versions:e=>r.get(`/skills/${e}/versions`).then(e=>e.data),rollback:(e,t)=>r.post(`/skills/${e}/rollback`,{version:t}).then(e=>e.data),export:e=>r.get(`/skills/${e}/export`).then(e=>e.data),importFromUrl:(e,t)=>r.post(`/skills/import-url`,{source:e,overwriteSlug:t?.overwriteSlug===!0}).then(e=>e.data),import:(e,t)=>r.post(`/skills/import`,{skill:e,overwriteSlug:t?.overwriteSlug===!0}).then(e=>e.data),listFiles:e=>r.get(`/skills/${e}/files`).then(e=>e.data),getFile:(e,t)=>r.get(`/skills/${e}/files/content`,{params:{path:t}}).then(e=>e.data),putFile:(e,t,n)=>r.put(`/skills/${e}/files`,{path:t,content:n}).then(e=>e.data),deleteFile:(e,t)=>r.delete(`/skills/${e}/files`,{params:{path:t}}).then(e=>e.data)},U={getCatalog:()=>e()?i({available:!1,tools:[]}):r.get(`/tools/catalog`).then(e=>e.data),listServers:()=>e()?i([]):r.get(`/tools/servers`).then(e=>e.data),getServer:e=>r.get(`/tools/servers/${e}`).then(e=>e.data),registerServer:e=>r.post(`/tools/servers`,e).then(e=>e.data),updateServer:(e,t)=>r.put(`/tools/servers/${e}`,t).then(e=>e.data),deleteServer:e=>r.delete(`/tools/servers/${e}`).then(e=>e.data),refreshServer:e=>r.post(`/tools/servers/${e}/refresh`).then(e=>e.data),overrideServerTool:(e,t,n)=>r.put(`/tools/servers/${e}/tools/${t}`,n).then(e=>e.data),setCredential:(e,t)=>r.put(`/tools/servers/${e}/credential`,{secret:t}).then(e=>e.data),deleteCredential:e=>r.delete(`/tools/servers/${e}/credential`).then(e=>e.data),listApprovals:()=>r.get(`/tools/approvals`).then(e=>e.data),decideApproval:(e,t,n)=>r.post(`/tools/approvals/${e}`,{approve:t,scope:n}).then(e=>e.data),revokeApproval:e=>r.delete(`/tools/approvals/${e}`).then(e=>e.data),getAccessMode:()=>r.get(`/tools/access`).then(e=>e.data),setAccessMode:e=>r.put(`/tools/access`,{mode:e}).then(e=>e.data)},W=e=>{let t=Date.now();return{range:{from:t-Math.max(0,e-1)*864e5,to:t,days:e},totals:{calls:0,successfulCalls:0,failedCalls:0,cancelledCalls:0,meteredCalls:0,promptTokens:0,completionTokens:0,reportedTokens:0,averageLatencyMs:0,uniqueUsers:0},series:[],plugins:[],models:[],capabilities:[]}},G={getUsage:(t=30)=>e()?i(W(t)):r.get(`/plugins/usage`,{params:{days:t}}).then(e=>e.data),getAllPlugins:()=>e()?i([]):r.get(`/plugins`).then(e=>e.data),discoverModels:t=>e()?i({models:[],outcome:`unavailable`}):r.post(`/plugins/discover/${encodeURIComponent(t)}`).then(e=>e.data),uploadPlugin:t=>{if(e())return i({},!1);let n=new FormData;return n.append(`plugin`,t),r.post(`/plugins/upload`,n).then(e=>e.data)},probeEndpoint:(t,n)=>e()?i({reachable:!1,models:[],kind:n}):r.post(`/plugins/probe-endpoint`,{baseUrl:t,kind:n}).then(e=>e.data),installPlugin:t=>e()?i({},!1):r.post(`/plugins/install`,t).then(e=>e.data),updatePlugin:(t,n)=>e()?i({},!1):r.put(`/plugins/${t}`,n).then(e=>e.data),deletePlugin:t=>e()?i(void 0):r.delete(`/plugins/${t}`).then(e=>e.data),activatePlugin:t=>e()?i(!1,!1):r.post(`/plugins/activate/${t}`).then(e=>e.data),deactivatePlugin:t=>{if(e())return i(void 0);let n=t?`/plugins/deactivate/${t}`:`/plugins/deactivate`;return r.post(n).then(e=>e.data)},getActivePlugin:()=>e()?i(null):r.get(`/plugins/active`).then(e=>e.data),getPluginStatus:()=>e()?i([]):r.get(`/plugins/status`).then(e=>e.data),exportPlugin:t=>e()?Promise.resolve(new Blob([`{}`],{type:`application/json`})):r.get(`/plugins/${t}/export`,{responseType:`blob`}).then(e=>e.data),getCredentials:()=>e()?i([]):r.get(`/plugins/credentials/all`).then(e=>e.data),setApiKey:(t,n)=>e()?i(!1,!1):r.post(`/plugins/${t}/credentials`,{api_key:n}).then(e=>e.data),deleteApiKey:t=>e()?i(!1,!1):r.delete(`/plugins/${t}/credentials`).then(e=>e.data),checkApiKey:t=>e()?i(!1):r.get(`/plugins/${t}/credentials/check`).then(e=>e.data),getVariables:t=>e()?i({}):r.get(`/plugins/${t}/variables`).then(e=>e.data),setVariables:(t,n,a=[])=>e()?i(!0):r.put(`/plugins/${t}/variables`,{variables:n,unset:a}).then(e=>e.data),resetVariables:t=>e()?i(!0):r.delete(`/plugins/${t}/variables`).then(e=>e.data)},K=`libre-webui-user-data`,q=`libre-webui-export`,J=new Set([2,3]),Y=class extends Error{code;version;constructor(e,t,n){super(t),this.code=e,this.version=n,this.name=`PortableArchiveParseError`}};function X(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(e=>X(e)).join(`,`)}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${X(e[t])}`).join(`,`)}}`}async function oe(e){let{integrity:t,...n}=e,r=JSON.parse(JSON.stringify(n)),i=await globalThis.crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(X(r)));return Array.from(new Uint8Array(i),e=>e.toString(16).padStart(2,`0`)).join(``)}function se(e){let t;try{t=JSON.parse(e)}catch{throw new Y(`invalidJson`,`Portable archive is not valid JSON.`)}if(!t||typeof t!=`object`||Array.isArray(t))throw new Y(`objectRequired`,`Portable archive must contain a JSON object.`);let n=t;if(n.format===K){if(!J.has(n.version))throw new Y(`unsupportedVersion`,`Unsupported portable archive version ${String(n.version)}.`,n.version);return n}if(n.format===q)return n;throw new Y(`unrecognized`,`This file is not a Libre WebUI portable archive.`)}var ce=[{key:`accountAndAuthentication`,reason:`Account and authentication records are not portable.`},{key:`providerSecrets`,reason:`Provider credentials must be configured again.`},{key:`voiceProfiles`,reason:`Voice reference audio is biometric data and is not portable.`},{key:`personasAndMemory`,reason:`Personas and persona memory are not part of archive version 3.`},{key:`generatedMedia`,reason:`Generated media library files are not portable.`},{key:`work`,reason:`Work data and volumes require a system backup.`},{key:`derivedEmbeddings`,reason:`Document embeddings can be regenerated after import.`},{key:`noteHistoryAndAttachments`,reason:`Note revision history and note attachments are not part of archive version 3.`}];function Z(e,t){if(typeof File<`u`&&e instanceof File){let n=new FormData;return n.append(`archive`,e),n.append(`strategy`,t),n}return{data:e,strategy:t}}var le={getDefaultTheme:()=>e()?i({theme:l.theme}):r.get(`/preferences/default-theme`).then(e=>e.data),setDefaultTheme:t=>e()?i({theme:t}):r.put(`/preferences/default-theme`,{theme:t}).then(e=>e.data),getPreferences:()=>e()?i(d()):r.get(`/preferences`).then(e=>e.data),updatePreferences:t=>e()?i(f(t)):r.put(`/preferences`,t).then(e=>e.data),setDefaultModel:(t,n,a)=>e()?i(f({defaultModel:t,defaultProviderType:n,defaultProviderId:n===`plugin`||n===`agent`?a:null})):r.put(`/preferences/default-model`,{model:t,providerType:n,providerId:a}).then(e=>e.data),setSystemMessage:t=>e()?i(f({systemMessage:t})):r.put(`/preferences/system-message`,{message:t}).then(e=>e.data),setGenerationOptions:t=>e()?i(f({generationOptions:t})):r.put(`/preferences/generation-options`,t).then(e=>e.data),setModelGenerationOptions:(e,t)=>r.put(`/preferences/model-generation-options`,{model:e,options:t}).then(e=>e.data),resetGenerationOptions:()=>e()?i(f({generationOptions:l.generationOptions})):r.post(`/preferences/generation-options/reset`).then(e=>e.data),setEmbeddingSettings:t=>e()?i(f({embeddingSettings:t})):r.put(`/preferences/embedding-settings`,t).then(e=>e.data),resetEmbeddingSettings:()=>e()?i(f({embeddingSettings:l.embeddingSettings})):r.post(`/preferences/embedding-settings/reset`).then(e=>e.data),exportData:async()=>{if(e()){let e={format:`libre-webui-user-data`,version:3,exportedAt:new Date().toISOString(),preferences:d(),sessionFolders:[],sessions:[],notes:[],knowledgeCollections:[],documents:[],exclusions:ce};return i({...e,integrity:{algorithm:`sha256`,canonicalization:`libre-json-sort-v1`,digest:await oe(e)}})}return r.get(`/preferences/export`).then(e=>e.data)},preflightImport:(t,n)=>e()?i({valid:!0,format:`libre-webui-user-data`,version:3,strategy:n,incoming:{sessionFolders:0,sessions:0,messages:0,notes:0,knowledgeCollections:0,documents:0,documentChunks:0},result:{format:`libre-webui-user-data`,version:3,strategy:n,sessionFolders:{imported:0,overwritten:0,skipped:0},sessions:{imported:0,overwritten:0,skipped:0},notes:{imported:0,overwritten:0,skipped:0},knowledgeCollections:{imported:0,overwritten:0,skipped:0},documents:{imported:0,overwritten:0,skipped:0},remappedIds:0,warnings:[],exclusions:[]},warnings:[],exclusions:[]}):r.post(`/preferences/import/preflight`,Z(t,n)).then(e=>e.data),importData:(t,n=`skip`)=>e()?i({format:`libre-webui-user-data`,version:3,strategy:n,preferences:{imported:!0,mode:n===`overwrite`?`replace`:`merge`},sessionFolders:{imported:0,overwritten:0,skipped:0},sessions:{imported:0,overwritten:0,skipped:0},notes:{imported:0,overwritten:0,skipped:0},knowledgeCollections:{imported:0,overwritten:0,skipped:0},documents:{imported:0,overwritten:0,skipped:0},remappedIds:0,warnings:[],exclusions:[]}):r.post(`/preferences/import`,Z(t,n)).then(e=>e.data)},ue={getDiagnostics:()=>r.get(`/system`).then(e=>e.data)};function Q(e,t,n){if(t)return e.find(e=>e.model===t&&(!n||e.plugin===n))}function de(e,t,n){return Q(e,t,n)||e[0]}function fe(e){return`${encodeURIComponent(e.plugin)}::${encodeURIComponent(e.model)}`}var $={getModels:()=>e()?i([{model:`tts-1`,plugin:`openai`,config:{voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`,formats:[`mp3`,`opus`,`aac`,`flac`,`wav`],default_format:`mp3`,max_characters:4096}}]):r.get(`/tts/models`).then(e=>e.data),getPlugins:()=>e()?i([{id:`openai`,name:`OpenAI GPT`,models:[`tts-1`,`tts-1-hd`],config:{voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`}}]):r.get(`/tts/plugins`).then(e=>e.data),getVoiceProfiles:(t={})=>e()?i([]):r.get(`/tts/voice-profiles`,{params:{pluginId:t.pluginId||void 0,model:t.model||void 0}}).then(e=>e.data),revokeVoiceProfile:async t=>e()?{success:!1,error:`Demo mode`}:(await r.post(`/tts/voice-profiles/${encodeURIComponent(t)}/revoke`)).data,deleteVoiceProfile:async t=>{e()||await r.delete(`/tts/voice-profiles/${encodeURIComponent(t)}`)},getVoices:t=>e()?i({voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`,formats:[`mp3`,`opus`,`aac`,`flac`,`wav`],default_format:`mp3`,max_characters:4096,supports_streaming:!1,supports_voice_cloning:!1,clone_requires_transcript:!1}):r.get(`/tts/voices/${t}`).then(e=>e.data),generateBase64:t=>{if(e())return i({audio:``,format:t.response_format||`mp3`,mimeType:`audio/mpeg`,size:0});let n={...t,pluginId:t.pluginId||void 0};return r.post(`/tts/generate-base64`,n).then(e=>e.data)},generate:async(t,n={})=>{if(e())return new Blob([],{type:`audio/mpeg`});let i={...t,pluginId:t.pluginId||void 0};return(await r.post(`/tts/generate`,i,{responseType:`blob`,signal:n.signal})).data},speak:async(e,t={})=>{try{t.onStart?.();let n=await $.generateBase64({model:t.model||`tts-1`,pluginId:t.pluginId,input:e,voice:t.voice,voiceProfileId:t.voiceProfileId,speed:t.speed,response_format:t.responseFormat});if(!n.success||!n.data?.audio)throw Error(n.message||`Failed to generate speech`);let r=`data:${n.data.mimeType};base64,${n.data.audio}`,i=new Audio(r);return i.onended=()=>t.onEnd?.(),i.onerror=()=>t.onError?.(Error(`Audio playback failed`)),await i.play(),i}catch(e){let n=e instanceof Error?e:Error(`Unknown error`);return t.onError?.(n),null}}},pe={getModels:()=>e()?i([]):r.get(`/stt/models`).then(e=>e.data),transcribe:async(e,t,n={})=>{let i=new FormData,a=me(e.type);i.append(`audio`,e,`recording.${a}`),i.append(`model`,t.model),i.append(`pluginId`,t.plugin),n.language&&i.append(`language`,n.language);let o=await r.post(`/stt/transcribe`,i,{signal:n.signal});if(!o.data.success||!o.data.data)throw Error(o.data.message||o.data.error||n.fallbackMessage||`Transcription failed`);return o.data.data}};function me(e){let t=e.split(`;`,1)[0].toLowerCase();return t.includes(`webm`)?`webm`:t.includes(`ogg`)?`ogg`:t.includes(`wav`)?`wav`:t.includes(`flac`)?`flac`:t.includes(`mp4`)||t.includes(`m4a`)?`m4a`:`mp3`}export{y as A,w as C,S as D,C as E,m as F,ee as I,h as L,v as M,g as N,x as O,ne as P,te as R,E as S,re as T,B as _,$ as a,k as b,Y as c,U as d,ae as f,z as g,R as h,de as i,_ as j,b as k,se as l,V as m,Q as n,ue as o,H as p,fe as r,le as s,pe as t,G as u,j as v,ie as w,O as x,N as y,a as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t=`0.34.2`){return t?.trim()||e?.trim()||``}export{e as t};
|