libre-webui 0.39.0 → 0.40.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 +6 -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 +7 -0
- package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
- package/backend/dist/routes/email.d.ts.map +1 -1
- package/backend/dist/routes/email.js +51 -1
- package/backend/dist/routes/email.js.map +1 -1
- package/backend/dist/routes/tts.d.ts.map +1 -1
- package/backend/dist/routes/tts.js +6 -1
- package/backend/dist/routes/tts.js.map +1 -1
- package/backend/dist/services/agentCliService.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.js +1 -0
- package/backend/dist/services/agentCliService.js.map +1 -1
- package/backend/dist/services/emailService.d.ts +17 -3
- package/backend/dist/services/emailService.d.ts.map +1 -1
- package/backend/dist/services/emailService.js +73 -11
- package/backend/dist/services/emailService.js.map +1 -1
- package/backend/dist/services/pluginCredentialsService.d.ts +3 -0
- package/backend/dist/services/pluginCredentialsService.d.ts.map +1 -1
- package/backend/dist/services/pluginCredentialsService.js +18 -5
- package/backend/dist/services/pluginCredentialsService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts +9 -0
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +31 -14
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/workRuntimeService.d.ts +5 -0
- package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeService.js +243 -84
- package/backend/dist/services/workRuntimeService.js.map +1 -1
- package/backend/dist/utils/emailMarkdown.js +3 -3
- package/backend/dist/utils/emailMarkdown.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.d.ts +7 -0
- package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +49 -1
- package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
- package/backend/package.json +1 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/artifact-runtime/mermaid.js +366 -366
- package/frontend/dist/assets/index-DLfU_qNT.js +75 -0
- package/frontend/dist/assets/index-DtS3qhdq.css +2 -0
- package/frontend/dist/assets/xterm-B1njb2Cr.css +1 -0
- package/frontend/dist/index.html +27 -26
- package/frontend/dist/js/ArtifactContainer-BjzltfdU.js +1 -0
- package/frontend/dist/js/{ArtifactDemoPage-Ddpy2O_v.js → ArtifactDemoPage-DWua6xj9.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-CdsAqv8H.js → ArtifactSandboxFrame-CR9ghP0A.js} +1 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-DX2nL3AS.js +1 -0
- package/frontend/dist/js/AutomationModal-DZe-C2jN.js +1 -0
- package/frontend/dist/js/AutomationsPage-CrCcnTyk.js +1 -0
- package/frontend/dist/js/AvatarUpload-nPS0QHod.js +1 -0
- package/frontend/dist/js/Button-Dh2UJA-B.js +1 -0
- package/frontend/dist/js/CalendarPage-D2WiWglM.js +1 -0
- package/frontend/dist/js/ChannelsPage-COp2T8FQ.js +1 -0
- package/frontend/dist/js/ChatPage-CUfAlpdt.js +14 -0
- package/frontend/dist/js/ConnectModels-emc3dv4A.js +1 -0
- package/frontend/dist/js/EvaluationsPage-CbyeDkz_.js +2 -0
- package/frontend/dist/js/FirstTimeSetup-C4ffQRMN.js +1 -0
- package/frontend/dist/js/GalleryPage-D4Ci_3dv.js +1 -0
- package/frontend/dist/js/HomePage-C3IhEERN.js +1 -0
- package/frontend/dist/js/LanguageSwitcher-BQqDJPwm.js +1 -0
- package/frontend/dist/js/ModelManagerModals-DhY8Rme6.js +1 -0
- package/frontend/dist/js/NotesPage-j812I1BN.js +3 -0
- package/frontend/dist/js/PasswordStrengthMeter-BSEtQBJp.js +1 -0
- package/frontend/dist/js/PersonasPage--YWoThqF.js +13 -0
- package/frontend/dist/js/PluginUsagePage-CZiMdmjI.js +1 -0
- package/frontend/dist/js/{RichMessageContent-BfYbVBFz.js → RichMessageContent-BLI0hhzR.js} +2 -2
- package/frontend/dist/js/RichMessageContent-BXv5baJ_.js +1 -0
- package/frontend/dist/js/SettingsModal-C6aVzSI-.js +19 -0
- package/frontend/dist/js/SettingsToggle-CkLLtFbz.js +1 -0
- package/frontend/dist/js/ShareDialog-DQskc17d.js +1 -0
- package/frontend/dist/js/StrandsPage-DENhVKcz.js +1 -0
- package/frontend/dist/js/SystemPage-C86ypXG4.js +1 -0
- package/frontend/dist/js/UserManagementPanel-D1CS0KPn.js +1 -0
- package/frontend/dist/js/WhatsNewModal-B31A_UQY.js +1 -0
- package/frontend/dist/js/WorkPage-DEXBL5J7.js +7 -0
- package/frontend/dist/js/api-DRAKhdz7.js +1 -0
- package/frontend/dist/js/{api-BrHW-VGd.js → api-Dcz1G4Ib.js} +4 -2
- package/frontend/dist/js/{appNavigation-B6xYIgLi.js → appNavigation-C5A9BF_G.js} +1 -1
- package/frontend/dist/js/appStore-0_qlwS8f.js +2 -0
- package/frontend/dist/js/appVersion-D5lk_2zb.js +1 -0
- package/frontend/dist/js/ar-BZntyucf.js +2 -0
- package/frontend/dist/js/authStore-C4dzH1NY.js +1 -0
- package/frontend/dist/js/{authStore-DjAsRpNL.js → authStore-COgKeTRv.js} +3 -3
- package/frontend/dist/js/bn-BDCaFQu-.js +2 -0
- package/frontend/dist/js/chatStore-CVTbkZyb.js +3 -0
- package/frontend/dist/js/{client-DppLngAs.js → client-jaxZzn-I.js} +2 -2
- package/frontend/dist/js/{composerStyles-C83jssgZ.js → composerStyles-BEx0XAp6.js} +1 -1
- package/frontend/dist/js/{config-4_s8hdqO.js → config-Da1yh9sC.js} +1 -1
- package/frontend/dist/js/confirmStore-CKkUtP9c.js +1 -0
- package/frontend/dist/js/cs-BCmN--jQ.js +2 -0
- package/frontend/dist/js/da-B895dAyV.js +2 -0
- package/frontend/dist/js/de-B0ZhC0dm.js +2 -0
- package/frontend/dist/js/es-D7eaw4_W.js +2 -0
- package/frontend/dist/js/{evaluationsApi-DyuW7IJ_.js → evaluationsApi-BwaxBVpl.js} +1 -1
- package/frontend/dist/js/fr-DsB0gLW4.js +2 -0
- package/frontend/dist/js/hi-CLeU3ung.js +2 -0
- package/frontend/dist/js/id-Cdq6tOTi.js +2 -0
- package/frontend/dist/js/is-DJ1tHaAT.js +2 -0
- package/frontend/dist/js/it-9K1R4CeT.js +2 -0
- package/frontend/dist/js/ja-BYP_3M5M.js +2 -0
- package/frontend/dist/js/ko-CNtjlaDm.js +2 -0
- package/frontend/dist/js/liveAnnouncerStore-B6mS-JWC.js +1 -0
- package/frontend/dist/js/messageCodeStyles-D3cWF9XO.js +2 -0
- package/frontend/dist/js/ms-A_IVO_qt.js +2 -0
- package/frontend/dist/js/nl-CrKWO3ea.js +2 -0
- package/frontend/dist/js/pl-BrpSuyDP.js +2 -0
- package/frontend/dist/js/pt-BHbpB5BM.js +2 -0
- package/frontend/dist/js/ru-DzLsS9zY.js +2 -0
- package/frontend/dist/js/{strandsApi-BFbeEpAY.js → strandsApi-COxSPh_5.js} +1 -1
- package/frontend/dist/js/sv-VU2CjzNj.js +2 -0
- package/frontend/dist/js/{teamEventStream-DsAS6P4m.js → teamEventStream-RNJYm84u.js} +1 -1
- package/frontend/dist/js/th-DV2hNXXc.js +2 -0
- package/frontend/dist/js/tr-DvVZ9jxF.js +2 -0
- package/frontend/dist/js/ui-CI0OdG9q.js +2 -0
- package/frontend/dist/js/ui-vendor-6S05F84J.js +1 -0
- package/frontend/dist/js/uk-MFFDRo2m.js +2 -0
- package/frontend/dist/js/useChat-BSkqxHnH.js +13 -0
- package/frontend/dist/js/useDictation-D9whH12W.js +1 -0
- package/frontend/dist/js/vi-CfZ-U8Cw.js +2 -0
- package/frontend/dist/js/{work-CdbmBok5.js → work-C7MYlv5S.js} +1 -1
- package/frontend/dist/js/{workModels-BM2Zyiba.js → workAnnouncements-CAsI8P7c.js} +1 -1
- package/frontend/dist/js/workApi-BJfbaV6k.js +1 -0
- package/frontend/dist/js/{workApi-UPxumrEF.js → workApi-Ck8nTlJn.js} +1 -1
- package/frontend/dist/js/zh-CTl_raYa.js +2 -0
- package/package.json +3 -2
- package/plugins/codex-oauth.json +1 -0
- package/frontend/dist/assets/index-D99DS5c6.js +0 -57
- package/frontend/dist/assets/index-Dz1JufgZ.css +0 -1
- package/frontend/dist/assets/xterm-B8QFf3JU.css +0 -1
- package/frontend/dist/js/ArtifactContainer-Cn7X9HGm.js +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-cVd9X80o.js +0 -1
- package/frontend/dist/js/AutomationModal-B4UaWjkk.js +0 -1
- package/frontend/dist/js/AutomationsPage-huCrvLUp.js +0 -1
- package/frontend/dist/js/AvatarUpload-CG-w6Mpt.js +0 -1
- package/frontend/dist/js/Button-j68Q8KVh.js +0 -1
- package/frontend/dist/js/CalendarPage-CZXT1w99.js +0 -1
- package/frontend/dist/js/ChannelsPage-DbtdHnSL.js +0 -1
- package/frontend/dist/js/ChatPage-BZE65kiq.js +0 -14
- package/frontend/dist/js/ConnectModels-DD4bLgdq.js +0 -1
- package/frontend/dist/js/EvaluationsPage-Dq53LaXd.js +0 -2
- package/frontend/dist/js/FirstTimeSetup-BoJIfuQT.js +0 -1
- package/frontend/dist/js/GalleryPage-DKwqeB2A.js +0 -1
- package/frontend/dist/js/HomePage-C8bCJfls.js +0 -1
- package/frontend/dist/js/LanguageSwitcher-B_YyU5JG.js +0 -1
- package/frontend/dist/js/ModelManagerModals-BzjZ-QwL.js +0 -1
- package/frontend/dist/js/NotesPage-CnaAp_w_.js +0 -3
- package/frontend/dist/js/PasswordStrengthMeter-DI4RDv67.js +0 -1
- package/frontend/dist/js/PersonasPage-CH3GUKph.js +0 -13
- package/frontend/dist/js/PluginUsagePage-d54K2gAj.js +0 -1
- package/frontend/dist/js/RichMessageContent-CDxxs3Tt.js +0 -1
- package/frontend/dist/js/SettingsModal-BvtJcvow.js +0 -19
- package/frontend/dist/js/SettingsToggle-DrJ0Bapi.js +0 -1
- package/frontend/dist/js/ShareDialog-DaSxkTKS.js +0 -1
- package/frontend/dist/js/StrandsPage-BQwz0mWq.js +0 -1
- package/frontend/dist/js/SystemPage-BqNZoFxR.js +0 -1
- package/frontend/dist/js/UserManagementPanel-C3T1ReJJ.js +0 -1
- package/frontend/dist/js/WhatsNewModal-CLcU2Ugk.js +0 -1
- package/frontend/dist/js/WorkPage-BpjGn--1.js +0 -8
- package/frontend/dist/js/api-K_hhqPdx.js +0 -1
- package/frontend/dist/js/appStore-DkRdQQeY.js +0 -2
- package/frontend/dist/js/appVersion-BVtSqLVj.js +0 -1
- package/frontend/dist/js/ar-XTZGEtBr.js +0 -2
- package/frontend/dist/js/authStore-DBS6Kbvh.js +0 -1
- package/frontend/dist/js/bn-JiK7ZWmy.js +0 -2
- package/frontend/dist/js/chatStore-DpVxt9VX.js +0 -3
- package/frontend/dist/js/cs-D8ju18CO.js +0 -2
- package/frontend/dist/js/da-BJWcAoUc.js +0 -2
- package/frontend/dist/js/de-CLJLmy69.js +0 -2
- package/frontend/dist/js/es-BvqHEL-3.js +0 -2
- package/frontend/dist/js/fr-B8ZoZomI.js +0 -2
- package/frontend/dist/js/goober.modern-BaHbaW3_.js +0 -1
- package/frontend/dist/js/hi-AzJLALo-.js +0 -2
- package/frontend/dist/js/id-DZYGQhvC.js +0 -2
- package/frontend/dist/js/is-Da_kvtzW.js +0 -2
- package/frontend/dist/js/it-B90zSlqn.js +0 -2
- package/frontend/dist/js/ja-DU_K1GOr.js +0 -2
- package/frontend/dist/js/ko-DicfoO-e.js +0 -2
- package/frontend/dist/js/messageCodeStyles-CuQPkfEK.js +0 -2
- package/frontend/dist/js/ms-CfH7wjUY.js +0 -2
- package/frontend/dist/js/nl-ELlOz-B3.js +0 -2
- package/frontend/dist/js/pl-33dayyUk.js +0 -2
- package/frontend/dist/js/pt-aIXSQPCT.js +0 -2
- package/frontend/dist/js/ru-BSvGtBtW.js +0 -2
- package/frontend/dist/js/sv-B7KOz81W.js +0 -2
- package/frontend/dist/js/th-DgpjGxvA.js +0 -2
- package/frontend/dist/js/tr-BQTbl2h-.js +0 -2
- package/frontend/dist/js/ui-Aq8MP7Ph.js +0 -2
- package/frontend/dist/js/ui-vendor-DVTj_sKN.js +0 -1
- package/frontend/dist/js/uk-JLymloot.js +0 -2
- package/frontend/dist/js/useChat-D3ZAGz70.js +0 -10
- package/frontend/dist/js/useDictation-B6l8QzeM.js +0 -1
- package/frontend/dist/js/vi-BXdLOJ8q.js +0 -2
- package/frontend/dist/js/workApi-D1xtiG3Q.js +0 -1
- package/frontend/dist/js/zh-gdUf9sXa.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./react-vendor-CR5VJ85Q.js";import{t}from"./utils-B-Bhh1pF.js";var n=e();function r({checked:e,onChange:r,disabled:i=!1,id:a,"aria-label":o,"aria-labelledby":s,"aria-describedby":c}){return(0,n.jsxs)(`label`,{className:t(`relative flex items-center`,i?`cursor-not-allowed`:`cursor-pointer`),children:[(0,n.jsx)(`input`,{type:`checkbox`,id:a,checked:e,onChange:e=>r(e.target.checked),disabled:i,"aria-label":o,"aria-labelledby":s,"aria-describedby":c,className:`peer sr-only`}),(0,n.jsx)(`div`,{className:t(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors peer-focus-visible:ring-2 peer-focus-visible:ring-primary-500 peer-focus-visible:ring-offset-2`,i?`bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed`:e?`bg-primary-600 dark:bg-primary-500`:`bg-gray-200 dark:bg-dark-300`),children:(0,n.jsx)(`span`,{className:t(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})]})}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{t as r}from"./logger-BR4forr_.js";import{t as i}from"./useTranslation-Boi0fB1B.js";import{B as a,Or as o,Rt as s,n as c,s as l}from"./ui-vendor-6S05F84J.js";import{t as u}from"./Button-Dh2UJA-B.js";import{_ as d,g as f}from"./ui-CI0OdG9q.js";import{k as p}from"./api-Dcz1G4Ib.js";var m=e(t(),1),h=n(),g=r(`share-dialog`),_=({resourceType:e,resourceId:t,resourceLabel:n,onClose:r})=>{let{t:_}=i(),[v,y]=(0,m.useState)(null),[b,x]=(0,m.useState)(`user`),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(`read`),[E,D]=(0,m.useState)(!1),[O,k]=(0,m.useState)(!1),A=(0,m.useCallback)(()=>{p.listGrants(e,t).then(e=>{e.success&&Array.isArray(e.data)?(y(e.data),k(!1)):k(!0)}).catch(e=>{g.error(`Failed to load shares:`,e),k(!0)})},[e,t]);(0,m.useEffect)(()=>{A()},[A]);let j=async()=>{let n=S.trim();if(n){D(!0);try{let r=b===`user`?await p.resolvePrincipal(n):await p.resolveGroup(n);if(!r.success||!r.data){o.error(_(b===`user`?`share.userNotFound`:`share.groupNotFound`));return}let i=await p.createGrant({resourceType:e,resourceId:t,principalType:b,principalId:r.data.id,permission:w});i.success?(C(``),A(),o.success(_(`share.added`,{name:n}))):o.error(i.error||_(`share.failed`))}catch(e){g.error(`Failed to share resource:`,e),o.error(_(`share.failed`))}finally{D(!1)}}},M=async e=>{try{let t=await p.deleteGrant(e);t.success?A():o.error(t.error||_(`share.revokeFailed`))}catch(e){g.error(`Failed to revoke share:`,e),o.error(_(`share.revokeFailed`))}};return(0,h.jsxs)(f,{titleId:`share-dialog-title`,title:_(`share.title`,{name:n}),subtitle:_(`share.subtitle`),onClose:r,testId:`share-dialog`,children:[(0,h.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,h.jsxs)(`select`,{value:b,onChange:e=>x(e.target.value),"aria-label":_(`share.principalKind`),className:`${d} w-auto`,"data-testid":`share-principal-kind`,children:[(0,h.jsx)(`option`,{value:`user`,children:_(`share.kindUser`)}),(0,h.jsx)(`option`,{value:`group`,children:_(`share.kindGroup`)})]}),(0,h.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()},placeholder:_(b===`user`?`share.usernamePlaceholder`:`share.groupPlaceholder`),"aria-label":_(`share.principalName`),className:`${d} min-w-0 flex-1`,"data-testid":`share-principal-name`}),(0,h.jsxs)(`select`,{value:w,onChange:e=>T(e.target.value),"aria-label":_(`share.permission`),className:`${d} w-auto`,"data-testid":`share-permission`,children:[(0,h.jsx)(`option`,{value:`read`,children:_(`share.permissionRead`)}),(0,h.jsx)(`option`,{value:`write`,children:_(`share.permissionWrite`)})]}),(0,h.jsx)(u,{size:`sm`,disabled:E||!S.trim(),onClick:()=>void j(),"data-testid":`share-submit`,children:E?(0,h.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`,role:`status`,"aria-label":_(`share.sharing`)}):_(`share.action`)})]}),O?(0,h.jsxs)(`div`,{role:`alert`,className:`flex items-center justify-between gap-2 rounded-lg border border-error-200 px-2.5 py-2 text-xs text-error-700 dark:border-error-800 dark:text-error-300`,children:[(0,h.jsx)(`span`,{children:_(`share.loadFailed`)}),(0,h.jsx)(u,{variant:`outline`,size:`sm`,onClick:()=>{k(!1),A()},children:_(`common.retry`)})]}):v===null?(0,h.jsx)(s,{className:`mx-auto h-4 w-4 animate-spin text-ink-muted`,role:`status`,"aria-label":_(`share.loading`)}):v.length===0?(0,h.jsx)(`p`,{className:`text-center text-xs text-ink-muted`,children:_(`share.empty`)}):(0,h.jsx)(`div`,{className:`space-y-2`,children:v.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/6 px-2.5 py-2 dark:border-white/8`,"data-testid":`share-item`,children:[e.principalType===`group`?(0,h.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 text-ink-muted`}):(0,h.jsx)(a,{className:`h-3.5 w-3.5 shrink-0 text-ink-muted`}),(0,h.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.principalName??e.principalId}),(0,h.jsx)(`span`,{className:`shrink-0 text-[11px] uppercase text-ink-muted`,children:e.permission===`read`?_(`share.permissionRead`):e.permission===`write`?_(`share.permissionWrite`):e.permission}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void M(e.id),className:`rounded-md p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:_(`share.revoke`),"aria-label":_(`share.revoke`),children:(0,h.jsx)(c,{className:`h-3.5 w-3.5`})})]},e.id))}),(0,h.jsx)(`p`,{className:`text-[11px] leading-relaxed text-ink-muted`,children:_(`share.hint`)})]})};export{_ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{t as r}from"./useTranslation-Boi0fB1B.js";import{t as i}from"./utils-B-Bhh1pF.js";import{O as a,Or as o,W as s,dr as c,kt as l,r as u,v as d}from"./ui-vendor-6S05F84J.js";import{t as f}from"./Button-Dh2UJA-B.js";import{i as p,m,n as h,p as g,r as _,t as v,u as y}from"./ui-CI0OdG9q.js";import{a as b}from"./client-jaxZzn-I.js";import{t as x}from"./strandsApi-COxSPh_5.js";import{n as S}from"./composerStyles-BEx0XAp6.js";var C=e(t(),1),w=n(),T=(e,t)=>{if(b(e)){let t=e.response?.data;if(typeof t?.error==`string`)return t.error}return e instanceof Error?e.message:t},E=e=>{if(e==null)return``;try{let t=typeof e==`string`?e:JSON.stringify(e);return t.length>400?`${t.slice(0,400)}…`:t}catch{return``}},D=(e,t)=>{switch(t.type){case`text`:return{...e,content:e.content+t.text};case`reasoning`:return{...e,thinking:(e.thinking??``)+t.text};case`tool-start`:return{...e,tools:[...e.tools??[],{id:t.toolUseId,name:t.name,input:t.input}]};case`tool-result`:return{...e,tools:(e.tools??[]).map(e=>e.id===t.toolUseId?{...e,status:t.status,output:t.output}:e)};case`done`:return{...e,stopReason:t.stopReason};case`error`:return{...e,error:t.message};default:return e}},O=({tool:e})=>{let{t}=r(),n=E(e.input);return(0,w.jsxs)(`details`,{className:`rounded-lg border border-line bg-surface-subtle px-3 py-2 text-xs`,"data-testid":`strands-tool-trace`,children:[(0,w.jsxs)(`summary`,{className:`flex cursor-pointer items-center gap-2 text-ink-muted`,children:[(0,w.jsx)(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":`true`}),(0,w.jsx)(`span`,{dir:`ltr`,className:`font-mono text-ink`,children:e.name}),(0,w.jsx)(`span`,{children:e.status===`error`?t(`strands.tool.failed`):e.status===`success`?t(`strands.tool.done`):t(`strands.tool.running`)})]}),n&&(0,w.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-all font-mono text-ink-muted`,children:n}),e.output&&(0,w.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all font-mono text-ink`,children:e.output})]})},k=({message:e,streaming:t=!1})=>{let{t:n}=r();return e.role===`user`?(0,w.jsx)(`div`,{className:`flex justify-end`,"data-testid":`strands-user-message`,children:(0,w.jsx)(`div`,{className:`max-w-[85%] whitespace-pre-wrap rounded-2xl bg-surface-subtle px-4 py-2.5 text-sm text-ink`,children:e.content})}):(0,w.jsxs)(`div`,{className:`space-y-2`,"data-testid":`strands-assistant-message`,children:[e.thinking&&(0,w.jsxs)(`details`,{className:`text-xs text-ink-muted`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer`,children:n(`strands.reasoning`)}),(0,w.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:e.thinking})]}),(e.tools??[]).map(e=>(0,w.jsx)(O,{tool:e},e.id)),e.content&&(0,w.jsx)(`div`,{className:`text-sm text-ink`,children:(0,w.jsx)(y,{content:e.content,isStreaming:t})}),e.error&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:e.error}),e.stopReason===`cancelled`&&(0,w.jsx)(`p`,{className:`text-xs text-ink-muted`,children:n(`strands.cancelled`)}),e.stopReason===`limitTurns`&&(0,w.jsx)(`p`,{className:`text-xs text-ink-muted`,children:n(`strands.turnLimit`)})]})};function A(){let{t:e}=r(),[t,n]=(0,C.useState)(null),[u,y]=(0,C.useState)([]),[b,E]=(0,C.useState)([]),[O,A]=(0,C.useState)(null),[j,M]=(0,C.useState)([]),[N,P]=(0,C.useState)(``),[F,I]=(0,C.useState)(``),[L,R]=(0,C.useState)(!0),[z,B]=(0,C.useState)(null),[V,H]=(0,C.useState)(null),U=(0,C.useRef)(null),W=(0,C.useRef)(null),G=(0,C.useRef)(null),K=b.find(e=>e.id===O)??null,q=K?K.model??``:F,J=(0,C.useCallback)(async()=>{let e=await x.listSessions();return e.success&&e.data&&E(e.data),e.data??[]},[]);(0,C.useEffect)(()=>{let t=!1;return(async()=>{try{let[e,r,i]=await Promise.all([x.health(),x.models(),J()]);if(t)return;e.success&&e.data&&n(e.data),r.success&&r.data&&y(r.data),A(e=>e??i[0]?.id??null)}catch(n){t||B(T(n,e(`strands.loadFailed`)))}finally{t||R(!1)}})(),()=>{t=!0}},[J,e]),(0,C.useEffect)(()=>{if(!O||W.current===O)return;let t=!1;return x.getSession(O).then(e=>{!t&&e.success&&e.data&&M(e.data.messages)}).catch(n=>{t||o.error(T(n,e(`strands.loadFailed`)))}),()=>{t=!0}},[O,e]),(0,C.useEffect)(()=>{G.current?.scrollIntoView({block:`end`})},[j,V]),(0,C.useEffect)(()=>()=>U.current?.abort(),[]);let Y=async()=>{try{let e=await x.createSession({model:q||null});if(!e.success||!e.data)throw Error(e.error);return W.current=e.data.id,E(t=>[e.data,...t]),M([]),A(e.data.id),e.data}catch(t){return o.error(T(t,e(`strands.createFailed`))),null}},X=async t=>{if(window.confirm(e(`strands.deleteConfirm`,{title:t.title})))try{await x.deleteSession(t.id);let e=b.filter(e=>e.id!==t.id);E(e),O===t.id&&(M([]),A(e[0]?.id??null))}catch(t){o.error(T(t,e(`strands.deleteFailed`)))}},Z=async t=>{if(I(t),!K)return;let n=K.id,r=K.model,i=e=>E(t=>t.map(t=>t.id===n?{...t,model:e}:t));i(t||null);try{let e=await x.updateSession(n,{model:t||null});if(!e.success||!e.data)throw Error(e.error);E(t=>t.map(t=>t.id===n?e.data:t))}catch(t){i(r),I(r??``),o.error(T(t,e(`strands.saveFailed`)))}},Q=async()=>{let t=N.trim();if(!t||V)return;let n=K??await Y();if(!n)return;let r=Date.now();P(``),M(e=>[...e,{id:`local-${r}`,role:`user`,content:t,createdAt:r}]);let i={id:`local-reply-${r}`,role:`assistant`,content:``,createdAt:r};H(i);let a=new AbortController;U.current=a;try{await x.sendMessage(n.id,t,{signal:a.signal,onEvent:e=>{i=D(i,e),H(i)}})}catch(t){i=a.signal.aborted?{...i,stopReason:`cancelled`}:{...i,error:T(t,e(`strands.turnFailed`))}}finally{U.current=null,M(e=>[...e,i]),H(null),J()}},ee=async()=>{K&&(await x.cancel(K.id).catch(()=>void 0),U.current?.abort())},$=[{value:``,label:e(`strands.defaultModel`)},...u.map(e=>({value:e.id,label:`${e.name} · ${e.providerName}`}))];return q&&!u.some(e=>e.id===q)&&$.push({value:q,label:q}),(0,w.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface`,"data-testid":`strands-page`,children:[(0,w.jsx)(p,{className:`shrink-0`,title:e(`strands.title`),description:t?.harnessVersion?e(`strands.subtitleVersion`,{version:t.harnessVersion}):e(`strands.subtitle`),actions:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,onClick:()=>void Y(),disabled:!!V,"data-testid":`strands-new-session`,children:[(0,w.jsx)(l,{className:`me-2 h-4 w-4`}),e(`strands.newSession`)]})}),z&&(0,w.jsx)(v,{size:`sm`,message:z,className:`m-4 rounded-xl border border-line bg-surface-subtle`}),(0,w.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col lg:flex-row`,children:[(0,w.jsx)(`aside`,{"aria-label":e(`strands.sessions`),className:`shrink-0 border-b border-line bg-surface-subtle/30 lg:flex lg:w-64 lg:min-h-0 lg:flex-col lg:border-b-0 lg:border-e`,children:(0,w.jsxs)(`div`,{className:`min-h-0 overflow-auto p-2 lg:flex-1 lg:p-3`,children:[(0,w.jsx)(`ul`,{className:`flex gap-1 lg:block lg:space-y-1`,children:b.map(t=>(0,w.jsx)(`li`,{className:`min-w-44 lg:min-w-0`,children:(0,w.jsxs)(`div`,{className:i(`group flex items-center gap-1 rounded-lg`,t.id===O?`bg-surface-raised`:`hover:bg-surface-raised/60`),children:[(0,w.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg px-3 py-2 text-start focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/40`,onClick:()=>{t.id!==O&&(M([]),A(t.id))},"aria-current":t.id===O?`page`:void 0,disabled:!!V,children:[(0,w.jsx)(`span`,{className:`block truncate text-sm text-ink`,children:t.title}),(0,w.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-ink-muted`,children:e(`strands.messageCount`,{count:t.messageCount})})]}),(0,w.jsx)(`button`,{type:`button`,className:`me-1 rounded-sm p-1.5 text-ink-muted opacity-70 hover:text-ink focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-500/40 group-hover:opacity-100`,"aria-label":`${e(`strands.deleteSession`)}: ${t.title}`,onClick:()=>void X(t),disabled:!!V,children:(0,w.jsx)(d,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})},t.id))}),!L&&b.length===0&&(0,w.jsx)(`p`,{className:`p-2 text-xs text-ink-muted`,children:e(`strands.noSessions`)})]})}),(0,w.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,w.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-4 py-5 sm:px-6`,children:(0,w.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-5`,children:[L?(0,w.jsx)(h,{}):j.length===0&&!V?(0,w.jsx)(_,{icon:c,title:e(`strands.empty`)}):j.map(e=>(0,w.jsx)(k,{message:e},e.id)),V&&(0,w.jsx)(k,{message:V,streaming:!0}),(0,w.jsx)(`div`,{ref:G})]})}),(0,w.jsx)(`div`,{className:`shrink-0 px-4 pb-4 sm:px-6`,children:(0,w.jsxs)(`div`,{className:i(`mx-auto max-w-3xl`,S),children:[(0,w.jsx)(m,{value:N,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Q())},placeholder:e(`strands.placeholder`),"aria-label":e(`strands.placeholder`),rows:2,className:`resize-none border-0 bg-transparent shadow-none focus:ring-0`,"data-testid":`strands-input`}),(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pt-1`,children:[(0,w.jsx)(`div`,{className:`w-56 max-w-[60%]`,children:(0,w.jsx)(g,{"aria-label":e(`strands.model`),"data-testid":`strands-model-select`,value:q,onChange:e=>void Z(e.target.value),disabled:!!V,options:$,className:`h-9 py-1 text-sm`})}),V?(0,w.jsx)(f,{size:`sm`,variant:`outline`,onClick:()=>void ee(),"aria-label":e(`strands.stop`),"data-testid":`strands-stop`,children:(0,w.jsx)(a,{className:`h-4 w-4`,"aria-hidden":`true`})}):(0,w.jsx)(f,{size:`sm`,onClick:()=>void Q(),disabled:!N.trim(),"aria-label":e(`strands.send`),"data-testid":`strands-send`,children:(0,w.jsx)(s,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]})})]})]})]})}export{A as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{C as r,t as i}from"./useQuery-BTKpXudI.js";import{t as a}from"./useTranslation-Boi0fB1B.js";import{r as o,t as s}from"./utils-B-Bhh1pF.js";import{$t as c,Dr as l,Pn as u,Q as d,Rt as f,Sr as p,U as m,Vn as h,g,gt as _,jt as v,lr as y,ur as b,z as x}from"./ui-vendor-6S05F84J.js";import{t as S}from"./Button-Dh2UJA-B.js";import{o as C,s as w}from"./ui-CI0OdG9q.js";import{t as T}from"./client-jaxZzn-I.js";import{o as E}from"./api-Dcz1G4Ib.js";import{t as D}from"./workApi-Ck8nTlJn.js";import{t as O}from"./authStore-COgKeTRv.js";var k=e(t(),1),A={getDrills:()=>T.get(`/recovery/drills`).then(e=>e.data),runDrill:()=>T.post(`/recovery/drills/run`).then(e=>e.data)},j=n(),M=e=>e===null?`—`:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`,N=e=>e===null?`—`:e>=3600?`${(e/3600).toFixed(1)} h`:e>=60?`${Math.round(e/60)} min`:`${e} s`,P=()=>{let{t:e}=a(),{user:t}=O(),[n,r]=(0,k.useState)(null),[i,o]=(0,k.useState)(!1),s=(0,k.useCallback)(async()=>{try{let e=await A.getDrills();e.success&&e.data&&r(e.data)}catch{}},[]);if((0,k.useEffect)(()=>{if(t?.role!==`admin`)return;let e=setTimeout(()=>void s(),0);return()=>clearTimeout(e)},[t?.role,s]),t?.role!==`admin`||!n)return null;let c=n.drills[0],u=n.drills.find(e=>e.status===`passed`),d=async()=>{o(!0);try{let t=await A.runDrill();t.success&&t.data?t.data.status===`passed`?l.success(e(`systemPage.recovery.passed`)):l.error(t.data.error||e(`systemPage.recovery.failed`)):l.error(t.message||e(`systemPage.recovery.failed`))}catch(t){let n=t;l.error(n.response?.data?.message||e(`systemPage.recovery.failed`))}finally{o(!1),await s()}};return(0,j.jsxs)(`section`,{"data-testid":`recovery-drills-panel`,className:`rounded-2xl border border-gray-200 bg-white p-4 dark:border-dark-200 dark:bg-dark-25`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100`,children:[(0,j.jsx)(p,{className:`h-4 w-4 text-primary-500`}),e(`systemPage.recovery.title`)]}),(0,j.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:n.supported?n.intervalHours?e(`systemPage.recovery.scheduleOn`,{hours:n.intervalHours}):e(`systemPage.recovery.scheduleOff`):e(`systemPage.recovery.teamUnsupported`)})]}),n.supported&&(0,j.jsx)(S,{size:`sm`,onClick:()=>void d(),disabled:i,children:i?(0,j.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(f,{className:`h-4 w-4 animate-spin`}),e(`systemPage.recovery.running`)]}):e(`systemPage.recovery.runNow`)})]}),u&&(0,j.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.lastPassed`)}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:new Date(u.startedAt).toLocaleString()})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.restoreTime`)}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u.restoreMs===null?`—`:`${(u.restoreMs/1e3).toFixed(1)} s`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.drillSpacing`)}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:N(u.rpoSeconds)})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.archiveSize`)}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:M(u.snapshotBytes)})]})]}),c&&c.status===`failed`&&(0,j.jsxs)(`p`,{className:`mt-3 rounded-lg bg-red-50 px-3 py-2 text-xs text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:[e(`systemPage.recovery.lastFailed`,{date:new Date(c.startedAt).toLocaleString()}),c.error?` — ${c.error}`:``]}),n.drills.length>0&&(0,j.jsx)(`div`,{className:`mt-3 max-h-48 overflow-y-auto`,children:(0,j.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`text-left text-gray-500 dark:text-dark-500`,children:[(0,j.jsx)(`th`,{className:`py-1 pe-3 font-medium`,children:e(`systemPage.recovery.columns.when`)}),(0,j.jsx)(`th`,{className:`py-1 pe-3 font-medium`,children:e(`systemPage.recovery.columns.origin`)}),(0,j.jsx)(`th`,{className:`py-1 pe-3 font-medium`,children:e(`systemPage.recovery.columns.status`)}),(0,j.jsx)(`th`,{className:`py-1 font-medium`,children:e(`systemPage.recovery.columns.restore`)})]})}),(0,j.jsx)(`tbody`,{children:n.drills.slice(0,10).map(t=>(0,j.jsxs)(`tr`,{className:`border-t border-gray-100 text-gray-700 dark:border-dark-200 dark:text-dark-800`,children:[(0,j.jsx)(`td`,{className:`py-1 pe-3`,children:new Date(t.startedAt).toLocaleString()}),(0,j.jsx)(`td`,{className:`py-1 pe-3`,children:t.origin===`manual`?e(`systemPage.recovery.originManual`):e(`systemPage.recovery.originScheduled`)}),(0,j.jsx)(`td`,{className:`py-1 pe-3`,children:(0,j.jsx)(`span`,{className:t.status===`passed`?`text-green-600 dark:text-green-400`:t.status===`failed`?`text-red-600 dark:text-red-400`:`text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.status.${t.status}`)})}),(0,j.jsx)(`td`,{className:`py-1`,children:t.restoreMs===null?`—`:`${(t.restoreMs/1e3).toFixed(1)} s`})]},t.id))})]})})]})},F=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),I=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),L=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),R=e=>{if(!Number.isFinite(e)||e<0)return`—`;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${F.format(e/1024**n)} ${t[n]}`},z=e=>{if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:i>0?`${i}m`:`${Math.floor(e)}s`},B=e=>Math.min(100,Math.max(0,Number.isFinite(e)?e:0)),V=e=>{switch(e.toLowerCase()){case`running`:return`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`;case`paused`:return`bg-amber-500/10 text-amber-700 dark:text-amber-300`;case`exited`:case`dead`:return`bg-gray-500/10 text-gray-600 dark:text-dark-600`;default:return`bg-primary-500/10 text-primary-700 dark:text-primary-300`}},H=({title:e,description:t,icon:n,className:r,action:i,children:a})=>(0,j.jsxs)(`section`,{className:s(`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/8 dark:bg-dark-100/75`,r),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,j.jsx)(`div`,{className:`mt-0.5 rounded-xl bg-primary-500/10 p-1.5 text-primary-600 dark:text-primary-300`,children:(0,j.jsx)(n,{className:`h-4 w-4`})}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e}),t&&(0,j.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t})]})]}),i]}),a]}),U=({label:e,value:t,mono:n})=>(0,j.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-5 border-b border-gray-100 py-2 last:border-0 dark:border-white/5`,children:[(0,j.jsx)(`dt`,{className:`shrink-0 text-xs text-gray-500 dark:text-dark-500`,children:e}),(0,j.jsx)(`dd`,{className:s(`min-w-0 wrap-break-word text-end text-xs font-medium text-gray-800 dark:text-dark-800`,n&&`font-mono text-[11px]`),children:t})]}),W=({value:e,label:t,tone:n=`primary`})=>(0,j.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,role:`progressbar`,"aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(B(e)),children:(0,j.jsx)(`div`,{className:s(`h-full rounded-full transition-[width] duration-300`,n===`warning`?`bg-amber-500 dark:bg-amber-400`:`bg-primary-500 dark:bg-primary-400`),style:{width:`${B(e)}%`}})}),G=()=>{let{t:e,i18n:t}=a(),n=r(),[s,c]=k.useState(!1),{data:u,error:d}=i({queryKey:[`work-admin-recovery`],queryFn:async()=>{let t=await D.adminRecovery();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.work.recovery.loadFailed`));return t.data},refetchInterval:15e3,refetchIntervalInBackground:!1}),f=t=>{switch(t){case`stop-failed`:return e(`systemPage.work.recovery.reasonStopFailed`);case`runtime-unreachable`:return e(`systemPage.work.recovery.reasonRuntimeUnreachable`);case`orphan`:return e(`systemPage.work.recovery.reasonOrphan`);default:return e(`systemPage.work.recovery.reasonStartup`)}},p=async()=>{c(!0);try{let t=await D.retryAdminRecovery();if(!t.success||!t.data){l.error(t.error||e(`systemPage.work.recovery.retryFailed`));return}let{attempted:n,cleared:r}=t.data;r>0?l.success(e(`systemPage.work.recovery.retrySucceeded`,{attempted:n,cleared:r})):l.error(e(`systemPage.work.recovery.retryPending`,{attempted:n}))}catch(t){l.error(t instanceof Error&&t.message?t.message:e(`systemPage.work.recovery.retryFailed`))}finally{c(!1),await n.invalidateQueries({queryKey:[`work-admin-recovery`]}),await n.invalidateQueries({queryKey:[`work-admin-overview`]})}};return(0,j.jsxs)(`div`,{"data-testid":`work-recovery-panel`,className:`mx-4 mt-4 rounded-xl border border-amber-500/30 bg-amber-500/5 sm:mx-5`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,j.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e(`systemPage.work.recovery.title`)}),(0,j.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-600 dark:text-dark-600`,children:e(`systemPage.work.recovery.description`)})]})]}),(0,j.jsx)(S,{variant:`outline`,size:`sm`,"data-testid":`work-recovery-retry`,onClick:()=>void p(),disabled:s,children:e(s?`systemPage.work.recovery.retrying`:`systemPage.work.recovery.retry`)})]}),d&&!u?(0,j.jsx)(`p`,{className:`px-4 pb-3 text-xs text-red-700 dark:text-red-300`,children:d instanceof Error&&d.message?d.message:e(`systemPage.work.recovery.loadFailed`)}):(0,j.jsx)(`div`,{className:`overflow-x-auto`,children:(0,j.jsxs)(`table`,{className:`w-full min-w-[720px] text-sm`,children:[(0,j.jsx)(`thead`,{className:`text-[11px] uppercase tracking-widest text-gray-400 dark:text-dark-500`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.container`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.task`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.reason`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.attempts`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.lastError`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`systemPage.work.recovery.nextAttempt`)})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-amber-500/20`,children:(u??[]).map(n=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{className:`px-4 py-2.5 font-mono text-[11px] text-gray-800 dark:text-dark-800`,children:n.containerName}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-700 dark:text-dark-700`,children:n.title?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:n.title}),n.ownerUsername&&(0,j.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:n.ownerUsername})]}):e(`systemPage.work.recovery.reasonOrphan`)}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-700 dark:text-dark-700`,children:f(n.reason)}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-700 dark:text-dark-700`,children:n.attempts}),(0,j.jsx)(`td`,{className:`max-w-xs px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:(0,j.jsx)(`span`,{className:`line-clamp-2`,children:n.lastError||`—`})}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-end text-xs text-gray-600 dark:text-dark-600`,children:n.nextAttemptAt?o(n.nextAttemptAt,t.language):e(`systemPage.work.recovery.notScheduled`)})]},`${n.kind}:${n.containerName}`))})]})})]})},K=()=>{let{t:e}=a(),{data:t,error:n,isFetching:r,refetch:o}=i({queryKey:[`work-admin-overview`],queryFn:async()=>{let t=await D.adminOverview();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1});if(!t)return n?(0,j.jsx)(H,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:y,children:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-4 sm:px-5`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3 text-sm text-red-700 dark:text-red-300`,children:[(0,j.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,j.jsx)(`p`,{children:n instanceof Error&&n.message?n.message:e(`systemPage.loadFailed`)})]}),(0,j.jsx)(S,{variant:`outline`,size:`sm`,onClick:()=>void o(),disabled:r,children:e(`common.retry`)})]})}):null;let c=t=>e(t===null?`systemPage.work.stateUnknown`:t?`systemPage.work.stateRunning`:`systemPage.work.stateStopped`),l=t=>{if(!t||t.length===0)return e(`systemPage.work.inUseNone`);let n=new Map;for(let e of t)n.set(e.kind,(n.get(e.kind)??0)+1);return[...n.entries()].map(([t,n])=>`${n} ${e(`systemPage.work.usageKinds.${t}`)}`).join(`, `)},u=t=>{switch((t||``).split(`:`)[0]){case`completed`:return e(`work.runs.exitStates.completed`);case`needs_input`:return e(`work.runs.exitStates.needsInput`);case`failed`:return e(`work.runs.exitStates.failed`);case`cancelled`:return e(`work.runs.exitStates.cancelled`);default:return`—`}},d=t=>t===`running`?e(`systemPage.work.stateRunning`):t===`starting`?e(`systemPage.work.stateStarting`):`—`;return(0,j.jsxs)(H,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:y,action:(0,j.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-widest`,t.runtimeAvailable?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,j.jsx)(`span`,{className:s(`h-1.5 w-1.5 rounded-full`,t.runtimeAvailable?`bg-emerald-500`:`bg-gray-400`)}),t.runtimeAvailable?e(`systemPage.work.runtimeAvailable`):e(`systemPage.work.runtimeUnavailable`)]}),children:[(0,j.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[e(`systemPage.work.access`),t.accessMode===`all-users`?e(`systemPage.work.accessAllUsers`):e(`systemPage.work.accessAdmins`)],[e(`systemPage.work.activeRuntimes`),`${t.admission.activeGlobal} / ${t.admission.maxGlobal}`],[e(`systemPage.work.pendingCleanups`),t.recoveryPending],[e(`systemPage.work.orphans`),t.orphanContainers.length]].map(([e,t])=>(0,j.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,j.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),t.recoveryPending>0&&(0,j.jsx)(G,{}),!t.runtimeAvailable&&t.runtimeReason&&(0,j.jsxs)(`div`,{className:`mx-4 mt-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:mx-5`,children:[(0,j.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,j.jsx)(`p`,{children:t.runtimeReason})]}),t.tasks.length===0?(0,j.jsx)(`p`,{className:`px-4 py-4 text-sm text-gray-500 dark:text-dark-500 sm:px-5`,children:e(`systemPage.work.noTasks`)}):(0,j.jsx)(`div`,{className:`overflow-x-auto`,children:(0,j.jsxs)(`table`,{"data-testid":`system-work-table`,className:`w-full min-w-[900px] text-sm`,children:[(0,j.jsx)(`thead`,{className:`text-[11px] uppercase tracking-widest text-gray-400 dark:text-dark-500`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`systemPage.work.owner`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.task`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.state`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.preview`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.terminals`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.inUse`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.lastRun`)}),(0,j.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`systemPage.work.updated`)})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/6`,children:t.tasks.map(t=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{className:`px-5 py-2.5 text-gray-800 dark:text-dark-800`,children:t.ownerUsername}),(0,j.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,j.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:t.model})]}),(0,j.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,j.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 text-xs`,t.running?`text-emerald-700 dark:text-emerald-300`:`text-gray-600 dark:text-dark-600`),children:[(0,j.jsx)(`span`,{className:s(`h-1.5 w-1.5 rounded-full`,t.running===null?`bg-amber-400`:t.running?`bg-emerald-500`:`bg-gray-400`)}),c(t.running)]})}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:d(t.previewStatus)}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:t.terminalSessions}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,"data-testid":`work-admin-usage`,children:l(t.usage)}),(0,j.jsx)(`td`,{className:`max-w-[240px] px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,"data-testid":`work-admin-last-run`,children:t.lastRun?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{title:t.lastRun.exitState,children:u(t.lastRun.exitState)}),t.lastRun.summary&&(0,j.jsx)(`div`,{dir:`auto`,className:`mt-0.5 truncate text-[10px] text-gray-500 dark:text-dark-500`,title:t.lastRun.summary,children:t.lastRun.summary})]}):e(`systemPage.work.noRun`)}),(0,j.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-600 dark:text-dark-600`,children:L.format(t.updatedAt)})]},t.id))})]})})]})},q=()=>{let{t:e}=a(),{data:t,error:n,isLoading:r,isFetching:o,refetch:c}=i({queryKey:[`system-diagnostics`],queryFn:async()=>{let t=await E.getDiagnostics();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1}),l=n?n instanceof Error?n.message:e(`systemPage.loadFailed`):null;return r&&!t?(0,j.jsx)(w,{width:`wide`,children:(0,j.jsxs)(`div`,{role:`status`,className:`flex min-h-[50vh] items-center justify-center`,children:[(0,j.jsx)(f,{className:`h-7 w-7 animate-spin text-primary-500`}),(0,j.jsx)(`span`,{className:`sr-only`,children:e(`common.loading`)})]})}):(0,j.jsxs)(w,{width:`wide`,children:[(0,j.jsx)(C,{eyebrow:e(`systemPage.eyebrow`),title:e(`systemPage.title`),description:e(`systemPage.description`),actions:(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,j.jsx)(`span`,{className:`hidden text-xs text-gray-500 dark:text-dark-500 sm:inline`,children:e(`systemPage.updated`,{date:L.format(t.generatedAt)})}),(0,j.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>void c(),disabled:o,children:[(0,j.jsx)(d,{className:s(`h-4 w-4`,o&&`animate-spin`)}),(0,j.jsx)(`span`,{className:`sr-only`,children:e(`systemPage.refresh`)})]})]})}),l&&(0,j.jsxs)(`div`,{role:`alert`,className:`mb-6 flex items-center gap-3 rounded-2xl border border-error-200 bg-error-50 px-4 py-3 text-sm text-error-700 dark:border-error-900/40 dark:bg-error-900/30 dark:text-error-300`,children:[(0,j.jsx)(g,{className:`h-4 w-4 shrink-0`}),(0,j.jsx)(`span`,{children:l})]}),t&&(0,j.jsxs)(`div`,{"data-testid":`system-dashboard`,className:`space-y-4`,children:[(0,j.jsx)(J,{diagnostics:t}),(0,j.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,j.jsx)(Y,{diagnostics:t}),(0,j.jsx)(X,{diagnostics:t})]}),(0,j.jsx)(Z,{diagnostics:t}),(0,j.jsx)(Q,{diagnostics:t}),(0,j.jsx)(K,{}),(0,j.jsx)(P,{}),(0,j.jsx)(ee,{diagnostics:t}),(0,j.jsxs)(`div`,{className:`flex items-start gap-2 px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:[(0,j.jsx)(x,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary-500`}),(0,j.jsx)(`p`,{children:e(`systemPage.securityNote`)})]})]})]})},J=({diagnostics:e})=>{let{t}=a(),n=e.filesystems.find(e=>e.label===`Data directory`)??e.filesystems[0],r=[{label:t(`systemPage.cards.uptime`),value:z(e.host.uptimeSeconds),detail:t(`systemPage.cards.uptimeDetail`,{date:L.format(e.host.bootedAt)}),icon:h},{label:t(`systemPage.cards.memory`),value:`${I.format(e.memory.usedPercent)}%`,detail:t(`systemPage.cards.memoryDetail`,{used:R(e.memory.usedBytes),total:R(e.memory.totalBytes)}),icon:v},{label:t(`systemPage.cards.freeSpace`),value:n?R(n.freeBytes):`—`,detail:n?t(`systemPage.cards.freeSpaceDetail`,{label:n.label,total:R(n.totalBytes)}):t(`systemPage.cards.unavailable`),icon:c},{label:t(`systemPage.cards.containers`),value:e.docker.available?String(e.docker.runningContainers):`—`,detail:e.docker.available?t(`systemPage.cards.containersDetail`,{total:e.docker.totalContainers}):t(`systemPage.cards.dockerUnavailable`),icon:u}];return(0,j.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:r.map(e=>{let t=e.icon;return(0,j.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/8 dark:bg-dark-100/70`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,j.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,j.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,j.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})})},Y=({diagnostics:e})=>{let{t}=a(),{host:n,runtime:r}=e;return(0,j.jsx)(H,{title:t(`systemPage.host.title`),description:t(`systemPage.host.description`),icon:m,action:(0,j.jsx)(`span`,{className:`rounded-full bg-primary-500/10 px-2.5 py-1 text-[10px] font-medium uppercase tracking-widest text-primary-700 dark:text-primary-300`,children:n.containerized?t(`systemPage.host.container`):t(`systemPage.host.native`)}),children:(0,j.jsxs)(`dl`,{className:`px-4 py-2 sm:px-5`,children:[(0,j.jsx)(U,{label:t(`systemPage.host.hostname`),value:n.hostname}),(0,j.jsx)(U,{label:t(`systemPage.host.operatingSystem`),value:`${n.platform} ${n.release} · ${n.architecture}`}),(0,j.jsx)(U,{label:t(`systemPage.host.processor`),value:`${n.cpuModel} · ${n.logicalCpus} ${t(`systemPage.host.logicalCpus`)}`}),(0,j.jsx)(U,{label:t(`systemPage.host.loadAverage`),value:n.loadAverage.map(e=>I.format(e)).join(` · `)}),(0,j.jsx)(U,{label:t(`systemPage.host.libreVersion`),value:r.appVersion}),(0,j.jsx)(U,{label:t(`systemPage.host.nodeVersion`),value:r.nodeVersion}),(0,j.jsx)(U,{label:t(`systemPage.host.process`),value:`PID ${r.processId} · ${z(r.processUptimeSeconds)}`}),(0,j.jsx)(U,{label:t(`systemPage.host.workingDirectory`),value:r.workingDirectory,mono:!0})]})})},X=({diagnostics:e})=>{let{t}=a(),{memory:n}=e;return(0,j.jsx)(H,{title:t(`systemPage.memory.title`),description:t(`systemPage.memory.description`),icon:v,children:(0,j.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`mb-2 flex items-end justify-between gap-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`text-2xl tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:[I.format(n.usedPercent),`%`]}),(0,j.jsx)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.usedOf`,{used:R(n.usedBytes),total:R(n.totalBytes)})})]}),(0,j.jsx)(`span`,{className:`text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.free`,{value:R(n.freeBytes)})})]}),(0,j.jsx)(W,{label:t(`systemPage.memory.title`),value:n.usedPercent,tone:n.usedPercent>=85?`warning`:`primary`})]}),(0,j.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[t(`systemPage.memory.processRss`),n.processRssBytes],[t(`systemPage.memory.heapUsed`),n.heapUsedBytes],[t(`systemPage.memory.heapTotal`),n.heapTotalBytes],[t(`systemPage.memory.external`),n.externalBytes]].map(([e,t])=>(0,j.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,j.jsx)(`div`,{className:`mt-1 text-lg text-gray-950 dark:text-dark-950`,children:R(Number(t))})]},String(e)))})]})})},Z=({diagnostics:e})=>{let{t}=a();return(0,j.jsx)(H,{title:t(`systemPage.storage.title`),description:t(`systemPage.storage.description`),icon:c,children:e.filesystems.length===0?(0,j.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.storage.empty`)}):(0,j.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5`,children:e.filesystems.map(e=>(0,j.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/6 dark:bg-dark-200/55`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e.label}),(0,j.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.path})]}),(0,j.jsxs)(`span`,{className:`shrink-0 text-sm tabular-nums text-gray-700 dark:text-dark-700`,children:[I.format(e.usedPercent),`%`]})]}),(0,j.jsx)(`div`,{className:`mt-4`,children:(0,j.jsx)(W,{label:e.label,value:e.usedPercent,tone:e.usedPercent>=85?`warning`:`primary`})}),(0,j.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,j.jsx)(`span`,{children:t(`systemPage.storage.used`,{value:R(e.usedBytes)})}),(0,j.jsx)(`span`,{children:t(`systemPage.storage.free`,{value:R(e.freeBytes)})})]})]},`${e.label}:${e.path}`))})})},Q=({diagnostics:e})=>{let{t}=a(),{docker:n}=e;return(0,j.jsx)(H,{title:t(`systemPage.docker.title`),description:t(`systemPage.docker.description`),icon:u,action:(0,j.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-widest`,n.available?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,j.jsx)(`span`,{className:s(`h-1.5 w-1.5 rounded-full`,n.available?`bg-emerald-500`:`bg-gray-400`)}),n.available?t(`systemPage.docker.connected`):t(`systemPage.docker.unavailable`)]}),children:n.available?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[t(`systemPage.docker.running`),n.runningContainers],[t(`systemPage.docker.stopped`),n.stoppedContainers],[t(`systemPage.docker.paused`),n.pausedContainers],[t(`systemPage.docker.total`),n.totalContainers]].map(([e,t])=>(0,j.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,j.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-4 sm:px-5`,children:[n.serverVersion&&(0,j.jsx)($,{label:t(`systemPage.docker.version`),value:n.serverVersion}),n.operatingSystem&&(0,j.jsx)($,{label:t(`systemPage.docker.host`),value:n.operatingSystem}),n.architecture&&(0,j.jsx)($,{label:t(`systemPage.docker.architecture`),value:n.architecture}),n.logicalCpus!==void 0&&(0,j.jsx)($,{label:t(`systemPage.docker.cpus`),value:String(n.logicalCpus)}),n.memoryBytes!==void 0&&(0,j.jsx)($,{label:t(`systemPage.docker.memory`),value:R(n.memoryBytes)})]}),n.containers.length===0?(0,j.jsx)(`p`,{className:`px-5 pb-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.empty`)}):(0,j.jsx)(`div`,{className:`overflow-x-auto border-t border-gray-200/70 dark:border-white/[0.07]`,children:(0,j.jsxs)(`table`,{"data-testid":`system-docker-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,j.jsx)(`thead`,{className:`text-[11px] uppercase tracking-widest text-gray-400 dark:text-dark-500`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:t(`systemPage.docker.container`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.image`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.state`)}),(0,j.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:t(`systemPage.docker.created`)})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/6`,children:n.containers.map(e=>(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,j.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.id})]}),(0,j.jsx)(`td`,{className:`max-w-[280px] px-4 py-2.5`,children:(0,j.jsx)(`div`,{className:`truncate font-mono text-[11px] text-gray-600 dark:text-dark-600`,title:e.image,children:e.image})}),(0,j.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,j.jsx)(`span`,{className:s(`inline-flex rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.08em]`,V(e.state)),children:e.state}),(0,j.jsx)(`div`,{className:`mt-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:e.status})]}),(0,j.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-500 dark:text-dark-500`,children:e.createdAt?L.format(e.createdAt):`—`})]},e.id))})]})})]}):(0,j.jsxs)(`div`,{className:`m-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:m-5`,children:[(0,j.jsx)(g,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{children:n.reason||t(`systemPage.docker.unavailableDetail`)}),(0,j.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.socketStatus`,{status:n.socketMounted?t(`systemPage.docker.mounted`):t(`systemPage.docker.notMounted`)})})]})]})})},$=({label:e,value:t})=>(0,j.jsxs)(`span`,{className:`rounded-full border border-gray-200 bg-white px-3 py-1.5 text-[11px] text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/70 dark:text-dark-600`,children:[(0,j.jsx)(`span`,{className:`text-gray-400 dark:text-dark-500`,children:e}),` `,t]}),ee=({diagnostics:e})=>{let{t}=a();return(0,j.jsx)(H,{title:t(`systemPage.network.title`),description:t(`systemPage.network.description`),icon:_,children:e.network.interfaces.length===0?(0,j.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.network.empty`)}):(0,j.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5 xl:grid-cols-3`,children:e.network.interfaces.map(e=>(0,j.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/6 dark:bg-dark-200/55`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(b,{className:`h-4 w-4 text-primary-500`}),(0,j.jsx)(`h3`,{className:`font-mono text-xs font-medium text-gray-900 dark:text-dark-900`,children:e.name})]}),(0,j.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.addresses.map(e=>(0,j.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-white px-3 py-2 dark:bg-dark-100/80`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-gray-400 dark:text-dark-500`,children:e.family}),e.internal&&(0,j.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`systemPage.network.internal`)})]}),(0,j.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-gray-700 dark:text-dark-700`,children:e.cidr||e.address})]},`${e.family}:${e.address}`))}),(e.receivedBytes!==void 0||e.transmittedBytes!==void 0)&&(0,j.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[10px] text-gray-500 dark:text-dark-500`,children:[(0,j.jsxs)(`span`,{children:[`↓ `,R(e.receivedBytes??0)]}),(0,j.jsxs)(`span`,{children:[`↑ `,R(e.transmittedBytes??0)]})]})]},e.name))})})};export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{C as r,t as i}from"./useQuery-BTKpXudI.js";import{a}from"./logger-BR4forr_.js";import{t as o}from"./chatStore-CVTbkZyb.js";import{t as s}from"./useTranslation-Boi0fB1B.js";import{t as c}from"./utils-B-Bhh1pF.js";import{c as l,t as u}from"./appStore-0_qlwS8f.js";import{$n as d,Dr as f,E as p,G as m,I as h,Nt as g,Q as _,R as v,St as y,T as b,Vn as x,Zn as S,c as ee,d as C,f as w,j as T,q as E,s as D,st as O,tt as te,v as k,vt as A,yt as j}from"./ui-vendor-6S05F84J.js";import{t as M}from"./Button-Dh2UJA-B.js";import{g as N,h as P,l as ne,p as F}from"./ui-CI0OdG9q.js";import{t as I}from"./confirmStore-CKkUtP9c.js";import{n as L,t as R}from"./client-jaxZzn-I.js";import{C as z,I as B,P as V,R as H,d as U,s as W,w as G,y as K,z as re}from"./api-Dcz1G4Ib.js";import{t as q}from"./strandsApi-COxSPh_5.js";import{t as J}from"./workApi-Ck8nTlJn.js";import{t as Y}from"./authStore-COgKeTRv.js";import{t as ie}from"./PasswordStrengthMeter-BSEtQBJp.js";import{t as X}from"./SettingsToggle-CkLLtFbz.js";var Z=e(t(),1),Q=n(),ae=`h-11 w-full rounded-xl border border-line bg-surface-raised px-3 text-sm text-ink focus:outline-hidden focus:ring-2 focus:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-60`;function oe(e,t){return e?.response?.data?.message||(e instanceof Error?e.message:t)||t}function se({user:e,currentUserId:t,onClose:n,onSaved:r}){let{t:i}=s(),[a,o]=(0,Z.useState)({username:e?.username??``,email:e?.email??``,password:``,role:e?.role??`user`}),[c,l]=(0,Z.useState)(!1),u=(0,Z.useRef)(!1),[d,p]=(0,Z.useState)(``),m=e?.id===t,h=()=>{u.current||n()};return(0,Q.jsx)(N,{titleId:`user-form-title`,title:i(e?`userManager.form.title.edit`:`userManager.form.title.create`),subtitle:e?(0,Q.jsx)(`span`,{className:`break-all`,children:e.username}):i(`userManager.subtitle`),onClose:h,testId:`user-form-dialog`,children:(0,Q.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),u.current)return;u.current=!0,l(!0),p(``);let n=i(e?`userManager.form.updateFailed`:`userManager.form.createFailed`);try{let t={username:a.username.trim(),email:a.email.trim()||null,role:m?e.role:a.role};a.password&&(t.password=a.password);let o=e?await H.updateUser(e.id,t):await H.createUser({...a,username:a.username.trim(),email:a.email.trim()});if(!o.success||!o.data)throw Error(o.message||n);r(o.data),f.success(i(e?`userManager.form.updateSuccess`:`userManager.form.createSuccess`))}catch(e){p(oe(e,n))}finally{u.current=!1,l(!1)}},className:`space-y-5`,"aria-busy":c,children:[(0,Q.jsxs)(`fieldset`,{disabled:c,className:`min-w-0 space-y-4`,children:[(0,Q.jsx)(P,{id:`user-form-username`,label:i(`userManager.form.username`),autoFocus:!0,autoComplete:`off`,value:a.username,onChange:e=>o({...a,username:e.target.value}),required:!0}),(0,Q.jsx)(P,{id:`user-form-email`,label:`${i(`userManager.form.email`)}${e?` (${i(`common.optional`)})`:``}`,type:`email`,dir:`ltr`,autoComplete:`off`,value:a.email,onChange:e=>o({...a,email:e.target.value}),required:!e}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(P,{id:`user-form-password`,label:`${i(`userManager.form.password`)}${e?` (${i(`common.optional`)})`:``}`,type:`password`,autoComplete:`new-password`,value:a.password,onChange:e=>o({...a,password:e.target.value}),required:!e,helper:e?i(`userManager.form.passwordHint`):void 0}),(0,Q.jsx)(ie,{password:a.password})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(ne,{htmlFor:`user-form-role`,children:i(`userManager.form.role`)}),(0,Q.jsxs)(`select`,{id:`user-form-role`,value:a.role,onChange:e=>o({...a,role:e.target.value}),disabled:m,"aria-describedby":m?`user-form-role-hint`:void 0,className:ae,children:[(0,Q.jsx)(`option`,{value:`user`,children:i(`userManager.roles.user`)}),(0,Q.jsx)(`option`,{value:`admin`,children:i(`userManager.roles.admin`)})]}),m&&(0,Q.jsx)(`p`,{id:`user-form-role-hint`,className:`text-xs text-ink-muted`,children:i(`userManager.directory.editSelfRole`)})]})]}),d&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:d}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-line pt-4`,children:[(0,Q.jsx)(M,{type:`button`,variant:`outline`,onClick:h,disabled:c,className:`min-h-11`,children:i(`common.cancel`)}),(0,Q.jsx)(M,{type:`submit`,loading:c,disabled:!a.username.trim(),className:`min-h-11`,children:i(c?e?`userManager.form.updating`:`userManager.form.creating`:e?`userManager.form.updateButton`:`userManager.form.createButton`)})]})]})})}var ce=()=>{let{t:e,i18n:t}=s(),n=r(),a=Y(e=>e.user),o=Y(e=>e.setUser),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(``),[p,g]=(0,Z.useState)(`all`),[y,b]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(``),[E,O]=(0,Z.useState)(null),A=(0,Z.useRef)(!1),{data:j=[],isLoading:F,isError:I,isFetching:L,refetch:R}=i({queryKey:[`users`],queryFn:async()=>{let t=await H.getUsers();if(!t.success||!t.data)throw Error(e(`userManager.directory.loadFailed`));return t.data}}),z=()=>{n.invalidateQueries({queryKey:[`users`]})},B=e=>{n.setQueryData([`users`],(t=[])=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),e.id===a?.id&&o(e),l(null),z()},V=u.trim().toLocaleLowerCase(t.language),U=j.filter(e=>(p===`all`||e.role===p)&&`${e.username} ${e.email??``}`.toLocaleLowerCase(t.language).includes(V)),W=U.filter(e=>e.status===`pending`),G=U.filter(e=>e.status!==`pending`),K=j.filter(e=>e.status===`pending`).length,re=j.length-K,q=!!(u||p!==`all`),J=()=>{d(``),g(`all`)},ie=async t=>{if(!A.current){A.current=!0,O(t.id);try{let n=await H.approveUser(t.id);if(!n.success||!n.data)throw Error(n.message||e(`userManager.approval.failed`));B(n.data),f.success(e(`userManager.approval.approved`,{name:t.username}))}catch(t){f.error(oe(t,e(`userManager.approval.failed`)))}finally{A.current=!1,O(null)}}},X=async()=>{if(!y||A.current||y.kind===`delete`&&y.user.id===a?.id)return;A.current=!0,O(y.user.id),C(``);let t=e(y.kind===`delete`?`userManager.deleteFailed`:`userManager.mfaResetFailed`);try{if(y.kind===`delete`){let r=await H.deleteUser(y.user.id);if(!r.success)throw Error(r.message||t);n.setQueryData([`users`],(e=[])=>e.filter(e=>e.id!==y.user.id)),z(),f.success(e(`userManager.deleteSuccess`))}else{let n=await H.resetUserMfa(y.user.id);if(!n.success)throw Error(n.message||t);f.success(e(n.data?.removed?`userManager.mfaResetSuccess`:`userManager.mfaResetNothing`,{name:y.user.username}))}b(null)}catch(e){C(oe(e,t))}finally{A.current=!1,O(null)}},ce=(e,t)=>{C(``),b({kind:e,user:t})},le=n=>(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-surface-subtle text-ink-muted`,"aria-hidden":`true`,children:n.status===`pending`?(0,Q.jsx)(x,{size:18}):n.role===`admin`?(0,Q.jsx)(h,{size:18}):(0,Q.jsx)(ee,{size:18})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`h3`,{className:`min-w-0 break-all text-sm font-medium text-ink`,children:(0,Q.jsx)(`bdi`,{children:n.username})}),n.id===a?.id&&(0,Q.jsxs)(`span`,{className:`text-xs text-ink-muted`,children:[`(`,e(`chatMessage.you`),`)`]}),(0,Q.jsx)(`span`,{className:`rounded-md border border-line px-1.5 py-0.5 text-xs text-ink-muted`,children:e(n.role===`admin`?`userManager.roles.admin`:`userManager.roles.user`)})]}),(0,Q.jsx)(`p`,{className:`mt-1 break-all text-sm text-ink-muted`,children:(0,Q.jsx)(`bdi`,{children:n.email||e(`userManager.noEmail`)})}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(n.status===`pending`?`userManager.approval.registered`:`userManager.columns.created`),`: `,new Date(n.createdAt).toLocaleDateString(t.language)]})]})]}),ue=e=>(0,Q.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,Q.jsx)(D,{size:24,className:`mx-auto mb-3 text-ink-subtle`,"aria-hidden":`true`}),(0,Q.jsx)(`p`,{className:`text-sm text-ink-muted`,children:e})]});return(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-5`,"data-testid":`user-directory`,children:[(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-line bg-surface p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 basis-full sm:flex-1 sm:basis-48`,children:[(0,Q.jsx)(m,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute inset-s-3.5 top-3.5 text-ink-subtle`}),(0,Q.jsx)(P,{type:`search`,"aria-label":e(`userManager.search`),placeholder:e(`userManager.search`),value:u,onChange:e=>d(e.target.value),className:`ps-10`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 sm:max-w-36`,children:[(0,Q.jsx)(ne,{htmlFor:`user-role-filter`,className:`sr-only`,children:e(`userManager.columns.role`)}),(0,Q.jsxs)(`select`,{id:`user-role-filter`,value:p,onChange:e=>g(e.target.value),className:ae,children:[(0,Q.jsx)(`option`,{value:`all`,children:e(`userManager.directory.allRoles`)}),(0,Q.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)}),(0,Q.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)})]})]}),(0,Q.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>void R(),disabled:L,className:`min-h-11 min-w-11 px-3`,"aria-label":e(`common.refresh`),title:e(`common.refresh`),children:(0,Q.jsx)(_,{size:16,"aria-hidden":`true`,className:L?`animate-spin motion-reduce:animate-none`:void 0})}),(0,Q.jsxs)(M,{type:`button`,onClick:()=>l(`create`),disabled:!!E,className:`min-h-11`,children:[(0,Q.jsx)(te,{size:16,"aria-hidden":`true`}),e(`userManager.createUser`)]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex min-h-5 flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{role:`status`,className:`text-xs text-ink-muted`,children:F?e(`userManager.loading`):e(`userManager.directory.results`,{visible:U.length,total:j.length})}),q&&(0,Q.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:J,className:`min-h-11 sm:min-h-8`,children:e(`userManager.directory.clearFilters`)})]})]}),I&&(0,Q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-error-500/30 p-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-ink`,children:e(`userManager.directory.loadFailed`)}),(0,Q.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>void R(),disabled:L,children:e(`common.retry`)})]}),!F&&(!I||j.length>0)&&(0,Q.jsxs)(Q.Fragment,{children:[K>0&&(0,Q.jsxs)(`section`,{"data-testid":`pending-user-approvals`,"aria-labelledby":`pending-users-title`,className:`overflow-hidden rounded-2xl border border-warning-500/30 bg-surface`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-line bg-warning-500/6 p-4`,children:[(0,Q.jsxs)(`h3`,{id:`pending-users-title`,className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,Q.jsx)(x,{size:16,"aria-hidden":`true`,className:`text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`),` `,(0,Q.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,K,`)`]})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-ink-muted`,children:e(`userManager.approval.description`)})]}),(0,Q.jsxs)(`div`,{className:`divide-y divide-line`,children:[W.map(t=>(0,Q.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-3 p-4 xl:flex-row xl:items-center xl:justify-between`,children:[le(t),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,Q.jsxs)(M,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void ie(t),disabled:!!E,loading:E===t.id,className:`min-h-11 sm:min-h-9`,children:[(0,Q.jsx)(w,{size:16,"aria-hidden":`true`}),e(`userManager.approval.activate`)]}),(0,Q.jsx)(M,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>ce(`delete`,t),disabled:!!E,className:`min-h-11 sm:min-h-9`,children:e(`userManager.approval.reject`)})]})]},t.id)),W.length===0&&ue(e(`userManager.noUsersMatching`))]})]}),(0,Q.jsxs)(`section`,{"aria-labelledby":`active-users-title`,className:`overflow-hidden rounded-2xl border border-line bg-surface`,children:[(0,Q.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,Q.jsxs)(`h3`,{id:`active-users-title`,className:`text-sm font-semibold text-ink`,children:[e(`userManager.directory.title`),` `,(0,Q.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,re,`)`]})]})}),(0,Q.jsxs)(`div`,{className:`divide-y divide-line`,children:[G.map(t=>(0,Q.jsxs)(`div`,{"data-testid":`user-row`,className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[le(t),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsxs)(M,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>l(t),disabled:!!E,"aria-label":`${e(`common.edit`)}: ${t.username}`,className:`min-h-11 sm:min-h-9`,children:[(0,Q.jsx)(T,{size:15,"aria-hidden":`true`}),e(`common.edit`)]}),(0,Q.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-mfa-button`,"aria-label":`${e(`userManager.mfaReset`)}: ${t.username}`,title:e(`userManager.mfaReset`),onClick:()=>ce(`reset`,t),disabled:!!E,className:`min-h-11 min-w-11 sm:min-h-9 sm:min-w-9 px-2`,children:(0,Q.jsx)(v,{size:16,"aria-hidden":`true`})}),(0,Q.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`${e(`common.delete`)}: ${t.username}`,title:t.id===a?.id?e(`userManager.cannotDeleteSelf`):e(`common.delete`),onClick:()=>ce(`delete`,t),disabled:t.id===a?.id||!!E,className:`min-h-11 min-w-11 sm:min-h-9 sm:min-w-9 px-2 text-error-600 dark:text-error-400`,children:(0,Q.jsx)(k,{size:16,"aria-hidden":`true`})})]})]},t.id)),G.length===0&&ue(e(q?`userManager.noUsersMatching`:`userManager.directory.empty`))]})]})]}),c&&(0,Q.jsx)(se,{user:c===`create`?null:c,currentUserId:a?.id,onClose:()=>l(null),onSaved:B},c===`create`?`create`:c.id),y&&(0,Q.jsxs)(N,{titleId:`user-action-title`,title:e(y.kind===`reset`?`userManager.mfaReset`:y.user.status===`pending`?`userManager.approval.reject`:`userManager.directory.deleteTitle`),onClose:()=>{A.current||b(null)},testId:`user-action-dialog`,children:[(0,Q.jsx)(`p`,{className:`wrap-break-word text-sm leading-relaxed text-ink-muted`,children:e(y.kind===`delete`?`userManager.deleteConfirm`:`userManager.mfaResetConfirm`,{name:y.user.username})}),S&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:S}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-line pt-4`,children:[(0,Q.jsx)(M,{type:`button`,variant:`outline`,onClick:()=>b(null),disabled:!!E,className:`min-h-11`,children:e(`common.cancel`)}),(0,Q.jsx)(M,{type:`button`,variant:`danger`,loading:!!E,onClick:()=>void X(),className:`min-h-11`,children:e(y.kind===`delete`?`common.delete`:`userManager.mfaReset`)})]})]})]})},le=()=>{let{t:e}=s(),t=(0,Z.useId)(),n=Y(e=>e.systemInfo),r=Y(e=>e.setSystemInfo),i=o(e=>e.loadModels),[a,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(0),v=`userManager.agentCliAccess`;return(0,Z.useEffect)(()=>{let e=!1;return re.getAccess().then(t=>{e||(t.success&&t.data?(c(t.data.enabled),u(t.data.lockedByEnv)):h(!0))}).catch(()=>{e||h(!0)}),()=>{e=!0}},[g]),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,"data-testid":`agent-cli-access-settings`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`${v}.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`${v}.description`)}),l&&(0,Q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`${v}.lockedByEnv`)})]}),a===null&&m?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{h(!1),_(e=>e+1)},children:e(`common.retry`)}):(0,Q.jsx)(X,{"aria-labelledby":t,checked:a===!0,onChange:async t=>{p(!0);try{let a=await re.setAccess(t);if(!a.success||!a.data)throw Error(a.error||`Agent access update failed.`);c(a.data.enabled),n&&r({...n,agentCliModelsEnabled:a.data.enabled}),await i({quiet:!0}),f.success(e(`userManager.agentCliAccess.saved`))}catch{f.error(e(`userManager.agentCliAccess.saveFailed`))}finally{p(!1)}},disabled:d||a===null||l})]})})},ue=[`disabled`,`admins`,`all-users`],de=()=>{let{t:e}=s(),t=Y(e=>e.systemInfo),n=Y(e=>e.setSystemInfo),r=o(e=>e.loadModels),[i,a]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=!1;return q.getAccess().then(t=>{e||(t.success&&t.data?(a(t.data.mode),l(t.data.lockedByEnv)):m(!0))}).catch(()=>{e||m(!0)}),()=>{e=!0}},[h]);let _=async i=>{d(!0);try{let o=await q.setAccess(i);if(!o.success||!o.data)throw Error(o.error||`Strands access update failed.`);a(o.data.mode),t&&n({...t,strandsAccess:o.data.mode}),await r({quiet:!0}),f.success(e(`userManager.strandsAccess.saved`))}catch{f.error(e(`userManager.strandsAccess.saveFailed`))}finally{d(!1)}};return(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,"data-testid":`strands-access-settings`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.strandsAccess.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.strandsAccess.description`)}),c&&(0,Q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.strandsAccess.lockedByEnv`)})]}),i===null&&p?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{m(!1),g(e=>e+1)},children:e(`common.retry`)}):(0,Q.jsx)(`div`,{className:`w-44`,children:(0,Q.jsx)(F,{"data-testid":`strands-access-mode`,"aria-label":e(`userManager.strandsAccess.title`),value:i??`disabled`,disabled:u||i===null||c,onChange:e=>void _(e.target.value),options:ue.map(t=>({value:t,label:e(`userManager.strandsAccess.modes.${t}`)}))})})]})})},fe=[{mode:`light`,icon:p,key:`settings.appearance.theme.light`},{mode:`dark`,icon:A,key:`settings.appearance.theme.dark`},{mode:`amoled`,icon:j,key:`settings.appearance.theme.amoled`},{mode:`celestial`,icon:b,key:`settings.appearance.theme.celestial`}],pe=()=>{let{t:e}=s(),t=Y(e=>e.systemInfo),n=Y(e=>e.setSystemInfo),r=u(e=>e.applyInstanceTheme),[i,a]=(0,Z.useState)(null),[o,d]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=!1;return W.getDefaultTheme().then(t=>{e||(t.success&&t.data?a(l(t.data.theme)):m(!0))}).catch(()=>{e||m(!0)}),()=>{e=!0}},[h]);let _=async o=>{if(i&&i.mode!==o){d(!0);try{let s=await W.setDefaultTheme({...i,mode:o});if(!s.success||!s.data)throw Error(s.error||`Default theme update failed.`);let c=l(s.data.theme);a(c),t&&n({...t,defaultTheme:c}),r(c),f.success(e(`userManager.defaultTheme.saved`))}catch{f.error(e(`userManager.defaultTheme.saveFailed`))}finally{d(!1)}}};return(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-[1_1_18rem]`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.defaultTheme.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.defaultTheme.description`)})]}),i===null&&p?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{m(!1),g(e=>e+1)},children:e(`common.retry`)}):(0,Q.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`userManager.defaultTheme.title`),className:`flex max-w-full flex-wrap gap-2`,children:fe.map(({mode:t,icon:n,key:r})=>{let a=i?.mode===t;return(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":a,disabled:o||i===null,onClick:()=>void _(t),className:c(`flex min-h-11 max-w-full items-center gap-2 rounded-lg border px-3 py-2 text-sm text-ink transition-colors focus:outline-hidden 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,Q.jsx)(n,{className:`h-4 w-4`,"aria-hidden":`true`}),e(r)]},t)})})]})})},me=()=>{let{t:e}=s(),t=(0,Z.useId)(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,p]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=!1;return U.getAccessMode().then(t=>{e||(t.success&&t.data?(r(t.data.mode),a(t.data.lockedByEnv)):u(!0))}).catch(()=>{e||u(!0)}),()=>{e=!0}},[d]),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.tools.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.tools.description`)}),i&&(0,Q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.tools.lockedByEnv`)})]}),n===null&&l?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{u(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Q.jsx)(X,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;c(!0);try{let t=await U.setAccessMode(n);if(!t.success)throw Error(t.error||`Tool access update failed.`);r(n),f.success(e(`userManager.tools.saved`))}catch{f.error(e(`userManager.tools.saveFailed`))}finally{c(!1)}},disabled:o||n===null||i})]})})},he={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}},ge={getModes:async()=>a()?L(he):(await R.get(`/voice-access`)).data,setMode:async(e,t)=>a()?L({feature:e,mode:t}):(await R.put(`/voice-access/${encodeURIComponent(e)}`,{mode:t})).data},_e=[{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`}],ve=()=>{let{t:e}=s(),t=(0,Z.useId)(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=!1;return ge.getModes().then(t=>{e||(t.success&&t.data?r(t.data):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]);let d=async(t,n)=>{let i=n?`all-users`:`admins`;a(t);try{let n=await ge.setMode(t,i);if(!n.success)throw Error(n.error||`Voice access update failed.`);r(e=>e&&{...e,[t]:{...e[t],mode:i}}),f.success(e(`userManager.voice.saved`))}catch{f.error(e(`userManager.voice.saveFailed`))}finally{a(null)}};return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.voice.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.voice.description`)})]}),n===null&&o&&(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)})]}),(0,Q.jsx)(`div`,{className:`mt-3 space-y-2`,children:_e.map(r=>{let a=n?.[r.key];return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{id:`${t}-${r.key}`,className:`text-xs text-gray-700 dark:text-gray-300`,children:e(r.labelKey)}),a?.lockedByEnv&&(0,Q.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:e(`userManager.voice.lockedByEnv`)})]}),(0,Q.jsx)(X,{"aria-labelledby":`${t}-${r.key}`,checked:a?.mode===`all-users`,onChange:e=>d(r.key,e),disabled:a===void 0||i===r.key||a.lockedByEnv})]},r.key)})})]})},ye=[`starttls`,`tls`,`none`],be=e=>e.replace(/<head>/i,`<head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none'"><style>img { display: none; }</style>`),xe=e=>({host:e.host??``,port:e.port?String(e.port):``,security:e.security??`starttls`,username:e.username??``,password:``,from:e.from??``,appUrl:e.appUrl??``,rejectUnauthorized:e.rejectUnauthorized!==!1,emailTheme:e.emailTheme??`light`}),Se=()=>{let{t:e,i18n:t}=s(),n=(0,Z.useId)(),r=(0,Z.useId)(),[i,a]=(0,Z.useState)(null),[o,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(``),[d,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[ee,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(0),E=o?.emailTheme,D=E?`${E}:${w}:${t.resolvedLanguage}`:null,O=ee?.key===D?ee:null,te=O?.html===null;(0,Z.useEffect)(()=>{if(!E||!D)return;let t=!1;return z.preview({emailTheme:E,heading:e(`userManager.emailNotifications.previewHeading`),lines:[e(`userManager.emailNotifications.previewIntro`)],markdown:e(`userManager.emailNotifications.previewMarkdown`),linkLabel:e(`userManager.emailNotifications.previewLinkLabel`)}).then(e=>{t||(e.success&&e.data?C({key:D,html:e.data.html}):C({key:D,html:null}))}).catch(()=>{t||C({key:D,html:null})}),()=>{t=!0}},[E,D,e]),(0,Z.useEffect)(()=>{let e=!1;return z.getSettings().then(t=>{e||(t.success&&t.data?(a(t.data),c(xe(t.data)),u(t.data.recipient??``)):b(!0))}).catch(()=>{e||b(!0)}),()=>{e=!0}},[x]);let k=e=>{a(e),c(xe(e)),v(!1)},A=(e,t)=>{let n=e.response?.data;return n?.error?n.error:n?.message?n.message:e instanceof Error&&e.message?e.message:t},j=async()=>{if(o){p(!0);try{let t=await z.updateSettings({host:o.host.trim(),port:o.port.trim(),security:o.security,username:o.username.trim(),from:o.from.trim(),appUrl:o.appUrl.trim(),rejectUnauthorized:o.rejectUnauthorized,emailTheme:o.emailTheme,...o.password?{password:o.password}:_?{password:``}:{}});if(!t.success||!t.data)throw Error(t.error||e(`userManager.emailNotifications.saveFailed`));k(t.data),f.success(e(`userManager.emailNotifications.saved`))}catch(t){f.error(A(t,e(`userManager.emailNotifications.saveFailed`)))}finally{p(!1)}}},N=async t=>{p(!0);try{let n=await z.updateSettings({enabled:t});if(!n.success||!n.data)throw Error(n.error||e(`userManager.emailNotifications.saveFailed`));k(n.data),f.success(e(t?`userManager.emailNotifications.enabledToast`:`userManager.emailNotifications.disabledToast`))}catch(t){f.error(A(t,e(`userManager.emailNotifications.saveFailed`)))}finally{p(!1)}},ne=async()=>{h(!0);try{let t=await z.test(l.trim()||void 0);if(!t.success||!t.data?.ok)throw Error(t.error||e(`userManager.emailNotifications.testFailed`));f.success(t.data.sentTo?e(`userManager.emailNotifications.testSent`,{address:t.data.sentTo}):e(`userManager.emailNotifications.testConnected`))}catch(t){f.error(A(t,e(`userManager.emailNotifications.testFailed`)))}finally{h(!1)}},I=(e,t)=>c(n=>n&&{...n,[e]:t}),L=t=>i?.sources?.[t]===`env`?e(`userManager.emailNotifications.fromEnvironment`):null,R=i!==null&&o!==null&&(JSON.stringify(xe(i))!==JSON.stringify({...o,password:``})||o.password.length>0||_),B=`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,V=`mb-2 block text-xs text-gray-500 dark:text-gray-400`;return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-4`,"data-testid":`email-notification-settings`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{id:n,className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(g,{className:`h-4 w-4 text-primary-500`}),e(`userManager.emailNotifications.title`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.emailNotifications.description`)})]}),(0,Q.jsx)(`div`,{"data-testid":`email-notifications-enabled`,children:(0,Q.jsx)(X,{"aria-labelledby":n,checked:i?.enabled===!0,onChange:e=>void N(e),disabled:d||i===null||!i.enabled&&!i.configured})})]}),y&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,Q.jsx)(`span`,{children:e(`userManager.emailNotifications.loadFailed`)}),(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{b(!1),S(e=>e+1)},children:e(`common.retry`)})]}),o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[2fr_1fr]`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.hostLabel`)}),(0,Q.jsx)(`span`,{className:V,children:L(`host`)??e(`userManager.emailNotifications.hostHint`)}),(0,Q.jsx)(P,{value:o.host,onChange:e=>I(`host`,e.target.value),placeholder:`smtp.example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-host`})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.portLabel`)}),(0,Q.jsx)(`span`,{className:V,children:L(`port`)??e(`userManager.emailNotifications.portHint`)}),(0,Q.jsx)(P,{type:`number`,min:1,max:65535,value:o.port,onChange:e=>I(`port`,e.target.value),placeholder:o.security===`tls`?`465`:`587`,dir:`ltr`,"data-testid":`email-smtp-port`})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.securityLabel`)}),(0,Q.jsx)(`span`,{className:V,children:L(`security`)??e(`userManager.emailNotifications.securityHint`)}),(0,Q.jsx)(F,{value:o.security,onChange:e=>I(`security`,e.target.value),options:ye.map(t=>({value:t,label:e(`userManager.emailNotifications.security.${t}`)})),"data-testid":`email-smtp-security`})]}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 sm:pt-1`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{id:r,className:B,children:e(`userManager.emailNotifications.verifyLabel`)}),(0,Q.jsx)(`span`,{className:`block text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.emailNotifications.verifyHint`)})]}),(0,Q.jsx)(X,{"aria-labelledby":r,checked:o.rejectUnauthorized,onChange:e=>I(`rejectUnauthorized`,e),disabled:d||o.security===`none`})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.usernameLabel`)}),(0,Q.jsx)(`span`,{className:V,children:L(`username`)??e(`userManager.emailNotifications.usernameHint`)}),(0,Q.jsx)(P,{value:o.username,onChange:e=>I(`username`,e.target.value),autoComplete:`off`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-username`})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.passwordLabel`)}),(0,Q.jsx)(`span`,{className:V,children:L(`password`)??(i?.passwordConfigured?e(`userManager.emailNotifications.passwordStored`):e(`userManager.emailNotifications.passwordHint`))}),(0,Q.jsx)(P,{type:`password`,value:o.password,onChange:e=>{I(`password`,e.target.value),e.target.value&&v(!1)},autoComplete:`new-password`,placeholder:i?.passwordConfigured?`••••••••`:``,dir:`ltr`,"data-testid":`email-smtp-password`}),i?.passwordConfigured&&i.sources?.password===`stored`&&!o.password&&(0,Q.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),e(`userManager.emailNotifications.clearPassword`)]})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.fromLabel`)}),(0,Q.jsx)(`span`,{className:V,children:L(`from`)??e(`userManager.emailNotifications.fromHint`)}),(0,Q.jsx)(P,{value:o.from,onChange:e=>I(`from`,e.target.value),placeholder:`Libre WebUI <notifications@example.com>`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-from`})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.appUrlLabel`)}),(0,Q.jsx)(`span`,{className:V,children:L(`appUrl`)??e(`userManager.emailNotifications.appUrlHint`)}),(0,Q.jsx)(P,{value:o.appUrl,onChange:e=>I(`appUrl`,e.target.value),placeholder:`https://chat.example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-app-url`})]})]}),(0,Q.jsxs)(`fieldset`,{className:`border-t border-gray-200 dark:border-dark-300 pt-3 space-y-3`,children:[(0,Q.jsx)(`legend`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:e(`userManager.emailNotifications.templateTitle`)}),(0,Q.jsx)(`p`,{className:V,children:e(`userManager.emailNotifications.templateHint`)}),(0,Q.jsxs)(`label`,{className:`block sm:max-w-xs`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.themeLabel`)}),(0,Q.jsx)(F,{value:o.emailTheme,onChange:e=>I(`emailTheme`,e.target.value),disabled:d,"data-testid":`email-template-theme`,options:[{value:`light`,label:e(`userManager.emailNotifications.themeLight`)},{value:`dark`,label:e(`userManager.emailNotifications.themeDark`)}]})]}),(0,Q.jsxs)(`div`,{"aria-busy":!O,children:[(0,Q.jsx)(`h4`,{className:B,children:e(`userManager.emailNotifications.previewTitle`)}),te?(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3`,children:[(0,Q.jsx)(`p`,{className:V,children:e(`userManager.emailNotifications.previewFailed`)}),(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>T(e=>e+1),children:e(`common.retry`)})]}):O?.html?(0,Q.jsx)(`iframe`,{title:e(`userManager.emailNotifications.previewTitle`),srcDoc:be(O.html),sandbox:``,referrerPolicy:`no-referrer`,className:`h-96 w-full rounded-lg border border-gray-200 dark:border-dark-300 bg-white`,"data-testid":`email-template-preview`}):(0,Q.jsx)(`p`,{role:`status`,className:V,children:e(`userManager.emailNotifications.previewLoading`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-gray-200 dark:border-dark-300 pt-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Q.jsxs)(`label`,{className:`block sm:max-w-xs sm:flex-1`,children:[(0,Q.jsx)(`span`,{className:B,children:e(`userManager.emailNotifications.testRecipientLabel`)}),(0,Q.jsx)(`span`,{className:V,children:e(`userManager.emailNotifications.testRecipientHint`)}),(0,Q.jsx)(P,{type:`email`,value:l,onChange:e=>u(e.target.value),placeholder:`you@example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-test-recipient`})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>void ne(),disabled:m||d||!i?.configured||R,title:R?e(`userManager.emailNotifications.saveBeforeTest`):void 0,"data-testid":`email-test-button`,children:e(m?`userManager.emailNotifications.testing`:`userManager.emailNotifications.test`)}),(0,Q.jsx)(M,{size:`sm`,onClick:()=>void j(),disabled:d||!R,"data-testid":`email-save-button`,children:e(d?`userManager.emailNotifications.saving`:`userManager.emailNotifications.save`)})]})]})]})]})},Ce=()=>{let{t:e}=s(),t=(0,Z.useId)(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=!1;return B.getMfaPolicy().then(t=>{e||(t.success&&t.data?r(t.data):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.mfaPolicy.description`)})]}),n===null&&o&&(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{id:t,className:`text-sm text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.requireAll`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:n?.locked?e(`userManager.mfaPolicy.lockedByEnv`):e(`userManager.mfaPolicy.requireAllHint`)})]}),(0,Q.jsx)(X,{"aria-labelledby":t,checked:n?.mode===`required`,disabled:n===null||n.locked||i,onChange:async t=>{let n=t?`required`:`optional`;a(!0);try{let t=await B.setMfaPolicy(n);if(!t.success||!t.data)throw Error(t.error||`MFA policy update failed.`);r(t.data),f.success(e(`userManager.mfaPolicy.saved`))}catch{f.error(e(`userManager.mfaPolicy.saveFailed`))}finally{a(!1)}}})]})]})},we=()=>{let{t:e,i18n:t}=s(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)([]),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!0),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(!1),[x,ee]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(``),[E,O]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(``),[N,ne]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(!1),z=(0,Z.useMemo)(()=>{let e=new Map;return i.forEach(t=>e.set(t.id,t.username)),e},[i]),B=(0,Z.useCallback)(async()=>{u(!0),c(!1);try{let[t,n]=await Promise.all([V.getGroups(),H.getUsers()]);if(!t.success||!t.data)throw Error(t.error||e(`userManager.groups.loadFailed`));r(t.data),n.success&&n.data&&a(n.data)}catch{c(!0)}finally{u(!1)}},[e]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void B(),0);return()=>clearTimeout(e)},[B]);let U=async t=>{if(t.preventDefault(),!h.trim()){f.error(e(`userManager.groups.nameRequired`,`Give the group a name.`));return}b(!0);try{let t=await V.createGroup({name:h.trim(),description:_.trim()||void 0});if(!t.success)throw Error(t.error||e(`userManager.groups.createFailed`));g(``),v(``),m(!1),f.success(e(`userManager.groups.created`,`Group created.`)),await B()}catch(t){f.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.createFailed`,`The group could not be created.`))}finally{b(!1)}},W=async t=>{if(await I({title:e(`userManager.groups.deleteConfirmTitle`,{name:t.name}),description:e(`userManager.groups.deleteConfirmDescription`),confirmLabel:e(`userManager.groups.deleteGroup`),destructive:!0})){O(t.id);try{let n=await V.deleteGroup(t.id);if(!n.success)throw Error(n.error||e(`userManager.groups.deleteFailed`));f.success(e(`userManager.groups.deleted`,`Group deleted.`)),x===t.id&&ee(null),await B()}catch(t){f.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.deleteFailed`,`The group could not be deleted.`))}finally{O(null)}}},G=async t=>{if(w){O(t.id);try{let n=await V.addGroupMember(t.id,w);if(!n.success)throw Error(n.error||e(`userManager.groups.memberAddFailed`));T(``),f.success(e(`userManager.groups.memberAdded`,`Member added.`)),await B()}catch(t){f.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberAddFailed`,`The member could not be added.`))}finally{O(null)}}},K=async(t,n)=>{O(t.id);try{let r=await V.removeGroupMember(t.id,n);if(!r.success)throw Error(r.error||e(`userManager.groups.memberRemoveFailed`));f.success(e(`userManager.groups.memberRemoved`,`Member removed.`)),await B()}catch(t){f.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberRemoveFailed`,`The member could not be removed.`))}finally{O(null)}},re=async t=>{if(j(t),ne(null),t){R(!0);try{let n=await V.getEffectiveAccess(t);if(!n.success||!n.data)throw Error(n.error||e(`userManager.groups.accessLookupFailed`));ne(n.data)}catch(t){f.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.accessLookupFailed`,`The effective access could not be loaded.`))}finally{R(!1)}}},q=e=>e.map(e=>({value:e.id,label:e.username}));return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(D,{className:`h-4 w-4 text-primary-500`}),e(`userManager.groups.title`,`Groups`)]}),(0,Q.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.`)})]}),o?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>void B(),children:e(`common.retry`)}):(0,Q.jsxs)(M,{size:`sm`,variant:`outline`,onClick:()=>m(e=>!e),className:`gap-1.5`,children:[(0,Q.jsx)(te,{size:14}),e(`userManager.groups.newGroup`,`New group`)]})]}),p&&(0,Q.jsxs)(`form`,{onSubmit:U,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,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.nameLabel`,`Name`)}),(0,Q.jsx)(P,{value:h,onChange:e=>g(e.target.value)})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.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,Q.jsx)(P,{value:_,onChange:e=>v(e.target.value)})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(M,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>m(!1),children:e(`common.cancel`)}),(0,Q.jsx)(M,{type:`submit`,size:`sm`,disabled:y,children:y?e(`userManager.groups.creating`,`Creating…`):e(`userManager.groups.create`,`Create group`)})]})]}),(0,Q.jsx)(`div`,{className:`mt-4 space-y-3`,children:l?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):o?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.loadFailed`,`The groups could not be loaded.`)}):n.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.empty`,`No groups yet.`)}):n.map(n=>{let r=x===n.id,a=new Set(n.members.map(e=>e.user_id)),o=i.filter(e=>!a.has(e.id));return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-100`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-4`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-start`,onClick:()=>{ee(r?null:n.id),T(``)},"aria-expanded":r,children:[r?(0,Q.jsx)(d,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Q.jsx)(S,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:[n.name,(0,Q.jsx)(`span`,{className:`ms-2 text-xs font-normal text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberCount`,{count:n.members.length,defaultValue:`Members: {{count}}`})})]}),n.description&&(0,Q.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:n.description})]})]}),(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>void W(n),disabled:E===n.id,"aria-label":e(`userManager.groups.deleteGroup`,`Delete group`),className:`text-error-700 hover:border-error-500/40 hover:bg-error-500/10 hover:text-error-800 dark:text-error-400 dark:hover:text-error-300`,children:(0,Q.jsx)(k,{size:16})})]}),r&&(0,Q.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 p-4 space-y-3`,children:[n.members.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.noMembers`,`No members yet.`)}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.members.map(r=>(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:z.get(r.user_id)||r.user_id}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`userManager.groups.addedAt`,`Added`),`:`,` `,new Date(r.added_at).toLocaleDateString(t.language)]})]}),(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>void K(n,r.user_id),disabled:E===n.id,"aria-label":e(`userManager.groups.removeMember`,`Remove member`),children:(0,Q.jsx)(C,{size:16})})]},r.user_id))}),o.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(F,{label:e(`userManager.groups.addMember`,`Add member`),value:w,onChange:e=>T(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...q(o)]})}),(0,Q.jsx)(M,{size:`sm`,onClick:()=>void G(n),disabled:!w||E===n.id,className:`mb-0.5`,children:e(`userManager.groups.add`,`Add`)})]})]})]},n.id)})}),(0,Q.jsxs)(`div`,{className:`mt-6 border-t border-gray-200 dark:border-dark-300 pt-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.effectiveTitle`,`Effective access`)}),(0,Q.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,Q.jsx)(F,{"aria-label":e(`userManager.groups.effectiveTitle`,`Effective access`),value:A,onChange:e=>void re(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...q(i)]}),L&&(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}),N&&!L&&(0,Q.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,Q.jsxs)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:N.username}),(0,Q.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[` · `,e(`userManager.groups.roleLabel`,`Role`),`:`,` `,e(`userManager.roles.${N.role}`,{defaultValue:N.role}),` · `,e(`userManager.groups.statusLabel`,`Status`),`:`,` `,e(`userManager.groups.statuses.${N.status}`,{defaultValue:N.status})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberOf`,`Groups`)}),N.groups.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:N.groups.map(e=>(0,Q.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,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.featuresLabel`,`Feature access`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(N.features).map(([t,n])=>(0,Q.jsxs)(`span`,{className:n?`rounded-full bg-success-100 px-2 py-0.5 text-xs text-success-800 dark:bg-success-900/30 dark:text-success-300`:`rounded-full bg-surface-subtle px-2 py-0.5 text-xs text-ink-muted`,children:[e(`userManager.groups.features.${t}`,{defaultValue:t}),`: `,e(n?`common.yes`:`common.no`)]},t))})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.grantsLabel`,`Grants`)}),N.grants.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Q.jsx)(`div`,{className:`space-y-1`,children:N.grants.map(t=>(0,Q.jsxs)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[t.resourceType,`/`,t.resourceId,` ·`,` `,t.permission,` `,(0,Q.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[`(`,e(`userManager.groups.grantVia`,`via`),` `,e(`userManager.groups.grantViaKinds.${t.via}`,{defaultValue:t.via}),`)`]})]},t.id))})]})]})]})]})},Te={success:`bg-success-100 text-success-800 dark:bg-success-900/30 dark:text-success-300`,denied:`bg-warning-500/15 text-ink`,failure:`bg-error-100 text-error-800 dark:bg-error-900/30 dark:text-error-200`},Ee=()=>{let{t:e,i18n:t}=s(),n=(0,Z.useId)(),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(!0),[c,l]=(0,Z.useState)(!1),[u,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(`50`),b=(0,Z.useCallback)(async()=>{o(!0),l(!1);try{let t=Number(v),n=await V.getAuditEvents({action:p.trim()||void 0,result:h||void 0,limit:Number.isInteger(t)&&t>0?t:void 0});if(!n.success||!n.data)throw Error(n.error||e(`userManager.audit.loadFailed`));i(n.data)}catch{l(!0)}finally{o(!1)}},[p,h,v,e]);(0,Z.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,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(E,{className:`h-4 w-4 text-primary-500`}),e(`userManager.audit.title`,`Security audit log`)]}),(0,Q.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,Q.jsxs)(M,{size:`sm`,variant:`outline`,type:`submit`,form:n,disabled:a,className:`gap-1.5`,children:[(0,Q.jsx)(_,{size:14,className:a?`animate-spin`:void 0}),e(`common.refresh`)]})]}),(0,Q.jsxs)(`form`,{id:n,onSubmit:e=>{e.preventDefault(),b()},className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.actionFilter`,`Action`)}),(0,Q.jsx)(P,{value:p,onChange:e=>m(e.target.value),placeholder:e(`userManager.audit.actionPlaceholder`,`e.g. auth.login`),spellCheck:!1,dir:`ltr`})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.resultFilter`,`Result`)}),(0,Q.jsx)(F,{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,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.limitFilter`,`Limit`)}),(0,Q.jsx)(P,{type:`number`,min:1,max:500,value:v,onChange:e=>y(e.target.value),dir:`ltr`})]})]}),(0,Q.jsx)(`div`,{className:`mt-4 space-y-2`,children:a?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):c?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.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,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>void b(),children:e(`common.retry`)})]}):r.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.empty`,`No audit events recorded yet.`)}):r.map(n=>{let r=u===n.id,i=n.details&&Object.keys(n.details).length>0;return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 px-3 py-2 text-start`,onClick:()=>f(r?null:n.id),"aria-expanded":r,children:[i?r?(0,Q.jsx)(d,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Q.jsx)(S,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Q.jsx)(`span`,{className:`h-4 w-4 shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:n.action}),(0,Q.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${Te[n.result]||`bg-surface-subtle text-ink-muted`}`,children:x(n.result)})]}),(0,Q.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-gray-500 dark:text-gray-400`,children:[new Date(n.occurredAt).toLocaleString(t.language),` · `,e(`userManager.audit.actor`,`Actor`),`:`,` `,n.actorUserId||n.actorKind,n.targetType&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,e(`userManager.audit.target`,`Target`),`:`,` `,n.targetType,n.targetId?`/${n.targetId}`:``]})]})]})]}),r&&i&&(0,Q.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(n.details,null,2)})]},n.id)})})]})},De=()=>{let{t:e}=s(),t=(0,Z.useId)(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=!1;return K.getModelAccess().then(t=>{e||(t.success&&t.data?r(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.modelAccess.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.modelAccess.description`)})]}),n===null&&o?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Q.jsx)(X,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;a(!0);try{if(!(await K.setModelAccess(n)).success)throw Error(`Model download access update failed.`);r(n),f.success(e(`userManager.modelAccess.saved`))}catch{f.error(e(`userManager.modelAccess.saveFailed`))}finally{a(!1)}},disabled:i||n===null})]})})},Oe=()=>{let{t:e}=s(),t=(0,Z.useId)(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(``),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,p]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=!1;return K.getSettings().then(t=>{e||(t.success&&t.data?(r(t.data),a(t.data.baseUrl)):u(!0))}).catch(()=>{e||u(!0)}),()=>{e=!0}},[d]);let m=async t=>{c(!0);try{let n=await K.updateSettings(t);if(!n.success||!n.data)throw Error(n.message||`update failed`);r(n.data),a(n.data.baseUrl),f.success(e(`userManager.ollamaProvider.saved`))}catch{f.error(e(`userManager.ollamaProvider.saveFailed`))}finally{c(!1)}},h=n!==null&&i.trim()!==n.baseUrl;return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.ollamaProvider.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.ollamaProvider.description`)})]}),n===null&&l?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{u(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Q.jsx)(X,{"aria-labelledby":t,checked:n?.enabled===!0,onChange:e=>void m({enabled:e}),disabled:o||n===null})]}),n!==null&&(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,Q.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-hidden dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,value:i,onChange:e=>a(e.target.value),placeholder:`http://localhost:11434`,spellCheck:!1,"aria-label":e(`userManager.ollamaProvider.baseUrlLabel`)}),(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>void m({baseUrl:i.trim()}),disabled:o||!h||!i.trim(),children:e(`common.save`)})]})]})},ke=()=>{let{t:e}=s(),t=(0,Z.useId)(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=!1;return G.getAccess().then(t=>{e||(t.success&&t.data?r(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.webSearchAccess.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.webSearchAccess.description`)})]}),n===null&&o?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Q.jsx)(X,{"aria-labelledby":t,checked:n===`all-users`,onChange:async t=>{let n=t?`all-users`:`admins`;a(!0);try{if(!(await G.setAccess(n)).success)throw Error(`Web search access update failed.`);r(n),f.success(e(`userManager.webSearchAccess.saved`))}catch{f.error(e(`userManager.webSearchAccess.saveFailed`))}finally{a(!1)}},disabled:i||n===null})]})})},Ae=()=>{let{t:e}=s(),t=(0,Z.useId)(),n=Y(e=>e.refreshWorkAccess),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=!1;return J.access().then(t=>{e||(t.success&&t.data?i(t.data.mode):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{id:t,className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAccess.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAccess.description`)})]}),r===null&&c?(0,Q.jsx)(M,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),d(e=>e+1)},children:e(`common.retry`)}):(0,Q.jsx)(X,{"aria-labelledby":t,checked:r===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;o(!0);try{if(!(await J.setAccess(r)).success)throw Error(`Work access update failed.`);i(r),await n(),f.success(e(`userManager.workAccess.saved`))}catch{f.error(e(`userManager.workAccess.saveFailed`))}finally{o(!1)}},disabled:a||r===null})]})})},je={name:``,image:``,memoryLimit:``,cpuLimit:``,pidsLimit:``,workspaceSize:``,idleMinutes:``,networkDefault:`inherit`,guiEnabled:!1,takeoverEnabled:!0,approvalsRequired:!1},Me={...je,name:`Work Computer`,image:`libre-work-computer:latest`,memoryLimit:`4g`,networkDefault:`on`,guiEnabled:!0},Ne=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`}),Pe=e=>[e.pidsLimit,e.idleMinutes].some(e=>e.trim()!==``&&!Number.isFinite(Number(e))),Fe=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}),Ie=()=>{let{t:e}=s(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(je),[c,l]=(0,Z.useState)(!1),u=async()=>{try{let e=await J.listPolicies();e.success&&e.data&&n(e.data)}catch{}};(0,Z.useEffect)(()=>{let e=!1;return J.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}))}),p=async()=>{if(Pe(a)){f.error(e(`userManager.workPolicies.invalidNumber`));return}l(!0);try{let t=Fe(a),n=r===`new`?await J.createPolicy(t):await J.updatePolicy(r,t);if(!n.success)throw Error(n.error||`Policy save failed.`);f.success(e(`userManager.workPolicies.saved`)),i(null),o(je),await u()}catch(t){f.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}finally{l(!1)}},m=async t=>{if(window.confirm(e(`userManager.workPolicies.deleteConfirm`)))try{let n=await J.deletePolicy(t.id);if(!n.success)throw Error(n.error||`Policy delete failed.`);f.success(e(`userManager.workPolicies.deleted`)),await u()}catch(t){f.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}},h=(e,t,n)=>(0,Q.jsxs)(`label`,{className:`block text-xs`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:t}),(0,Q.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-hidden focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]});return(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workPolicies.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workPolicies.description`)})]}),r===null&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsxs)(M,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,"data-testid":`work-policy-computer-preset`,onClick:()=>{o(Me),i(`new`)},children:[(0,Q.jsx)(y,{size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.computerPreset`)})]}),(0,Q.jsxs)(M,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,onClick:()=>{o(je),i(`new`)},children:[(0,Q.jsx)(te,{size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.add`)})]})]})]}),t.length===0&&r===null&&(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.empty`)}),t.length>0&&(0,Q.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-100 dark:divide-dark-300`,children:t.map(t=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,Q.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,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(M,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.edit`),onClick:()=>{o(Ne(t)),i(t.id)},children:(0,Q.jsx)(O,{size:14})}),(0,Q.jsx)(M,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.delete`),onClick:()=>void m(t),children:(0,Q.jsx)(k,{size:14})})]})]},t.id))}),r!==null&&(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 p-3 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[h(`name`,e(`userManager.workPolicies.name`),`heavy`),h(`memoryLimit`,e(`userManager.workPolicies.memory`),`4g`),h(`cpuLimit`,e(`userManager.workPolicies.cpu`),`4`),h(`pidsLimit`,e(`userManager.workPolicies.pids`),`512`),h(`workspaceSize`,e(`userManager.workPolicies.workspaceSize`),`20Gi`),h(`idleMinutes`,e(`userManager.workPolicies.idleMinutes`),`30`),(0,Q.jsxs)(`label`,{className:`block text-xs`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.networkDefault`)}),(0,Q.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-hidden focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,children:[(0,Q.jsx)(`option`,{value:`inherit`,children:e(`userManager.workPolicies.networkInherit`)}),(0,Q.jsx)(`option`,{value:`on`,children:e(`userManager.workPolicies.networkOn`)}),(0,Q.jsx)(`option`,{value:`off`,children:e(`userManager.workPolicies.networkOff`)})]})]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.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-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Q.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.guiEnabled`)})]}),a.guiEnabled&&(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.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-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Q.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.takeoverEnabled`)})]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.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-sm border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Q.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.approvalsRequired`)})]}),h(`image`,e(`userManager.workPolicies.image`),`node:22-bookworm@sha256:…`)]}),a.guiEnabled&&(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.computerPresetHint`)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Q.jsx)(M,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>{i(null),o(je)},children:e(`userManager.workPolicies.cancel`)}),(0,Q.jsx)(M,{size:`sm`,disabled:c||!a.name.trim(),onClick:()=>void p(),children:e(`userManager.workPolicies.save`)})]})]})]})},$=[{id:`users`,label:`userManager.sections.users`},{id:`groups`,label:`userManager.groups.title`},{id:`access`,label:`userManager.sections.access`},{id:`security`,label:`userManager.sections.security`},{id:`defaults`,label:`userManager.sections.defaults`}],Le=e=>{switch(e){case`users`:return(0,Q.jsx)(ce,{});case`groups`:return(0,Q.jsx)(we,{});case`access`:return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(Ae,{}),(0,Q.jsx)(Ie,{}),(0,Q.jsx)(Oe,{}),(0,Q.jsx)(De,{}),(0,Q.jsx)(ke,{}),(0,Q.jsx)(le,{}),(0,Q.jsx)(de,{}),(0,Q.jsx)(me,{}),(0,Q.jsx)(ve,{}),(0,Q.jsx)(Se,{})]});case`security`:return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(Ce,{}),(0,Q.jsx)(Ee,{})]});case`defaults`:return(0,Q.jsx)(pe,{})}},Re=()=>{let{t:e}=s(),t=(0,Z.useId)(),n=(0,Z.useRef)({}),[r,i]=(0,Z.useState)(`users`),[a,o]=(0,Z.useState)([`users`]),l=e=>{i(e),o(t=>t.includes(e)?t:[...t,e])},u=(e,t)=>{let r=getComputedStyle(e.currentTarget).direction===`rtl`,i=$.findIndex(e=>e.id===t),a;switch(e.key){case`Home`:a=0;break;case`End`:a=$.length-1;break;case`ArrowRight`:a=i+(r?-1:1);break;case`ArrowLeft`:a=i+(r?1:-1);break;default:return}e.preventDefault();let o=$[(a+$.length)%$.length].id;l(o),n.current[o]?.focus()};return(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":e(`userManager.title`),"aria-orientation":`horizontal`,className:`-mx-1 flex gap-1 overflow-x-auto border-b border-line px-1 pb-3 pt-1 scrollbar-thin`,children:$.map(i=>(0,Q.jsx)(`button`,{ref:e=>{n.current[i.id]=e},type:`button`,role:`tab`,id:`${t}-tab-${i.id}`,"aria-controls":`${t}-panel-${i.id}`,"aria-selected":r===i.id,tabIndex:r===i.id?0:-1,onClick:()=>l(i.id),onKeyDown:e=>u(e,i.id),className:c(`min-h-11 shrink-0 rounded-xl border px-3 py-2 text-sm font-medium outline-hidden transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-surface motion-reduce:transition-none`,r===i.id?`border-line bg-nav-active text-ink`:`border-transparent text-ink-muted hover:bg-hover-solid hover:text-ink`),children:e(i.label)},i.id))}),$.map(e=>(0,Q.jsx)(`div`,{id:`${t}-panel-${e.id}`,role:`tabpanel`,"aria-labelledby":`${t}-tab-${e.id}`,hidden:r!==e.id,children:a.includes(e.id)&&Le(e.id)},e.id))]})};export{Re as UserManagementPanel,Re as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-CR5VJ85Q.js";import{t as n}from"./useTranslation-Boi0fB1B.js";import{D as r,n as i}from"./ui-vendor-6S05F84J.js";import{t as a}from"./Button-Dh2UJA-B.js";import"./ui-CI0OdG9q.js";import{s as o}from"./markdown-core-Cyql92Hg.js";e();var s=t(),c=({notes:e,onDismiss:t})=>{let{t:c}=n();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`fixed inset-0 z-60 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,s.jsx)(`div`,{className:`fixed inset-0 z-60 flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":c(`whatsNew.title`),onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,s.jsxs)(`div`,{className:`flex max-h-[82vh] w-full max-w-2xl flex-col rounded-3xl border border-gray-200/80 bg-surface/95 shadow-2xl backdrop-blur-xl animate-scale-in dark:border-white/10 dark:bg-dark-25/95`,children:[(0,s.jsxs)(`div`,{className:`flex items-start justify-between px-6 pb-3 pt-6`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h2`,{className:`text-xl font-semibold tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:c(`whatsNew.title`)}),(0,s.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[c(`whatsNew.releaseNotes`),` · v`,e.version,` · `,e.date]})]}),(0,s.jsx)(`button`,{onClick:t,className:`rounded-full p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-white/6 dark:hover:text-dark-900`,title:c(`common.close`),children:(0,s.jsx)(i,{className:`h-4 w-4`})})]}),(0,s.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-6 py-3 scrollbar-thin`,children:(0,s.jsx)(o,{components:{h3:({children:e})=>(0,s.jsx)(`h3`,{className:`mb-2 mt-5 text-[11px] font-semibold uppercase tracking-widest text-primary-600 first:mt-0 dark:text-primary-400`,children:e}),ul:({children:e})=>(0,s.jsx)(`ul`,{className:`space-y-2.5`,children:e}),li:({children:e})=>(0,s.jsxs)(`li`,{className:`flex gap-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:[(0,s.jsx)(`span`,{className:`mt-[7px] h-1 w-1 shrink-0 rounded-full bg-gray-300 dark:bg-dark-400`}),(0,s.jsx)(`span`,{className:`min-w-0`,children:e})]}),strong:({children:e})=>(0,s.jsx)(`strong`,{className:`font-semibold text-gray-900 dark:text-dark-900`,children:e}),a:({children:e,href:t})=>(0,s.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`text-primary-600 underline decoration-primary-300 underline-offset-2 hover:text-primary-700 dark:text-primary-400`,children:e}),code:({children:e})=>(0,s.jsx)(`code`,{className:`rounded-md border border-gray-200 bg-gray-100 px-1 py-0.5 font-mono text-[0.85em] text-gray-800 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:e}),p:({children:e})=>(0,s.jsx)(`p`,{className:`mb-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:e})},children:e.body})}),(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-gray-200/70 px-6 py-4 dark:border-white/8`,children:[(0,s.jsxs)(`a`,{href:`https://github.com/libre-webui/libre-webui`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-w-0 items-center gap-1.5 text-xs text-gray-500 transition-colors hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`,children:[(0,s.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),(0,s.jsx)(`span`,{className:`truncate`,children:c(`whatsNew.starAsk`)})]}),(0,s.jsx)(a,{onClick:t,size:`sm`,children:c(`whatsNew.cta`)})]})]})})]})};export{c as WhatsNewModal};
|