libre-webui 0.14.2 → 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 +92 -24
- 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 +12 -11
- package/frontend/dist/js/{ArtifactContainer-RPQq1DRo.js → ArtifactContainer-CXfmVx8T.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-Dd0Rbl3N.js → ArtifactDemoPage-B1_AuMd2.js} +1 -1
- package/frontend/dist/js/ArtifactSlideOutPanel-C0eTguNL.js +1 -0
- package/frontend/dist/js/{Button-BZBnLKRn.js → Button-DBk-AREB.js} +1 -1
- package/frontend/dist/js/ChatPage-1bK0gDBy.js +16 -0
- package/frontend/dist/js/FirstTimeSetup-DOoZUaRs.js +1 -0
- package/frontend/dist/js/{GalleryPage-BTA5LAmZ.js → GalleryPage-6WwyH3kt.js} +1 -1
- package/frontend/dist/js/LibreClawPage-ChHVfPLb.js +1 -0
- package/frontend/dist/js/{ModelManagerModals-D1_k_AKo.js → ModelManagerModals-DneqFQJC.js} +1 -1
- package/frontend/dist/js/ModelsPage-Dw6wdiMt.js +2 -0
- package/frontend/dist/js/{OptimizedSyntaxHighlighter-BR97Z7hi.js → OptimizedSyntaxHighlighter-Ci9sRc78.js} +1 -1
- 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/logger-DbNs3-DK.js +1 -0
- package/frontend/dist/js/markdown-C08x2H-K.js +70 -0
- package/frontend/dist/js/{markdown-core-fkbHPd-g.js → markdown-core-GI9BPwrB.js} +1 -1
- package/frontend/dist/js/{markdown-math-Ci4QOsf-.js → markdown-math-E4O1gcxj.js} +1 -1
- 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/react-vendor-DyG_ODzn.js +9 -0
- 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/{syntax-highlight-B8OiKBhG.js → syntax-highlight-pM1xnNpY.js} +1 -1
- 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/{useTranslation-CP6Cg-EI.js → useTranslation-Cs6iTP4m.js} +1 -1
- package/frontend/dist/js/{utils-D0l9J3P-.js → utils-pTFqSV8c.js} +1 -1
- package/frontend/dist/js/{utils-vendor-BX3ZwoIK.js → utils-vendor-Cbaj0BC5.js} +1 -1
- 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 +14 -7
- package/plugins/kimi-code.json +6 -37
- package/frontend/dist/assets/index-BPvF-fpc.css +0 -1
- package/frontend/dist/assets/index-CDvTfv-t.js +0 -5
- package/frontend/dist/js/ArtifactSlideOutPanel-oA5Iy8Nc.js +0 -1
- package/frontend/dist/js/ChatPage-DdLe5r1n.js +0 -16
- package/frontend/dist/js/FirstTimeSetup-DL_WZABT.js +0 -1
- package/frontend/dist/js/LibreClawPage-CuQ8tJUW.js +0 -1
- package/frontend/dist/js/ModelsPage-BVfl9FU_.js +0 -2
- package/frontend/dist/js/PersonasPage-wP36Pd7I.js +0 -13
- package/frontend/dist/js/RichMessageContent-CdgQHk6Q.js +0 -3
- package/frontend/dist/js/SettingsModal-CLdxDdQV.js +0 -1
- package/frontend/dist/js/UserManagementPage-BwnBtNj1.js +0 -1
- package/frontend/dist/js/api-BRz6cQiD.js +0 -15
- package/frontend/dist/js/logger-BmpKNkls.js +0 -1
- package/frontend/dist/js/react-vendor-Co1u1rWb.js +0 -8
- package/frontend/dist/js/ui-vendor-njo77ljx.js +0 -177
- package/frontend/dist/js/useBaseQuery-C8AWX-Cq.js +0 -1
- package/frontend/dist/js/useQuery-CbYbdhch.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
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-C0lZwNoc.js";import{t as i}from"./useTranslation-Cs6iTP4m.js";import{C as a,Dt as o,E as s,F as c,H as l,M as u,O as d,Ot as f,Q as p,U as m,Vt as h,W as g,X as _,Z as v,Zt as y,_t as b,a as x,bt as S,c as C,ct as ee,dt as w,h as te,j as ne,lt as T,n as re,p as ie,st as E,u as ae,ut as oe,w as D,xt as O,zt as se}from"./ui-vendor-DUqvZsfs.js";import{t as ce}from"./logger-DbNs3-DK.js";import{_ as le,a as ue,c as de,f as fe,g as pe,i as me,m as he,n as ge,r as _e,s as k,y as ve}from"./api-DD5qhhLf.js";import{t as A}from"./utils-pTFqSV8c.js";import{t as j}from"./Button-DBk-AREB.js";import{B as ye,F as M,G as be,H as xe,I as Se,J as Ce,K as we,O as Te,P as Ee,S as De,U as N,r as Oe,x as P,z as ke}from"../assets/index-uCHBH_PM.js";var F=e(n(),1),I=t(),Ae=[{href:`https://github.com/libre-webui/libre-webui`,icon:p,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:v,labelKey:`settings.about.links.gitlab`,descriptionKey:`settings.about.links.gitlabDescription`},{href:`https://librewebui.org`,icon:T,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:f,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://ollama.ai`,icon:o,labelKey:`settings.about.links.ollama`,descriptionKey:`settings.about.links.ollamaDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:c,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],je=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function Me({appVersion:e}){let{t}=i();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-4`,children:(0,I.jsx)(Oe,{className:`text-gray-900 dark:text-gray-100`})}),(0,I.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,I.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,I.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,I.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:je.map(e=>(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,I.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,I.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,I.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Ae.map(e=>{let n=e.icon;return(0,I.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,I.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,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,I.jsx)(T,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.href)})})]}),(0,I.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,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-gray-500 dark:text-gray-400`,children:[e.includes(`-dev`)?(0,I.jsx)(`span`,{children:t(`settings.about.version`,{version:e})}):(0,I.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,I.jsxs)(`span`,{children:[t(`settings.about.openSourceBy`,{company:``}),(0,I.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 L=ce(`components:background-upload`),Ne=({className:e=``})=>{let{t}=i(),{preferences:n,setPreferences:r,backgroundImage:a,uploadBackgroundImage:o,removeBackgroundImage:s}=M(),c=(0,F.useRef)(null),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(!1),p=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},m=async e=>{if(!e.type.startsWith(`image/`)){y.error(`Please select a valid image file`);return}if(e.size>5*1024*1024){y.error(`Image file size must be less than 5MB`);return}u(!0);try{await o(e),y.success(`Background image uploaded successfully`)}catch(e){L.error(`Failed to upload background:`,e),y.error(`Failed to upload background image`)}finally{u(!1)}},h=e=>{let t=e.target.files?.[0];t&&m(t)},_=e=>{e.preventDefault(),f(!0)},v=e=>{e.preventDefault(),f(!1)},b=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files?.[0];t&&m(t)},x=()=>{s(),y.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 k.updatePreferences({backgroundSettings:n})}catch(e){L.error(`Failed to update preferences:`,e)}},ee=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,blurAmount:e};if(r({backgroundSettings:n}),t)try{await k.updatePreferences({backgroundSettings:n})}catch(e){L.error(`Failed to update preferences:`,e)}},w=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,opacity:e};if(r({backgroundSettings:n}),t)try{await k.updatePreferences({backgroundSettings:n})}catch(e){L.error(`Failed to update preferences:`,e)}};return(0,I.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,I.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,I.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:p.enabled,onChange:e=>S(e.target.checked)}),(0,I.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,I.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,I.jsx)(`div`,{className:`relative`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,I.jsx)(`div`,{className:`flex-shrink-0`,children:(0,I.jsx)(`img`,{src:a,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,I.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,I.jsx)(re,{className:`h-4 w-4`})})]})}):(0,I.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:_,onDragLeave:v,onDrop:b,onClick:()=>c.current?.click(),children:[(0,I.jsx)(g,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,I.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,I.jsxs)(j,{variant:`outline`,size:`sm`,disabled:l,className:`mx-auto`,children:[(0,I.jsx)(C,{className:`h-4 w-4 me-2`}),t(l?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,I.jsx)(`input`,{ref:c,type:`file`,accept:`image/*`,onChange:h,className:`hidden`})]}),a&&(0,I.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.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,I.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:p.blurAmount,onChange:e=>ee(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,I.jsxs)(`div`,{children:[(0,I.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,I.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.1`,value:p.opacity,onChange:e=>w(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]})]})]})})},Pe=()=>{let{t:e,i18n:t}=i();return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(_,{className:`h-4 w-4 text-gray-500 dark:text-gray-400`}),(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.appearance.language.title`)})]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.appearance.language.description`)}),(0,I.jsx)(`select`,{"data-testid":`language-switcher-select`,value:be(t.language),onChange:e=>{let t=e.target.value;N(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:we.map(e=>(0,I.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))})]})};function Fe({theme:e,preferences:t,onThemeChange:n,onAccentChange:r,onCustomAccentChange:a,onAdaptToAccentChange:o,onShowUsernameChange:s}){let{t:c}=i(),l=e.accent||`blue`,d=e.customAccent||`#2563eb`,f=ke(e);return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(Pe,{}),(0,I.jsx)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:c(`settings.appearance.title`)})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.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,I.jsx)(ie,{className:`h-4 w-4`}),c(`settings.appearance.theme.light`)]}),(0,I.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,I.jsx)(u,{className:`h-4 w-4`}),c(`settings.appearance.theme.dark`)]})]}),(0,I.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-3`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:c(`settings.appearance.accent.title`,{defaultValue:`Accent color`})})}),(0,I.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,I.jsxs)(`div`,{className:`grid grid-cols-5 xs:grid-cols-6 sm:grid-cols-9 gap-2`,children:[Se.map(e=>{let t=l===e.id;return(0,I.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,I.jsx)(O,{className:`absolute inset-0 m-auto h-4 w-4 drop-shadow`,style:{color:e.foreground}})},e.id)}),(0,I.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 ${l===`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,I.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,I.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:d},"aria-hidden":`true`}),(0,I.jsx)(ne,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),(0,I.jsxs)(`div`,{className:`mt-5 border-t border-gray-200 pt-5 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:c(`settings.appearance.accent.behaviorTitle`)}),(0,I.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.behaviorDescription`)}),(0,I.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,I.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,I.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:c(`settings.appearance.accent.defaultStyle`)}),(0,I.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,I.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,I.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:c(`settings.appearance.accent.adaptedStyle`)}),(0,I.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:c(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:c(`settings.appearance.chatInterface.title`)}),(0,I.jsx)(`div`,{className:`space-y-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:c(`settings.appearance.chatInterface.showUsername`)}),(0,I.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:c(`settings.appearance.chatInterface.showUsernameDescription`)})]}),(0,I.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showUsername,onChange:e=>s(e.target.checked)}),(0,I.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,I.jsx)(Ne,{})]})}function Ie({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,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.data.title`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.export`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.exportDescription`)}),(0,I.jsx)(j,{onClick:c,variant:`outline`,size:`sm`,className:`w-full`,children:h(`settings.data.exportAll`)})]}),(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.import`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.importDescription`)}),(0,I.jsx)(`input`,{ref:s,type:`file`,accept:`.json`,onChange:l,className:`hidden`}),(0,I.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,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.clearSessions`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.clearSessionsDescription`)}),(0,I.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,I.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,I.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:h(`settings.data.importOptions`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:h(`settings.data.importOptionsDescription`)}),(0,I.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,I.jsxs)(`label`,{className:`flex items-center`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:a===`skip`,onChange:e=>d(e.target.value),className:`me-2`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.skipDuplicates`)})]}),(0,I.jsxs)(`label`,{className:`flex items-center`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:a===`overwrite`,onChange:e=>d(e.target.value),className:`me-2`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.overwrite`)})]})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(j,{onClick:f,size:`sm`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.import`)}),(0,I.jsx)(j,{onClick:p,variant:`outline`,size:`sm`,children:h(`common.cancel`)})]})]}),o&&(0,I.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,I.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:h(`settings.data.importResults`)}),(0,I.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,I.jsxs)(`div`,{children:[h(`settings.data.preferences`),`:`,` `,o.preferences.imported?h(`settings.data.imported`):h(`settings.data.failed`)]}),(0,I.jsxs)(`div`,{children:[h(`settings.data.sessions`),`:`,` `,o.sessions.imported,` `,h(`settings.data.importedLabel`),`,`,o.sessions.skipped,` `,h(`settings.data.skipped`)]}),(0,I.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,I.jsxs)(`div`,{className:`mt-2`,children:[(0,I.jsxs)(`p`,{className:`font-medium`,children:[h(`settings.data.errors`),`:`]}),o.sessions.errors.map((e,t)=>(0,I.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`session-${t}`)),o.documents.errors.map((e,t)=>(0,I.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`document-${t}`))]})]}),(0,I.jsx)(j,{onClick:m,variant:`outline`,size:`sm`,className:`mt-2`,children:h(`common.close`)})]})]})]})})}function R({checked:e,onChange:t,disabled:n=!1}){return(0,I.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),disabled:n,className:`sr-only`}),(0,I.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,I.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 Le({settings:e,effectiveSettings:t,modelOptions:n,status:r,regenerating:a,onSettingChange:o,onReset:s,onRegenerate:c,onSave:l}){let{t:u}=i();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.documents.title`)}),(0,I.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,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u(`settings.documents.embeddings.title`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:u(`settings.documents.embeddings.enable`)})]}),(0,I.jsx)(R,{checked:e.enabled,onChange:e=>o(`enabled`,e)})]}),e.enabled&&(0,I.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:u(`settings.documents.embeddings.model`)}),(0,I.jsx)(P,{value:t.model,onChange:e=>o(`model`,e.target.value),options:n}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:u(`settings.documents.embeddings.modelDescription`)})]}),(0,I.jsx)(Re,{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,I.jsx)(Re,{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,I.jsx)(Re,{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,I.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:u(`settings.documents.embeddings.status`)}),(0,I.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,I.jsxs)(`div`,{children:[u(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,I.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,I.jsxs)(`div`,{children:[u(`settings.documents.embeddings.model`),`:`,` `,(0,I.jsx)(`span`,{className:`font-medium`,children:r.model})]}),(0,I.jsxs)(`div`,{children:[u(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,I.jsxs)(`span`,{className:`font-medium`,children:[r.chunksWithEmbeddings,` / `,r.totalChunks]})]}),r.totalChunks>0&&(0,I.jsxs)(`div`,{children:[u(`settings.documents.embeddings.coverage`),`:`,` `,(0,I.jsxs)(`span`,{className:`font-medium`,children:[Math.round(r.chunksWithEmbeddings/r.totalChunks*100),`%`]})]})]})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(j,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),u(`settings.generation.resetDefaults`)]}),e.enabled&&r&&r.totalChunks>0&&(0,I.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,I.jsx)(w,{size:16}),u(a?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,I.jsxs)(j,{onClick:l,className:`flex items-center gap-2`,children:[(0,I.jsx)(O,{size:16}),u(`settings.saveSettings`)]})]})]})})}function Re({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,I.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,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function ze({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,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:f(`settings.generation.title`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:f(`settings.generation.description`)}),(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(z,{title:f(`settings.generation.coreParameters`),children:[(0,I.jsx)(B,{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,I.jsx)(B,{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,I.jsx)(B,{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,I.jsx)(B,{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,I.jsxs)(z,{title:f(`settings.generation.generationControl`),children:[(0,I.jsx)(B,{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,I.jsx)(B,{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,I.jsx)(B,{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,I.jsx)(B,{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,I.jsxs)(z,{title:f(`settings.generation.advancedOptions`),children:[(0,I.jsx)(B,{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,I.jsx)(B,{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,I.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[f(`settings.generation.stopSequences`),(0,I.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,f(`settings.generation.commaSeparated`),`)`]})]}),(0,I.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,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:f(`settings.generation.stopSequencesDescription`)})]})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(j,{onClick:c,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),f(`settings.generation.resetDefaults`)]}),(0,I.jsxs)(j,{onClick:l,className:`flex items-center gap-2`,children:[(0,I.jsx)(O,{size:16}),f(`settings.generation.saveOptions`)]})]})]}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:f(`settings.generation.embeddingSettings`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:f(`settings.generation.enableEmbeddings`)}),(0,I.jsx)(R,{checked:t.enabled,onChange:e=>s(`enabled`,e)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:f(`settings.documents.embeddings.model`)}),(0,I.jsx)(P,{value:n.model,onChange:e=>s(`model`,e.target.value),options:r,disabled:!t.enabled})]}),(0,I.jsx)(V,{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,I.jsx)(V,{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,I.jsx)(V,{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,I.jsxs)(`div`,{className:`mt-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,I.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[f(`settings.documents.embeddings.status`),`:`]}),(0,I.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,I.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,I.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[f(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,I.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[a.chunksWithEmbeddings,` /`,` `,a.totalChunks]})]})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,I.jsxs)(j,{onClick:u,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),f(`settings.generation.resetDefaults`)]}),(0,I.jsxs)(j,{onClick:d,className:`flex items-center gap-2`,children:[(0,I.jsx)(O,{size:16}),f(`settings.saveSettings`)]})]})]})})]})})}function z({title:e,children:t}){return(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,I.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function B({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,I.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,I.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,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function V({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,I.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,I.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 Be({loading:e,settings:t,effectiveSettings:n,models:r,plugins:a,sizes:o,qualities:s,styles:c,onSettingChange:l,onModelChange:u,onReset:d,onSave:f}){let{t:p}=i();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.title`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.imageGen.description`)}),e?(0,I.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,I.jsx)(h,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,I.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:p(`settings.imageGen.loadingProviders`)})]}):r.length===0?(0,I.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(g,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:p(`settings.imageGen.noProviders`)}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:p(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.imageGen.enable`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.imageGen.enableDescription`)})]}),(0,I.jsx)(R,{checked:t.enabled,onChange:e=>l(`enabled`,e)})]})}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.configuration`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.model`)}),(0,I.jsx)(P,{value:n.model,onChange:e=>u(e.target.value),disabled:!t.enabled,options:[{value:``,label:p(`settings.model.selectModel`)},...r.map(e=>({value:e.model,label:`${e.model} (${e.plugin})`}))]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.modelDescription`)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.size`)}),(0,I.jsx)(P,{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,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.sizeDescription`)})]}),s.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.quality`)}),(0,I.jsx)(P,{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,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.qualityDescription`)})]}),c.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.style`)}),(0,I.jsx)(P,{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,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.styleDescription`)})]})]})]}),a.length>0&&(0,I.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.imageGen.availableProviders`)}),(0,I.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,I.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,I.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,I.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,p(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(j,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),p(`common.reset`)]}),(0,I.jsxs)(j,{onClick:f,className:`flex items-center gap-2`,children:[(0,I.jsx)(O,{size:16}),p(`settings.saveSettings`)]})]})]})]})})}function Ve({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,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:x(`settings.model.title`)}),(0,I.jsxs)(`div`,{className:`space-y-6`,children:[o?.role===`admin`&&(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:x(`settings.model.modelPullAccess`)}),(0,I.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:x(`settings.model.modelPullAccessDescription`)})]}),(0,I.jsx)(R,{checked:s?.allowUserModelPull??!0,onChange:m,disabled:d})]})}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.model.defaultModel`)}),(0,I.jsx)(P,{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,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:x(`settings.model.defaultModelDescription`)})]}),t&&(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.model.currentModelInfo`)}),(0,I.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,I.jsx)(H,{label:`${x(`settings.model.name`)}:`,value:t,truncate:!0}),S?.details&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(H,{label:`${x(`settings.model.size`)}:`,value:S.details.parameter_size}),(0,I.jsx)(H,{label:`${x(`settings.model.family`)}:`,value:S.details.family}),(0,I.jsx)(H,{label:`${x(`settings.model.format`)}:`,value:S.details.format})]})]})})]}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.systemMessage.title`)}),(0,I.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,I.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:x(`settings.systemMessage.description`)}),(0,I.jsx)(j,{onClick:_,size:`sm`,disabled:a||r===n,children:x(`common.save`)})]})]})]}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.model.autoTitle.title`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:x(`settings.model.autoTitle.enable`)}),(0,I.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:x(`settings.model.autoTitle.enableDescription`)})]}),(0,I.jsx)(R,{checked:c.titleSettings?.autoTitle||!1,onChange:v})]}),c.titleSettings?.autoTitle&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:x(`settings.model.autoTitle.taskModel`)}),(0,I.jsx)(P,{value:l,onChange:e=>y(e.target.value),options:u}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:x(`settings.model.autoTitle.taskModelDescription`)})]})]})]})}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:x(`settings.model.bulkOperations`)}),(0,I.jsx)(`div`,{className:`space-y-3`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:x(`settings.model.updateAll`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:x(`settings.model.updateAllDescription`)}),f&&p&&(0,I.jsx)(He,{progress:p}),(0,I.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 H({label:e,value:t,truncate:n=!1}){return(0,I.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,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,I.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 He({progress:e}){let{t}=i(),n=Math.round(e.current/e.total*100);return(0,I.jsxs)(`div`,{className:`mb-4 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,I.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,I.jsxs)(`span`,{className:`text-primary-600 dark:text-primary-400 font-semibold`,children:[n,`%`]})]}),(0,I.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-3 shadow-subtle`,children:(0,I.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,I.jsxs)(`div`,{className:`text-xs flex items-center justify-between`,children:[(0,I.jsxs)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:[t(`settings.model.status`),`:`,` `,e.status===`starting`?(0,I.jsx)(`span`,{className:`text-accent-500 dark:text-accent-400`,children:t(`settings.model.statusStarting`)}):e.status===`success`?(0,I.jsx)(`span`,{className:`text-success-600 dark:text-success-500`,children:t(`settings.model.statusComplete`)}):e.status===`error`?(0,I.jsxs)(`span`,{className:`text-error-600 dark:text-error-500`,children:[t(`settings.model.statusError`),`: `,e.error]}):``]}),(0,I.jsx)(`span`,{className:`text-gray-400 dark:text-dark-600 text-[10px]`,children:t(`settings.model.modelsProgress`,{current:e.current,total:e.total})})]})]})}ce(`components:hugging-face-model-browser`);var Ue=({plugin:e})=>{let{t}=i(),{pluginVariables:n,fetchPluginVariables:r,updatePluginVariables:o,resetPluginVariables:s}=Ee(),[c,l]=(0,F.useState)({}),[u,d]=(0,F.useState)(!1),[f,p]=(0,F.useState)(!1),[m,h]=(0,F.useState)(new Set),[g,_]=(0,F.useState)({}),v=(0,F.useMemo)(()=>e.variables||[],[e.variables]),b=(0,F.useMemo)(()=>n[e.id]||{},[n,e.id]);(0,F.useEffect)(()=>{r(e.id)},[r,e.id]);let x=JSON.stringify(b),[S,C]=(0,F.useState)(null);if(S!==x){let e=JSON.parse(x);if(!(Object.keys(e).length===0&&f)){let t={};for(let n of v){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)}C(x)}let w=async()=>{let n={};for(let e of v){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(_(n),Object.keys(n).length>0)return;d(!0);let r=await o(e.id,c);d(!1),r?y.success(t(`pluginManager.variables.saved`,`Variables saved`)):y.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))},te=async()=>{await s(e.id);let n={};for(let e of v)n[e.name]=e.default??(e.type===`boolean`?!1:e.type===`number`?0:``);l(n),y.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})},T=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,I.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,I.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,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.label})]});case`select`:return(0,I.jsx)(`select`,{value:String(n??``),onChange:t=>l(n=>({...n,[e.name]:t.target.value})),className:o,children:(e.options||[]).map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))});case`number`:return(0,I.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,I.jsxs)(`div`,{className:`relative`,children:[(0,I.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,I.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,I.jsx)(E,{className:`w-4 h-4`}):(0,I.jsx)(ee,{className:`w-4 h-4`})})]})}};return(0,I.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[(0,I.jsx)(`div`,{className:`space-y-3`,children:v.map(e=>(0,I.jsxs)(`div`,{children:[e.type!==`boolean`&&(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[e.label,e.required&&(0,I.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&e.type!==`boolean`&&(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:e.description}),T(e),g[e.name]&&(0,I.jsx)(`p`,{className:`text-xs text-red-500 mt-1`,children:g[e.name]})]},e.name))}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,I.jsxs)(j,{size:`sm`,onClick:w,disabled:u,className:`gap-1.5`,children:[(0,I.jsx)(a,{className:`w-3.5 h-3.5`}),u?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,I.jsxs)(j,{variant:`outline`,size:`sm`,onClick:te,className:`gap-1.5`,children:[(0,I.jsx)(D,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function We({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:ee,onActivatePlugin:w,onDeletePlugin:te,onExportPlugin:ne,onSaveApiKey:T,onDeleteApiKey:ie}){let{t:E}=i(),ae=e.filter(e=>e.active);return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:E(`settings.plugins.title`)}),r&&(0,I.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,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:r}),(0,I.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,I.jsx)(re,{className:`h-4 w-4`})})]})}),(0,I.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,I.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:E(`settings.plugins.addNew`)}),(0,I.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,I.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>g(!o),disabled:t||n,children:[(0,I.jsx)(C,{className:`h-4 w-4 me-2`}),E(`settings.plugins.upload`)]}),(0,I.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>_(!c),disabled:t,children:E(`settings.plugins.addJson`)})]})]}),o&&(0,I.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,I.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,I.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,I.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>g(!1),disabled:n,children:E(`common.cancel`)})]}),n&&(0,I.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:E(`settings.plugins.uploading`)})]}),c&&(0,I.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.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,I.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,I.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>{_(!1),v(``)},children:E(`common.cancel`)}),(0,I.jsx)(j,{size:`sm`,onClick:b,disabled:!l.trim()||t,children:E(`settings.plugins.install`)})]})]})})]}),ae.length>0&&(0,I.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,I.jsxs)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:[E(`settings.plugins.active`),` (`,ae.length,`)`]}),(0,I.jsx)(`div`,{className:`space-y-2`,children:ae.map(e=>(0,I.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,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`font-medium text-green-800 dark:text-green-200`,children:e.name}),(0,I.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,I.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>w(e.id),className:`text-green-600 border-green-300 hover:bg-green-100`,children:E(`settings.plugins.deactivate`)})]},e.id))})]}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`div`,{className:`p-4 border-b border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[E(`settings.plugins.installed`),` (`,e.length,`)`]})}),t?(0,I.jsx)(`div`,{className:`p-8 text-center`,children:(0,I.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:E(`settings.plugins.loading`)})}):e.length===0?(0,I.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,I.jsx)(s,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,I.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:E(`settings.plugins.noPlugins`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:E(`settings.plugins.noPluginsDescription`)})]}):(0,I.jsx)(`div`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,I.jsx)(Ge,{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:()=>w(e.id),onExport:()=>ne(e.id),onDelete:()=>te(e.id),onApiKeyChange:t=>S(e.id,t),onShowApiKeyChange:t=>ee(e.id,t),onSaveApiKey:()=>T(e.id),onDeleteApiKey:()=>ie(e.id)},e.id))})]})]})})}function Ge({plugin:e,loading:t,hasApiKey:n,expanded:r,apiKey:a,showApiKey:o,savingApiKey:s,onExpand:c,onActivate:u,onExport:d,onDelete:f,onApiKeyChange:p,onShowApiKeyChange:m,onSaveApiKey:h,onDeleteApiKey:g}){let{t:_}=i();return(0,I.jsxs)(`div`,{className:`p-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,I.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,I.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,I.jsxs)(`div`,{children:[(0,I.jsx)(`h5`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,I.jsxs)(`div`,{className:`flex items-center space-x-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,I.jsx)(`span`,{children:e.type}),(0,I.jsx)(`span`,{children:`•`}),(0,I.jsxs)(`span`,{children:[e.model_map?.length||0,` `,_(`settings.plugins.models`)]}),e.endpoint&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{children:`•`}),(0,I.jsx)(`span`,{className:`truncate max-w-32`,children:e.endpoint})]}),n&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{children:`•`}),(0,I.jsx)(`span`,{className:`text-green-600`,children:_(`settings.plugins.apiKeySet`)})]})]})]})]})}),(0,I.jsxs)(`div`,{className:`flex items-center space-x-1 flex-shrink-0`,children:[(0,I.jsxs)(j,{variant:`ghost`,size:`sm`,onClick:c,title:`Configure API key`,className:n?`text-green-600`:`text-ink`,children:[(0,I.jsx)(l,{className:`h-4 w-4`}),r?(0,I.jsx)(b,{className:`h-3 w-3`}):(0,I.jsx)(S,{className:`h-3 w-3`})]}),(0,I.jsx)(j,{variant:`outline`,size:`sm`,onClick:u,disabled:t,className:e.active?`text-green-600 border-green-300`:``,children:e.active?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(O,{className:`h-4 w-4 me-1`}),_(`settings.plugins.activeLabel`)]}):_(`settings.plugins.activate`)}),(0,I.jsx)(j,{variant:`ghost`,size:`sm`,onClick:d,disabled:t,title:`Export plugin`,children:(0,I.jsx)(oe,{className:`h-4 w-4`})}),(0,I.jsx)(j,{variant:`ghost`,size:`sm`,onClick:f,disabled:t,className:`text-red-600 hover:text-red-700 hover:bg-red-50`,title:`Delete plugin`,children:(0,I.jsx)(ae,{className:`h-4 w-4`})})]})]}),r&&(0,I.jsx)(Ke,{plugin:e,hasApiKey:n,apiKey:a,showApiKey:o,savingApiKey:s,onApiKeyChange:p,onShowApiKeyChange:m,onSaveApiKey:h,onDeleteApiKey:g}),e.variables&&e.variables.length>0&&(0,I.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,I.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,I.jsx)(se,{className:`h-4 w-4 text-gray-500`}),(0,I.jsxs)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[_(`settings.plugins.variables`,`Variables`),` (`,e.variables.length,`)`]})]}),(0,I.jsx)(Ue,{plugin:e})]})]})}function Ke({plugin:e,hasApiKey:t,apiKey:n,showApiKey:r,savingApiKey:a,onApiKeyChange:o,onShowApiKeyChange:s,onSaveApiKey:c,onDeleteApiKey:u}){let{t:d}=i();return(0,I.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,I.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,I.jsx)(l,{className:`h-4 w-4 text-gray-500`}),(0,I.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:d(`settings.plugins.apiKeyConfiguration`)})]}),(0,I.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,I.jsxs)(`span`,{className:`block mt-1`,children:[d(`settings.plugins.apiKeyEnvAlternative`),` `,(0,I.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,d(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,I.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,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(O,{className:`h-4 w-4 text-green-600`}),(0,I.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:d(`settings.plugins.apiKeyConfigured`)})]}),(0,I.jsx)(j,{variant:`outline`,size:`sm`,onClick:u,disabled:a,className:`text-red-600 border-red-300 hover:bg-red-50`,children:a?(0,I.jsx)(h,{className:`h-4 w-4 animate-spin`}):d(`common.remove`)})]}):(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.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,I.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,I.jsx)(E,{className:`h-4 w-4`}):(0,I.jsx)(ee,{className:`h-4 w-4`})})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(j,{size:`sm`,onClick:c,disabled:a||!n.trim(),children:a?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{className:`h-4 w-4 me-2 animate-spin`}),d(`common.saving`)]}):d(`settings.plugins.saveApiKey`)})})]})]})}function qe({loading:e,settings:t,effectiveSettings:n,models:r,plugins:a,voices:o,testing:s,onSettingChange:c,onModelChange:l,onReset:u,onTest:f,onSave:p}){let{t:m}=i(),g=r.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.tts.title`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:m(`settings.tts.description`)}),e?(0,I.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,I.jsx)(h,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,I.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:m(`settings.tts.loadingProviders`)})]}):r.length===0?(0,I.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(x,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:m(`settings.tts.noProviders`)}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:m(`settings.tts.noProvidersDescription`)})]})]})}):(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.enable`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.enableDescription`)})]}),(0,I.jsx)(R,{checked:t.enabled,onChange:e=>c(`enabled`,e)})]})}),(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.autoPlay`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.autoPlayDescription`)})]}),(0,I.jsx)(R,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>c(`autoPlay`,e)})]})}),(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.streamSentences`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.streamSentencesDescription`)})]}),(0,I.jsx)(R,{checked:t.streamSentences||!1,disabled:!t.enabled,onChange:e=>c(`streamSentences`,e)})]})}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.tts.voiceConfiguration`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.tts.model`)}),(0,I.jsx)(P,{"aria-label":m(`settings.tts.model`),value:g?_e(g):``,onChange:e=>{let t=r.find(t=>_e(t)===e.target.value);t&&l(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:m(`settings.model.selectModel`)},...r.map(e=>({value:_e(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.tts.modelDescription`)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.tts.voice`)}),(0,I.jsx)(P,{"aria-label":m(`settings.tts.voice`),value:n.voice,onChange:e=>c(`voice`,e.target.value),disabled:!t.enabled||o.length===0,options:[{value:``,label:m(`settings.tts.selectVoice`)},...o.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.tts.voiceDescription`)})]})]})]}),a.length>0&&(0,I.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:m(`settings.tts.availableProviders`)}),(0,I.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,I.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,I.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,I.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,m(`settings.tts.models`),`)`]})]},e.id))})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(j,{onClick:u,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),m(`common.reset`)]}),(0,I.jsx)(j,{onClick:f,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:s?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(te,{size:16}),m(`settings.tts.stop`)]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{size:16}),m(`settings.tts.test`)]})})]}),(0,I.jsxs)(j,{onClick:p,className:`flex items-center gap-2`,children:[(0,I.jsx)(O,{size:16}),m(`settings.saveSettings`)]})]})]})]})})}function Je({preferences:e,sessions:t,loadPreferences:n,loadSessions:r}){let[i,a]=(0,F.useState)(!1),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(`skip`),[u,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(null),m=(0,F.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),y.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 k.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:[]}}),y.success(`Data imported successfully`),await n(),await r();else throw Error(i.error||`Import failed`)}catch(e){y.error(e instanceof Error?e.message:`Import failed`),d(null)}finally{a(!1),s(!1),h()}}},handleCancelImport:()=>{s(!1),d(null),h()}}}var Ye=`0.15.0`,Xe=`__current_running_model__`,Ze={enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},Qe={enabled:!1,autoPlay:!1,model:``,voice:``,speed:1,pluginId:``,streamSentences:!1},$e={enabled:!1,model:``,size:`1024x1024`,quality:`standard`,style:`vivid`,pluginId:``},et=({isOpen:e,onClose:t})=>{let{models:n,selectedModel:a,setSelectedModel:c,systemMessage:l,setSystemMessage:u,clearAllSessions:d,loading:f,sessions:p,loadModels:h,loadSessions:_}=xe(),{theme:v,updateTheme:b,preferences:S,setPreferences:C,loadPreferences:ee}=M(),{user:te,systemInfo:T,setSystemInfo:ie}=Te(),{plugins:E,isLoading:ae,isUploading:oe,error:D,loadPlugins:O,uploadPlugin:ce,deletePlugin:_e,activatePlugin:A,deactivatePlugin:be,exportPlugin:Se,clearError:we,installPlugin:De}=Ee(),{t:N}=i(),Oe=F.useId(),P=S.titleSettings?.taskModel||``,ke=[{value:``,label:N(`settings.model.autoTitle.selectTaskModel`)},{value:Xe,label:`Use current running model`},...n.map(e=>({value:e.name,label:e.name})),...![``,Xe,...n.map(e=>e.name)].includes(P)&&P?[{value:P,label:`${P} (current)`}]:[]],[Ae,je]=(0,F.useState)(`appearance`),[L,Ne]=(0,F.useState)(l),[Pe,R]=(0,F.useState)(!1),[Re,z]=(0,F.useState)(!1),[B,V]=(0,F.useState)(null),[H,He]=(0,F.useState)(!1),[Ue,Ge]=(0,F.useState)(!1),[Ke,et]=(0,F.useState)(``),tt=(0,F.useRef)(null),[nt,rt]=(0,F.useState)(null),[it,at]=(0,F.useState)({}),[ot,st]=(0,F.useState)({}),[ct,lt]=(0,F.useState)(null),[ut,dt]=(0,F.useState)(S.generationOptions||{}),[U,ft]=(0,F.useState)(S.embeddingSettings||Ze),[pt,mt]=(0,F.useState)(!1),[W,ht]=(0,F.useState)(S.ttsSettings||Qe),[gt,G]=(0,F.useState)(!1),K=(0,F.useRef)(null),[q,_t]=(0,F.useState)(S.imageGenSettings||$e),{importing:vt,showImportOptions:yt,mergeStrategy:bt,setMergeStrategy:xt,importResult:St,setImportResult:Ct,importFileInputRef:wt,handleExportData:Tt,handleImportFileSelect:Et,handleConfirmImport:Dt,handleCancelImport:Ot}=Je({preferences:S,sessions:p,loadPreferences:ee,loadSessions:_}),kt=Ce(),{data:At={}}=r({queryKey:[`plugin-credentials`],queryFn:async()=>{let e=await de.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 le.getModels();return e.success&&e.data?e.data:[]},enabled:e}),J=(0,F.useMemo)(()=>{let e=jt.find(e=>e.id===U.model||e.rawModel===U.model);return e&&e.id!==U.model?{...U,model:e.id}:U},[jt,U]),{data:Mt=null}=r({queryKey:[`embedding-status`],queryFn:async()=>{let e=await pe.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([ue.getModels(),ue.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Y=(0,F.useMemo)(()=>Nt?.models??[],[Nt]),Ft=Nt?.plugins??[],X=(0,F.useMemo)(()=>me(Y,W.model,W.pluginId),[Y,W.model,W.pluginId]),Z=(0,F.useMemo)(()=>{if(!X)return W;let e=ge(Y,W.model,W.pluginId);return e&&W.pluginId===e.plugin?W:{...W,model:X.model,pluginId:X.plugin,voice:X.config?.default_voice||``}},[X,Y,W]),It=(0,F.useMemo)(()=>ge(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([he.getModels(),he.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Q=(0,F.useMemo)(()=>Lt?.models??[],[Lt]),zt=(0,F.useMemo)(()=>Lt?.plugins??[],[Lt]),$=(0,F.useMemo)(()=>Q.find(e=>e.model===q.model)||Q[0],[Q,q.model]),Bt=(0,F.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,F.useRef)(!1),Gt=(0,F.useRef)(l);(0,F.useEffect)(()=>{if(!e){Wt.current=!1;return}Wt.current&&Gt.current===l||(Wt.current=!0,Gt.current=l,Ne(l),dt(S.generationOptions||{}),ft(S.embeddingSettings||Ze),ht(S.ttsSettings||Qe),_t(S.imageGenSettings||$e))},[e,S.embeddingSettings,S.generationOptions,S.imageGenSettings,S.ttsSettings,l]);let Kt=(0,F.useRef)(!1);(0,F.useEffect)(()=>{if(!e){Kt.current=!1;return}Kt.current||(Kt.current=!0,O(),h())},[e,O,h]),(0,F.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=it[e];if(!t?.trim()){y.error(`Please enter an API key`);return}lt(e);try{let n=await de.setApiKey(e,t.trim());n.success?(y.success(`API key saved successfully`),await kt.invalidateQueries({queryKey:[`plugin-credentials`]}),at(t=>({...t,[e]:``})),st(t=>({...t,[e]:!1})),rt(null)):y.error(n.error||`Failed to save API key`)}catch{y.error(`Failed to save API key`)}finally{lt(null)}},Jt=async e=>{lt(e);try{let t=await de.deleteApiKey(e);t.success?(y.success(`API key removed`),await kt.invalidateQueries({queryKey:[`plugin-credentials`]}),at(t=>({...t,[e]:``}))):y.error(t.error||`Failed to remove API key`)}catch{y.error(`Failed to remove API key`)}finally{lt(null)}},Yt=(e,t)=>{let n=ge(Y,e,t);n&&ht(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)=>{ht(n=>({...n,[e]:t}))},Qt=async()=>{try{let e=await k.updatePreferences({ttsSettings:Z});e.success&&e.data&&(C(e.data),y.success(`TTS settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);y.error(`Failed to save TTS settings: `+t)}},$t=async()=>{if(gt){let e=K.current;e&&(e.pause(),e.currentTime=0,K.current=null),G(!1);return}G(!0);try{let e=await ue.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);K.current=n,n.onended=()=>{G(!1),K.current=null},n.onerror=()=>{y.error(`Failed to play audio`),G(!1),K.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);y.error(`TTS test failed: `+t),G(!1)}},en=()=>{ht({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 k.updatePreferences({imageGenSettings:Bt});e.success&&e.data&&(C(e.data),y.success(`Image generation settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);y.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{mt(!0),(await pe.regenerateEmbeddings()).success&&(y.success(`Embeddings regenerated successfully`),await kt.invalidateQueries({queryKey:[`embedding-status`]}))}catch(e){let t=e instanceof Error?e.message:String(e);y.error(`Failed to regenerate embeddings: `+t)}finally{mt(!1)}},on=async e=>{try{let t=await k.updatePreferences(e);t.success&&t.data&&(C(t.data),y.success(`Settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);y.error(`Failed to update settings: `+t)}},sn=async e=>{let t=e.target.files?.[0];t&&(await ce(t),He(!1),tt.current&&(tt.current.value=``),await h())},cn=async()=>{try{await De(JSON.parse(Ke)),Ge(!1),et(``),await h()}catch{we(),y.error(`Invalid JSON format`)}},ln=async e=>{E.find(t=>t.id===e)?.active?await be(e):await A(e),await h()},un=async e=>{window.confirm(`Are you sure you want to delete this plugin?`)&&(await _e(e),await h())},dn=async e=>{await Se(e)};if(!e)return null;let fn=e=>{let t=M.getState().theme;b(ye({...t,mode:e}))},pn=e=>{let t=M.getState().theme;b(ye({...t,accent:e}))},mn=e=>{let t=M.getState().theme;b(ye({...t,accent:`custom`,customAccent:e}))},hn=e=>{let t=M.getState().theme;b(ye({...t,adaptToAccent:e}))},gn=e=>{C({showUsername:e}),k.updatePreferences({showUsername:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);y.error(`Failed to update settings: `+t)})},_n=e=>{let t=e.target.value;c(t),on({defaultModel:t}),y.success(`Default model updated`)},vn=e=>{Ne(e.target.value)},yn=()=>{u(L),on({systemMessage:L}),y.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(),y.success(`All chat sessions deleted`))},xn=async()=>{R(!0),V(null),fe.pullAllModelsStream(e=>{V(e)},()=>{R(!1),V(null),y.success(`All models updated successfully!`),h()},e=>{R(!1),V(null),y.error(`Failed to update models: `+e)})},Sn=async e=>{z(!0);try{let t=await ve.updateModelPullSetting(e);if(t.success&&t.data)ie(t.data),y.success(N(`settings.model.modelPullAccessSaved`));else throw Error(t.error||`Failed to update model access`)}catch(e){let t=e instanceof Error?e.message:String(e);y.error(`${N(`settings.model.modelPullAccessSaveFailed`)}: ${t}`)}finally{z(!1)}},Cn=e=>{let t={...S.titleSettings,autoTitle:e,taskModel:S.titleSettings?.taskModel||``};C({titleSettings:t}),k.updatePreferences({titleSettings:t})},wn=e=>{let t={...S.titleSettings,autoTitle:S.titleSettings?.autoTitle||!1,taskModel:e};C({titleSettings:t}),k.updatePreferences({titleSettings:t})},Tn=(e,t)=>{at(n=>({...n,[e]:t}))},En=(e,t)=>{st(n=>({...n,[e]:t}))},Dn=(e,t)=>{dt(n=>({...n,[e]:t}))},On=async()=>{try{let e=await k.setGenerationOptions(ut);e.success&&e.data&&(C(e.data),y.success(`Generation options updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);y.error(`Failed to update generation options: `+t)}},kn=async()=>{try{let e=await k.resetGenerationOptions();e.success&&e.data&&(C(e.data),dt(e.data.generationOptions||{}),y.success(`Generation options reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);y.error(`Failed to reset generation options: `+t)}},An=(e,t)=>{ft(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 k.setEmbeddingSettings(J);e.success&&e.data&&(C(e.data),y.success(`Embedding settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);y.error(`Failed to update embedding settings: `+t)}},Nn=async()=>{try{let e=await k.resetEmbeddingSettings();e.success&&e.data&&(C(e.data),ft(e.data.embeddingSettings||{}),y.success(`Embedding settings reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);y.error(`Failed to reset embedding settings: `+t)}},Pn=[{id:`appearance`,label:N(`settings.tabs.appearance`),icon:ne},{id:`models`,label:N(`settings.tabs.model`),icon:o},{id:`generation`,label:N(`settings.tabs.generation`),icon:se},{id:`tts`,label:N(`settings.tabs.tts`),icon:x},{id:`image-gen`,label:N(`settings.tabs.imageGen`),icon:g},{id:`documents`,label:N(`settings.tabs.documents`),icon:w},{id:`plugins`,label:N(`settings.tabs.plugins`),icon:s},{id:`data`,label:N(`settings.tabs.data`),icon:w},{id:`about`,label:N(`settings.tabs.about`),icon:m}];return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,I.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":Oe,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,I.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,I.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,I.jsx)(`h2`,{id:Oe,className:`text-xl font-normal tracking-[-0.025em] text-gray-950 dark:text-dark-950 sm:text-2xl rtl:tracking-normal`,children:N(`settings.title`)}),(0,I.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:N(`common.close`,{defaultValue:`Close`}),children:(0,I.jsx)(re,{className:`h-5 w-5 sm:h-4 sm:w-4`})})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overscroll-behavior-contain sm:flex-row`,children:[(0,I.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,I.jsx)(`nav`,{className:`flex gap-1 sm:flex-col`,role:`tablist`,children:Pn.map(e=>{let t=e.icon,n=Ae===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,I.jsxs)(`button`,{onClick:()=>je(e.id),className:r,role:`tab`,"aria-selected":n,"aria-controls":`settings-tab-panel`,children:[(0,I.jsx)(t,{className:`h-4 w-4 flex-shrink-0`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`truncate whitespace-nowrap text-xs font-medium sm:text-sm`,children:e.label})]},e.id)})})}),(0,I.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(Ae){case`appearance`:return(0,I.jsx)(Fe,{theme:v,preferences:S,onThemeChange:fn,onAccentChange:pn,onCustomAccentChange:mn,onAdaptToAccentChange:hn,onShowUsernameChange:gn});case`models`:return(0,I.jsx)(Ve,{models:n,selectedModel:a,systemMessage:l,tempSystemMessage:L,loading:f,user:te,systemInfo:T,preferences:S,currentTaskModel:P,autoTitleTaskModelOptions:ke,updatingModelPullAccess:Re,updatingAllModels:Pe,updateProgress:B,onModelPullAccessToggle:Sn,onModelChange:_n,onSystemMessageChange:vn,onSystemMessageSave:yn,onAutoTitleChange:Cn,onAutoTitleTaskModelChange:wn,onUpdateAllModels:xn});case`tts`:return(0,I.jsx)(qe,{loading:Pt,settings:W,effectiveSettings:Z,models:Y,plugins:Ft,voices:It,testing:gt,onSettingChange:Zt,onModelChange:Yt,onReset:en,onTest:$t,onSave:Qt});case`image-gen`:return(0,I.jsx)(Be,{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,I.jsx)(Le,{settings:U,effectiveSettings:J,modelOptions:jn,status:Mt,regenerating:pt,onSettingChange:An,onReset:Nn,onRegenerate:an,onSave:Mn});case`plugins`:return(0,I.jsx)(We,{plugins:E,loading:ae,uploading:oe,error:D,hasKeys:At,showUploadForm:H,showJsonForm:Ue,jsonInput:Ke,fileInputRef:tt,expandedPluginId:nt,pluginApiKeys:it,showApiKey:ot,savingApiKey:ct,onClearError:we,onShowUploadFormChange:He,onShowJsonFormChange:Ge,onJsonInputChange:et,onFileUpload:sn,onJsonSubmit:cn,onExpandedPluginChange:rt,onPluginApiKeyChange:Tn,onShowApiKeyChange:En,onActivatePlugin:ln,onDeletePlugin:un,onExportPlugin:dn,onSaveApiKey:qt,onDeleteApiKey:Jt});case`data`:return(0,I.jsx)(Ie,{sessionCount:p.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,I.jsx)(Me,{appVersion:Ye});case`generation`:return(0,I.jsx)(ze,{generationOptions:ut,embeddingSettings:U,effectiveEmbeddingSettings:J,embeddingModelOptions:jn,embeddingStatus:Mt,onGenerationOptionChange:Dn,onEmbeddingSettingsChange:An,onResetGenerationOptions:kn,onSaveGenerationOptions:On,onResetEmbeddingSettings:Nn,onSaveEmbeddingSettings:Mn});default:return null}})()})]})]})})]})};export{et as SettingsModal};
|
|
@@ -0,0 +1 @@
|
|
|
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-C0lZwNoc.js";import{t as i}from"./useTranslation-Cs6iTP4m.js";import{D as a,Lt as o,Xt as s,g as c,o as l,u}from"./ui-vendor-DUqvZsfs.js";import{t as d}from"./logger-DbNs3-DK.js";import{b as f}from"./api-DD5qhhLf.js";import{t as p}from"./Button-DBk-AREB.js";import{C as m,J as h,O as g,a as _,c as v,d as y,f as b,l as x,o as S,s as C,u as w}from"../assets/index-uCHBH_PM.js";var T=e(n(),1),E=t(),D=d(`components:user-manager`),O=()=>{let{t:e}=i(),t=h(),[n,d]=(0,T.useState)(!1),[_,S]=(0,T.useState)(null),[O,k]=(0,T.useState)({username:``,email:``,password:``,role:`user`}),{user:A}=g(),{data:j=[],isLoading:M}=r({queryKey:[`users`],queryFn:async()=>{let t=await f.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 f.createUser(O);t.success&&t.data&&(await N(),k({username:``,email:``,password:``,role:`user`}),d(!1),s.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`)),s.error(n)}},F=async t=>{if(t.preventDefault(),_)try{let t={username:O.username,email:O.email,role:O.role};O.password&&O.password.trim()!==``&&(t.password=O.password);let n=await f.updateUser(_.id,t);n.success&&n.data&&(await N(),S(null),k({username:``,email:``,password:``,role:`user`}),s.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`)),s.error(n)}},I=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await f.deleteUser(t)).success&&(await N(),s.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`)),s.error(n)}},L=e=>{S(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)(p,{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)(a,{size:16}),(0,E.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,E.jsxs)(C,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,E.jsxs)(w,{children:[(0,E.jsx)(y,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,E.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,E.jsx)(v,{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)(b,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,E.jsx)(m,{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)(b,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,E.jsx)(m,{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)(b,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,E.jsx)(m,{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)(b,{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)(p,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,E.jsx)(p,{type:`button`,variant:`outline`,onClick:()=>{k({username:``,email:``,password:``,role:`user`}),d(!1)},children:e(`common.cancel`)})]})]})})]}),_&&(0,E.jsxs)(C,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,E.jsxs)(w,{children:[(0,E.jsxs)(y,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,_.username]}),(0,E.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,E.jsx)(v,{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)(b,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,E.jsx)(m,{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)(b,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,E.jsx)(m,{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)(b,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,E.jsx)(m,{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)(b,{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:_?.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`)})]}),_?.id===A?.id&&A?.role===`admin`&&(0,E.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,E.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,E.jsx)(p,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,E.jsx)(p,{type:`button`,variant:`outline`,onClick:()=>{S(null),k({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),(0,E.jsxs)(C,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,E.jsxs)(w,{children:[(0,E.jsxs)(y,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,j.length,`)`]}),(0,E.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,E.jsx)(v,{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)(c,{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)(p,{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)(o,{size:16})}),(0,E.jsx)(p,{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)(S,{children:[(0,E.jsx)(_,{title:e(`userManager.title`),description:e(`userManager.pageDescription`)}),(0,E.jsx)(O,{})]})};export{k as UserManagementPage,k as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-BnLuavNv.js","js/router-vendor-BjDI9mRe.js","js/rolldown-runtime-QTnfLwEv.js","js/markdown-core-GI9BPwrB.js","js/estree-DPzMpjFm.js","assets/index-uCHBH_PM.js","js/react-vendor-DyG_ODzn.js","js/useTranslation-Cs6iTP4m.js","js/ui-vendor-DUqvZsfs.js","js/utils-vendor-Cbaj0BC5.js","js/demoMode-BhEpMVh5.js","js/logger-DbNs3-DK.js","js/api-DD5qhhLf.js","js/utils-pTFqSV8c.js","js/Button-DBk-AREB.js","assets/index-Bv-twCuY.css","js/typescript-B6y_hxBm.js","js/postcss-DSDkwgFE.js","js/html-R50jmBYq.js","js/markdown-C08x2H-K.js","js/yaml-mLy9chOK.js","js/standalone-DpMZUvjd.js","js/OptimizedSyntaxHighlighter-Ci9sRc78.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}from"./markdown-core-GI9BPwrB.js";import{d as r,f as i,i as a,l as o,u as s}from"./router-vendor-BjDI9mRe.js";import{t as c}from"./useTranslation-Cs6iTP4m.js";import{At as l,C as u,Dt as d,Et as f,F as p,Gt as m,It as h,J as g,Jt as _,N as v,Nt as y,O as b,Pt as x,Rt as S,T as C,Tt as w,Vt as T,Zt as E,_ as D,bt as O,h as ee,jt as k,lt as te,n as ne,nt as re,o as A,qt as ie,r as ae,rt as oe,tt as se,u as ce,x as le,xt as ue,yt as de}from"./ui-vendor-DUqvZsfs.js";import{o as fe,s as pe}from"./api-DD5qhhLf.js";import{t as j}from"./utils-pTFqSV8c.js";import{t as M}from"./Button-DBk-AREB.js";import{A as me,F as he,H as ge,M as _e,N as ve,O as ye,V as be,W as xe,j as Se,m as N,n as P}from"../assets/index-uCHBH_PM.js";import{t as Ce}from"./RichMessageContent-WQLdJ5jq.js";var F=e(n(),1),I=t();function L({models:e,modelKey:t,running:n,loading:r,disabled:i=!1,remoteDisclosureDismissed:a,remoteDisclosureSaving:o,onModelChange:s,onDismissRemoteDisclosure:l,onSubmit:u,onCancel:d}){let{t:f}=c(),[p,m]=(0,F.useState)(``),h=(0,F.useRef)(null),g=e.find(e=>e.key===t),v=g?.remote===!0,y=async()=>{await l()&&h.current?.focus()},b=async()=>{let e=p.trim();!e||r||n||i||!g||await u(e)&&m(``)};return(0,I.jsxs)(`div`,{className:`relative shrink-0 border-t border-line bg-surface-raised/95 px-3 py-3 backdrop-blur md:px-5`,children:[v&&!a&&(0,I.jsx)(`div`,{className:`absolute inset-x-3 bottom-full z-30 mx-auto mb-3 max-w-3xl md:inset-x-5`,children:(0,I.jsxs)(`aside`,{"data-testid":`work-provider-disclosure-popover`,"aria-labelledby":`work-provider-disclosure-title`,"aria-live":`polite`,className:`relative rounded-2xl border border-warning-500/40 bg-surface-overlay p-3 pe-10 shadow-overlay backdrop-blur dark:border-warning-500/45`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>void y(),disabled:o,className:`absolute end-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-warning-500/20 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-warning-500 disabled:cursor-wait disabled:opacity-50`,"aria-label":f(`work.composer.remoteDismissLabel`,{defaultValue:`Dismiss remote provider notice`}),children:(0,I.jsx)(ne,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-warning-500/20`,children:(0,I.jsx)(_,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:f(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,I.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-ink-muted`,children:f(`work.composer.remoteHint`,{defaultValue:`Conversation and tool output are sent to the configured service. One autonomous run can make multiple provider calls and may incur charges. Workspace files stay local unless a tool returns their contents.`})}),(0,I.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,I.jsx)(M,{"data-testid":`work-provider-disclosure-dismiss`,type:`button`,variant:`ghost`,size:`sm`,loading:o,className:`h-7 border-warning-500 bg-warning-500 px-2.5 text-xs text-[#3d120c] hover:bg-warning-500/90 hover:text-[#3d120c]`,onClick:()=>void y(),children:f(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,I.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-2xl border border-line bg-surface shadow-subtle focus-within:border-primary-500 focus-within:ring-2 focus-within:ring-primary-500/15`,children:[(0,I.jsx)(`textarea`,{"data-testid":`work-composer-input`,dir:`auto`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),b())},disabled:i||n,rows:3,className:`block max-h-48 min-h-[5rem] w-full resize-none bg-transparent px-4 pt-3 text-sm leading-relaxed text-ink outline-none placeholder:text-ink-subtle disabled:cursor-not-allowed disabled:opacity-60`,placeholder:f(`work.composer.placeholder`,{defaultValue:`Describe what you want to build or change…`})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-2.5 pb-2.5`,children:[(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:(0,I.jsxs)(`select`,{ref:h,"data-testid":`work-model-select`,dir:`auto`,value:t,onChange:e=>void s(e.target.value),disabled:n||e.length===0,className:`h-8 min-w-0 max-w-56 rounded-lg border border-line bg-surface-raised px-2 text-xs font-medium text-ink outline-none focus:border-primary-500`,"aria-label":f(`work.composer.model`,{defaultValue:`Work model`}),children:[e.length===0&&(0,I.jsx)(`option`,{value:``,children:f(`work.composer.noModels`,{defaultValue:`No Work-compatible models`})}),e.map(e=>(0,I.jsx)(`option`,{value:e.key,children:e.label},e.key))]})}),n?(0,I.jsxs)(M,{"data-testid":`work-cancel-button`,variant:`danger`,size:`sm`,loading:r,onClick:()=>void d(),children:[(0,I.jsx)(ee,{className:`h-3.5 w-3.5 fill-current`}),f(`work.composer.cancel`,{defaultValue:`Stop`})]}):(0,I.jsxs)(M,{"data-testid":`work-submit-button`,size:`sm`,loading:r,disabled:i||!p.trim()||!g,onClick:()=>void b(),children:[(0,I.jsx)(le,{className:`h-3.5 w-3.5`}),f(`work.composer.send`,{defaultValue:`Run`})]})]})]}),(0,I.jsx)(`p`,{"data-testid":`work-composer-hint`,className:`mt-1.5 text-center text-[11px] text-ink-subtle`,children:f(`work.composer.hint`,{defaultValue:`Each task keeps its own files and history. Review model output before using it.`})})]})}var R=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},z=e=>{if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}`:`${r}s`},B=e=>{if(!e)return 0;let t=Array.from(e).length,n=e.trim()?e.trim().split(/\s+/u).length:0;return Math.max(n,Math.ceil(t/4))};function we({run:e}){let[t,n]=(0,F.useState)();if((0,F.useEffect)(()=>{if(e.terminal||!e.startedAt)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e.startedAt,e.terminal]),!e.startedAt)return null;let r=e.finishedAt||t;return r?(0,I.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:z(r-e.startedAt)}):null}function V({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,F.useState)(e.status),[i,a]=(0,F.useState)(null),o=(0,F.useMemo)(()=>R(e.arguments),[e.arguments]),s=e.output||null,l=!!(o||s),u=e.status===`error`,d=e.status===`running`,f=(0,F.useId)(),p=u?n(`work.activity.kinds.error`,{defaultValue:`Error`}):d?n(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}):n(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),m=i??(e.status===r?t:e.status===`error`);return(0,I.jsxs)(`div`,{"data-testid":`work-live-tool`,"data-tool-id":e.id,className:j(`overflow-hidden rounded-xl border bg-surface-raised transition-colors`,u?`border-error-500/30`:`border-line`),children:[(0,I.jsxs)(`button`,{type:`button`,disabled:!l,onClick:()=>{a(!m)},"aria-expanded":l?m:void 0,"aria-controls":l?f:void 0,"aria-label":`${p}: ${e.name}`,className:`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-start outline-none hover:bg-surface-subtle focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52] disabled:cursor-default disabled:hover:bg-transparent`,children:[(0,I.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:u?(0,I.jsx)(_,{className:`h-3.5 w-3.5 text-error-500`}):d?(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,I.jsx)(ue,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,I.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-xs text-ink`,children:e.name}),e.durationMs!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:z(e.durationMs)}),l&&(0,I.jsx)(O,{"aria-hidden":`true`,className:j(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,m&&`rotate-180`)})]}),l&&m&&(0,I.jsxs)(`div`,{id:f,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,I.jsx)(`pre`,{dir:`ltr`,className:`max-h-48 overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:o}),s&&(0,I.jsx)(`pre`,{dir:`ltr`,className:j(`max-h-64 overflow-auto whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed`,u?`text-error-600`:`text-ink-muted`),children:s})]})]})}function Te({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,F.useState)(!0);return(0,I.jsxs)(`details`,{"data-testid":`work-live-reasoning`,open:r,onToggle:e=>i(e.currentTarget.open),className:`group mb-3 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,I.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-ink-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(w,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[n(`libreClaw.metrics.provider`,{defaultValue:`Provider`}),` ·`,` `,n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})]})]}),(0,I.jsx)(O,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,I.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,I.jsx)(N,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var Ee=(e,t,n)=>e===`queued`||e===`preparing`?t(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):e===`using_tool`?n?.name?`${t(`work.activity.toolActivity`,{defaultValue:`Tool activity`})} · ${n.name}`:t(`work.activity.toolActivity`,{defaultValue:`Tool activity`}):e===`completed`?t(`work.statusLabels.complete`,{defaultValue:`Complete`}):e===`needs_input`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`failed`?t(`work.statusLabels.error`,{defaultValue:`Error`}):e===`cancelled`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`responding`?t(`work.status.running`,{defaultValue:`Working in the local workspace…`}):t(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),H=(e,t)=>{if(e===`connecting`)return t(`work.live.connecting`,{defaultValue:`Connecting to live updates…`});if(e===`reconnecting`)return t(`work.live.reconnecting`,{defaultValue:`Reconnecting to live updates…`});if(e===`error`)return t(`work.live.unavailable`,{defaultValue:`Live updates unavailable`})};function De({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=H(e.connection,n)||Ee(e.phase,n,r),a=!e.terminal,o=e.usage?.outputTokens,s=e.reasoning+e.response,l=o!==void 0&&o>0?o:s?B(s):o,u=(o===void 0||o===0)&&!!s&&l!==void 0,d=e.usage?.tokensPerSecond;return(0,I.jsxs)(`section`,{"data-testid":`work-live-run`,"data-run-id":e.runId,"data-phase":e.phase,"aria-busy":a||void 0,className:j(`min-w-0`,t===`activity`&&`rounded-2xl border border-line bg-surface p-3 shadow-subtle`),children:[(0,I.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:j(`h-2 w-2 shrink-0 rounded-full`,e.phase===`failed`?`bg-[rgb(255,61,129)]`:e.phase===`completed`?`bg-[rgb(76,212,117)]`:e.phase===`needs_input`||e.phase===`cancelled`?`bg-[rgb(255,204,0)]`:e.connection===`error`?`bg-[rgb(255,61,129)]`:`bg-[rgb(48,121,255)]`,a&&`animate-pulse motion-reduce:animate-none`)}),(0,I.jsx)(`span`,{dir:`auto`,title:e.connectionError,className:`min-w-0 flex-1 truncate font-medium text-ink-muted`,children:i}),e.round!==void 0&&(0,I.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,I.jsx)(we,{run:e})]}),t===`conversation`&&(0,I.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,I.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line bg-surface-raised px-2 py-1 text-[10px] text-ink-muted`,children:[(0,I.jsx)(S,{className:`h-3 w-3 text-[#ff7b52]`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{dir:`auto`,children:n(`work.live.skillsLoaded`,{count:e.skills.length,defaultValue:`Workspace skills · {{count}}`})})]})}),e.reasoning&&(0,I.jsx)(Te,{content:e.reasoning,streaming:a&&e.phase!==`responding`}),e.tools.length>0&&(0,I.jsx)(`div`,{"data-testid":`work-live-tools`,className:j(`mb-3 space-y-1.5`,t===`activity`&&`mb-0`),children:e.tools.map(e=>(0,I.jsx)(V,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),t===`conversation`&&e.response&&(0,I.jsx)(N,{content:e.response,isStreaming:a,className:`text-ink`}),e.error&&(0,I.jsxs)(`div`,{role:`alert`,dir:`auto`,className:`mt-3 flex items-start gap-2 rounded-xl border border-error-500/30 bg-error-500/10 px-3 py-2.5 text-xs leading-relaxed text-error-600`,children:[(0,I.jsx)(_,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{children:e.error})]}),(l!==void 0||d!==void 0)&&(0,I.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-line pt-2 text-[10px] tabular-nums text-ink-subtle`,children:[l!==void 0&&(0,I.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,I.jsxs)(`bdi`,{dir:`ltr`,children:[u&&`≈`,l.toLocaleString()]})]}),d!==void 0&&(0,I.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,I.jsxs)(`bdi`,{dir:`ltr`,children:[d.toFixed(1),` t/s`]})]})]}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,I.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:320ms] motion-reduce:animate-none`})]}),t===`activity`&&e.tools.length===0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,I.jsx)(h,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}var Oe=e=>{if(!e||Object.keys(e).length===0)return null;try{return JSON.stringify(e,null,2)}catch{return null}},ke=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t};function Ae({message:e}){let{t}=c();return(0,I.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-11 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,I.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-ink-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(w,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[t(`libreClaw.metrics.provider`,{defaultValue:`Provider`}),` ·`,` `,t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})]})]}),(0,I.jsx)(O,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,I.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-xs leading-relaxed text-ink-muted`,children:e.content})]})}function U({message:e}){let{t}=c(),n=Oe(e.metadata),r=e.kind===`error`,i={message:t(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:t(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:t(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:t(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind];return(0,I.jsxs)(`div`,{className:j(`rounded-xl border bg-surface-subtle`,r?`border-error-500/30`:`border-line`),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-line px-3 py-2`,children:[r?(0,I.jsx)(_,{className:`h-4 w-4 text-error-500`}):(0,I.jsx)(h,{className:`h-4 w-4 text-ink-muted`}),(0,I.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1 truncate font-mono text-xs font-medium text-ink`,children:ke(e,t(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,I.jsx)(`span`,{className:`rounded-md bg-surface-raised px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-ink-muted rtl:tracking-normal`,children:i})]}),e.content&&(0,I.jsx)(`pre`,{dir:`ltr`,className:`max-h-56 overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-left font-mono text-xs leading-relaxed text-ink-muted`,children:e.content}),n&&(0,I.jsxs)(`details`,{className:`border-t border-line px-3 py-2`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-[11px] font-medium text-ink-muted`,children:t(`work.activity.details`,{defaultValue:`Details`})}),(0,I.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-all text-left font-mono text-[11px] text-ink-muted`,children:n})]})]})}function je({task:e,loading:t,loadingOlder:n,liveRun:r,onLoadOlder:i}){let{t:a}=c(),o=(0,F.useRef)(null),s=(0,F.useRef)(!0),[l,u]=(0,F.useState)(!1),f=(0,F.useMemo)(()=>[...e.messages||[]].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id)),[e.messages]),p=[...f].reverse().find(e=>e.role===`assistant`&&e.kind===`message`)?.id;(0,F.useEffect)(()=>{s.current=!0;let e=o.current;e&&(e.scrollTop=e.scrollHeight);let t=window.requestAnimationFrame(()=>u(!1));return()=>window.cancelAnimationFrame(t)},[e.id]),(0,F.useEffect)(()=>{let e=o.current,t;return e&&s.current?(e.scrollTop=e.scrollHeight,t=window.requestAnimationFrame(()=>u(!1))):e&&r&&(t=window.requestAnimationFrame(()=>u(!0))),()=>{t!==void 0&&window.cancelAnimationFrame(t)}},[r,f,e.status]);let m=async()=>{let e=o.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;s.current=!1;try{await i(),requestAnimationFrame(()=>{let e=o.current;e&&(e.scrollTop=n+e.scrollHeight-t)})}catch{}};return t&&f.length===0?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,I.jsx)(T,{className:`h-6 w-6 animate-spin`})}):(0,I.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,I.jsx)(`div`,{ref:o,onScroll:e=>{let t=e.currentTarget;s.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,s.current&&u(!1)},className:`min-h-0 flex-1 overflow-y-auto`,children:(0,I.jsx)(`div`,{className:`mx-auto flex min-h-full max-w-3xl flex-col px-4 py-6 md:px-6`,children:f.length===0&&!r?(0,I.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,I.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl border border-line bg-surface-raised text-ink-muted`,children:(0,I.jsx)(d,{className:`h-6 w-6`})}),(0,I.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:a(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,I.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-ink-muted`,children:a(`work.conversation.empty`,{defaultValue:`Continue the task below. This conversation and its files stay attached to this workspace.`})})]}):(0,I.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,I.jsx)(`div`,{className:`flex justify-center`,children:(0,I.jsxs)(`button`,{type:`button`,"data-testid":`work-load-older-messages`,disabled:n,onClick:()=>void m(),className:`inline-flex items-center gap-2 rounded-lg border border-line bg-surface-raised px-3 py-1.5 text-xs font-medium text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink disabled:cursor-not-allowed disabled:opacity-60`,children:[n&&(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}),a(`work.conversation.loadOlder`,{defaultValue:`Load older messages`})]})}),f.map(t=>{if(r&&t.runId===r.runId&&t.role!==`user`)return null;if(t.kind===`reasoning`)return(0,I.jsx)(Ae,{message:t},t.id);if(t.role===`tool`||t.kind!==`message`)return(0,I.jsx)(U,{message:t},t.id);let n=t.role===`user`,i=!n&&e.status===`running`&&t.id===p&&t.runId===e.activeRun?.id;return(0,I.jsxs)(`article`,{className:j(`flex gap-3`,n&&`flex-row-reverse`),children:[(0,I.jsx)(`div`,{className:j(`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl`,n?`bg-ink text-ink-inverse`:`border border-line bg-surface-raised text-ink-muted`),children:n?(0,I.jsx)(A,{className:`h-4 w-4`}):(0,I.jsx)(d,{className:`h-4 w-4`})}),(0,I.jsx)(`div`,{className:j(`min-w-0 max-w-[88%]`,n&&`rounded-2xl rounded-se-md bg-ink px-4 py-2.5 text-ink-inverse`),children:n?(0,I.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:t.content}):i?(0,I.jsx)(N,{content:t.content,className:`text-ink`}):(0,I.jsx)(Ce,{content:t.content,className:`text-sm text-ink`})})]},t.id)}),r&&(0,I.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,I.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl border border-line bg-surface-raised text-ink-muted`,children:(0,I.jsx)(d,{className:`h-4 w-4`})}),(0,I.jsx)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:(0,I.jsx)(De,{run:r})})]}),!r&&(e.status===`preparing`||e.status===`running`)&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 ps-11 text-xs text-ink-muted`,children:[(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}),e.status===`preparing`?a(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):a(`work.status.running`,{defaultValue:`Working in the local workspace…`})]})]})})}),l&&(0,I.jsxs)(`button`,{type:`button`,"data-testid":`work-new-activity-button`,onClick:()=>{let e=o.current;e&&(e.scrollTop=e.scrollHeight),s.current=!0,u(!1)},className:`absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-line bg-surface-overlay/95 px-3 py-2 text-xs font-medium text-ink shadow-overlay backdrop-blur transition-colors hover:bg-surface-raised`,children:[(0,I.jsx)(k,{className:`h-3.5 w-3.5`}),a(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var W=45,Me=30,Ne=70,Pe=360,G=480,K=9,q=2,Fe=10,Ie=`libre-webui-work-split:`,Le=(e,t,n)=>Math.min(n,Math.max(t,e)),Re=e=>`${Ie}${encodeURIComponent(e||`local`)}`,ze=e=>{if(typeof window>`u`)return W;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return W;let n=Number(t);return Number.isFinite(n)?Le(n,Me,Ne):W}catch{return W}},Be=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},Ve=e=>{let t=Math.max(0,e-K);if(t===0)return{min:Me,max:Ne};let n=Math.max(Me,Pe/t*100),r=Math.min(Ne,(t-G)/t*100);if(n<=r)return{min:n,max:r};let i=Le(Pe/840*100,Me,Ne);return{min:i,max:i}},J=(e,t)=>Le(e,t.min,t.max);function He({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=xe(o.language),l=Re(n),[u,d]=(0,F.useState)(()=>({storageKey:l,percent:ze(l)})),[f,p]=(0,F.useState)(0),[m,h]=(0,F.useState)(!1),g=(0,F.useRef)(null),_=(0,F.useRef)(null),v=(0,F.useRef)(null),y=(0,F.useRef)(l),b=(0,F.useRef)(u.percent),x=(0,F.useRef)(null),S=u.storageKey===l?u.percent:ze(l),C=(0,F.useMemo)(()=>Ve(f),[f]),w=J(S,C),T=Math.round(w),E=100-T,D=(0,F.useCallback)(e=>{d({storageKey:l,percent:e})},[l]),O=(0,F.useCallback)(e=>{b.current=J(e,Ve(g.current?.getBoundingClientRect().width??0)),x.current===null&&(x.current=window.requestAnimationFrame(()=>{x.current=null,D(b.current)}))},[D]),ee=(0,F.useCallback)(()=>{if(v.current===null&&!m)return;x.current!==null&&(window.cancelAnimationFrame(x.current),x.current=null);let e=g.current?.getBoundingClientRect().width??0,t=J(b.current,Ve(e));b.current=t,D(t),Be(y.current,t);let n=v.current;v.current=null,n!==null&&_.current?.hasPointerCapture(n)&&_.current.releasePointerCapture(n),h(!1)},[m,D]),k=(0,F.useCallback)(e=>{let t=g.current?.getBoundingClientRect();if(!t)return b.current;let n=Math.max(1,t.width-K);return((s?t.right-e:e-t.left)-K/2)/n*100},[s]),te=e=>{e.button!==0||!e.isPrimary||(e.preventDefault(),e.stopPropagation(),v.current=e.pointerId,y.current=l,b.current=w,e.currentTarget.setPointerCapture(e.pointerId),h(!0))},ne=(0,F.useCallback)(e=>{let t=J(e,C);b.current=t,D(t),Be(l,t)},[C,D,l]),re=(0,F.useCallback)(()=>{ne(W)},[ne]),A=e=>{let t=e.shiftKey?Fe:q,n=null;e.key===`ArrowLeft`?n=w+(s?t:-t):e.key===`ArrowRight`?n=w+(s?-t:t):e.key===`Home`?n=C.min:e.key===`End`?n=C.max:e.key===`Enter`&&(n=W),n!==null&&(e.preventDefault(),ne(n))};(0,F.useEffect)(()=>{let e=g.current;if(!e)return;if(typeof ResizeObserver>`u`){let t=()=>p(e.getBoundingClientRect().width);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}let t=new ResizeObserver(e=>{let t=e[0];t&&p(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]),(0,F.useEffect)(()=>{if(!m)return;let e=document.body.style.cursor,t=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let n=e=>{e.pointerId===v.current&&(e.preventDefault(),O(k(e.clientX)))},r=e=>{e.pointerId===v.current&&ee()};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),window.addEventListener(`blur`,ee),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`blur`,ee),document.body.style.cursor=e,document.body.style.userSelect=t}},[ee,m,k,O]),(0,F.useEffect)(()=>()=>{x.current!==null&&window.cancelAnimationFrame(x.current),v.current!==null&&Be(y.current,b.current)},[]);let ie={gridTemplateColumns:`minmax(0, ${w}fr) ${K}px minmax(0, ${100-w}fr)`};return(0,I.jsxs)(`div`,{ref:g,"data-testid":`work-split-pane`,"data-split-percent":w.toFixed(2),"data-resizing":m?`true`:`false`,className:j(`relative flex min-h-0 min-w-0 flex-1 overflow-hidden xl:grid`,i),style:ie,children:[(0,I.jsx)(`section`,{id:`work-conversation-panel`,"data-testid":`work-conversation-panel`,className:j(`min-h-0 min-w-0 flex-1 flex-col bg-surface xl:flex`,r===`conversation`?`flex`:`hidden`),children:e}),(0,I.jsxs)(`div`,{ref:_,role:`separator`,"aria-orientation":`vertical`,"aria-controls":`work-conversation-panel work-workspace-panel`,"aria-label":a(`work.workspace.resize`,{defaultValue:`Resize conversation and workspace`}),"aria-valuemin":Math.round(C.min),"aria-valuemax":Math.round(C.max),"aria-valuenow":T,"aria-valuetext":a(`work.workspace.splitSize`,{conversation:T,workspace:E,defaultValue:`Conversation {{conversation}}%, workspace {{workspace}}%`}),title:a(`work.workspace.resizeHint`,{defaultValue:`Drag to resize. Use arrow keys for precise control. Double-click or press Enter to reset.`}),tabIndex:0,"data-testid":`work-split-resizer`,onPointerDown:te,onDoubleClick:re,onKeyDown:A,className:j(`group relative z-40 hidden h-full cursor-col-resize touch-none select-none items-center justify-center outline-none xl:flex`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52]`),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,className:j(`pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-line transition-colors`,`group-hover:bg-[#ff7b52] group-focus-visible:bg-[#ff7b52]`,m&&`bg-[#ff7b52]`)}),(0,I.jsx)(`span`,{"aria-hidden":`true`,className:j(`pointer-events-none relative h-14 w-1 rounded-full bg-ink-subtle/50 opacity-60 transition-[height,background-color,opacity]`,`group-hover:h-20 group-hover:bg-[#ff7b52] group-hover:opacity-100`,`group-focus-visible:h-20 group-focus-visible:bg-[#ff7b52] group-focus-visible:opacity-100`,m&&`h-20 bg-[#ff7b52] opacity-100`)})]}),(0,I.jsx)(`section`,{id:`work-workspace-panel`,"data-testid":`work-workspace-panel`,className:j(`min-h-0 min-w-0 flex-1 flex-col bg-surface-raised xl:flex`,r===`workspace`?`flex`:`hidden`),children:t}),m&&(0,I.jsx)(`div`,{"data-testid":`work-split-drag-shield`,"aria-hidden":`true`,className:`absolute inset-0 z-30 hidden cursor-col-resize select-none xl:block`})]})}var Ue=1e5,We=4e3,Ge={bash:`bash`,c:`c`,cc:`cpp`,cjs:`javascript`,cpp:`cpp`,cs:`csharp`,csh:`bash`,css:`css`,cts:`typescript`,cxx:`cpp`,diff:`diff`,go:`go`,h:`c`,hpp:`cpp`,htm:`markup`,html:`markup`,java:`java`,js:`javascript`,json:`json`,json5:`json`,jsonc:`json`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`css`,md:`markdown`,mdx:`markdown`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,py:`python`,rb:`ruby`,rs:`rust`,scss:`css`,sh:`bash`,sql:`sql`,svg:`markup`,swift:`swift`,ts:`typescript`,tsx:`tsx`,xml:`markup`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},Y={".bashrc":`bash`,".zshrc":`bash`},Ke={cjs:{family:`babel`,parser:`babel`},css:{family:`postcss`,parser:`css`},cts:{family:`typescript`,parser:`typescript`},htm:{family:`html`,parser:`html`},html:{family:`html`,parser:`html`},js:{family:`babel`,parser:`babel`},json:{family:`babel`,parser:`json`},json5:{family:`babel`,parser:`json5`},jsonc:{family:`babel`,parser:`json`},jsx:{family:`babel`,parser:`babel`},less:{family:`postcss`,parser:`less`},md:{family:`markdown`,parser:`markdown`},mdx:{family:`markdown`,parser:`mdx`},mjs:{family:`babel`,parser:`babel`},mts:{family:`typescript`,parser:`typescript`},scss:{family:`postcss`,parser:`scss`},ts:{family:`typescript`,parser:`typescript`},tsx:{family:`typescript`,parser:`typescript`},yaml:{family:`yaml`,parser:`yaml`},yml:{family:`yaml`,parser:`yaml`}},X=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,qe=e=>{let t=X(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},Je=e=>Y[X(e)]??Ge[qe(e)]??`text`,Ye=e=>Ke[qe(e)],Xe=e=>Ye(e)!==void 0,Ze=e=>{if(e.length>1e5)return!1;let t=1;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10&&(t+=1,t>4e3))return!1;return!0},Z=async e=>(await e).default,Qe=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),Z(a(()=>import(`./estree-DPzMpjFm.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))]);case`typescript`:return Promise.all([Z(a(()=>import(`./typescript-B6y_hxBm.js`),__vite__mapDeps([16,1,2,3,5,6,7,8,9,10,11,12,13,14,15]))),Z(a(()=>import(`./estree-DPzMpjFm.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))]);case`postcss`:return[await Z(a(()=>import(`./postcss-DSDkwgFE.js`),__vite__mapDeps([17,1,2,3])))];case`html`:{let e=[await Z(a(()=>import(`./html-R50jmBYq.js`),__vite__mapDeps([18,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))];return/<script\b/i.test(t)&&e.push(await Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),await Z(a(()=>import(`./estree-DPzMpjFm.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))),/<script\b[^>]*\blang\s*=\s*["']?(?:ts|typescript)/i.test(t)&&e.push(await Z(a(()=>import(`./typescript-B6y_hxBm.js`),__vite__mapDeps([16,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))),/<style\b/i.test(t)&&e.push(await Z(a(()=>import(`./postcss-DSDkwgFE.js`),__vite__mapDeps([17,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await Z(a(()=>import(`./markdown-C08x2H-K.js`),__vite__mapDeps([19,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))],r=e=>RegExp(`^(?: {0,3})(?:\`{3,}|~{3,})\\s*(?:${e})(?:\\s|$)`,`im`).test(t);return e.parser===`mdx`&&n.push(await Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),await Z(a(()=>import(`./estree-DPzMpjFm.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))),r(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),await Z(a(()=>import(`./estree-DPzMpjFm.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))),r(`ts|tsx|typescript`)&&n.push(await Z(a(()=>import(`./typescript-B6y_hxBm.js`),__vite__mapDeps([16,1,2,3,5,6,7,8,9,10,11,12,13,14,15]))),await Z(a(()=>import(`./estree-DPzMpjFm.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15])))),r(`css|scss|less`)&&n.push(await Z(a(()=>import(`./postcss-DSDkwgFE.js`),__vite__mapDeps([17,1,2,3])))),r(`html`)&&n.push(await Z(a(()=>import(`./html-R50jmBYq.js`),__vite__mapDeps([18,1,2,3,5,6,7,8,9,10,11,12,13,14,15]))),await Z(a(()=>import(`./babel-BnLuavNv.js`),__vite__mapDeps([0,1,2,3]))),await Z(a(()=>import(`./estree-DPzMpjFm.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15]))),await Z(a(()=>import(`./typescript-B6y_hxBm.js`),__vite__mapDeps([16,1,2,3,5,6,7,8,9,10,11,12,13,14,15]))),await Z(a(()=>import(`./postcss-DSDkwgFE.js`),__vite__mapDeps([17,1,2,3])))),r(`yaml|yml`)&&n.push(await Z(a(()=>import(`./yaml-mLy9chOK.js`),__vite__mapDeps([20,1,2,3])))),[...new Set(n)]}case`yaml`:return[await Z(a(()=>import(`./yaml-mLy9chOK.js`),__vite__mapDeps([20,1,2,3])))]}},$e=async(e,t)=>{let n=Ye(e);if(!n)throw Error(`Formatting is not supported for “${X(e)||e}”.`);if(!Ze(t))throw Error(`Could not format “${X(e)||e}”: files are limited to ${Ue.toLocaleString()} characters and ${We.toLocaleString()} lines.`);try{let[{format:e},r]=await Promise.all([a(()=>import(`./standalone-DpMZUvjd.js`),__vite__mapDeps([21,1,2,3,5,6,7,8,9,10,11,12,13,14,15])),Qe(n,t)]);return await e(t,{parser:n.parser,plugins:r,tabWidth:2,useTabs:!1})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not format “${X(e)||e}”: ${n}`)}},et=(0,F.lazy)(async()=>({default:(await a(()=>import(`./OptimizedSyntaxHighlighter-Ci9sRc78.js`).then(e=>e.n),__vite__mapDeps([22,2,3,23]))).OptimizedSyntaxHighlighter})),tt=8e3,nt=400,rt=500;function it({path:e,value:t,ariaLabel:n,disabled:r=!1,onChange:i,onSaveShortcut:a,onFormatShortcut:o}){let{t:s}=c(),l=he(e=>e.theme.mode===`dark`),u=(0,F.useRef)(null),d=(0,F.useRef)(null),[f,p]=(0,F.useState)(``),m=(0,F.useMemo)(()=>Je(e),[e]),h=(0,F.useMemo)(()=>{if(t.length>tt)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>nt));n+=1);return e},[t]),g=t.length>tt||h>nt,_=m!==`text`&&!g,v=_&&f===t;return(0,F.useEffect)(()=>{if(!_)return;let e=window.setTimeout(()=>p(t),rt);return()=>window.clearTimeout(e)},[_,e,t]),(0,F.useLayoutEffect)(()=>{!v||!u.current||!d.current||(u.current.style.transform=`translate3d(${-d.current.scrollLeft}px, ${-d.current.scrollTop}px, 0)`)},[v,e]),(0,I.jsxs)(`div`,{dir:`ltr`,className:j(`relative min-h-0 flex-1 overflow-hidden bg-surface focus-within:ring-1 focus-within:ring-inset focus-within:ring-primary-500/60`,r&&`opacity-60`),"data-language":m,"data-highlighted":v?`true`:`false`,children:[v&&(0,I.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,I.jsx)(`div`,{ref:u,"data-testid":`work-file-highlight-content`,className:`min-h-full min-w-full origin-top-left will-change-transform`,children:(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(`pre`,{className:`m-0 min-h-full min-w-full whitespace-pre p-4 text-left font-mono text-[12px] leading-5 text-ink`,children:t||``}),children:(0,I.jsx)(et,{language:m,isDark:l,backgroundColor:`transparent`,borderRadius:0,customStyle:{margin:0,minHeight:`100%`,minWidth:`100%`,width:`max-content`,overflow:`visible`,padding:`1rem`,fontSize:`12px`,lineHeight:`20px`,tabSize:2,whiteSpace:`pre`},children:f||``})})})}),(0,I.jsx)(`textarea`,{ref:d,"data-testid":`work-file-editor`,"data-language":m,"aria-label":n,value:t,onChange:e=>i(e.target.value),onScroll:e=>{u.current&&(u.current.style.transform=`translate3d(${-e.currentTarget.scrollLeft}px, ${-e.currentTarget.scrollTop}px, 0)`)},onKeyDown:e=>{let t=e.key.toLowerCase();if((e.metaKey||e.ctrlKey)&&t===`s`){e.preventDefault(),a();return}e.altKey&&e.shiftKey&&t===`f`&&(e.preventDefault(),o())},disabled:r,spellCheck:!1,wrap:`off`,className:j(`absolute inset-0 z-10 h-full w-full resize-none overflow-auto whitespace-pre border-0 bg-transparent p-4 text-left font-mono text-[12px] leading-5 outline-none selection:bg-primary-500/25 disabled:cursor-not-allowed`,v?`text-transparent caret-ink`:`text-ink`),style:v?{WebkitTextFillColor:`transparent`,caretColor:`rgb(var(--color-ink))`,tabSize:2}:{tabSize:2}}),g&&(0,I.jsx)(`span`,{dir:`auto`,className:`pointer-events-none absolute bottom-2 end-3 z-20 rounded-md border border-line bg-surface-overlay/90 px-2 py-1 text-[10px] text-ink-muted shadow-subtle`,title:s(`work.files.highlightPaused`,{defaultValue:`Live highlighting is paused for large files to keep editing responsive.`}),children:s(`work.files.plainTextLarge`,{defaultValue:`Plain text · large file`})})]})}var at=e=>{if(!e)return null;try{let t=new URL(e);return(t.hostname===`localhost`||t.hostname===`127.0.0.1`||t.hostname===`[::1]`)&&(t.protocol===`http:`||t.protocol===`https:`)?t.toString():null}catch{return null}},ot=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),t.join(`/`)},st=(e,t)=>{let n=e.metadata?.name??e.metadata?.toolName??e.metadata?.tool??e.metadata?.command;return typeof n==`string`&&n?n:t};function ct({task:e,liveRun:t,files:n,selectedFile:r,loadingFiles:i,actionLoading:a,onLoadFiles:o,onLoadFile:s,onClearSelectedFile:d,onSaveFile:f,onStartPreview:p,onStopPreview:m,onDirtyChange:g}){let{t:_,i18n:S}=c(),w=xe(S.language),[D,O]=(0,F.useState)(`files`),[k,ne]=(0,F.useState)(``),[A,ie]=(0,F.useState)(``),[ae,ce]=(0,F.useState)(),[le,ue]=(0,F.useState)(``),[de,fe]=(0,F.useState)(!1),pe=at(e.previewUrl),he=t?.runId,ge=t?.error,ye=t?.tools,be=(0,F.useMemo)(()=>{let t=new Set(ye?.map(e=>e.id)||[]);return(e.messages||[]).filter(e=>{if(e.kind===`reasoning`||e.role!==`tool`&&e.kind===`message`)return!1;if(!he||e.runId!==he)return!0;if(e.kind===`error`&&ge)return!1;let n=e.metadata?.toolCallId;return typeof n!=`string`||!t.has(n)})},[ge,he,ye,e.messages]),Se=be.length+(ye?.length||0),N=!!r&&A!==(r?.content??``),P=e.status===`preparing`||e.status===`running`,Ce=(0,F.useRef)(P),L=(0,F.useRef)(0),R=(0,F.useRef)(A),z=(0,F.useRef)(ae),B=(0,F.useRef)(r),we=(0,F.useRef)(e.id),V=(0,F.useRef)(o),Te=(0,F.useRef)(s),Ee=(0,F.useRef)(g),H=(0,F.useRef)(!0),Oe=r?Xe(r.path):!1,ke=!r||Ze(A),Ae=Oe&&ke;(0,F.useEffect)(()=>{R.current=A,z.current=ae,B.current=r,we.current=e.id,Ee.current=g},[ae,A,g,r,e.id]),(0,F.useEffect)(()=>{V.current=o,Te.current=s},[s,o]),(0,F.useEffect)(()=>(H.current=!0,()=>{H.current=!1,L.current+=1,Ee.current(!1)}),[]),(0,F.useEffect)(()=>{if(Ce.current&&!P&&(V.current(k),r&&!N)){let e=++L.current,t=r.path,n=R.current,i=z.current;Te.current(t).then(r=>{!H.current||e!==L.current||r.path!==t||R.current!==n||z.current!==i||(R.current=r.content,z.current=r.updatedAt??r.modifiedAt,ie(r.content),ce(r.updatedAt??r.modifiedAt))}).catch(()=>void 0)}Ce.current=P},[k,N,r,P]);let U=()=>!N||window.confirm(_(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),je=()=>{r&&me(e.id,r.path)},W=async e=>{U()&&(L.current+=1,je(),d(),g(!1),ne(e),await o(e).catch(()=>void 0))},Me=async t=>{if(!U())return;let n=++L.current;je();let r=await s(t).catch(()=>void 0);if(!H.current||!r||n!==L.current)return;let i=_e(e.id,r.path),a=i?.content??r.content,o=i?.baseUpdatedAt??r.updatedAt??r.modifiedAt;R.current=a,z.current=o,ie(a),ce(o),g(i!==null&&i.content!==r.content)},Ne=()=>{U()&&(L.current+=1,je(),d(),g(!1))},Pe=t=>{r&&(R.current=t,ie(t),t===r.content?me(e.id,r.path):ve(e.id,r.path,{content:t,baseUpdatedAt:ae??r.updatedAt??r.modifiedAt}),g(t!==r.content))},G=async()=>{if(!r)return;let t=e.id,n=r.path,i=A,a=L.current,o=await f(n,i,ae).catch(()=>!1);if(!H.current||o===!1||a!==L.current||we.current!==t||B.current?.path!==n)return;let s=o.updatedAt??o.modifiedAt;z.current=s,ce(s);let c=R.current;if(c===i){me(t,n),g(!1);return}ve(t,n,{content:c,baseUpdatedAt:s}),g(!0)},K=async()=>{if(!r||P||de||!Ae)return;fe(!0);let e=L.current,t=r.path,n=R.current;try{let r=await $e(t,n);if(!H.current||e!==L.current||B.current?.path!==t||R.current!==n)return;Pe(r),E.success(_(`work.files.formatted`,{defaultValue:`Code formatted.`}))}catch(r){if(!H.current||e!==L.current||B.current?.path!==t||R.current!==n)return;E.error(r instanceof Error?r.message:_(`work.files.formatFailed`,{defaultValue:`Could not format this file.`}))}finally{H.current&&fe(!1)}},q=[{id:`files`,label:_(`work.workspace.files`,{defaultValue:`Files`}),icon:re,testId:`work-files-tab`},{id:`activity`,label:_(`work.workspace.activity`,{defaultValue:`Activity`}),icon:y,testId:`work-activity-tab`},{id:`preview`,label:_(`work.workspace.preview`,{defaultValue:`Preview`}),icon:v,testId:`work-preview-tab`}],Fe=(e,t)=>{let n=null;if(e.key===`ArrowRight`&&(n=(t+(w?-1:1)+q.length)%q.length),e.key===`ArrowLeft`&&(n=(t+(w?1:-1)+q.length)%q.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=q.length-1),n===null)return;e.preventDefault();let r=q[n];O(r.id),e.currentTarget.parentElement?.querySelector(`#work-workspace-tab-${r.id}`)?.focus()};return(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-surface-raised`,children:[(0,I.jsxs)(`div`,{"data-testid":`work-workspace-toolbar`,className:`flex h-12 shrink-0 items-center gap-2 border-b border-line bg-surface-raised px-2`,children:[(0,I.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,"aria-label":_(`work.workspace.label`,{defaultValue:`Workspace views`}),className:`flex shrink-0 items-center rounded-xl border border-line bg-surface-subtle p-0.5`,children:q.map((e,t)=>{let n=e.icon;return(0,I.jsxs)(`button`,{type:`button`,role:`tab`,id:`work-workspace-tab-${e.id}`,"aria-selected":D===e.id,"aria-controls":D===e.id?`work-workspace-panel-${e.id}`:void 0,"aria-label":e.label,tabIndex:D===e.id?0:-1,title:e.label,"data-testid":e.testId,onClick:()=>O(e.id),onKeyDown:e=>Fe(e,t),className:j(`flex h-7 items-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow]`,D===e.id?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:text-ink`),children:[(0,I.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`hidden xs:inline`,children:e.label}),e.id===`activity`&&Se>0&&(0,I.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-[10px] text-ink-muted`,children:Se})]},e.id)})}),D===`files`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[r&&(0,I.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink sm:hidden`,onClick:Ne,"aria-label":_(`work.files.back`,{defaultValue:`Back to files`}),children:(0,I.jsx)(l,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,I.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,title:r?.path??`/workspace${k?`/${k}`:``}`,children:[r?.path??`/workspace${k?`/${k}`:``}`,N&&` •`]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:!k,onClick:()=>void W(ot(k)),className:j(`hidden h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink disabled:opacity-30 sm:inline-flex`,!r&&`inline-flex`),"aria-label":_(`work.files.up`,{defaultValue:`Parent folder`}),title:_(`work.files.up`,{defaultValue:`Parent folder`}),children:(0,I.jsx)(l,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,I.jsx)(`button`,{type:`button`,"data-testid":`work-refresh-files-button`,onClick:()=>void o(k).catch(()=>void 0),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink`,"aria-label":_(`common.refresh`,{defaultValue:`Refresh`}),title:_(`common.refresh`,{defaultValue:`Refresh`}),children:(0,I.jsx)(C,{className:j(`h-3.5 w-3.5`,i&&`animate-spin`)})}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(M,{"data-testid":`work-format-file-button`,size:`sm`,variant:`ghost`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:P||de||!Ae,onClick:()=>void K(),"aria-busy":de||void 0,title:Ae?_(`work.files.formatShortcut`,{defaultValue:`Format (Shift+Alt+F)`}):Oe?_(`work.files.formatTooLarge`,{defaultValue:`Formatting is limited to files under 100,000 characters and 4,000 lines.`}):_(`work.files.formatUnsupported`,{defaultValue:`Formatting is not available for this file type.`}),"aria-label":_(`work.files.format`,{defaultValue:`Format file`}),children:[de?(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(x,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{className:`hidden 2xl:inline`,children:_(`work.files.format`,{defaultValue:`Format`})})]}),(0,I.jsxs)(M,{"data-testid":`work-save-file-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:!N||P||de||a,onClick:()=>void G(),"aria-busy":a||void 0,title:_(`work.files.saveShortcut`,{defaultValue:`Save (⌘/Ctrl+S)`}),"aria-label":_(`common.save`),children:[a?(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(u,{className:`h-3.5 w-3.5`}),(0,I.jsx)(`span`,{className:`hidden 2xl:inline`,children:_(`common.save`)})]})]})]})]}),D===`activity`&&(0,I.jsx)(`div`,{className:`min-w-0 flex-1`}),D===`preview`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{dir:`auto`,value:le,onChange:e=>ue(e.target.value),placeholder:_(`work.preview.command`,{defaultValue:`Optional start command`}),"aria-label":_(`work.preview.command`,{defaultValue:`Optional start command`}),className:`h-8 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2.5 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.previewStatus===`running`||e.previewStatus===`starting`?(0,I.jsxs)(M,{"data-testid":`work-stop-preview-button`,variant:`danger`,size:`sm`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void m(),"aria-busy":a||void 0,"aria-label":_(`work.preview.stop`,{defaultValue:`Stop preview`}),children:[a?(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(ee,{className:`h-3.5 w-3.5 fill-current`}),(0,I.jsx)(`span`,{className:`hidden 2xl:inline`,children:_(`work.preview.stop`,{defaultValue:`Stop preview`})})]}):(0,I.jsxs)(M,{"data-testid":`work-start-preview-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void p(le.trim()||void 0),"aria-busy":a||void 0,"aria-label":_(`work.preview.start`,{defaultValue:`Start preview`}),children:[a?(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}):(0,I.jsx)(b,{className:`h-3.5 w-3.5 fill-current`}),(0,I.jsx)(`span`,{className:`hidden 2xl:inline`,children:_(`work.preview.start`,{defaultValue:`Start preview`})})]}),pe&&(0,I.jsx)(`a`,{href:pe,target:`_blank`,rel:`noopener noreferrer`,"aria-label":_(`work.preview.open`,{defaultValue:`Open`}),title:_(`work.preview.open`,{defaultValue:`Open`}),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`,children:(0,I.jsx)(te,{className:`h-3.5 w-3.5`})})]})]})]}),D===`files`&&(0,I.jsxs)(`div`,{id:`work-workspace-panel-files`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-files`,className:`flex min-h-0 flex-1`,children:[(0,I.jsx)(`div`,{className:j(`flex min-h-0 w-full flex-col border-e border-line bg-surface-raised`,r?`hidden sm:flex sm:w-52 xl:w-60`:`flex`),children:(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:i&&n.length===0?(0,I.jsx)(`div`,{className:`flex justify-center py-8 text-ink-muted`,children:(0,I.jsx)(T,{className:`h-5 w-5 animate-spin`})}):n.length===0?(0,I.jsx)(`p`,{className:`px-3 py-8 text-center text-xs text-ink-muted`,children:_(`work.files.empty`,{defaultValue:`No files in this folder yet.`})}):[...n].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1).map(e=>(0,I.jsxs)(`button`,{type:`button`,"data-testid":`work-file-item`,"data-path":e.path,onClick:()=>{e.type===`directory`?W(e.path):Me(e.path)},className:j(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-xs hover:bg-surface-subtle`,r?.path===e.path?`bg-surface-subtle text-ink`:`text-ink-muted`),children:[e.type===`directory`?(0,I.jsx)(se,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}):(0,I.jsx)(oe,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{dir:`auto`,className:`truncate`,children:e.name})]},e.path))})}),(0,I.jsx)(`div`,{className:j(`min-h-0 min-w-0 flex-1 flex-col`,r?`flex`:`hidden sm:flex`),children:r?(0,I.jsx)(it,{path:r.path,value:A,ariaLabel:_(`work.files.editorLabel`,{path:r.path,defaultValue:`File editor: {{path}}`}),onChange:Pe,onSaveShortcut:()=>{N&&!P&&!a&&!de&&G()},onFormatShortcut:()=>void K(),disabled:P||de}):(0,I.jsxs)(`div`,{className:`m-auto px-6 text-center text-xs text-ink-muted`,children:[(0,I.jsx)(oe,{className:`mx-auto mb-3 h-7 w-7 text-ink-subtle`}),_(`work.files.select`,{defaultValue:`Select a file to inspect and edit it.`})]})})]}),D===`activity`&&(0,I.jsxs)(`div`,{id:`work-workspace-panel-activity`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-activity`,className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[t&&(0,I.jsx)(`div`,{className:`mb-3`,children:(0,I.jsx)(De,{run:t,variant:`activity`})}),be.length===0&&!t?(0,I.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center text-xs text-ink-muted`,children:[(0,I.jsx)(h,{className:`mb-3 h-7 w-7 text-ink-subtle`}),_(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]}):(0,I.jsx)(`div`,{className:`space-y-2`,children:be.map(e=>(0,I.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{dir:`auto`,className:`truncate font-mono text-xs font-medium text-ink`,children:st(e,_(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,I.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-ink-subtle rtl:tracking-normal`,children:{message:_(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:_(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:_(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:_(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:_(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind]})]}),e.content&&(0,I.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap break-words text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:e.content})]},e.id))})]}),D===`preview`&&(0,I.jsx)(`div`,{id:`work-workspace-panel-preview`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-preview`,className:`flex min-h-0 flex-1 flex-col`,children:e.previewStatus===`starting`?(0,I.jsxs)(`div`,{className:`m-auto flex items-center gap-2 text-xs text-ink-muted`,children:[(0,I.jsx)(T,{className:`h-4 w-4 animate-spin`}),_(`work.preview.starting`,{defaultValue:`Starting preview…`})]}):pe&&e.previewStatus===`running`?(0,I.jsx)(`iframe`,{"data-testid":`work-preview-frame`,title:_(`work.preview.frameTitle`,{defaultValue:`Workspace preview`}),src:pe,sandbox:`allow-scripts allow-forms allow-modals allow-downloads`,referrerPolicy:`no-referrer`,className:`min-h-0 flex-1 border-0 bg-white`}):(0,I.jsxs)(`div`,{className:`m-auto max-w-sm px-6 text-center text-xs leading-relaxed text-ink-muted`,children:[(0,I.jsx)(v,{className:`mx-auto mb-3 h-8 w-8 text-ink-subtle`}),e.previewStatus===`failed`?_(`work.preview.failed`,{defaultValue:`The preview could not start. Check Activity, then try another command.`}):_(`work.preview.empty`,{defaultValue:`Start the app inside this workspace to inspect it here.`})]})})]})}var lt=e=>e.status===`preparing`||e.status===`running`,ut=e=>{let t=encodeURIComponent(e.model);return e.providerType===`plugin`?`plugin:${encodeURIComponent(e.providerId||``)}:${t}`:`ollama:${t}`},dt=e=>{let t=e.trim().toLowerCase();return!!t&&!t.includes(`embed`)},ft=(e,t)=>e instanceof Error&&e.message?e.message:t,pt=(e,t)=>new Promise(n=>{if(t.aborted){n();return}let r,i=()=>{r!==void 0&&window.clearTimeout(r),t.removeEventListener(`abort`,i),n()};r=window.setTimeout(i,e),t.addEventListener(`abort`,i,{once:!0})});function Q(){let{t:e}=c(),t=s(),n=r(),{taskId:a}=i(),l=he(e=>e.preferences),u=he(e=>e.setPreferences),d=ye(e=>e.user?.id??null),[h,y]=(0,F.useState)(!1),b=ge(e=>e.models),x=ge(e=>e.selectedModel),{capabilities:S,tasks:C,selectedTask:w,files:T,selectedFile:O,liveRuns:ee,loadingTask:k,loadingOlderMessages:te,loadingFiles:ne,actionLoading:re,error:A,loadCapabilities:oe,loadTasks:se,selectTask:le,loadTask:ue,loadOlderMessages:M,createTask:_e,updateTask:ve,deleteTask:xe,startRun:N,cancelRun:Ce,beginLiveRun:R,applyRunEvents:z,setLiveRunConnection:B,clearLiveRun:we,loadFiles:V,loadFile:Te,clearSelectedFile:Ee,saveFile:H,startPreview:De,stopPreview:Oe,clearError:ke}=be(),Ae=(0,F.useMemo)(()=>b.filter(e=>!e.isPersona&&dt(e.name)),[b]),U=(0,F.useMemo)(()=>Ae.flatMap(e=>{if(e.isPlugin&&!e.pluginId)return[];let t=e.isPlugin?`plugin`:`ollama`,n=e.isPlugin?e.pluginId:void 0,r=e.name.trim().toLowerCase(),i={model:e.name,providerType:t,providerId:n};return[{...i,key:ut(i),label:e.isPlugin&&e.pluginName?`${e.name} · ${e.pluginName}`:e.name,remote:e.isPlugin||r.endsWith(`:cloud`)||r.endsWith(`-cloud`)}]}),[Ae]),[W,Me]=(0,F.useState)(``),[Ne,Pe]=(0,F.useState)({locationKey:t.key,value:`conversation`}),G=Ne.locationKey===t.key?Ne.value:`conversation`,K=e=>Pe({locationKey:t.key,value:e}),[q,Fe]=(0,F.useState)(!1),[Ie,Le]=(0,F.useState)({taskId:null,open:!1}),Re=Ie.open&&Ie.taskId===w?.id,ze=(0,F.useRef)(null),Be=(0,F.useRef)(null),Ve=(0,F.useRef)(null),J=(0,F.useCallback)((e=!1)=>{Le(e=>({...e,open:!1})),e&&window.requestAnimationFrame(()=>Be.current?.focus())},[]);(0,F.useEffect)(()=>{if(!Re)return;let e=window.requestAnimationFrame(()=>{Ve.current?.querySelector(`[role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!ze.current?.contains(e.target)&&J()},n=e=>{e.key===`Escape`&&(e.preventDefault(),J(!0))};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[J,Re]);let Ue=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),J(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=[...Ve.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]];if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowUp`?(n-1+t.length)%t.length:(n+1)%t.length]?.focus()};(0,F.useEffect)(()=>{oe(),se()},[oe,se]),(0,F.useEffect)(()=>{if(!a){le(null);return}le(a),ue(a).catch(()=>void 0),V(a,``).catch(()=>void 0)},[a,V,ue,le]);let We=U.find(e=>e.key===W)||U.find(e=>e.providerType===`ollama`&&e.model===x)||U[0],Ge=a?C.find(e=>e.id===a):void 0,Y=Ge?.status??w?.status,Ke=w?.activeRun??Ge?.activeRun??null,X=Ke?.id,qe=Ke?.status===`queued`||Ke?.status===`preparing`||Ke?.status===`running`,Je=a&&ee[a]?.runId===X?ee[a]:void 0,Ye=Y===`preparing`||Y===`running`?1e3:4e3;(0,F.useEffect)(()=>{let e,t=!1,n=async()=>{await se(!0),t||(e=setTimeout(n,Ye))};return e=setTimeout(n,Ye),()=>{t=!0,e&&clearTimeout(e)}},[se,Ye]);let Xe=(0,F.useRef)(null);(0,F.useEffect)(()=>{if(!a||!Y){Xe.current=null;return}let e=Xe.current;Xe.current={taskId:a,status:Y},e?.taskId===a&&(e.status===`preparing`||e.status===`running`)&&Y!==`preparing`&&Y!==`running`&&(ue(a,!0).catch(()=>void 0),V(a,``).catch(()=>void 0))},[V,ue,Y,a]),(0,F.useEffect)(()=>{if(!a||!X||!qe)return;let e=new AbortController,t=!1,n=0,r=be.getState().liveRuns[a]?.runId===X&&be.getState().liveRuns[a]?.lastEventId||0,i=!1,o=[],s=null,c=()=>{if(s!==null&&(window.cancelAnimationFrame(s),s=null),o.length===0)return;let e=o;o=[],z(e)},l=e=>{if(e.type!==`snapshot`&&(n=0),r=Math.max(r,e.id),o.push(e),e.type===`done`||e.type===`error`&&e.data.terminal!==!1){i=!0,c();return}s===null&&(s=window.requestAnimationFrame(c))};return R(a,X,Ke?.startedAt||void 0),(async()=>{for(;!t&&!e.signal.aborted&&!i;){B(a,X,n>=3?`error`:n===0?`connecting`:`reconnecting`);let o=Date.now();try{if(await fe.streamRunEvents({taskId:a,runId:X,after:r,signal:e.signal,onEvent:l}),c(),i||t||e.signal.aborted)break;throw Error(`The live Work connection closed.`)}catch(r){if(c(),t||e.signal.aborted)return;Date.now()-o>=5e3&&(n=0),n+=1,B(a,X,n>=3?`error`:`reconnecting`,n>=3?ft(r,`Live updates are reconnecting in the background.`):void 0),await pt(Math.min(4e3,250*2**Math.min(n,4)),e.signal)}}if(c(),!(!i||e.signal.aborted)){B(a,X,`closed`);try{await Promise.all([ue(a,!0),V(a,``),se(!0)])}catch{}finally{we(a,X)}}})(),()=>{t=!0,e.abort(),c()}},[z,R,we,V,ue,se,Ke?.startedAt,qe,X,B,a]),(0,F.useEffect)(()=>{if(!q)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[q]);let Ze=(0,F.useCallback)(()=>!q||window.confirm(e(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),[e,q]),Z=(0,F.useCallback)(()=>!q||window.confirm(e(`work.files.leaveWithDraft`,{defaultValue:`Leave this file? Your unsaved edit will remain as a browser draft.`})),[e,q]),Qe=()=>{w&&O&&me(w.id,O.path)},$e=o(({currentLocation:e,nextLocation:t})=>{let n=t.state;return q&&n?.deletedWorkTaskId!==a&&`${e.pathname}${e.search}${e.hash}`!=`${t.pathname}${t.search}${t.hash}`});(0,F.useEffect)(()=>{if($e.state!==`blocked`)return;if(!Z()){$e.reset();return}let e=$e.proceed,t=window.setTimeout(()=>{Fe(!1),window.setTimeout(e,0)},0);return()=>window.clearTimeout(t)},[Z,$e]);let et=()=>{ke(),K(`conversation`),n(`/work`)},tt=async t=>{if(w&&!Ze())return!1;w&&q&&(Qe(),Ee(),Fe(!1));try{if(w)await N(w.id,{message:t,model:w.model,providerType:w.providerType,providerId:w.providerId||void 0});else{if(!We)throw Error(e(`work.composer.noModelSelected`,{defaultValue:`No Work-compatible model is selected.`}));n(`/work/${(await _e({message:t,model:We.model,providerType:We.providerType,providerId:We.providerId,networkEnabled:!0})).id}`)}return!0}catch(t){return E.error(ft(t,e(`work.toasts.runFailed`,{defaultValue:`Could not start the Work task.`}))),!1}},nt=async t=>{let n=vt.find(e=>e.key===t);if(n){if(!w){Me(t);return}try{await ve(w.id,{model:n.model,providerType:n.providerType,providerId:n.providerId})}catch(t){E.error(ft(t,e(`work.toasts.updateFailed`,{defaultValue:`Could not update this task.`})))}}},rt=async()=>{if(w)try{await Ce(w.id),E.success(e(`work.toasts.cancelled`,{defaultValue:`Work run stopped.`}))}catch(t){E.error(ft(t,e(`work.toasts.cancelFailed`,{defaultValue:`Could not stop the Work run.`})))}},it=async t=>{let r=C.find(e=>e.id===t);if(!window.confirm(e(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:r?.title||e(`work.tasks.untitled`,{defaultValue:`Untitled task`})})))return;let i=a===t&&q;i&&Fe(!1);try{await xe(t),Se(t),a===t&&n(`/work`)}catch(t){i&&Fe(!0),E.error(ft(t,e(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`})))}},at=async t=>{if(!w)return!1;let n=t.trim();if(!n||n===w.title)return!!n;try{return await ve(w.id,{title:n}),!0}catch(t){return E.error(ft(t,e(`work.toasts.renameFailed`,{defaultValue:`Could not rename this task.`}))),!1}},ot=async(e,t,n)=>{try{return await e(),n&&E.success(n),!0}catch(e){return E.error(ft(e,t)),!1}},st=async(t,n,r)=>{if(!w)return!1;let i=w.id;try{let a=await H(i,t,n,r);return be.getState().selectedTaskId===i&&E.success(e(`work.toasts.saved`,{defaultValue:`File saved.`})),a}catch(t){return be.getState().selectedTaskId===i&&E.error(ft(t,e(`work.toasts.saveFailed`,{defaultValue:`Could not save this file.`}))),!1}},Q=S?.available===!1,mt=S?.pluginAvailable?S.ollamaAvailable?e(`work.runtime.readyHybrid`,{defaultValue:`Docker + models ready`}):e(`work.runtime.readyPlugin`,{defaultValue:`Docker + plugin ready`}):e(`work.runtime.readyOllama`,{defaultValue:`Docker ready`}),ht=w?lt(w):!1,$=w?{model:w.model,providerType:w.providerType,providerId:w.providerId||void 0}:void 0,gt=$?ut($):We?.key||``,_t=$&&!U.some(e=>e.key===gt)?{...$,key:gt,label:`${$.model} · ${$.providerType===`plugin`?$.providerId||`plugin`:`Ollama`}`,remote:$.providerType===`plugin`||$.model.toLowerCase().endsWith(`:cloud`)||$.model.toLowerCase().endsWith(`-cloud`)}:void 0,vt=_t?[_t,...U]:U,yt=P[w?.status??`idle`],bt=e(yt.labelKey,{defaultValue:yt.label}),xt=async()=>{if(l.workRemoteProviderDisclosureDismissed||h)return!1;let t=d;y(!0);try{let n=await pe.updatePreferences({workRemoteProviderDisclosureDismissed:!0});if(!n.success)throw Error(n.error||e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`}));return(ye.getState().user?.id??null)===t?(u({workRemoteProviderDisclosureDismissed:!0}),!0):!1}catch{return E.error(e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`})),!1}finally{y(!1)}};return(0,I.jsx)(`div`,{"data-testid":`work-page`,className:`relative flex h-full min-h-0 overflow-hidden bg-surface`,children:(0,I.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,I.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3 border-b border-line bg-surface-raised px-3 md:px-4`,children:[w?(0,I.jsx)(`input`,{"data-testid":`work-task-title`,dir:`auto`,defaultValue:w.title,onBlur:e=>{let t=e.currentTarget;if(!t.value.trim()){t.value=w.title;return}at(t.value).then(e=>{e||(t.value=w.title)})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=w.title,e.currentTarget.blur())},className:`min-w-0 max-w-sm flex-1 truncate rounded-lg border border-transparent bg-transparent px-2 py-1 text-sm font-semibold text-ink outline-none hover:border-line focus:border-primary-500 focus:bg-surface`,"aria-label":e(`work.tasks.rename`,{defaultValue:`Task title`})},`${w.id}:${w.title}`):(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h1`,{className:`truncate text-sm font-semibold text-ink`,children:e(`work.title`,{defaultValue:`Work`})}),(0,I.jsx)(`p`,{className:`truncate text-xs text-ink-muted`,children:e(`work.subtitle`,{defaultValue:`Isolated model workspaces`})})]}),w&&(0,I.jsxs)(`span`,{"data-testid":`work-compact-status`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2 text-[11px] font-medium text-ink-muted xl:hidden`,"aria-label":e(`work.tasks.status`,{status:bt,defaultValue:`Status: {{status}}`}),title:e(`work.tasks.status`,{status:bt,defaultValue:`Status: {{status}}`}),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-compact-status-indicator`,className:j(`h-1.5 w-1.5 rounded-full`,yt.animated&&`animate-pulse`,w.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:yt.color}}),(0,I.jsx)(`span`,{className:`hidden md:inline`,children:bt})]}),w&&(0,I.jsxs)(`div`,{className:`ms-auto inline-flex h-9 shrink-0 items-center rounded-xl border border-line bg-surface-subtle p-1 shadow-subtle xl:hidden`,role:`group`,"aria-label":e(`work.mobile.surface`,{defaultValue:`Task surface`}),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>K(`conversation`),"aria-label":e(`work.mobile.conversation`,{defaultValue:`Conversation`}),"aria-pressed":G===`conversation`,className:j(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,G===`conversation`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,I.jsx)(p,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.conversation`,{defaultValue:`Conversation`})})]}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>K(`workspace`),"aria-label":e(`work.mobile.workspace`,{defaultValue:`Workspace`}),"aria-pressed":G===`workspace`,className:j(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,G===`workspace`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,I.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.workspace`,{defaultValue:`Workspace`})})]})]}),(0,I.jsxs)(`div`,{className:j(`ms-auto hidden min-w-0 items-center gap-2`,w?`xl:flex`:`sm:flex`),children:[w&&(0,I.jsxs)(`span`,{"data-testid":`work-status`,className:`inline-flex h-7 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-status-indicator`,className:j(`h-1.5 w-1.5 rounded-full`,yt.animated&&`animate-pulse`,w.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:yt.color}}),bt]}),(0,I.jsxs)(`span`,{className:j(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-[11px] font-medium`,Q?`border-error-500/30 bg-error-500/10 text-error-600`:`border-line bg-surface text-ink-muted`),title:S?.image?`${mt} · ${S.image}`:mt,children:[(0,I.jsx)(f,{className:`h-3.5 w-3.5`}),Q?e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):mt]}),w&&(0,I.jsxs)(`span`,{className:`hidden h-7 max-w-44 items-center gap-1.5 truncate rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted md:inline-flex`,children:[(0,I.jsx)(g,{className:`h-3.5 w-3.5 shrink-0`}),(0,I.jsx)(`span`,{dir:`ltr`,className:`truncate`,children:w.model})]})]}),w&&(0,I.jsxs)(`div`,{ref:ze,className:`relative shrink-0`,children:[(0,I.jsx)(`button`,{ref:Be,id:`work-task-actions-trigger`,type:`button`,"data-testid":`work-task-actions-button`,onClick:()=>Le(e=>({taskId:w.id,open:e.taskId===w.id?!e.open:!0})),onKeyDown:e=>{e.key!==`ArrowDown`&&e.key!==`ArrowUp`||(e.preventDefault(),Le({taskId:w.id,open:!0}))},className:`inline-flex h-9 w-9 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink`,"aria-label":e(`work.tasks.actions`,{defaultValue:`Task actions`}),"aria-haspopup":`menu`,"aria-expanded":Re,"aria-controls":Re?`work-task-actions-menu`:void 0,children:(0,I.jsx)(m,{className:`h-4 w-4`})}),Re&&(0,I.jsx)(`div`,{ref:Ve,id:`work-task-actions-menu`,role:`menu`,"aria-labelledby":`work-task-actions-trigger`,onKeyDown:Ue,className:`absolute end-0 top-10 z-40 min-w-44 rounded-xl border border-line bg-surface-overlay p-1.5 shadow-overlay`,children:(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`work-delete-task-button`,onClick:()=>{J(!0),it(w.id)},className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-start text-xs font-medium text-error-600 transition-colors hover:bg-error-500/10`,children:[(0,I.jsx)(ce,{className:`h-3.5 w-3.5`}),e(`work.tasks.delete`,{defaultValue:`Delete task`})]})})]})]}),(Q||A)&&(0,I.jsxs)(`div`,{className:j(`flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs`,Q?`border-error-500/20 bg-error-500/10 text-error-700`:`border-amber-500/20 bg-amber-500/10 text-ink`),children:[(0,I.jsx)(_,{className:`h-4 w-4 shrink-0`}),(0,I.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1`,children:Q?S?.reason||e(`work.runtime.reason`,{defaultValue:`Docker and an available Ollama or plugin model provider are required.`}):A}),A&&!Q&&(0,I.jsx)(`button`,{type:`button`,className:`rounded-md p-1 hover:bg-black/5`,onClick:ke,"aria-label":e(`common.close`),children:`×`})]}),a?w?(0,I.jsx)(He,{userId:d,mobileSurface:G,conversation:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(je,{task:w,liveRun:Je,loading:k,loadingOlder:te,onLoadOlder:()=>M(w.id)}),(0,I.jsx)(L,{models:vt,modelKey:gt,running:ht,loading:re,disabled:Q,remoteDisclosureDismissed:l.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:h,onModelChange:nt,onDismissRemoteDisclosure:xt,onSubmit:tt,onCancel:rt},w.id)]}),workspace:(0,I.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,I.jsx)(ct,{task:w,liveRun:Je,files:T,selectedFile:O,loadingFiles:ne,actionLoading:re,onLoadFiles:e=>V(w.id,e),onLoadFile:e=>Te(w.id,e),onClearSelectedFile:Ee,onSaveFile:st,onStartPreview:t=>ot(()=>De(w.id,t),e(`work.toasts.previewFailed`,{defaultValue:`Could not start the preview.`})),onStopPreview:()=>ot(()=>Oe(w.id),e(`work.toasts.previewStopFailed`,{defaultValue:`Could not stop the preview.`})),onDirtyChange:Fe},w.id)})}):(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:k?(0,I.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`work.tasks.loading`,{defaultValue:`Loading task…`})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(_,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-ink`,children:e(`work.tasks.notFound`,{defaultValue:`This Work task is unavailable`})}),(0,I.jsxs)(`button`,{type:`button`,onClick:et,className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-primary-600 hover:text-primary-700`,children:[(0,I.jsx)(de,{className:`h-4 w-4 rtl:rotate-180`}),e(`work.tasks.back`,{defaultValue:`Start a new task`})]})]})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,I.jsxs)(`div`,{className:`mx-auto flex min-h-full max-w-3xl flex-col justify-center px-6 py-10`,children:[(0,I.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,I.jsx)(`div`,{className:`mb-5 flex h-14 w-14 items-center justify-center rounded-2xl border border-line bg-surface-raised shadow-subtle`,children:(0,I.jsx)(ae,{className:`h-7 w-7 text-primary-600`})}),(0,I.jsx)(`h2`,{className:`text-3xl font-semibold tracking-[-0.035em] text-ink md:text-4xl`,children:e(`work.landing.title`,{defaultValue:`Start a new Work task`})}),(0,I.jsx)(`p`,{className:`mt-3 max-w-xl text-sm leading-relaxed text-ink-muted md:text-base`,children:e(`work.landing.description`,{defaultValue:`Give a local model a durable, isolated workspace. It can inspect files, run tools, and continue where it left off when you return.`})})]}),(0,I.jsx)(`div`,{className:`mt-8 grid gap-3 sm:grid-cols-3`,children:[{icon:f,title:e(`work.landing.isolated`,{defaultValue:`Isolated`}),body:e(`work.landing.isolatedBody`,{defaultValue:`Every task gets its own container and files.`})},{icon:ie,title:e(`work.landing.durable`,{defaultValue:`Durable`}),body:e(`work.landing.durableBody`,{defaultValue:`Return to its conversation and workspace later.`})},{icon:D,title:e(`work.landing.controlled`,{defaultValue:`Controlled`}),body:e(`work.landing.controlledBody`,{defaultValue:`The runtime and task files stay isolated from the host.`})}].map(e=>{let t=e.icon;return(0,I.jsxs)(`div`,{className:`rounded-2xl border border-line bg-surface-raised p-4`,children:[(0,I.jsx)(t,{className:`h-5 w-5 text-ink-muted`}),(0,I.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-ink`,children:e.title}),(0,I.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-ink-muted`,children:e.body})]},e.title)})})]})}),(0,I.jsx)(L,{models:U,modelKey:We?.key||``,running:!1,loading:re,disabled:Q,remoteDisclosureDismissed:l.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:h,onModelChange:nt,onDismissRemoteDisclosure:xt,onSubmit:tt,onCancel:rt})]})]})})}export{Q as default};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-uCHBH_PM.js","js/rolldown-runtime-QTnfLwEv.js","js/markdown-core-GI9BPwrB.js","js/react-vendor-DyG_ODzn.js","js/router-vendor-BjDI9mRe.js","js/useTranslation-Cs6iTP4m.js","js/ui-vendor-DUqvZsfs.js","js/utils-vendor-Cbaj0BC5.js","js/demoMode-BhEpMVh5.js","js/logger-DbNs3-DK.js","js/utils-pTFqSV8c.js","js/Button-DBk-AREB.js","assets/index-Bv-twCuY.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,p as n}from"./router-vendor-BjDI9mRe.js";import{a as r}from"./utils-vendor-Cbaj0BC5.js";import{n as i}from"./demoMode-BhEpMVh5.js";import{n as a,t as o}from"./logger-DbNs3-DK.js";var s=o(`config`),c=window.location.protocol===`file:`?`http://localhost:3001/api`:`${window.location.origin}/api`,l=a(),u=()=>{l&&(s.debug(`API_BASE_URL configured as:`,c),s.debug(`Window location:`,window.location),s.debug(`Environment variables:`,{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.15.0`}))},d=o(`api`);u(),d.debug(`User agent:`,navigator.userAgent),d.debug(`Demo mode detected:`,i());var f=(e,t=!0)=>new Promise(n=>{setTimeout(()=>{n({success:t,data:e,error:t?void 0:`Demo mode: Backend not available`})},500)}),p=r.create({baseURL:c,timeout:3e5});p.interceptors.request.use(e=>{let t=localStorage.getItem(`auth-token`);return t&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e)),p.interceptors.response.use(e=>e,e=>{if(e.response?.status===401){d.warn(`Session expired or unauthorized, logging out...`),localStorage.removeItem(`auth-token`),t(async()=>{let{useAuthStore:e}=await import(`../assets/index-uCHBH_PM.js`).then(e=>e.D);return{useAuthStore:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(({useAuthStore:e})=>{e.getState().logout()});let e=window.location.protocol===`file:`;return(e?window.location.hash:window.location.pathname).includes(`/login`)||(window.location.href=e?`#/login`:`/login`),Promise.reject(Error(`Session expired`))}return d.error(`API Error:`,e),Promise.reject(e)});var m=`0.15.0`,h={login:e=>i()?f({user:{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,allowUserModelPull:!0,version:m}}):p.post(`/auth/login`,e).then(e=>e.data),signup:e=>i()?f({user:{id:`demo-user-new`,username:e.username,email:e.email||``,role:`user`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token-new`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,allowUserModelPull:!0,version:m,turnstile:{enabled:!1}}}):p.post(`/auth/signup`,e).then(e=>e.data),logout:()=>i()?f(void 0):p.post(`/auth/logout`).then(e=>e.data),getSystemInfo:()=>(d.debug(`getSystemInfo called, demo mode:`,i()),i()?f({requiresAuth:!0,hasUsers:!0,userCount:1,allowUserModelPull:!0,version:m,turnstile:{enabled:!1}}):(d.debug(`Making API call to:`,c+`/auth/system-info`),d.debug(`Full URL from:`,window.location.origin,`-> API:`,c+`/auth/system-info`),p.get(`/auth/system-info`).then(e=>(d.debug(`getSystemInfo response:`,e.data),e.data)).catch(e=>{throw d.debug(`getSystemInfo error:`,e),e.response&&(d.debug(`Error response data:`,e.response.data),d.debug(`Error status:`,e.response.status),d.debug(`Error headers:`,e.response.headers)),e.request&&d.debug(`Network error - no response received:`,e.request),d.debug(`Error config:`,e.config),e}))),verifyToken:()=>i()?f({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):p.get(`/auth/verify`).then(e=>e.data),getEncryptionKey:()=>i()?f({encryptionKey:`demo-encryption-key-not-real`}):p.get(`/auth/encryption-key`).then(e=>e.data),updateModelPullSetting:e=>i()?f({requiresAuth:!0,hasUsers:!0,userCount:1,allowUserModelPull:e,version:m,turnstile:{enabled:!1}}):p.patch(`/auth/system-settings/model-pull`,{allowUserModelPull:e}).then(e=>e.data)},g={getUsers:()=>i()?f([{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]):p.get(`/users`).then(e=>e.data),createUser:e=>i()?f({id:`new-user-`+Date.now(),username:e.username,email:e.email,role:e.role,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):p.post(`/users`,e).then(e=>e.data),updateUser:(e,t)=>i()?f({id:e,username:t.username||`demo`,email:t.email||`demo@example.com`,role:t.role||`user`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):p.patch(`/users/${e}`,t).then(e=>e.data),deleteUser:e=>i()?f(void 0):p.delete(`/users/${e}`).then(e=>e.data),updateMyAvatar:e=>i()?f({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,avatar:e,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):p.patch(`/users/me/avatar`,{avatar:e}).then(e=>e.data)},_=[{name:`llama3.2:3b`,size:2048e6,digest:`demo-digest-1`,modified_at:new Date().toISOString(),details:{format:`gguf`,family:`llama`,families:[`llama`],parameter_size:`3B`,quantization_level:`Q4_0`}},{name:`qwen2.5:7b`,size:4096e6,digest:`demo-digest-2`,modified_at:new Date().toISOString(),details:{format:`gguf`,family:`qwen`,families:[`qwen`],parameter_size:`7B`,quantization_level:`Q4_0`}}],v=()=>[{id:`demo-session-1`,title:`Demo Chat Session`,model:_[0].name,messages:[{id:`demo-msg-1`,role:`user`,content:`Hello! Can you tell me about this demo?`,timestamp:Date.now()},{id:`demo-msg-2`,role:`assistant`,content:`This is a demo of Libre WebUI! In a real deployment, I would be powered by Ollama running locally on your machine. This demo shows the beautiful interface and features without the backend connection.`,timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()}],y=v(),b={theme:{mode:`dark`,adaptToAccent:!1,accent:`blue`,customAccent:`#2563eb`},defaultModel:`llama3.2:3b`,systemMessage:`You are a helpful assistant.`,generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},titleSettings:{autoTitle:!1,taskModel:``},showUsername:!1,workRemoteProviderDisclosureDismissed:!1,backgroundSettings:{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6}},x={...b,theme:{...b.theme},generationOptions:{...b.generationOptions},embeddingSettings:{...b.embeddingSettings},titleSettings:{...b.titleSettings},backgroundSettings:{...b.backgroundSettings}},S=()=>x,C=e=>{let t=x.backgroundSettings||b.backgroundSettings;return x={...x,...e,theme:{...x.theme,...e.theme},generationOptions:{...x.generationOptions,...e.generationOptions},embeddingSettings:{...x.embeddingSettings,...e.embeddingSettings},titleSettings:e.titleSettings?{...x.titleSettings||b.titleSettings,...e.titleSettings}:x.titleSettings,backgroundSettings:e.backgroundSettings?{...t,...e.backgroundSettings}:x.backgroundSettings},x},w={getSessions:()=>p.get(`/chat/sessions`).then(e=>e.data),createSession:(e,t,n)=>p.post(`/chat/sessions`,{model:e,title:t,personaId:n}).then(e=>e.data),getSession:e=>{if(i()){let t=v().find(t=>t.id===e);return t?f(t):Promise.resolve({success:!1,error:`Session not found in demo mode`})}return p.get(`/chat/sessions/${e}`).then(e=>e.data)},updateSession:(e,t)=>{if(i()){let n=y.findIndex(t=>t.id===e),r=y[n];if(r){let e={...r,...t,updatedAt:Date.now()};return y[n]=e,f(e)}return Promise.resolve({success:!1,error:`Session not found in demo mode`})}return p.put(`/chat/sessions/${e}`,t).then(e=>e.data)},deleteSession:e=>i()?f(null):p.delete(`/chat/sessions/${e}`).then(e=>e.data),clearAllSessions:()=>p.delete(`/chat/sessions`).then(e=>e.data),generateTitle:(e,t,n)=>i()?f({title:n.substring(0,30)+(n.length>30?`...`:``),source:`fallback`,updatedAt:Date.now()}):p.post(`/chat/sessions/${e}/generate-title`,{model:t,message:n}).then(e=>e.data),sendMessage:(e,t,n)=>p.post(`/chat/sessions/${e}/messages`,{content:t,options:n}).then(e=>e.data),saveMessage:(e,t)=>p.post(`/chat/sessions/${e}/messages`,t).then(e=>e.data),updateMessage:(e,t,n)=>i()?f({}):p.put(`/chat/sessions/${e}/messages/${t}`,n).then(e=>e.data),generateChatResponse:(e,t,n)=>p.post(`/chat/sessions/${e}/generate`,{message:t,options:n}).then(e=>e.data),generateChatStreamResponse:(e,t,n)=>({subscribe:async(r,i,a)=>{try{let o=await fetch(`${c}/chat/sessions/${e}/generate/stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:t,options:n})});if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);let s=o.body?.getReader();if(!s)throw Error(`No response body reader available`);let l=new TextDecoder,u=``,f=()=>{s.read().then(({done:e,value:t})=>{if(e){a?.();return}u+=l.decode(t,{stream:!0});let n=u.split(`
|
|
3
|
+
`);u=n.pop()||``;for(let e of n){let t=e.trim();if(t.startsWith(`data: `)){let e=t.slice(6);if(e===`[DONE]`){a?.();return}try{let t=JSON.parse(e);if(r(t),t.type===`done`||t.type===`error`){t.type===`error`?i?.(t.error):a?.();return}}catch(e){d.error(`Failed to parse SSE data:`,e)}}}f()}).catch(e=>{i?.(e instanceof Error?e:Error(String(e)))})};return f(),()=>s.cancel()}catch(e){return i?.(e instanceof Error?e:Error(String(e))),()=>{}}}}),getMessageBranches:(e,t)=>i()?f([]):p.get(`/chat/sessions/${e}/messages/${t}/branches`).then(e=>e.data),switchMessageBranch:(e,t,n)=>i()?f({}):p.post(`/chat/sessions/${e}/messages/${t}/branch`,{branchIndex:n}).then(e=>e.data),createMessageBranch:(e,t,n)=>i()?f({}):p.post(`/chat/sessions/${e}/messages/${t}/branches`,{...n}).then(e=>e.data)},T={uploadDocument:(e,t)=>{if(i())return f({id:`demo-doc-`+Date.now(),filename:e.name,fileType:e.name.endsWith(`.pdf`)?`pdf`:`txt`,size:e.size,sessionId:t,uploadedAt:Date.now()});let n=new FormData;return n.append(`document`,e),t&&n.append(`sessionId`,t),p.post(`/documents/upload`,n).then(e=>e.data)},getDocuments:e=>{if(i())return f([]);let t=e?`/documents/session/${e}`:`/documents`;return p.get(t).then(e=>e.data)},getDocument:e=>i()?f({id:e,filename:`demo-document.pdf`,fileType:`pdf`,size:1024,content:`Demo document content...`,uploadedAt:Date.now()}):p.get(`/documents/${e}`).then(e=>e.data),searchDocuments:(e,t,n)=>i()?f([]):p.post(`/documents/search`,{query:e,sessionId:t,limit:n}).then(e=>e.data),deleteDocument:e=>i()?f(void 0):p.delete(`/documents/${e}`).then(e=>e.data),getEmbeddingStatus:()=>i()?f({available:!1,model:`nomic-embed-text`,chunksWithEmbeddings:0,totalChunks:0}):p.get(`/documents/embeddings/status`).then(e=>e.data),regenerateEmbeddings:()=>i()?f(void 0):p.post(`/documents/embeddings/regenerate`).then(e=>e.data)},E={getModels:()=>i()?f([{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]):p.get(`/embeddings/models`).then(e=>e.data)},D={getModels:e=>i()?f([{id:`meta-llama/Llama-3.3-70B-Instruct`,modelId:`meta-llama/Llama-3.3-70B-Instruct`,author:`meta-llama`,downloads:1e6,likes:5e3,tags:[`text-generation`,`llama`],pipeline_tag:`text-generation`,gated:!1}]):p.get(`/huggingface-hub/models`,{params:e}).then(e=>e.data),getTrending:e=>i()?f([]):p.get(`/huggingface-hub/trending`,{params:e}).then(e=>e.data),getModel:(e,t)=>i()?f({id:`${e}/${t}`,modelId:`${e}/${t}`,author:e,downloads:0,likes:0,tags:[],gated:!1}):p.get(`/huggingface-hub/models/${e}/${t}`).then(e=>e.data),getTasks:()=>i()?f([`text-generation`,`text-to-speech`,`text-to-image`]):p.get(`/huggingface-hub/tasks`).then(e=>e.data),clearCache:()=>i()?f(!0):p.post(`/huggingface-hub/cache/clear`).then(e=>e.data),getGgufFiles:(e,t)=>i()?f([{filename:`model-Q4_K_M.gguf`,size:45e8,sizeFormatted:`4.19 GB`,quantization:`Q4_K_M`,url:`https://huggingface.co/${e}/${t}/resolve/main/model-Q4_K_M.gguf`,ollamaCommand:`hf.co/${e}/${t}:Q4_K_M`}]):p.get(`/huggingface-hub/models/${e}/${t}/gguf`).then(e=>e.data),hasGgufFiles:(e,t)=>i()?f({hasGguf:!1,count:0}):p.get(`/huggingface-hub/models/${e}/${t}/has-gguf`).then(e=>e.data)},O={getModels:()=>i()?f([{model:`dall-e-3`,plugin:`openai`,config:{sizes:[`1024x1024`,`1792x1024`,`1024x1792`],default_size:`1024x1024`,qualities:[`standard`,`hd`],default_quality:`standard`,styles:[`vivid`,`natural`],default_style:`vivid`,max_prompt_length:4e3}}]):p.get(`/image-gen/models`).then(e=>e.data),getPlugins:()=>i()?f([{id:`openai`,name:`OpenAI DALL-E`,models:[`dall-e-3`,`dall-e-2`],config:{sizes:[`1024x1024`,`1792x1024`,`1024x1792`],default_size:`1024x1024`,qualities:[`standard`,`hd`],default_quality:`standard`}}]):p.get(`/image-gen/plugins`).then(e=>e.data),getConfig:e=>i()?f({sizes:[`1024x1024`,`1792x1024`,`1024x1792`],default_size:`1024x1024`,qualities:[`standard`,`hd`],default_quality:`standard`,styles:[`vivid`,`natural`],default_style:`vivid`,max_prompt_length:4e3}):p.get(`/image-gen/config/${e}`).then(e=>e.data),generate:e=>i()?f({images:[{url:`https://placehold.co/1024x1024/purple/white?text=Demo+Image`,revised_prompt:e.prompt}]}):p.post(`/image-gen/generate`,e).then(e=>e.data),getGallery:e=>i()?f({images:[],total:0}):p.get(`/image-gen/gallery`,{params:e}).then(e=>e.data),getGalleryImage:e=>i()?f({id:e,userId:`demo`,prompt:`Demo image prompt`,model:`dall-e-3`,imageData:`https://placehold.co/1024x1024/purple/white?text=Demo`,createdAt:Date.now()}):p.get(`/image-gen/gallery/${e}`).then(e=>e.data),deleteGalleryImage:e=>i()?f(void 0):p.delete(`/image-gen/gallery/${e}`).then(e=>e.data)},k={connected:!1,baseUrl:`http://127.0.0.1:8766`,dashboardUrl:`http://127.0.0.1:8766/dashboard`,error:`Libre Claw daemon is not connected in demo mode.`},A={status:()=>i()?f(k):p.get(`/libre-claw/status`).then(e=>e.data),dashboard:()=>i()?f({url:k.dashboardUrl}):p.get(`/libre-claw/dashboard`).then(e=>e.data),currentModel:()=>i()?f({provider:`openrouter`,model:`openrouter/auto`}):p.get(`/libre-claw/config/model`).then(e=>e.data),updateModel:(e,t,n=!1)=>i()?f({provider:e,model:t,persist_global:n}):p.patch(`/libre-claw/config/model`,{provider:e,model:t,persist_global:n}).then(e=>e.data),currentFallback:()=>i()?f({enabled:!1,routes:[]}):p.get(`/libre-claw/config/fallback`).then(e=>e.data),updateFallback:e=>i()?f(e):p.patch(`/libre-claw/config/fallback`,e).then(e=>e.data),updateTheme:(e,t=!0)=>i()?f({theme:e,label:e,persist_global:t}):p.patch(`/libre-claw/config/theme`,{theme:e,persist_global:t}).then(e=>e.data),usage:(e=``,t=250)=>{let n=new URLSearchParams({limit:String(t)});return e&&n.set(`provider`,e),i()?f({summary:{},records:[],text:``}):p.get(`/libre-claw/usage?${n.toString()}`).then(e=>e.data)},listRuns:(e=20)=>i()?f({runs:[]}):p.get(`/libre-claw/runs?limit=${e}`).then(e=>e.data),startRun:e=>{if(i()){let t=new Date().toISOString();return f({run:{run_id:`demo-${Date.now()}`,state:`queued`,title:e.message.slice(0,80)||`Libre Claw demo run`,kind:e.kind||`chat`,provider:e.provider||`openrouter`,model:e.model||`openrouter/auto`,working_directory:``,created_at:t,updated_at:t}})}return p.post(`/libre-claw/runs`,e).then(e=>e.data)},getRun:e=>i()?f({run_id:e}):p.get(`/libre-claw/runs/${encodeURIComponent(e)}`).then(e=>e.data),getEvents:(e,t=0)=>i()?f({events:[]}):p.get(`/libre-claw/runs/${encodeURIComponent(e)}/events?after=${t}`).then(e=>e.data),cancelRun:e=>i()?f({run_id:e,cancelled:!0}):p.post(`/libre-claw/runs/${encodeURIComponent(e)}/cancel`).then(e=>e.data),resolvePermission:(e,t,n)=>i()?f({run_id:e,tool_call_id:t,resolution:n}):p.post(`/libre-claw/runs/${encodeURIComponent(e)}/permissions/${encodeURIComponent(t)}`,{resolution:n}).then(e=>e.data),listAutomations:(e=50)=>i()?f({automations:[]}):p.get(`/libre-claw/automations?limit=${e}`).then(e=>e.data),createAutomation:e=>i()?f({...e,automation_id:`demo-${Date.now()}`}):p.post(`/libre-claw/automations`,e).then(e=>e.data),updateAutomation:(e,t)=>i()?f({...t,automation_id:e}):p.patch(`/libre-claw/automations/${encodeURIComponent(e)}`,t).then(e=>e.data),pauseAutomation:e=>i()?f({automation_id:e,status:`paused`}):p.post(`/libre-claw/automations/${encodeURIComponent(e)}/pause`).then(e=>e.data),resumeAutomation:e=>i()?f({automation_id:e,status:`active`}):p.post(`/libre-claw/automations/${encodeURIComponent(e)}/resume`).then(e=>e.data),runAutomationNow:e=>i()?f({automation_id:e,run:!0}):p.post(`/libre-claw/automations/${encodeURIComponent(e)}/run`).then(e=>e.data),deleteAutomation:e=>i()?f({automation_id:e,deleted:!0}):p.delete(`/libre-claw/automations/${encodeURIComponent(e)}`).then(e=>e.data)},j={checkHealth:()=>i()?f({status:`offline`},!1):p.get(`/ollama/health`).then(e=>e.data),getModels:()=>i()?f(_):p.get(`/ollama/models`).then(e=>e.data),pullModel:e=>i()?f(null,!1):p.post(`/ollama/models/pull`,{name:e}).then(e=>e.data),pullModelStream:(e,t,n,r)=>{if(i()){let e=0,r=setInterval(()=>{e+=Math.random()*20,e>=100?(e=100,t({status:`success`,total:100,completed:100,percent:100}),clearInterval(r),setTimeout(n,500)):t({status:`pulling`,total:100,completed:e,percent:Math.round(e)})},1e3);return()=>clearInterval(r)}let a=new URLSearchParams({model:e}),o=localStorage.getItem(`auth-token`);o&&a.set(`token`,o);let s=new EventSource(`${c}/ollama/pull/stream?${a.toString()}`);return s.onmessage=e=>{let i=JSON.parse(e.data);switch(i.type){case`progress`:t({status:i.status,digest:i.digest,total:i.total,completed:i.completed,percent:i.percent});break;case`complete`:s.close(),n();break;case`error`:s.close(),r(i.error);break}},s.onerror=()=>{s.close(),r(`Connection to server lost`)},()=>{s.close()}},deleteModel:e=>i()?f(null,!1):p.delete(`/ollama/models`,{params:{name:e}}).then(e=>e.data),showModel:(e,t=!1)=>{if(i()){let t=_.find(t=>t.name===e);return f(t||null,!!t)}return p.get(`/ollama/models/show`,{params:{name:e,verbose:t}}).then(e=>e.data)},createModel:e=>i()?f(null,!1):p.post(`/ollama/models`,e).then(e=>e.data),copyModel:(e,t)=>i()?f(null,!1):p.post(`/ollama/models/copy`,{source:e,destination:t}).then(e=>e.data),pushModel:e=>i()?f(null,!1):p.post(`/ollama/models/push`,{name:e}).then(e=>e.data),pullAllModels:()=>i()?f(null,!1):p.post(`/ollama/models/pull-all`).then(e=>e.data),pullAllModelsStream:(e,t,n)=>{if(i()){let n=_,r=0,i=setInterval(()=>{r++,r<=n.length&&e({current:r,total:n.length,modelName:n[r-1]?.name||`demo-model`,status:Math.random()>.1?`success`:`error`,error:Math.random()>.1?void 0:`Demo error`}),r>=n.length&&(clearInterval(i),setTimeout(t,500))},1e3);return}let r=new EventSource(`${c}/ollama/models/pull-all/stream`);r.onmessage=i=>{let a=JSON.parse(i.data);switch(a.type){case`progress`:e({current:a.current,total:a.total,modelName:a.modelName,status:a.status,error:a.error});break;case`complete`:r.close(),t();break;case`error`:r.close(),n(a.error);break}},r.onerror=()=>{r.close(),n(`Connection to server lost`)}},generateEmbeddings:e=>i()?f({embeddings:[[]]},!1):p.post(`/ollama/embed`,e).then(e=>e.data),listRunningModels:()=>i()?f([]):p.get(`/ollama/running`).then(e=>e.data),unloadModel:e=>i()?f(null):p.post(`/ollama/models/unload`,{name:e}).then(e=>e.data),unloadAllModels:()=>i()?f(null):p.post(`/ollama/models/unload-all`).then(e=>e.data),getVersion:()=>i()?f({version:`demo-mode`},!1):p.get(`/ollama/version`).then(e=>e.data),chatCompletion:e=>i()?f({message:{content:`Demo response`,role:`assistant`}},!1):p.post(`/ollama/chat`,e).then(e=>e.data),checkBlobExists:e=>i()?Promise.resolve(!1):p.head(`/ollama/blobs/${e}`).then(()=>!0).catch(()=>!1),pushBlob:(e,t)=>i()?f(null,!1):p.post(`/ollama/blobs/${e}`,t,{headers:{"Content-Type":`application/octet-stream`}}).then(e=>e.data),generateLegacyEmbeddings:e=>i()?f({embedding:[]},!1):p.post(`/ollama/embeddings`,e).then(e=>e.data),getLibraryModels:e=>{if(i())return e?.category===`cloud`?f([{name:`gpt-oss:cloud`,description:`Demo cloud model using Ollama cloud naming`,category:`cloud`,sizes:[`cloud`],pulls:`Cloud`,tags:[`cloud`]}]):f([{name:`llama3.2`,description:`Meta's latest Llama model`,category:`general`,sizes:[`1b`,`3b`],pulls:`50M+`,tags:[`general`]},{name:`deepseek-r1`,description:`Open reasoning model`,category:`reasoning`,sizes:[`7b`,`14b`,`32b`],pulls:`200M+`,tags:[`reasoning`]}]);let t=new URLSearchParams;e?.search&&t.set(`search`,e.search),e?.sort&&t.set(`sort`,e.sort),e?.category&&t.set(`category`,e.category);let n=t.toString();return p.get(`/ollama/library${n?`?${n}`:``}`).then(e=>e.data)}},M=[[`#2563eb`,`#7c3aed`],[`#0891b2`,`#2563eb`],[`#0f766e`,`#2563eb`],[`#be123c`,`#7c3aed`],[`#ff7b52`,`#dc2626`]],ee=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)},N=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`),P=e=>{let t=e.trim().split(/[\s._-]+/).filter(Boolean);return t.length===0?`AI`:t.slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`AI`},F=(e,t=128)=>{let n=e.trim()||`AI Persona`,r=ee(n),[i,a]=M[r%M.length],o=N(P(n)),s=`persona-avatar-${r}-${t}`,c=t>=96?44:24,l=`
|
|
4
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}" role="img" aria-label="${N(n)} avatar">
|
|
5
|
+
<defs>
|
|
6
|
+
<linearGradient id="${s}" x1="0" y1="0" x2="1" y2="1">
|
|
7
|
+
<stop offset="0%" stop-color="${i}" />
|
|
8
|
+
<stop offset="100%" stop-color="${a}" />
|
|
9
|
+
</linearGradient>
|
|
10
|
+
</defs>
|
|
11
|
+
<rect width="${t}" height="${t}" rx="${Math.round(t*.22)}" fill="url(#${s})" />
|
|
12
|
+
<circle cx="${t*.22}" cy="${t*.22}" r="${t*.26}" fill="rgba(255,255,255,0.16)" />
|
|
13
|
+
<text x="50%" y="52%" dominant-baseline="middle" text-anchor="middle" fill="white" font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="${c}" font-weight="700">${o}</text>
|
|
14
|
+
</svg>
|
|
15
|
+
`;return`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(l)}`},I=(e,t=128)=>e.avatar?.trim()||F(e.name,t),L=(e,t,n=128)=>{e.onerror=null,e.src=F(t,n)},R={getPersonas:()=>i()?f([{id:`demo-1`,user_id:`default`,name:`Creative Assistant`,description:`Helpful assistant for creative tasks`,model:`llama3.3:latest`,parameters:{temperature:.8,top_p:.9,context_window:4096,system_prompt:`You are a creative and helpful assistant. Provide thoughtful and engaging responses.`},avatar:F(`Creative Assistant`,128),created_at:Date.now()-864e5,updated_at:Date.now()-864e5},{id:`demo-2`,user_id:`default`,name:`Research Assistant`,description:`Academic assistant for research and learning`,model:`qwen3:7b`,parameters:{temperature:.3,top_p:.8,context_window:8192,system_prompt:`You are a knowledgeable research assistant. Provide detailed, informative explanations.`},avatar:F(`Research Assistant`,128),created_at:Date.now()-1728e5,updated_at:Date.now()-1728e5}]):p.get(`/personas`).then(e=>e.data),getPersona:e=>i()?f({id:e,user_id:`default`,name:`Sample Assistant`,description:`A sample assistant for demonstration`,model:`llama3.2:latest`,parameters:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},created_at:Date.now(),updated_at:Date.now()}):p.get(`/personas/${e}`).then(e=>e.data),createPersona:e=>i()?f({id:`demo-`+Date.now(),user_id:`default`,...e,created_at:Date.now(),updated_at:Date.now()}):p.post(`/personas`,e).then(e=>e.data),updatePersona:(e,t)=>i()?f({id:e,user_id:`default`,name:t.name||`Updated Sample Assistant`,description:t.description,model:t.model||`llama3.2:latest`,parameters:t.parameters||{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},avatar:t.avatar,background:t.background,created_at:Date.now()-864e5,updated_at:Date.now()}):p.put(`/personas/${e}`,t).then(e=>e.data),deletePersona:e=>i()?f(void 0):p.delete(`/personas/${e}`).then(e=>e.data),exportPersona:e=>{if(i()){let e={name:`Sample Assistant`,description:`A sample assistant for demonstration`,model:`llama3.2:latest`,params:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},exportedAt:Date.now(),version:`1.0.0`};return Promise.resolve(e)}return p.get(`/personas/${e}/export`).then(e=>e.data)},importPersona:e=>i()?f({id:`demo-imported-`+Date.now(),user_id:`default`,name:e.name,description:e.description,model:e.model,parameters:e.params,avatar:e.avatar,background:e.background,created_at:Date.now(),updated_at:Date.now(),embedding_model:e.embedding_model,memory_settings:e.memory_settings,mutation_settings:e.mutation_settings}):p.post(`/personas/import`,e).then(e=>e.data),getPersonasCount:()=>i()?f({count:2}):p.get(`/personas/stats/count`).then(e=>e.data),getDefaultParameters:()=>i()?f({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}):p.get(`/personas/defaults/parameters`).then(e=>e.data),getMemoryStatus:e=>i()?f({status:`active`,memory_count:42,last_backup:Date.now()-864e5,size_mb:2.3}):p.get(`/personas/${e}/memory/status`).then(e=>e.data),wipeMemories:e=>i()?f({deleted_count:42}):p.delete(`/personas/${e}/memory`).then(e=>e.data),backupPersona:e=>{if(i()){let t=JSON.stringify({persona_id:e,backup_date:new Date().toISOString(),data:`demo backup data`});return Promise.resolve(new Blob([t],{type:`application/json`}))}return p.get(`/personas/${e}/backup`,{responseType:`blob`}).then(e=>e.data)},exportPersonaDNA:e=>{if(i()){let t=JSON.stringify({persona_id:e,export_date:new Date().toISOString(),dna:`demo DNA data`,memories:[],learned_behaviors:{}});return Promise.resolve(new Blob([t],{type:`application/json`}))}return p.get(`/personas/${e}/export/dna`,{responseType:`blob`}).then(e=>e.data)},importPersonaDNA:e=>{if(i())return f({id:`demo-dna-`+Date.now(),user_id:`default`,name:`Imported Persona`,description:`Persona imported from DNA`,model:`llama3.2:latest`,parameters:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},created_at:Date.now(),updated_at:Date.now()});let t=new FormData;return t.append(`dnaFile`,e),p.post(`/personas/import/dna`,t).then(e=>e.data)},downloadPersona:async(e,t)=>{try{let n=await R.exportPersona(e),r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${t}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch(e){throw d.error(`Error while downloading persona:`,e),Error(`Failed to download persona: ${e instanceof Error?e.message:String(e)}`)}}},z={getAllPlugins:()=>i()?f([]):p.get(`/plugins`).then(e=>e.data),uploadPlugin:e=>{if(i())return f({},!1);let t=new FormData;return t.append(`plugin`,e),p.post(`/plugins/upload`,t).then(e=>e.data)},installPlugin:e=>i()?f({},!1):p.post(`/plugins/install`,e).then(e=>e.data),updatePlugin:(e,t)=>i()?f({},!1):p.put(`/plugins/${e}`,t).then(e=>e.data),deletePlugin:e=>i()?f(void 0):p.delete(`/plugins/${e}`).then(e=>e.data),activatePlugin:e=>i()?f({},!1):p.post(`/plugins/activate/${e}`).then(e=>e.data),deactivatePlugin:e=>{if(i())return f(void 0);let t=e?`/plugins/deactivate/${e}`:`/plugins/deactivate`;return p.post(t).then(e=>e.data)},getActivePlugin:()=>i()?f(null):p.get(`/plugins/active`).then(e=>e.data),getPluginStatus:()=>i()?f([]):p.get(`/plugins/status`).then(e=>e.data),exportPlugin:e=>i()?Promise.resolve(new Blob([`{}`],{type:`application/json`})):p.get(`/plugins/${e}/export`,{responseType:`blob`}).then(e=>e.data),getCredentials:()=>i()?f([]):p.get(`/plugins/credentials/all`).then(e=>e.data),setApiKey:(e,t)=>i()?f(!1,!1):p.post(`/plugins/${e}/credentials`,{api_key:t}).then(e=>e.data),deleteApiKey:e=>i()?f(!1,!1):p.delete(`/plugins/${e}/credentials`).then(e=>e.data),checkApiKey:e=>i()?f(!1):p.get(`/plugins/${e}/credentials/check`).then(e=>e.data),getVariables:e=>i()?f({}):p.get(`/plugins/${e}/variables`).then(e=>e.data),setVariables:(e,t)=>i()?f(!0):p.put(`/plugins/${e}/variables`,{variables:t}).then(e=>e.data),resetVariables:e=>i()?f(!0):p.delete(`/plugins/${e}/variables`).then(e=>e.data)},B={getPreferences:()=>i()?f(S()):p.get(`/preferences`).then(e=>e.data),updatePreferences:e=>i()?f(C(e)):p.put(`/preferences`,e).then(e=>e.data),setDefaultModel:e=>i()?f(C({defaultModel:e})):p.put(`/preferences/default-model`,{model:e}).then(e=>e.data),setSystemMessage:e=>i()?f(C({systemMessage:e})):p.put(`/preferences/system-message`,{message:e}).then(e=>e.data),setGenerationOptions:e=>i()?f(C({generationOptions:e})):p.put(`/preferences/generation-options`,e).then(e=>e.data),resetGenerationOptions:()=>i()?f(C({generationOptions:b.generationOptions})):p.post(`/preferences/generation-options/reset`).then(e=>e.data),setEmbeddingSettings:e=>i()?f(C({embeddingSettings:e})):p.put(`/preferences/embedding-settings`,e).then(e=>e.data),resetEmbeddingSettings:()=>i()?f(C({embeddingSettings:b.embeddingSettings})):p.post(`/preferences/embedding-settings/reset`).then(e=>e.data),importData:(e,t=`replace`)=>i()?f({theme:{mode:`dark`,adaptToAccent:!1,accent:`blue`,customAccent:`#2563eb`},defaultModel:`llama3.2`,systemMessage:`You are a helpful assistant.`,generationOptions:{},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},showUsername:!1,workRemoteProviderDisclosureDismissed:!1}):p.post(`/preferences/import`,{data:e,mergeStrategy:t}).then(e=>e.data)},V=new Set([`snapshot`,`run_state`,`reasoning_delta`,`assistant_delta`,`tool_call`,`tool_result`,`usage`,`skill_loaded`,`error`,`done`]),H=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,U=e=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`){let t=Number(e);if(Number.isFinite(t))return t;let n=Date.parse(e);if(Number.isFinite(n))return n}return Date.now()},W=(e,t,n,r,i)=>{let a=H(e);if(!a)return;let o=Number(a.id??t),s=String(a.type??n??``),c=String(a.taskId??r),l=String(a.runId??i);if(!Number.isSafeInteger(o)||o<0||!V.has(s)||c!==r||l!==i)return;let u=a.data;return{id:o,type:s,taskId:c,runId:l,timestamp:U(a.timestamp),data:H(u)||(u===void 0?{}:{content:u})}},G=(e,t,n)=>{let r,i,a=[];for(let t of e.split(`
|
|
16
|
+
`)){if(!t||t.startsWith(`:`))continue;let e=t.indexOf(`:`),n=e===-1?t:t.slice(0,e),o=e===-1?``:t.slice(e+1),s=o.startsWith(` `)?o.slice(1):o;n===`id`&&(r=s),n===`event`&&(i=s),n===`data`&&a.push(s)}if(a.length===0)return;let o=a.join(`
|
|
17
|
+
`);if(o===`[DONE]`)return W({id:r,type:`done`,taskId:t,runId:n,timestamp:Date.now(),data:{}},r,i,t,n);try{return W(JSON.parse(o),r,i,t,n)}catch{return}},K=class{constructor(e,t,r){n(this,`taskId`,void 0),n(this,`runId`,void 0),n(this,`onEvent`,void 0),n(this,`buffer`,``),this.taskId=e,this.runId=t,this.onEvent=r}push(e){e&&(this.buffer+=e,this.drain())}finish(e=``){if(this.buffer+=e,this.drain(),!this.buffer.trim()){this.buffer=``;return}let t=G(this.buffer.replace(/\r\n?/g,`
|
|
18
|
+
`),this.taskId,this.runId);this.buffer=``,t&&this.onEvent(t)}drain(){let e=/\r?\n\r?\n/.exec(this.buffer);for(;e?.index!==void 0;){let t=this.buffer.slice(0,e.index).replace(/\r\n?/g,`
|
|
19
|
+
`);this.buffer=this.buffer.slice(e.index+e[0].length);let n=G(t,this.taskId,this.runId);n&&this.onEvent(n),e=/\r?\n\r?\n/.exec(this.buffer)}}},q=async e=>{try{let t=await e.json(),n=typeof t.error==`string`?t.error:typeof t.message==`string`?t.message:void 0;if(n)return Error(n)}catch{}return Error(`Work event stream failed with status ${e.status}.`)},J=async({taskId:e,runId:t,after:n,signal:r,onEvent:i})=>{let a=localStorage.getItem(`auth-token`),o=new URL(`${c}/work/tasks/${encodeURIComponent(e)}/runs/${encodeURIComponent(t)}/events`,window.location.origin);o.searchParams.set(`after`,String(Math.max(0,Math.trunc(n))));let s=await fetch(o,{method:`GET`,headers:{Accept:`text/event-stream`,...a?{Authorization:`Bearer ${a}`}:{}},cache:`no-store`,credentials:`same-origin`,signal:r});if(!s.ok)throw await q(s);if(!s.body)throw Error(`Work event stream has no response body.`);let l=s.body.getReader(),u=new TextDecoder,d=new K(e,t,i);try{for(;!r.aborted;){let{done:e,value:t}=await l.read();if(e)break;d.push(u.decode(t,{stream:!0}))}d.finish(u.decode())}finally{l.releaseLock()}},Y=e=>`/work/tasks/${encodeURIComponent(e)}`,X={capabilities:()=>p.get(`/work/capabilities`).then(e=>e.data),listTasks:()=>p.get(`/work/tasks`).then(e=>e.data),createTask:e=>p.post(`/work/tasks`,e).then(e=>e.data),getTask:e=>p.get(Y(e)).then(e=>e.data),getMessages:(e,t,n=200)=>p.get(`${Y(e)}/messages`,{params:{before:t,limit:n}}).then(e=>e.data),updateTask:(e,t)=>p.patch(Y(e),t).then(e=>e.data),deleteTask:e=>p.delete(Y(e)).then(e=>e.data),startRun:(e,t)=>p.post(`${Y(e)}/runs`,t).then(e=>e.data),cancelRun:e=>p.post(`${Y(e)}/cancel`).then(e=>e.data),streamRunEvents:e=>J(e),listFiles:(e,t=``)=>p.get(`${Y(e)}/files`,{params:{path:t}}).then(e=>{let t=e.data;return t.data&&!Array.isArray(t.data)?{...t,data:t.data.entries}:t}),getFile:(e,t)=>p.get(`${Y(e)}/file`,{params:{path:t}}).then(e=>e.data),saveFile:(e,t,n,r)=>p.put(`${Y(e)}/file`,{content:n,expectedUpdatedAt:r},{params:{path:t}}).then(e=>e.data),startPreview:(e,t)=>p.post(`${Y(e)}/preview/start`,t?{command:t}:{}).then(e=>e.data),stopPreview:e=>p.post(`${Y(e)}/preview/stop`).then(e=>e.data)};function Z(e,t,n){if(t)return e.find(e=>e.model===t&&(!n||e.plugin===n))}function Q(e,t,n){return Z(e,t,n)||e[0]}function te(e){return`${encodeURIComponent(e.plugin)}::${encodeURIComponent(e.model)}`}var $={getModels:()=>i()?f([{model:`tts-1`,plugin:`openai`,config:{voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`,formats:[`mp3`,`opus`,`aac`,`flac`,`wav`],default_format:`mp3`,max_characters:4096}}]):p.get(`/tts/models`).then(e=>e.data),getPlugins:()=>i()?f([{id:`openai`,name:`OpenAI GPT`,models:[`tts-1`,`tts-1-hd`],config:{voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`}}]):p.get(`/tts/plugins`).then(e=>e.data),getVoices:e=>i()?f({voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`,formats:[`mp3`,`opus`,`aac`,`flac`,`wav`],default_format:`mp3`,max_characters:4096,supports_streaming:!1}):p.get(`/tts/voices/${e}`).then(e=>e.data),generateBase64:e=>{if(i())return f({audio:``,format:e.response_format||`mp3`,mimeType:`audio/mpeg`,size:0});let t={...e,pluginId:e.pluginId||void 0};return p.post(`/tts/generate-base64`,t).then(e=>e.data)},generate:async e=>{if(i())return new Blob([],{type:`audio/mpeg`});let t={...e,pluginId:e.pluginId||void 0};return(await p.post(`/tts/generate`,t,{responseType:`blob`})).data},speak:async(e,t={})=>{try{t.onStart?.();let n=await $.generateBase64({model:t.model||`tts-1`,pluginId:t.pluginId,input:e,voice:t.voice,speed:t.speed,response_format:t.responseFormat});if(!n.success||!n.data?.audio)throw Error(n.message||`Failed to generate speech`);let r=`data:${n.data.mimeType};base64,${n.data.audio}`,i=new Audio(r);return i.onended=()=>t.onEnd?.(),i.onerror=()=>t.onError?.(Error(`Audio playback failed`)),await i.play(),i}catch(e){let n=e instanceof Error?e:Error(`Unknown error`);return t.onError?.(n),null}}},ne=e({personaApi:()=>R,preferencesApi:()=>B});export{E as _,$ as a,g as b,z as c,L as d,j as f,T as g,D as h,Q as i,R as l,O as m,Z as n,X as o,A as p,te as r,B as s,ne as t,I as u,w as v,c as x,h as y};
|