libre-webui 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -15
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +9 -0
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.js +2 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
- package/backend/dist/persistence/postgresPersonalAutomationsMigration.d.ts +8 -0
- package/backend/dist/persistence/postgresPersonalAutomationsMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresPersonalAutomationsMigration.js +98 -0
- package/backend/dist/persistence/postgresPersonalAutomationsMigration.js.map +1 -0
- package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.js +274 -0
- package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/resourceTypes.d.ts +83 -2
- package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
- package/backend/dist/persistence/resourceTypes.js.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.d.ts +1 -0
- package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.js +181 -0
- package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.js +233 -0
- package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js +41 -0
- package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
- package/backend/dist/platform/jobs/domainJobContracts.d.ts +3 -0
- package/backend/dist/platform/jobs/domainJobContracts.d.ts.map +1 -1
- package/backend/dist/platform/jobs/domainJobContracts.js +3 -0
- package/backend/dist/platform/jobs/domainJobContracts.js.map +1 -1
- package/backend/dist/platform/jobs/domainJobHandlers.d.ts.map +1 -1
- package/backend/dist/platform/jobs/domainJobHandlers.js +101 -1
- package/backend/dist/platform/jobs/domainJobHandlers.js.map +1 -1
- package/backend/dist/routes/automations.d.ts +3 -0
- package/backend/dist/routes/automations.d.ts.map +1 -0
- package/backend/dist/routes/automations.js +232 -0
- package/backend/dist/routes/automations.js.map +1 -0
- package/backend/dist/routes/calendar.d.ts +3 -0
- package/backend/dist/routes/calendar.d.ts.map +1 -0
- package/backend/dist/routes/calendar.js +206 -0
- package/backend/dist/routes/calendar.js.map +1 -0
- package/backend/dist/routes/chat.d.ts.map +1 -1
- package/backend/dist/routes/chat.js +99 -7
- package/backend/dist/routes/chat.js.map +1 -1
- package/backend/dist/routes/ollama.d.ts.map +1 -1
- package/backend/dist/routes/ollama.js +4 -1
- package/backend/dist/routes/ollama.js.map +1 -1
- package/backend/dist/routes/search.d.ts.map +1 -1
- package/backend/dist/routes/search.js +5 -3
- package/backend/dist/routes/search.js.map +1 -1
- package/backend/dist/services/automationSchedulerService.d.ts +28 -0
- package/backend/dist/services/automationSchedulerService.d.ts.map +1 -0
- package/backend/dist/services/automationSchedulerService.js +191 -0
- package/backend/dist/services/automationSchedulerService.js.map +1 -0
- package/backend/dist/services/automationService.d.ts +53 -0
- package/backend/dist/services/automationService.d.ts.map +1 -0
- package/backend/dist/services/automationService.js +224 -0
- package/backend/dist/services/automationService.js.map +1 -0
- package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
- package/backend/dist/services/chatGenerationService.js +7 -1
- package/backend/dist/services/chatGenerationService.js.map +1 -1
- package/backend/dist/services/chatService.d.ts +9 -1
- package/backend/dist/services/chatService.d.ts.map +1 -1
- package/backend/dist/services/chatService.js +91 -13
- package/backend/dist/services/chatService.js.map +1 -1
- package/backend/dist/services/contextCompactionService.d.ts +11 -6
- package/backend/dist/services/contextCompactionService.d.ts.map +1 -1
- package/backend/dist/services/contextCompactionService.js +127 -27
- package/backend/dist/services/contextCompactionService.js.map +1 -1
- package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
- package/backend/dist/services/durableChatGenerationService.js +15 -3
- package/backend/dist/services/durableChatGenerationService.js.map +1 -1
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +9 -2
- package/backend/dist/services/ollamaService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts +10 -0
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +42 -7
- package/backend/dist/services/pluginService.js.map +1 -1
- package/backend/dist/services/preferencesService.d.ts.map +1 -1
- package/backend/dist/services/preferencesService.js +3 -0
- package/backend/dist/services/preferencesService.js.map +1 -1
- package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
- package/backend/dist/services/titleGenerationService.js +5 -1
- package/backend/dist/services/titleGenerationService.js.map +1 -1
- package/backend/dist/services/webSearchPlanService.d.ts +18 -0
- package/backend/dist/services/webSearchPlanService.d.ts.map +1 -0
- package/backend/dist/services/webSearchPlanService.js +160 -0
- package/backend/dist/services/webSearchPlanService.js.map +1 -0
- package/backend/dist/services/webSearchService.d.ts +9 -3
- package/backend/dist/services/webSearchService.d.ts.map +1 -1
- package/backend/dist/services/webSearchService.js +8 -2
- package/backend/dist/services/webSearchService.js.map +1 -1
- package/backend/dist/storage.d.ts +7 -1
- package/backend/dist/storage.d.ts.map +1 -1
- package/backend/dist/storage.js +65 -1
- package/backend/dist/storage.js.map +1 -1
- package/backend/dist/types/index.d.ts +79 -0
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/utils/automationSchedule.d.ts +26 -0
- package/backend/dist/utils/automationSchedule.d.ts.map +1 -0
- package/backend/dist/utils/automationSchedule.js +231 -0
- package/backend/dist/utils/automationSchedule.js.map +1 -0
- package/backend/dist/utils/chatContext.d.ts +7 -0
- package/backend/dist/utils/chatContext.d.ts.map +1 -1
- package/backend/dist/utils/chatContext.js +13 -2
- package/backend/dist/utils/chatContext.js.map +1 -1
- package/backend/dist/utils/openAIResponsesAdapter.d.ts.map +1 -1
- package/backend/dist/utils/openAIResponsesAdapter.js +3 -1
- package/backend/dist/utils/openAIResponsesAdapter.js.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.d.ts +1 -0
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.js +82 -19
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
- package/backend/dist/utils/pluginModelCatalog.d.ts +20 -0
- package/backend/dist/utils/pluginModelCatalog.d.ts.map +1 -1
- package/backend/dist/utils/pluginModelCatalog.js +101 -9
- package/backend/dist/utils/pluginModelCatalog.js.map +1 -1
- package/backend/dist/utils/resourceLimits.d.ts +7 -0
- package/backend/dist/utils/resourceLimits.d.ts.map +1 -1
- package/backend/dist/utils/resourceLimits.js +7 -0
- package/backend/dist/utils/resourceLimits.js.map +1 -1
- package/backend/dist/utils/thinkingOptions.d.ts +23 -3
- package/backend/dist/utils/thinkingOptions.d.ts.map +1 -1
- package/backend/dist/utils/thinkingOptions.js +35 -9
- package/backend/dist/utils/thinkingOptions.js.map +1 -1
- package/backend/dist/websocketServer.d.ts.map +1 -1
- package/backend/dist/websocketServer.js +9 -3
- package/backend/dist/websocketServer.js.map +1 -1
- package/backend/package.json +1 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/assets/index-6o-Hc2wS.js +41 -0
- package/frontend/dist/assets/index-D-pM957b.css +1 -0
- package/frontend/dist/index.html +12 -12
- package/frontend/dist/js/ArtifactContainer-CpUi6ekF.js +1 -0
- package/frontend/dist/js/{ArtifactDemoPage-TONeQvof.js → ArtifactDemoPage-BeNs3gHp.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-CV2XXu_t.js → ArtifactSandboxFrame-qsj_Y3LV.js} +2 -2
- package/frontend/dist/js/ArtifactSlideOutPanel-CSFRluWA.js +1 -0
- package/frontend/dist/js/AutomationsPage-KUeWoZNv.js +1 -0
- package/frontend/dist/js/CalendarPage-D9I972w8.js +1 -0
- package/frontend/dist/js/ChatPage-CmBx4oAL.js +16 -0
- package/frontend/dist/js/{FirstTimeSetup-smhj0X6o.js → FirstTimeSetup-Df0YJni3.js} +1 -1
- package/frontend/dist/js/GalleryPage-bLCrdJN_.js +1 -0
- package/frontend/dist/js/HomePage-Uc6PEg-U.js +1 -0
- package/frontend/dist/js/{LibreClawPage-CRKei1MM.js → LibreClawPage-CG63DHg1.js} +1 -1
- package/frontend/dist/js/{ModelManagerModals-D0amaOnl.js → ModelManagerModals-DcLGYN3l.js} +1 -1
- package/frontend/dist/js/ModelSelector-yxJC64rM.js +1 -0
- package/frontend/dist/js/ModelsPage-1R_TxgmJ.js +2 -0
- package/frontend/dist/js/NotesPage-L65j5HoW.js +1 -0
- package/frontend/dist/js/PersonasPage-CKeBpHIH.js +13 -0
- package/frontend/dist/js/PluginUsagePage-BX1SKMbW.js +1 -0
- package/frontend/dist/js/{RichMessageContent-Bxi_u0gC.js → RichMessageContent-DiySVYGB.js} +1 -1
- package/frontend/dist/js/SettingsModal-68SG1uZ2.js +1 -0
- package/frontend/dist/js/SystemPage-CytpZiQV.js +1 -0
- package/frontend/dist/js/UserManagementPage-BzJBvZiS.js +1 -0
- package/frontend/dist/js/WorkPage-C8gr0QJe.js +6 -0
- package/frontend/dist/js/api-BDtqBtqw.js +14 -0
- package/frontend/dist/js/{appStore-CJtomipz.js → appStore-0JnCUlEq.js} +2 -2
- package/frontend/dist/js/ar-CSpi37Gr.js +2 -0
- package/frontend/dist/js/{authStore-BckFDL70.js → authStore-DbMdvNgJ.js} +3 -3
- package/frontend/dist/js/{babel-D24oDI9y.js → babel-BsYoxD-7.js} +1 -1
- package/frontend/dist/js/bn-CyH1BeDD.js +2 -0
- package/frontend/dist/js/calendarDates-Co3o_05Y.js +1 -0
- package/frontend/dist/js/chatStore-CHQ2uINS.js +3 -0
- package/frontend/dist/js/{config-CNVNpf_q.js → config-DSOYQ9a3.js} +1 -1
- package/frontend/dist/js/cs-Cv2NfRK5.js +2 -0
- package/frontend/dist/js/da-D6D6IvPK.js +2 -0
- package/frontend/dist/js/de-BNoJJTrT.js +2 -0
- package/frontend/dist/js/es-kzo9C7q_.js +2 -0
- package/frontend/dist/js/{estree-D1TYSBcf.js → estree-BcnBcOAx.js} +7 -7
- package/frontend/dist/js/fr-CjHYvJRp.js +2 -0
- package/frontend/dist/js/hi-BU98AdCQ.js +2 -0
- package/frontend/dist/js/{html-Dmddj0zf.js → html-DkY55Jys.js} +10 -10
- package/frontend/dist/js/id-CpdedejX.js +2 -0
- package/frontend/dist/js/is-Cp5dDWBH.js +2 -0
- package/frontend/dist/js/it-CuH_cK4U.js +2 -0
- package/frontend/dist/js/ja-BWXXXiHn.js +2 -0
- package/frontend/dist/js/ko-DQgv2M1t.js +2 -0
- package/frontend/dist/js/{markdown-Bl_LsHEk.js → markdown-IZSI9DXw.js} +6 -6
- package/frontend/dist/js/{messageCodeStyles-CgKxn4tN.js → messageCodeStyles-BFNR9Wv6.js} +2 -2
- package/frontend/dist/js/ms-DCcRoIcX.js +2 -0
- package/frontend/dist/js/nl-CbKR1_EU.js +2 -0
- package/frontend/dist/js/pl-CRyJZccn.js +2 -0
- package/frontend/dist/js/{postcss-Bx9CTcIc.js → postcss-BJ0okz7n.js} +1 -1
- package/frontend/dist/js/pt-BXYmHFGH.js +2 -0
- package/frontend/dist/js/{router-vendor-CbPDks39.js → router-vendor-DGFGM3EP.js} +1 -1
- package/frontend/dist/js/ru-M9SyZG4b.js +2 -0
- package/frontend/dist/js/{standalone-BWau8hEE.js → standalone-Csw3jfJ_.js} +5 -5
- package/frontend/dist/js/sv-DJ486LTU.js +2 -0
- package/frontend/dist/js/th-Ch7gKtZv.js +2 -0
- package/frontend/dist/js/tr-ClehWhSC.js +2 -0
- package/frontend/dist/js/{typescript-DxGn3Yn-.js → typescript-CnF4UVx7.js} +2 -2
- package/frontend/dist/js/{ui-jlx9WA5A.js → ui-CC-K19wO.js} +2 -2
- package/frontend/dist/js/ui-vendor-B1UgO3vd.js +177 -0
- package/frontend/dist/js/uk-BqAd5zHF.js +2 -0
- package/frontend/dist/js/{vi-BgRaIrQC.js → vi-D9gjlDVB.js} +2 -2
- package/frontend/dist/js/{workApi-DWRpZ_cq.js → workApi-C3uy9EDT.js} +3 -3
- package/frontend/dist/js/{yaml-DioTxVLA.js → yaml-DzT5hBSH.js} +5 -5
- package/frontend/dist/js/zh-DKTyHkiR.js +2 -0
- package/package.json +2 -2
- package/frontend/dist/assets/index-BlTbxYPP.js +0 -33
- package/frontend/dist/assets/index-CbiWSGOj.css +0 -1
- package/frontend/dist/js/ArtifactContainer-C-n1vPsA.js +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-2exw7YqL.js +0 -1
- package/frontend/dist/js/ChatPage-wnyG_TyC.js +0 -23
- package/frontend/dist/js/GalleryPage-BZfeWlBg.js +0 -1
- package/frontend/dist/js/HomePage-gf4GgI6z.js +0 -1
- package/frontend/dist/js/ModelSelector-C5Tn6y0p.js +0 -1
- package/frontend/dist/js/ModelsPage-Rbags4Xq.js +0 -2
- package/frontend/dist/js/NotesPage-9NR9HZZ8.js +0 -1
- package/frontend/dist/js/PersonasPage-DYP67Qiy.js +0 -13
- package/frontend/dist/js/PluginUsagePage-QtCgymRu.js +0 -1
- package/frontend/dist/js/SettingsModal-B4RelkLP.js +0 -1
- package/frontend/dist/js/SystemPage-xFSTYdBS.js +0 -1
- package/frontend/dist/js/UserManagementPage-Cp430WCP.js +0 -1
- package/frontend/dist/js/WorkPage-DFES41Qm.js +0 -6
- package/frontend/dist/js/api-DUUxxx_B.js +0 -14
- package/frontend/dist/js/ar-DMH3qbt6.js +0 -2
- package/frontend/dist/js/bn-CGDX8khx.js +0 -2
- package/frontend/dist/js/chatStore-DK-_wd-j.js +0 -3
- package/frontend/dist/js/cs-CJLgUk3m.js +0 -2
- package/frontend/dist/js/da-DnZMnCVM.js +0 -2
- package/frontend/dist/js/de-CWpguVQ5.js +0 -2
- package/frontend/dist/js/es-DVU1vjm0.js +0 -2
- package/frontend/dist/js/fr-pWnSnypD.js +0 -2
- package/frontend/dist/js/hi-B6xDfxA5.js +0 -2
- package/frontend/dist/js/id-BThSTUAG.js +0 -2
- package/frontend/dist/js/is-BOohDFie.js +0 -2
- package/frontend/dist/js/it-BdRArcCC.js +0 -2
- package/frontend/dist/js/ja-5Cq35sMr.js +0 -2
- package/frontend/dist/js/ko-BlzNRtpQ.js +0 -2
- package/frontend/dist/js/ms-CtGeurkZ.js +0 -2
- package/frontend/dist/js/nl-MKPHGjVF.js +0 -2
- package/frontend/dist/js/pl-BwBrqCey.js +0 -2
- package/frontend/dist/js/pt-CKzoHWBB.js +0 -2
- package/frontend/dist/js/ru-BQC4jh0Y.js +0 -2
- package/frontend/dist/js/sv-Cm0qXxzM.js +0 -2
- package/frontend/dist/js/th-DUPbiRI2.js +0 -2
- package/frontend/dist/js/tr-AsFu_Br5.js +0 -2
- package/frontend/dist/js/ui-vendor-54SgntkX.js +0 -177
- package/frontend/dist/js/uk-DrMMOZ17.js +0 -2
- package/frontend/dist/js/zh-B4rcgcAy.js +0 -2
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/SettingsModal-B4RelkLP.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-BmPPZiuD.js","js/useTranslation-Bho4HCyg.js","js/utils-D9W1Lnkn.js","js/utils-vendor-DWh39_3x.js","js/chatStore-DK-_wd-j.js","js/router-vendor-CbPDks39.js","js/i18next-DgmgtwsV.js","js/ui-vendor-54SgntkX.js","js/logger-DSXjF4ye.js","js/api-DUUxxx_B.js","js/config-CNVNpf_q.js","js/workApi-DWRpZ_cq.js","js/imageGenModels-Dx_QMLJQ.js","js/authStore-BckFDL70.js","js/appStore-CJtomipz.js","js/messageCodeStyles-CgKxn4tN.js","js/Button-BPf_pOxH.js","js/ui-jlx9WA5A.js","js/SettingsToggle-woG_WebF.js","js/thinking-DwlkTfPX.js","js/HomePage-gf4GgI6z.js","js/work-DVgm81bJ.js","js/ChatPage-wnyG_TyC.js","js/react-vendor-C5yShNlM.js","js/welcomePrompts-to5mv_gx.js","js/ArtifactSandboxFrame-CV2XXu_t.js","js/ArtifactContainer-C-n1vPsA.js","js/OptimizedSyntaxHighlighter-Dz7D1LPB.js","js/syntax-highlight-3EEX6CGL.js","js/ModelSelector-C5Tn6y0p.js","js/ModelsPage-Rbags4Xq.js","js/PersonasPage-DYP67Qiy.js","js/GalleryPage-BZfeWlBg.js","js/NotesPage-9NR9HZZ8.js","js/RichMessageContent-Bxi_u0gC.js","js/markdown-math-DK846gXU.js","assets/markdown-math-Ddr6Z9Sf.css","js/LibreClawPage-CRKei1MM.js","js/WorkPage-DFES41Qm.js","js/UserManagementPage-Cp430WCP.js","js/PluginUsagePage-QtCgymRu.js","js/SystemPage-xFSTYdBS.js","js/ArtifactDemoPage-TONeQvof.js","js/ArtifactSlideOutPanel-2exw7YqL.js","js/FirstTimeSetup-smhj0X6o.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"../js/rolldown-runtime-hePW80VL.js";import{m as t,o as n,p as r}from"../js/markdown-core-BmPPZiuD.js";import{n as i,t as a}from"../js/react-vendor-C5yShNlM.js";import{_ as o,a as s,c,d as l,g as u,h as d,i as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,v as x}from"../js/router-vendor-CbPDks39.js";import{t as S}from"../js/useTranslation-Bho4HCyg.js";import{a as C,r as ee,s as w,t as T}from"../js/utils-D9W1Lnkn.js";import{_ as E,a as D,h as O,s as k,t as A,v as j}from"../js/chatStore-DK-_wd-j.js";import{$ as M,A as N,An as P,At as te,C as ne,E as re,En as F,Gt as ie,Jt as ae,K as oe,Kt as se,M as I,Nt as L,P as ce,Pt as le,Q as ue,U as de,Ut as fe,V as pe,W as me,Wt as he,X as ge,Y as _e,_t as ve,b as ye,bn as be,c as R,cn as xe,dn as Se,f as z,fn as B,ft as Ce,h as we,hn as Te,j as Ee,jn as V,k as De,kn as Oe,kt as ke,l as Ae,lt as je,n as Me,nn as Ne,ot as Pe,p as Fe,pn as Ie,pt as Le,s as Re,tt as ze,un as Be,ut as Ve,vn as He,vt as Ue,wt as We,xt as Ge,z as Ke}from"../js/ui-vendor-54SgntkX.js";import{a as qe,o as Je,t as Ye}from"../js/utils-vendor-DWh39_3x.js";import{i as Xe,t as Ze}from"../js/logger-DSXjF4ye.js";import{t as Qe}from"../js/config-CNVNpf_q.js";import{D as $e,O as et,h as tt,m as nt}from"../js/api-DUUxxx_B.js";import{l as rt,n as H,o as it,r as at,u as ot}from"../js/authStore-BckFDL70.js";import{t as st}from"../js/appStore-CJtomipz.js";import{n as ct}from"../js/welcomePrompts-to5mv_gx.js";import{l as lt}from"../js/messageCodeStyles-CgKxn4tN.js";import{t as ut}from"../js/Button-BPf_pOxH.js";import{p as dt}from"../js/ui-jlx9WA5A.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ft=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},pt,mt,ht,gt=new(pt=new WeakMap,mt=new WeakMap,ht=new WeakMap,class extends ft{constructor(){super(),o(this,pt,void 0),o(this,mt,void 0),o(this,ht,void 0),d(ht,this,e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}})}onSubscribe(){p(mt,this)||this.setEventListener(p(ht,this))}onUnsubscribe(){this.hasListeners()||(p(mt,this)?.call(this),d(mt,this,void 0))}setEventListener(e){d(ht,this,e),p(mt,this)?.call(this),d(mt,this,e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()}))}setFocused(e){p(pt,this)!==e&&(d(pt,this,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof p(pt,this)==`boolean`?p(pt,this):globalThis.document?.visibilityState!==`hidden`}}),_t,vt,yt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},bt=new(_t=new WeakMap,vt=new WeakMap,class{constructor(){o(this,_t,yt),o(this,vt,!1)}setTimeoutProvider(e){d(_t,this,e)}setTimeout(e,t){return p(_t,this).setTimeout(e,t)}clearTimeout(e){p(_t,this).clearTimeout(e)}setInterval(e,t){return p(_t,this).setInterval(e,t)}clearInterval(e){p(_t,this).clearInterval(e)}});function xt(e){setTimeout(e,0)}var St=typeof window>`u`||`Deno`in globalThis;function U(){}function Ct(e,t){return typeof e==`function`?e(t):e}function wt(e){return typeof e==`number`&&e>=0&&e!==1/0}function Tt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Et(e,t){return typeof e==`function`?e(t):e}function W(e,t){return typeof e==`function`?e(t):e}function Dt(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==kt(o,t.options))return!1}else if(!jt(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Ot(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(At(t.options.mutationKey)!==At(a))return!1}else if(!jt(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function kt(e,t){return(t?.queryKeyHashFn||At)(e)}function At(e){return JSON.stringify(e,(e,t)=>It(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function jt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!jt(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!jt(e[r],t[r]))return!1;return!0}return!1}var Mt=Object.prototype.hasOwnProperty;function Nt(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Ft(e)&&Ft(t);if(!r&&!(It(e)&&It(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Mt.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Nt(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Pt(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Ft(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function It(e){if(!Lt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Lt(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Lt(e){return Object.prototype.toString.call(e)===`[object Object]`}function Rt(e){return new Promise(t=>{bt.setTimeout(t,e)})}function zt(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Nt(e,t)}function Bt(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Vt(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Ht=Symbol();function Ut(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ht?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Wt(e,t){return typeof e==`function`?e(...t):!!e}function Gt(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Kt=(()=>{let e=()=>St;return{isServer(){return e()},setIsServer(t){e=t}}})();function qt(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Jt=xt;function Yt(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Jt,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var G=Yt(),Xt,Zt,Qt,$t=new(Xt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,class extends ft{constructor(){super(),o(this,Xt,!0),o(this,Zt,void 0),o(this,Qt,void 0),d(Qt,this,e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}})}onSubscribe(){p(Zt,this)||this.setEventListener(p(Qt,this))}onUnsubscribe(){this.hasListeners()||(p(Zt,this)?.call(this),d(Zt,this,void 0))}setEventListener(e){d(Qt,this,e),p(Zt,this)?.call(this),d(Zt,this,e(this.setOnline.bind(this)))}setOnline(e){p(Xt,this)!==e&&(d(Xt,this,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return p(Xt,this)}});function en(e){return Math.min(1e3*2**e,3e4)}function tn(e){return(e??`online`)!==`online`||$t.isOnline()}var nn=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function rn(e){let t=!1,n=0,r,i=qt(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new nn(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>gt.isFocused()&&(e.networkMode===`always`||$t.isOnline())&&e.canRun(),u=()=>tn(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Kt.isServer()?0:3),o=e.retryDelay??en,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),Rt(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var an,on=(an=new WeakMap,class{constructor(){o(this,an,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),wt(this.gcTime)&&d(an,this,bt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Kt.isServer()?1/0:3e5))}clearGcTimeout(){p(an,this)!==void 0&&(bt.clearTimeout(p(an,this)),d(an,this,void 0))}});function sn(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Gt(e,()=>t.signal,()=>n=!0)},u=Ut(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Vt:Bt;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?ln:cn,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:cn(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function cn(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ln(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function un(e,t){return t?cn(e,t)!=null:!1}function dn(e,t){return!t||!e.getPreviousPageParam?!1:ln(e,t)!=null}function fn(e,t){x(e,t),t.add(e)}var pn,mn,hn,gn,_n,K,vn,yn,bn,xn=(pn=new WeakMap,mn=new WeakMap,hn=new WeakMap,gn=new WeakMap,_n=new WeakMap,K=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakSet,class extends on{constructor(e){super(),fn(this,bn),o(this,pn,void 0),o(this,mn,void 0),o(this,hn,void 0),o(this,gn,void 0),o(this,_n,void 0),o(this,K,void 0),o(this,vn,void 0),o(this,yn,void 0),d(yn,this,!1),d(vn,this,e.defaultOptions),this.setOptions(e.options),this.observers=[],d(_n,this,e.client),d(gn,this,p(_n,this).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,d(mn,this,En(this.options)),this.state=e.state??p(mn,this),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return p(pn,this)}get promise(){return p(K,this)?.promise}setOptions(e){if(this.options={...p(vn,this),...e},e?._type&&d(pn,this,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=En(this.options);e.data!==void 0&&(this.setState(Tn(e.data,e.dataUpdatedAt)),d(mn,this,e))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&p(gn,this).remove(this)}setData(e,t){let n=zt(this.state.data,e,this.options);return u(bn,this,Cn).call(this,{data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){u(bn,this,Cn).call(this,{type:`setState`,state:e})}cancel(e){let t=p(K,this)?.promise;return p(K,this)?.cancel(e),t?t.then(U).catch(U):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return p(mn,this)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>W(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ht||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Et(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Tt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),p(K,this)?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),p(K,this)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),p(gn,this).notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(p(K,this)&&(p(yn,this)||u(bn,this,Sn).call(this)?p(K,this).cancel({revert:!0}):p(K,this).cancelRetry()),this.scheduleGc()),p(gn,this).notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||u(bn,this,Cn).call(this,{type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&p(K,this)?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(p(K,this))return p(K,this).continueRetry(),p(K,this).promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(d(yn,this,!0),n.signal)})},i=()=>{let e=Ut(this.options,t),n=(()=>{let e={client:p(_n,this),queryKey:this.queryKey,meta:this.meta};return r(e),e})();return d(yn,this,!1),this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:p(_n,this),state:this.state,fetchFn:i};return r(e),e})();(p(pn,this)===`infinite`?sn(this.options.pages):this.options.behavior)?.onFetch(a,this),d(hn,this,this.state),(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&u(bn,this,Cn).call(this,{type:`fetch`,meta:a.fetchOptions?.meta}),d(K,this,rn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof nn&&e.revert&&this.setState({...p(hn,this),fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{u(bn,this,Cn).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{u(bn,this,Cn).call(this,{type:`pause`})},onContinue:()=>{u(bn,this,Cn).call(this,{type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{let e=await p(K,this).start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),p(gn,this).config.onSuccess?.(e,this),p(gn,this).config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof nn){if(e.silent)return p(K,this).promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw u(bn,this,Cn).call(this,{type:`error`,error:e}),p(gn,this).config.onError?.(e,this),p(gn,this).config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}});function Sn(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}function Cn(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...wn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Tn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return d(hn,this,e.manual?n:void 0),n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),G.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),p(gn,this).notify({query:this,type:`updated`,action:e})})}function wn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:tn(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Tn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function En(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Dn,q,On,J,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Y,Bn=(Dn=new WeakMap,q=new WeakMap,On=new WeakMap,J=new WeakMap,kn=new WeakMap,An=new WeakMap,jn=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,Pn=new WeakMap,Fn=new WeakMap,In=new WeakMap,Ln=new WeakMap,Rn=new WeakMap,zn=new WeakMap,Y=new WeakSet,class extends ft{constructor(e,t){super(),fn(this,Y),o(this,Dn,void 0),o(this,q,void 0),o(this,On,void 0),o(this,J,void 0),o(this,kn,void 0),o(this,An,void 0),o(this,jn,void 0),o(this,Mn,void 0),o(this,Nn,void 0),o(this,Pn,void 0),o(this,Fn,void 0),o(this,In,void 0),o(this,Ln,void 0),o(this,Rn,void 0),o(this,zn,new Set),this.options=t,d(Dn,this,e),d(Mn,this,null),d(jn,this,qt()),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(p(q,this).addObserver(this),Zn(p(q,this),this.options)?u(Y,this,Vn).call(this):this.updateResult(),u(Y,this,Gn).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qn(p(q,this),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qn(p(q,this),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,u(Y,this,Kn).call(this),u(Y,this,qn).call(this),p(q,this).removeObserver(this)}setOptions(e){let t=this.options,n=p(q,this);if(this.options=p(Dn,this).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof W(this.options.enabled,p(q,this))!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);u(Y,this,Jn).call(this),p(q,this).setOptions(this.options),t._defaulted&&!Pt(this.options,t)&&p(Dn,this).getQueryCache().notify({type:`observerOptionsUpdated`,query:p(q,this),observer:this});let r=this.hasListeners();r&&$n(p(q,this),n,this.options,t)&&u(Y,this,Vn).call(this),this.updateResult(),r&&(p(q,this)!==n||W(this.options.enabled,p(q,this))!==W(t.enabled,p(q,this))||Et(this.options.staleTime,p(q,this))!==Et(t.staleTime,p(q,this)))&&u(Y,this,Hn).call(this);let i=u(Y,this,Un).call(this);r&&(p(q,this)!==n||W(this.options.enabled,p(q,this))!==W(t.enabled,p(q,this))||i!==p(Rn,this))&&u(Y,this,Wn).call(this,i)}getOptimisticResult(e){let t=p(Dn,this).getQueryCache().build(p(Dn,this),e),n=this.createResult(t,e);return tr(this,n)&&(d(J,this,n),d(An,this,this.options),d(kn,this,p(q,this).state)),n}getCurrentResult(){return p(J,this)}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&p(jn,this).status===`pending`&&p(jn,this).reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){p(zn,this).add(e)}getCurrentQuery(){return p(q,this)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=p(Dn,this).defaultQueryOptions(e),n=p(Dn,this).getQueryCache().build(p(Dn,this),t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return u(Y,this,Vn).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),p(J,this)))}createResult(e,t){let n=p(q,this),r=this.options,i=p(J,this),a=p(kn,this),o=p(An,this),s=e===n?p(On,this):e.state,{state:c}=e,l={...c},u=!1,f;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Zn(e,t),o=i&&$n(e,n,t,r);(a||o)&&(l={...l,...wn(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:m,errorUpdatedAt:h,status:g}=l;f=l.data;let _=!1;if(t.placeholderData!==void 0&&f===void 0&&g===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,_=!0):e=typeof t.placeholderData==`function`?t.placeholderData(p(Fn,this)?.state.data,p(Fn,this)):t.placeholderData,e!==void 0&&(g=`success`,f=zt(i?.data,e,t),u=!0)}if(t.select&&f!==void 0&&!_)if(i&&f===a?.data&&t.select===p(Nn,this))f=p(Pn,this);else try{d(Nn,this,t.select),f=t.select(f),f=zt(i?.data,f,t),d(Pn,this,f),d(Mn,this,null)}catch(e){d(Mn,this,e)}p(Mn,this)&&(m=p(Mn,this),f=p(Pn,this),h=Date.now(),g=`error`);let v=l.fetchStatus===`fetching`,y=g===`pending`,b=g===`error`,x=y&&v,S=f!==void 0,C={status:g,fetchStatus:l.fetchStatus,isPending:y,isSuccess:g===`success`,isError:b,isInitialLoading:x,isLoading:x,data:f,dataUpdatedAt:l.dataUpdatedAt,error:m,errorUpdatedAt:h,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:v,isRefetching:v&&!y,isLoadingError:b&&!S,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:b&&S,isStale:er(e,t),refetch:this.refetch,promise:p(jn,this),isEnabled:W(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=C.data!==void 0,r=C.status===`error`&&!t,i=e=>{r?e.reject(C.error):t&&e.resolve(C.data)},a=()=>{let e=d(jn,this,C.promise=qt());i(e)},o=p(jn,this);switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||C.data!==o.value)&&a();break;case`rejected`:(!r||C.error!==o.reason)&&a()}}return C}updateResult(){let e=p(J,this),t=this.createResult(p(q,this),this.options);d(kn,this,p(q,this).state),d(An,this,this.options),p(kn,this).data!==void 0&&d(Fn,this,p(q,this)),!Pt(t,e)&&(d(J,this,t),u(Y,this,Yn).call(this,{listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!p(zn,this).size)return!0;let r=new Set(n??p(zn,this));return this.options.throwOnError&&r.add(`error`),Object.keys(p(J,this)).some(t=>{let n=t;return p(J,this)[n]!==e[n]&&r.has(n)})})()}))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&u(Y,this,Gn).call(this)}});function Vn(e){u(Y,this,Jn).call(this);let t=p(q,this).fetch(this.options,e);return e?.throwOnError||(t=t.catch(U)),t}function Hn(){u(Y,this,Kn).call(this);let e=Et(this.options.staleTime,p(q,this));if(Kt.isServer()||p(J,this).isStale||!wt(e))return;let t=Tt(p(J,this).dataUpdatedAt,e)+1;d(In,this,bt.setTimeout(()=>{p(J,this).isStale||this.updateResult()},t))}function Un(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(p(q,this)):this.options.refetchInterval)??!1}function Wn(e){u(Y,this,qn).call(this),d(Rn,this,e),!(Kt.isServer()||W(this.options.enabled,p(q,this))===!1||!wt(p(Rn,this))||p(Rn,this)===0)&&d(Ln,this,bt.setInterval(()=>{(this.options.refetchIntervalInBackground||gt.isFocused())&&u(Y,this,Vn).call(this)},p(Rn,this)))}function Gn(){u(Y,this,Hn).call(this),u(Y,this,Wn).call(this,u(Y,this,Un).call(this))}function Kn(){p(In,this)!==void 0&&(bt.clearTimeout(p(In,this)),d(In,this,void 0))}function qn(){p(Ln,this)!==void 0&&(bt.clearInterval(p(Ln,this)),d(Ln,this,void 0))}function Jn(){let e=p(Dn,this).getQueryCache().build(p(Dn,this),this.options);if(e===p(q,this))return;let t=p(q,this);d(q,this,e),d(On,this,e.state),this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}function Yn(e){G.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(p(J,this))}),p(Dn,this).getQueryCache().notify({query:p(q,this),type:`observerResultsUpdated`})})}function Xn(e,t){return W(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||W(t.retryOnMount,e)!==!1)}function Zn(e,t){return Xn(e,t)||e.state.data!==void 0&&Qn(e,t,t.refetchOnMount)}function Qn(e,t,n){if(W(t.enabled,e)!==!1&&Et(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&er(e,t)}return!1}function $n(e,t,n,r){return(e!==t||W(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&er(e,n)}function er(e,t){return W(t.enabled,e)!==!1&&e.isStaleByTime(Et(t.staleTime,e))}function tr(e,t){return!Pt(e.getCurrentResult(),t)}var nr,rr,X,ir,ar,or=(nr=new WeakMap,rr=new WeakMap,X=new WeakMap,ir=new WeakMap,ar=new WeakSet,class extends on{constructor(e){super(),fn(this,ar),o(this,nr,void 0),o(this,rr,void 0),o(this,X,void 0),o(this,ir,void 0),d(nr,this,e.client),this.mutationId=e.mutationId,d(X,this,e.mutationCache),d(rr,this,[]),this.state=e.state||cr(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){p(rr,this).includes(e)||(p(rr,this).push(e),this.clearGcTimeout(),p(X,this).notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){d(rr,this,p(rr,this).filter(t=>t!==e)),this.scheduleGc(),p(X,this).notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){p(rr,this).length||(this.state.status===`pending`?this.scheduleGc():p(X,this).remove(this))}continue(){return p(ir,this)?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{u(ar,this,sr).call(this,{type:`continue`})},n={client:p(nr,this),meta:this.options.meta,mutationKey:this.options.mutationKey};d(ir,this,rn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{u(ar,this,sr).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{u(ar,this,sr).call(this,{type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>p(X,this).canRun(this)}));let r=this.state.status===`pending`,i=!p(ir,this).canStart();try{if(r)t();else{u(ar,this,sr).call(this,{type:`pending`,variables:e,isPaused:i}),p(X,this).config.onMutate&&await p(X,this).config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&u(ar,this,sr).call(this,{type:`pending`,context:t,variables:e,isPaused:i})}let a=await p(ir,this).start();return await p(X,this).config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await p(X,this).config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),u(ar,this,sr).call(this,{type:`success`,data:a}),a}catch(t){try{await p(X,this).config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await p(X,this).config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw u(ar,this,sr).call(this,{type:`error`,error:t}),t}finally{p(X,this).runNext(this)}}});function sr(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),G.batch(()=>{p(rr,this).forEach(t=>{t.onMutationUpdate(e)}),p(X,this).notify({mutation:this,type:`updated`,action:e})})}function cr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var lr,ur,dr,fr=(lr=new WeakMap,ur=new WeakMap,dr=new WeakMap,class extends ft{constructor(e={}){super(),o(this,lr,void 0),o(this,ur,void 0),o(this,dr,void 0),this.config=e,d(lr,this,new Set),d(ur,this,new Map),d(dr,this,0)}build(e,t,n){var r;let i=new or({client:e,mutationCache:this,mutationId:d(dr,this,(r=p(dr,this),++r)),options:e.defaultMutationOptions(t),state:n});return this.add(i),i}add(e){p(lr,this).add(e);let t=pr(e);if(typeof t==`string`){let n=p(ur,this).get(t);n?n.push(e):p(ur,this).set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(p(lr,this).delete(e)){let t=pr(e);if(typeof t==`string`){let n=p(ur,this).get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&p(ur,this).delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=pr(e);if(typeof t==`string`){let n=p(ur,this).get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=pr(e);return typeof t==`string`?(p(ur,this).get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){G.batch(()=>{p(lr,this).forEach(e=>{this.notify({type:`removed`,mutation:e})}),p(lr,this).clear(),p(ur,this).clear()})}getAll(){return Array.from(p(lr,this))}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ot(t,e))}findAll(e={}){return this.getAll().filter(t=>Ot(e,t))}notify(e){G.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return G.batch(()=>Promise.all(e.map(e=>e.continue().catch(U))))}});function pr(e){return e.options.scope?.id}var mr,hr=(mr=new WeakMap,class extends ft{constructor(e={}){super(),o(this,mr,void 0),this.config=e,d(mr,this,new Map)}build(e,t,n){let r=t.queryKey,i=t.queryHash??kt(r,t),a=this.get(i);return a||(a=new xn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){p(mr,this).has(e.queryHash)||(p(mr,this).set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=p(mr,this).get(e.queryHash);t&&(e.destroy(),t===e&&p(mr,this).delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){G.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return p(mr,this).get(e)}getAll(){return[...p(mr,this).values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Dt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Dt(e,t)):t}notify(e){G.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){G.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){G.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}}),Z,gr,_r,vr,yr,br,xr,Sr,Cr=(Z=new WeakMap,gr=new WeakMap,_r=new WeakMap,vr=new WeakMap,yr=new WeakMap,br=new WeakMap,xr=new WeakMap,Sr=new WeakMap,class{constructor(e={}){o(this,Z,void 0),o(this,gr,void 0),o(this,_r,void 0),o(this,vr,void 0),o(this,yr,void 0),o(this,br,void 0),o(this,xr,void 0),o(this,Sr,void 0),d(Z,this,e.queryCache||new hr),d(gr,this,e.mutationCache||new fr),d(_r,this,e.defaultOptions||{}),d(vr,this,new Map),d(yr,this,new Map),d(br,this,0)}mount(){var e;d(br,this,(e=p(br,this),e++,e)),p(br,this)===1&&(d(xr,this,gt.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(Z,this).onFocus())})),d(Sr,this,$t.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(Z,this).onOnline())})))}unmount(){var e;d(br,this,(e=p(br,this),e--,e)),p(br,this)===0&&(p(xr,this)?.call(this),d(xr,this,void 0),p(Sr,this)?.call(this),d(Sr,this,void 0))}isFetching(e){return p(Z,this).findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return p(gr,this).findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return p(Z,this).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=p(Z,this).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Et(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return p(Z,this).findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=p(Z,this).get(r.queryHash)?.state.data,a=Ct(t,i);if(a!==void 0)return p(Z,this).build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return G.batch(()=>p(Z,this).findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return p(Z,this).get(t.queryHash)?.state}removeQueries(e){let t=p(Z,this);G.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=p(Z,this);return G.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=G.batch(()=>p(Z,this).findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(U).catch(U)}invalidateQueries(e,t={}){return G.batch(()=>(p(Z,this).findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=G.batch(()=>p(Z,this).findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(U)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(U)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=p(Z,this).build(this,t);return n.isStaleByTime(Et(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(U).catch(U)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(U).catch(U)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return $t.isOnline()?p(gr,this).resumePausedMutations():Promise.resolve()}getQueryCache(){return p(Z,this)}getMutationCache(){return p(gr,this)}getDefaultOptions(){return p(_r,this)}setDefaultOptions(e){d(_r,this,e)}setQueryDefaults(e,t){p(vr,this).set(At(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...p(vr,this).values()],n={};return t.forEach(t=>{jt(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){p(yr,this).set(At(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...p(yr,this).values()],n={};return t.forEach(t=>{jt(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...p(_r,this).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=kt(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ht&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...p(_r,this).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){p(Z,this).clear(),p(gr,this).clear()}}),Q=e(t(),1),$=r(),wr=Q.createContext(void 0),Tr=e=>{let t=Q.useContext(wr);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Er=({client:e,children:t})=>(Q.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,$.jsx)(wr.Provider,{value:e,children:t})),Dr=Q.createContext(!1),Or=()=>Q.useContext(Dr);Dr.Provider;function kr(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ar=Q.createContext(kr()),jr=()=>Q.useContext(Ar),Mr=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Wt(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Nr=e=>{Q.useEffect(()=>{e.clearReset()},[e])},Pr=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Wt(n,[e.error,r])),Fr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Ir=(e,t)=>e.isLoading&&e.isFetching&&!t,Lr=(e,t)=>e?.suspense&&t.isPending,Rr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function zr(e,t,n){let r=Or(),i=jr(),a=Tr(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Fr(o),Mr(o,i,s),Nr(i);let l=!a.getQueryCache().get(o.queryHash),[u]=Q.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(Q.useSyncExternalStore(Q.useCallback(e=>{let t=f?u.subscribe(G.batchCalls(e)):U;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),Q.useEffect(()=>{u.setOptions(o)},[o,u]),Lr(o,d))throw Rr(o,u,i);if(Pr({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Kt.isServer()&&Ir(d,r)&&(l?Rr(o,u,i):s?.promise)?.catch(U).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Br(e,t){return zr(e,Bn,t)}var Vr=e(a(),1),Hr={id:`home`,kind:`home`,path:`/`},Ur=[`/models`,`/personas`,`/gallery`,`/agents`,`/users`,`/usage`,`/system`,`/artifacts`],Wr=e=>{if(e===`/`||e===`/home`)return Hr;if(e===`/chat`)return{id:`chat:new`,kind:`chat`,path:`/chat`};let t=e.match(/^\/c\/([^/]+)$/);if(t)return{id:`chat:${t[1]}`,kind:`chat`,path:e};if(e===`/work`)return{id:`work:new`,kind:`work`,path:`/work`};let n=e.match(/^\/work\/([^/]+)$/);return n?{id:`work:${n[1]}`,kind:`work`,path:e}:Ur.includes(e)?{id:`page:${e}`,kind:`page`,path:e}:null},Gr=e=>[Hr,...e.filter(e=>e.id!==Hr.id)],Kr=Je()(Ye((e,t)=>({tabs:[Hr],activeTabId:Hr.id,syncWithPath:t=>{let n=Wr(t);n&&e(e=>{let t=Gr(e.tabs),r=t.find(e=>e.id===n.id);if(r)return{tabs:t,activeTabId:r.id};let i=t.find(t=>t.id===e.activeTabId);return i&&i.kind===n.kind&&i.id.endsWith(`:new`)&&!n.id.endsWith(`:new`)?{tabs:t.map(e=>e.id===i.id?n:e),activeTabId:n.id}:{tabs:[...t,n],activeTabId:n.id}})},closeTab:e=>t().closeTabs([e]),closeTabs:(n,r)=>{let i=t(),a=Gr(i.tabs),o=new Set(n.filter(e=>e!==Hr.id&&a.some(t=>t.id===e)));if(o.size===0)return null;let s=a.findIndex(e=>e.id===i.activeTabId),c=a.filter(e=>!o.has(e.id));if(!o.has(i.activeTabId))return e({tabs:c}),null;let l=r?c.find(e=>e.id===r):void 0,u=a.slice(0,Math.max(0,s)).reverse().find(e=>!o.has(e.id)),d=l??u??c[0]??Hr;return e({tabs:c,activeTabId:d.id}),d},reset:()=>e({tabs:[Hr],activeTabId:Hr.id})}),{name:`libre-webui-tabs`,merge:(e,t)=>{let n=e??{},r=Array.isArray(n.tabs)?Gr(n.tabs.filter(e=>!!e&&typeof e.id==`string`&&typeof e.path==`string`&&Wr(e.path)?.id===e.id)):t.tabs,i=r.some(e=>e.id===n.activeTabId)?n.activeTabId:Hr.id;return{...t,tabs:r,activeTabId:i}}})),qr=i(),Jr=Ze(`components:avatar-upload`),Yr=({value:e,onChange:t,className:n=``})=>{let{t:r}=S(),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=async e=>{if(!e.type.startsWith(`image/`)){V.error(r(`user.avatar.invalidFile`));return}if(e.size>2097152){V.error(r(`user.avatar.fileTooLarge`));return}o(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),V.success(r(`user.avatar.uploaded`))},n.onerror=()=>{V.error(r(`user.avatar.readFailed`))},n.readAsDataURL(e)}catch(e){Jr.error(`Failed to upload avatar:`,e),V.error(r(`user.avatar.uploadFailed`))}finally{o(!1)}},u=e=>{let t=e.target.files?.[0];t&&l(t)},d=e=>{e.preventDefault(),c(!0)},f=e=>{e.preventDefault(),c(!1)},p=e=>{e.preventDefault(),c(!1);let t=e.dataTransfer.files?.[0];t&&l(t)},m=()=>{t(``),V.success(r(`user.avatar.removed`))},h=()=>e||null;return(0,$.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:r(`user.avatar.label`)}),(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsx)(`div`,{className:`flex-shrink-0`,children:(0,$.jsx)(`div`,{className:`w-20 h-20 rounded-full overflow-hidden bg-gray-100 dark:bg-dark-200 border-2 border-gray-300 dark:border-dark-300 flex items-center justify-center`,children:h()?(0,$.jsx)(`img`,{src:h(),alt:`Avatar preview`,className:`w-full h-full object-cover`}):(0,$.jsx)(R,{className:`h-8 w-8 text-gray-400 dark:text-gray-500`})})}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[e?(0,$.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:r(`user.avatar.customAvatar`)}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`user.avatar.clickToChange`)})]}),(0,$.jsx)(ut,{variant:`ghost`,size:`sm`,onClick:m,className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,$.jsx)(Me,{className:`h-4 w-4`})})]}):(0,$.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${s?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:d,onDragLeave:f,onDrop:p,onClick:()=>i.current?.click(),children:[(0,$.jsx)(z,{className:`h-8 w-8 mx-auto text-gray-400 dark:text-gray-500 mb-2`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:r(`user.avatar.uploadAvatarImage`)}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-2`,children:r(`user.avatar.dragAndDrop`)}),(0,$.jsxs)(ut,{variant:`outline`,size:`sm`,disabled:a,className:`mx-auto`,children:[(0,$.jsx)(z,{className:`h-4 w-4 mr-2`}),r(a?`user.avatar.uploading`:`user.avatar.chooseImage`)]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:r(`user.avatar.enterImageUrl`)}),(0,$.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/avatar.jpg`})]})]})]}),(0,$.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,onChange:u,className:`hidden`}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:r(`user.avatar.supportedFormats`)})]})})};function Xr({open:e,value:t,saving:n,onChange:r,onClose:i,onSave:a}){let{t:o}=S();return e?(0,qr.createPortal)((0,$.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:i,children:(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`avatar-modal-title`,className:`bg-white dark:bg-dark-25 rounded-3xl shadow-[0_24px_80px_rgba(0,0,0,0.24)] p-6 w-full max-w-md border border-black/[0.07] dark:border-white/[0.08] animate-scale-in`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,$.jsx)(`h3`,{id:`avatar-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:o(`user.avatar.title`)}),(0,$.jsx)(`button`,{onClick:i,className:`p-2 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-xl transition-colors`,children:(0,$.jsx)(Me,{size:20,className:`text-gray-500`})})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Yr,{value:t,onChange:r}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,$.jsx)(`button`,{onClick:i,className:`px-4 py-2 text-sm font-medium text-gray-700 dark:text-dark-700 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-xl transition-colors`,children:o(`common.cancel`)}),(0,$.jsx)(`button`,{onClick:a,disabled:n,className:`px-4 py-2 text-sm font-medium text-white bg-gray-950 hover:bg-gray-800 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed rounded-xl transition-colors`,children:o(n?`common.saving`:`common.save`)})]})]})]})}),document.body):null}var Zr={sm:`text-[1.0625rem] leading-none`,md:`text-[1.625rem] leading-none`,lg:`text-[2.5rem] leading-none`},Qr=({className:e,size:t=`md`,wordmark:n=!0})=>(0,$.jsxs)(`span`,{dir:`ltr`,className:T(`libre-brand inline-flex items-baseline whitespace-nowrap`,Zr[t],e),children:[`Libre`,n&&(0,$.jsx)(`span`,{className:`ms-1 font-normal tracking-[-0.035em]`,children:`WebUI`})]}),$r={sm:`h-6 w-6`,md:`h-8 w-8`,lg:`h-12 w-12`},ei=({className:e,size:t=`md`,label:n=`Libre WebUI`})=>(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,className:T(`shrink-0`,$r[t],e),role:n?`img`:`presentation`,"aria-label":n??void 0,"aria-hidden":!n||void 0,focusable:`false`,children:[(0,$.jsx)(`path`,{d:`M 11.5 18.0 L 11.5 32 A 20.5 20.5 0 0 0 50.58 40.66`,fill:`none`,stroke:`currentColor`,strokeWidth:`11`,strokeLinecap:`round`}),(0,$.jsx)(`path`,{d:`M 50.58 18.0 L 50.58 25.66`,fill:`none`,stroke:`currentColor`,strokeWidth:`11`,strokeLinecap:`round`})]}),ti=()=>{let{theme:e,toggleTheme:t}=st(),n=e.mode===`light`?`dark`:`light`,r=e.mode===`light`?(0,$.jsx)(ze,{className:`h-4 w-4 text-ink-muted transition-colors duration-150 group-hover:text-ink motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":`true`}):(0,$.jsx)(ye,{className:`h-4 w-4 text-ink-muted transition-colors duration-150 group-hover:text-ink motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":`true`}),i=`Switch to ${n} mode`;return(0,$.jsx)(ut,{variant:`ghost`,size:`sm`,onClick:t,className:`h-9 w-9 rounded-full p-0`,"aria-label":i,title:`${i} (⌘D)`,children:r})};function ni({sidebarCompact:e,isElectron:t,showWork:n,activeMode:r,selectedModel:i,modelCount:a,onToggleCompact:o,onStartWork:s,onCreateSession:c}){let{t:l}=S(),u=!i||a===0,d=u?l(`chat.model.noModelsTooltip`):``,f=`flex h-9 w-9 items-center justify-center rounded-full text-ink transition-colors hover:bg-interactive-hover outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`;return e?(0,$.jsxs)(`div`,{className:T(`flex flex-col items-center gap-3 px-2 pt-4 pb-2`,t&&`pt-10`),children:[(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:T(f,`group`),title:l(`sidebar.expandSidebar`),"aria-label":l(`sidebar.expandSidebar`),"data-testid":`sidebar-rail-expand`,children:[(0,$.jsx)(ei,{size:`sm`,label:null,className:`h-6 w-6 p-0 text-ink group-hover:hidden`}),(0,$.jsx)(ge,{className:`hidden h-[18px] w-[18px] group-hover:block rtl:rotate-180`})]}),(0,$.jsx)(`button`,{type:`button`,onClick:c,disabled:u,className:T(f,u&&`opacity-40`),title:u?d:l(`chat.session.chat`),"aria-label":l(`chat.session.chat`),"aria-pressed":r===`chat`,"data-testid":`sidebar-chat-button`,children:(0,$.jsx)(Pe,{className:`h-[18px] w-[18px]`})}),n&&(0,$.jsx)(`button`,{type:`button`,onClick:s,className:f,title:l(`chat.session.work`),"aria-label":l(`chat.session.work`),"aria-pressed":r===`work`,"data-testid":`sidebar-work-button`,children:(0,$.jsx)(Te,{className:`h-[18px] w-[18px]`})}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`sidebar-search-button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-palette`)),title:l(`palette.search`,`Search`),"aria-label":l(`palette.search`,`Search`),className:f,children:(0,$.jsx)(ce,{className:`h-[18px] w-[18px]`})})]}):(0,$.jsxs)(`div`,{className:T(`px-3 pb-2 pt-2`,t&&`pt-10`),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex h-[52px] min-w-0 items-center justify-between ps-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-ink`,children:[(0,$.jsx)(ei,{size:`sm`,label:null}),(0,$.jsx)(Qr,{size:`sm`,className:`tracking-[-0.035em]`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,$.jsx)(`div`,{className:`hidden sm:block`,children:(0,$.jsx)(ti,{})}),(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`flex h-7 w-7 items-center justify-center rounded-full text-ink-muted transition-colors hover:bg-interactive-hover hover:text-ink outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`,title:l(`sidebar.toggleSize`),"aria-label":l(`sidebar.toggleSize`),"data-testid":`sidebar-toggle-size`,children:(0,$.jsx)(ge,{className:`h-4 w-4 rtl:rotate-180`})})]})]}),(0,$.jsxs)(`div`,{className:T(`grid w-full gap-2`,!n&&`grid-cols-1`,n&&`grid-cols-2`),"data-testid":`sidebar-create-actions`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:c,disabled:u,className:T(`flex h-[38px] items-center justify-center gap-1.5 rounded-xl border text-sm font-medium transition-colors touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,r===`chat`?`border-transparent bg-nav-active text-ink`:`border-line bg-surface-raised text-ink hover:bg-hover-solid dark:border-white/[0.12] dark:bg-dark-25 dark:hover:bg-dark-300`,u&&`opacity-50`),title:u?d:l(`chat.session.chat`),"aria-label":l(`chat.session.chat`),"aria-pressed":r===`chat`,"data-testid":`sidebar-chat-button`,children:[(0,$.jsx)(Pe,{className:`h-4 w-4`}),l(`chat.session.chat`)]}),n&&(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:T(`flex h-[38px] items-center justify-center gap-1.5 rounded-xl border text-sm font-medium transition-colors touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,r===`work`?`border-transparent bg-nav-active text-ink`:`border-line bg-surface-raised text-ink hover:bg-hover-solid dark:border-white/[0.12] dark:bg-dark-25 dark:hover:bg-dark-300`),title:l(`chat.session.work`),"aria-label":l(`chat.session.work`),"aria-pressed":r===`work`,"data-testid":`sidebar-work-button`,children:[(0,$.jsx)(Te,{className:`h-4 w-4`}),l(`chat.session.work`)]})]}),(0,$.jsxs)(`button`,{type:`button`,"data-testid":`sidebar-search-button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-palette`)),title:l(`palette.search`,`Search`),"aria-label":l(`palette.search`,`Search`),className:`mt-1.5 flex h-[34px] w-full items-center gap-2 rounded-xl px-2.5 text-sm text-ink-muted transition-colors hover:bg-interactive-hover hover:text-ink outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30 touch-manipulation`,children:[(0,$.jsx)(ce,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 text-start`,children:l(`palette.search`,`Search`)}),(0,$.jsxs)(`span`,{className:`font-mono text-[10px] tracking-wide text-ink-subtle`,children:[C()?`⌘`:`Ctrl`,`K`]})]})]})}var ri=[{path:`/notes`,icon:M,labelKey:`sidebar.navigation.notes`},{path:`/models`,icon:ae,labelKey:`sidebar.navigation.models`},{path:`/personas`,icon:R,labelKey:`sidebar.navigation.personas`},{path:`/gallery`,icon:re,labelKey:`sidebar.navigation.imagine`},{path:`/agents`,icon:be,labelKey:`sidebar.navigation.agents`}];function ii({sidebarCompact:e,activePath:t,showAgents:n,onMobileNavigate:r}){let{t:i}=S();return(0,$.jsx)(`div`,{className:T(`pb-3`,e?`px-2`:`px-3`),children:(0,$.jsx)(`nav`,{"data-testid":`sidebar-navigation`,"aria-label":i(`sidebar.navigation.exploreLabel`,`Explore`),className:T(`flex gap-1`,e?`flex-col items-center`:`items-center`),children:ri.filter(e=>e.path!==`/agents`||n).map(({path:n,icon:a,labelKey:o})=>{let s=t===n,c=i(o);return(0,$.jsxs)(y,{to:n,onClick:r,title:c,"aria-label":c,"aria-current":s?`page`:void 0,className:T(`relative flex items-center justify-center rounded-xl transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,e?`h-9 w-9`:`h-9 flex-1`,s?`bg-nav-active text-ink`:`text-ink-muted hover:bg-interactive-hover hover:text-ink`),children:[e&&s&&(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -start-2 h-5 w-0.5 rounded-full bg-primary-500 shadow-[0_0_12px_rgb(var(--color-primary-500)/0.55)]`}),(0,$.jsx)(a,{className:`h-[18px] w-[18px] shrink-0`})]},n)})})})}function ai(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),r=864e5;return e>=n?`today`:e>=n-r?`yesterday`:e>=n-7*r?`previous7Days`:e>=n-30*r?`previous30Days`:`older`}var oi=[`today`,`yesterday`,`previous7Days`,`previous30Days`,`older`];function si(e){let t=e.trim().split(/\s+/u).filter(Boolean);return t.length===0?`•`:t.length===1?Array.from(t[0]).slice(0,2).join(``).toLocaleUpperCase():`${Array.from(t[0])[0]}${Array.from(t[t.length-1])[0]}`.toLocaleUpperCase()}function ci({preview:e}){let{t,i18n:n}=S(),{session:r}=e,i=r.messages.find(e=>e.role===`user`&&e.content.trim()),a=r.messages.find(e=>e.role===`assistant`&&e.content.trim());return(0,qr.createPortal)((0,$.jsxs)(`div`,{role:`tooltip`,className:`pointer-events-none fixed z-[70] hidden w-72 rounded-2xl border border-black/[0.07] bg-surface/95 p-3.5 shadow-[0_16px_48px_rgba(15,23,42,0.18)] backdrop-blur-xl animate-scale-in dark:border-white/[0.09] dark:bg-dark-100/95 md:block`,style:{top:Math.max(8,Math.min(e.top,window.innerHeight-220)),left:e.left},children:[(0,$.jsx)(`p`,{className:`mb-1 truncate text-[13px] font-semibold text-gray-900 dark:text-dark-900`,children:r.title}),(0,$.jsx)(`p`,{className:`mb-2 text-[10px] tabular-nums text-gray-400 dark:text-dark-500`,children:ee(r.updatedAt,n.language)}),i&&(0,$.jsx)(`div`,{className:`mb-1.5 flex justify-end`,children:(0,$.jsx)(`p`,{dir:`auto`,className:`max-w-[85%] rounded-xl rounded-ee-sm bg-gray-900 px-2.5 py-1.5 text-[11px] leading-snug text-white dark:bg-dark-300`,children:w(i.content,110)})}),a&&(0,$.jsx)(`p`,{dir:`auto`,className:`text-[11px] leading-snug text-gray-600 dark:text-dark-700`,children:w(a.content.replace(/\s+/g,` `),180)}),!i&&!a&&(0,$.jsx)(`p`,{className:`text-[11px] italic text-gray-400 dark:text-dark-500`,children:t(`chat.session.noChats`)})]}),document.body)}function li({sessions:e,personas:t,currentSessionId:n,generatingTitleForSession:r,sidebarCompact:i,editingSessionId:a,editingTitle:o,onEditingTitleChange:s,onSelectSession:c,onStartEditing:l,onSaveEdit:u,onCancelEdit:d,onDeleteSession:f,onArchiveSession:p,onTogglePinSession:m,folders:h=[],onCreateFolder:g,onRenameFolder:_,onDeleteFolder:v,onMoveSession:y,onExpandSidebar:b}){let{t:x,i18n:C}=S(),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(null),A=(0,Q.useRef)(null),j=O?e.find(e=>e.id===O)??null:null;(0,Q.useEffect)(()=>()=>{A.current!==null&&window.clearTimeout(A.current)},[]);let M=()=>{A.current!==null&&(window.clearTimeout(A.current),A.current=null),D(null)},N=(e,t)=>{let n=window.matchMedia(`(hover: hover) and (pointer: fine)`).matches;i||window.innerWidth<768||!n||(A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{let n=t.getBoundingClientRect();D({session:e,top:n.top,left:n.right+10})},500))},[P,te]=(0,Q.useState)(()=>new Set),[ne,re]=(0,Q.useState)(!1),[ae,I]=(0,Q.useState)(``),[ce,ue]=(0,Q.useState)(null),[fe,pe]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(null),_e=fe?e.find(e=>e.id===fe)??null:null,ve=()=>{pe(null),ge(null)},ye=e=>{let t=_e;ve(),!(!t||!y)&&(t.folderId??null)!==e&&y(t.id,e)},be=(e,t)=>({onDragOver:t=>{fe&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,he!==e&&ge(e))},onDragLeave:()=>{he===e&&ge(null)},onDrop:e=>{e.preventDefault(),ye(t)}}),[R,z]=(0,Q.useState)(null),B=R?e.find(e=>e.id===R.sessionId)??null:null;(0,Q.useEffect)(()=>{if(!R)return;let e=e=>{e.key===`Escape`&&z(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[R]);let Ce=(e,t)=>{if(t.stopPropagation(),M(),R?.sessionId===e.id){z(null);return}let n=t.currentTarget.getBoundingClientRect();z({sessionId:e.id,top:Math.max(8,Math.min(n.bottom+6,window.innerHeight-340-8)),left:Math.max(8,Math.min(n.right-208,window.innerWidth-208-8))})},Te=e=>{let t=window.location.protocol===`file:`?`${window.location.pathname}#/c/${e.id}`:`/c/${e.id}`;window.open(t,`_blank`,`noopener,noreferrer`)},Ee=e=>{te(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},V=()=>{let e=ae.trim();re(!1),I(``),e&&g&&g(e)},De=e=>{let t=ae.trim();ue(null),I(``),t&&_&&_(e,t)},Oe=new Set(h.map(e=>e.id)),ke=e.filter(e=>e.pinned),Ae=e.filter(e=>!e.pinned),je=Ae.filter(e=>!e.folderId||!Oe.has(e.folderId)),Ne=[...ke.length>0?[{key:`pinned`,labelKey:`pinned`,sessions:ke}]:[],...h.map(e=>({key:`folder:${e.id}`,folder:e,sessions:Ae.filter(t=>t.folderId===e.id)})),...oi.map(e=>({key:e,labelKey:e,sessions:je.filter(t=>ai(t.updatedAt)===e)})).filter(e=>e.sessions.length>0)],Fe=[...e].sort((e,t)=>t.updatedAt-e.updatedAt);return(0,$.jsxs)(`div`,{"data-testid":`sidebar-session-scroll-region`,className:`scroll-region min-h-0 flex-1 scrollbar-thin border-t border-black/[0.05] dark:border-white/[0.05]`,style:{willChange:`scroll-position`},children:[(0,$.jsxs)(`div`,{className:T(`px-3 py-3`,i&&`px-2`),children:[!i&&e.length>0&&(0,$.jsxs)(`div`,{className:`mb-1 flex h-7 items-center justify-between px-1.5`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:x(`chat.session.chats`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[g&&(0,$.jsx)(`button`,{onClick:()=>{re(!0),I(``)},className:`flex h-6 w-6 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-interactive-hover hover:text-ink`,title:x(`chat.session.folder.new`),children:(0,$.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-ink-subtle font-medium`,children:e.length})]})]}),!i&&ne&&(0,$.jsx)(`div`,{className:`mb-2 px-1`,children:(0,$.jsx)(dt,{value:ae,onChange:e=>I(e.target.value),onKeyDown:e=>{e.key===`Enter`?V():e.key===`Escape`&&(re(!1),I(``))},onBlur:V,placeholder:x(`chat.session.folder.namePlaceholder`),className:`h-8 text-sm`,autoFocus:!0})}),i?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:b,"data-testid":`sidebar-mobile-chats`,"aria-label":`${x(`chat.session.chats`)} (${e.length})`,title:x(`chat.session.chats`),className:`relative flex h-12 w-12 items-center justify-center rounded-xl text-gray-500 outline-none transition-colors hover:bg-white/70 hover:text-gray-950 focus-visible:ring-2 focus-visible:ring-primary-500/30 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 md:hidden`,children:[(0,$.jsx)(Pe,{className:`h-[18px] w-[18px]`}),e.length>0&&(0,$.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-500 px-1 text-[9px] font-semibold tabular-nums text-white shadow-sm`,children:e.length>99?`99+`:e.length})]}),(0,$.jsx)(`div`,{"data-testid":`sidebar-compact-session-list`,className:`flex w-full flex-col items-center gap-1`,children:Fe.map(e=>{let t=n===e.id;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>c(e),"data-testid":`sidebar-compact-session`,"aria-current":t?`page`:void 0,"aria-label":e.title,title:e.title,className:T(`relative flex h-12 w-12 items-center justify-center rounded-xl outline-none transition-colors focus-visible:ring-2 focus-visible:ring-primary-500/30`,t?`bg-gray-950 text-white ring-1 ring-black/10 shadow-[0_8px_24px_-14px_rgba(0,0,0,0.7)] dark:bg-white dark:text-gray-950 dark:ring-white/20 dark:shadow-[0_8px_24px_-14px_rgba(255,255,255,0.45)]`:`text-gray-500 hover:bg-white/70 hover:text-gray-950 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950`),children:[t&&(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -start-2 h-5 w-0.5 rounded-full bg-gray-950 shadow-[0_0_10px_rgba(0,0,0,0.35)] dark:bg-white dark:shadow-[0_0_10px_rgba(255,255,255,0.35)]`}),(0,$.jsx)(`span`,{className:`font-mono text-[11px] font-semibold tracking-[-0.03em]`,children:si(e.title)}),r===e.id&&(0,$.jsx)(`span`,{className:`absolute end-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-primary-500`})]},e.id)})})]}):e.length===0?(0,$.jsxs)(`div`,{className:T(`text-center py-8`,i?`px-1`:`px-2`),children:[(0,$.jsx)(`div`,{className:T(`mx-auto mb-3 bg-white/70 dark:bg-dark-200 rounded-xl flex items-center justify-center ring-1 ring-black/[0.04] dark:ring-white/[0.05]`,i?`w-8 h-8`:`w-12 h-12`),children:(0,$.jsx)(Pe,{className:T(`text-gray-400 dark:text-gray-500`,i?`h-4 w-4`:`h-5 w-5`)})}),!i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:x(`chat.session.noChats`)}),(0,$.jsx)(`p`,{className:`text-xs mt-1 text-gray-400 dark:text-dark-500`,children:x(`chat.session.createFirst`)})]})]}):(0,$.jsx)(`div`,{className:T(`space-y-2`,i&&`space-y-1`),children:Ne.map(e=>(0,$.jsxs)(`div`,{children:[!i&&e.folder&&(0,$.jsx)(`div`,{...be(`folder:${e.folder.id}`,e.folder.id),className:T(`group/folder mb-0.5 flex h-[34px] items-center justify-between rounded-lg px-2 transition-colors hover:bg-interactive-hover`,he===`folder:${e.folder.id}`&&`bg-primary-500/10 ring-1 ring-primary-500/40`),children:ce===e.folder.id?(0,$.jsx)(dt,{value:ae,onChange:e=>I(e.target.value),onKeyDown:t=>{t.key===`Enter`?De(e.folder.id):t.key===`Escape`&&(ue(null),I(``))},onBlur:()=>De(e.folder.id),className:`h-7 text-sm`,autoFocus:!0}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:()=>Ee(e.folder.id),className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm text-ink transition-colors`,"aria-expanded":!P.has(e.folder.id),children:[P.has(e.folder.id)?(0,$.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle rtl:rotate-180`}):(0,$.jsx)(Be,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle`}),(0,$.jsx)(L,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.folder.name}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-ink-subtle`,children:e.sessions.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-0 transition-opacity group-hover/folder:opacity-100`,children:[_&&(0,$.jsx)(`button`,{onClick:()=>{ue(e.folder.id),I(e.folder.name)},className:`rounded-md p-0.5 text-gray-400 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-800`,title:x(`chat.session.renameChat`),children:(0,$.jsx)(oe,{className:`h-3 w-3`})}),v&&(0,$.jsx)(`button`,{onClick:()=>{window.confirm(x(`chat.session.folder.deleteConfirm`))&&v(e.folder.id)},className:`rounded-md p-0.5 text-gray-400 hover:text-red-500 dark:text-dark-500 dark:hover:text-red-400`,title:x(`chat.session.folder.delete`),children:(0,$.jsx)(we,{className:`h-3 w-3`})})]})]})}),!i&&!e.folder&&(0,$.jsx)(`p`,{...be(`group:${e.key}`,null),className:T(`mb-0.5 mt-1 rounded-md px-2 text-[11px] font-medium text-ink-subtle transition-colors`,he===`group:${e.key}`&&_e?.folderId&&`bg-primary-500/10 ring-1 ring-primary-500/40 text-primary-600 dark:text-primary-400`),children:x(`chat.session.groups.${e.labelKey}`)}),e.folder&&P.has(e.folder.id)?null:(0,$.jsx)(`div`,{className:T(`space-y-0.5`,i&&`space-y-1`),children:e.sessions.map(e=>{let t=n===e.id,l=R?.sessionId===e.id;return(0,$.jsx)(`div`,{draggable:!i&&!!y&&a!==e.id,onDragStart:t=>{M(),z(null),pe(e.id),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id)},onDragEnd:ve,className:T(`group relative cursor-pointer transition-colors duration-150 touch-manipulation outline-none`,i?`rounded-xl p-1 flex items-center justify-center`:`rounded-lg px-2`,t?`bg-interactive-active`:`hover:bg-interactive-hover`,fe===e.id&&`opacity-40`),onClick:()=>{M(),c(e)},onMouseEnter:t=>N(e,t.currentTarget),onMouseLeave:M,title:i?`${e.title} - ${e.model}`:void 0,children:i?(0,$.jsx)(`div`,{className:`flex items-center justify-center w-full h-10`,children:(0,$.jsx)(`div`,{className:T(`flex h-9 w-9 items-center justify-center rounded-xl text-[11px] font-semibold uppercase transition-colors`,r===e.id?`bg-white text-primary-600 animate-pulse dark:bg-dark-200 dark:text-primary-400`:t?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`bg-white/70 text-gray-500 ring-1 ring-black/[0.04] dark:bg-dark-200/70 dark:text-dark-600 dark:ring-white/[0.05]`),children:e.title.trim().charAt(0)||`•`})}):a===e.id?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(dt,{value:o,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`?u(e.id):t.key===`Escape`&&d()},className:`text-sm h-8`,autoFocus:!0}),(0,$.jsx)(ut,{variant:`ghost`,size:`sm`,onClick:()=>u(e.id),className:`h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 active:bg-gray-200 dark:active:bg-dark-400 touch-manipulation`,children:(0,$.jsx)(Se,{className:`h-3 w-3`})}),(0,$.jsx)(ut,{variant:`ghost`,size:`sm`,onClick:d,className:`h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 active:bg-gray-200 dark:active:bg-dark-400 touch-manipulation`,children:(0,$.jsx)(Me,{className:`h-3 w-3`})})]}):(0,$.jsxs)(`div`,{className:`flex h-8 w-full items-center`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm leading-5 text-ink`,title:e.title,children:r===e.id?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`animate-pulse`,children:x(`chat.session.generatingTitle`)}),(0,$.jsxs)(`span`,{className:`inline-flex`,children:[(0,$.jsx)(`span`,{className:`animate-bounce`,style:{animationDelay:`0ms`},children:`.`}),(0,$.jsx)(`span`,{className:`animate-bounce`,style:{animationDelay:`150ms`},children:`.`}),(0,$.jsx)(`span`,{className:`animate-bounce`,style:{animationDelay:`300ms`},children:`.`})]})]}):w(e.title,40)}),(0,$.jsx)(`span`,{dir:`auto`,className:T(`ms-2 shrink-0 text-xs leading-5 tabular-nums text-ink-subtle max-sm:hidden`,`sm:group-hover:hidden sm:group-focus-within:hidden`,l&&`sm:hidden`),children:ee(e.updatedAt,C.language)}),(0,$.jsx)(ut,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),M(),k(e.id)},className:`h-8 w-8 shrink-0 rounded-lg p-0 touch-manipulation sm:hidden`,title:x(`palette.actions`),"aria-label":x(`palette.actions`),"data-testid":`sidebar-session-actions-mobile`,children:(0,$.jsx)(se,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:T(`hidden shrink-0`,`sm:group-hover:block sm:group-focus-within:block`,l&&`sm:block`),children:(0,$.jsx)(ut,{variant:`ghost`,size:`sm`,onClick:t=>Ce(e,t),className:T(`h-6 w-6 rounded-md p-0 text-ink-subtle hover:text-ink hover:bg-transparent touch-manipulation`,l&&`text-ink`),title:x(`palette.actions`),"aria-label":x(`palette.actions`),"aria-haspopup":`menu`,"aria-expanded":l,"data-testid":`sidebar-session-actions`,children:(0,$.jsx)(se,{className:`h-4 w-4`})})})]})},e.id)})})]},e.key))})]}),E&&(0,$.jsx)(ci,{preview:E}),R&&B&&(0,qr.createPortal)((0,$.jsxs)(`div`,{className:`fixed inset-0 z-[75] hidden sm:block`,children:[(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":x(`common.close`),className:`absolute inset-0 cursor-default`,onClick:()=>z(null)}),(0,$.jsxs)(`div`,{role:`menu`,"aria-label":B.title,"data-testid":`sidebar-session-menu`,className:`absolute overflow-y-auto rounded-xl border border-black/[0.04] bg-surface-overlay p-1 shadow-lv3 animate-scale-in dark:border-white/[0.06]`,style:{top:R.top,left:R.left,width:208,maxHeight:340},children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{z(null),Te(B)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.openNewTab`)]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{z(null),l(B,e)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,$.jsx)(oe,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.renameChat`)]}),m&&(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{z(null),m(B.id,!B.pinned)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[B.pinned?(0,$.jsx)(me,{className:`h-3.5 w-3.5 shrink-0`}):(0,$.jsx)(de,{className:`h-3.5 w-3.5 shrink-0`}),B.pinned?x(`chat.session.unpinChat`):x(`chat.session.pinChat`)]}),p&&(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{z(null),p(B.id,e)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,children:[(0,$.jsx)(F,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.archiveChat`)]}),y&&h.length>0&&(0,$.jsxs)(`div`,{className:`mt-1 border-t border-black/[0.06] pt-1 dark:border-white/[0.07]`,children:[(0,$.jsx)(`p`,{className:`px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-gray-400 dark:text-dark-500 rtl:tracking-normal`,children:x(`chat.session.folder.move`)}),h.map(e=>(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{z(null),y(B.id,e.id)},className:T(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink hover:bg-interactive-hover`,B.folderId===e.id&&`text-primary-600 dark:text-primary-400`),children:[(0,$.jsx)(L,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),B.folderId&&(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{z(null),y(B.id,null)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-start text-[13px] text-ink-muted hover:bg-interactive-hover`,children:[(0,$.jsx)(Me,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.folder.remove`)]})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:e=>{z(null),f(B.id,e)},className:`mt-1 flex w-full items-center gap-2.5 rounded-lg border-t border-black/[0.06] px-2.5 py-2 text-start text-[13px] text-red-500 hover:bg-red-50 dark:border-white/[0.07] dark:hover:bg-red-900/20`,children:[(0,$.jsx)(we,{className:`h-3.5 w-3.5 shrink-0`}),x(`chat.session.deleteChat`)]})]})]}),document.body),j&&(0,qr.createPortal)((0,$.jsxs)(`div`,{className:`fixed inset-0 z-[80] sm:hidden`,children:[(0,$.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-black/35 backdrop-blur-[2px]`,onClick:()=>k(null),"aria-label":x(`common.close`)}),(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":x(`palette.actions`),className:`absolute inset-x-3 bottom-3 rounded-2xl border border-black/[0.08] bg-surface p-2 shadow-[0_20px_70px_rgba(0,0,0,0.3)] dark:border-white/[0.09] dark:bg-dark-100`,"data-testid":`sidebar-session-actions-sheet`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-2 pb-2 pt-1`,children:[(0,$.jsx)(`p`,{className:`min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-dark-900`,children:j.title}),(0,$.jsx)(ut,{variant:`ghost`,size:`sm`,onClick:()=>k(null),className:`h-9 w-9 shrink-0 rounded-xl p-0`,title:x(`common.close`),"aria-label":x(`common.close`),children:(0,$.jsx)(Me,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{k(null),l(j,e)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[(0,$.jsx)(oe,{className:`h-4 w-4 shrink-0`}),x(`chat.session.renameChat`)]}),m&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{k(null),m(j.id,!j.pinned)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[j.pinned?(0,$.jsx)(me,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(de,{className:`h-4 w-4 shrink-0`}),j.pinned?x(`chat.session.unpinChat`):x(`chat.session.pinChat`)]}),p&&(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{k(null),p(j.id,e)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,children:[(0,$.jsx)(F,{className:`h-4 w-4 shrink-0`}),x(`chat.session.archiveChat`)]}),y&&h.length>0&&(0,$.jsxs)(`div`,{className:`mt-1 border-t border-black/[0.06] pt-1 dark:border-white/[0.07]`,children:[(0,$.jsx)(`p`,{className:`px-3 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-gray-400 dark:text-dark-500`,children:x(`chat.session.folder.move`)}),h.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{k(null),y(j.id,e.id)},className:T(`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-ink hover:bg-interactive-hover`,j.folderId===e.id&&`text-primary-600 dark:text-primary-400`),children:[(0,$.jsx)(L,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)),j.folderId&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{k(null),y(j.id,null)},className:`flex min-h-11 w-full items-center gap-3 rounded-xl px-3 py-2 text-start text-sm text-gray-500 hover:bg-gray-100 dark:text-dark-600 dark:hover:bg-dark-200`,children:[(0,$.jsx)(Me,{className:`h-4 w-4 shrink-0`}),x(`chat.session.folder.remove`)]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{k(null),f(j.id,e)},className:`mt-1 flex min-h-11 w-full items-center gap-3 rounded-xl border-t border-black/[0.06] px-3 py-2 text-start text-sm text-red-500 hover:bg-red-50 dark:border-white/[0.07] dark:hover:bg-red-900/20`,children:[(0,$.jsx)(we,{className:`h-4 w-4 shrink-0`}),x(`chat.session.deleteChat`)]})]})]}),document.body)]})}function ui({user:e,size:t}){let n=t===`sm`?`w-7 h-7`:`w-8 h-8`,r=t===`sm`?`text-xs`:`text-sm`;return e.avatar?(0,$.jsx)(`img`,{src:e.avatar,alt:e.username,className:`${n} rounded-full object-cover ring-1 ring-black/10 dark:ring-white/10`,title:`${e.username} (${e.role})`}):(0,$.jsx)(`div`,{className:`${n} bg-gray-950 dark:bg-white rounded-full flex items-center justify-center`,title:`${e.username} (${e.role})`,children:(0,$.jsx)(`span`,{className:`text-white dark:text-gray-950 ${r} font-medium`,children:e.username.charAt(0).toUpperCase()})})}function di({requiresAuth:e,user:t,isAdmin:n,pendingApprovalCount:r,sidebarCompact:i,userMenuOpen:a,userMenuRef:o,onToggleUserMenu:s,onOpenSettings:c,onOpenAvatar:l,onLogout:u,onMobileNavigate:d,onCloseUserMenu:f}){let{t:p}=S();return!e||!t?null:(0,$.jsx)(`div`,{className:T(`border-t border-black/[0.04] dark:border-white/[0.06]`,`p-2`),children:i?(0,$.jsxs)(`div`,{className:`relative flex flex-col items-center gap-1`,ref:o,children:[(0,$.jsx)(`button`,{type:`button`,onClick:c,className:`flex h-9 w-9 items-center justify-center rounded-full text-ink outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500/30`,title:p(`user.menu.settings`),"aria-label":p(`user.menu.settings`),"data-testid":`sidebar-rail-settings-button`,children:(0,$.jsx)(Ee,{className:`h-[18px] w-[18px]`})}),(0,$.jsxs)(`button`,{type:`button`,onClick:s,className:`relative flex h-9 w-9 items-center justify-center rounded-full outline-none transition-colors hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary-500/30`,"aria-label":t.username,"aria-expanded":a,title:t.username,"data-testid":`sidebar-rail-user-menu-button`,children:[(0,$.jsx)(ui,{user:t,size:`sm`}),r>0&&(0,$.jsx)(`span`,{"data-testid":`pending-user-notification-badge`,className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-error-500 px-1 text-[9px] font-semibold text-white shadow-sm`,"aria-label":p(`userManager.approval.notificationBadge`,{count:r,defaultValue:`{{count}} pending user approvals`}),children:r>99?`99+`:r})]}),a&&(0,$.jsxs)(`div`,{"data-testid":`sidebar-user-menu`,className:`scroll-region absolute bottom-0 start-full z-[70] ms-3 w-64 max-h-[calc(100dvh-1rem)] overflow-y-auto rounded-xl border border-black/[0.04] bg-surface-overlay py-1 shadow-lv3 animate-scale-in scrollbar-thin dark:border-white/[0.06]`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{l(t.avatar||``),f()},className:`flex w-full items-center gap-2.5 border-b border-gray-100 px-3 py-2.5 text-start transition-colors hover:bg-gray-100/70 dark:border-dark-200/50 dark:hover:bg-dark-200/70`,children:[(0,$.jsx)(ui,{user:t,size:`md`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.username}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:p(`user.menu.changePicture`)})]}),(0,$.jsx)(Ie,{className:`h-4 w-4 shrink-0 text-gray-400`})]}),(0,$.jsxs)(`div`,{className:`py-1`,children:[n&&(0,$.jsxs)(y,{to:`/users`,onClick:()=>{f(),d()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-[13px] text-ink transition-colors duration-150 hover:bg-interactive-hover`,children:[(0,$.jsx)(R,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:p(`user.menu.userManagement`)}),r>0&&(0,$.jsx)(`span`,{className:`rounded-md bg-error-500 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:r>99?`99+`:r})]}),n&&(0,$.jsxs)(y,{to:`/system`,onClick:()=>{f(),d()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-[13px] text-ink transition-colors duration-150 hover:bg-interactive-hover`,children:[(0,$.jsx)(I,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:p(`user.menu.system`)})]}),n&&(0,$.jsxs)(y,{to:`/usage`,onClick:()=>{f(),d()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-[13px] text-ink transition-colors duration-150 hover:bg-interactive-hover`,children:[(0,$.jsx)(B,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:p(`user.menu.usageAnalytics`)})]}),(0,$.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200/50`}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{c(),f()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-start text-[13px] text-ink transition-colors hover:bg-interactive-hover`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4 shrink-0`}),p(`user.menu.settings`)]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{u(),f()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-start text-[13px] text-red-600 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:[(0,$.jsx)(Ve,{className:`h-4 w-4 shrink-0`}),p(`user.menu.logout`)]})]})]})]}):(0,$.jsxs)(`div`,{className:`relative`,ref:o,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:c,className:`flex h-[34px] w-full items-center gap-2 rounded-xl px-2.5 text-start text-sm text-ink transition-colors duration-150 hover:bg-interactive-hover touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,"data-testid":`sidebar-settings-button`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4 shrink-0 text-ink-muted`}),p(`user.menu.settings`)]}),(0,$.jsxs)(`button`,{onClick:s,className:`relative h-[38px] w-full rounded-xl px-2.5 hover:bg-interactive-hover transition-colors duration-150 text-start touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ui,{user:t,size:`sm`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm text-ink`,children:t.username}),t.role===`admin`&&(0,$.jsx)(De,{size:11,className:`shrink-0 text-ink-subtle`})]}),(0,$.jsx)(xe,{className:T(`h-4 w-4 text-ink-subtle transition-transform duration-150 rtl:rotate-180`,a&&`rotate-90 rtl:rotate-90`)})]}),n&&r>0&&(0,$.jsx)(`span`,{"data-testid":`pending-user-notification-badge`,className:`absolute -end-1 -top-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-error-500 px-1 text-[10px] font-semibold text-white shadow-subtle`,"aria-label":p(`userManager.approval.notificationBadge`,{count:r,defaultValue:`{{count}} pending user approvals`}),children:r>99?`99+`:r})]}),a&&(0,$.jsxs)(`div`,{"data-testid":`sidebar-user-menu`,className:`scroll-region absolute bottom-full left-0 right-0 z-50 mb-2 max-h-[calc(100dvh-1rem)] rounded-xl border border-black/[0.04] bg-surface-overlay py-1 shadow-lv3 animate-scale-in scrollbar-thin dark:border-white/[0.06]`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-100 dark:border-dark-200/50`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(ui,{user:t,size:`md`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:t.username}),(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t.email||p(`user.profile.noEmail`)})]})]})}),(0,$.jsxs)(`div`,{className:`py-1`,children:[(0,$.jsxs)(`button`,{onClick:()=>{l(t.avatar||``),f()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-ink hover:bg-interactive-hover transition-colors duration-150 text-start`,children:[(0,$.jsx)(Ie,{className:`h-4 w-4 shrink-0`}),p(`user.menu.changePicture`)]}),n&&(0,$.jsxs)(y,{to:`/users`,onClick:()=>{f(),d()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-[13px] text-ink transition-colors duration-150 hover:bg-interactive-hover`,children:[(0,$.jsx)(R,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:p(`user.menu.userManagement`)}),r>0&&(0,$.jsx)(`span`,{className:`rounded-md bg-error-500 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:r>99?`99+`:r})]}),n&&(0,$.jsxs)(y,{to:`/system`,onClick:()=>{f(),d()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-[13px] text-ink transition-colors duration-150 hover:bg-interactive-hover`,children:[(0,$.jsx)(I,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:p(`user.menu.system`)})]}),n&&(0,$.jsxs)(y,{to:`/usage`,onClick:()=>{f(),d()},className:`flex w-full items-center gap-3 px-3 py-2.5 text-[13px] text-ink transition-colors duration-150 hover:bg-interactive-hover`,children:[(0,$.jsx)(B,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-start`,children:p(`user.menu.usageAnalytics`)})]}),(0,$.jsx)(`div`,{className:`border-t border-gray-100 dark:border-dark-200/50 my-1`}),(0,$.jsxs)(`button`,{onClick:()=>{c(),f()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-ink hover:bg-interactive-hover transition-colors duration-150 text-start`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4 shrink-0`}),p(`user.menu.settings`)]}),(0,$.jsxs)(`button`,{onClick:()=>{u(),f()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors duration-150 text-start`,children:[(0,$.jsx)(Ve,{className:`h-4 w-4 shrink-0`}),p(`user.menu.logout`)]})]})]})]})})}var fi={idle:{labelKey:`work.statusLabels.idle`,label:`Idle`,color:`rgb(255, 255, 255)`,animated:!1},preparing:{labelKey:`work.statusLabels.thinking`,label:`Thinking`,color:`rgb(48, 121, 255)`,animated:!0},running:{labelKey:`work.statusLabels.thinking`,label:`Thinking`,color:`rgb(48, 121, 255)`,animated:!0},completed:{labelKey:`work.statusLabels.complete`,label:`Complete`,color:`rgb(76, 212, 117)`,animated:!1},needs_input:{labelKey:`work.statusLabels.needsInput`,label:`Needs input`,color:`rgb(255, 204, 0)`,animated:!1},cancelled:{labelKey:`work.statusLabels.needsInput`,label:`Needs input`,color:`rgb(255, 204, 0)`,animated:!1},failed:{labelKey:`work.statusLabels.error`,label:`Error`,color:`rgb(255, 61, 129)`,animated:!1}};function pi(e){let t=e.trim().split(/\s+/u).filter(Boolean);return t.length===0?`•`:t.length===1?Array.from(t[0]).slice(0,2).join(``).toLocaleUpperCase():`${Array.from(t[0])[0]}${Array.from(t[t.length-1])[0]}`.toLocaleUpperCase()}function mi({tasks:e,currentTaskId:t,loading:n,actionLoading:r,sidebarCompact:i,onSelectTask:a,onDeleteTask:o,onExpandSidebar:s}){let{t:c,i18n:l}=S(),u=[...e].sort((e,t)=>t.updatedAt-e.updatedAt);return(0,$.jsx)(`div`,{"data-testid":`sidebar-work-task-scroll-region`,className:`scroll-region min-h-0 flex-1 border-t border-black/[0.05] scrollbar-thin dark:border-white/[0.05]`,style:{willChange:`scroll-position`},children:(0,$.jsxs)(`div`,{className:T(`px-3 py-3`,i&&`px-2`),children:[!i&&e.length>0&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between px-1`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-ink-subtle`,children:c(`work.tasks.title`,{defaultValue:`Work tasks`})}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-gray-400 dark:text-dark-500`,children:e.length})]}),i?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:s,"data-testid":`sidebar-mobile-work-tasks`,"aria-label":`${c(`work.tasks.title`,{defaultValue:`Work tasks`})} (${e.length})`,title:c(`work.tasks.title`,{defaultValue:`Work tasks`}),className:`relative flex h-12 w-12 items-center justify-center rounded-xl text-gray-500 outline-none transition-colors hover:bg-white/70 hover:text-gray-950 focus-visible:ring-2 focus-visible:ring-primary-500/30 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950 md:hidden`,children:[(0,$.jsx)(Te,{className:`h-[18px] w-[18px]`}),e.length>0&&(0,$.jsx)(`span`,{className:`absolute -end-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-md bg-primary-500 px-1 text-[9px] font-semibold tabular-nums text-white shadow-sm`,children:e.length>99?`99+`:e.length})]}),(0,$.jsx)(`div`,{"data-testid":`sidebar-compact-work-task-list`,className:`flex w-full flex-col items-center gap-1`,children:u.map(e=>{let n=t===e.id,r=fi[e.status],i=e.title||c(`work.tasks.untitled`,{defaultValue:`Untitled task`});return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"data-testid":`sidebar-compact-work-task`,"aria-current":n?`page`:void 0,"aria-label":i,title:i,className:T(`relative flex h-12 w-12 items-center justify-center rounded-xl outline-none transition-colors focus-visible:ring-2 focus-visible:ring-primary-500/30`,n?`bg-primary-500/10 text-primary-700 ring-1 ring-primary-500/10 dark:bg-primary-500/15 dark:text-primary-300 dark:ring-primary-400/10`:`text-gray-500 hover:bg-white/70 hover:text-gray-950 dark:text-dark-600 dark:hover:bg-dark-200 dark:hover:text-dark-950`),children:[n&&(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -start-2 h-5 w-0.5 rounded-full bg-primary-500 shadow-[0_0_12px_rgb(var(--color-primary-500)/0.55)]`}),(0,$.jsx)(`span`,{className:`font-mono text-[11px] font-semibold tracking-[-0.03em]`,children:pi(i)}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:T(`absolute bottom-1.5 end-1.5 h-2 w-2 rounded-full border-2 border-gray-100 dark:border-dark-50`,r.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:r.color}})]},e.id)})})]}):n&&e.length===0?(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center justify-center py-10 text-gray-400 dark:text-dark-500`,children:[(0,$.jsx)(Ce,{"aria-hidden":`true`,className:`h-5 w-5 animate-spin`}),(0,$.jsx)(`span`,{className:`sr-only`,children:c(`work.tasks.loading`,{defaultValue:`Loading Work tasks`})})]}):e.length===0?(0,$.jsxs)(`div`,{className:T(`py-8 text-center`,i?`px-1`:`px-2`),children:[(0,$.jsx)(`div`,{className:T(`mx-auto mb-3 flex items-center justify-center rounded-xl bg-white/70 ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`,i?`h-8 w-8`:`h-12 w-12`),children:(0,$.jsx)(Te,{className:T(`text-gray-400 dark:text-gray-500`,i?`h-4 w-4`:`h-5 w-5`)})}),!i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:c(`work.tasks.emptyTitle`,{defaultValue:`No Work tasks yet`})}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:c(`work.tasks.empty`,{defaultValue:`Your Work tasks will appear here after you send the first message.`})})]})]}):(0,$.jsx)(`div`,{"data-testid":`sidebar-work-task-list`,className:T(`space-y-0.5`,i&&`space-y-1`),children:e.map(e=>{let n=t===e.id,s=fi[e.status],u=c(s.labelKey,{defaultValue:s.label});return(0,$.jsxs)(`div`,{"data-testid":`sidebar-work-task-item`,"data-task-id":e.id,className:T(`group relative transition-colors duration-150 outline-none`,i?`flex items-center justify-center rounded-xl p-1`:`rounded-lg px-2`,n?`bg-interactive-active`:`hover:bg-interactive-hover`),children:[(0,$.jsxs)(`button`,{type:`button`,"aria-current":n?`page`:void 0,className:T(`w-full text-start outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,i&&`flex h-10 items-center justify-center`),title:i?`${e.title} · ${e.model}`:void 0,onClick:()=>a(e.id),children:[i?(0,$.jsxs)(`span`,{className:T(`relative flex h-9 w-9 items-center justify-center rounded-xl text-[11px] font-semibold uppercase transition-colors`,n?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`bg-white/70 text-gray-500 ring-1 ring-black/[0.04] dark:bg-dark-200/70 dark:text-dark-600 dark:ring-white/[0.05]`),children:[e.title.trim().charAt(0)||`•`,(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":u,className:T(`absolute -bottom-0.5 -end-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-100 dark:border-dark-50`,s.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:s.color}})]}):(0,$.jsxs)(`span`,{className:`flex h-8 items-center gap-2`,title:`${e.title} · ${e.model}`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":u,className:T(`h-2 w-2 shrink-0 rounded-full`,s.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:s.color}}),(0,$.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1 truncate text-sm leading-5 text-ink`,children:w(e.title||c(`work.tasks.untitled`,{defaultValue:`Untitled task`}),40)}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs leading-5 tabular-nums text-ink-subtle group-hover:hidden group-focus-within:hidden`,children:ee(e.updatedAt,l.language)})]}),(0,$.jsx)(`span`,{className:`sr-only`,children:c(`work.tasks.status`,{defaultValue:`Status: {{status}}`,status:u})})]}),!i&&(0,$.jsx)(`button`,{type:`button`,"data-testid":`sidebar-work-task-delete`,disabled:r,className:T(`absolute end-2 top-1/2 -translate-y-1/2 rounded-lg p-1.5 text-gray-400 transition-[color,background-color,opacity] hover:bg-error-500/10 hover:text-error-600 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-error-500/30 disabled:cursor-not-allowed disabled:opacity-40 group-focus-within:opacity-100 group-hover:opacity-100 dark:text-dark-500`,n?`opacity-100`:`opacity-0`),"aria-label":c(`work.tasks.deleteNamed`,{defaultValue:`Delete {{title}}`,title:e.title||c(`work.tasks.untitled`,{defaultValue:`Untitled task`})}),onClick:t=>{t.stopPropagation(),o(e)},children:(0,$.jsx)(we,{"aria-hidden":`true`,className:`h-3.5 w-3.5`})})]},e.id)})})]})})}function hi(e){let{t}=S(),n=(0,Q.useRef)(null),r=Br({queryKey:[`users`,`pending-approvals`],enabled:e,queryFn:async()=>{let e=await et.getPendingApprovals();if(!e.success||!e.data)throw Error(e.message||`Could not load pending accounts`);return e.data},refetchInterval:6e4,refetchOnWindowFocus:!0});return(0,Q.useEffect)(()=>{if(!r.data)return;let e=n.current,i=e?!!(r.data.count>e.count||r.data.latestCreatedAt&&r.data.latestCreatedAt!==e.latestCreatedAt):r.data.count>0;n.current=r.data,i&&P(t(`userManager.approval.notification`,{count:r.data.count,defaultValue:`{{count}} registration(s) are waiting for your approval.`}),{icon:`👤`})},[r.data,t]),{...r,pendingApprovalCount:r.data?.count??0}}var gi=Ze(`components:sidebar`),_i=Q.lazy(()=>f(()=>import(`../js/SettingsModal-B4RelkLP.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]))),vi=({isOpen:e,onClose:t,className:n})=>{let{t:r}=S(),i=b(),a=l(),{sessions:o,deleteSession:s,updateSessionTitle:c,setSessionArchived:u,setSessionPinned:d,folders:f,loadFolders:p,createFolder:m,renameFolder:h,deleteFolder:g,moveSessionToFolder:_,selectedModel:v,models:y,currentSession:x,generatingTitleForSession:C,personas:ee}=A(),w=ot(e=>e.tasks),E=ot(e=>e.loadingTasks),D=ot(e=>e.actionLoading),O=ot(e=>e.deleteTask),{user:k,isAdmin:j,systemInfo:M,setUser:N,canUseWork:te,canUseAgents:ne}=H(),{backgroundImage:re,sidebarCompact:F,toggleSidebarCompact:ie}=st(),ae=j(),{pendingApprovalCount:oe}=hi(!!(k&&ae&&M?.requiresAuth)),[se,I]=(0,Q.useState)(null),[L,ce]=(0,Q.useState)(``),[le,ue]=(0,Q.useState)(!1),[de,fe]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)(!1),[he,ge]=(0,Q.useState)(``),[_e,ve]=(0,Q.useState)(!1),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),R=i.pathname.match(/^\/c\/([^/]+)$/)?.[1]||x?.id,xe=()=>{window.innerWidth<768&&!F&&ie()},Se=()=>{lt(`selection`),ie()},z=()=>{let{setCurrentSession:e}=A.getState();ct(),e(null),sessionStorage.setItem(`forceWelcomeScreen`,`true`)};(0,Q.useEffect)(()=>{let e=e=>{ye.current&&!ye.current.contains(e.target)&&fe(!1)};if(de)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[de]),(0,Q.useEffect)(()=>{let t=t=>{be.current&&!be.current.contains(t.target)&&window.innerWidth<768&&e&&!F&&ie()};if(e&&!F&&window.innerWidth<768)return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[e,F,ie]);let B=async()=>{ve(!0);try{let e=await et.updateMyAvatar(he||null);e.success&&e.data?(N(e.data),P.success(r(`user.avatar.updated`)),me(!1)):P.error(e.message||r(`user.avatar.updateFailed`))}catch(e){gi.error(`Failed to update avatar:`,e),P.error(r(`user.avatar.updateFailed`))}finally{ve(!1)}},Ce=()=>{lt(`impact`),z(),a(`/chat`,{replace:!0}),xe()},we=()=>{lt(`impact`),ot.getState().clearError(),a(`/work`),xe()},Te=e=>{lt(`selection`),a(`/c/${e.id}`,{replace:!0}),xe()},Ee=e=>{lt(`selection`),a(`/work/${e}`,{replace:!0}),xe()},V=async e=>{if(window.confirm(r(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:e.title||r(`work.tasks.untitled`,{defaultValue:`Untitled task`})}))){lt(`warning`);try{await O(e.id),it(e.id),Kr.getState().closeTab(`work:${e.id}`),Re===e.id&&a(`/work`,{replace:!0,state:{deletedWorkTaskId:e.id}})}catch(e){gi.error(`Failed to delete Work task:`,e),P.error(r(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`}))}}},De=async(e,t)=>{if(t.stopPropagation(),gi.debug(`Delete session clicked:`,e),window.confirm(r(`chat.session.deleteConfirm`))){lt(`warning`);try{gi.debug(`Attempting to delete session:`,e);let t=R===e;if(await s(e),gi.debug(`Session deleted successfully`),Kr.getState().closeTab(`chat:${e}`),t){let t=o.filter(t=>t.id!==e);t.length>0?a(`/c/${t[0].id}`,{replace:!0}):a(`/`,{replace:!0})}}catch(e){gi.error(`Error deleting session:`,e)}}};(0,Q.useEffect)(()=>{p()},[p]);let Oe=async(e,t)=>{if(t.stopPropagation(),await u(e,!0),Kr.getState().closeTab(`chat:${e}`),R===e){let t=o.filter(t=>t.id!==e&&!t.archived);t.length>0?a(`/c/${t[0].id}`,{replace:!0}):a(`/`,{replace:!0})}},ke=(e,t)=>{d(e,t)},Ae=(e,t)=>{t.stopPropagation(),I(e.id),ce(e.title)},je=async e=>{L.trim()&&await c(e,L.trim()),I(null),ce(``)},Me=()=>{I(null),ce(``)},Ne=async()=>{try{await $e.logout();let{logout:e}=H.getState();e(),a(`/login`),P.success(r(`auth.logout.success`))}catch(e){gi.error(`Logout error:`,e);let{logout:t}=H.getState();t(),a(`/login`)}},Pe=()=>{ue(!0),xe()},Fe=e=>{ge(e),me(!0)},Ie=window.location.protocol===`file:`,Le=i.pathname===`/work`||i.pathname.startsWith(`/work/`),Re=i.pathname.match(/^\/work\/([^/]+)$/)?.[1]||null,ze=i.pathname===`/`||i.pathname===`/chat`||i.pathname.startsWith(`/c/`),Be=te();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{ref:be,"data-testid":`sidebar`,className:T(`fixed inset-y-0 start-0 z-50 border-e border-black/[0.04] dark:border-white/[0.06] transform transition-[width,transform,background-color] duration-200 ease-out shadow-[0_24px_80px_rgba(15,23,42,0.12)]`,F?`w-16`:`w-72 max-sm:w-[calc(100vw-4.5rem)] max-sm:max-w-80`,e?`translate-x-0`:`ltr:-translate-x-full rtl:translate-x-full`,`lg:shadow-none`,re?`bg-sidebar/75 backdrop-blur-xl`:`bg-sidebar`,`overscroll-behavior-contain`,n),style:{WebkitOverflowScrolling:`touch`},children:[Ie&&(0,$.jsx)(`div`,{className:`absolute top-0 start-16 end-0 h-8 z-[60]`,style:{WebkitAppRegion:`drag`}}),(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsx)(ni,{sidebarCompact:F,isElectron:Ie,showWork:Be,activeMode:Le?`work`:ze?`chat`:null,selectedModel:v,modelCount:y.length,onToggleCompact:Se,onStartWork:we,onCreateSession:Ce}),!F&&(0,$.jsx)(ii,{sidebarCompact:F,activePath:i.pathname,showAgents:ne(),onMobileNavigate:xe}),Le&&Be?(0,$.jsx)(mi,{tasks:w,currentTaskId:Re,loading:E,actionLoading:D,sidebarCompact:F,onSelectTask:Ee,onDeleteTask:e=>void V(e),onExpandSidebar:Se}):(0,$.jsx)(li,{sessions:o.filter(e=>!e.archived),personas:ee,currentSessionId:R,generatingTitleForSession:C,sidebarCompact:F,editingSessionId:se,editingTitle:L,onEditingTitleChange:ce,onSelectSession:Te,onStartEditing:Ae,onSaveEdit:je,onCancelEdit:Me,onDeleteSession:De,onArchiveSession:Oe,onTogglePinSession:ke,folders:f,onCreateFolder:e=>void m(e),onRenameFolder:(e,t)=>void h(e,t),onDeleteFolder:e=>void g(e),onMoveSession:(e,t)=>void _(e,t),onExpandSidebar:Se}),(0,$.jsx)(di,{requiresAuth:M?.requiresAuth,user:k,isAdmin:ae,pendingApprovalCount:oe,sidebarCompact:F,userMenuOpen:de,userMenuRef:ye,onToggleUserMenu:()=>fe(e=>!e),onOpenSettings:Pe,onOpenAvatar:Fe,onLogout:Ne,onMobileNavigate:xe,onCloseUserMenu:()=>fe(!1)})]})]}),le&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(_i,{isOpen:le,onClose:()=>ue(!1)})}),(0,$.jsx)(Xr,{open:pe,value:he,saving:_e,onChange:ge,onClose:()=>me(!1),onSave:B})]})},yi=({children:e,requireAuth:t=!0,requireAdmin:n=!1,requireWork:r=!1,requireAgents:i=!1})=>{let{isAuthenticated:a,user:o,systemInfo:c,isLoading:l,canUseWork:u}=H();return b(),l?(0,$.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 dark:bg-dark-50`,children:(0,$.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-dark-300 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}):i&&c?.agentsEnabled!==!0?(0,$.jsx)(s,{to:`/`,replace:!0}):c&&!c.requiresAuth?(0,$.jsx)($.Fragment,{children:e}):t&&!a?(0,$.jsx)(s,{to:`/login`,replace:!0}):n&&(!o||o.role!==`admin`)||r&&!u()?(0,$.jsx)(s,{to:`/`,replace:!0}):(0,$.jsx)($.Fragment,{children:e})},bi=Ze(`components:error-boundary`),xi=({error:e})=>{let{t}=S();return(0,$.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center p-4 text-gray-900 dark:text-dark-800`,children:(0,$.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-gray-200 dark:border-dark-300 bg-white/95 dark:bg-dark-100/95 shadow-card backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,$.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-primary-100 text-primary-700 dark:bg-primary-900/35 dark:text-primary-300 ring-1 ring-primary-200 dark:ring-primary-800/60`,children:(0,$.jsx)(Fe,{className:`h-6 w-6`})}),(0,$.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-gray-950 dark:text-dark-950`,children:t(`errorBoundary.title`)}),(0,$.jsx)(`p`,{className:`mb-5 text-sm leading-6 text-gray-600 dark:text-dark-600`,children:t(`errorBoundary.description`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-center`,children:[(0,$.jsxs)(`button`,{onClick:()=>window.location.reload(),className:`inline-flex items-center justify-center gap-2 rounded-xl bg-primary-600 px-4 py-2.5 text-sm font-medium text-white shadow-sm transition-all hover:bg-primary-700 hover:shadow-md focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-100`,children:[(0,$.jsx)(Ke,{className:`h-4 w-4`}),t(`errorBoundary.tryAgain`)]}),(0,$.jsxs)(`button`,{onClick:()=>{window.location.assign(`/`)},className:`inline-flex items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm transition-all hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-700 dark:hover:bg-dark-200 dark:focus:ring-offset-dark-100`,children:[(0,$.jsx)(Ge,{className:`h-4 w-4`}),t(`common.home`,`Home`)]})]}),!1]})})})},Si=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){bi.error(`ErrorBoundary caught an error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,$.jsx)(xi,{error:this.state.error}):this.props.children}},Ci=({notes:e,onDismiss:t})=>{let{t:r}=S();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,"aria-label":r(`whatsNew.title`),onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,$.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,$.jsxs)(`div`,{className:`flex items-start justify-between px-6 pb-3 pt-6`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-xl font-semibold tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:r(`whatsNew.title`)}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[r(`whatsNew.releaseNotes`),` · v`,e.version,` · `,e.date]})]}),(0,$.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/[0.06] dark:hover:text-dark-900`,title:r(`common.close`),children:(0,$.jsx)(Me,{className:`h-4 w-4`})})]}),(0,$.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-6 py-3 scrollbar-thin`,children:(0,$.jsx)(n,{components:{h3:({children:e})=>(0,$.jsx)(`h3`,{className:`mb-2 mt-5 text-[11px] font-semibold uppercase tracking-[0.1em] text-primary-600 first:mt-0 dark:text-primary-400`,children:e}),ul:({children:e})=>(0,$.jsx)(`ul`,{className:`space-y-2.5`,children:e}),li:({children:e})=>(0,$.jsxs)(`li`,{className:`flex gap-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:[(0,$.jsx)(`span`,{className:`mt-[7px] h-1 w-1 shrink-0 rounded-full bg-gray-300 dark:bg-dark-400`}),(0,$.jsx)(`span`,{className:`min-w-0`,children:e})]}),strong:({children:e})=>(0,$.jsx)(`strong`,{className:`font-semibold text-gray-900 dark:text-dark-900`,children:e}),a:({children:e,href:t})=>(0,$.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,$.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,$.jsx)(`p`,{className:`mb-2 text-[13.5px] leading-relaxed text-gray-700 dark:text-dark-700`,children:e})},children:e.body})}),(0,$.jsx)(`div`,{className:`flex justify-end border-t border-gray-200/70 px-6 py-4 dark:border-white/[0.08]`,children:(0,$.jsx)(ut,{onClick:t,size:`sm`,children:r(`whatsNew.cta`)})})]})})]})},wi=`libre-webui:whats-new-seen`;function Ti(){let e={version:`0.24.0`,date:`2026-08-18`,body:`Control over how models answer, and a clearer view of what they are working with: a thinking level per chat, a context meter in the composer, an administrator model catalog, and long conversations that compact themselves.
|
|
3
|
-
|
|
4
|
-
### ✨ New Features
|
|
5
|
-
|
|
6
|
-
- **Set how hard a model thinks.** A control in the composer opens the reasoning levels (off, on, low, medium, high) for the chat you are in, on the new chat screen as well, and the same setting lives in the chat controls panel and in Settings → Generation as a default for new replies. One value travels with the chat and is translated at each provider boundary: Ollama takes it in the request body, OpenAI-style providers take a reasoning effort, the Responses API takes its own field, and Anthropic and Gemini take a token budget with room reserved for the answer. Nothing is sent when the setting is unset, so a model you never configure behaves exactly as before, and a model Ollama reports as unable to reason is never asked to. (#205, Zack Young)
|
|
7
|
-
- **See how full the context window is.** A ring beside the model name fills as the conversation grows; hovering it reports how full, the tokens used, and the window they run against. The count is what the provider measured for the last reply where it reported one, and an estimate at four characters per token before that, marked as an estimate. A window capped below what the model was trained for says so, which is what explains a 32k reading on a model trained for 262k.
|
|
8
|
-
- **Context windows for provider models.** Model discovery now keeps the context window a provider publishes with its listing, reading whichever field that provider uses, so the meter has something to measure against on hosted models and not only on Ollama. Catalogs stored before this release are refreshed once instead of waiting out their refresh interval.
|
|
9
|
-
- **Administrator model catalog.** Settings → Models gains a searchable catalog where administrators choose which models everyone sees, the order they appear in, and the name and picture each one carries. Hiding a model applies immediately, dragging shows where it will land, and a default model can be set for the deployment.
|
|
10
|
-
- **Long conversations compact themselves.** Past a token threshold, older turns are replaced by a summary that carries the goals, decisions, facts, and open questions forward, keeping a long chat inside the model's window instead of failing at it. Administrators control the threshold, the model that writes the summary, and the prompt.
|
|
11
|
-
- **Code blocks read like code while they stream.** Line numbers and syntax highlighting now apply to a reply as it arrives, rather than only once it has finished.
|
|
12
|
-
- **Model names and pictures in the chat.** The picker and each assistant message show the model's configured name and picture. A reply that is still streaming has no model stamped on it yet, so it shows the chat's own model rather than the generic word Assistant.
|
|
13
|
-
|
|
14
|
-
### 🔧 Improvements
|
|
15
|
-
|
|
16
|
-
- Titles and follow-up suggestions never spend a reasoning pass, whatever the chat is set to.
|
|
17
|
-
- The About screen names the mirror correctly as Forgejo and links to project sponsorship.
|
|
18
|
-
- The Vite configuration reads its own directory through \`import.meta\`, so builds no longer warn about an unsupported configuration feature.
|
|
19
|
-
- All new interface text is translated in all 25 languages.
|
|
20
|
-
|
|
21
|
-
### 🐛 Bug Fixes
|
|
22
|
-
|
|
23
|
-
- **Reasoning models can name a chat.** A model that thinks before answering spent its whole allowance on reasoning and returned empty content, so the chat fell back to a message preview for its title. Local models are asked not to reason for this, and providers that cannot be told that are given room to think and still answer.
|
|
24
|
-
- **A long reply no longer fails its durable job and regenerates.** Progress events carried the whole accumulated reply, so a long answer hit the durable event size ceiling and the interface responded by generating the same reply again. Completion events are bounded and oversized deltas are split across ordered events.
|
|
25
|
-
- **Token counts and timings appear for provider-backed replies.** Streams never asked for usage, so nothing was reported, and the timings llama.cpp returns beside the counts were dropped on the way through.
|
|
26
|
-
- **Work rounds that only reason keep their context and finish.** A round that produced reasoning and no visible text lost that context instead of completing with it.
|
|
27
|
-
- **The workspace file list retries quietly while a sandbox is preparing.** It used to report a failure for a sandbox that was simply not ready yet.
|
|
28
|
-
- Three interface render fixes: mount-time loaders no longer force a second synchronous render, a streaming code block no longer rebuilds and resets its scroll mid-stream, and the durable reload effect no longer misses a dependency.
|
|
29
|
-
|
|
30
|
-
### 🔒 Security & Dependencies
|
|
31
|
-
|
|
32
|
-
- Dependencies refreshed across the workspace: \`@kubernetes/client-node\` 2.0 (a major upgrade, with the Work Kubernetes driver verified against it), \`framer-motion\` 13.1, \`katex\` 0.18.4, \`papaparse\` 5.6, \`zustand\` 5.0.15, \`tsx\`, and \`eslint-plugin-react-refresh\`, along with AWS SDK and TypeScript ESLint updates resolved in the lockfile.`},[t,n]=(0,Q.useState)(()=>{if(!e||typeof window>`u`)return!1;try{return window.localStorage.getItem(wi)!==e.version}catch{return!1}});return{open:t,dismiss:()=>{if(n(!1),e)try{window.localStorage.setItem(wi,e.version)}catch{}},notes:e}}var Ei=({message:e=`This is a demo version for presentation purposes only. The Ollama backend is not connected.`,onDismiss:t,className:n})=>{let[r,i]=(0,Q.useState)(!1),{t:a}=S();return r?null:(0,$.jsx)(`div`,{className:T(`bg-gray-950 text-white dark:bg-white dark:text-gray-950`,`border-b border-black/10 dark:border-white/10`,`px-4 py-2`,n),children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between max-w-6xl mx-auto gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex-shrink-0`,children:(0,$.jsx)(Ue,{className:`h-4 w-4 text-white/65 dark:text-gray-950/60`})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`p`,{className:`shrink-0 text-xs font-semibold tracking-wide`,children:a(`demoMode.title`)}),(0,$.jsx)(`p`,{className:`hidden truncate text-xs text-white/60 dark:text-gray-950/60 sm:block`,children:e})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,$.jsxs)(ut,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-white/70 hover:bg-white/10 hover:text-white dark:text-gray-950/70 dark:hover:bg-black/[0.06] dark:hover:text-gray-950`,onClick:()=>window.open(`https://github.com/libre-webui/libre-webui`,`_blank`),title:`View on GitHub`,children:[(0,$.jsx)(ie,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`ml-1 hidden sm:inline`,children:a(`demoMode.github`)})]}),(0,$.jsx)(ut,{variant:`ghost`,size:`sm`,onClick:()=>{i(!0),t?.()},className:`h-8 w-8 p-0 text-white/70 hover:bg-white/10 hover:text-white dark:text-gray-950/70 dark:hover:bg-black/[0.06] dark:hover:text-gray-950`,title:`Dismiss`,children:(0,$.jsx)(Me,{className:`h-4 w-4`})})]})]})})},Di=()=>{let{preferences:e,backgroundImage:t}=st(),n=e.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},r=t||n.imageUrl;return!n.enabled||!r?null:(0,$.jsx)(`div`,{"data-testid":`app-background`,className:`fixed inset-0 pointer-events-none z-0`,style:{backgroundImage:`url(${r})`,backgroundSize:`cover`,backgroundPosition:`center`,backgroundRepeat:`no-repeat`,filter:`blur(${n.blurAmount}px)`,opacity:n.opacity,transform:`scale(1.1)`}})},Oi=e=>{ct(),A.getState().setCurrentSession(null),sessionStorage.setItem(`forceWelcomeScreen`,`true`),e(`/chat`)},ki=e=>{ct(),A.getState().setCurrentSession(null),sessionStorage.removeItem(`pendingMessage`),sessionStorage.setItem(`forceWelcomeScreen`,`true`),e(`/chat?incognito=1`)},Ai=e=>{ot.getState().clearError(),e(`/work`)},ji={"/notes":{icon:M,labelKey:`sidebar.navigation.notes`},"/models":{icon:ae,labelKey:`sidebar.navigation.models`},"/personas":{icon:R,labelKey:`sidebar.navigation.personas`},"/gallery":{icon:re,labelKey:`sidebar.navigation.imagine`},"/agents":{icon:be,labelKey:`sidebar.navigation.agents`},"/users":{icon:Re,labelKey:`sidebar.navigation.userManagement`},"/usage":{icon:B,labelKey:`usageAnalytics.title`},"/system":{icon:I,labelKey:`systemPage.title`},"/artifacts":{icon:ue,labelKey:`tabs.artifacts`}},Mi=e=>e.kind===`home`?Ge:e.kind===`chat`?Pe:e.kind===`work`?Te:ji[e.path]?.icon??ue,Ni=()=>C()?`⌘`:`Ctrl`,Pi=new Set([`/agents`,`/users`,`/usage`,`/system`]),Fi=(e,t)=>e.kind===`work`?!t:Pi.has(e.path),Ii=()=>{let{t:e}=S(),t=b(),n=l(),r=Kr(e=>e.tabs),i=Kr(e=>e.activeTabId),a=Kr(e=>e.syncWithPath),o=Kr(e=>e.closeTab),s=Kr(e=>e.closeTabs),c=A(e=>e.sessions),u=A(e=>e.currentSession),d=ot(e=>e.tasks),{systemInfo:f,isAdmin:p,canUseWork:m,canUseAgents:h}=H(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[x,C]=(0,Q.useState)(null),ee=(0,Q.useRef)(null),w=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useRef)(null),k=p(),j=f?.requiresAuth===!1||k,M=m(),N=j?r:r.filter(e=>!Fi(e,M));(0,Q.useEffect)(()=>{a(t.pathname)},[t.pathname,a]),(0,Q.useEffect)(()=>{(O.current?.querySelector(`[data-active="true"]`))?.scrollIntoView({block:`nearest`,inline:`nearest`})},[N.length,i]),(0,Q.useEffect)(()=>{if(!f||j)return;let e=r.filter(e=>Fi(e,M)).map(e=>e.id);if(e.length===0)return;let t=s(e,`home`);t&&n(t.path,{replace:!0})},[s,n,j,M,f,r]),(0,Q.useEffect)(()=>{if(!g&&!x)return;let e=e=>{let t=e.target;!ee.current?.contains(t)&&!w.current?.contains(t)&&!D.current?.contains(t)&&(_(!1),C(null))},t=e=>{e.key===`Escape`&&(_(!1),C(null))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[x,g]),(0,Q.useEffect)(()=>{if(!g)return;let e=()=>{let e=E.current;if(!e)return;let t=e.getBoundingClientRect(),n=e.closest(`[data-testid="app-shell-content"]`)?.getBoundingClientRect(),r=n?.left??0,i=n?.right??window.innerWidth,a=r+8,o=i-8,s=Math.max(0,Math.min(224,o-a)),c=o-t.left>=s?t.left:t.right-s,l=Math.max(a,Math.min(c,o-s));y({left:l,top:t.bottom+4,width:s})};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[g]),(0,Q.useEffect)(()=>{x&&D.current?.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()},[x]);let P=t=>{if(t.kind===`home`)return e(`tabs.home`,`Home`);if(t.kind===`chat`){if(t.id===`chat:new`)return u?.isPrivate?e(`chat.session.incognito`,`Incognito Chat`):e(`tabs.newChat`,`New Chat`);let n=t.id.slice(5);return c.find(e=>e.id===n)?.title||e(`tabs.chat`,`Chat`)}if(t.kind===`work`){if(t.id===`work:new`)return e(`tabs.work`,`Work`);let n=t.id.slice(5);return d.find(e=>e.id===n)?.title||e(`tabs.work`,`Work`)}let n=ji[t.path];return n?e(n.labelKey,t.path.slice(1)):t.path.slice(1)},re=(e,t)=>{e.stopPropagation(),e.preventDefault();let r=o(t.id);r&&n(r.path)},F=(e,t,n)=>{_(!1),C({tabId:e.id,x:Math.max(8,Math.min(t,window.innerWidth-224-8)),y:Math.max(8,Math.min(n,window.innerHeight-176-8))})},ie=(e,t)=>{e.preventDefault(),e.stopPropagation(),F(t,e.clientX,e.clientY)},ae=(e,t)=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect();F(t,n.left+12,n.bottom+4)},oe=e=>{let t=Array.from(D.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]);if(t.length===0)return;let n=t.indexOf(document.activeElement),r=n;if(e.key===`ArrowDown`)r=(n+1+t.length)%t.length;else if(e.key===`ArrowUp`)r=(n-1+t.length)%t.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else return;e.preventDefault(),t[r]?.focus()},se=(e,t)=>{let r=s(e,t);C(null),r&&n(r.path)},I=[{key:`chat`,label:e(`tabs.newChat`,`New Chat`),icon:Pe,shortcut:`${Ni()}⇧O`,action:()=>Oi(n)},{key:`incognito-chat`,label:e(`chat.session.incognito`,`Incognito Chat`),icon:te,action:()=>ki(n)},...M?[{key:`work`,label:e(`tabs.newWork`,`New Work`),icon:Te,shortcut:`${Ni()}⇧U`,action:()=>Ai(n)}]:[],...[`/notes`,`/models`,`/personas`,`/gallery`].map(t=>({key:t,label:e(ji[t].labelKey,t.slice(1)),icon:ji[t].icon,action:()=>n(t)})),...h()?[{key:`/agents`,label:e(ji[`/agents`].labelKey,`Agents`),icon:ji[`/agents`].icon,separatorBefore:!0,action:()=>n(`/agents`)}]:[],...k?[`/users`,`/system`,`/usage`].map(t=>({key:t,label:e(ji[t].labelKey,t.slice(1)),icon:ji[t].icon,action:()=>n(t)})):[]],L=x?N.find(e=>e.id===x.tabId):void 0,ce=L?N.findIndex(e=>e.id===L.id):-1,le=L?N.filter(e=>e.id!==`home`&&e.id!==L.id).map(e=>e.id):[],ue=ce>=0?N.slice(ce+1).filter(e=>e.id!==`home`).map(e=>e.id):[],de=N.filter(e=>e.id!==`home`).map(e=>e.id);return(0,$.jsxs)(`div`,{"data-testid":`app-tab-bar`,className:`relative z-20 flex h-9 flex-none items-center gap-1 px-1 pb-1 lg:px-0`,children:[(0,$.jsx)(`div`,{ref:O,role:`tablist`,"aria-label":e(`tabs.label`,`Open tabs`),className:`flex min-w-0 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:N.map(t=>{let r=t.id===`chat:new`&&u?.isPrivate?te:Mi(t),a=t.id===i;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,"data-active":a||void 0,"data-tab-id":t.id,"data-testid":`app-tab`,title:P(t),onClick:()=>n(t.path),onContextMenu:e=>ie(e,t),onKeyDown:e=>ae(e,t),onAuxClick:e=>{e.button===1&&t.id!==`home`&&re(e,t)},className:T(`group flex h-7 min-w-0 flex-none items-center gap-1.5 rounded-lg border text-[13px] transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,t.id===`home`?`px-2.5`:`ps-2.5 pe-1`,a?`border-black/[0.06] bg-gray-50 text-gray-950 shadow-subtle dark:border-white/[0.07] dark:bg-dark-100 dark:text-dark-950`:`border-transparent text-gray-500 hover:bg-white/60 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-dark-200/60 dark:hover:text-dark-900`),children:[(0,$.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`max-w-[9rem] truncate`,children:P(t)}),t.id!==`home`&&(0,$.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":e(`tabs.close`,`Close tab`),"data-testid":`app-tab-close`,onClick:e=>re(e,t),className:T(`flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-gray-400 transition-opacity hover:bg-black/[0.06] hover:text-gray-700 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-800`,a?`opacity-100`:`sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-visible:opacity-100`),children:(0,$.jsx)(Me,{className:`h-3 w-3`})})]},t.id)})}),x&&L&&(0,qr.createPortal)((0,$.jsxs)(`div`,{ref:D,role:`menu`,"aria-label":e(`tabs.actions`,`Tab actions`),"data-testid":`app-tab-context-menu`,onContextMenu:e=>e.preventDefault(),onKeyDown:oe,className:`fixed z-[100] w-56 rounded-xl border border-line bg-surface-overlay/95 p-1 shadow-overlay backdrop-blur-xl animate-fade-in motion-reduce:animate-none`,style:{left:x.x,top:x.y},children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close`,disabled:L.id===`home`,onClick:()=>{let e=o(L.id);C(null),e&&n(e.path)},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,$.jsx)(Me,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e(`tabs.close`,`Close tab`)})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-others`,disabled:le.length===0,onClick:()=>se(le,L.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,$.jsx)(ne,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e(`tabs.closeOthers`,`Close other tabs`)})]}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-right`,disabled:ue.length===0,onClick:()=>se(ue,L.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,$.jsx)(_e,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e(`tabs.closeRight`,`Close tabs to the right`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-line`,role:`separator`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`app-tab-context-close-all`,disabled:de.length===0,onClick:()=>se(de,`home`),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink disabled:cursor-not-allowed disabled:opacity-40 dark:hover:bg-white/[0.06]`,children:[(0,$.jsx)(Le,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e(`tabs.closeAll`,`Close all tabs`)})]})]}),document.body),(0,$.jsxs)(`div`,{className:`relative flex-none`,ref:ee,children:[(0,$.jsx)(`button`,{ref:E,type:`button`,"aria-label":e(`tabs.new`,`New tab`),"aria-expanded":g,"data-testid":`app-tab-new`,onClick:()=>_(e=>!e),className:`flex h-7 w-7 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-white/60 hover:text-gray-900 dark:text-dark-600 dark:hover:bg-dark-200/60 dark:hover:text-dark-900 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,children:(0,$.jsx)(pe,{className:`h-4 w-4`})}),g&&v&&(0,qr.createPortal)((0,$.jsx)(`div`,{ref:w,role:`menu`,"data-testid":`app-tab-new-menu`,className:`fixed z-[100] max-h-[calc(100dvh-4rem)] overflow-y-auto rounded-xl border border-line bg-surface-overlay/95 p-1 shadow-overlay backdrop-blur-xl animate-fade-in motion-reduce:animate-none`,style:v,children:I.map(e=>(0,$.jsxs)(Q.Fragment,{children:[e.separatorBefore&&(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-line`,role:`separator`}),(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{_(!1),e.action()},className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px] text-ink-muted transition-colors hover:bg-black/[0.05] hover:text-ink dark:hover:bg-white/[0.06]`,children:[(0,$.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-start`,children:e.label}),e.shortcut&&(0,$.jsx)(`span`,{className:`font-mono text-[10px] tracking-wide text-ink-subtle`,children:e.shortcut})]})]},e.key))}),document.body)]})]})},Li=({onOpenSettings:e})=>{let{t,i18n:n}=S(),r=l(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(``),[c,u]=(0,Q.useState)(0),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=A(e=>e.sessions),m=ot(e=>e.tasks),h=st(e=>e.toggleTheme),{canUseWork:g,canUseAgents:_}=H(),v=g(),y=_(),b=C()?`⌘`:`Ctrl`;(0,Q.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),s(``),u(0),a(e=>!e))},t=()=>{s(``),u(0),a(!0)};return document.addEventListener(`keydown`,e,!0),window.addEventListener(`libre:open-palette`,t),()=>{document.removeEventListener(`keydown`,e,!0),window.removeEventListener(`libre:open-palette`,t)}},[]),(0,Q.useEffect)(()=>{if(!i)return;let e=window.requestAnimationFrame(()=>d.current?.focus());return()=>window.cancelAnimationFrame(e)},[i]);let x=(0,Q.useCallback)(()=>a(!1),[]),w=(0,Q.useMemo)(()=>{let i=t(`palette.actions`,`Actions`),a=[{id:`action:new-chat`,section:i,label:t(`tabs.newChat`,`New Chat`),icon:Pe,hint:`${b}⇧O`,run:()=>Oi(r)},{id:`action:incognito-chat`,section:i,label:t(`chat.session.incognito`,`Incognito Chat`),icon:te,run:()=>ki(r)},...v?[{id:`action:new-work`,section:i,label:t(`tabs.newWork`,`New Work`),icon:Te,hint:`${b}⇧U`,run:()=>Ai(r)}]:[],{id:`action:home`,section:i,label:t(`tabs.home`,`Home`),icon:Ge,run:()=>r(`/`)},{id:`action:models`,section:i,label:t(`sidebar.navigation.models`,`Models`),icon:ae,run:()=>r(`/models`)},{id:`action:personas`,section:i,label:t(`sidebar.navigation.personas`,`Personas`),icon:R,run:()=>r(`/personas`)},{id:`action:gallery`,section:i,label:t(`sidebar.navigation.imagine`,`Imagine`),icon:re,run:()=>r(`/gallery`)},...y?[{id:`action:agents`,section:i,label:t(`sidebar.navigation.agents`,`Agents`),icon:be,run:()=>r(`/agents`)}]:[],{id:`action:settings`,section:i,label:t(`palette.settings`,`Settings`),icon:Ee,hint:`${b},`,run:e},{id:`action:theme`,section:i,label:t(`palette.toggleTheme`,`Toggle theme`),icon:ze,hint:`${b}D`,run:h}],o=[...p].sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>({id:`session:${e.id}`,section:t(`palette.chats`,`Chats`),label:e.title||t(`tabs.chat`,`Chat`),icon:Pe,hint:ee(e.updatedAt,n.language),keywords:e.model,run:()=>r(`/c/${e.id}`)})),s=v?[...m].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()).map(e=>({id:`work:${e.id}`,section:t(`palette.work`,`Work`),label:e.title||t(`work.tasks.untitled`,`Untitled task`),icon:Te,hint:e.status,run:()=>r(`/work/${e.id}`)})):[];return[...a,...o,...s]},[t,b,r,e,h,p,m,v,y,n.language]),E=(0,Q.useMemo)(()=>{let e=o.trim().toLowerCase();if(!e){let e=w.filter(e=>e.id.startsWith(`action:`)),t=w.filter(e=>e.id.startsWith(`session:`)).slice(0,4),n=w.filter(e=>e.id.startsWith(`work:`)).slice(0,3);return[...e,...t,...n]}return w.filter(t=>`${t.label} ${t.keywords??``}`.toLowerCase().includes(e)).slice(0,20)},[w,o]);(0,Q.useEffect)(()=>{(f.current?.querySelector(`[data-selected="true"]`))?.scrollIntoView({block:`nearest`})},[c,E.length]);let D=e=>{e&&(x(),e.run())};if(!i)return null;let O=``;return(0,qr.createPortal)((0,$.jsx)(`div`,{"data-testid":`command-palette`,className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/25 px-4 pt-[14vh] backdrop-blur-[2px] dark:bg-black/45`,onMouseDown:e=>{e.target===e.currentTarget&&x()},children:(0,$.jsxs)(`div`,{className:`w-full max-w-lg overflow-hidden rounded-2xl border border-line bg-surface-overlay/95 shadow-overlay backdrop-blur-xl animate-scale-in motion-reduce:animate-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-3.5`,children:[(0,$.jsx)(ce,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,$.jsx)(`input`,{ref:d,"data-testid":`command-palette-input`,value:o,onChange:e=>{s(e.target.value),u(0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),x()):e.key===`ArrowDown`?(e.preventDefault(),u(e=>Math.min(E.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),u(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),D(E[c]))},placeholder:t(`palette.placeholder`,`Search chats, Work, actions…`),className:`h-11 w-full bg-transparent text-sm text-ink outline-none placeholder:text-ink-subtle`}),(0,$.jsx)(`kbd`,{className:`shrink-0 rounded-md border border-line px-1.5 py-0.5 font-mono text-[10px] text-ink-subtle`,children:`esc`})]}),(0,$.jsxs)(`div`,{ref:f,className:`max-h-[19rem] overflow-y-auto p-1.5 scrollbar-thin`,children:[E.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-6 text-center text-sm text-ink-subtle`,children:t(`palette.empty`,`No matches.`)}),E.map((e,t)=>{let n=e.section!==O;return O=e.section,(0,$.jsxs)(Q.Fragment,{children:[n&&(0,$.jsx)(`p`,{className:`px-2.5 pb-1 pt-2 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-subtle first:pt-1`,children:e.section}),(0,$.jsxs)(`button`,{type:`button`,"data-selected":t===c||void 0,onMouseEnter:()=>u(t),onClick:()=>D(e),className:T(`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-start text-sm transition-colors`,t===c?`bg-black/[0.05] text-ink dark:bg-white/[0.07]`:`text-ink-muted`),children:[(0,$.jsx)(e.icon,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint&&(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-subtle`,children:e.hint})]})]},e.id)})]})]})}),document.body)},Ri=Ze(`user-service`),zi=class{static async initializeAuth(){let{setLoading:e,setSystemInfo:t,login:n}=H.getState();try{e(!0),Ri.debug(`Starting auth initialization...`),Ri.debug(`Fetching system info...`);let r=await $e.getSystemInfo();Ri.debug(`System info response:`,r),r.success&&r.data?(Ri.debug(`Setting system info:`,r.data),t(r.data)):Ri.error(`System info response failed:`,r);let i=localStorage.getItem(`auth-token`);if(i)try{let e=(await f(async()=>{let{default:e}=await import(`../js/utils-vendor-DWh39_3x.js`).then(e=>e.i);return{default:e}},__vite__mapDeps([5,1,2]))).default,t=e.defaults.headers.common;e.defaults.headers.common.Authorization=`Bearer ${i}`;let r=await $e.verifyToken();if(r.success&&r.data){let e=H.getState().systemInfo;e&&n(r.data,i,e)}e.defaults.headers.common=t}catch(e){Ri.error(`Token verification failed:`,e),localStorage.removeItem(`auth-token`)}}catch(e){Ri.error(`Auth initialization error:`,e)}finally{e(!1)}}};qe.interceptors.request.use(e=>{let t=localStorage.getItem(`auth-token`);return t&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e)),qe.interceptors.response.use(e=>e,e=>{if(e.response?.status===401){localStorage.removeItem(`auth-token`);let{logout:e}=H.getState();e();let t=window.location.protocol===`file:`;window.location.href=t?`#/login`:`/login`}return Promise.reject(e)});var Bi=Ze(`initialize`),Vi=()=>{let e=(0,Q.useRef)(!1),t=(0,Q.useRef)(!1),{loadSessions:n,loadModels:r,loadPreferences:i,setSelectedModel:a,models:o,ollamaConnected:s}=A(),{loadPreferences:c}=st(),{loadPlugins:l,plugins:u}=rt(),d=H(e=>e.isAuthenticated);(0,Q.useEffect)(()=>{e.current||t.current||(async()=>{t.current=!0;try{Bi.debug(`Initializing Libre WebUI...`),await zi.initializeAuth();let t=H.getState();if(t.requiresAuth()&&!t.isAuthenticated){Bi.debug(`Authentication required; deferring protected app initialization`);return}try{!(await tt.checkHealth()).success&&!Xe()&&V.error(`Ollama service is not available. Plugin models may still be used.`)}catch(e){Bi.warn(`Ollama health check failed; continuing provider initialization:`,e),Xe()||V.error(`Ollama service is not available. Plugin models may still be used.`)}await Promise.all([c(),i()]),await Promise.all([r(),n(),l()]),e.current=!0,Bi.debug(`Libre WebUI initialized successfully`)}catch(t){Xe()?(await Promise.all([c(),i()]),await Promise.all([r(),n(),l()]),e.current=!0):(Bi.error(`Failed to initialize app:`,t),V.error(`Failed to connect to the backend service`))}finally{t.current=!1}})()},[d,c,i,r,n,l]),(0,Q.useEffect)(()=>{if(o.length>0){let e=o.filter(e=>!e.name.includes(`embed`))[0]||o[0],{selectedModel:t,selectedProviderType:n,selectedProviderId:r}=A.getState();if(t){if(!k(o,{model:t,providerType:n,providerId:r})&&n!==`ollama`&&n!==`plugin`){let t=D(e);Bi.debug(`Legacy selected model not available, falling back to:`,t.model),a(t.model,t.providerType,t.providerId)}}else{let t=D(e);Bi.debug(`No model selected, using first available:`,t.model),a(t.model,t.providerType,t.providerId)}}},[o,a]),(0,Q.useEffect)(()=>{e.current&&(Bi.debug(`Plugin availability changed, reloading models...`),r())},[u,r]),(0,Q.useEffect)(()=>{let e=0,t=()=>{if(document.visibilityState!==`visible`)return;let t=H.getState();if(t.requiresAuth()&&!t.isAuthenticated)return;let n=Date.now();n-e<1e4||(e=n,t.refreshWorkAccess())};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,t)}},[]),(0,Q.useEffect)(()=>{let e=()=>{Bi.debug(`Installed models changed, reloading models...`),r()};return window.addEventListener(nt,e),()=>window.removeEventListener(nt,e)},[r]),(0,Q.useEffect)(()=>{if(s)return;let e=H.getState();if(e.requiresAuth()&&!e.isAuthenticated)return;let t=()=>{document.visibilityState===`visible`&&(Bi.debug(`Provider offline at startup, re-checking availability...`),r({quiet:!0}))},n=o.some(e=>!e.isPersona)?void 0:window.setInterval(t,1e4);return window.addEventListener(`focus`,t),()=>{n!==void 0&&window.clearInterval(n),window.removeEventListener(`focus`,t)}},[s,o,r])},Hi=(e,t=!0)=>{let n=(0,Q.useCallback)(n=>{if(!t)return;let r=n.target;if(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.contentEditable===`true`||r.isContentEditable)return;if(n.key===`?`||n.key===`/`&&n.shiftKey){let t=e.find(e=>e.key===`?`||e.key===`h`);if(t){n.preventDefault(),n.stopPropagation(),t.action();return}}let i=e.find(e=>{let t=e.key.toLowerCase()===n.key.toLowerCase(),r=!!e.metaKey,i=n.metaKey||n.ctrlKey,a=!r||i,o=!e.ctrlKey||n.ctrlKey,s=!!e.shiftKey===n.shiftKey,c=!!e.altKey===n.altKey;return t&&a&&o&&s&&c});i&&(n.preventDefault(),n.stopPropagation(),i.action())},[e,t]);(0,Q.useEffect)(()=>{if(t)return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n)}},[n,t])},Ui=new Set([`.`,`!`,`?`,`。`,`!`,`?`,`…`]),Wi=new Set([`。`,`!`,`?`]),Gi=new Set([`"`,`'`,`’`,`”`,`»`,`)`,`]`,`}`]),Ki=new Set([`,`,`;`,`:`,`—`,`–`,`,`,`;`,`:`,`、`,`
|
|
33
|
-
`]),qi=new Set(`a.m,apr,aug,dec,dr,e.g,etc,feb,fri,i.e,jan,jr,jul,jun,mar,mr,mrs,ms,nov,oct,p.m,prof,sep,sept,sr,st,vs`.split(`,`)),Ji=(e,t)=>{if(!Number.isFinite(e)||e<1)throw RangeError(`${t} must be a positive number`);return Math.floor(e)},Yi=e=>{let t=Ji(e.maxChars??360,`maxChars`),n=Ji(e.targetChars??Math.min(240,t),`targetChars`),r=Ji(e.minChars??Math.min(48,n),`minChars`);if(n>t)throw RangeError(`targetChars cannot exceed maxChars`);if(r>n)throw RangeError(`minChars cannot exceed targetChars`);return{...e,targetChars:n,maxChars:t,minChars:r}},Xi=e=>{let t=Intl;if(t.Segmenter)try{return new t.Segmenter(e,{granularity:`sentence`})}catch{return}},Zi=e=>e!==void 0&&/\s/u.test(e),Qi=(e,t,n)=>{let r=e.slice(t,n).match(/([\p{L}.]+)\.$/u)?.[1]?.toLocaleLowerCase();return r?!!(qi.has(r)||/^\p{L}$/u.test(r)||/^(?:\p{L}\.)+\p{L}$/u.test(r)):!1};function $i(e){let t=[],n=0,r=0;for(;r<e.length;){let i=e[r];if(!Ui.has(i)){r+=1;continue}if(i===`.`&&/\d/u.test(e[r-1]??``)&&/\d/u.test(e[r+1]??``)){r+=1;continue}let a=r+1;for(;a<e.length&&Ui.has(e[a]);)a+=1;let o=a;for(;o<e.length&&Gi.has(e[o]);)o+=1;let s=o===e.length||Zi(e[o])||Wi.has(i),c=i===`.`&&o<e.length&&Qi(e,n,a);if(s&&!c){let i=e.slice(n,o).trim();for(i&&t.push(i),n=o;n<e.length&&Zi(e[n]);)n+=1;r=n;continue}r=a}let i=e.slice(n).trim();return i&&t.push(i),t}function ea(e,t={}){if(!e.trim())return[];let n=t.segmenter===!1?void 0:t.segmenter??Xi(t.locale);if(!n)return $i(e);try{let t=Array.from(n.segment(e),e=>e.segment.trim()).filter(Boolean);return t.length>0?t:$i(e)}catch{return $i(e)}}var ta=(e,t)=>{let n=Math.min(Math.max(1,t),e.length),r=e.charCodeAt(n-1);return r>=55296&&r<=56319&&n<e.length&&--n,Math.max(1,n)},na=(e,t,n)=>{let r=ta(e,t),i=Math.max(1,n);for(let t=r-1;t>=i;--t)if(Ki.has(e[t]))return t+1;for(let t=r-1;t>=i;--t)if(Zi(e[t]))return t},ra=(e,t,n)=>{let r=Math.min(e.length-1,n);for(let n=Math.max(1,t);n<=r;n+=1)if(Ki.has(e[n]))return n+1;for(let n=Math.max(1,t);n<=r;n+=1)if(Zi(e[n]))return n},ia=(e,t,n)=>{let r=[],i=e.trim();for(;i.length>t;){let e=Math.min(t,Math.max(n,i.length-n)),a=na(i,e,Math.min(n,Math.floor(e/2)))??ta(i,e),o=i.slice(0,a).trim();o&&r.push(o),i=i.slice(a).trimStart()}return i&&r.push(i),r},aa=e=>e.reduce((e,t,n)=>e+t.length+ +!!n,0),oa=e=>e.join(` `),sa=(e,{targetChars:t,maxChars:n,minChars:r})=>{if(e.length<2)return;let i=e.length-1,a=e[i];if(a.length>=r)return;let o=`${e[i-1]} ${a}`;if(o.length<=n){e.splice(i-1,2,o);return}let s=Math.max(r,o.length-n),c=Math.min(n,o.length-r);if(s>c)return;let l=Math.min(c,Math.max(s,t)),u=na(o,l,s)??ra(o,l,c);if(!u)return;let d=o.slice(0,u).trim(),f=o.slice(u).trim();d.length>=r&&d.length<=n&&f.length>=r&&f.length<=n&&e.splice(i-1,2,d,f)};function ca(e,t={}){let n=Yi(t),r=ea(e,n);if(r.length===0)return[];let i=r.flatMap(e=>ia(e,n.maxChars,n.minChars)),a=[],o=[];for(let e of i){if(o.length===0){o=[e];continue}let t=aa(o),r=t+1+e.length,i=Math.abs(n.targetChars-t),s=Math.abs(n.targetChars-r);r<=n.maxChars&&(r<=n.targetChars||t<n.minChars||e.length<n.minChars||s<=i)?o.push(e):(a.push(o),o=[e])}o.length>0&&a.push(o);let s=a.map(oa);return sa(s,n),s}var la=class extends Error{constructor(){super(`Audio playback needs a click or key press before it can start`),this.name=`TTSPlaybackBlockedError`}},ua=(e,t)=>e instanceof Error?e:Error(t),da=e=>{let t=e instanceof Error?e.message:`TTS playback cancelled`;if(typeof DOMException<`u`)return new DOMException(t,`AbortError`);let n=Error(t);return n.name=`AbortError`,n},fa=e=>typeof e==`object`&&e&&`name`in e?String(e.name):void 0,pa=e=>fa(e)===`AbortError`,ma=e=>{let t=fa(e);return t===`TTSPlaybackBlockedError`||t===`NotAllowedError`},ha=(e,t,n)=>Math.min(n,Math.max(t,Math.floor(e))),ga=e=>{try{e?.()}catch{}},_a=()=>{let e=globalThis,t=e.AudioContext??e.webkitAudioContext;if(!t)return null;try{return new t}catch{return null}},va=null,ya=()=>(va?.state===`closed`&&(va=null),!va&&(va=_a(),!va)?null:(va.state,va));function ba(){let e=ya();if(!e)return Promise.resolve(`unsupported`);if(!e.state||e.state===`running`)return Promise.resolve(`ready`);if(!e.resume||e.state===`closed`)return Promise.resolve(`blocked`);let t;try{t=e.resume()}catch{return Promise.resolve(`blocked`)}return Promise.resolve(t).then(()=>{let t=e.state;return!t||t===`running`?`ready`:`blocked`},()=>`blocked`)}function xa(){if(typeof document>`u`)return()=>void 0;let e=!1,t=()=>{e||(e=!0,document.removeEventListener(`pointerdown`,n,!0),document.removeEventListener(`keydown`,n,!0))},n=e=>{e instanceof KeyboardEvent&&[`Alt`,`Control`,`Meta`,`Shift`].includes(e.key)||ba().then(e=>{(e===`ready`||e===`unsupported`)&&t()})};return document.addEventListener(`pointerdown`,n,!0),document.addEventListener(`keydown`,n,!0),t}var Sa=e=>{let t=globalThis.Audio;if(!t)throw Error(`Audio playback is not supported in this environment`);return new t(e)},Ca={create(e){if(typeof URL.createObjectURL!=`function`)throw Error(`Blob audio URLs are not supported in this environment`);return URL.createObjectURL(e)},revoke(e){URL.revokeObjectURL(e)}},wa=class{constructor(e,t,n,r,i,a){g(this,`batches`,void 0),g(this,`generate`,void 0),g(this,`concurrency`,void 0),g(this,`maxAhead`,void 0),g(this,`signal`,void 0),g(this,`onFailure`,void 0),g(this,`nextIndex`,0),g(this,`consumedCount`,0),g(this,`results`,void 0),g(this,`waiters`,new Set),g(this,`failure`,void 0),this.batches=e,this.generate=t,this.concurrency=n,this.maxAhead=r,this.signal=i,this.onFailure=a,this.results=Array(e.length);let o=Math.min(n,e.length);for(let e=0;e<o;e+=1)this.runWorker()}async get(e){for(;;){if(this.failure)throw this.failure;if(this.signal.aborted)throw da(this.signal.reason);let t=this.results[e];if(t)return this.results[e]=void 0,this.consumedCount=Math.max(this.consumedCount,e+1),this.notify(),t.blob;await new Promise(e=>{let t=()=>{this.waiters.delete(t),this.signal.removeEventListener(`abort`,t),e()};this.waiters.add(t),this.signal.addEventListener(`abort`,t,{once:!0})})}}notify(){for(let e of[...this.waiters])e()}async runWorker(){for(;!this.signal.aborted&&!this.failure;){let e=await this.claimNextIndex();if(e===void 0)return;try{let t=await this.generate(this.batches[e],{index:e,total:this.batches.length,signal:this.signal});if(this.signal.aborted||this.failure)return;if(!t||typeof t.arrayBuffer!=`function`)throw TypeError(`The TTS generator did not return a Blob`);this.results[e]={blob:t},this.notify()}catch(t){if(this.signal.aborted||this.failure)return;this.failure=ua(t,`Failed to generate TTS batch ${e+1}`),this.onFailure(this.failure),this.notify();return}}}async claimNextIndex(){for(;!this.signal.aborted&&!this.failure;){if(this.nextIndex>=this.batches.length)return;if(this.nextIndex<this.consumedCount+this.maxAhead){let e=this.nextIndex;return this.nextIndex+=1,e}await new Promise(e=>{let t=()=>{this.waiters.delete(t),this.signal.removeEventListener(`abort`,t),e()};this.waiters.add(t),this.signal.addEventListener(`abort`,t,{once:!0})})}}},Ta=class{constructor(e){g(this,`options`,void 0),g(this,`controller`,new AbortController),g(this,`concurrency`,void 0),g(this,`initialBufferSize`,void 0),g(this,`scheduleLeadSeconds`,void 0),g(this,`externalAbortListener`,void 0),g(this,`audioContext`,null),g(this,`activeAudio`,null),g(this,`sources`,new Set),g(this,`started`,!1),g(this,`used`,!1),g(this,`cancelled`,!1),g(this,`fatalError`,void 0),g(this,`currentState`,`idle`),g(this,`ownsAudioContext`,!1),this.options=e,this.concurrency=ha(e.concurrency??3,1,3),this.initialBufferSize=Math.max(1,Math.floor(e.initialBufferSize??2)),this.scheduleLeadSeconds=Math.max(0,e.scheduleLeadSeconds??.03),e.signal&&(this.externalAbortListener=()=>{this.cancelled=!0,this.abort(e.signal?.reason)},e.signal.aborted?this.externalAbortListener():e.signal.addEventListener(`abort`,this.externalAbortListener,{once:!0}))}get state(){return this.currentState}get signal(){return this.controller.signal}cancel(e){this.currentState!==`ended`&&this.currentState!==`error`&&this.currentState!==`cancelled`&&(this.cancelled=!0,this.abort(e),this.stopActivePlayback())}async play(e){if(this.used)throw Error(`A TTSPlaybackSession can only be played once`);this.used=!0;let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){this.setState(`ended`),ga(this.options.onEnd),this.removeExternalAbortListener();return}try{this.throwIfStopped(),this.setState(`loading`),this.options.audioContextFactory?(this.ownsAudioContext=!0,this.audioContext=this.options.audioContextFactory()):this.audioContext=ya(),this.audioContext&&await this.ensureAudioContextReady(this.audioContext),this.throwIfStopped(),this.setState(`generating`);let e=new wa(t,this.options.generate,this.concurrency,Math.max(this.concurrency,this.initialBufferSize),this.controller.signal,e=>{this.fatalError=e,this.abort(e)});this.audioContext?await this.playWithWebAudio(e,t.length):await this.playWithHtmlAudio(e,t.length),this.throwIfStopped(),this.setState(`ended`),await this.cleanup(),ga(this.options.onEnd)}catch(e){let t=this.fatalError??ua(e,`TTS playback failed`),n=this.cancelled&&!this.fatalError,r=!n&&ma(t);if(this.setState(n?`cancelled`:r?`blocked`:`error`),this.controller.signal.aborted||this.abort(t),await this.cleanup(),n)throw da(this.controller.signal.reason);if(r)throw ga(this.options.onBlocked),t;try{this.options.onError?.(t)}catch{}throw t}}abort(e){this.controller.signal.aborted||this.controller.abort(e)}throwIfStopped(){if(this.fatalError)throw this.fatalError;if(this.controller.signal.aborted)throw da(this.controller.signal.reason)}setState(e){if(this.currentState!==e){this.currentState=e;try{this.options.onStateChange?.(e)}catch{}}}async ensureAudioContextReady(e){if(!e.state||e.state===`running`){this.ownsAudioContext;return}if(e.state===`closed`)throw Error(`Audio output was closed before playback started`);if(!e.resume)throw new la;try{await this.raceAbort(e.resume())}catch(e){throw pa(e)?e:(this.ownsAudioContext,new la)}if(e.state&&e.state!==`running`)throw this.ownsAudioContext,new la;this.ownsAudioContext}markStarted(){this.started||(this.started=!0,this.setState(`playing`),ga(this.options.onStart))}markBuffering(){!this.started&&this.currentState===`generating`&&this.setState(`buffering`)}async playWithWebAudio(e,t){let n=this.audioContext;if(!n)throw Error(`Web Audio context is unavailable`);let r=Math.min(Math.max(2,this.initialBufferSize),t),i=[];for(let t=0;t<r;t+=1)i.push(await this.decode(e,n,t));let a=n.currentTime+this.scheduleLeadSeconds,o=[],s=e=>{this.throwIfStopped();let t=n.createBufferSource();t.buffer=e,t.connect(n.destination),this.sources.add(t);let r=new Promise(e=>{t.onended=()=>{t.onended=null,this.sources.delete(t);try{t.disconnect?.()}catch{}e()}}),i=Math.max(a,n.currentTime+this.scheduleLeadSeconds);t.start(i),this.markStarted(),a=i+Math.max(0,e.duration),o.push(r)};for(let e of i)s(e);for(let i=r;i<t;i+=1){let t=this.decode(e,n,i),a=o[i-r],[,c]=await this.raceAbort(Promise.all([a,t]));s(c)}await this.raceAbort(Promise.all(o).then(()=>void 0))}async decode(e,t,n){let r=await e.get(n);this.markBuffering(),this.throwIfStopped();let i=await this.raceAbort(r.arrayBuffer());return this.throwIfStopped(),this.raceAbort(t.decodeAudioData(i))}async playWithHtmlAudio(e,t){let n=Math.min(this.initialBufferSize,t),r=[];for(let t=0;t<n;t+=1)r.push(await e.get(t)),this.markBuffering();for(let i=0;i<t;i+=1){this.throwIfStopped();let t=i<n?r[i]:await e.get(i);await this.playHtmlBlob(t)}}async playHtmlBlob(e){let t=this.options.objectUrlFactory??Ca,n=t.create(e),r=null;try{r=(this.options.audioElementFactory??Sa)(n),this.activeAudio=r;let e=new Promise((e,t)=>{if(!r)return t(Error(`Failed to create an audio element`));r.onended=e,r.onerror=()=>t(Error(`TTS audio playback failed`))});await this.raceAbort(r.play()),this.markStarted(),await this.raceAbort(e)}finally{r&&(r.onended=null,r.onerror=null,this.activeAudio===r&&(this.activeAudio=null),r.removeAttribute?.(`src`),r.load?.()),t.revoke(n)}}raceAbort(e){return this.controller.signal.aborted?Promise.reject(this.fatalError??da(this.controller.signal.reason)):new Promise((t,n)=>{let r=()=>{this.controller.signal.removeEventListener(`abort`,r),n(this.fatalError??da(this.controller.signal.reason))};this.controller.signal.addEventListener(`abort`,r,{once:!0}),e.then(e=>{this.controller.signal.removeEventListener(`abort`,r),t(e)},e=>{this.controller.signal.removeEventListener(`abort`,r),n(e)})})}stopActivePlayback(){for(let e of this.sources)try{e.stop()}catch{}this.activeAudio&&(this.activeAudio.pause(),this.activeAudio.currentTime=0)}async cleanup(){this.stopActivePlayback();for(let e of this.sources){e.onended=null;try{e.disconnect?.()}catch{}}this.sources.clear();let e=this.audioContext;if(this.audioContext=null,this.ownsAudioContext&&e?.close)try{await e.close()}catch{}this.removeExternalAbortListener()}removeExternalAbortListener(){this.options.signal&&this.externalAbortListener&&(this.options.signal.removeEventListener(`abort`,this.externalAbortListener),this.externalAbortListener=void 0)}},Ea=e=>new Ta(e),Da=null;function Oa(e){return Da!==e&&Da?.cancel(),Da=e,()=>{Da===e&&(Da=null)}}var ka=Ze(`components:git-hub-auth-button`),Aa=()=>{let{t:e}=S(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{(async()=>{try{let e=await fetch(`${Qe}/auth/oauth/github/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),ka.debug(`GitHub OAuth configured:`,t.configured)}else ka.debug(`GitHub OAuth status check failed`),i(!1)}catch(e){ka.debug(`GitHub OAuth not configured:`,e),i(!1)}})()},[]),r?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${Qe}/auth/oauth/github`;window.location.href=e},disabled:t,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:t?(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(Ce,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.github`)})]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(ke,{size:16,className:`me-2`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.github`)})]})}):null},ja=Ze(`components:hugging-face-auth-button`),Ma=()=>{let{t:e}=S(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{(async()=>{try{let e=await fetch(`${Qe}/auth/oauth/huggingface/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),ja.debug(`Hugging Face OAuth configured:`,t.configured)}else ja.debug(`Hugging Face OAuth status check failed`),i(!1)}catch(e){ja.debug(`Hugging Face OAuth not configured:`,e),i(!1)}})()},[]),r?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${Qe}/auth/oauth/huggingface`;window.location.href=e},disabled:t,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:t?(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(Ce,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.huggingFace`)})]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`me-2 text-base`,children:`🤗`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.huggingFace`)})]})}):null},Na=({displayName:e})=>{let{t}=S(),[n,r]=(0,Q.useState)(!1),i=e||t(`auth.oidc.defaultProviderName`,`Single sign-on`);return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{n||(r(!0),window.location.href=`${Qe}/auth/oauth/oidc`)},disabled:n,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:n?(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(Ce,{size:16,className:`me-2 animate-spin`}),t(`auth.oauth.connectingTo`,{provider:i})]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(ve,{size:16,className:`me-2`}),t(`auth.oauth.continueWith`,{provider:i})]})})},Pa=Ze(`hooks:oauth-providers`),Fa=async e=>{try{let t=await fetch(`${Qe}/auth/oauth/${e}/status`,{method:`GET`,credentials:`include`});if(!t.ok)return{configured:!1};let n=await t.json();return{configured:!!n.configured,displayName:typeof n.displayName==`string`?n.displayName:void 0}}catch(t){return Pa.debug(`${e} OAuth not configured:`,t),{configured:!1}}},Ia=()=>{let[e,t]=(0,Q.useState)({github:!1,huggingface:!1,oidc:!1}),[n,r]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{let e=!0;return Promise.all([Fa(`github`),Fa(`huggingface`),Fa(`oidc`)]).then(([n,i,a])=>{e&&(t({github:n.configured,huggingface:i.configured,oidc:a.configured}),r(a.displayName))}),()=>{e=!1}},[]),{...e,oidcDisplayName:n,hasAny:e.github||e.huggingface||e.oidc}},La=Ze(`components:turnstile-widget`),Ra=`https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit`,za=null,Ba=()=>window.turnstile?Promise.resolve():za||(za=new Promise((e,t)=>{let n=document.querySelector(`script[src="${Ra}"]`);if(n){n.addEventListener(`load`,()=>e(),{once:!0}),n.addEventListener(`error`,t,{once:!0});return}let r=document.createElement(`script`);r.src=Ra,r.async=!0,r.defer=!0,r.onload=()=>e(),r.onerror=t,document.head.appendChild(r)}),za),Va=({siteKey:e,action:t,disabled:n=!1,errorMessage:r,onTokenChange:i})=>{let a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),[s,c]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let n=!1,r=a.current;return i(``),Ba().then(()=>{n||!r||!window.turnstile||(r.innerHTML=``,o.current=window.turnstile.render(r,{sitekey:e,theme:`auto`,size:`flexible`,action:t,callback:e=>i(e),"expired-callback":()=>i(``),"error-callback":()=>i(``)}))}).catch(e=>{La.error(`Turnstile script failed to load:`,e),n||c(!0)}),()=>{n=!0,i(``),o.current&&window.turnstile?.remove?window.turnstile.remove(o.current):r&&(r.innerHTML=``),o.current=null}},[t,i,e]),(0,Q.useEffect)(()=>{n&&o.current&&(window.turnstile?.reset(o.current),i(``))},[n,i]),s?(0,$.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300`,children:r}):(0,$.jsx)(`div`,{className:`rounded-lg border border-accent-200 bg-accent-50/40 p-3 transition-opacity dark:border-accent-800/70 dark:bg-accent-950/20 ${n?`pointer-events-none opacity-60`:``}`,"aria-label":`Security verification`,children:(0,$.jsx)(`div`,{ref:a,className:`min-h-[65px]`})})},Ha=Ze(`components:login-form`),Ua={username:`demo`,password:`demo`},Wa=({onLogin:e,onShowSignup:t,initialApprovalPending:n=!1,bare:r=!1})=>{let{t:i}=S(),a=Xe(),o=Ia(),[s,c]=(0,Q.useState)(a?Ua.username:``),[u,d]=(0,Q.useState)(a?Ua.password:``),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(n),[v,y]=(0,Q.useState)(``),b=l(),{login:x,systemInfo:C}=H(),ee=C?.turnstile?.siteKey,w=!!(C?.turnstile?.enabled&&ee&&!a),E=(0,Q.useCallback)(e=>{y(e)},[]),D=(0,Q.useMemo)(()=>m||w&&!v,[m,w,v]),O=async t=>{t.preventDefault();let n=a?Ua.username:s.trim(),r=a?Ua.password:u;if(!n||!r){P.error(i(`auth.login.enterBoth`));return}if(w&&!v){P.error(i(`auth.login.verificationFailed`,`Security verification failed. Please refresh and try again.`));return}h(!0),_(!1);try{localStorage.removeItem(`auth-token`);let t=await $e.login({username:n,password:r,turnstileToken:v});t.success&&t.data?(x(t.data.user,t.data.token,t.data.systemInfo),P.success(i(`auth.login.loginSuccess`)),e?.(),b(`/`)):P.error(t.message||i(`auth.login.loginFailed`))}catch(e){Ha.error(`Login error:`,e);let t=e;t.response?.data?.code===`ACCOUNT_PENDING`?(_(!0),P.error(t.response.data.message||i(`auth.login.approvalPending`,`Your account is waiting for administrator approval.`))):P.error(i(`auth.login.checkCredentials`))}finally{y(``),h(!1)}},k=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return(0,$.jsxs)(`div`,{className:T(`mx-auto w-full max-w-md`,!r&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,$.jsxs)(`div`,{className:T(`mb-8`,r?`text-start`:`text-center`),children:[(0,$.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:i(`auth.login.title`)}),(0,$.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:i(`auth.login.subtitle`)})]}),(0,$.jsxs)(`form`,{onSubmit:O,className:`space-y-5`,children:[g&&(0,$.jsxs)(`div`,{"data-testid":`login-approval-pending`,role:`status`,className:`flex gap-3 rounded-xl border border-warning-500/30 bg-warning-500/10 p-3 text-start`,children:[(0,$.jsx)(Ne,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-warning-700 dark:text-warning-400`}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:i(`auth.login.approvalPending`,`Your account is waiting for administrator approval.`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:i(`auth.login.username`)}),(0,$.jsx)(`input`,{id:`username`,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:k,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:i(`auth.login.usernamePlaceholder`),required:!0,disabled:m||a})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:i(`auth.login.password`)}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{id:`password`,type:f?`text`:`password`,value:u,onChange:e=>d(e.target.value),onKeyDown:k,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:i(`auth.login.passwordPlaceholder`),required:!0,disabled:m||a}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:m||a,"aria-label":f?`Hide characters`:`Reveal characters`,children:f?(0,$.jsx)(he,{size:20}):(0,$.jsx)(fe,{size:20})})]})]}),w&&ee&&(0,$.jsx)(Va,{siteKey:ee,action:`login`,disabled:m,errorMessage:i(`auth.login.verificationFailed`,`Security verification failed. Please refresh and try again.`),onTokenChange:E}),(0,$.jsx)(`button`,{type:`submit`,disabled:D,className:`flex h-11 w-full items-center justify-center rounded-xl border border-transparent bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:m?(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),i(`auth.login.signingIn`)]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(je,{size:16,className:`me-2`}),i(`auth.login.signIn`)]})})]}),!a&&(0,$.jsxs)($.Fragment,{children:[o.hasAny&&(0,$.jsxs)(`div`,{className:`mt-6`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,$.jsx)(`div`,{className:`w-full border-t border-line`})}),(0,$.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,$.jsx)(`span`,{className:T(`px-2 text-ink-muted`,r?`bg-canvas`:`bg-surface-raised`),children:i(`common.or`)})})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3`,children:[o.github&&(0,$.jsx)(Aa,{}),o.huggingface&&(0,$.jsx)(Ma,{}),o.oidc&&(0,$.jsx)(Na,{displayName:o.oidcDisplayName})]})]}),t&&(0,$.jsx)(`div`,{className:`mt-6 text-center`,children:(0,$.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[i(`auth.login.noAccount`),` `,(0,$.jsx)(`button`,{onClick:t,className:`font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:i(`auth.login.signUpHere`)})]})})]})]})},Ga=`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`,Ka=e=>e.length<12?`Password must be at least 12 characters.`:new TextEncoder().encode(e).length>72?`Password must be no more than 72 UTF-8 bytes.`:/[A-Z]/.test(e)?/[a-z]/.test(e)?/[0-9]/.test(e)?null:`Password must contain a number.`:`Password must contain a lowercase letter.`:`Password must contain an uppercase letter.`,qa=Ze(`components:signup-form`),Ja=({onSignup:e,onBackToLogin:t,bare:n=!1})=>{let{t:r}=S(),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,C]=(0,Q.useState)(``),ee=l(),{login:w,systemInfo:E}=H(),D=E?.turnstile?.siteKey,O=!!(E?.turnstile?.enabled&&D),k=(0,Q.useCallback)(e=>{C(e)},[]),A=(0,Q.useMemo)(()=>_||O&&!x,[_,O,x]),j=async t=>{if(t.preventDefault(),!i.trim()||!c.trim()){P.error(r(`auth.signup.usernameRequired`));return}if(c!==d){P.error(r(`auth.signup.passwordMismatch`));return}let n=Ka(c);if(n){P.error(n);return}if(O&&!x){P.error(r(`auth.signup.tryAgain`));return}v(!0);try{let t=await $e.signup({username:i,password:c,email:o,turnstileToken:x});if(t.success&&t.data){if(!(`token`in t.data)){b(!0),P.success(r(`auth.signup.approvalPending`,`Registration received. An administrator must approve your account.`));return}w(t.data.user,t.data.token,t.data.systemInfo),P.success(r(`auth.signup.signupSuccess`)),e?.(),ee(`/`)}else P.error(t.message||r(`auth.signup.signupFailed`))}catch(e){qa.error(`Signup error:`,e),P.error(r(`auth.signup.tryAgain`))}finally{C(``),v(!1)}},M=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return y?(0,$.jsxs)(`div`,{"data-testid":`signup-approval-pending`,className:T(`mx-auto w-full max-w-md text-center`,!n&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,$.jsx)(`div`,{className:`mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-warning-500/15 text-warning-700 dark:text-warning-400`,children:(0,$.jsx)(Ne,{"aria-hidden":`true`,className:`h-6 w-6`})}),(0,$.jsx)(`h1`,{className:`mt-5 text-3xl font-light tracking-[-0.04em] text-ink`,children:r(`auth.signup.awaitingApproval`,`Awaiting approval`)}),(0,$.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-ink-muted`,children:r(`auth.signup.awaitingApprovalDescription`,`Your account has been created, but an administrator must activate it before you can sign in.`)}),(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`mt-6 inline-flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:bg-surface-raised`,children:r(`auth.signup.backToSignIn`,`Back to sign in`)})]}):(0,$.jsxs)(`div`,{className:T(`mx-auto w-full max-w-md`,!n&&`rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`),children:[(0,$.jsxs)(`div`,{className:T(`mb-8`,n?`text-start`:`text-center`),children:[(0,$.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:r(`auth.signup.title`)}),(0,$.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:r(`auth.signup.subtitle`)})]}),(0,$.jsxs)(`form`,{onSubmit:j,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.username`)}),(0,$.jsx)(`input`,{id:`username`,type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:M,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.usernamePlaceholder`),required:!0,disabled:_})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`label`,{htmlFor:`email`,className:`mb-2 block text-sm font-medium text-ink`,children:[r(`auth.signup.email`),` `,(0,$.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,r(`common.optional`),`)`]})]}),(0,$.jsx)(`input`,{id:`email`,type:`email`,value:o,onChange:e=>s(e.target.value),onKeyDown:M,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.emailPlaceholder`),disabled:_})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.password`)}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{id:`password`,type:p?`text`:`password`,value:c,onChange:e=>u(e.target.value),onKeyDown:M,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.passwordPlaceholder`),required:!0,disabled:_}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(!p),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:_,"aria-label":p?`Hide characters`:`Reveal characters`,children:p?(0,$.jsx)(he,{size:20}):(0,$.jsx)(fe,{size:20})})]}),(0,$.jsx)(`p`,{className:`mt-1.5 text-xs text-ink-muted`,children:Ga})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`confirmPassword`,className:`mb-2 block text-sm font-medium text-ink`,children:r(`auth.signup.confirmPassword`)}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`input`,{id:`confirmPassword`,type:h?`text`:`password`,value:d,onChange:e=>f(e.target.value),onKeyDown:M,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:r(`auth.signup.confirmPasswordPlaceholder`),required:!0,disabled:_}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(!h),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:_,"aria-label":h?`Hide confirmation`:`Reveal confirmation`,children:h?(0,$.jsx)(he,{size:20}):(0,$.jsx)(fe,{size:20})})]})]}),O&&D&&(0,$.jsx)(Va,{siteKey:D,action:`signup`,disabled:_,errorMessage:r(`auth.signup.tryAgain`),onTokenChange:k}),(0,$.jsx)(`button`,{type:`submit`,disabled:A,className:`flex h-11 w-full items-center justify-center rounded-xl border border-transparent bg-ink px-4 text-sm font-medium text-ink-inverse shadow-subtle transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:_?(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),r(`auth.signup.creatingAccount`)]}):(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(Ae,{size:16,className:`me-2`}),r(`auth.signup.createAccount`)]})})]}),(0,$.jsx)(Aa,{}),(0,$.jsx)(`div`,{className:`mt-6 text-center`,children:(0,$.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[r(`auth.signup.hasAccount`),` `,(0,$.jsx)(`button`,{onClick:t,className:`font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:r(`auth.signup.signInHere`)})]})})]})};function Ya(e,t=`0.24.0`){return t?.trim()||e?.trim()||``}var Xa=()=>{let{t:e}=S(),t=l(),n=b(),{isAuthenticated:r,requiresAuth:i,systemInfo:a}=H(),[o,s]=(0,Q.useState)(!1),c=i(),u=a?.signupEnabled??!0,d=new URLSearchParams(n.search).get(`approval`)===`pending`;if((0,Q.useEffect)(()=>{(r||!c)&&t(`/`)},[c,r,t]),r||!c)return null;let f=[{icon:N,title:e(`auth.highlights.local.title`,`Local first`),body:e(`auth.highlights.local.body`,`Your conversations and files stay on the machine you run this on.`)},{icon:He,title:e(`auth.highlights.providers.title`,`Any provider`),body:e(`auth.highlights.providers.body`,`Local models through Ollama, plus the remote providers you choose to add.`)},{icon:We,title:e(`auth.highlights.work.title`,`Isolated Work`),body:e(`auth.highlights.work.body`,`Give a model a sandboxed workspace with files, a terminal, and a preview.`)}],p=Ya(a?.version);return(0,$.jsxs)(`div`,{className:`relative min-h-screen overflow-y-auto bg-canvas text-ink`,children:[(0,$.jsxs)(`header`,{className:`absolute inset-x-0 top-0 z-10 flex h-14 items-center justify-between px-5 sm:px-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-ink lg:invisible`,children:[(0,$.jsx)(ei,{size:`sm`,label:null}),(0,$.jsx)(Qr,{size:`sm`})]}),(0,$.jsx)(ti,{})]}),(0,$.jsxs)(`main`,{className:`grid min-h-screen lg:grid-cols-2`,children:[(0,$.jsxs)(`section`,{className:`relative hidden flex-col justify-between border-e border-line bg-surface px-10 py-12 lg:flex xl:px-16`,children:[(0,$.jsxs)(`div`,{className:`relative z-10 flex items-center gap-3.5 text-ink`,children:[(0,$.jsx)(ei,{size:`lg`,label:null}),(0,$.jsx)(Qr,{size:`lg`})]}),(0,$.jsxs)(`div`,{className:`relative z-10 max-w-lg`,children:[(0,$.jsx)(`p`,{className:`text-[2.6rem] font-light leading-[1.05] tracking-[-0.04em] text-ink xl:text-5xl`,children:e(`auth.tagline`,`Your AI stack should answer to you.`)}),(0,$.jsx)(`ul`,{className:`mt-10 space-y-5`,children:f.map(e=>(0,$.jsxs)(`li`,{className:`flex gap-3`,children:[(0,$.jsx)(e.icon,{"aria-hidden":`true`,className:`mt-0.5 h-4 w-4 shrink-0 text-ink-subtle`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[13px] font-medium text-ink`,children:e.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[13px] leading-relaxed text-ink-muted`,children:e.body})]})]},e.title))})]}),(0,$.jsxs)(`div`,{className:`relative z-10 space-y-1 font-mono text-[11px] text-ink-subtle`,children:[(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`a`,{href:`https://librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`librewebui.org`}),` · `,(0,$.jsx)(`a`,{href:`https://docs.librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`docs.librewebui.org`})]}),(0,$.jsxs)(`p`,{"data-testid":`app-version`,children:[p?`v${p}`:``,p?` · `:``,e(`auth.selfHosted`,`Self-hosted · Apache 2.0`),` · `,(0,$.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`transition-colors hover:text-ink`,children:`kroonen.ai`})]})]})]}),(0,$.jsx)(`section`,{className:`flex items-center justify-center px-5 pb-12 pt-24 sm:px-8 lg:px-12 lg:py-12`,children:(0,$.jsx)(`div`,{className:`w-full max-w-sm`,children:o&&u?(0,$.jsx)(Ja,{bare:!0,onBackToLogin:()=>s(!1),onSignup:()=>s(!1)}):(0,$.jsx)(Wa,{bare:!0,initialApprovalPending:d,onShowSignup:u?()=>s(!0):void 0})})})]})]})},Za=window.location.protocol===`file:`,Qa=()=>Za?(0,$.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-8 z-50`,style:{WebkitAppRegion:`drag`}}):null,$a=Ze(`app`),eo=Q.lazy(()=>f(()=>import(`../js/HomePage-gf4GgI6z.js`),__vite__mapDeps([22,1,2,7,3,4,5,6,8,9,10,11,12,13,15,16,23]))),to=Q.lazy(()=>f(()=>import(`../js/ChatPage-wnyG_TyC.js`),__vite__mapDeps([24,1,2,25,7,3,4,5,6,8,9,10,11,12,13,15,16,26,17,18,19,27,21,28,29,30,31]))),no=Q.lazy(()=>f(()=>import(`../js/ModelsPage-Rbags4Xq.js`),__vite__mapDeps([32,1,2,7,3,4,5,9,10,11,12,13,15,6,8,16,18,19,17]))),ro=Q.lazy(()=>f(()=>import(`../js/PersonasPage-DYP67Qiy.js`),__vite__mapDeps([33,1,2,3,4,5,9,10,11,12,13,7,16,18,19,17]))),io=Q.lazy(()=>f(()=>import(`../js/GalleryPage-BZfeWlBg.js`),__vite__mapDeps([34,1,2,25,3,4,5,9,10,11,12,13,7,14,16,18,19,17]))),ao=Q.lazy(()=>f(()=>import(`../js/NotesPage-9NR9HZZ8.js`),__vite__mapDeps([35,1,2,3,4,5,9,10,11,12,13,7,18,19,16,17,36,37,38]))),oo=Q.lazy(()=>f(()=>import(`../js/LibreClawPage-CRKei1MM.js`),__vite__mapDeps([39,1,2,8,3,4,5,9,10,11,12,13,7,18,19,16,17]))),so=Q.lazy(()=>f(()=>import(`../js/WorkPage-DFES41Qm.js`),__vite__mapDeps([40,1,2,7,3,4,5,6,8,9,10,11,12,13,15,16,18,19,17,36,37,38,31,25,23]))),co=Q.lazy(()=>f(()=>import(`../js/UserManagementPage-Cp430WCP.js`),__vite__mapDeps([41,1,2,3,4,5,9,10,13,7,12,11,15,6,8,16,18,19,17,20]))),lo=Q.lazy(()=>f(()=>import(`../js/PluginUsagePage-QtCgymRu.js`),__vite__mapDeps([42,1,2,3,4,5,9,11,10,12,13,7,18,19,16,17]))),uo=Q.lazy(()=>f(()=>import(`../js/SystemPage-xFSTYdBS.js`),__vite__mapDeps([43,1,2,3,4,5,9,13,7,10,12,11,18,19,16,17]))),fo=Q.lazy(()=>f(()=>import(`../js/ArtifactDemoPage-TONeQvof.js`),__vite__mapDeps([44,1,2,18,4,5,19,7,16,10,17,3,9,28,29,30,27,12]))),po=Q.lazy(()=>f(()=>import(`../js/SettingsModal-B4RelkLP.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]))),mo=Q.lazy(()=>f(()=>import(`../js/ArtifactSlideOutPanel-2exw7YqL.js`).then(e=>({default:e.ArtifactSlideOutPanel})),__vite__mapDeps([45,1,2,25,3,4,5,6,7,8,9,10,11,12,13,16,18,29,30,27]))),ho=Q.lazy(()=>f(()=>import(`../js/FirstTimeSetup-smhj0X6o.js`).then(e=>({default:e.FirstTimeSetup})),__vite__mapDeps([46,1,2,3,4,5,9,10,11,12,13,7,15,6,8,16]))),go=()=>{let{t:e}=S();return(0,$.jsx)(`div`,{className:`flex h-full min-h-screen items-center justify-center bg-gray-50 dark:bg-dark-100`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`h-8 w-8 rounded-full border-4 border-gray-200 border-t-primary-500 animate-spin dark:border-dark-300 dark:border-t-primary-400`}),(0,$.jsx)(`div`,{className:`text-gray-600 dark:text-dark-600`,children:e(`common.loading`)})]})})},_o=({isOpen:e,compact:t})=>(0,$.jsx)(`div`,{"aria-hidden":`true`,className:T(`hidden lg:block flex-shrink-0 transition-[width] duration-200 ease-out`,e?t?`w-16`:`w-72`:`w-0`)}),vo=({hasBackground:e,sidebarOpen:t,sidebarCompact:n,onCloseSidebar:r,showDemoBanner:i,demoMessage:a,children:o})=>(0,$.jsxs)(`div`,{className:T(`flex h-dvh min-h-0 text-ink relative overflow-hidden`,e?`bg-sidebar/60`:`bg-sidebar`),children:[(0,$.jsx)(Qa,{}),(0,$.jsx)(Di,{}),(0,$.jsx)(vi,{isOpen:t,onClose:r}),(0,$.jsx)(_o,{isOpen:t,compact:n}),(0,$.jsxs)(`div`,{"data-testid":`app-shell-content`,className:T(`flex-1 basis-0 flex min-h-0 flex-col min-w-0 transition-[margin,background-color] duration-200 ease-out relative z-10 lg:pb-2 lg:pe-2`,Za?`pt-8`:`lg:pt-1.5`,t&&n?`max-lg:ms-16`:`max-lg:ms-0`,e?`bg-white/10 dark:bg-dark-50/10`:`bg-transparent`),children:[i&&(0,$.jsx)(Ei,{message:a}),(0,$.jsx)(Ii,{}),(0,$.jsx)(`main`,{className:T(`min-h-0 flex-1 overflow-hidden lg:rounded-[1.5rem] lg:border lg:border-black/[0.06] dark:lg:border-white/[0.07] lg:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_60px_rgba(15,23,42,0.04)]`,e?`bg-white/30 dark:bg-dark-50/35 backdrop-blur-sm`:`bg-canvas`),children:(0,$.jsx)(Si,{children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(go,{}),children:o})})})]})]}),yo=()=>{let{t:e,i18n:t}=S(),n=l(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(void 0),[s,u]=(0,Q.useState)(0),[d,f]=(0,Q.useState)(!1),{sidebarOpen:p,sidebarCompact:m,setSidebarOpen:g,setSidebarCompact:_,toggleSidebar:v,toggleSidebarCompact:y,toggleTheme:b,backgroundImage:x,preferences:C,artifactPanelOpen:ee,closeArtifactPanel:w}=st(),{systemInfo:T,isLoading:E,user:D,isAuthenticated:O}=H(),{isDemoMode:k,demoConfig:A}=st(),M=T?.requiresAuth===!1||O,N=Ti();Q.useEffect(()=>{if(!(!C.ttsSettings?.enabled||!C.ttsSettings.autoPlay))return xa()},[C.ttsSettings?.autoPlay,C.ttsSettings?.enabled]);let[P,te]=Q.useState(!1),ne=Q.useRef(!1);Q.useEffect(()=>{(async()=>{if(ne.current){$a.debug(`OAuth already processing, skipping...`);return}if($a.debug(`Starting OAuth callback processing...`),ne.current=!0,new URLSearchParams(window.location.search).get(`auth`)===`success`){try{let e=await fetch(`${Qe}/auth/oauth/exchange`,{method:`POST`,credentials:`include`});if(e.ok){let t=await e.json();if(t.success&&t.data){let{login:e}=H.getState();e(t.data.user,t.data.token,t.data.systemInfo),$a.debug(`OAuth login successful`),V.success(`OAuth login successful!`)}else V.error(`Failed to complete OAuth authentication`)}else V.error(`OAuth authentication verification failed`)}catch(e){$a.error(`OAuth processing error:`,e),V.error(`OAuth authentication failed`)}window.history.replaceState({},document.title,window.location.pathname)}$a.debug(`OAuth processing completed`),te(!0),ne.current=!1})()},[]),Vi();let re=()=>{if(x)return!0;let e=C.backgroundSettings;return e?.enabled&&e?.imageUrl};Hi([{key:`b`,metaKey:!0,action:()=>{window.innerWidth>=1024?p?y():(_(!1),v()):(!p&&m&&_(!1),v())},description:e(`keyboard.toggleSidebar`)},{key:`,`,metaKey:!0,action:()=>{o(void 0),i(!0)},description:e(`keyboard.openSettings`)},{key:`o`,metaKey:!0,shiftKey:!0,action:()=>Oi(n),description:e(`keyboard.newChat`)},{key:`u`,metaKey:!0,shiftKey:!0,action:()=>{H.getState().canUseWork()&&Ai(n)},description:e(`keyboard.newWork`)},{key:`d`,metaKey:!0,action:b,description:e(`keyboard.toggleDarkMode`)},{key:`h`,action:()=>{o(`shortcuts`),i(!0)},description:e(`keyboard.showShortcuts`)},{key:`Escape`,action:()=>i(!1),description:e(`keyboard.closeModals`)}],M),Q.useEffect(()=>{if(M)return;let e=window.requestAnimationFrame(()=>{i(!1),w()});return()=>window.cancelAnimationFrame(e)},[w,M]),Q.useEffect(()=>{if(!M){at.disconnect();return}return at.connect().catch($a.error),()=>{at.disconnect()}},[M]),Q.useEffect(()=>{if(!T&&!E&&s<15){let e=setTimeout(async()=>{u(e=>e+1);try{await zi.initializeAuth()}catch{}},2e3);return()=>clearTimeout(e)}},[T,E,s]);let F=!d&&T?.requiresAuth===!0&&T?.hasUsers===!1;return E?(0,$.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,$.jsx)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:(0,$.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,$.jsx)(ei,{size:`lg`,className:`text-gray-900 dark:text-gray-100`})})}),(0,$.jsx)(`div`,{className:`mt-8 flex flex-col items-center gap-4`,children:(0,$.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})})]}):T?F&&!d?(0,$.jsx)(Si,{children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(go,{}),children:(0,$.jsx)(ho,{onComplete:()=>{f(!0)}})})}):P?(0,$.jsxs)($.Fragment,{children:[T&&!T.requiresAuth?(0,$.jsx)(vo,{hasBackground:!!re(),sidebarOpen:p,sidebarCompact:m,onCloseSidebar:()=>g(!1),showDemoBanner:k&&A.showBanner,demoMessage:A.message,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(h,{path:`/`,element:(0,$.jsx)(eo,{})}),(0,$.jsx)(h,{path:`/chat`,element:(0,$.jsx)(to,{})}),(0,$.jsx)(h,{path:`/c/:sessionId`,element:(0,$.jsx)(to,{})}),(0,$.jsx)(h,{path:`/models`,element:(0,$.jsx)(no,{})}),(0,$.jsx)(h,{path:`/personas`,element:(0,$.jsx)(ro,{})}),(0,$.jsx)(h,{path:`/gallery`,element:(0,$.jsx)(io,{})}),(0,$.jsx)(h,{path:`/notes`,element:(0,$.jsx)(ao,{})}),(0,$.jsx)(h,{path:`/work`,element:(0,$.jsx)(yi,{requireWork:!0,children:(0,$.jsx)(so,{})})}),(0,$.jsx)(h,{path:`/work/:taskId`,element:(0,$.jsx)(yi,{requireWork:!0,children:(0,$.jsx)(so,{})})}),(0,$.jsx)(h,{path:`/agents`,element:(0,$.jsx)(yi,{requireAdmin:!0,requireAgents:!0,children:(0,$.jsx)(oo,{})})}),(0,$.jsx)(h,{path:`/usage`,element:(0,$.jsx)(yi,{requireAdmin:!0,children:(0,$.jsx)(lo,{})})}),(0,$.jsx)(h,{path:`/system`,element:(0,$.jsx)(yi,{requireAdmin:!0,children:(0,$.jsx)(uo,{})})}),(0,$.jsx)(h,{path:`/login`,element:(0,$.jsx)(Xa,{})})]})}):(0,$.jsxs)(c,{children:[(0,$.jsx)(h,{path:`/login`,element:(0,$.jsx)(Xa,{})}),(0,$.jsx)(h,{path:`/*`,element:(0,$.jsx)(yi,{children:(0,$.jsx)(vo,{hasBackground:!!re(),sidebarOpen:p,sidebarCompact:m,onCloseSidebar:()=>g(!1),showDemoBanner:k&&A.showBanner,demoMessage:A.message,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(h,{path:`/`,element:(0,$.jsx)(eo,{})}),(0,$.jsx)(h,{path:`/chat`,element:(0,$.jsx)(to,{})}),(0,$.jsx)(h,{path:`/c/:sessionId`,element:(0,$.jsx)(to,{})}),(0,$.jsx)(h,{path:`/models`,element:(0,$.jsx)(no,{})}),(0,$.jsx)(h,{path:`/personas`,element:(0,$.jsx)(ro,{})}),(0,$.jsx)(h,{path:`/gallery`,element:(0,$.jsx)(io,{})}),(0,$.jsx)(h,{path:`/notes`,element:(0,$.jsx)(ao,{})}),(0,$.jsx)(h,{path:`/work`,element:(0,$.jsx)(yi,{requireWork:!0,children:(0,$.jsx)(so,{})})}),(0,$.jsx)(h,{path:`/work/:taskId`,element:(0,$.jsx)(yi,{requireWork:!0,children:(0,$.jsx)(so,{})})}),(0,$.jsx)(h,{path:`/agents`,element:(0,$.jsx)(yi,{requireAdmin:!0,requireAgents:!0,children:(0,$.jsx)(oo,{})})}),(0,$.jsx)(h,{path:`/artifacts`,element:(0,$.jsx)(fo,{})}),(0,$.jsx)(h,{path:`/usage`,element:(0,$.jsx)(yi,{requireAdmin:!0,children:(0,$.jsx)(lo,{})})}),(0,$.jsx)(h,{path:`/system`,element:(0,$.jsx)(yi,{requireAdmin:!0,children:(0,$.jsx)(uo,{})})}),(0,$.jsx)(h,{path:`/users`,element:(0,$.jsx)(yi,{requireAdmin:!0,children:(0,$.jsx)(co,{})})})]})})})})]}),M&&r&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(po,{isOpen:r,initialTab:a,onClose:()=>i(!1)})}),M&&N.open&&N.notes&&(0,$.jsx)(Ci,{notes:N.notes,onDismiss:N.dismiss}),M&&ee&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(mo,{})}),(0,$.jsx)(Oe,{position:j(t.language)?`top-left`:`top-right`,toastOptions:{duration:4e3,className:`animate-slide-up`,style:{background:`var(--toast-bg)`,color:`var(--toast-color)`,border:`1px solid var(--toast-border)`,borderRadius:`0.75rem`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)`,cursor:`pointer`},success:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}},error:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}}},containerStyle:{top:80,insetInlineEnd:20}}),M&&(0,$.jsx)(Li,{onOpenSettings:()=>i(!0)})]}):(0,$.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center`,children:(0,$.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}):(0,$.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center p-4`,children:(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`div`,{className:`mb-8`,children:(0,$.jsx)(ei,{size:`lg`,className:`mx-auto text-gray-900 dark:text-white`})}),(0,$.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,$.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-dark-300 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}),(0,$.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-sm`,children:s>0?`Connecting to backend... (${s}/15)`:`Starting up...`})]})})},bo=Za?_([{path:`*`,element:(0,$.jsx)(yo,{})}]):m([{path:`*`,element:(0,$.jsx)(yo,{})}]),xo=()=>(0,$.jsx)(Si,{children:(0,$.jsx)(v,{router:bo})}),So=new Cr({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});E.catch(()=>{O(`en`)}).then(()=>{Vr.createRoot(document.getElementById(`root`)).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Er,{client:So,children:(0,$.jsx)(xo,{})})}))});export{un as C,fn as S,Yr as _,Oa as a,Tr as b,pa as c,ki as d,Oi as f,Qr as g,ei as h,Va as i,ma as l,fi as m,Ga as n,ca as o,Ai as p,Ka as r,Ea as s,Ya as t,ba as u,Br as v,dn as w,Bn as x,zr as y};
|