libre-webui 0.14.3 → 0.15.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 +91 -23
- package/backend/dist/db.d.ts.map +1 -1
- package/backend/dist/db.js +84 -0
- package/backend/dist/db.js.map +1 -1
- package/backend/dist/index.d.ts.map +1 -1
- package/backend/dist/index.js +99 -35
- package/backend/dist/index.js.map +1 -1
- package/backend/dist/middleware/auth.d.ts.map +1 -1
- package/backend/dist/middleware/auth.js +27 -2
- package/backend/dist/middleware/auth.js.map +1 -1
- package/backend/dist/routes/plugins.d.ts.map +1 -1
- package/backend/dist/routes/plugins.js +1 -1
- package/backend/dist/routes/plugins.js.map +1 -1
- package/backend/dist/routes/users.d.ts.map +1 -1
- package/backend/dist/routes/users.js +40 -6
- package/backend/dist/routes/users.js.map +1 -1
- package/backend/dist/routes/work.d.ts +3 -0
- package/backend/dist/routes/work.d.ts.map +1 -0
- package/backend/dist/routes/work.js +604 -0
- package/backend/dist/routes/work.js.map +1 -0
- package/backend/dist/services/ollamaService.d.ts +7 -2
- package/backend/dist/services/ollamaService.d.ts.map +1 -1
- package/backend/dist/services/ollamaService.js +8 -8
- package/backend/dist/services/ollamaService.js.map +1 -1
- package/backend/dist/services/pluginService.d.ts.map +1 -1
- package/backend/dist/services/pluginService.js +8 -9
- 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 +1 -0
- package/backend/dist/services/preferencesService.js.map +1 -1
- package/backend/dist/services/workAgentGuidance.d.ts +23 -0
- package/backend/dist/services/workAgentGuidance.d.ts.map +1 -0
- package/backend/dist/services/workAgentGuidance.js +129 -0
- package/backend/dist/services/workAgentGuidance.js.map +1 -0
- package/backend/dist/services/workAgentService.d.ts +33 -0
- package/backend/dist/services/workAgentService.d.ts.map +1 -0
- package/backend/dist/services/workAgentService.js +880 -0
- package/backend/dist/services/workAgentService.js.map +1 -0
- package/backend/dist/services/workEventService.d.ts +40 -0
- package/backend/dist/services/workEventService.d.ts.map +1 -0
- package/backend/dist/services/workEventService.js +324 -0
- package/backend/dist/services/workEventService.js.map +1 -0
- package/backend/dist/services/workModelProviderService.d.ts +49 -0
- package/backend/dist/services/workModelProviderService.d.ts.map +1 -0
- package/backend/dist/services/workModelProviderService.js +916 -0
- package/backend/dist/services/workModelProviderService.js.map +1 -0
- package/backend/dist/services/workRuntimeService.d.ts +143 -0
- package/backend/dist/services/workRuntimeService.d.ts.map +1 -0
- package/backend/dist/services/workRuntimeService.js +1860 -0
- package/backend/dist/services/workRuntimeService.js.map +1 -0
- package/backend/dist/services/workTaskService.d.ts +96 -0
- package/backend/dist/services/workTaskService.d.ts.map +1 -0
- package/backend/dist/services/workTaskService.js +718 -0
- package/backend/dist/services/workTaskService.js.map +1 -0
- package/backend/dist/types/index.d.ts +3 -0
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/types/work.d.ts +209 -0
- package/backend/dist/types/work.d.ts.map +1 -0
- package/backend/dist/types/work.js +18 -0
- package/backend/dist/types/work.js.map +1 -0
- package/backend/dist/utils/pluginChatAdapter.d.ts +9 -0
- package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginChatAdapter.js +32 -6
- package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
- package/backend/dist/utils/pluginStreamAdapter.d.ts +12 -0
- package/backend/dist/utils/pluginStreamAdapter.d.ts.map +1 -1
- package/backend/dist/utils/pluginStreamAdapter.js +168 -19
- package/backend/dist/utils/pluginStreamAdapter.js.map +1 -1
- package/backend/dist/utils/pluginStreaming.d.ts +10 -0
- package/backend/dist/utils/pluginStreaming.d.ts.map +1 -1
- package/backend/dist/utils/pluginStreaming.js.map +1 -1
- package/backend/package.json +1 -1
- package/electron/main.js +39 -16
- package/frontend/dist/assets/index-Bv-twCuY.css +1 -0
- package/frontend/dist/assets/index-uCHBH_PM.js +5 -0
- package/frontend/dist/index.html +5 -4
- package/frontend/dist/js/{ArtifactContainer-CuvIIoHC.js → ArtifactContainer-CXfmVx8T.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-DI0QzAee.js → ArtifactDemoPage-B1_AuMd2.js} +1 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-C0eTguNL.js +1 -0
- package/frontend/dist/js/ChatPage-1bK0gDBy.js +16 -0
- package/frontend/dist/js/FirstTimeSetup-DOoZUaRs.js +1 -0
- package/frontend/dist/js/GalleryPage-6WwyH3kt.js +1 -0
- package/frontend/dist/js/LibreClawPage-ChHVfPLb.js +1 -0
- package/frontend/dist/js/{ModelManagerModals-DfgizeSq.js → ModelManagerModals-DneqFQJC.js} +1 -1
- package/frontend/dist/js/ModelsPage-Dw6wdiMt.js +2 -0
- package/frontend/dist/js/PersonasPage-BxdI2e1-.js +13 -0
- package/frontend/dist/js/RichMessageContent-WQLdJ5jq.js +3 -0
- package/frontend/dist/js/SettingsModal-C-cK6TNb.js +1 -0
- package/frontend/dist/js/UserManagementPage-DqjNXPkf.js +1 -0
- package/frontend/dist/js/WorkPage-MGR3odo6.js +2 -0
- package/frontend/dist/js/api-DD5qhhLf.js +19 -0
- package/frontend/dist/js/{ar-UnnZB1Qy.js → ar-CCVY0-7X.js} +2 -2
- package/frontend/dist/js/babel-BnLuavNv.js +16 -0
- package/frontend/dist/js/{bn-uZXaDyeV.js → bn-CoU5CSph.js} +2 -2
- package/frontend/dist/js/{cs-CCXlnUEB.js → cs-CR6pjIbG.js} +2 -2
- package/frontend/dist/js/{da--BpVVGPp.js → da-CkyYITRz.js} +2 -2
- package/frontend/dist/js/{de-DZd9lsBc.js → de-DwNANzB-.js} +2 -2
- package/frontend/dist/js/{es-Bm968oUX.js → es-TxygiaVQ.js} +2 -2
- package/frontend/dist/js/estree-DPzMpjFm.js +44 -0
- package/frontend/dist/js/{fr-RlC0rD8I.js → fr-DvEqVpZr.js} +2 -2
- package/frontend/dist/js/{hi-C6kwkL7d.js → hi-CyrWkyh7.js} +2 -2
- package/frontend/dist/js/html-R50jmBYq.js +25 -0
- package/frontend/dist/js/{id-CDfqnnXS.js → id-PJjIGHGM.js} +2 -2
- package/frontend/dist/js/{is-Dnd_7Jqv.js → is-ChXcN1tI.js} +2 -2
- package/frontend/dist/js/{it-BM0j6_Sz.js → it-DsgM8-MJ.js} +2 -2
- package/frontend/dist/js/{ja-xGblKDDf.js → ja-ivtt80N2.js} +2 -2
- package/frontend/dist/js/{ko-CQ2d_Oj0.js → ko-B8l_Ice1.js} +2 -2
- package/frontend/dist/js/markdown-C08x2H-K.js +70 -0
- package/frontend/dist/js/{ms-CFpRuv_a.js → ms-DoUBI6Qi.js} +2 -2
- package/frontend/dist/js/{nl-D6oTztmP.js → nl-DsX5Hj8m.js} +2 -2
- package/frontend/dist/js/{pl-ByuvABul.js → pl-Db_NKL4x.js} +2 -2
- package/frontend/dist/js/postcss-DSDkwgFE.js +62 -0
- package/frontend/dist/js/{pt-CNFV21T7.js → pt-CpzBhb5J.js} +2 -2
- package/frontend/dist/js/router-vendor-BjDI9mRe.js +1 -0
- package/frontend/dist/js/{ru-CRsSOntz.js → ru-DCXvJyXJ.js} +2 -2
- package/frontend/dist/js/standalone-DpMZUvjd.js +29 -0
- package/frontend/dist/js/{sv-BRkwjyS5.js → sv-DcVoybc7.js} +2 -2
- package/frontend/dist/js/{th-DigqsQEB.js → th-D0G7HyQn.js} +2 -2
- package/frontend/dist/js/{tr-B5aMUMJE.js → tr-CMDOh4Aq.js} +2 -2
- package/frontend/dist/js/typescript-B6y_hxBm.js +22 -0
- package/frontend/dist/js/ui-vendor-DUqvZsfs.js +177 -0
- package/frontend/dist/js/{uk-BUYi3llT.js → uk-D2MMa6LP.js} +2 -2
- package/frontend/dist/js/useBaseQuery-Duml3DYp.js +1 -0
- package/frontend/dist/js/useQuery-C0lZwNoc.js +1 -0
- package/frontend/dist/js/{vi-hQIcXi3m.js → vi-B8uHT8yh.js} +2 -2
- package/frontend/dist/js/yaml-mLy9chOK.js +154 -0
- package/frontend/dist/js/{zh-CUDZ3JDv.js → zh-CNqa_15K.js} +2 -2
- package/package.json +3 -2
- package/plugins/kimi-code.json +6 -37
- package/frontend/dist/assets/index-BKzwVaAM.js +0 -16
- package/frontend/dist/assets/index-BPvF-fpc.css +0 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-BzBemzHy.js +0 -1
- package/frontend/dist/js/ChatPage-DqpXctC2.js +0 -16
- package/frontend/dist/js/FirstTimeSetup-DRWeCsVI.js +0 -1
- package/frontend/dist/js/GalleryPage-CgD8fVx0.js +0 -1
- package/frontend/dist/js/LibreClawPage-B_Yon2fQ.js +0 -1
- package/frontend/dist/js/ModelsPage-CAKQ7J-b.js +0 -2
- package/frontend/dist/js/PersonasPage-Dj6Bka4I.js +0 -13
- package/frontend/dist/js/RichMessageContent-DP7XoxIa.js +0 -3
- package/frontend/dist/js/SettingsModal-BFyYhZYE.js +0 -1
- package/frontend/dist/js/UserManagementPage-CGMnhZr1.js +0 -1
- package/frontend/dist/js/router-vendor-Bbvzv1ZC.js +0 -1
- package/frontend/dist/js/ui-vendor-CurEAeCe.js +0 -177
- package/frontend/dist/js/useBaseQuery-B1on3xcz.js +0 -1
- package/frontend/dist/js/useQuery-CXvo2RBT.js +0 -1
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-GI9BPwrB.js";import{t as r}from"./useQuery-CXvo2RBT.js";import{t as i}from"./useTranslation-Cs6iTP4m.js";import{At as a,Et as o,H as s,Lt as c,O as l,Ot as u,P as d,T as f,U as p,Vt as m,c as h,ct as g,jt as _,kt as v,l as y,m as b,n as x,nt as S,o as C,pt as w,q as T,st as E,t as D,u as O,vt as k,xt as A,y as j}from"./ui-vendor-CurEAeCe.js";import{t as M}from"./logger-DbNs3-DK.js";import{t as N}from"./utils-pTFqSV8c.js";import{t as P}from"./Button-DBk-AREB.js";import{B as F,D as I,H as L,J as R,U as z,V as B,a as V,i as H,r as U,rt as W}from"../assets/index-BKzwVaAM.js";var G=e(n(),1),K=t(),q=M(`components:persona-card`),J=({persona:e,onEdit:t,onDelete:n,onDownload:s,onSelect:f,onToggleFavorite:p,isSelected:h=!1,compact:_=!1})=>{let{t:y}=i(),x=W(),[C,w]=(0,G.useState)(!1),[T,k]=(0,G.useState)(!1),M=!!(e.memory_settings?.enabled||e.mutation_settings?.enabled),{data:I=null}=r({queryKey:[`persona-memory-status`,e.id],queryFn:async()=>{let t=await F.getMemoryStatus(e.id);return t.success&&t.data?t.data:null},enabled:M}),R=()=>x.invalidateQueries({queryKey:[`persona-memory-status`,e.id]}),z=async()=>{if(confirm(y(`personaCard.wipeConfirm`))){k(!0);try{let t=await F.wipeMemories(e.id);t.success?(m.success(y(`personaCard.wipeSuccess`,{count:t.data?.deleted_count||0})),await R()):m.error(y(`personaCard.failed`,{action:`wipe memories`}))}catch(e){m.error(y(`personaCard.failed`,{action:`wipe memories`})),q.error(e)}finally{k(!1),w(!1)}}},V=async()=>{k(!0);try{let t=await F.backupPersona(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-backup.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),m.success(y(`personaCard.backupSuccess`))}catch(e){m.error(y(`personaCard.failed`,{action:`backup persona`})),q.error(e)}finally{k(!1),w(!1)}},H=async()=>{k(!0);try{let t=await F.exportPersonaDNA(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-dna.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),m.success(y(`personaCard.dnaSuccess`))}catch(e){m.error(y(`personaCard.failed`,{action:`export persona DNA`})),q.error(e)}finally{k(!1),w(!1)}},U=(t=128)=>B(e,t),J=(t=128)=>n=>{L(n.currentTarget,e.name,t)};return _?(0,K.jsxs)(`div`,{className:N(`group relative flex items-center gap-3 p-3 rounded-xl cursor-pointer transition-all duration-200`,`border border-transparent`,`hover:bg-gray-50 dark:hover:bg-dark-100`,h&&[`bg-primary-50 dark:bg-primary-900/20`,`border-primary-200 dark:border-primary-700`]),onClick:()=>f?.(e),children:[(0,K.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,K.jsx)(`img`,{src:U(64),alt:e.name,className:`w-10 h-10 rounded-full object-cover ring-2 ring-white dark:ring-dark-100`,onError:J(64)}),M&&(0,K.jsx)(`div`,{className:`absolute -bottom-0.5 -end-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-primary-600`,children:(0,K.jsx)(a,{className:`h-2.5 w-2.5 text-white`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`h4`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100 truncate`,children:e.name}),e.is_favorite&&(0,K.jsx)(b,{className:`h-3 w-3 text-amber-500 fill-amber-500 flex-shrink-0`})]}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:e.model})]}),h&&(0,K.jsx)(`div`,{className:`flex-shrink-0`,children:(0,K.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary-500 dark:bg-primary-600 flex items-center justify-center`,children:(0,K.jsx)(l,{className:`h-3 w-3 text-white rtl:rotate-180`})})})]}):(0,K.jsxs)(`div`,{className:N(`group relative overflow-hidden rounded-2xl transition-[border-color,background-color] duration-200`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`hover:border-gray-300 dark:hover:border-white/20`,h&&[`ring-2 ring-primary-500 dark:ring-primary-400`,`border-primary-300 dark:border-primary-600`]),children:[(0,K.jsxs)(`div`,{className:`relative h-24`,children:[e.background?(0,K.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${e.background})`}}):(0,K.jsx)(`div`,{className:`absolute inset-0 bg-gray-200 dark:bg-dark-200`}),e.background&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/15 dark:bg-black/25`}),(0,K.jsxs)(`div`,{className:`absolute inset-x-3 top-3 flex items-start justify-between`,children:[(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),p?.(e)},className:N(`p-1.5 rounded-full transition-all duration-200`,`border border-white/30 bg-black/20 text-white backdrop-blur-sm hover:bg-black/30`,e.is_favorite&&`bg-amber-500/80 hover:bg-amber-500`),children:(0,K.jsx)(b,{className:N(`h-4 w-4`,e.is_favorite?`text-white fill-white`:`text-white/80 hover:text-white`)})}),M&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 rounded-full border border-white/30 bg-black/20 px-2 py-1 text-[10px] font-medium text-white backdrop-blur-sm`,children:[(0,K.jsx)(a,{className:`h-3 w-3`}),y(`personaCard.enhanced`)]})]})]}),(0,K.jsx)(`div`,{className:`relative -mt-8 px-4`,children:(0,K.jsxs)(`div`,{className:`relative inline-block`,children:[(0,K.jsx)(`img`,{src:U(128),alt:e.name,className:`h-16 w-16 rounded-xl object-cover ring-4 ring-white dark:ring-dark-100`,onError:J(128)}),M&&(0,K.jsx)(`div`,{className:`absolute -bottom-1 -end-1 flex h-6 w-6 items-center justify-center rounded-lg bg-primary-600 ring-2 ring-white dark:ring-dark-100`,children:(0,K.jsx)(A,{className:`h-3.5 w-3.5 text-white`})})]})}),(0,K.jsxs)(`div`,{className:`px-4 pt-3 pb-4`,children:[(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 leading-tight`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 flex items-center gap-1.5 mt-0.5`,children:[(0,K.jsx)(j,{className:`h-3.5 w-3.5`}),e.model]})]}),e.description&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2 mb-3`,children:e.description}),e.parameters.system_prompt&&(0,K.jsxs)(`div`,{className:`mb-3 rounded-xl border border-gray-200/70 bg-gray-50/70 p-2.5 dark:border-white/[0.08] dark:bg-white/[0.025]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,K.jsx)(d,{className:`h-3 w-3 text-gray-400 dark:text-gray-500`}),(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider font-medium text-gray-400 dark:text-gray-500`,children:y(`personaCard.systemPrompt`)})]}),(0,K.jsxs)(`p`,{className:`line-clamp-2 text-xs leading-5 text-gray-600 dark:text-gray-400`,children:[`“`,e.parameters.system_prompt,`”`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[(0,K.jsx)(D,{className:`h-3 w-3`}),e.parameters.temperature?.toFixed(1)||`0.7`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[`Top-P `,e.parameters.top_p?.toFixed(1)||`0.9`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[(e.parameters.context_window||4096).toLocaleString(),` ctx`]})]}),M&&I&&(0,K.jsx)(`div`,{className:`mb-3 rounded-xl border border-primary-200/70 bg-primary-50/50 p-2.5 dark:border-primary-800/40 dark:bg-primary-900/10`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(g,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300`,children:[I.memory_count,` `,y(`personaCard.memories`)]}),(0,K.jsx)(`span`,{className:`ms-2 text-[10px] text-primary-600/70 dark:text-primary-400/70`,children:(e=>e<1?`${(e*1024).toFixed(0)} KB`:`${e.toFixed(1)} MB`)(I.size_mb)})]})]}),I.status&&(0,K.jsx)(`span`,{className:N(`text-[10px] px-1.5 py-0.5 rounded-full font-medium`,I.status===`active`?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`),children:I.status})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-200/70 pt-3 dark:border-white/[0.08]`,children:[f&&(0,K.jsxs)(P,{onClick:()=>f(e),size:`sm`,className:`px-4`,children:[(0,K.jsx)(l,{className:`me-1.5 h-3.5 w-3.5 rtl:rotate-180`}),y(`personaCard.use`)]}),(0,K.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>t(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:y(`personaCard.editTooltip`),children:(0,K.jsx)(v,{className:`h-4 w-4`})}),(0,K.jsx)(`button`,{onClick:()=>s(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:y(`personaCard.downloadTooltip`),children:(0,K.jsx)(E,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:()=>w(!C),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:y(`common.more`,{defaultValue:`More`}),children:(0,K.jsx)(c,{className:`h-4 w-4`})}),C&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>w(!1)}),(0,K.jsxs)(`div`,{className:`absolute end-0 bottom-full z-20 mb-1 w-44 rounded-xl border border-gray-200 bg-white py-1 shadow-lg dark:border-white/10 dark:bg-dark-100`,children:[M&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{onClick:V,disabled:T,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,K.jsx)(o,{className:`h-4 w-4`}),y(`personaCard.backup`)]}),(0,K.jsxs)(`button`,{onClick:H,disabled:T,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,K.jsx)(S,{className:`h-4 w-4`}),y(`personaCard.exportDNA`)]}),I&&I.memory_count>0&&(0,K.jsxs)(`button`,{onClick:z,disabled:T,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50`,children:[(0,K.jsx)(u,{className:`h-4 w-4`}),y(`personaCard.wipeMemories`)]}),(0,K.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200`})]}),(0,K.jsxs)(`button`,{onClick:()=>{n(e),w(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20`,children:[(0,K.jsx)(O,{className:`h-4 w-4`}),y(`common.delete`)]})]})]})]})]})]})]})]})},Y={name:``,description:``,model:``,parameters:{temperature:.7,top_p:.9,top_k:40,context_window:4096,max_tokens:1024,system_prompt:``,repeat_penalty:1.1,presence_penalty:0,frequency_penalty:0},avatar:``,background:``,embedding_model:``,memory_settings:{enabled:!1,max_memories:1e3,auto_cleanup:!0,retention_days:90},mutation_settings:{enabled:!1,sensitivity:`medium`,auto_adapt:!0}};function ee({embeddingModel:e,embeddingModels:t,onEmbeddingModelChange:n}){let{t:r}=i(),a=t.filter(e=>e.isDetectedEmbedding),o=t.filter(e=>!e.isDetectedEmbedding);return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`rounded-xl p-5 bg-gradient-to-br from-primary-50 to-primary-100/50 dark:from-primary-900/30 dark:to-primary-800/20 border border-primary-200/50 dark:border-primary-700/30`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,K.jsx)(g,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}),(0,K.jsx)(`h3`,{className:`font-semibold text-primary-900 dark:text-primary-100`,children:r(`personaForm.advanced.embeddingModel`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-primary-600 dark:text-primary-400 mb-3`,children:r(`personaForm.advanced.embeddingHint`)}),(0,K.jsx)(`select`,{value:e,onChange:e=>n(e.target.value),className:`w-full px-3 py-2.5 border border-primary-200 dark:border-primary-700 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20`,children:t.length===0?(0,K.jsx)(`option`,{value:``,disabled:!0,children:r(`personaForm.advanced.noModels`)}):(0,K.jsxs)(K.Fragment,{children:[a.length>0&&(0,K.jsx)(`optgroup`,{label:r(`personaForm.advanced.embeddingModels`),children:a.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))}),o.length>0&&(0,K.jsx)(`optgroup`,{label:r(`personaForm.advanced.otherModels`),children:o.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))})]})}),t.length===0&&(0,K.jsx)(`div`,{className:`mt-3 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700/50 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:[r(`personaForm.advanced.installHint`),` `,(0,K.jsx)(`code`,{className:`px-1.5 py-0.5 bg-amber-100 dark:bg-amber-900/40 rounded text-xs`,children:`ollama pull nomic-embed-text`})]})}),(0,K.jsx)(`p`,{className:`text-[10px] text-primary-500 dark:text-primary-500 mt-2`,children:r(`personaForm.advanced.recommended`)})]}),(0,K.jsx)(`div`,{className:`p-4 bg-gray-50 dark:bg-dark-50 rounded-xl border border-gray-200 dark:border-dark-300`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(s,{className:`h-5 w-5 text-gray-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`personaForm.advanced.aboutTitle`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:r(`personaForm.advanced.aboutDescription`)})]})]})})]})}var X=M(`components:persona-background-upload`),Z=({value:e,onChange:t,className:n=``})=>{let{t:r}=i(),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),u=async e=>{if(!e.type.startsWith(`image/`)){m.error(r(`personaBackground.invalidFile`));return}if(e.size>5*1024*1024){m.error(r(`personaBackground.fileTooLarge`));return}s(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),m.success(r(`personaBackground.uploaded`))},n.onerror=()=>{m.error(r(`personaBackground.readFailed`))},n.readAsDataURL(e)}catch(e){X.error(`Failed to upload background:`,e),m.error(r(`personaBackground.uploadFailed`))}finally{s(!1)}};return(0,K.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:r(`personaBackground.label`)}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[e?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`div`,{className:`w-full h-32 rounded-lg bg-cover bg-center border-2 border-gray-300 dark:border-dark-300`,style:{backgroundImage:`url(${e})`}}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:r(`personaBackground.customBackground`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`personaBackground.clickToChange`)})]}),(0,K.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>{t(``),m.success(r(`personaBackground.removed`))},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,K.jsx)(x,{className:`h-4 w-4`})})]})]}):(0,K.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${c?`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:e=>{e.preventDefault(),l(!0)},onDragLeave:e=>{e.preventDefault(),l(!1)},onDrop:e=>{e.preventDefault(),l(!1);let t=e.dataTransfer.files?.[0];t&&u(t)},onClick:()=>a.current?.click(),children:[(0,K.jsx)(p,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:r(`personaBackground.uploadBackgroundImage`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:r(`personaBackground.dragAndDrop`)}),(0,K.jsxs)(P,{variant:`outline`,size:`sm`,disabled:o,className:`mx-auto`,children:[(0,K.jsx)(h,{className:`h-4 w-4 mr-2`}),r(o?`personaBackground.uploading`:`personaBackground.chooseImage`)]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:r(`personaBackground.enterImageUrl`)}),(0,K.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/background.jpg`})]})]}),(0,K.jsx)(`input`,{ref:a,type:`file`,accept:`image/*`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)},className:`hidden`}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:r(`personaBackground.supportedFormats`)})]})})};function te({formData:e,availableModels:t,onFieldChange:n,onParameterChange:r}){let{t:a}=i();return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[a(`personaForm.basic.name`),` *`]}),(0,K.jsx)(`input`,{type:`text`,value:e.name,onChange:e=>n(`name`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,placeholder:a(`personaForm.basic.namePlaceholder`),required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[a(`personaForm.basic.model`),` *`]}),(0,K.jsxs)(`select`,{value:e.model,onChange:e=>n(`model`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,required:!0,children:[(0,K.jsx)(`option`,{value:``,children:a(`personaForm.basic.selectModel`)}),t.map(e=>(0,K.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:a(`personaForm.basic.description`)}),(0,K.jsx)(`textarea`,{value:e.description,onChange:e=>n(`description`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none`,rows:3,placeholder:a(`personaForm.basic.descriptionPlaceholder`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,K.jsx)(U,{value:e.avatar||``,onChange:e=>n(`avatar`,e)}),(0,K.jsx)(Z,{value:e.background||``,onChange:e=>n(`background`,e)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:a(`personaForm.basic.systemPrompt`)}),(0,K.jsx)(`textarea`,{value:e.parameters.system_prompt,onChange:e=>r(`system_prompt`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none font-mono text-sm`,rows:6,placeholder:a(`personaForm.basic.systemPromptPlaceholder`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-2`,children:a(`personaForm.basic.systemPromptHint`)})]})]})}function ne({persona:e,submitting:t,saveAndClose:n,lastSaved:r,onCancel:a,onSave:o,onSaveAndClose:s}){let{t:c}=i();return(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(P,{type:`button`,variant:`ghost`,onClick:a,disabled:t,className:`text-gray-600 dark:text-gray-400`,children:c(`personaForm.actions.cancel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,K.jsx)(k,{className:`h-4 w-4`}),(0,K.jsx)(`span`,{children:c(`personaForm.saved`)})]}),(0,K.jsx)(P,{type:`button`,variant:`outline`,onClick:o,disabled:t,children:c(t&&!n?`personaForm.actions.saving`:`personaForm.actions.save`)}),(0,K.jsx)(P,{type:`button`,onClick:s,disabled:t,children:c(t&&n?`personaForm.actions.saving`:e?`personaForm.actions.saveClose`:`personaForm.actions.create`)})]})]})}var Q=({label:e,value:t,min:n,max:r,step:i,onChange:a,hint:o,format:s=e=>String(e),colorClass:c=`text-gray-700 dark:text-dark-600`})=>{let l=(t-n)/(r-n)*100;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`label`,{className:N(`block text-sm font-medium`,c),children:e}),(0,K.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:s(t),onChange:e=>{let t=parseFloat(e.target.value);isNaN(t)||a(Math.min(r,Math.max(n,t)))},className:`w-20 px-2 py-1 text-sm text-right bg-gray-100 dark:bg-dark-200 border border-gray-300 dark:border-dark-300 rounded focus:outline-none focus:ring-1 focus:ring-primary-500 dark:text-dark-600`})]}),(0,K.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>a(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 dark:bg-dark-200 rounded-lg appearance-none cursor-pointer slider`,style:{"--progress":`${l}%`}}),o&&(0,K.jsx)(`p`,{className:N(`text-xs mt-1`,c.replace(`700`,`500`).replace(`600`,`400`)),children:o})]})},$=({label:e,checked:t,onChange:n,colorClass:r=`text-gray-700 dark:text-dark-600`})=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`div`,{className:N(`relative w-10 h-5 rounded-full transition-colors`,t?`bg-primary-500 dark:bg-primary-600`:`bg-gray-300 dark:bg-dark-300`),onClick:()=>n(!t),children:(0,K.jsx)(`div`,{className:N(`absolute top-0.5 start-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-5 rtl:-translate-x-5`)})}),(0,K.jsx)(`span`,{className:N(`text-sm font-medium`,r),children:e})]});function re({formData:e,persona:t,memoryStatus:n,loadingMemoryStatus:r,wipingMemories:o,onSettingsChange:s,onWipeMemories:c}){let{t:l}=i();return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-emerald-200/50 dark:border-emerald-700/30`,children:[(0,K.jsx)(`div`,{className:`px-5 py-4 bg-gradient-to-r from-emerald-500 to-teal-500 dark:from-emerald-600 dark:to-teal-600`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,K.jsx)(g,{className:`h-5 w-5 text-white`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-semibold text-white`,children:l(`personaForm.memory.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-white/80`,children:l(`personaForm.memory.subtitle`)})]})]}),(0,K.jsx)($,{label:``,checked:e.memory_settings?.enabled||!1,onChange:e=>s(`memory_settings`,{enabled:e})})]})}),e.memory_settings?.enabled&&t?.id&&(0,K.jsx)(`div`,{className:`px-5 py-4 bg-emerald-50 dark:bg-emerald-900/20 border-b border-emerald-100 dark:border-emerald-800/30`,children:r?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,K.jsx)(f,{className:`h-4 w-4 animate-spin`}),l(`personaForm.memory.loading`)]}):n?(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(g,{className:`h-5 w-5`}),n.memory_count.toLocaleString()]}),(0,K.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:l(`personaForm.memory.memories`)})]}),(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(T,{className:`h-5 w-5`}),n.size_mb.toFixed(1)]}),(0,K.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:l(`personaForm.memory.mbUsed`)})]}),(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,K.jsx)(w,{className:`h-5 w-5`}),n.last_backup?new Date(n.last_backup).toLocaleDateString():l(`personaForm.memory.never`)]}),(0,K.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:l(`personaForm.memory.lastBackup`)})]})]}):(0,K.jsx)(`p`,{className:`text-sm text-emerald-600 dark:text-emerald-400`,children:l(`personaForm.memory.noData`)})}),e.memory_settings?.enabled&&(0,K.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-4`,children:[(0,K.jsx)(Q,{label:l(`personaForm.memory.maxMemories`),value:e.memory_settings.max_memories,min:100,max:1e4,step:100,hint:l(`personaForm.memory.maxMemoriesHint`),format:e=>e.toLocaleString(),colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>s(`memory_settings`,{max_memories:e})}),(0,K.jsx)(Q,{label:l(`personaForm.memory.retention`),value:e.memory_settings.retention_days,min:7,max:365,step:7,hint:l(`personaForm.memory.retentionHint`),format:e=>`${Math.round(e)} days`,colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>s(`memory_settings`,{retention_days:e})}),(0,K.jsx)($,{label:l(`personaForm.memory.autoCleanup`),checked:e.memory_settings.auto_cleanup,onChange:e=>s(`memory_settings`,{auto_cleanup:e}),colorClass:`text-emerald-700 dark:text-emerald-300`}),t?.id&&n&&n.memory_count>0&&(0,K.jsx)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800/30`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:l(`personaForm.memory.wipeAll`)}),(0,K.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:l(`personaForm.memory.wipeCannot`)})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:c,disabled:o,className:`px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 flex items-center gap-1.5`,children:[o?(0,K.jsx)(f,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(O,{className:`h-3.5 w-3.5`}),l(o?`personaForm.memory.wiping`:`personaForm.memory.wipeButton`)]})]})})]}),!e.memory_settings?.enabled&&(0,K.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:l(`personaForm.memory.enableHint`)})})]}),(0,K.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-primary-200/50 dark:border-primary-700/30`,children:[(0,K.jsx)(`div`,{className:`px-5 py-4 bg-primary-600 dark:bg-primary-600`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,K.jsx)(y,{className:`h-5 w-5 text-white`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-semibold text-white`,children:l(`personaForm.learning.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-white/80`,children:l(`personaForm.learning.subtitle`)})]})]}),(0,K.jsx)($,{label:``,checked:e.mutation_settings?.enabled||!1,onChange:e=>s(`mutation_settings`,{enabled:e})})]})}),e.mutation_settings?.enabled&&(0,K.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-5`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-primary-700 dark:text-primary-300 mb-3`,children:l(`personaForm.learning.speed`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:[{level:`low`,icon:D,label:l(`personaForm.learning.slow`),desc:l(`personaForm.learning.slowDesc`)},{level:`medium`,icon:y,label:l(`personaForm.learning.balanced`),desc:l(`personaForm.learning.balancedDesc`)},{level:`high`,icon:a,label:l(`personaForm.learning.fast`),desc:l(`personaForm.learning.fastDesc`)}].map(({level:t,icon:n,label:r,desc:i})=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>s(`mutation_settings`,{sensitivity:t}),className:N(`p-3 rounded-xl text-center transition-all border`,e.mutation_settings?.sensitivity===t?`bg-primary-600 border-primary-600 text-white shadow-lg`:`bg-primary-50 dark:bg-primary-900/20 border-primary-200 dark:border-primary-700/30 text-primary-700 dark:text-primary-300 hover:bg-primary-100 dark:hover:bg-primary-900/30`),children:[(0,K.jsx)(n,{className:`h-5 w-5 mx-auto mb-1`}),(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:r}),(0,K.jsx)(`p`,{className:`text-[10px] opacity-70`,children:i})]},t))})]}),(0,K.jsx)($,{label:l(`personaForm.learning.autoAdapt`),checked:e.mutation_settings.auto_adapt,onChange:e=>s(`mutation_settings`,{auto_adapt:e}),colorClass:`text-primary-700 dark:text-primary-300`}),(0,K.jsxs)(`div`,{className:`p-4 bg-primary-50 dark:bg-primary-900/20 rounded-xl`,children:[(0,K.jsxs)(`p`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300 mb-2 flex items-center gap-1.5`,children:[(0,K.jsx)(A,{className:`h-3.5 w-3.5`}),l(`personaForm.learning.whatLearns`)]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-primary-600 dark:text-primary-400`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),l(`personaForm.learning.conversationTone`)]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),l(`personaForm.learning.responseStyle`)]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),l(`personaForm.learning.userPreferences`)]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),l(`personaForm.learning.topicInterests`)]})]})]})]}),!e.mutation_settings?.enabled&&(0,K.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:l(`personaForm.learning.enableHint`)})})]})]})}function ie({parameters:e,onParameterChange:t}){let{t:n}=i();return(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:(0,G.useMemo)(()=>[{key:`temperature`,label:n(`personaForm.parameters.temperature`),min:0,max:2,step:.1,hint:n(`personaForm.parameters.temperatureHint`),format:e=>e.toFixed(1)},{key:`top_p`,label:n(`personaForm.parameters.topP`),min:0,max:1,step:.1,hint:n(`personaForm.parameters.topPHint`),format:e=>e.toFixed(1)},{key:`top_k`,label:n(`personaForm.parameters.topK`),min:1,max:100,step:1,hint:n(`personaForm.parameters.topKHint`),format:e=>String(Math.round(e))},{key:`context_window`,label:n(`personaForm.parameters.contextWindow`),min:128,max:131072,step:128,hint:n(`personaForm.parameters.contextWindowHint`),format:e=>String(Math.round(e))},{key:`max_tokens`,label:n(`personaForm.parameters.maxTokens`),min:1,max:8192,step:1,hint:n(`personaForm.parameters.maxTokensHint`),format:e=>String(Math.round(e))},{key:`repeat_penalty`,label:n(`personaForm.parameters.repeatPenalty`),min:.5,max:2,step:.1,hint:n(`personaForm.parameters.repeatPenaltyHint`),format:e=>e.toFixed(1)}],[n]).map(({key:n,label:r,min:i,max:a,step:o,hint:s,format:c})=>(0,K.jsx)(Q,{label:r,value:e[n]||0,min:i,max:a,step:o,hint:s,format:c,onChange:e=>t(n,e)},n))})}var ae=M(`components:persona-form`),oe=({persona:e,onSubmit:t,onCancel:n})=>{let{preferences:o}=I(),{t:s}=i(),[c,l]=(0,G.useState)(Y),[u,d]=(0,G.useState)([]),[f,p]=(0,G.useState)([]),[h,g]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[S,w]=(0,G.useState)(null),[T,E]=(0,G.useState)(`basic`),[D,O]=(0,G.useState)(!1),k=(0,G.useRef)(!1),j=(0,G.useCallback)((e,t)=>{l(n=>({...n,[e]:t})),w(null)},[]),M=(0,G.useCallback)((e,t)=>{l(n=>({...n,parameters:{...n.parameters,[e]:t}})),w(null)},[]),P=(0,G.useCallback)((e,t)=>{l(n=>({...n,[e]:{...n[e],...t}})),w(null)},[]),L=(0,G.useCallback)(e=>{let t=e.reduce((e,t)=>(e.find(e=>e.id===t.id)||e.push(t),e),[]);return t.length>0?t:[{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]},[]),B=e?.id,V=!!c.memory_settings?.enabled,H=W(),{data:U=null,isLoading:q}=r({queryKey:[`persona-memory-status`,B],queryFn:async()=>{if(!B)return null;let e=await F.getMemoryStatus(B);return e.success&&e.data?e.data:null},enabled:!!B&&V}),J=()=>H.invalidateQueries({queryKey:[`persona-memory-status`,B]}),X=async()=>{if(e?.id&&confirm(s(`personaForm.memory.wipeConfirm`))){O(!0);try{let t=await F.wipeMemories(e.id);t.success?(m.success(s(`personaForm.memory.wipeSuccess`,{count:t.data?.deleted_count||0})),await J()):m.error(s(`personaForm.error.saveFailed`))}catch{m.error(s(`personaForm.error.saveFailed`))}finally{O(!1)}}};(0,G.useEffect)(()=>{k.current||(k.current=!0,(async()=>{g(!0);try{let[t,n,r]=await Promise.all([z.getModels(),R.getModels(),e?Promise.resolve(null):F.getDefaultParameters()]);t.success&&t.data&&d(t.data);let i=L(n.success&&n.data?n.data:[]);p(i);let a=i.find(e=>e.id===o.embeddingSettings?.model||e.rawModel===o.embeddingSettings?.model)?.id||i[0]?.id||``,s=i.find(t=>t.id===e?.embedding_model||t.rawModel===e?.embedding_model)?.id||e?.embedding_model||i[0]?.id||``;if(e)l({name:e.name,description:e.description||``,model:e.model,parameters:e.parameters,avatar:e.avatar||``,background:e.background||``,embedding_model:s,memory_settings:e.memory_settings||Y.memory_settings,mutation_settings:e.mutation_settings||Y.mutation_settings}),e.embedding_model&&!i.find(t=>t.id===e.embedding_model||t.rawModel===e.embedding_model)&&p(t=>L([...t,{id:e.embedding_model,name:e.embedding_model,description:`Previously selected model (not currently available)`,provider:`openai`,dimensions:0}]));else{let e=r?.success?r.data:{};l(t=>({...t,parameters:{...t.parameters,...e},embedding_model:a}))}}catch(e){ae.error(`Error loading data:`,e)}finally{g(!1)}})())},[e,L,o.embeddingSettings?.model]);let Z=async n=>{y(!0),x(n);try{let r={name:c.name,description:c.description,model:c.model,parameters:c.parameters,avatar:c.avatar,background:c.background,embedding_model:c.embedding_model,memory_settings:c.memory_settings,mutation_settings:c.mutation_settings},i=e?await F.updatePersona(e.id,r):await F.createPersona(c);i.success?(m.success(s(e?`personaForm.success.updated`:`personaForm.success.created`)),w(new Date),n&&t()):m.error(`${s(`personaForm.error.saveFailed`)}: ${i.error}`)}catch(e){m.error(`${s(`personaForm.error.saveFailed`)}: ${e instanceof Error?e.message:String(e)}`)}finally{y(!1),x(!1)}},Q=(0,G.useMemo)(()=>[{id:`basic`,label:s(`personaForm.tabs.basic`),icon:C},{id:`parameters`,label:s(`personaForm.tabs.parameters`),icon:_},{id:`memory`,label:s(`personaForm.tabs.memory`),icon:a},{id:`advanced`,label:s(`personaForm.tabs.advanced`),icon:A}],[s]);return h?(0,K.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,K.jsxs)(`div`,{className:`animate-pulse flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary-500 border-t-transparent rounded-full animate-spin`}),(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:s(`personaForm.loading`)})]})}):(0,K.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:s(e?`personaForm.title.edit`:`personaForm.title.create`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 mt-1`,children:[(0,K.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600`,children:s(e?`personaForm.subtitle.edit`:`personaForm.subtitle.create`)}),S&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 bg-green-500 rounded-full`}),s(`personaForm.saved`),` `,S.toLocaleTimeString()]})]})]}),(0,K.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,K.jsx)(`div`,{className:`flex border-b border-gray-200 dark:border-dark-300`,children:Q.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>E(e.id),className:N(`flex items-center gap-2 px-6 py-4 text-sm font-medium transition-colors`,T===e.id?`border-b-2 border-primary-500 text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-dark-600 hover:text-gray-700 dark:hover:text-dark-800`),children:[(0,K.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.id))}),(0,K.jsxs)(`div`,{className:`p-6`,children:[T===`basic`&&(0,K.jsx)(te,{formData:c,availableModels:u,onFieldChange:j,onParameterChange:M}),T===`parameters`&&(0,K.jsx)(ie,{parameters:c.parameters,onParameterChange:M}),T===`memory`&&(0,K.jsx)(re,{formData:c,persona:e,memoryStatus:U,loadingMemoryStatus:q,wipingMemories:D,onSettingsChange:P,onWipeMemories:X}),T===`advanced`&&(0,K.jsx)(ee,{embeddingModel:c.embedding_model,embeddingModels:f,onEmbeddingModelChange:e=>j(`embedding_model`,e)})]})]}),(0,K.jsx)(ne,{persona:e,submitting:v,saveAndClose:b,lastSaved:S,onCancel:n,onSave:()=>Z(!1),onSaveAndClose:()=>Z(!0)})]})]})},se=M(`components:persona-import-export`),ce=({personas:e,onImport:t,onClose:n})=>{let{t:r}=i(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=async e=>{try{let t=await F.exportPersona(e.id),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),i=URL.createObjectURL(n),a=document.createElement(`a`);a.href=i,a.download=`${e.name}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),m.success(r(`personaImportExport.exportSuccess`,{name:e.name}))}catch(e){let t=e instanceof Error?e.message:String(e);m.error(r(`personaImportExport.exportFailed`)+`: `+t)}};return(0,K.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:r(`personaImportExport.title`)}),(0,K.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mt-1`,children:r(`personaImportExport.description`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,K.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:r(`personaImportExport.exportPersonas`)}),e.length===0?(0,K.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-center py-8`,children:r(`personaImportExport.noPersonasToExport`)}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:r(`personaImportExport.personasAvailable`,{count:e.length})}),(0,K.jsx)(P,{onClick:async()=>{try{let t=e.map(e=>F.exportPersona(e.id)),n=await Promise.all(t),i={personas:n,exportedAt:Date.now(),version:`1.0.0`,count:n.length},a=new Blob([JSON.stringify(i,null,2)],{type:`application/json`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`personas-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o),m.success(r(`personaImportExport.exportAllSuccess`,{count:e.length}))}catch(e){let t=e instanceof Error?e.message:String(e);m.error(r(`personaImportExport.exportAllFailed`)+`: `+t)}},variant:`outline`,size:`sm`,className:`px-3 py-1`,children:r(`personaImportExport.exportAll`)})]}),(0,K.jsx)(`div`,{className:`space-y-2 max-h-80 overflow-y-auto`,children:e.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-gray-50 dark:bg-dark-200 rounded-md`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`img`,{src:B(e,32),alt:e.name,className:`w-8 h-8 rounded-full`,onError:t=>L(t.currentTarget,e.name,32)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),(0,K.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e.model})]})]}),(0,K.jsx)(P,{onClick:()=>l(e),variant:`outline`,size:`sm`,className:`px-3 py-1`,children:r(`common.export`)})]},e.id))})]})]}),(0,K.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:r(`personaImportExport.importPersonas`)}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:r(`personaImportExport.uploadJsonFile`)}),(0,K.jsx)(`input`,{type:`file`,accept:`.json`,onChange:e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{let t=e.target?.result;typeof t==`string`&&c(t)},e.readAsText(t)}},className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`})]}),(0,K.jsx)(`div`,{className:`text-center text-gray-500 dark:text-dark-500`,children:r(`common.or`).toUpperCase()}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:r(`personaImportExport.pasteJsonLabel`)}),(0,K.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`,rows:8,placeholder:r(`personaImportExport.pasteJsonPlaceholder`)})]}),(0,K.jsx)(P,{onClick:async()=>{if(!s.trim()){m.error(r(`personaImportExport.pasteJsonData`));return}o(!0);try{let e=JSON.parse(s);if(e.personas&&Array.isArray(e.personas)){let t=0,n=0;for(let r of e.personas)try{await F.importPersona(r),t++}catch(e){n++,se.error(`Failed to import persona:`,e)}t>0?(m.success(r(`personaImportExport.importMultipleSuccess`,{count:t})),n>0&&m.error(r(`personaImportExport.importMultipleFailed`,{count:n}))):m.error(r(`personaImportExport.importNoneFailed`))}else await F.importPersona(e),m.success(r(`personaImportExport.importSuccess`));c(``),t()}catch(e){let t=e instanceof Error?e.message:String(e);m.error(r(`personaImportExport.importFailed`)+`: `+t)}finally{o(!1)}},disabled:!s.trim()||a,className:`w-full`,children:r(a?`personaImportExport.importing`:`personaImportExport.importButton`)})]})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 bg-gray-50 dark:bg-dark-200 rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-dark-800 mb-2`,children:r(`personaImportExport.expectedFormat`)}),(0,K.jsx)(`pre`,{className:`text-xs text-gray-600 dark:text-dark-600 overflow-x-auto`,children:`{
|
|
2
|
-
"name": "Assistant Name",
|
|
3
|
-
"description": "Brief description of the assistant's personality",
|
|
4
|
-
"model": "model-name:version",
|
|
5
|
-
"params": {
|
|
6
|
-
"temperature": 0.8,
|
|
7
|
-
"top_p": 0.9,
|
|
8
|
-
"context_window": 4096,
|
|
9
|
-
"system_prompt": "You are a helpful assistant with specific traits..."
|
|
10
|
-
},
|
|
11
|
-
"avatar": "/path/to/avatar.png",
|
|
12
|
-
"background": "/path/to/background.png"
|
|
13
|
-
}`})]}),(0,K.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,K.jsx)(P,{onClick:n,variant:`outline`,children:r(`common.close`)})})]})},le=()=>{let{t:e}=i(),t=W(),[n,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),{data:u=[],isLoading:d,refetch:f}=r({queryKey:[`personas`],queryFn:async()=>{let e=await F.getPersonas();if(!e.success)throw Error(e.error||`Failed to load personas`);return e.data||[]}}),p=async()=>{await t.invalidateQueries({queryKey:[`personas`]}),await f()},h=()=>{s(null),a(!0)},g=e=>{s(e),a(!0)},_=async t=>{if(confirm(e(`personaManager.deleteConfirm`,{name:t.name})))try{let n=await F.deletePersona(t.id);n.success?(m.success(e(`personaManager.deleteSuccess`,{name:t.name})),await p()):m.error(e(`personaManager.failed`,{action:`delete`})+`: `+n.error)}catch(t){let n=t instanceof Error?t.message:String(t);m.error(e(`personaManager.failed`,{action:`delete`})+`: `+n)}},v=async t=>{try{await F.downloadPersona(t.id,t.name),m.success(e(`personaManager.downloadSuccess`,{name:t.name}))}catch(t){let n=t instanceof Error?t.message:String(t);m.error(e(`personaManager.failed`,{action:`download`})+`: `+n)}};return d?(0,K.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,K.jsx)(`div`,{className:`text-gray-600 dark:text-dark-600`,children:e(`personaManager.loading`)})}):n?(0,K.jsx)(oe,{persona:o,onSubmit:async()=>{a(!1),s(null),await p()},onCancel:()=>{a(!1),s(null)}}):c?(0,K.jsx)(ce,{personas:u,onImport:p,onClose:()=>l(!1)}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,K.jsxs)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:[(0,K.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e(`personaManager.stats.title`)}),` `,`· `,e(`personaManager.stats.count`,{count:u.length})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(P,{onClick:()=>l(!0),variant:`outline`,className:`px-4`,children:e(`personaManager.importExport`)}),(0,K.jsx)(P,{onClick:h,className:`px-4`,children:e(`personaManager.createButton`)})]})]}),u.length===0?(0,K.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 bg-white/40 p-12 text-center dark:border-white/15 dark:bg-white/[0.025]`,children:[(0,K.jsx)(`div`,{className:`text-gray-400 dark:text-dark-500 mb-4`,children:(0,K.jsx)(`svg`,{className:`w-16 h-16 mx-auto`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`})})}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-2`,children:e(`personaManager.empty.title`)}),(0,K.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-6`,children:e(`personaManager.empty.description`)}),(0,K.jsx)(P,{onClick:h,className:`px-6 py-2`,children:e(`personaManager.empty.button`)})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,K.jsx)(J,{persona:e,onEdit:g,onDelete:_,onDownload:v},e.id))})]})},ue=()=>{let{t:e}=i();return(0,K.jsxs)(V,{children:[(0,K.jsx)(H,{title:e(`personaManager.title`),description:e(`personaManager.subtitle`)}),(0,K.jsx)(le,{})]})};export{ue as PersonasPage,ue as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/OptimizedSyntaxHighlighter-Ci9sRc78.js","js/rolldown-runtime-QTnfLwEv.js","js/markdown-core-GI9BPwrB.js","js/syntax-highlight-pM1xnNpY.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n,r}from"./markdown-core-GI9BPwrB.js";import{i}from"./router-vendor-Bbvzv1ZC.js";import{t as a}from"./utils-pTFqSV8c.js";import{_ as o,g as s,h as c,m as l,p as u}from"../assets/index-BKzwVaAM.js";import{n as d,t as f}from"./markdown-math-E4O1gcxj.js";var p=e(n(),1),m=t(),h=p.lazy(()=>i(()=>import(`./OptimizedSyntaxHighlighter-Ci9sRc78.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3])));function g({children:e,className:t}){return(0,m.jsx)(`pre`,{dir:`ltr`,className:a(l,`rounded-lg`,t),children:(0,m.jsx)(`code`,{children:e})})}var _=({content:e,className:t})=>{let n=p.useMemo(()=>o(e),[e]);return(0,m.jsx)(`div`,{dir:`auto`,className:a(`prose prose-sm max-w-none dark:prose-invert prose-gray`,`[&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden [&_.katex-display]:py-2`,`[&_.katex]:text-inherit`,t),children:(0,m.jsx)(r,{remarkPlugins:[d],rehypePlugins:[f],components:{code({className:e,children:t,node:n,...r}){let i=/language-([^\s]+)/.exec(e||``),o=String(t),l=o.replace(/\n$/,``),d=i?i[1]:null;return d||o.includes(`
|
|
3
|
-
`)?(0,m.jsx)(s,{code:l,language:d,state:`complete`,children:(0,m.jsx)(`div`,{className:`overflow-x-auto`,children:(0,m.jsx)(p.Suspense,{fallback:(0,m.jsx)(g,{className:`!m-0 !rounded-none !border-none`,children:l}),children:(0,m.jsx)(h,{language:d||`text`,isDark:!0,backgroundColor:u,borderRadius:0,customStyle:c,className:`!m-0 !rounded-none !border-none`,children:l})})})}):(0,m.jsx)(`code`,{dir:`ltr`,className:a(`px-2 py-1 rounded-md bg-gray-100 dark:bg-dark-200 text-gray-800 dark:text-dark-800`,`font-mono text-sm border border-gray-200 dark:border-dark-300`,e),...r,children:t})},pre({children:e}){return(0,m.jsx)(m.Fragment,{children:e})},p({children:e,...t}){return(0,m.jsx)(`div`,{dir:`auto`,className:`mb-4 last:mb-0 leading-relaxed`,...t,children:e})},ul({children:e,...t}){return(0,m.jsx)(`ul`,{dir:`auto`,className:`list-disc list-inside mb-4 space-y-2 ps-4`,...t,children:e})},ol({children:e,...t}){return(0,m.jsx)(`ol`,{dir:`auto`,className:`list-decimal list-inside mb-4 space-y-2 ps-4`,...t,children:e})},li({children:e,...t}){return(0,m.jsx)(`li`,{dir:`auto`,className:`text-gray-700 dark:text-dark-700 leading-relaxed`,...t,children:e})},blockquote({children:e,...t}){return(0,m.jsx)(`blockquote`,{dir:`auto`,className:`border-s-4 border-primary-400 dark:border-primary-500 bg-primary-25 dark:bg-primary-950/30 ps-4 py-3 my-4 rounded-e-lg italic text-gray-700 dark:text-dark-700`,...t,children:e})},h1({children:e,...t}){return(0,m.jsx)(`h1`,{dir:`auto`,className:`text-2xl font-bold mb-4 mt-6 first:mt-0 text-gray-900 dark:text-dark-800 border-b border-gray-200 dark:border-dark-300 pb-2`,...t,children:e})},h2({children:e,...t}){return(0,m.jsx)(`h2`,{dir:`auto`,className:`text-xl font-semibold mb-3 mt-6 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})},h3({children:e,...t}){return(0,m.jsx)(`h3`,{dir:`auto`,className:`text-lg font-medium mb-3 mt-4 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})}},children:n})})};export{_ as RichMessageContent,_ as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-GI9BPwrB.js";import{t as r}from"./useQuery-CXvo2RBT.js";import{t as i}from"./useTranslation-Cs6iTP4m.js";import{C as a,Ct as o,E as s,H as c,M as l,Nt as u,O as d,P as f,St as p,U as m,V as h,Vt as g,X as _,Y as v,Z as y,_t as b,a as x,at as S,c as C,ct as w,h as T,it as ee,j as te,jt as ne,mt as re,n as ie,ot as E,p as D,st as ae,u as oe,vt as O,w as k}from"./ui-vendor-CurEAeCe.js";import{t as se}from"./logger-DbNs3-DK.js";import{t as A}from"./utils-pTFqSV8c.js";import{t as j}from"./Button-DBk-AREB.js";import{D as M,E as ce,F as le,G as ue,I as de,J as fe,L as pe,M as me,N as he,O as ge,P as _e,Q as ve,R as N,U as ye,X as be,et as xe,j as Se,n as P,q as Ce,rt as we,tt as Te,v as F,w as Ee,y as De,z as Oe}from"../assets/index-BKzwVaAM.js";var I=e(n(),1),L=t(),ke=[{href:`https://github.com/libre-webui/libre-webui`,icon:y,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:_,labelKey:`settings.about.links.gitlab`,descriptionKey:`settings.about.links.gitlabDescription`},{href:`https://librewebui.org`,icon:E,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:o,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://ollama.ai`,icon:p,labelKey:`settings.about.links.ollama`,descriptionKey:`settings.about.links.ollamaDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:f,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],Ae=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function je({appVersion:e}){let{t}=i();return(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`mb-4`,children:(0,L.jsx)(P,{className:`text-gray-900 dark:text-gray-100`})}),(0,L.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,L.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,L.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,L.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:Ae.map(e=>(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,L.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,L.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:ke.map(e=>{let n=e.icon;return(0,L.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 p-3 bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg hover:bg-gray-50 dark:hover:bg-dark-200 hover:border-gray-300 dark:hover:border-dark-400 transition-all duration-200 group`,children:[(0,L.jsx)(n,{className:`h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,L.jsx)(E,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.href)})})]}),(0,L.jsx)(`div`,{className:`mt-6 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-gray-500 dark:text-gray-400`,children:[e.includes(`-dev`)?(0,L.jsx)(`span`,{children:t(`settings.about.version`,{version:e})}):(0,L.jsx)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${e}`,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:t(`settings.about.version`,{version:e})}),(0,L.jsxs)(`span`,{children:[t(`settings.about.openSourceBy`,{company:``}),(0,L.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:`Kroonen AI`})]})]})})]})})}var R=se(`components:background-upload`),Me=({className:e=``})=>{let{t}=i(),{preferences:n,setPreferences:r,backgroundImage:a,uploadBackgroundImage:o,removeBackgroundImage:s}=M(),c=(0,I.useRef)(null),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(!1),p=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},h=async e=>{if(!e.type.startsWith(`image/`)){g.error(`Please select a valid image file`);return}if(e.size>5*1024*1024){g.error(`Image file size must be less than 5MB`);return}u(!0);try{await o(e),g.success(`Background image uploaded successfully`)}catch(e){R.error(`Failed to upload background:`,e),g.error(`Failed to upload background image`)}finally{u(!1)}},_=e=>{let t=e.target.files?.[0];t&&h(t)},v=e=>{e.preventDefault(),f(!0)},y=e=>{e.preventDefault(),f(!1)},b=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files?.[0];t&&h(t)},x=()=>{s(),g.success(`Background image removed`)},S=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,enabled:e};if(r({backgroundSettings:n}),t||!e)try{await N.updatePreferences({backgroundSettings:n})}catch(e){R.error(`Failed to update preferences:`,e)}},w=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,blurAmount:e};if(r({backgroundSettings:n}),t)try{await N.updatePreferences({backgroundSettings:n})}catch(e){R.error(`Failed to update preferences:`,e)}},T=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,opacity:e};if(r({backgroundSettings:n}),t)try{await N.updatePreferences({backgroundSettings:n})}catch(e){R.error(`Failed to update preferences:`,e)}};return(0,L.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,L.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,L.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:p.enabled,onChange:e=>S(e.target.checked)}),(0,L.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,L.jsx)(`div`,{className:`relative`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,L.jsx)(`div`,{className:`flex-shrink-0`,children:(0,L.jsx)(`img`,{src:a,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,L.jsx)(j,{variant:`ghost`,size:`sm`,onClick:x,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,L.jsx)(ie,{className:`h-4 w-4`})})]})}):(0,L.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${d?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:v,onDragLeave:y,onDrop:b,onClick:()=>c.current?.click(),children:[(0,L.jsx)(m,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,L.jsxs)(j,{variant:`outline`,size:`sm`,disabled:l,className:`mx-auto`,children:[(0,L.jsx)(C,{className:`h-4 w-4 me-2`}),t(l?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,L.jsx)(`input`,{ref:c,type:`file`,accept:`image/*`,onChange:_,className:`hidden`})]}),a&&(0,L.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.blur`),`:`,` `,p.blurAmount,`px`]}),(0,L.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:p.blurAmount,onChange:e=>w(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.opacity`),`:`,` `,Math.round(p.opacity*100),`%`]}),(0,L.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.1`,value:p.opacity,onChange:e=>T(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]})]})]})})},Ne=()=>{let{t:e,i18n:t}=i();return(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-gray-400`}),(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.appearance.language.title`)})]}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.appearance.language.description`)}),(0,L.jsx)(`select`,{"data-testid":`language-switcher-select`,value:xe(t.language),onChange:e=>{let t=e.target.value;ve(t)},className:`w-full px-3 py-2 text-sm border border-gray-200 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-primary-500`,children:Te.map(e=>(0,L.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))})]})};function Pe({theme:e,preferences:t,onThemeChange:n,onAccentChange:r,onCustomAccentChange:a,onAdaptToAccentChange:o,onShowUsernameChange:s}){let{t:c}=i(),u=e.accent||`blue`,d=e.customAccent||`#2563eb`,f=Se(e);return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(Ne,{}),(0,L.jsx)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:c(`settings.appearance.title`)})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(`button`,{onClick:()=>n(`light`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`light`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,L.jsx)(D,{className:`h-4 w-4`}),c(`settings.appearance.theme.light`)]}),(0,L.jsxs)(`button`,{onClick:()=>n(`dark`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`dark`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,L.jsx)(l,{className:`h-4 w-4`}),c(`settings.appearance.theme.dark`)]})]}),(0,L.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-3`,children:[(0,L.jsx)(`div`,{children:(0,L.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:c(`settings.appearance.accent.title`,{defaultValue:`Accent color`})})}),(0,L.jsx)(`div`,{className:`h-9 w-9 rounded-full border border-gray-200 dark:border-dark-400 shadow-inner flex-shrink-0`,style:{backgroundColor:f},"aria-hidden":`true`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-5 xs:grid-cols-6 sm:grid-cols-9 gap-2`,children:[ge.map(e=>{let t=u===e.id;return(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`relative h-10 rounded-xl border transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${t?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,style:{backgroundColor:e.color},"aria-label":c(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,L.jsx)(O,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})},e.id)}),(0,L.jsxs)(`label`,{className:`relative h-10 rounded-xl border transition-all duration-200 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-500 focus-within:ring-offset-2 dark:focus-within:ring-offset-dark-50 overflow-hidden cursor-pointer ${u===`custom`?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,title:c(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":c(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,L.jsx)(`input`,{type:`color`,value:d,onInput:e=>a(e.currentTarget.value),onChange:e=>a(e.target.value),className:`absolute inset-0 h-full w-full cursor-pointer opacity-0`}),(0,L.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:d},"aria-hidden":`true`}),(0,L.jsx)(te,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),(0,L.jsxs)(`div`,{className:`mt-5 border-t border-gray-200 pt-5 dark:border-dark-300`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:c(`settings.appearance.accent.behaviorTitle`)}),(0,L.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.behaviorDescription`)}),(0,L.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(`button`,{type:`button`,"aria-pressed":!e.adaptToAccent,onClick:()=>o(!1),className:`rounded-xl border p-3 text-start transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${e.adaptToAccent?`border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-100 dark:hover:border-dark-400 dark:hover:bg-dark-200`:`border-primary-500 bg-primary-50/70 shadow-sm dark:border-primary-400 dark:bg-primary-950/25`}`,children:[(0,L.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:c(`settings.appearance.accent.defaultStyle`)}),(0,L.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,L.jsxs)(`button`,{type:`button`,"aria-pressed":e.adaptToAccent===!0,onClick:()=>o(!0),className:`rounded-xl border p-3 text-start transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${e.adaptToAccent?`border-primary-500 bg-primary-50/70 shadow-sm dark:border-primary-400 dark:bg-primary-950/25`:`border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-100 dark:hover:border-dark-400 dark:hover:bg-dark-200`}`,children:[(0,L.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:c(`settings.appearance.accent.adaptedStyle`)}),(0,L.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:c(`settings.appearance.chatInterface.title`)}),(0,L.jsx)(`div`,{className:`space-y-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:c(`settings.appearance.chatInterface.showUsername`)}),(0,L.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`settings.appearance.chatInterface.showUsernameDescription`)})]}),(0,L.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showUsername,onChange:e=>s(e.target.checked)}),(0,L.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]})})]}),(0,L.jsx)(Me,{})]})}function Fe({sessionCount:e,loading:t,importing:n,showImportOptions:r,mergeStrategy:a,importResult:o,importFileInputRef:s,onExportData:c,onImportFileSelect:l,onClearAllHistory:u,onMergeStrategyChange:d,onConfirmImport:f,onCancelImport:p,onDismissImportResult:m}){let{t:h}=i();return(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.data.title`)}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.export`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.exportDescription`)}),(0,L.jsx)(j,{onClick:c,variant:`outline`,size:`sm`,className:`w-full`,children:h(`settings.data.exportAll`)})]}),(0,L.jsxs)(`div`,{className:`flex flex-col`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.import`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.importDescription`)}),(0,L.jsx)(`input`,{ref:s,type:`file`,accept:`.json`,onChange:l,className:`hidden`}),(0,L.jsx)(j,{onClick:()=>s.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,L.jsxs)(`div`,{className:`flex flex-col`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.clearSessions`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.clearSessionsDescription`)}),(0,L.jsx)(j,{onClick:u,variant:`outline`,size:`sm`,className:`w-full text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border-red-200 hover:border-red-300 dark:border-red-800 dark:hover:border-red-700`,disabled:e===0||t,children:t?h(`settings.data.clearing`):h(`settings.data.clearAll`,{count:e})})]})]}),r&&(0,L.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,L.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:h(`settings.data.importOptions`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:h(`settings.data.importOptionsDescription`)}),(0,L.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,L.jsxs)(`label`,{className:`flex items-center`,children:[(0,L.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:a===`skip`,onChange:e=>d(e.target.value),className:`me-2`}),(0,L.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.skipDuplicates`)})]}),(0,L.jsxs)(`label`,{className:`flex items-center`,children:[(0,L.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:a===`overwrite`,onChange:e=>d(e.target.value),className:`me-2`}),(0,L.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.overwrite`)})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(j,{onClick:f,size:`sm`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.import`)}),(0,L.jsx)(j,{onClick:p,variant:`outline`,size:`sm`,children:h(`common.cancel`)})]})]}),o&&(0,L.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,L.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:h(`settings.data.importResults`)}),(0,L.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,L.jsxs)(`div`,{children:[h(`settings.data.preferences`),`:`,` `,o.preferences.imported?h(`settings.data.imported`):h(`settings.data.failed`)]}),(0,L.jsxs)(`div`,{children:[h(`settings.data.sessions`),`:`,` `,o.sessions.imported,` `,h(`settings.data.importedLabel`),`,`,o.sessions.skipped,` `,h(`settings.data.skipped`)]}),(0,L.jsxs)(`div`,{children:[h(`settings.data.documents`),`:`,` `,o.documents.imported,` `,h(`settings.data.importedLabel`),`,`,` `,o.documents.skipped,` `,h(`settings.data.skipped`)]}),(o.sessions.errors.length>0||o.documents.errors.length>0)&&(0,L.jsxs)(`div`,{className:`mt-2`,children:[(0,L.jsxs)(`p`,{className:`font-medium`,children:[h(`settings.data.errors`),`:`]}),o.sessions.errors.map((e,t)=>(0,L.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`session-${t}`)),o.documents.errors.map((e,t)=>(0,L.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`document-${t}`))]})]}),(0,L.jsx)(j,{onClick:m,variant:`outline`,size:`sm`,className:`mt-2`,children:h(`common.close`)})]})]})]})})}function z({checked:e,onChange:t,disabled:n=!1}){return(0,L.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),disabled:n,className:`sr-only`}),(0,L.jsx)(`div`,{className:A(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2`,n?`bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed`:e?`bg-primary-600 dark:bg-primary-500`:`bg-gray-200 dark:bg-dark-300`),children:(0,L.jsx)(`span`,{className:A(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})]})}function Ie({settings:e,effectiveSettings:t,modelOptions:n,status:r,regenerating:a,onSettingChange:o,onReset:s,onRegenerate:c,onSave:l}){let{t:u}=i();return(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.documents.title`)}),(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 p-4 rounded-lg border border-gray-200 dark:border-dark-300 space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u(`settings.documents.embeddings.title`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:u(`settings.documents.embeddings.enable`)})]}),(0,L.jsx)(z,{checked:e.enabled,onChange:e=>o(`enabled`,e)})]}),e.enabled&&(0,L.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:u(`settings.documents.embeddings.model`)}),(0,L.jsx)(F,{value:t.model,onChange:e=>o(`model`,e.target.value),options:n}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:u(`settings.documents.embeddings.modelDescription`)})]}),(0,L.jsx)(Le,{label:u(`settings.documents.embeddings.chunkSize`),value:e.chunkSize,min:500,max:2e3,step:100,description:u(`settings.documents.embeddings.chunkSizeDescription`),onChange:e=>o(`chunkSize`,e)}),(0,L.jsx)(Le,{label:u(`settings.documents.embeddings.chunkOverlap`),value:e.chunkOverlap,min:50,max:500,step:50,description:u(`settings.documents.embeddings.chunkOverlapDescription`),onChange:e=>o(`chunkOverlap`,e)}),(0,L.jsx)(Le,{label:u(`settings.documents.embeddings.similarityThreshold`),value:e.similarityThreshold,min:.3,max:.9,step:.05,description:u(`settings.documents.embeddings.similarityDescription`),format:e=>e.toFixed(2),onChange:e=>o(`similarityThreshold`,e)})]})]}),r&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:u(`settings.documents.embeddings.status`)}),(0,L.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,L.jsxs)(`div`,{children:[u(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,L.jsx)(`span`,{className:r.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:r.available?u(`settings.documents.embeddings.available`):u(`settings.documents.embeddings.unavailable`)})]}),(0,L.jsxs)(`div`,{children:[u(`settings.documents.embeddings.model`),`:`,` `,(0,L.jsx)(`span`,{className:`font-medium`,children:r.model})]}),(0,L.jsxs)(`div`,{children:[u(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,L.jsxs)(`span`,{className:`font-medium`,children:[r.chunksWithEmbeddings,` / `,r.totalChunks]})]}),r.totalChunks>0&&(0,L.jsxs)(`div`,{children:[u(`settings.documents.embeddings.coverage`),`:`,` `,(0,L.jsxs)(`span`,{className:`font-medium`,children:[Math.round(r.chunksWithEmbeddings/r.totalChunks*100),`%`]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsxs)(j,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,L.jsx)(k,{size:16}),u(`settings.generation.resetDefaults`)]}),e.enabled&&r&&r.totalChunks>0&&(0,L.jsxs)(j,{onClick:c,disabled:a,variant:`outline`,className:`flex items-center gap-2 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20`,children:[(0,L.jsx)(w,{size:16}),u(a?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,L.jsxs)(j,{onClick:l,className:`flex items-center gap-2`,children:[(0,L.jsx)(O,{size:16}),u(`settings.saveSettings`)]})]})]})})}function Le({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,L.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full range-slider`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function Re({generationOptions:e,embeddingSettings:t,effectiveEmbeddingSettings:n,embeddingModelOptions:r,embeddingStatus:a,onGenerationOptionChange:o,onEmbeddingSettingsChange:s,onResetGenerationOptions:c,onSaveGenerationOptions:l,onResetEmbeddingSettings:u,onSaveEmbeddingSettings:d}){let{t:f}=i();return(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:f(`settings.generation.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:f(`settings.generation.description`)}),(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(B,{title:f(`settings.generation.coreParameters`),children:[(0,L.jsx)(V,{label:f(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:f(`settings.generation.temperatureDescription`),onChange:e=>o(`temperature`,e)}),(0,L.jsx)(V,{label:f(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:f(`settings.generation.topPDescription`),onChange:e=>o(`top_p`,e)}),(0,L.jsx)(V,{label:f(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:f(`settings.generation.topKDescription`),onChange:e=>o(`top_k`,e)}),(0,L.jsx)(V,{label:f(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:f(`settings.generation.minPDescription`),onChange:e=>o(`min_p`,e)})]}),(0,L.jsxs)(B,{title:f(`settings.generation.generationControl`),children:[(0,L.jsx)(V,{label:f(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:f(`settings.generation.maxTokensDescription`),onChange:e=>o(`num_predict`,e)}),(0,L.jsx)(V,{label:f(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:f(`settings.generation.repeatPenaltyDescription`),onChange:e=>o(`repeat_penalty`,e)}),(0,L.jsx)(V,{label:f(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:f(`settings.generation.contextLengthDescription`),onChange:e=>o(`num_ctx`,e)}),(0,L.jsx)(V,{label:f(`settings.generation.seed`),hint:`(${f(`settings.generation.optional`)})`,value:e.seed,placeholder:f(`settings.generation.random`),integer:!0,description:f(`settings.generation.seedDescription`),onChange:e=>o(`seed`,e)})]}),(0,L.jsxs)(B,{title:f(`settings.generation.advancedOptions`),children:[(0,L.jsx)(V,{label:f(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:f(`settings.generation.presencePenaltyDescription`),onChange:e=>o(`presence_penalty`,e)}),(0,L.jsx)(V,{label:f(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:f(`settings.generation.frequencyPenaltyDescription`),onChange:e=>o(`frequency_penalty`,e)}),(0,L.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[f(`settings.generation.stopSequences`),(0,L.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,f(`settings.generation.commaSeparated`),`)`]})]}),(0,L.jsx)(`input`,{type:`text`,value:e.stop?.join(`, `)??``,onChange:e=>o(`stop`,e.target.value?e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,placeholder:`\\\\n, ###, STOP`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:f(`settings.generation.stopSequencesDescription`)})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,L.jsxs)(j,{onClick:c,variant:`outline`,className:`flex items-center gap-2`,children:[(0,L.jsx)(k,{size:16}),f(`settings.generation.resetDefaults`)]}),(0,L.jsxs)(j,{onClick:l,className:`flex items-center gap-2`,children:[(0,L.jsx)(O,{size:16}),f(`settings.generation.saveOptions`)]})]})]}),(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:f(`settings.generation.embeddingSettings`)}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:f(`settings.generation.enableEmbeddings`)}),(0,L.jsx)(z,{checked:t.enabled,onChange:e=>s(`enabled`,e)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:f(`settings.documents.embeddings.model`)}),(0,L.jsx)(F,{value:n.model,onChange:e=>s(`model`,e.target.value),options:r,disabled:!t.enabled})]}),(0,L.jsx)(H,{label:f(`settings.documents.embeddings.chunkSize`),hint:f(`settings.documents.embeddings.chunkSizeInTokens`),value:t.chunkSize,min:1,disabled:!t.enabled,onChange:e=>s(`chunkSize`,e)}),(0,L.jsx)(H,{label:f(`settings.documents.embeddings.chunkOverlap`),hint:f(`settings.documents.embeddings.chunkOverlapInTokens`),value:t.chunkOverlap,min:0,disabled:!t.enabled,onChange:e=>s(`chunkOverlap`,e)}),(0,L.jsx)(H,{label:f(`settings.documents.embeddings.similarityThreshold`),value:t.similarityThreshold,min:0,max:1,step:.01,disabled:!t.enabled,onChange:e=>s(`similarityThreshold`,e)})]}),a&&(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,L.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[f(`settings.documents.embeddings.status`),`:`]}),(0,L.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:a.available?f(`settings.documents.embeddings.available`):f(`settings.documents.embeddings.unavailable`)})]}),a.available&&(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,L.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[f(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,L.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[a.chunksWithEmbeddings,` /`,` `,a.totalChunks]})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,L.jsxs)(j,{onClick:u,variant:`outline`,className:`flex items-center gap-2`,children:[(0,L.jsx)(k,{size:16}),f(`settings.generation.resetDefaults`)]}),(0,L.jsxs)(j,{onClick:d,className:`flex items-center gap-2`,children:[(0,L.jsx)(O,{size:16}),f(`settings.saveSettings`)]})]})]})})]})})}function B({title:e,children:t}){return(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function V({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,L.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,L.jsx)(`input`,{type:`number`,min:a,max:o,step:s,value:t??``,placeholder:n,onChange:e=>l(e.target.value?c?parseInt(e.target.value):parseFloat(e.target.value):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function H({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,L.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,L.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,disabled:o})]})}function ze({loading:e,settings:t,effectiveSettings:n,models:r,plugins:a,sizes:o,qualities:s,styles:c,onSettingChange:l,onModelChange:d,onReset:f,onSave:p}){let{t:h}=i();return(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.imageGen.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:h(`settings.imageGen.description`)}),e?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,L.jsx)(u,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,L.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:h(`settings.imageGen.loadingProviders`)})]}):r.length===0?(0,L.jsx)(`div`,{className:`bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(m,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-200`,children:h(`settings.imageGen.noProviders`)}),(0,L.jsx)(`p`,{className:`text-sm text-yellow-700 dark:text-yellow-300 mt-1`,children:h(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:h(`settings.imageGen.enable`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:h(`settings.imageGen.enableDescription`)})]}),(0,L.jsx)(z,{checked:t.enabled,onChange:e=>l(`enabled`,e)})]})}),(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.imageGen.configuration`)}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.imageGen.model`)}),(0,L.jsx)(F,{value:n.model,onChange:e=>d(e.target.value),disabled:!t.enabled,options:[{value:``,label:h(`settings.model.selectModel`)},...r.map(e=>({value:e.model,label:`${e.model} (${e.plugin})`}))]}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:h(`settings.imageGen.modelDescription`)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.imageGen.size`)}),(0,L.jsx)(F,{value:n.size,onChange:e=>l(`size`,e.target.value),disabled:!t.enabled||o.length===0,options:[...o.length>0?o.map(e=>({value:e,label:e})):[{value:`1024x1024`,label:`1024x1024`},{value:`1792x1024`,label:`1792x1024`},{value:`1024x1792`,label:`1024x1792`}]]}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:h(`settings.imageGen.sizeDescription`)})]}),s.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.imageGen.quality`)}),(0,L.jsx)(F,{value:n.quality,onChange:e=>l(`quality`,e.target.value),disabled:!t.enabled,options:s.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:h(`settings.imageGen.qualityDescription`)})]}),c.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.imageGen.style`)}),(0,L.jsx)(F,{value:n.style,onChange:e=>l(`style`,e.target.value),disabled:!t.enabled,options:c.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:h(`settings.imageGen.styleDescription`)})]})]})]}),a.length>0&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:h(`settings.imageGen.availableProviders`)}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,L.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,L.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,h(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,L.jsxs)(j,{onClick:f,variant:`outline`,className:`flex items-center gap-2`,children:[(0,L.jsx)(k,{size:16}),h(`common.reset`)]}),(0,L.jsxs)(j,{onClick:p,className:`flex items-center gap-2`,children:[(0,L.jsx)(O,{size:16}),h(`settings.saveSettings`)]})]})]})]})})}function Be({models:e,selectedModel:t,systemMessage:n,tempSystemMessage:r,loading:a,user:o,systemInfo:s,preferences:c,currentTaskModel:l,autoTitleTaskModelOptions:u,updatingModelPullAccess:d,updatingAllModels:f,updateProgress:p,onModelPullAccessToggle:m,onModelChange:h,onSystemMessageChange:g,onSystemMessageSave:_,onAutoTitleChange:v,onAutoTitleTaskModelChange:y,onUpdateAllModels:b}){let{t:x}=i(),S=e.find(e=>e.name===t);return(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:x(`settings.model.title`)}),(0,L.jsxs)(`div`,{className:`space-y-6`,children:[o?.role===`admin`&&(0,L.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:x(`settings.model.modelPullAccess`)}),(0,L.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:x(`settings.model.modelPullAccessDescription`)})]}),(0,L.jsx)(z,{checked:s?.allowUserModelPull??!0,onChange:m,disabled:d})]})}),(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.model.defaultModel`)}),(0,L.jsx)(F,{value:t||``,onChange:h,options:[{value:``,label:x(`settings.model.selectModel`)},...e.map(e=>({value:e.name,label:e.isPersona?`${e.personaName} (${x(`settings.model.persona`)})`:e.name}))]}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:x(`settings.model.defaultModelDescription`)})]}),t&&(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.model.currentModelInfo`)}),(0,L.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,L.jsx)(U,{label:`${x(`settings.model.name`)}:`,value:t,truncate:!0}),S?.details&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(U,{label:`${x(`settings.model.size`)}:`,value:S.details.parameter_size}),(0,L.jsx)(U,{label:`${x(`settings.model.family`)}:`,value:S.details.family}),(0,L.jsx)(U,{label:`${x(`settings.model.format`)}:`,value:S.details.format})]})]})})]}),(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.systemMessage.title`)}),(0,L.jsx)(De,{value:r,onChange:g,placeholder:x(`settings.systemMessage.placeholder`),className:`w-full min-h-[100px] bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,rows:4}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:x(`settings.systemMessage.description`)}),(0,L.jsx)(j,{onClick:_,size:`sm`,disabled:a||r===n,children:x(`common.save`)})]})]})]}),(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.model.autoTitle.title`)}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:x(`settings.model.autoTitle.enable`)}),(0,L.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:x(`settings.model.autoTitle.enableDescription`)})]}),(0,L.jsx)(z,{checked:c.titleSettings?.autoTitle||!1,onChange:v})]}),c.titleSettings?.autoTitle&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:x(`settings.model.autoTitle.taskModel`)}),(0,L.jsx)(F,{value:l,onChange:e=>y(e.target.value),options:u}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:x(`settings.model.autoTitle.taskModelDescription`)})]})]})]})}),(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.model.bulkOperations`)}),(0,L.jsx)(`div`,{className:`space-y-3`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:x(`settings.model.updateAll`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:x(`settings.model.updateAllDescription`)}),f&&p&&(0,L.jsx)(Ve,{progress:p}),(0,L.jsx)(j,{onClick:b,variant:`outline`,size:`sm`,className:`w-full`,disabled:f||a||e.length===0,children:f?x(`settings.model.updating`):x(`settings.model.updateAllButton`,{count:e.length})})]})})]})})]})})}function U({label:e,value:t,truncate:n=!1}){return(0,L.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-white dark:bg-dark-100 rounded-md border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,L.jsx)(`span`,{className:n?`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ms-2`:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t})]})}function Ve({progress:e}){let{t}=i(),n=Math.round(e.current/e.total*100);return(0,L.jsxs)(`div`,{className:`mb-4 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,L.jsx)(`span`,{className:`text-gray-600 dark:text-dark-600 font-medium`,children:t(`settings.model.updatingModel`,{name:e.modelName,current:e.current,total:e.total})}),(0,L.jsxs)(`span`,{className:`text-primary-600 dark:text-primary-400 font-semibold`,children:[n,`%`]})]}),(0,L.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-3 shadow-subtle`,children:(0,L.jsx)(`div`,{className:`bg-gradient-to-r from-primary-500 to-primary-600 dark:from-primary-400 dark:to-primary-500 h-3 rounded-full transition-all duration-500 ease-out shadow-glow`,style:{width:`${e.current/e.total*100}%`}})}),(0,L.jsxs)(`div`,{className:`text-xs flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:[t(`settings.model.status`),`:`,` `,e.status===`starting`?(0,L.jsx)(`span`,{className:`text-accent-500 dark:text-accent-400`,children:t(`settings.model.statusStarting`)}):e.status===`success`?(0,L.jsx)(`span`,{className:`text-success-600 dark:text-success-500`,children:t(`settings.model.statusComplete`)}):e.status===`error`?(0,L.jsxs)(`span`,{className:`text-error-600 dark:text-error-500`,children:[t(`settings.model.statusError`),`: `,e.error]}):``]}),(0,L.jsx)(`span`,{className:`text-gray-400 dark:text-dark-600 text-[10px]`,children:t(`settings.model.modelsProgress`,{current:e.current,total:e.total})})]})]})}se(`components:hugging-face-model-browser`);var He=({plugin:e})=>{let{t}=i(),{pluginVariables:n,fetchPluginVariables:r,updatePluginVariables:o,resetPluginVariables:s}=ce(),[c,l]=(0,I.useState)({}),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(new Set),[_,v]=(0,I.useState)({}),y=(0,I.useMemo)(()=>e.variables||[],[e.variables]),b=(0,I.useMemo)(()=>n[e.id]||{},[n,e.id]);(0,I.useEffect)(()=>{r(e.id)},[r,e.id]);let x=JSON.stringify(b),[C,w]=(0,I.useState)(null);if(C!==x){let e=JSON.parse(x);if(!(Object.keys(e).length===0&&f)){let t={};for(let n of y){let r=e[n.name];r?.has_value&&!r.is_sensitive?t[n.name]=r.value:t[n.name]=n.default??(n.type===`boolean`?!1:n.type===`number`?0:``)}l(t),p(!0)}w(x)}let T=async()=>{let n={};for(let e of y){let r=c[e.name];if(e.name===`endpoint`&&typeof r==`string`&&r.length>0)try{new URL(r)}catch{n[e.name]=t(`pluginManager.variables.invalidUrl`,`Must be a valid URL`)}if(e.type===`number`){let t=Number(r);e.min!==void 0&&t<e.min&&(n[e.name]=`Min: ${e.min}`),e.max!==void 0&&t>e.max&&(n[e.name]=`Max: ${e.max}`)}e.type===`string`&&typeof r==`string`&&r.length>2048&&(n[e.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(v(n),Object.keys(n).length>0)return;d(!0);let r=await o(e.id,c);d(!1),r?g.success(t(`pluginManager.variables.saved`,`Variables saved`)):g.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))},te=async()=>{await s(e.id);let n={};for(let e of y)n[e.name]=e.default??(e.type===`boolean`?!1:e.type===`number`?0:``);l(n),g.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))},ne=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},re=e=>{let n=c[e.name],r=e.sensitive??!1,i=m.has(e.name),a=b[e.name],o=A(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-white dark:bg-dark-100`,`border-gray-300 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-blue-500/20`);switch(e.type){case`boolean`:return(0,L.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:!!(n??!1),onChange:t=>l(n=>({...n,[e.name]:t.target.checked})),className:`rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500`}),(0,L.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.label})]});case`select`:return(0,L.jsx)(`select`,{value:String(n??``),onChange:t=>l(n=>({...n,[e.name]:t.target.value})),className:o,children:(e.options||[]).map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))});case`number`:return(0,L.jsx)(`input`,{type:`number`,value:n??0,min:e.min,max:e.max,onChange:t=>l(n=>({...n,[e.name]:t.target.value===``?0:Number(t.target.value)})),className:o});default:return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`input`,{type:r&&!i?`password`:`text`,value:r&&a?.has_value&&n===``?``:String(n??``),placeholder:r&&a?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):void 0,onChange:t=>l(n=>({...n,[e.name]:t.target.value})),className:A(o,r&&`pr-10`)}),r&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>ne(e.name),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,children:i?(0,L.jsx)(ee,{className:`w-4 h-4`}):(0,L.jsx)(S,{className:`w-4 h-4`})})]})}};return(0,L.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[(0,L.jsx)(`div`,{className:`space-y-3`,children:y.map(e=>(0,L.jsxs)(`div`,{children:[e.type!==`boolean`&&(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[e.label,e.required&&(0,L.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&e.type!==`boolean`&&(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:e.description}),re(e),_[e.name]&&(0,L.jsx)(`p`,{className:`text-xs text-red-500 mt-1`,children:_[e.name]})]},e.name))}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,L.jsxs)(j,{size:`sm`,onClick:T,disabled:u,className:`gap-1.5`,children:[(0,L.jsx)(a,{className:`w-3.5 h-3.5`}),u?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,L.jsxs)(j,{variant:`outline`,size:`sm`,onClick:te,className:`gap-1.5`,children:[(0,L.jsx)(k,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function Ue({plugins:e,loading:t,uploading:n,error:r,hasKeys:a,showUploadForm:o,showJsonForm:c,jsonInput:l,fileInputRef:u,expandedPluginId:d,pluginApiKeys:f,showApiKey:p,savingApiKey:m,onClearError:h,onShowUploadFormChange:g,onShowJsonFormChange:_,onJsonInputChange:v,onFileUpload:y,onJsonSubmit:b,onExpandedPluginChange:x,onPluginApiKeyChange:S,onShowApiKeyChange:w,onActivatePlugin:T,onDeletePlugin:ee,onExportPlugin:te,onSaveApiKey:ne,onDeleteApiKey:re}){let{t:E}=i(),D=e.filter(e=>e.active);return(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:E(`settings.plugins.title`)}),r&&(0,L.jsx)(`div`,{className:`p-4 bg-primary-50/80 dark:bg-primary-950/25 border border-primary-200 dark:border-primary-800/50 rounded-lg mb-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:r}),(0,L.jsx)(j,{variant:`ghost`,size:`sm`,onClick:h,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,L.jsx)(ie,{className:`h-4 w-4`})})]})}),(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:E(`settings.plugins.addNew`)}),(0,L.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,L.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>g(!o),disabled:t||n,children:[(0,L.jsx)(C,{className:`h-4 w-4 me-2`}),E(`settings.plugins.upload`)]}),(0,L.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>_(!c),disabled:t,children:E(`settings.plugins.addJson`)})]})]}),o&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,L.jsx)(`input`,{ref:u,type:`file`,accept:`.json,.zip`,onChange:y,className:`flex-1 p-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 file:me-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 dark:file:bg-dark-200 dark:file:text-dark-700 hover:file:bg-gray-200 dark:hover:file:bg-dark-300`,disabled:n}),(0,L.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>g(!1),disabled:n,children:E(`common.cancel`)})]}),n&&(0,L.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:E(`settings.plugins.uploading`)})]}),c&&(0,L.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`textarea`,{value:l,onChange:e=>v(e.target.value),placeholder:E(`settings.plugins.jsonPlaceholder`),className:`w-full h-32 p-3 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500 font-mono text-sm`,disabled:t}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,L.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>{_(!1),v(``)},children:E(`common.cancel`)}),(0,L.jsx)(j,{size:`sm`,onClick:b,disabled:!l.trim()||t,children:E(`settings.plugins.install`)})]})]})})]}),D.length>0&&(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,L.jsxs)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:[E(`settings.plugins.active`),` (`,D.length,`)`]}),(0,L.jsx)(`div`,{className:`space-y-2`,children:D.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`font-medium text-green-800 dark:text-green-200`,children:e.name}),(0,L.jsxs)(`p`,{className:`text-xs text-green-600 dark:text-green-300`,children:[e.type,` • `,e.model_map?.length||0,` `,E(`settings.plugins.models`)]})]}),(0,L.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>T(e.id),className:`text-green-600 border-green-300 hover:bg-green-100`,children:E(`settings.plugins.deactivate`)})]},e.id))})]}),(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`div`,{className:`p-4 border-b border-gray-200 dark:border-dark-300`,children:(0,L.jsxs)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[E(`settings.plugins.installed`),` (`,e.length,`)`]})}),t?(0,L.jsx)(`div`,{className:`p-8 text-center`,children:(0,L.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:E(`settings.plugins.loading`)})}):e.length===0?(0,L.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,L.jsx)(s,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,L.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:E(`settings.plugins.noPlugins`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:E(`settings.plugins.noPluginsDescription`)})]}):(0,L.jsx)(`div`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,L.jsx)(We,{plugin:e,loading:t,hasApiKey:a[e.id]||!1,expanded:d===e.id,apiKey:f[e.id]||``,showApiKey:p[e.id]||!1,savingApiKey:m===e.id,onExpand:()=>x(d===e.id?null:e.id),onActivate:()=>T(e.id),onExport:()=>te(e.id),onDelete:()=>ee(e.id),onApiKeyChange:t=>S(e.id,t),onShowApiKeyChange:t=>w(e.id,t),onSaveApiKey:()=>ne(e.id),onDeleteApiKey:()=>re(e.id)},e.id))})]})]})})}function We({plugin:e,loading:t,hasApiKey:n,expanded:r,apiKey:a,showApiKey:o,savingApiKey:s,onExpand:c,onActivate:l,onExport:u,onDelete:d,onApiKeyChange:f,onShowApiKeyChange:p,onSaveApiKey:m,onDeleteApiKey:g}){let{t:_}=i();return(0,L.jsxs)(`div`,{className:`p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,L.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,L.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0 ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h5`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,L.jsxs)(`div`,{className:`flex items-center space-x-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,L.jsx)(`span`,{children:e.type}),(0,L.jsx)(`span`,{children:`•`}),(0,L.jsxs)(`span`,{children:[e.model_map?.length||0,` `,_(`settings.plugins.models`)]}),e.endpoint&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:`•`}),(0,L.jsx)(`span`,{className:`truncate max-w-32`,children:e.endpoint})]}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:`•`}),(0,L.jsx)(`span`,{className:`text-green-600`,children:_(`settings.plugins.apiKeySet`)})]})]})]})]})}),(0,L.jsxs)(`div`,{className:`flex items-center space-x-1 flex-shrink-0`,children:[(0,L.jsxs)(j,{variant:`ghost`,size:`sm`,onClick:c,title:`Configure API key`,className:n?`text-green-600`:`text-amber-600`,children:[(0,L.jsx)(h,{className:`h-4 w-4`}),r?(0,L.jsx)(re,{className:`h-3 w-3`}):(0,L.jsx)(b,{className:`h-3 w-3`})]}),(0,L.jsx)(j,{variant:`outline`,size:`sm`,onClick:l,disabled:t,className:e.active?`text-green-600 border-green-300`:``,children:e.active?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(O,{className:`h-4 w-4 me-1`}),_(`settings.plugins.activeLabel`)]}):_(`settings.plugins.activate`)}),(0,L.jsx)(j,{variant:`ghost`,size:`sm`,onClick:u,disabled:t,title:`Export plugin`,children:(0,L.jsx)(ae,{className:`h-4 w-4`})}),(0,L.jsx)(j,{variant:`ghost`,size:`sm`,onClick:d,disabled:t,className:`text-red-600 hover:text-red-700 hover:bg-red-50`,title:`Delete plugin`,children:(0,L.jsx)(oe,{className:`h-4 w-4`})})]})]}),r&&(0,L.jsx)(Ge,{plugin:e,hasApiKey:n,apiKey:a,showApiKey:o,savingApiKey:s,onApiKeyChange:f,onShowApiKeyChange:p,onSaveApiKey:m,onDeleteApiKey:g}),e.variables&&e.variables.length>0&&(0,L.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(ne,{className:`h-4 w-4 text-gray-500`}),(0,L.jsxs)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[_(`settings.plugins.variables`,`Variables`),` (`,e.variables.length,`)`]})]}),(0,L.jsx)(He,{plugin:e})]})]})}function Ge({plugin:e,hasApiKey:t,apiKey:n,showApiKey:r,savingApiKey:a,onApiKeyChange:o,onShowApiKeyChange:s,onSaveApiKey:c,onDeleteApiKey:l}){let{t:d}=i();return(0,L.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,L.jsx)(h,{className:`h-4 w-4 text-gray-500`}),(0,L.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:d(`settings.plugins.apiKeyConfiguration`)})]}),(0,L.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[d(`settings.plugins.apiKeyDescription`,{name:e.name}),e.auth?.key_env&&(0,L.jsxs)(`span`,{className:`block mt-1`,children:[d(`settings.plugins.apiKeyEnvAlternative`),` `,(0,L.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,d(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,L.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(O,{className:`h-4 w-4 text-green-600`}),(0,L.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:d(`settings.plugins.apiKeyConfigured`)})]}),(0,L.jsx)(j,{variant:`outline`,size:`sm`,onClick:l,disabled:a,className:`text-red-600 border-red-300 hover:bg-red-50`,children:a?(0,L.jsx)(u,{className:`h-4 w-4 animate-spin`}):d(`common.remove`)})]}):(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`input`,{type:r?`text`:`password`,value:n,onChange:e=>o(e.target.value),placeholder:d(`settings.plugins.apiKeyPlaceholder`),className:`w-full p-2 pe-10 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(!r),className:`absolute end-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600`,children:r?(0,L.jsx)(ee,{className:`h-4 w-4`}):(0,L.jsx)(S,{className:`h-4 w-4`})})]}),(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsx)(j,{size:`sm`,onClick:c,disabled:a||!n.trim(),children:a?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-4 w-4 me-2 animate-spin`}),d(`common.saving`)]}):d(`settings.plugins.saveApiKey`)})})]})]})}function Ke({loading:e,settings:t,effectiveSettings:n,models:r,plugins:a,voices:o,testing:s,onSettingChange:c,onModelChange:l,onReset:f,onTest:p,onSave:m}){let{t:h}=i(),g=r.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.tts.title`)}),(0,L.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:h(`settings.tts.description`)}),e?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,L.jsx)(u,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,L.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:h(`settings.tts.loadingProviders`)})]}):r.length===0?(0,L.jsx)(`div`,{className:`bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(x,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-200`,children:h(`settings.tts.noProviders`)}),(0,L.jsx)(`p`,{className:`text-sm text-yellow-700 dark:text-yellow-300 mt-1`,children:h(`settings.tts.noProvidersDescription`)})]})]})}):(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:h(`settings.tts.enable`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:h(`settings.tts.enableDescription`)})]}),(0,L.jsx)(z,{checked:t.enabled,onChange:e=>c(`enabled`,e)})]})}),(0,L.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:h(`settings.tts.autoPlay`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:h(`settings.tts.autoPlayDescription`)})]}),(0,L.jsx)(z,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>c(`autoPlay`,e)})]})}),(0,L.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:h(`settings.tts.streamSentences`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:h(`settings.tts.streamSentencesDescription`)})]}),(0,L.jsx)(z,{checked:t.streamSentences||!1,disabled:!t.enabled,onChange:e=>c(`streamSentences`,e)})]})}),(0,L.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.tts.voiceConfiguration`)}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.tts.model`)}),(0,L.jsx)(F,{"aria-label":h(`settings.tts.model`),value:g?le(g):``,onChange:e=>{let t=r.find(t=>le(t)===e.target.value);t&&l(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:h(`settings.model.selectModel`)},...r.map(e=>({value:le(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:h(`settings.tts.modelDescription`)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.tts.voice`)}),(0,L.jsx)(F,{"aria-label":h(`settings.tts.voice`),value:n.voice,onChange:e=>c(`voice`,e.target.value),disabled:!t.enabled||o.length===0,options:[{value:``,label:h(`settings.tts.selectVoice`)},...o.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))]}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:h(`settings.tts.voiceDescription`)})]})]})]}),a.length>0&&(0,L.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:h(`settings.tts.availableProviders`)}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,L.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,L.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,L.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,h(`settings.tts.models`),`)`]})]},e.id))})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsxs)(j,{onClick:f,variant:`outline`,className:`flex items-center gap-2`,children:[(0,L.jsx)(k,{size:16}),h(`common.reset`)]}),(0,L.jsx)(j,{onClick:p,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:s?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(T,{size:16}),h(`settings.tts.stop`)]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(d,{size:16}),h(`settings.tts.test`)]})})]}),(0,L.jsxs)(j,{onClick:m,className:`flex items-center gap-2`,children:[(0,L.jsx)(O,{size:16}),h(`settings.saveSettings`)]})]})]})]})})}function qe({preferences:e,sessions:t,loadPreferences:n,loadSessions:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(`skip`),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null),m=(0,I.useRef)(null),h=()=>{p(null),m.current&&(m.current.value=``)};return{importing:i,showImportOptions:o,mergeStrategy:c,setMergeStrategy:l,importResult:u,setImportResult:d,importFileInputRef:m,handleExportData:()=>{let n={format:`libre-webui-export`,version:`1.0`,preferences:e,sessions:t,documents:[],exportedAt:new Date().toISOString()},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`libre-webui-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),g.success(`Data exported successfully`)},handleImportFileSelect:e=>{let t=e.target.files?.[0];t&&(p(t),s(!0),d(null))},handleConfirmImport:async()=>{if(f){a(!0);try{let e=await f.text(),t=JSON.parse(e);if(!t.format||t.format!==`libre-webui-export`)throw Error(`Invalid export format. Please use a valid Libre WebUI export file.`);let i=await N.importData(t,c===`overwrite`?`replace`:`merge`);if(i.success&&i.data)d({preferences:{imported:!0,error:null},sessions:{imported:0,skipped:0,errors:[]},documents:{imported:0,skipped:0,errors:[]}}),g.success(`Data imported successfully`),await n(),await r();else throw Error(i.error||`Import failed`)}catch(e){g.error(e instanceof Error?e.message:`Import failed`),d(null)}finally{a(!1),s(!1),h()}}},handleCancelImport:()=>{s(!1),d(null),h()}}}var Je=`0.14.3`,Ye=`__current_running_model__`,Xe={enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},Ze={enabled:!1,autoPlay:!1,model:``,voice:``,speed:1,pluginId:``,streamSentences:!1},Qe={enabled:!1,model:``,size:`1024x1024`,quality:`standard`,style:`vivid`,pluginId:``},$e=({isOpen:e,onClose:t})=>{let{models:n,selectedModel:a,setSelectedModel:o,systemMessage:l,setSystemMessage:u,clearAllSessions:d,loading:f,sessions:h,loadModels:_,loadSessions:v}=he(),{theme:y,updateTheme:b,preferences:S,setPreferences:C,loadPreferences:T}=M(),{user:ee,systemInfo:re,setSystemInfo:E}=Ee(),{plugins:D,isLoading:ae,isUploading:oe,error:O,loadPlugins:k,uploadPlugin:se,deletePlugin:A,activatePlugin:le,deactivatePlugin:ge,exportPlugin:ve,clearError:xe,installPlugin:Se}=ce(),{t:P}=i(),Te=I.useId(),F=S.titleSettings?.taskModel||``,De=[{value:``,label:P(`settings.model.autoTitle.selectTaskModel`)},{value:Ye,label:`Use current running model`},...n.map(e=>({value:e.name,label:e.name})),...![``,Ye,...n.map(e=>e.name)].includes(F)&&F?[{value:F,label:`${F} (current)`}]:[]],[ke,Ae]=(0,I.useState)(`appearance`),[R,Me]=(0,I.useState)(l),[Ne,z]=(0,I.useState)(!1),[Le,B]=(0,I.useState)(!1),[V,H]=(0,I.useState)(null),[U,Ve]=(0,I.useState)(!1),[He,We]=(0,I.useState)(!1),[Ge,$e]=(0,I.useState)(``),et=(0,I.useRef)(null),[tt,nt]=(0,I.useState)(null),[rt,it]=(0,I.useState)({}),[at,ot]=(0,I.useState)({}),[st,ct]=(0,I.useState)(null),[lt,ut]=(0,I.useState)(S.generationOptions||{}),[W,dt]=(0,I.useState)(S.embeddingSettings||Xe),[ft,pt]=(0,I.useState)(!1),[G,mt]=(0,I.useState)(S.ttsSettings||Ze),[ht,K]=(0,I.useState)(!1),gt=(0,I.useRef)(null),[q,_t]=(0,I.useState)(S.imageGenSettings||Qe),{importing:vt,showImportOptions:yt,mergeStrategy:bt,setMergeStrategy:xt,importResult:St,setImportResult:Ct,importFileInputRef:wt,handleExportData:Tt,handleImportFileSelect:Et,handleConfirmImport:Dt,handleCancelImport:Ot}=qe({preferences:S,sessions:h,loadPreferences:T,loadSessions:v}),kt=we(),{data:At={}}=r({queryKey:[`plugin-credentials`],queryFn:async()=>{let e=await Oe.getCredentials();if(!e.success||!e.data)return{};let t={};for(let n of e.data)t[n.plugin_id]=n.has_api_key;return t},enabled:e}),{data:jt=[]}=r({queryKey:[`embedding-models`],queryFn:async()=>{let e=await fe.getModels();return e.success&&e.data?e.data:[]},enabled:e}),J=(0,I.useMemo)(()=>{let e=jt.find(e=>e.id===W.model||e.rawModel===W.model);return e&&e.id!==W.model?{...W,model:e.id}:W},[jt,W]),{data:Mt=null}=r({queryKey:[`embedding-status`],queryFn:async()=>{let e=await Ce.getEmbeddingStatus();return e.success&&e.data?e.data:null},enabled:e}),{data:Nt,isLoading:Pt}=r({queryKey:[`tts-data`],queryFn:async()=>{let[e,t]=await Promise.all([pe.getModels(),pe.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Y=(0,I.useMemo)(()=>Nt?.models??[],[Nt]),Ft=Nt?.plugins??[],X=(0,I.useMemo)(()=>de(Y,G.model,G.pluginId),[Y,G.model,G.pluginId]),Z=(0,I.useMemo)(()=>{if(!X)return G;let e=_e(Y,G.model,G.pluginId);return e&&G.pluginId===e.plugin?G:{...G,model:X.model,pluginId:X.plugin,voice:X.config?.default_voice||``}},[X,Y,G]),It=(0,I.useMemo)(()=>_e(Y,Z.model,Z.pluginId)?.config?.voices??[],[Z,Y]),{data:Lt,isLoading:Rt}=r({queryKey:[`image-gen-data`],queryFn:async()=>{let[e,t]=await Promise.all([ue.getModels(),ue.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Q=(0,I.useMemo)(()=>Lt?.models??[],[Lt]),zt=(0,I.useMemo)(()=>Lt?.plugins??[],[Lt]),$=(0,I.useMemo)(()=>Q.find(e=>e.model===q.model)||Q[0],[Q,q.model]),Bt=(0,I.useMemo)(()=>q.model||!$?q:{...q,model:$.model,pluginId:$.plugin,size:$.config?.default_size||`1024x1024`,quality:$.config?.default_quality||`standard`,style:$.config?.default_style||`vivid`},[q,$]),Vt=$?.config?.sizes??[],Ht=$?.config?.qualities??[],Ut=$?.config?.styles??[],Wt=(0,I.useRef)(!1),Gt=(0,I.useRef)(l);(0,I.useEffect)(()=>{if(!e){Wt.current=!1;return}Wt.current&&Gt.current===l||(Wt.current=!0,Gt.current=l,Me(l),ut(S.generationOptions||{}),dt(S.embeddingSettings||Xe),mt(S.ttsSettings||Ze),_t(S.imageGenSettings||Qe))},[e,S.embeddingSettings,S.generationOptions,S.imageGenSettings,S.ttsSettings,l]);let Kt=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!e){Kt.current=!1;return}Kt.current||(Kt.current=!0,k(),_())},[e,k,_]),(0,I.useEffect)(()=>{if(!e)return;let n=document.body.style.overflow,r=e=>{e.key===`Escape`&&t()};return document.body.style.overflow=`hidden`,document.addEventListener(`keydown`,r),()=>{document.body.style.overflow=n,document.removeEventListener(`keydown`,r)}},[e,t]);let qt=async e=>{let t=rt[e];if(!t?.trim()){g.error(`Please enter an API key`);return}ct(e);try{let n=await Oe.setApiKey(e,t.trim());n.success?(g.success(`API key saved successfully`),await kt.invalidateQueries({queryKey:[`plugin-credentials`]}),it(t=>({...t,[e]:``})),ot(t=>({...t,[e]:!1})),nt(null)):g.error(n.error||`Failed to save API key`)}catch{g.error(`Failed to save API key`)}finally{ct(null)}},Jt=async e=>{ct(e);try{let t=await Oe.deleteApiKey(e);t.success?(g.success(`API key removed`),await kt.invalidateQueries({queryKey:[`plugin-credentials`]}),it(t=>({...t,[e]:``}))):g.error(t.error||`Failed to remove API key`)}catch{g.error(`Failed to remove API key`)}finally{ct(null)}},Yt=(e,t)=>{let n=_e(Y,e,t);n&&mt(r=>({...r,model:e,pluginId:t,voice:n.config?.default_voice||r.voice}))},Xt=async e=>{let t=Q.find(t=>t.model===e);t&&_t(n=>({...n,model:e,pluginId:t.plugin,size:t.config?.default_size||n.size,quality:t.config?.default_quality||n.quality,style:t.config?.default_style||n.style}))},Zt=(e,t)=>{mt(n=>({...n,[e]:t}))},Qt=async()=>{try{let e=await N.updatePreferences({ttsSettings:Z});e.success&&e.data&&(C(e.data),g.success(`TTS settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to save TTS settings: `+t)}},$t=async()=>{if(ht){let e=gt.current;e&&(e.pause(),e.currentTime=0,gt.current=null),K(!1);return}K(!0);try{let e=await pe.generateBase64({model:Z.model||`tts-1`,pluginId:Z.pluginId,input:`Hello! This is a test of the text-to-speech system.`,voice:Z.voice||`alloy`,speed:Z.speed||1,response_format:X?.config?.default_format});if(e.success&&e.data?.audio){let t=`data:${e.data.mimeType};base64,${e.data.audio}`,n=new Audio(t);gt.current=n,n.onended=()=>{K(!1),gt.current=null},n.onerror=()=>{g.error(`Failed to play audio`),K(!1),gt.current=null},await n.play()}else throw Error(e.message||`Failed to generate speech`)}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`TTS test failed: `+t),K(!1)}},en=()=>{mt({enabled:!1,autoPlay:!1,model:Y[0]?.model||``,voice:Y[0]?.config?.default_voice||``,speed:1,pluginId:Y[0]?.plugin||``,streamSentences:!1})},tn=(e,t)=>{_t(n=>({...n,[e]:t}))},nn=async()=>{try{let e=await N.updatePreferences({imageGenSettings:Bt});e.success&&e.data&&(C(e.data),g.success(`Image generation settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to save image generation settings: `+t)}},rn=()=>{_t({enabled:!1,model:Q[0]?.model||``,size:Q[0]?.config?.default_size||`1024x1024`,quality:Q[0]?.config?.default_quality||`standard`,style:Q[0]?.config?.default_style||`vivid`,pluginId:Q[0]?.plugin||``})},an=async()=>{try{pt(!0),(await Ce.regenerateEmbeddings()).success&&(g.success(`Embeddings regenerated successfully`),await kt.invalidateQueries({queryKey:[`embedding-status`]}))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to regenerate embeddings: `+t)}finally{pt(!1)}},on=async e=>{try{let t=await N.updatePreferences(e);t.success&&t.data&&(C(t.data),g.success(`Settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)}},sn=async e=>{let t=e.target.files?.[0];t&&(await se(t),Ve(!1),et.current&&(et.current.value=``),await _())},cn=async()=>{try{await Se(JSON.parse(Ge)),We(!1),$e(``),await _()}catch{xe(),g.error(`Invalid JSON format`)}},ln=async e=>{D.find(t=>t.id===e)?.active?await ge(e):await le(e),await _()},un=async e=>{window.confirm(`Are you sure you want to delete this plugin?`)&&(await A(e),await _())},dn=async e=>{await ve(e)};if(!e)return null;let fn=e=>{let t=M.getState().theme;b(me({...t,mode:e}))},pn=e=>{let t=M.getState().theme;b(me({...t,accent:e}))},mn=e=>{let t=M.getState().theme;b(me({...t,accent:`custom`,customAccent:e}))},hn=e=>{let t=M.getState().theme;b(me({...t,adaptToAccent:e}))},gn=e=>{C({showUsername:e}),N.updatePreferences({showUsername:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)})},_n=e=>{let t=e.target.value;o(t),on({defaultModel:t}),g.success(`Default model updated`)},vn=e=>{Me(e.target.value)},yn=()=>{u(R),on({systemMessage:R}),g.success(`System message updated`)},bn=async()=>{window.confirm(`Are you sure you want to delete all chat history? This action cannot be undone.`)&&(await d(),g.success(`All chat sessions deleted`))},xn=async()=>{z(!0),H(null),ye.pullAllModelsStream(e=>{H(e)},()=>{z(!1),H(null),g.success(`All models updated successfully!`),_()},e=>{z(!1),H(null),g.error(`Failed to update models: `+e)})},Sn=async e=>{B(!0);try{let t=await be.updateModelPullSetting(e);if(t.success&&t.data)E(t.data),g.success(P(`settings.model.modelPullAccessSaved`));else throw Error(t.error||`Failed to update model access`)}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`${P(`settings.model.modelPullAccessSaveFailed`)}: ${t}`)}finally{B(!1)}},Cn=e=>{let t={...S.titleSettings,autoTitle:e,taskModel:S.titleSettings?.taskModel||``};C({titleSettings:t}),N.updatePreferences({titleSettings:t})},wn=e=>{let t={...S.titleSettings,autoTitle:S.titleSettings?.autoTitle||!1,taskModel:e};C({titleSettings:t}),N.updatePreferences({titleSettings:t})},Tn=(e,t)=>{it(n=>({...n,[e]:t}))},En=(e,t)=>{ot(n=>({...n,[e]:t}))},Dn=(e,t)=>{ut(n=>({...n,[e]:t}))},On=async()=>{try{let e=await N.setGenerationOptions(lt);e.success&&e.data&&(C(e.data),g.success(`Generation options updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update generation options: `+t)}},kn=async()=>{try{let e=await N.resetGenerationOptions();e.success&&e.data&&(C(e.data),ut(e.data.generationOptions||{}),g.success(`Generation options reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to reset generation options: `+t)}},An=(e,t)=>{dt(n=>({...n,[e]:t}))},jn=[...jt.map(e=>({value:e.id,label:`${e.name} (${e.pluginName||e.provider})`})),...!jt.find(e=>e.id===J.model||e.rawModel===J.model)&&J.model?[{value:J.model,label:`${J.model} (current)`}]:[]],Mn=async()=>{try{let e=await N.setEmbeddingSettings(J);e.success&&e.data&&(C(e.data),g.success(`Embedding settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update embedding settings: `+t)}},Nn=async()=>{try{let e=await N.resetEmbeddingSettings();e.success&&e.data&&(C(e.data),dt(e.data.embeddingSettings||{}),g.success(`Embedding settings reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to reset embedding settings: `+t)}},Pn=[{id:`appearance`,label:P(`settings.tabs.appearance`),icon:te},{id:`models`,label:P(`settings.tabs.model`),icon:p},{id:`generation`,label:P(`settings.tabs.generation`),icon:ne},{id:`tts`,label:P(`settings.tabs.tts`),icon:x},{id:`image-gen`,label:P(`settings.tabs.imageGen`),icon:m},{id:`documents`,label:P(`settings.tabs.documents`),icon:w},{id:`plugins`,label:P(`settings.tabs.plugins`),icon:s},{id:`data`,label:P(`settings.tabs.data`),icon:w},{id:`about`,label:P(`settings.tabs.about`),icon:c}];return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-0 sm:p-4 lg:p-6`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Te,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{"data-testid":`settings-modal-panel`,className:`flex h-full w-full flex-col overscroll-behavior-contain border border-gray-200/80 bg-surface/95 shadow-2xl backdrop-blur-xl animate-scale-in dark:border-white/10 dark:bg-dark-25/95 sm:max-h-[94vh] sm:max-w-6xl sm:rounded-3xl`,children:[(0,L.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-gray-200/70 px-4 py-4 dark:border-white/[0.08] sm:px-6 sm:py-5`,children:[(0,L.jsx)(`h2`,{id:Te,className:`text-xl font-normal tracking-[-0.025em] text-gray-950 dark:text-dark-950 sm:text-2xl rtl:tracking-normal`,children:P(`settings.title`)}),(0,L.jsx)(j,{variant:`ghost`,size:`sm`,onClick:t,autoFocus:!0,className:`h-9 w-9 touch-manipulation p-0 hover:bg-gray-100 active:bg-gray-200 dark:hover:bg-white/[0.06] dark:active:bg-white/10`,title:P(`common.close`,{defaultValue:`Close`}),children:(0,L.jsx)(ie,{className:`h-5 w-5 sm:h-4 sm:w-4`})})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overscroll-behavior-contain sm:flex-row`,children:[(0,L.jsx)(`div`,{className:`w-full shrink-0 overflow-x-auto border-b border-gray-200/70 p-2 scrollbar-thin dark:border-white/[0.08] sm:w-56 sm:overflow-x-hidden sm:overflow-y-auto sm:border-b-0 sm:border-e sm:p-3 lg:w-64`,style:{WebkitOverflowScrolling:`touch`},children:(0,L.jsx)(`nav`,{className:`flex gap-1 sm:flex-col`,role:`tablist`,children:Pn.map(e=>{let t=e.icon,n=ke===e.id,r=`flex shrink-0 items-center gap-2 rounded-xl border px-3 py-2.5 text-start text-sm transition-colors duration-200 touch-manipulation sm:w-full`;return r+=n?` border-gray-900 bg-gray-900 text-white dark:border-white dark:bg-white dark:text-gray-950`:` border-transparent text-gray-600 hover:bg-gray-100/70 hover:text-gray-950 dark:text-dark-600 dark:hover:bg-white/[0.05] dark:hover:text-dark-900`,(0,L.jsxs)(`button`,{onClick:()=>Ae(e.id),className:r,role:`tab`,"aria-selected":n,"aria-controls":`settings-tab-panel`,children:[(0,L.jsx)(t,{className:`h-4 w-4 flex-shrink-0`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`truncate whitespace-nowrap text-xs font-medium sm:text-sm`,children:e.label})]},e.id)})})}),(0,L.jsx)(`div`,{"data-testid":`settings-scroll-region`,className:`scroll-region min-h-0 flex-1 p-4 scrollbar-thin sm:p-6 lg:p-8`,id:`settings-tab-panel`,role:`tabpanel`,children:(()=>{switch(ke){case`appearance`:return(0,L.jsx)(Pe,{theme:y,preferences:S,onThemeChange:fn,onAccentChange:pn,onCustomAccentChange:mn,onAdaptToAccentChange:hn,onShowUsernameChange:gn});case`models`:return(0,L.jsx)(Be,{models:n,selectedModel:a,systemMessage:l,tempSystemMessage:R,loading:f,user:ee,systemInfo:re,preferences:S,currentTaskModel:F,autoTitleTaskModelOptions:De,updatingModelPullAccess:Le,updatingAllModels:Ne,updateProgress:V,onModelPullAccessToggle:Sn,onModelChange:_n,onSystemMessageChange:vn,onSystemMessageSave:yn,onAutoTitleChange:Cn,onAutoTitleTaskModelChange:wn,onUpdateAllModels:xn});case`tts`:return(0,L.jsx)(Ke,{loading:Pt,settings:G,effectiveSettings:Z,models:Y,plugins:Ft,voices:It,testing:ht,onSettingChange:Zt,onModelChange:Yt,onReset:en,onTest:$t,onSave:Qt});case`image-gen`:return(0,L.jsx)(ze,{loading:Rt,settings:q,effectiveSettings:Bt,models:Q,plugins:zt,sizes:Vt,qualities:Ht,styles:Ut,onSettingChange:tn,onModelChange:Xt,onReset:rn,onSave:nn});case`documents`:return(0,L.jsx)(Ie,{settings:W,effectiveSettings:J,modelOptions:jn,status:Mt,regenerating:ft,onSettingChange:An,onReset:Nn,onRegenerate:an,onSave:Mn});case`plugins`:return(0,L.jsx)(Ue,{plugins:D,loading:ae,uploading:oe,error:O,hasKeys:At,showUploadForm:U,showJsonForm:He,jsonInput:Ge,fileInputRef:et,expandedPluginId:tt,pluginApiKeys:rt,showApiKey:at,savingApiKey:st,onClearError:xe,onShowUploadFormChange:Ve,onShowJsonFormChange:We,onJsonInputChange:$e,onFileUpload:sn,onJsonSubmit:cn,onExpandedPluginChange:nt,onPluginApiKeyChange:Tn,onShowApiKeyChange:En,onActivatePlugin:ln,onDeletePlugin:un,onExportPlugin:dn,onSaveApiKey:qt,onDeleteApiKey:Jt});case`data`:return(0,L.jsx)(Fe,{sessionCount:h.length,loading:f,importing:vt,showImportOptions:yt,mergeStrategy:bt,importResult:St,importFileInputRef:wt,onExportData:Tt,onImportFileSelect:Et,onClearAllHistory:bn,onMergeStrategyChange:xt,onConfirmImport:Dt,onCancelImport:Ot,onDismissImportResult:()=>Ct(null)});case`about`:return(0,L.jsx)(je,{appVersion:Je});case`generation`:return(0,L.jsx)(Re,{generationOptions:lt,embeddingSettings:W,effectiveEmbeddingSettings:J,embeddingModelOptions:jn,embeddingStatus:Mt,onGenerationOptionChange:Dn,onEmbeddingSettingsChange:An,onResetGenerationOptions:kn,onSaveGenerationOptions:On,onResetEmbeddingSettings:Nn,onSaveEmbeddingSettings:Mn});default:return null}})()})]})]})})]})};export{$e as SettingsModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-GI9BPwrB.js";import{t as r}from"./useQuery-CXvo2RBT.js";import{t as i}from"./useTranslation-Cs6iTP4m.js";import{Bt as a,D as o,g as s,kt as c,o as l,u}from"./ui-vendor-CurEAeCe.js";import{t as d}from"./logger-DbNs3-DK.js";import{t as f}from"./Button-DBk-AREB.js";import{Z as p,a as m,b as h,c as g,d as _,i as v,l as y,o as b,rt as x,s as S,u as C,w}from"../assets/index-BKzwVaAM.js";var T=e(n(),1),E=t(),D=d(`components:user-manager`),O=()=>{let{t:e}=i(),t=x(),[n,d]=(0,T.useState)(!1),[m,v]=(0,T.useState)(null),[O,k]=(0,T.useState)({username:``,email:``,password:``,role:`user`}),{user:A}=w(),{data:j=[],isLoading:M}=r({queryKey:[`users`],queryFn:async()=>{let t=await p.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),N=()=>t.invalidateQueries({queryKey:[`users`]}),P=async t=>{t.preventDefault();try{let t=await p.createUser(O);t.success&&t.data&&(await N(),k({username:``,email:``,password:``,role:`user`}),d(!1),a.success(e(`userManager.form.createSuccess`)))}catch(t){D.error(`Error creating user:`,t);let n=e(`userManager.form.createFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.createFailed`)),a.error(n)}},F=async t=>{if(t.preventDefault(),m)try{let t={username:O.username,email:O.email,role:O.role};O.password&&O.password.trim()!==``&&(t.password=O.password);let n=await p.updateUser(m.id,t);n.success&&n.data&&(await N(),v(null),k({username:``,email:``,password:``,role:`user`}),a.success(e(`userManager.form.updateSuccess`)))}catch(t){D.error(`Error updating user:`,t);let n=e(`userManager.form.updateFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.updateFailed`)),a.error(n)}},I=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await p.deleteUser(t)).success&&(await N(),a.success(e(`userManager.deleteSuccess`)))}catch(t){D.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),a.error(n)}},L=e=>{v(e),k({username:e.username,email:e.email||``,password:``,role:e.role})};return M?(0,E.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,E.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-gray-600 border-t-primary-500 rounded-full animate-spin`})}):(0,E.jsxs)(`div`,{className:`space-y-6`,children:[(0,E.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,E.jsx)(`div`,{}),(0,E.jsxs)(f,{onClick:()=>d(!n),className:`flex items-center space-x-2 bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600`,children:[(0,E.jsx)(o,{size:16}),(0,E.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,E.jsxs)(b,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,E.jsxs)(y,{children:[(0,E.jsx)(C,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,E.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,E.jsx)(S,{children:(0,E.jsxs)(`form`,{onSubmit:P,className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(_,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,E.jsx)(h,{id:`username`,value:O.username,onChange:e=>k({...O,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(_,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,E.jsx)(h,{id:`email`,type:`email`,value:O.email,onChange:e=>k({...O,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(_,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,E.jsx)(h,{id:`password`,type:`password`,value:O.password,onChange:e=>k({...O,password:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(_,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,E.jsxs)(`select`,{id:`role`,value:O.role,onChange:e=>k({...O,role:e.target.value}),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200`,children:[(0,E.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,E.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,E.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,E.jsx)(f,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,E.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>{k({username:``,email:``,password:``,role:`user`}),d(!1)},children:e(`common.cancel`)})]})]})})]}),m&&(0,E.jsxs)(b,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,E.jsxs)(y,{children:[(0,E.jsxs)(C,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,m.username]}),(0,E.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,E.jsx)(S,{children:(0,E.jsxs)(`form`,{onSubmit:F,className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(_,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,E.jsx)(h,{id:`edit-username`,value:O.username,onChange:e=>k({...O,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(_,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,E.jsx)(h,{id:`edit-email`,type:`email`,value:O.email,onChange:e=>k({...O,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(_,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,E.jsx)(h,{id:`edit-password`,type:`password`,value:O.password,onChange:e=>k({...O,password:e.target.value}),placeholder:e(`userManager.form.passwordHint`),className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(_,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,E.jsxs)(`select`,{id:`edit-role`,value:O.role,onChange:e=>k({...O,role:e.target.value}),disabled:m?.id===A?.id&&A?.role===`admin`,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,E.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,E.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),m?.id===A?.id&&A?.role===`admin`&&(0,E.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,E.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,E.jsx)(f,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,E.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>{v(null),k({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),(0,E.jsxs)(b,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,E.jsxs)(y,{children:[(0,E.jsxs)(C,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,j.length,`)`]}),(0,E.jsx)(g,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,E.jsx)(S,{children:(0,E.jsx)(`div`,{className:`space-y-3`,children:j.map(t=>(0,E.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,E.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,E.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,E.jsx)(s,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,E.jsx)(l,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===A?.id&&(0,E.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,E.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[t.email||e(`userManager.noEmail`),` •`,` `,t.role===`admin`?e(`userManager.roles.admin`):e(`userManager.roles.user`)]}),(0,E.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,E.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,E.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>L(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,E.jsx)(c,{size:16})}),(0,E.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>I(t.id,t.username),disabled:t.id===A?.id,className:`text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,E.jsx)(u,{size:16})})]})]},t.id))})})]})]})},k=()=>{let{t:e}=i();return(0,E.jsxs)(m,{children:[(0,E.jsx)(v,{title:e(`userManager.title`),description:e(`userManager.pageDescription`)}),(0,E.jsx)(O,{})]})};export{k as UserManagementPage,k as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./markdown-core-GI9BPwrB.js";var n=e(t(),1);function r(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function i(e,t,n){r(e,t),t.set(e,n)}function a(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function o(e,t){return e.get(a(e,t))}function s(e,t,n){return e.set(a(e,t),n),n}var c=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,l=/^[\\/]{2}/;function u(e,t){return t+e.replace(/\\/g,`/`)}var d=`popstate`;function f(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function p(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return y(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:b(t)}return S(t,n,null,e)}function m(e={}){function t(e,t){let{pathname:n=`/`,search:r=``,hash:i=``}=x(e.location.hash.substring(1));return!n.startsWith(`/`)&&!n.startsWith(`.`)&&(n=`/`+n),y(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){let n=e.document.querySelector(`base`),r=``;if(n&&n.getAttribute(`href`)){let t=e.location.href,n=t.indexOf(`#`);r=n===-1?t:t.slice(0,n)}return r+`#`+(typeof t==`string`?t:b(t))}function r(e,t){g(e.pathname.charAt(0)===`/`,`relative pathnames are not supported in hash history.push(${JSON.stringify(t)})`)}return S(t,n,r,e)}function h(e,t){if(e===!1||e==null)throw Error(t)}function g(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function _(){return Math.random().toString(36).substring(2,10)}function v(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function y(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?x(t):t,state:n,key:t&&t.key||r||_(),mask:i}}function b({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function x(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function S(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function p(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:_.location,delta:t})}function m(e,t){s=`PUSH`;let r=f(e)?e:y(_.location,e,t);n&&n(r,e),l=u()+1;let d=v(r,l),p=_.createHref(r.mask||r);try{o.pushState(d,``,p)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(p)}a&&c&&c({action:s,location:_.location,delta:1})}function h(e,t){s=`REPLACE`;let r=f(e)?e:y(_.location,e,t);n&&n(r,e),l=u();let i=v(r,l),d=_.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:_.location,delta:0})}function g(e){return C(i,e)}let _={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(d,p),c=e,()=>{i.removeEventListener(d,p),c=null}},createHref(e){return t(i,e)},createURL:g,encodeLocation(e){let t=g(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:m,replace:h,go(e){return o.go(e)}};return _}function C(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),h(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:b(t);return i=i.replace(/ $/,`%20`),!n&&l.test(i)&&(i=r+i),new URL(i,r)}function w(e){"@babel/helpers - typeof";return w=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},w(e)}function T(e,t){if(w(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(w(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ee(e){var t=T(e,`string`);return w(t)==`symbol`?t:t+``}function E(e,t,n){return(t=ee(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e,t,n=`/`){return te(e,t,n,!1)}function te(e,t,n,r,i){let a=A((typeof t==`string`?x(t):t).pathname||`/`,n);if(a==null)return null;let o=i??O(e),s=null,c=be(a);for(let e=0;s==null&&e<o.length;++e)s=_e(o[e],c,r);return s}function ne(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,loaderData:t[n.id],handle:n.handle}}function O(e){let t=re(e);return ae(t),t}function re(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;h(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=M([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(h(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),re(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:he(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=ye(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of ie(e.path))a(e,t,!0,n)}),t}function ie(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ie(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function ae(e){e.sort((e,t)=>e.score===t.score?ge(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var oe=/^:[\w-]+$/,se=/^:[\w-]+/,ce=3.5,le=3,ue=2,de=1,fe=10,pe=-2,me=e=>e===`*`;function he(e,t){let n=e.split(`/`),r=n.length;return n.some(me)&&(r+=pe),t&&(r+=ue),n.filter(e=>!me(e)).reduce((e,t)=>e+(oe.test(t)?le:se.test(t)?ce:t===``?de:fe),r)}function ge(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function _e(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u={path:s.relativePath,caseSensitive:s.caseSensitive,end:c},d=s.matcher&&s.compiledParams?ve(u,l,s.matcher,s.compiledParams):k(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=k({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:M([a,d.pathname]),pathnameBase:Oe(M([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=M([a,d.pathnameBase]))}return o}function k(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ye(e.path,e.caseSensitive,e.end);return ve(e,t,n,r)}function ve(e,t,n,r){let i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ye(e,t=!1,n=!0){g(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(?=\/|$|\()/g,`(?:/$1)?`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function be(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return g(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function A(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function xe(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?x(e):e,a;return n?(n=Ee(n),a=n.startsWith(`/`)?Se(n.substring(1),`/`):Se(n,t)):a=t,{pathname:a,search:ke(r),hash:Ae(i)}}function Se(e,t){let n=De(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Ce(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function we(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Te(e){let t=we(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function j(e,t,n,r=!1){let i;typeof e==`string`?i=x(e):(i={...e},h(!i.pathname||!i.pathname.includes(`?`),Ce(`?`,`pathname`,`search`,i)),h(!i.pathname||!i.pathname.includes(`#`),Ce(`#`,`pathname`,`hash`,i)),h(!i.search||!i.search.includes(`#`),Ce(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=xe(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Ee=e=>e.replace(/[\\/]{2,}/g,`/`),M=e=>Ee(e.join(`/`)),De=e=>e.replace(/\/+$/,``),Oe=e=>De(e).replace(/^\/*/,`/`),ke=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Ae=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,je=class{constructor(e,t,n,r=!1){E(this,`status`,void 0),E(this,`statusText`,void 0),E(this,`data`,void 0),E(this,`error`,void 0),E(this,`internal`,void 0),this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Me(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Ne(e){return M(e.map(e=>e.route.path).filter(Boolean))||`/`}var Pe=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Fe(e,t){let n=e;if(typeof n!=`string`||!c.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Pe)try{let e=new URL(window.location.href),r=l.test(n)?new URL(u(n,e.protocol)):new URL(n),a=A(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{g(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}var Ie=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Ie);var Le=[`GET`,...Ie];new Set(Le);var Re=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function ze(e){try{return Re.includes(new URL(e).protocol)}catch{return!1}}var N=n.createContext(null);N.displayName=`DataRouter`;var P=n.createContext(null);P.displayName=`DataRouterState`;var Be=n.createContext(!1);function Ve(){return n.useContext(Be)}var He=n.createContext({isTransitioning:!1});He.displayName=`ViewTransition`;var Ue=n.createContext(new Map);Ue.displayName=`Fetchers`;var We=n.createContext(null);We.displayName=`Await`;var F=n.createContext(null);F.displayName=`Navigation`;var I=n.createContext(null);I.displayName=`Location`;var L=n.createContext({outlet:null,matches:[],isDataRoute:!1});L.displayName=`Route`;var R=n.createContext(null);R.displayName=`RouteError`;var Ge=`REACT_ROUTER_ERROR`,Ke=`REDIRECT`,qe=`ROUTE_ERROR_RESPONSE`;function Je(e){if(e.startsWith(`${Ge}:${Ke}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function Ye(e){if(e.startsWith(`${Ge}:${qe}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new je(t.status,t.statusText,t.data)}catch{}}var Xe;function Ze(e,{relative:t}={}){h(z(),`useHref() may be used only in the context of a <Router> component.`);let{basename:r,navigator:i}=n.useContext(F),{hash:a,pathname:o,search:s}=V(e,{relative:t}),c=o;return r!==`/`&&(c=o===`/`?r:M([r,o])),i.createHref({pathname:c,search:s,hash:a})}function z(){return n.useContext(I)!=null}function B(){return h(z(),`useLocation() may be used only in the context of a <Router> component.`),n.useContext(I).location}var Qe=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function $e(){let{isDataRoute:e}=n.useContext(L);return e?_t():et()}function et(){h(z(),`useNavigate() may be used only in the context of a <Router> component.`);let e=n.useContext(N),{basename:t,navigator:r}=n.useContext(F),{matches:i}=n.useContext(L),{pathname:a}=B(),o=JSON.stringify(Te(i)),s=n.useRef(!1);return n.useLayoutEffect(()=>{s.current=!0}),n.useCallback((n,i={})=>{if(g(s.current,Qe),!s.current)return;if(typeof n==`number`){r.go(n);return}let c=j(n,JSON.parse(o),a,i.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:M([t,c.pathname])),(i.replace?r.replace:r.push)(c,i.state,i)},[t,r,o,a,e])}n.createContext(null);function tt(){let{matches:e}=n.useContext(L);return e[e.length-1]?.params??{}}function V(e,{relative:t}={}){let{matches:r}=n.useContext(L),{pathname:i}=B(),a=JSON.stringify(Te(r));return n.useMemo(()=>j(e,JSON.parse(a),i,t===`path`),[e,a,i,t])}function nt(e,t){return rt(e,t)}function rt(e,t,r){h(z(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:i}=n.useContext(F),{matches:a}=n.useContext(L),o=a[a.length-1],s=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:`/`;o&&o.route;let l=B(),u;if(t){let e=typeof t==`string`?x(t):t;h(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),u=e}else u=l;let d=u.pathname||`/`,f=d;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);f=`/`+d.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let p=r&&r.state.matches.length?r.state.matches.map(e=>Object.assign(e,{route:r.manifest[e.route.id]||e.route})):D(e,{pathname:f}),m=ut(p&&p.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:M([c,i.encodeLocation?i.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:M([c,i.encodeLocation?i.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),a,r);return t&&m?n.createElement(I.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...u},navigationType:`POP`}},m):m}function it(){let e=gt(),t=Me(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null;return n.createElement(n.Fragment,null,n.createElement(`h2`,null,`Unexpected Application Error!`),n.createElement(`h3`,{style:{fontStyle:`italic`}},t),r?n.createElement(`pre`,{style:{padding:`0.5rem`,backgroundColor:`rgba(200,200,200, 0.5)`}},r):null,null)}var at=n.createElement(it,null),ot=(Xe=class extends n.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=Ye(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:n.createElement(L.Provider,{value:this.props.routeContext},n.createElement(R.Provider,{value:e,children:this.props.component}));return this.context?n.createElement(ct,{error:e},t):t}},E(Xe,`contextType`,Be),Xe),st=new WeakMap;function ct({children:e,error:t}){let{basename:r}=n.useContext(F);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Je(t.digest);if(e){let i=st.get(t);if(i)throw i;let a=Fe(e.location,r),o=a.absoluteURL||a.to;if(ze(o))throw Error(`Invalid redirect location`);if(Pe&&!st.get(t))if(a.isExternal||e.reloadDocument)window.location.href=o;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:e.replace}));throw st.set(t,n),n}return n.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${o}`})}}return e}function lt({routeContext:e,match:t,children:r}){let i=n.useContext(N);return i&&i.static&&i.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=t.route.id),n.createElement(L.Provider,{value:e},r)}function ut(e,t=[],r){let i=r?.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(t.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let a=e,o=i?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);h(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(r&&i){s=i.renderFallback;for(let e=0;e<a.length;e++){let t=a[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(c=e),t.route.id){let{loaderData:e,errors:n}=i,o=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!n||n[t.route.id]===void 0);if(t.route.lazy||o){r.isStatic&&(s=!0),a=c>=0?a.slice(0,c+1):[a[0]];break}}}}let l=r?.onError,u=i&&l?(e,t)=>{l(e,{location:i.location,params:i.matches?.[0]?.params??{},pattern:Ne(i.matches),errorInfo:t})}:void 0;return a.reduceRight((e,r,l)=>{let d,f=!1,p=null,m=null;i&&(d=o&&r.route.id?o[r.route.id]:void 0,p=r.route.errorElement||at,s&&(c<0&&l===0?(yt(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):c===l&&(f=!0,m=r.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,l+1)),g=()=>{let t;return t=d?p:f?m:r.route.Component?n.createElement(r.route.Component,null):r.route.element?r.route.element:e,n.createElement(lt,{match:r,routeContext:{outlet:e,matches:h,isDataRoute:i!=null},children:t})};return i&&(r.route.ErrorBoundary||r.route.errorElement||l===0)?n.createElement(ot,{location:i.location,revalidation:i.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):g()},null)}function H(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function dt(e){let t=n.useContext(N);return h(t,H(e)),t}function U(e){let t=n.useContext(P);return h(t,H(e)),t}function ft(e){let t=n.useContext(L);return h(t,H(e)),t}function W(e){let t=ft(e),n=t.matches[t.matches.length-1];return h(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function pt(){return W(`useRouteId`)}function mt(){let e=U(`useNavigation`);return n.useMemo(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function ht(){let{matches:e,loaderData:t}=U(`useMatches`);return n.useMemo(()=>e.map(e=>ne(e,t)),[e,t])}function gt(){let e=n.useContext(R),t=U(`useRouteError`),r=W(`useRouteError`);return e===void 0?t.errors?.[r]:e}function _t(){let{router:e}=dt(`useNavigate`),t=W(`useNavigate`),r=n.useRef(!1);return n.useLayoutEffect(()=>{r.current=!0}),n.useCallback(async(n,i={})=>{g(r.current,Qe),r.current&&(typeof n==`number`?await e.navigate(n):await e.navigate(n,{fromRouteId:t,...i}))},[e,t])}var vt={};function yt(e,t,n){!t&&!vt[e]&&(vt[e]=!0,g(!1,n))}n.memo(bt);function bt({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return rt(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function xt({to:e,replace:t,state:r,relative:i}){h(z(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:a}=n.useContext(F);g(!a,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:o}=n.useContext(L),{pathname:s}=B(),c=$e(),l=j(e,Te(o),s,i===`path`),u=JSON.stringify(l);return n.useEffect(()=>{c(JSON.parse(u),{replace:t,state:r,relative:i})},[c,u,i,t,r]),null}function St(e){h(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function G({basename:e=`/`,children:t=null,location:r,navigationType:i=`POP`,navigator:a,static:o=!1,useTransitions:s}){h(!z(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let c=e.replace(/^\/*/,`/`),l=n.useMemo(()=>({basename:c,navigator:a,static:o,useTransitions:s,future:{}}),[c,a,o,s]);typeof r==`string`&&(r=x(r));let{pathname:u=`/`,search:d=``,hash:f=``,state:p=null,key:m=`default`,mask:_}=r,v=n.useMemo(()=>{let e=A(u,c);return e==null?null:{location:{pathname:e,search:d,hash:f,state:p,key:m,mask:_},navigationType:i}},[c,u,d,f,p,m,i,_]);return g(v!=null,`<Router basename="${c}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:n.createElement(F.Provider,{value:l},n.createElement(I.Provider,{children:t,value:v}))}function Ct({children:e,location:t}){return nt(K(e),t)}n.Component;function K(e,t=[]){let r=[];return n.Children.forEach(e,(e,i)=>{if(!n.isValidElement(e))return;let a=[...t,i];if(e.type===n.Fragment){r.push.apply(r,K(e.props.children,a));return}h(e.type===St,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`);let o=e.props;h(!o.index||!o.children,`An index route cannot have child routes.`);let s={id:o.id||a.join(`-`),caseSensitive:o.caseSensitive,element:o.element,Component:o.Component,index:o.index,path:o.path,middleware:o.middleware,loader:o.loader,action:o.action,hydrateFallbackElement:o.hydrateFallbackElement,HydrateFallback:o.HydrateFallback,errorElement:o.errorElement,ErrorBoundary:o.ErrorBoundary,shouldRevalidate:o.shouldRevalidate,handle:o.handle,lazy:o.lazy};o.children&&(s.children=K(o.children,a)),r.push(s)}),r}var q=`application/x-www-form-urlencoded`;function J(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function wt(e){return J(e)&&e.tagName.toLowerCase()===`button`}function Tt(e){return J(e)&&e.tagName.toLowerCase()===`form`}function Et(e){return J(e)&&e.tagName.toLowerCase()===`input`}function Dt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ot(e,t){return e.button===0&&(!t||t===`_self`)&&!Dt(e)}var Y=null;function kt(){if(Y===null)try{new FormData(document.createElement(`form`),0),Y=!1}catch{Y=!0}return Y}var At=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function jt(e){return e!=null&&!At.has(e)?(g(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${q}"`),null):e}function Mt(e,t){let n,r,i,a,o;if(Tt(e)){let o=e.getAttribute(`action`);r=o?A(o,t):null,n=e.getAttribute(`method`)||`get`,i=jt(e.getAttribute(`enctype`))||q,a=new FormData(e)}else if(wt(e)||Et(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?A(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||`get`,i=jt(e.getAttribute(`formenctype`))||jt(o.getAttribute(`enctype`))||q,a=new FormData(o,e),!kt()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(J(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=`get`,r=null,i=q,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}var Nt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},Pt=/[&><\u2028\u2029]/g;function Ft(e){return e.replace(Pt,e=>Nt[e])}function It(e,t){if(e===!1||e==null)throw Error(t)}var Lt=`modulepreload`,Rt=function(e){return`/`+e},zt={},Bt=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=Rt(t,n),t=s(t),t in zt)return;zt[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Lt,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};async function Vt(e,t){if(e.id in t)return t[e.id];try{let n=await Bt(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Ht(e){return e!=null&&typeof e.page==`string`}function Ut(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function Wt(e,t,n){return Yt((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await Vt(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(Ut).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function Gt(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function Kt(e,t,{includeHydrateFallback:n}={}){return qt(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function qt(e){return[...new Set(e)]}function Jt(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Yt(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!Ht(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Jt(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Xt(e,t){let n=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n.pathname.endsWith(`/`)?n.pathname=`${n.pathname}_.${t}`:n.pathname=`${n.pathname}.${t}`,n}function Zt(){let e=n.useContext(N);return It(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Qt(){let e=n.useContext(P);return It(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var X=n.createContext(void 0);X.displayName=`FrameworkContext`;function $t(){let e=n.useContext(X);return It(e,`You must render this element inside a <HydratedRouter> element`),e}function en(e,t){let r=n.useContext(X),[i,a]=n.useState(!1),[o,s]=n.useState(!1),{onFocus:c,onBlur:l,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=t,p=n.useRef(null);n.useEffect(()=>{if(e===`render`&&s(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{s(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),n.useEffect(()=>{if(i){let e=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(e)}}},[i]);let m=()=>{a(!0)},h=()=>{a(!1),s(!1)};return r?e===`intent`?[o,p,{onFocus:Z(c,m),onBlur:Z(l,h),onMouseEnter:Z(u,m),onMouseLeave:Z(d,h),onTouchStart:Z(f,m)}]:[o,p,{}]:[!1,p,{}]}function Z(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function tn({page:e,...t}){let r=Ve(),{nonce:i}=$t(),{router:a}=Zt(),o=n.useMemo(()=>D(a.routes,e,a.basename),[a.routes,e,a.basename]);return o?(t.nonce==null&&i&&(t={...t,nonce:i}),r?n.createElement(rn,{page:e,matches:o,...t}):n.createElement(an,{page:e,matches:o,...t})):null}function nn(e){let{manifest:t,routeModules:r}=$t(),[i,a]=n.useState([]);return n.useEffect(()=>{let n=!1;return Wt(e,t,r).then(e=>{n||a(e)}),()=>{n=!0}},[e,t,r]),i}function rn({page:e,matches:t,...r}){let i=B(),a=n.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let n=Xt(e,`rsc`),r=!1,a=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?r=!0:a.push(e.route.id);return r&&a.length>0&&n.searchParams.set(`_routes`,a.join(`,`)),[n.pathname+n.search]},[e,i,t]);return n.createElement(n.Fragment,null,a.map(e=>n.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...r})))}function an({page:e,matches:t,...r}){let i=B(),{manifest:a,routeModules:o}=$t(),{loaderData:s,matches:c}=Qt(),l=n.useMemo(()=>Gt(e,t,c,a,i,`data`),[e,t,c,a,i]),u=n.useMemo(()=>Gt(e,t,c,a,i,`assets`),[e,t,c,a,i]),d=n.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let n=new Set,r=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!l.some(t=>t.route.id===e.route.id)&&e.route.id in s&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?r=!0:n.add(e.route.id))}),n.size===0)return[];let c=Xt(e,`data`);return r&&n.size>0&&c.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[c.pathname+c.search]},[s,i,a,l,t,e,o]),f=n.useMemo(()=>Kt(u,a),[u,a]),p=nn(u);return n.createElement(n.Fragment,null,d.map(e=>n.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...r})),f.map(e=>n.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...r})),p.map(({key:e,link:t})=>n.createElement(`link`,{key:e,nonce:r.nonce,...t,crossOrigin:t.crossOrigin??r.crossOrigin})))}function on(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}var sn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{sn&&(window.__reactRouterVersion=`8.3.0`)}catch{}function cn({basename:e,children:t,useTransitions:r,window:i}){let a=n.useRef(null);a.current??(a.current=p({window:i,v5Compat:!0}));let o=a.current,[s,c]=n.useState({action:o.action,location:o.location}),l=n.useCallback(e=>{r===!1?c(e):n.startTransition(()=>c(e))},[r]);return n.useLayoutEffect(()=>o.listen(l),[o,l]),n.createElement(G,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,useTransitions:r})}function ln({basename:e,children:t,useTransitions:r,window:i}){let a=n.useRef(null);a.current??(a.current=m({window:i,v5Compat:!0}));let o=a.current,[s,c]=n.useState({action:o.action,location:o.location}),l=n.useCallback(e=>{r===!1?c(e):n.startTransition(()=>c(e))},[r]);return n.useLayoutEffect(()=>o.listen(l),[o,l]),n.createElement(G,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:o,useTransitions:r})}function un({basename:e,children:t,history:r,useTransitions:i}){let[a,o]=n.useState({action:r.action,location:r.location}),s=n.useCallback(e=>{i===!1?o(e):n.startTransition(()=>o(e))},[i]);return n.useLayoutEffect(()=>r.listen(s),[r,s]),n.createElement(G,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:r,useTransitions:i})}un.displayName=`unstable_HistoryRouter`;var Q=n.forwardRef(function({onClick:e,discover:t=`render`,prefetch:r=`none`,relative:i,reloadDocument:a,replace:o,mask:s,state:l,target:u,to:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g){let{basename:_,navigator:v,useTransitions:y}=n.useContext(F),b=typeof d==`string`&&c.test(d),x=Fe(d,_);d=x.to;let S=Ze(d,{relative:i}),C=B(),w=null;if(s){let e=j(s,[],C.mask?C.mask.pathname:`/`,!0);_!==`/`&&(e.pathname=e.pathname===`/`?_:M([_,e.pathname])),w=v.createHref(e)}let[T,ee,E]=en(r,h),D=_n(d,{replace:o,mask:s,state:l,target:u,preventScrollReset:f,relative:i,viewTransition:p,defaultShouldRevalidate:m,useTransitions:y});function te(t){e&&e(t),t.defaultPrevented||D(t)}let ne=!(x.isExternal||a),O=n.createElement(`a`,{...h,...E,href:(ne?w:void 0)||x.absoluteURL||S,onClick:ne?te:e,ref:on(g,ee),target:u,"data-discover":!b&&t===`render`?`true`:void 0});return T&&!b?n.createElement(n.Fragment,null,O,n.createElement(tn,{page:S})):O});Q.displayName=`Link`;var dn=n.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:r=``,end:i=!1,style:a,to:o,viewTransition:s,children:c,...l},u){let d=V(o,{relative:l.relative}),f=B(),p=n.useContext(P),{navigator:m,basename:h}=n.useContext(F),g=p!=null&&En(d)&&s===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=A(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!i&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!i&&y.startsWith(_)&&y.charAt(b)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,T;T=typeof r==`function`?r(C):[r,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let ee=typeof a==`function`?a(C):a;return n.createElement(Q,{...l,"aria-current":w,className:T,ref:u,style:ee,to:o,viewTransition:s},typeof c==`function`?c(C):c)});dn.displayName=`NavLink`;var fn=n.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:r,reloadDocument:i,replace:a,state:o,method:s=`get`,action:l,onSubmit:u,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m,...h},g)=>{let{useTransitions:_}=n.useContext(F),v=bn(),y=xn(l,{relative:d}),b=s.toLowerCase()===`get`?`get`:`post`,x=typeof l==`string`&&c.test(l);return n.createElement(`form`,{ref:g,method:b,action:y,onSubmit:i?u:e=>{if(u&&u(e),e.defaultPrevented)return;e.preventDefault();let i=e.nativeEvent.submitter,c=i?.getAttribute(`formmethod`)||s,l=()=>v(i||e.currentTarget,{fetcherKey:t,method:c,navigate:r,replace:a,state:o,relative:d,preventScrollReset:f,viewTransition:p,defaultShouldRevalidate:m});_&&r!==!1?n.startTransition(()=>l()):l()},...h,"data-discover":!x&&e===`render`?`true`:void 0})});fn.displayName=`Form`;function pn({getKey:e,storageKey:t,...r}){let i=n.useContext(X),{basename:a}=n.useContext(F),o=B(),s=ht();wn({getKey:e,storageKey:t});let c=n.useMemo(()=>{if(!i||!e)return null;let t=Cn(o,s,a,e);return t===o.key?null:t},[]);if(!i||i.isSpaMode)return null;let l=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return r.nonce==null&&i?.nonce&&(r.nonce=i.nonce),n.createElement(`script`,{...r,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${Ft(JSON.stringify(t||Sn))}, ${Ft(JSON.stringify(c))})`}})}pn.displayName=`ScrollRestoration`;function mn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function hn(e){let t=n.useContext(N);return h(t,mn(e)),t}function gn(e){let t=n.useContext(P);return h(t,mn(e)),t}function _n(e,{target:t,replace:r,mask:i,state:a,preventScrollReset:o,relative:s,viewTransition:c,defaultShouldRevalidate:l,useTransitions:u}={}){let d=$e(),f=B(),p=V(e,{relative:s});return n.useCallback(m=>{if(Ot(m,t)){m.preventDefault();let t=r===void 0?b(f)===b(p):r,h=()=>d(e,{replace:t,mask:i,state:a,preventScrollReset:o,relative:s,viewTransition:c,defaultShouldRevalidate:l});u?n.startTransition(()=>h()):h()}},[f,d,p,r,i,a,t,e,o,s,c,l,u])}var vn=0,yn=()=>`__${String(++vn)}__`;function bn(){let{router:e}=hn(`useSubmit`),{basename:t}=n.useContext(F),r=pt(),i=e.fetch,a=e.navigate;return n.useCallback(async(e,n={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=Mt(e,t);n.navigate===!1?await i(n.fetcherKey||yn(),r,n.action||o,{defaultShouldRevalidate:n.defaultShouldRevalidate,preventScrollReset:n.preventScrollReset,formData:l,body:u,formMethod:n.method||s,formEncType:n.encType||c,flushSync:n.flushSync}):await a(n.action||o,{defaultShouldRevalidate:n.defaultShouldRevalidate,preventScrollReset:n.preventScrollReset,formData:l,body:u,formMethod:n.method||s,formEncType:n.encType||c,replace:n.replace,state:n.state,fromRouteId:r,flushSync:n.flushSync,viewTransition:n.viewTransition})},[i,a,t,r])}function xn(e,{relative:t}={}){let{basename:r}=n.useContext(F),i=n.useContext(L);h(i,`useFormAction must be used inside a RouteContext`);let[a]=i.matches.slice(-1),o={...V(e||`.`,{relative:t})},s=B();if(e==null){o.search=s.search;let e=new URLSearchParams(o.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();o.search=n?`?${n}`:``}}return(!e||e===`.`)&&a.route.index&&(o.search=o.search?o.search.replace(/^\?/,`?index&`):`?index`),r!==`/`&&(o.pathname=o.pathname===`/`?r:M([r,o.pathname])),b(o)}var Sn=`react-router-scroll-positions`,$={};function Cn(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:A(e.pathname,n)||e.pathname},t)),i??(i=e.key),i}function wn({getKey:e,storageKey:t}={}){let{router:r}=hn(`useScrollRestoration`),{restoreScrollPosition:i,preventScrollReset:a}=gn(`useScrollRestoration`),{basename:o}=n.useContext(F),s=B(),c=ht(),l=mt();n.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Tn(n.useCallback(()=>{if(l.state===`idle`){let t=Cn(s,c,o,e);$[t]=window.scrollY}try{sessionStorage.setItem(t||Sn,JSON.stringify($))}catch(e){g(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[l.state,e,o,s,c,t])),typeof document<`u`&&(n.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Sn);e&&($=JSON.parse(e))}catch{}},[t]),n.useLayoutEffect(()=>{let t=r?.enableScrollRestoration($,()=>window.scrollY,e?(t,n)=>Cn(t,n,o,e):void 0);return()=>t&&t()},[r,o,e]),n.useLayoutEffect(()=>{if(i!==!1){if(typeof i==`number`){window.scrollTo(0,i);return}try{if(s.hash){let e=document.getElementById(decodeURIComponent(s.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{g(!1,`"${s.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}a!==!0&&window.scrollTo(0,0)}},[s,i,a]))}function Tn(e,t){let{capture:r}=t||{};n.useEffect(()=>{let t=r==null?void 0:{capture:r};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,r])}function En(e,{relative:t}={}){let r=n.useContext(He);h(r!=null,"`useViewTransitionState` must be used within `react-router/dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=hn(`useViewTransitionState`),a=V(e,{relative:t});if(!r.isTransitioning)return!1;let o=A(r.currentLocation.pathname,i)||r.currentLocation.pathname,s=A(r.nextLocation.pathname,i)||r.nextLocation.pathname;return k(a.pathname,s)!=null||k(a.pathname,o)!=null}export{xt as a,B as c,E as d,s as f,r as g,i as h,Bt as i,$e as l,a as m,ln as n,St as o,o as p,Q as r,Ct as s,cn as t,tt as u};
|