libre-webui 0.19.3 → 0.19.4

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.
Files changed (94) hide show
  1. package/backend/dist/routes/ollama.d.ts.map +1 -1
  2. package/backend/dist/routes/ollama.js +25 -0
  3. package/backend/dist/routes/ollama.js.map +1 -1
  4. package/backend/dist/routes/preferences.d.ts.map +1 -1
  5. package/backend/dist/routes/preferences.js +44 -0
  6. package/backend/dist/routes/preferences.js.map +1 -1
  7. package/backend/dist/services/chatGenerationService.d.ts +11 -0
  8. package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
  9. package/backend/dist/services/chatGenerationService.js +20 -1
  10. package/backend/dist/services/chatGenerationService.js.map +1 -1
  11. package/backend/dist/services/ollamaService.d.ts +9 -0
  12. package/backend/dist/services/ollamaService.d.ts.map +1 -1
  13. package/backend/dist/services/ollamaService.js +27 -0
  14. package/backend/dist/services/ollamaService.js.map +1 -1
  15. package/backend/dist/services/preferencesService.d.ts +7 -0
  16. package/backend/dist/services/preferencesService.d.ts.map +1 -1
  17. package/backend/dist/services/preferencesService.js +22 -0
  18. package/backend/dist/services/preferencesService.js.map +1 -1
  19. package/backend/dist/types/index.d.ts +5 -0
  20. package/backend/dist/types/index.d.ts.map +1 -1
  21. package/backend/dist/types/index.js.map +1 -1
  22. package/backend/dist/utils/ollamaModelDefaults.d.ts +39 -0
  23. package/backend/dist/utils/ollamaModelDefaults.d.ts.map +1 -0
  24. package/backend/dist/utils/ollamaModelDefaults.js +157 -0
  25. package/backend/dist/utils/ollamaModelDefaults.js.map +1 -0
  26. package/backend/package.json +1 -1
  27. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  28. package/frontend/dist/assets/index-DrcHGnwk.js +64 -0
  29. package/frontend/dist/assets/index-DtkGuqvC.css +1 -0
  30. package/frontend/dist/index.html +10 -10
  31. package/frontend/dist/js/{ArtifactContainer-DZV5ZT6g.js → ArtifactContainer-CEBbQqtg.js} +1 -1
  32. package/frontend/dist/js/{ArtifactDemoPage-BX6d2sWa.js → ArtifactDemoPage-BDTtUPjk.js} +1 -1
  33. package/frontend/dist/js/{ArtifactSandboxFrame-CSDSSxMI.js → ArtifactSandboxFrame-DOQWmEAm.js} +2 -2
  34. package/frontend/dist/js/{ArtifactSlideOutPanel-BYy4Yv_U.js → ArtifactSlideOutPanel-BMhWWM3P.js} +1 -1
  35. package/frontend/dist/js/ChatPage-B64xgIPZ.js +16 -0
  36. package/frontend/dist/js/{FirstTimeSetup-ByfcKmYo.js → FirstTimeSetup-1IqkWCsV.js} +1 -1
  37. package/frontend/dist/js/{GalleryPage-DLLiZj6X.js → GalleryPage-CKgQAYmH.js} +1 -1
  38. package/frontend/dist/js/{HomePage-DHuuGx-r.js → HomePage-aNO615Go.js} +1 -1
  39. package/frontend/dist/js/{LibreClawPage-BfCXrQ-e.js → LibreClawPage-DZqgIOgT.js} +1 -1
  40. package/frontend/dist/js/ModelSelector-DhmVTh2d.js +1 -0
  41. package/frontend/dist/js/{ModelsPage-BxLpqELH.js → ModelsPage-tzXaut3l.js} +1 -1
  42. package/frontend/dist/js/{NotesPage-BC62unJU.js → NotesPage-Ciwrazz9.js} +1 -1
  43. package/frontend/dist/js/{PersonasPage-BsOyNy8l.js → PersonasPage-C9Pkl4yH.js} +2 -2
  44. package/frontend/dist/js/{PluginUsagePage-CLpKYGwg.js → PluginUsagePage-DPfyos1y.js} +1 -1
  45. package/frontend/dist/js/{RichMessageContent-BTcjK7f1.js → RichMessageContent-CUcmvdXW.js} +1 -1
  46. package/frontend/dist/js/SettingsModal-DhrjNMcd.js +1 -0
  47. package/frontend/dist/js/{SystemPage-ZMCqqgBt.js → SystemPage-CkUsJ-UR.js} +1 -1
  48. package/frontend/dist/js/{UserManagementPage-6PsAs-Uy.js → UserManagementPage-DClRsCeA.js} +1 -1
  49. package/frontend/dist/js/{WorkPage-t7NVWt81.js → WorkPage-cJEe9LZ_.js} +4 -4
  50. package/frontend/dist/js/api-iDBo7I0x.js +19 -0
  51. package/frontend/dist/js/{appStore-ne0eCPTX.js → appStore-BAFz_6aP.js} +2 -2
  52. package/frontend/dist/js/{ar-B_uYj5Gv.js → ar-D3PgKaYD.js} +1 -1
  53. package/frontend/dist/js/{authStore-DqsiGpyN.js → authStore-2665PsVB.js} +2 -2
  54. package/frontend/dist/js/{bn-Pd4HHYsG.js → bn-DJiNo5j1.js} +1 -1
  55. package/frontend/dist/js/chatStore-fX9gMb9B.js +2 -0
  56. package/frontend/dist/js/{config-DZsEwEPX.js → config-CmH3hRFc.js} +1 -1
  57. package/frontend/dist/js/{cs-CgVXogHE.js → cs-BJ7pToPB.js} +1 -1
  58. package/frontend/dist/js/{da-DTUIrClO.js → da-Cqw35YeI.js} +1 -1
  59. package/frontend/dist/js/{de-CKITtmnY.js → de-DLw7O2DX.js} +1 -1
  60. package/frontend/dist/js/{es-DKDhsL9J.js → es-CLg6Zl_p.js} +1 -1
  61. package/frontend/dist/js/{estree-CWs-Kavs.js → estree-63s2XfPj.js} +1 -1
  62. package/frontend/dist/js/{fr-CUvNp0pc.js → fr-BUmG4BWs.js} +1 -1
  63. package/frontend/dist/js/{hi-Bwdmc__g.js → hi-CGktbsaL.js} +1 -1
  64. package/frontend/dist/js/{html-DrDcdqPC.js → html-CRbptZf3.js} +1 -1
  65. package/frontend/dist/js/{i18n-ZJQSoIuM.js → i18n-DFbHZ75-.js} +2 -2
  66. package/frontend/dist/js/{id-CWTPw3NJ.js → id-C7FnPtw9.js} +1 -1
  67. package/frontend/dist/js/{is-4dV6F4Bo.js → is-_FSS24Pj.js} +1 -1
  68. package/frontend/dist/js/{it-8uw2-j2s.js → it-DWTgF8my.js} +1 -1
  69. package/frontend/dist/js/{ja-Bl7gd3kp.js → ja-jYrlZiIs.js} +1 -1
  70. package/frontend/dist/js/{ko-C_CYwJnL.js → ko-3PZ87sc7.js} +1 -1
  71. package/frontend/dist/js/{markdown-CbB02VPB.js → markdown-C23cybKA.js} +1 -1
  72. package/frontend/dist/js/{messageCodeStyles-D1gR4Bnk.js → messageCodeStyles-BJVb4sK7.js} +1 -1
  73. package/frontend/dist/js/{ms-Dznw3AkA.js → ms-BfySq07T.js} +1 -1
  74. package/frontend/dist/js/{nl-fW-4lPWK.js → nl-DupdNsDK.js} +1 -1
  75. package/frontend/dist/js/{pl-CanprK04.js → pl-DYoPcTNe.js} +1 -1
  76. package/frontend/dist/js/{pt-JhTaVvKa.js → pt-p_-S_r1k.js} +1 -1
  77. package/frontend/dist/js/{ru-uPtHQATq.js → ru-CuJFlVPc.js} +1 -1
  78. package/frontend/dist/js/{standalone-BIvqjowG.js → standalone-BwzoPJoZ.js} +1 -1
  79. package/frontend/dist/js/{sv-yr6iqxR-.js → sv-DyZJcYOQ.js} +1 -1
  80. package/frontend/dist/js/{th-Bx4U5yKy.js → th-Cd6fTxUn.js} +1 -1
  81. package/frontend/dist/js/{tr-C7tCwYuZ.js → tr-BB1gefYF.js} +1 -1
  82. package/frontend/dist/js/{typescript-kUuRGkxH.js → typescript-CS-sPC9m.js} +1 -1
  83. package/frontend/dist/js/{ui-D4PVoJDa.js → ui-B-C2BCTb.js} +2 -2
  84. package/frontend/dist/js/{uk-C4SbiAUn.js → uk-DFURilqa.js} +1 -1
  85. package/frontend/dist/js/{vi-C3-TmuzC.js → vi-BXclLwGp.js} +1 -1
  86. package/frontend/dist/js/{zh-CRfqIC_I.js → zh-BS8f68w1.js} +1 -1
  87. package/package.json +3 -3
  88. package/frontend/dist/assets/index-ZxtmHZ3Y.js +0 -83
  89. package/frontend/dist/assets/index-mBbb8flG.css +0 -1
  90. package/frontend/dist/js/ChatPage-Bk1fO2xt.js +0 -16
  91. package/frontend/dist/js/ModelSelector-BET34RYg.js +0 -1
  92. package/frontend/dist/js/SettingsModal-ao0lVJHy.js +0 -1
  93. package/frontend/dist/js/api-F_fsjYA7.js +0 -19
  94. package/frontend/dist/js/chatStore-DRg2vRDS.js +0 -2
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CdeLZqSW.js";import{a as i,n as a,o}from"./i18n-ZJQSoIuM.js";import{Bt as s,Ct as c,E as l,F as u,Ht as d,I as f,P as p,R as m,Rt as h,Tn as g,Ut as _,V as v,Z as y,an as b,bt as x,d as S,dt as C,f as w,ft as T,gn as E,hn as D,m as O,n as ee,nn as te,o as ne,on as k,pt as A,q as j,st as M,tt as N,vt as re,x as ie,xn as ae,xt as oe,y as P,z as se,zt as ce}from"./ui-vendor-D_pYT79f.js";import{t as F}from"./logger-DSXjF4ye.js";import{a as I,b as le,c as L,g as ue,i as de,l as fe,n as pe,p as me,r as he,y as ge}from"./api-F_fsjYA7.js";import{a as _e,o as ve,s as ye,t as be}from"./imageGenModels-Dx_QMLJQ.js";import{n as xe,t as R}from"./utils-BhpNrGnR.js";import{a as Se,d as Ce,f as we,l as Te,n as Ee,o as De,p as Oe,r as ke,t as Ae,u as je}from"./chatStore-DRg2vRDS.js";import{c as Me,n as Ne}from"./authStore-DqsiGpyN.js";import{a as Pe,n as Fe,o as Ie,t as Le}from"./appStore-ne0eCPTX.js";import{l as Re}from"./messageCodeStyles-D1gR4Bnk.js";import{t as z}from"./Button-X9TT9gTD.js";import{d as B,f as ze}from"./ui-D4PVoJDa.js";import{f as Be,l as Ve,m as He,t as Ue,u as We}from"../assets/index-ZxtmHZ3Y.js";var V=e(n(),1),H=t(),Ge=[{href:`https://github.com/libre-webui/libre-webui`,icon:c,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:oe,labelKey:`settings.about.links.gitlab`,descriptionKey:`settings.about.links.gitlabDescription`},{href:`https://librewebui.org`,icon:s,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:E,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://ollama.ai`,icon:D,labelKey:`settings.about.links.ollama`,descriptionKey:`settings.about.links.ollamaDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:N,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],Ke=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function qe({appVersion:e}){let{t}=r();return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`mb-4 flex items-center gap-2.5 text-gray-900 dark:text-gray-100`,children:[(0,H.jsx)(Ve,{size:`md`,label:null}),(0,H.jsx)(We,{})]}),(0,H.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,H.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,H.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,H.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:Ke.map(e=>(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,H.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,H.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Ge.map(e=>{let n=e.icon;return(0,H.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,H.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,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,H.jsx)(s,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.href)})})]}),(0,H.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,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-gray-500 dark:text-gray-400`,children:[e.includes(`-dev`)?(0,H.jsx)(`span`,{children:t(`settings.about.version`,{version:e})}):(0,H.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,H.jsxs)(`span`,{children:[t(`settings.about.openSourceBy`,{company:``}),(0,H.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 Je=F(`components:background-upload`),Ye=({className:e=``})=>{let{t}=r(),{preferences:n,setPreferences:i,backgroundImage:a,uploadBackgroundImage:o,removeBackgroundImage:s}=Le(),c=(0,V.useRef)(null),[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(!1),p=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},m=async e=>{if(!e.type.startsWith(`image/`)){g.error(`Please select a valid image file`);return}if(e.size>5242880){g.error(`Image file size must be less than 5MB`);return}u(!0);try{await o(e),g.success(`Background image uploaded successfully`)}catch(e){Je.error(`Failed to upload background:`,e),g.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)},y=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files?.[0];t&&m(t)},b=()=>{s(),g.success(`Background image removed`)},x=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,enabled:e};if(i({backgroundSettings:n}),t||!e)try{await L.updatePreferences({backgroundSettings:n})}catch(e){Je.error(`Failed to update preferences:`,e)}},C=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,blurAmount:e};if(i({backgroundSettings:n}),t)try{await L.updatePreferences({backgroundSettings:n})}catch(e){Je.error(`Failed to update preferences:`,e)}},w=async e=>{let t=a||p.imageUrl||``,n={...p,imageUrl:t,opacity:e};if(i({backgroundSettings:n}),t)try{await L.updatePreferences({backgroundSettings:n})}catch(e){Je.error(`Failed to update preferences:`,e)}};return(0,H.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,H.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:p.enabled,onChange:e=>x(e.target.checked)}),(0,H.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,H.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,H.jsx)(`div`,{className:`relative`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,H.jsx)(`div`,{className:`flex-shrink-0`,children:(0,H.jsx)(`img`,{src:a,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:b,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,H.jsx)(ee,{className:`h-4 w-4`})})]})}):(0,H.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:y,onClick:()=>c.current?.click(),children:[(0,H.jsx)(A,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,H.jsxs)(z,{variant:`outline`,size:`sm`,disabled:l,className:`mx-auto`,children:[(0,H.jsx)(S,{className:`h-4 w-4 me-2`}),t(l?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,H.jsx)(`input`,{ref:c,type:`file`,accept:`image/*`,onChange:h,className:`hidden`})]}),a&&(0,H.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.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,H.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:p.blurAmount,onChange:e=>C(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,H.jsxs)(`div`,{children:[(0,H.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,H.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`})]})]})]})})},Xe=()=>{let{t:e,i18n:t}=r();return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(x,{className:`h-4 w-4 text-gray-500 dark:text-gray-400`}),(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.appearance.language.title`)})]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.appearance.language.description`)}),(0,H.jsx)(`select`,{"data-testid":`language-switcher-select`,value:i(t.language),onChange:e=>{let t=e.target.value;a(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:o.map(e=>(0,H.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))})]})};function Ze({theme:e,preferences:t,onThemeChange:n,onAccentChange:i,onCustomAccentChange:a,onAdaptToAccentChange:o,onShowUsernameChange:s,onShowFollowUpsChange:c,onHapticFeedbackChange:l}){let{t:u}=r(),d=e.accent||`blue`,f=e.customAccent||`#2563eb`,p=Pe(e);return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(Xe,{}),(0,H.jsx)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.appearance.title`)})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.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,H.jsx)(P,{className:`h-4 w-4`}),u(`settings.appearance.theme.light`)]}),(0,H.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,H.jsx)(y,{className:`h-4 w-4`}),u(`settings.appearance.theme.dark`)]})]}),(0,H.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-3`,children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:u(`settings.appearance.accent.title`,{defaultValue:`Accent color`})})}),(0,H.jsx)(`div`,{className:`h-9 w-9 rounded-full border border-gray-200 dark:border-dark-400 shadow-inner flex-shrink-0`,style:{backgroundColor:p},"aria-hidden":`true`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-5 xs:grid-cols-6 sm:grid-cols-9 gap-2`,children:[Fe.map(e=>{let t=d===e.id;return(0,H.jsx)(`button`,{type:`button`,onClick:()=>i(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":u(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,H.jsx)(k,{className:`absolute inset-0 m-auto h-4 w-4 drop-shadow`,style:{color:e.foreground}})},e.id)}),(0,H.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 ${d===`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:u(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":u(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,H.jsx)(`input`,{type:`color`,value:f,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,H.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:f},"aria-hidden":`true`}),(0,H.jsx)(j,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),(0,H.jsxs)(`div`,{className:`mt-5 border-t border-gray-200 pt-5 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:u(`settings.appearance.accent.behaviorTitle`)}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.behaviorDescription`)}),(0,H.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,H.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,H.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:u(`settings.appearance.accent.defaultStyle`)}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,H.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,H.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-dark-900`,children:u(`settings.appearance.accent.adaptedStyle`)}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-gray-500 dark:text-dark-500`,children:u(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:u(`settings.appearance.chatInterface.title`)}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.showUsername`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.showUsernameDescription`)})]}),(0,H.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showUsername,onChange:e=>s(e.target.checked)}),(0,H.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,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.followUpSuggestions`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.followUpSuggestionsDescription`)})]}),(0,H.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showFollowUpSuggestions!==!1,onChange:e=>c(e.target.checked)}),(0,H.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,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`})}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`settings.appearance.chatInterface.hapticFeedbackDescription`,{defaultValue:`Use subtle vibration for important mobile actions`})})]}),(0,H.jsxs)(`label`,{className:`relative inline-flex shrink-0 cursor-pointer items-center`,children:[(0,H.jsx)(`input`,{type:`checkbox`,"data-testid":`haptic-feedback-toggle`,"aria-label":u(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),className:`peer sr-only`,checked:t.hapticFeedbackEnabled===!0,onChange:e=>l(e.target.checked)}),(0,H.jsx)(`div`,{className:`peer h-6 w-11 rounded-full bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 peer-checked:bg-primary-600 after:absolute after:start-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:border after:border-gray-300 after:bg-white after:content-[''] after:transition-all peer-checked:after:translate-x-full peer-checked:after:border-white dark:border-gray-600 dark:bg-gray-700 dark:peer-focus:ring-primary-800 rtl:peer-checked:after:-translate-x-full`})]})]})]})]}),(0,H.jsx)(Ye,{})]})}function Qe(){let{t:e,i18n:t}=r(),{sessions:n,setSessionArchived:i,deleteSession:a}=Ae(),o=n.filter(e=>e.archived);return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:e(`settings.data.archivedChats.title`)}),o.length===0?(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.data.archivedChats.empty`)}):(0,H.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:o.map(n=>(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,H.jsx)(`p`,{className:`text-[11px] tabular-nums text-gray-400 dark:text-dark-500`,children:xe(n.updatedAt,t.language)})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsxs)(z,{variant:`ghost`,size:`sm`,onClick:()=>i(n.id,!1),className:`h-8 gap-1.5 px-2 text-xs`,title:e(`settings.data.archivedChats.unarchive`),children:[(0,H.jsx)(ae,{className:`h-3.5 w-3.5`}),e(`settings.data.archivedChats.unarchive`)]}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:()=>{window.confirm(e(`chat.session.deleteConfirm`))&&a(n.id)},className:`h-8 w-8 p-0 text-red-500 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20`,title:e(`chat.session.deleteChat`),children:(0,H.jsx)(O,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function $e({sessionCount:e,loading:t,importing:n,showImportOptions:i,mergeStrategy:a,importResult:o,importFileInputRef:s,onExportData:c,onImportFileSelect:l,onClearAllHistory:u,onMergeStrategyChange:d,onConfirmImport:f,onCancelImport:p,onDismissImportResult:m}){let{t:h}=r();return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:h(`settings.data.title`)}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.export`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.exportDescription`)}),(0,H.jsx)(z,{onClick:c,variant:`outline`,size:`sm`,className:`w-full`,children:h(`settings.data.exportAll`)})]}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.import`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.importDescription`)}),(0,H.jsx)(`input`,{ref:s,type:`file`,accept:`.json`,onChange:l,className:`hidden`}),(0,H.jsx)(z,{onClick:()=>s.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h(`settings.data.clearSessions`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:h(`settings.data.clearSessionsDescription`)}),(0,H.jsx)(z,{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})})]})]}),i&&(0,H.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,H.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:h(`settings.data.importOptions`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:h(`settings.data.importOptionsDescription`)}),(0,H.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,H.jsxs)(`label`,{className:`flex items-center`,children:[(0,H.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:a===`skip`,onChange:e=>d(e.target.value),className:`me-2`}),(0,H.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.skipDuplicates`)})]}),(0,H.jsxs)(`label`,{className:`flex items-center`,children:[(0,H.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:a===`overwrite`,onChange:e=>d(e.target.value),className:`me-2`}),(0,H.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:h(`settings.data.overwrite`)})]})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(z,{onClick:f,size:`sm`,disabled:n,children:h(n?`settings.data.importing`:`settings.data.import`)}),(0,H.jsx)(z,{onClick:p,variant:`outline`,size:`sm`,children:h(`common.cancel`)})]})]}),o&&(0,H.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,H.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:h(`settings.data.importResults`)}),(0,H.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,H.jsxs)(`div`,{children:[h(`settings.data.preferences`),`:`,` `,o.preferences.imported?h(`settings.data.imported`):h(`settings.data.failed`)]}),(0,H.jsxs)(`div`,{children:[h(`settings.data.sessions`),`:`,` `,o.sessions.imported,` `,h(`settings.data.importedLabel`),`,`,o.sessions.skipped,` `,h(`settings.data.skipped`)]}),(0,H.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,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsxs)(`p`,{className:`font-medium`,children:[h(`settings.data.errors`),`:`]}),o.sessions.errors.map((e,t)=>(0,H.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`session-${t}`)),o.documents.errors.map((e,t)=>(0,H.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`document-${t}`))]})]}),(0,H.jsx)(z,{onClick:m,variant:`outline`,size:`sm`,className:`mt-2`,children:h(`common.close`)})]})]})]}),(0,H.jsx)(Qe,{})]})}function U({checked:e,onChange:t,disabled:n=!1}){return(0,H.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),disabled:n,className:`sr-only`}),(0,H.jsx)(`div`,{className:R(`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,H.jsx)(`span`,{className:R(`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 et({settings:e,effectiveSettings:t,modelOptions:n,status:i,regenerating:a,onSettingChange:o,onReset:s,onRegenerate:c,onSave:l}){let{t:u}=r();return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.documents.title`)}),(0,H.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,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u(`settings.documents.embeddings.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:u(`settings.documents.embeddings.enable`)})]}),(0,H.jsx)(U,{checked:e.enabled,onChange:e=>o(`enabled`,e)})]}),e.enabled&&(0,H.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:u(`settings.documents.embeddings.model`)}),(0,H.jsx)(B,{value:t.model,onChange:e=>o(`model`,e.target.value),options:n}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:u(`settings.documents.embeddings.modelDescription`)})]}),(0,H.jsx)(nt,{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,H.jsx)(nt,{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,H.jsx)(nt,{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)})]})]}),i&&(0,H.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:u(`settings.documents.embeddings.status`)}),(0,H.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,H.jsxs)(`div`,{children:[u(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,H.jsx)(`span`,{className:i.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:i.available?u(`settings.documents.embeddings.available`):u(`settings.documents.embeddings.unavailable`)})]}),(0,H.jsxs)(`div`,{children:[u(`settings.documents.embeddings.model`),`:`,` `,(0,H.jsx)(`span`,{className:`font-medium`,children:i.model})]}),(0,H.jsxs)(`div`,{children:[u(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,H.jsxs)(`span`,{className:`font-medium`,children:[i.chunksWithEmbeddings,` / `,i.totalChunks]})]}),i.totalChunks>0&&(0,H.jsxs)(`div`,{children:[u(`settings.documents.embeddings.coverage`),`:`,` `,(0,H.jsxs)(`span`,{className:`font-medium`,children:[Math.round(i.chunksWithEmbeddings/i.totalChunks*100),`%`]})]})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(z,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),u(`settings.generation.resetDefaults`)]}),e.enabled&&i&&i.totalChunks>0&&(0,H.jsxs)(z,{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,H.jsx)(_,{size:16}),u(a?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,H.jsxs)(z,{onClick:l,className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{size:16}),u(`settings.saveSettings`)]})]}),(0,H.jsx)(tt,{})]})})}function tt(){let{t:e}=r(),t=He(),[n,i]=(0,V.useState)(``),{data:a}=Be({queryKey:[`knowledge-collections`],queryFn:async()=>{let[e,t]=await Promise.all([ge.getCollections(),ge.getDocuments()]);return{collections:e.success&&e.data?e.data:[],documents:t.success&&t.data?t.data:[]}}}),{collections:o=[],documents:s=[]}=a??{},c=()=>t.invalidateQueries({queryKey:[`knowledge-collections`]}),l=async()=>{let e=n.trim();e&&(i(``),(await ge.createCollection(e)).success&&await c())},u=async t=>{window.confirm(e(`settings.documents.collections.deleteConfirm`))&&(await ge.deleteCollection(t)).success&&await c()},d=async(e,t)=>{(await ge.setDocumentCollection(e,t)).success&&await c()};return(0,H.jsxs)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.collections.title`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.collections.description`)}),(0,H.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,H.jsx)(`input`,{value:n,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},placeholder:e(`settings.documents.collections.namePlaceholder`),className:`flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-900`}),(0,H.jsx)(z,{size:`sm`,onClick:()=>void l(),disabled:!n.trim(),children:e(`settings.documents.collections.create`)})]}),o.length>0&&(0,H.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:o.map(t=>(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:[(0,H.jsx)(E,{className:`h-3 w-3`}),t.name,(0,H.jsx)(`span`,{className:`tabular-nums text-gray-400 dark:text-dark-500`,children:t.documentCount??0}),(0,H.jsx)(`button`,{onClick:()=>void u(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,H.jsx)(ee,{className:`h-3 w-3`})})]},t.id))}),s.length>0&&o.length>0&&(0,H.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:s.map(t=>(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-gray-900 dark:text-dark-900`,children:t.filename}),(0,H.jsxs)(`select`,{value:t.collectionId??``,onChange:e=>void d(t.id,e.target.value||null),className:`rounded-lg border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,H.jsx)(`option`,{value:``,children:e(`settings.documents.collections.none`)}),o.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]},t.id))})]})}function nt({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,H.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,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function rt({generationOptions:e,embeddingSettings:t,effectiveEmbeddingSettings:n,embeddingModelOptions:i,embeddingStatus:a,onGenerationOptionChange:o,onEmbeddingSettingsChange:s,onResetGenerationOptions:c,onSaveGenerationOptions:l,onResetEmbeddingSettings:u,onSaveEmbeddingSettings:d}){let{t:p}=r(),[m,h]=(0,V.useState)(!1),g=(0,V.useId)();return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.generation.title`)}),(0,H.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.generation.description`)}),(0,H.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":m,"aria-controls":g,onClick:()=>h(e=>!e),className:`flex w-full items-center justify-between gap-4 p-4 text-left`,children:[(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.generation.advancedSettings`)}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-gray-500 dark:text-gray-400`,children:p(`settings.generation.advancedSettingsDescription`)})]}),(0,H.jsx)(b,{className:R(`h-4 w-4 flex-shrink-0 text-gray-500 transition-transform`,m&&`rotate-180`)})]}),m&&(0,H.jsxs)(`div`,{id:g,className:`space-y-6 border-t border-gray-200 p-4 dark:border-dark-300`,children:[(0,H.jsxs)(it,{title:p(`settings.generation.coreParameters`),children:[(0,H.jsx)(W,{label:p(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:p(`settings.generation.temperatureDescription`),onChange:e=>o(`temperature`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:p(`settings.generation.topPDescription`),onChange:e=>o(`top_p`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:p(`settings.generation.topKDescription`),onChange:e=>o(`top_k`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:p(`settings.generation.minPDescription`),onChange:e=>o(`min_p`,e)})]}),(0,H.jsxs)(it,{title:p(`settings.generation.generationControl`),children:[(0,H.jsx)(W,{label:p(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:p(`settings.generation.maxTokensDescription`),onChange:e=>o(`num_predict`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:p(`settings.generation.repeatPenaltyDescription`),onChange:e=>o(`repeat_penalty`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:p(`settings.generation.contextLengthDescription`),onChange:e=>o(`num_ctx`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.seed`),hint:`(${p(`settings.generation.optional`)})`,value:e.seed,placeholder:p(`settings.generation.random`),integer:!0,description:p(`settings.generation.seedDescription`),onChange:e=>o(`seed`,e)})]}),(0,H.jsxs)(it,{title:p(`settings.generation.advancedOptions`),children:[(0,H.jsx)(W,{label:p(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:p(`settings.generation.presencePenaltyDescription`),onChange:e=>o(`presence_penalty`,e)}),(0,H.jsx)(W,{label:p(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:p(`settings.generation.frequencyPenaltyDescription`),onChange:e=>o(`frequency_penalty`,e)}),(0,H.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[p(`settings.generation.stopSequences`),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,p(`settings.generation.commaSeparated`),`)`]})]}),(0,H.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,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.generation.stopSequencesDescription`)})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(z,{onClick:c,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),p(`settings.generation.resetDefaults`)]}),(0,H.jsxs)(z,{onClick:l,className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{size:16}),p(`settings.generation.saveOptions`)]})]})]})]}),(0,H.jsx)(`div`,{className:`mt-6`,children:(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.generation.embeddingSettings`)}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:p(`settings.generation.enableEmbeddings`)}),(0,H.jsx)(U,{checked:t.enabled,onChange:e=>s(`enabled`,e)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.documents.embeddings.model`)}),(0,H.jsx)(B,{value:n.model,onChange:e=>s(`model`,e.target.value),options:i,disabled:!t.enabled})]}),(0,H.jsx)(at,{label:p(`settings.documents.embeddings.chunkSize`),hint:p(`settings.documents.embeddings.chunkSizeInTokens`),value:t.chunkSize,min:1,disabled:!t.enabled,onChange:e=>s(`chunkSize`,e)}),(0,H.jsx)(at,{label:p(`settings.documents.embeddings.chunkOverlap`),hint:p(`settings.documents.embeddings.chunkOverlapInTokens`),value:t.chunkOverlap,min:0,disabled:!t.enabled,onChange:e=>s(`chunkOverlap`,e)}),(0,H.jsx)(at,{label:p(`settings.documents.embeddings.similarityThreshold`),value:t.similarityThreshold,min:0,max:1,step:.01,disabled:!t.enabled,onChange:e=>s(`similarityThreshold`,e)})]}),a&&(0,H.jsxs)(`div`,{className:`mt-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,H.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[p(`settings.documents.embeddings.status`),`:`]}),(0,H.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:a.available?p(`settings.documents.embeddings.available`):p(`settings.documents.embeddings.unavailable`)})]}),a.available&&(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,H.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[p(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,H.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[a.chunksWithEmbeddings,` /`,` `,a.totalChunks]})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,H.jsxs)(z,{onClick:u,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),p(`settings.generation.resetDefaults`)]}),(0,H.jsxs)(z,{onClick:d,className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{size:16}),p(`settings.saveSettings`)]})]})]})})]})})}function it({title:e,children:t}){return(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function W({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,H.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,H.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,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function at({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,H.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,H.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 ot({loading:e,settings:t,effectiveSettings:n,models:i,plugins:a,sizes:o,qualities:s,styles:c,onSettingChange:l,onModelChange:u,onReset:d,onSave:p}){let{t:m}=r(),h=be(i,n.model,n.pluginId);return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.imageGen.title`)}),(0,H.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:m(`settings.imageGen.description`)}),e?(0,H.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,H.jsx)(M,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,H.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:m(`settings.imageGen.loadingProviders`)})]}):i.length===0?(0,H.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,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(A,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:m(`settings.imageGen.noProviders`)}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:m(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.imageGen.enable`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.imageGen.enableDescription`)})]}),(0,H.jsx)(U,{checked:t.enabled,onChange:e=>l(`enabled`,e)})]})}),(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.imageGen.configuration`)}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.model`)}),(0,H.jsx)(B,{value:h?_e(h):``,onChange:e=>{let t=i.find(t=>_e(t)===e.target.value);t&&u(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:m(`settings.model.selectModel`)},...i.map(e=>({value:_e(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.modelDescription`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:h?.config?.size_label||m(`settings.imageGen.size`)}),(0,H.jsx)(B,{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,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.sizeDescription`)})]}),s.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.quality`)}),(0,H.jsx)(B,{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,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.qualityDescription`)})]}),c.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.imageGen.style`)}),(0,H.jsx)(B,{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,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.imageGen.styleDescription`)})]})]})]}),a.length>0&&(0,H.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:m(`settings.imageGen.availableProviders`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,H.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,H.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,H.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,m(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(z,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),m(`common.reset`)]}),(0,H.jsxs)(z,{onClick:p,className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{size:16}),m(`settings.saveSettings`)]})]})]})]})})}function st({models:e,selectedModel:t,selectedProviderType:n,selectedProviderId:i,systemMessage:a,tempSystemMessage:o,loading:s,preferences:c,currentVisionModel:l,visionModelOptions:u,currentTaskModel:d,autoTitleTaskModelOptions:f,updatingAllModels:p,updateProgress:m,onModelChange:h,onSystemMessageChange:g,onSystemMessageSave:_,onAutoTitleChange:v,onAutoTitleTaskModelChange:y,onVisionModelChange:b,onUpdateAllModels:x}){let{t:S}=r(),C={model:t,providerType:n,providerId:i},w=Te(e,C),T=t?Se(w,C):``,E=De(w,C);return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:S(`settings.model.title`)}),(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.defaultModel`)}),(0,H.jsx)(B,{value:T,onChange:h,options:[{value:``,label:S(`settings.model.selectModel`)},...w.map(e=>({value:Ee(e),label:e.isLegacySelection?`${e.name} (provider not recorded${e.isUnavailable?`, unavailable`:``})`:e.isPersona?`${e.personaName} (${S(`settings.model.persona`)})`:e.isPlugin?`${e.name} (${e.pluginName||e.pluginId}${e.isUnavailable?`, unavailable`:``})`:`${e.name} (Ollama${e.isUnavailable?`, unavailable`:``})`}))]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.defaultModelDescription`)})]}),t&&(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.currentModelInfo`)}),(0,H.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,H.jsx)(ct,{label:`${S(`settings.model.name`)}:`,value:t,truncate:!0}),E?.details&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ct,{label:`${S(`settings.model.size`)}:`,value:E.details.parameter_size}),(0,H.jsx)(ct,{label:`${S(`settings.model.family`)}:`,value:E.details.family}),(0,H.jsx)(ct,{label:`${S(`settings.model.format`)}:`,value:E.details.format})]})]})})]}),(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.systemMessage.title`)}),(0,H.jsx)(ze,{value:o,onChange:g,placeholder:S(`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,H.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:S(`settings.systemMessage.description`)}),(0,H.jsx)(z,{onClick:_,size:`sm`,disabled:s||o===a,children:S(`common.save`)})]})]})]}),(0,H.jsx)(`div`,{className:`mt-6`,children:(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.specializedModels`,{defaultValue:`Specialized Models`})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 lg:grid-cols-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.visionModel`,{defaultValue:`Vision Model`})}),(0,H.jsx)(B,{"data-testid":`vision-model-select`,value:l,onChange:e=>b(e.target.value),options:u}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.visionModelDescription`,{defaultValue:`Used automatically whenever the outgoing chat context contains images. Choose a model that supports image input.`})})]}),(0,H.jsxs)(`div`,{className:`lg:border-s lg:border-gray-200 lg:ps-5 dark:lg:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:S(`settings.model.autoTitle.enable`)}),(0,H.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:S(`settings.model.autoTitle.enableDescription`)})]}),(0,H.jsx)(U,{checked:c.titleSettings?.autoTitle||!1,onChange:v})]}),c.titleSettings?.autoTitle&&(0,H.jsxs)(`div`,{className:`mt-4`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.autoTitle.taskModel`)}),(0,H.jsx)(B,{value:d,onChange:e=>y(e.target.value),options:f}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:S(`settings.model.autoTitle.taskModelDescription`)})]})]})]})]})}),(0,H.jsx)(`div`,{className:`mt-6`,children:(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:S(`settings.model.bulkOperations`)}),(0,H.jsx)(`div`,{className:`space-y-3`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:S(`settings.model.updateAll`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:S(`settings.model.updateAllDescription`)}),p&&m&&(0,H.jsx)(lt,{progress:m}),(0,H.jsx)(z,{onClick:x,variant:`outline`,size:`sm`,className:`w-full`,disabled:p||s||e.length===0,children:p?S(`settings.model.updating`):S(`settings.model.updateAllButton`,{count:e.length})})]})})]})})]})})}function ct({label:e,value:t,truncate:n=!1}){return(0,H.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,H.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,H.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 lt({progress:e}){let{t}=r(),n=Math.round(e.current/e.total*100);return(0,H.jsxs)(`div`,{className:`mb-4 space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,H.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,H.jsxs)(`span`,{className:`text-primary-600 dark:text-primary-400 font-semibold`,children:[n,`%`]})]}),(0,H.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-3 shadow-subtle`,children:(0,H.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,H.jsxs)(`div`,{className:`text-xs flex items-center justify-between`,children:[(0,H.jsxs)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:[t(`settings.model.status`),`:`,` `,e.status===`starting`?(0,H.jsx)(`span`,{className:`text-accent-500 dark:text-accent-400`,children:t(`settings.model.statusStarting`)}):e.status===`success`?(0,H.jsx)(`span`,{className:`text-success-600 dark:text-success-500`,children:t(`settings.model.statusComplete`)}):e.status===`error`?(0,H.jsxs)(`span`,{className:`text-error-600 dark:text-error-500`,children:[t(`settings.model.statusError`),`: `,e.error]}):``]}),(0,H.jsx)(`span`,{className:`text-gray-400 dark:text-dark-600 text-[10px]`,children:t(`settings.model.modelsProgress`,{current:e.current,total:e.total})})]})]})}var ut=8;function dt(e,t){let n=e.trim();if(!n)return null;let r;try{r=new URL(n)}catch{return`invalid-url`}return r.protocol!==`http:`&&r.protocol!==`https:`?`insecure-url`:t?.toLowerCase().endsWith(`base_url`)&&(r.search||r.hash)?`query-or-fragment`:null}function ft(e){try{return new URL(e.trim()).protocol===`http:`}catch{return!1}}function pt(e){let t=e.toLowerCase();return t===`endpoint`||t===`base_url`||t===`api_url`||t===`models_endpoint`||t.endsWith(`_endpoint`)||t.endsWith(`_base_url`)}function mt(e){let t=e.trim();if(!t.startsWith(`/`)||t.startsWith(`//`)||t.includes(`://`)||t.includes(`\\`)||t.includes(`?`)||t.includes(`#`))return!1;let n=t;for(let e=0;e<=ut;e+=1){let t;try{t=decodeURIComponent(n)}catch{return!1}if(t===n)return!n.includes(`\\`)&&!n.includes(`?`)&&!n.includes(`#`)&&!n.split(`/`).some(e=>e===`.`||e===`..`);if(e===ut)return!1;n=t}return!1}var ht=new Set([`api_mode`,`api_path`,`endpoint`,`base_url`,`api_url`,`image_endpoint`,`embedding_endpoint`,`tts_endpoint`,`model`,`model_id`,`models_endpoint`]);function gt(e){let t=new Set(ht),n=e?.capabilities;for(let e of Object.values(n||{})){let n=e?.config?.endpoint_variable??e?.endpoint_variable;typeof n==`string`&&n.trim()&&t.add(n)}return t}function _t(e,t){return gt(t).has(e)}function vt(e,t){if(e.default!==void 0)return e.default;if(!t)return;if(e.name===`endpoint`||e.name===`api_url`)return t.endpoint||void 0;if(e.name===`base_url`)return t.base_url;if(e.name===`api_path`)return t.api_path;if(e.name===`api_mode`){if(t.api_mode)return t.api_mode;try{return new URL(t.endpoint).pathname.replace(/\/+$/,``).endsWith(`/responses`)?`responses`:`chat_completions`}catch{return`chat_completions`}}let n=t.capabilities;for(let t of Object.values(n||{}))if((t?.config?.endpoint_variable??t?.endpoint_variable)===e.name&&typeof t.endpoint==`string`)return t.endpoint}function yt(e,t){let n=[],r=[];for(let i of e)(_t(i.name,t)?n:r).push(i);return{connection:n,advanced:r}}function G(e,t){let n={};for(let r of e){let e=t[r.name];n[r.name]=e?.has_value&&!e.is_sensitive?e.value:``}return n}function bt(e,t,n,r,i){let a=new Set(e.map(e=>e.name)),o={},s=[];for(let c of n){if(!a.has(c))continue;let n=e.find(e=>e.name===c);if(!n)continue;let l=t[c],u=r[c],d=typeof l==`string`&&l.trim().length===0,f=vt(n,i),p=f!==void 0&&(typeof l==`string`&&typeof f==`string`?l.trim()===f.trim():Object.is(l,f));if(d||p){if(n.sensitive&&u?.has_value)continue;u?.has_value&&s.push(c);continue}o[c]=l}return{variables:o,unset:s}}F(`components:hugging-face-model-browser`);var xt=({plugin:e})=>{let{t}=r(),n=Ne(e=>e.user),i=Ne(e=>e.systemInfo)?.requiresAuth===!1||n?.role===`admin`,{pluginVariables:a,fetchPluginVariables:o,updatePluginVariables:s,resetPluginVariables:c,loadPlugins:l}=Me(),[d,p]=(0,V.useState)({}),[m,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1),[x,S]=(0,V.useState)(new Set),[C,T]=(0,V.useState)({}),[E,D]=(0,V.useState)(new Set),[O,ee]=(0,V.useState)(!1),te=V.useId(),ne=V.useId(),k=(0,V.useMemo)(()=>e.variables||[],[e.variables]),A=(0,V.useMemo)(()=>gt(e),[e]),j=(0,V.useMemo)(()=>i?k:k.filter(e=>!A.has(e.name)),[i,A,k]),M=(0,V.useMemo)(()=>a[e.id]||{},[a,e.id]),N=(0,V.useMemo)(()=>yt(j,e),[e,j]);(0,V.useEffect)(()=>{o(e.id)},[o,e.id]);let re=JSON.stringify(M),ie=(0,V.useRef)(null);(0,V.useEffect)(()=>{let t=j.map(e=>`${e.name}:${e.type}`).join(`|`),n=`${e.id}:${t}:${re}`;if(ie.current===n)return;ie.current=n;let r=JSON.parse(re);p(e=>{let t=G(j,r);for(let n of E)n in e&&(t[n]=e[n]);return t})},[E,e.id,j,re]);let ae=async()=>{let n={};for(let r of j){if(!E.has(r.name))continue;let i=d[r.name],a=typeof i==`string`&&i.trim().length===0,o=M[r.name],s=vt(r,e);if(a&&r.required&&s===void 0&&!(r.sensitive&&o?.has_value)){n[r.name]=t(`pluginManager.variables.required`,`A value is required`);continue}if(pt(r.name)&&typeof i==`string`&&!a){let e=dt(i,r.name);e===`invalid-url`?n[r.name]=t(`pluginManager.variables.invalidUrl`,`Enter a valid full API endpoint URL, for example https://provider.example/v1/chat/completions`):e===`insecure-url`?n[r.name]=t(`pluginManager.variables.insecureUrl`,`API endpoints must use HTTP or HTTPS.`):e===`query-or-fragment`&&(n[r.name]=t(`pluginManager.variables.invalidBaseUrl`,`Base URLs cannot contain a query string or fragment.`))}if(r.name===`api_path`&&typeof i==`string`&&i.length>0&&!mt(i)&&(n[r.name]=t(`pluginManager.variables.invalidApiPath`,`Must start with / and contain no URL, query, fragment, or .. segment`)),r.type===`number`&&!a){let e=Number(i);r.min!==void 0&&e<r.min&&(n[r.name]=`Min: ${r.min}`),r.max!==void 0&&e>r.max&&(n[r.name]=`Max: ${r.max}`)}r.type===`string`&&typeof i==`string`&&i.length>2048&&(n[r.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(T(n),Object.keys(n).length>0)return;let r=bt(j,d,E,M,e),i=new Set(E),a=Object.fromEntries([...Object.keys(r.variables).map(e=>[e,!0]),...r.unset.map(e=>[e,!0])]);if(Object.keys(r.variables).length===0&&r.unset.length===0){D(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),T(e=>{let t={...e};for(let e of i)delete t[e];return t}),g.success(t(`pluginManager.variables.saved`,`Variables saved`));return}_(!0);try{await s(e.id,r.variables,r.unset)?(Object.keys(a).some(e=>A.has(e))&&await l(),p(e=>{let t={...e};for(let e of j)e.sensitive&&i.has(e.name)&&(t[e.name]=``);return t}),S(e=>{let t=new Set(e);for(let e of j)e.sensitive&&i.has(e.name)&&t.delete(e.name);return t}),D(e=>{let t=new Set(e);for(let e of i)t.delete(e);return t}),T(e=>{let t={...e};for(let e of i)delete t[e];return t}),g.success(t(`pluginManager.variables.saved`,`Variables saved`))):g.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))}finally{_(!1)}},oe=async()=>{y(!0);try{if(!await c(e.id)){g.error(t(`pluginManager.variables.resetFailed`,`Failed to reset variables`));return}j.some(e=>A.has(e.name))&&await l(),p(G(j,{})),D(new Set),T({}),S(new Set),g.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))}finally{y(!1)}},P=(e,t)=>{p(n=>({...n,[e]:t})),D(t=>new Set(t).add(e)),T(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},se=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=e=>{let t=j.indexOf(e),n=`${ne}-${t}`;return{controlId:n,descriptionId:`${n}-description`,errorId:`${n}-error`,warningId:`${n}-http-warning`}},I=t=>{if(!pt(t.name))return!1;let n=d[t.name],r=vt(t,e),i=typeof n==`string`&&n.trim()?n:r;return typeof i==`string`&&ft(i)},le=n=>{let r=d[n.name],i=n.sensitive??!1,a=x.has(n.name),o=M[n.name],{controlId:s,descriptionId:c,errorId:l,warningId:u}=F(n),f=!!C[n.name],p=I(n),g=n.name===`endpoint`||n.name===`api_url`,_=[n.description||g?c:void 0,p?u:void 0,f?l:void 0].filter(Boolean).join(` `)||void 0,y=vt(n,e),b=y===void 0?t(`pluginManager.variables.inherited`,`Use provider default`):t(`pluginManager.variables.inheritedValue`,{defaultValue:`Use provider default ({{value}})`,value:String(y)}),S=R(`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(n.type){case`boolean`:return(0,H.jsxs)(`select`,{id:s,value:r===``?``:String(!!r),onChange:e=>P(n.name,e.target.value===``?``:e.target.value===`true`),className:S,"aria-invalid":f,"aria-describedby":_,disabled:m||v,children:[(0,H.jsx)(`option`,{value:``,children:b}),(0,H.jsx)(`option`,{value:`true`,children:t(`pluginManager.variables.enabled`,`Enabled`)}),(0,H.jsx)(`option`,{value:`false`,children:t(`pluginManager.variables.disabled`,`Disabled`)})]});case`select`:return(0,H.jsxs)(`select`,{id:s,value:String(r??``),onChange:e=>P(n.name,e.target.value),className:S,"aria-invalid":f,"aria-describedby":_,disabled:m||v,children:[(0,H.jsx)(`option`,{value:``,children:b}),(n.options||[]).map(e=>(0,H.jsx)(`option`,{value:e,children:e},e))]});case`number`:return(0,H.jsx)(`input`,{id:s,type:`number`,value:r===``?``:Number(r),min:n.min,max:n.max,placeholder:b,onChange:e=>P(n.name,e.target.value===``?``:Number(e.target.value)),className:S,"aria-invalid":f,"aria-describedby":_,disabled:m||v});default:return(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`input`,{id:s,type:i&&!a?`password`:`text`,value:i&&o?.has_value&&r===``?``:String(r??``),placeholder:i&&o?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):b,onChange:e=>P(n.name,e.target.value),className:R(S,i&&`pr-10`),"aria-invalid":f,"aria-describedby":_,disabled:m||v}),i&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>se(n.name),"aria-controls":s,"aria-label":a?t(`pluginManager.variables.hideValue`,{defaultValue:`Hide {{label}} value`,label:n.label}):t(`pluginManager.variables.showValue`,{defaultValue:`Show {{label}} value`,label:n.label}),disabled:m||v,className:`absolute end-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:text-gray-300`,children:a?(0,H.jsx)(ce,{className:`w-4 h-4`}):(0,H.jsx)(h,{className:`w-4 h-4`})})]})}},L=e=>{let{controlId:n,descriptionId:r,errorId:i,warningId:a}=F(e),o=e.name===`endpoint`||e.name===`api_url`,s=I(e);return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{htmlFor:n,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[o?t(`pluginManager.variables.fullApiEndpoint`,`Full API endpoint URL`):e.label,e.required&&(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-red-500 ml-1`,children:`*`})]}),(e.description||o)&&(0,H.jsxs)(`p`,{id:r,className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:[e.description,e.description&&o&&` `,o&&t(`pluginManager.variables.endpointHelp`,`Enter the complete request URL, including its operation path (for example, /v1/chat/completions), not only the provider base URL.`)]}),le(e),s&&(0,H.jsxs)(`p`,{id:a,role:`status`,className:`mt-1 flex items-start gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,H.jsx)(w,{"aria-hidden":`true`,className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{children:t(`pluginManager.variables.httpWarning`,`HTTP does not encrypt credentials or traffic. Use it only on a trusted network.`)})]}),C[e.name]&&(0,H.jsx)(`p`,{id:i,role:`alert`,className:`text-xs text-red-500 mt-1`,children:C[e.name]})]},e.name)};return(0,H.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[N.connection.length>0&&(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:t(`pluginManager.variables.connection`,`Connection`)}),N.connection.map(L)]}),N.advanced.length>0&&(0,H.jsxs)(`div`,{className:R(N.connection.length>0&&`mt-4 border-t pt-4`,`border-gray-200 dark:border-gray-700`),children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":O,"aria-controls":te,onClick:()=>ee(e=>!e),className:`flex w-full items-center justify-between rounded-md py-1 text-left text-sm font-medium text-gray-700 hover:text-gray-950 dark:text-gray-300 dark:hover:text-white`,children:[(0,H.jsxs)(`span`,{children:[t(`pluginManager.variables.advanced`,`Advanced parameters`),` (`,N.advanced.length,`)`]}),(0,H.jsx)(b,{className:R(`h-4 w-4 transition-transform`,O&&`rotate-180`)})]}),O&&(0,H.jsx)(`div`,{id:te,className:`mt-3 space-y-3`,children:N.advanced.map(L)})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,H.jsxs)(z,{size:`sm`,onClick:ae,disabled:m||v||E.size===0,className:`gap-1.5`,children:[(0,H.jsx)(u,{className:`w-3.5 h-3.5`}),m?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,H.jsxs)(z,{variant:`outline`,size:`sm`,onClick:oe,disabled:m||v,className:`gap-1.5`,children:[(0,H.jsx)(f,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function St({plugins:e,loading:t,uploading:n,error:i,hasKeys:a,showUploadForm:o,showJsonForm:s,jsonInput:c,fileInputRef:l,expandedPluginId:u,pluginApiKeys:d,showApiKey:f,savingApiKey:m,refreshingPluginIds:h,onClearError:g,onShowUploadFormChange:_,onShowJsonFormChange:v,onJsonInputChange:y,onFileUpload:b,onJsonSubmit:x,onExpandedPluginChange:C,onPluginApiKeyChange:w,onShowApiKeyChange:T,onActivatePlugin:E,onDeletePlugin:D,onExportPlugin:O,onSaveApiKey:te,onDeleteApiKey:ne,onRefreshModels:k}){let{t:A}=r(),j=Ne(e=>e.user),N=Ne(e=>e.systemInfo)?.requiresAuth===!1||j?.role===`admin`,[re,ie]=(0,V.useState)(``),[ae,oe]=(0,V.useState)(null),P=(0,V.useId)(),ce=(0,V.useMemo)(()=>e.filter(e=>we(e,re)),[e,re]),F=ae&&e.some(e=>e.id===ae)?ae:e[0]?.id??null,I=e.find(e=>e.id===F)??null,le=e=>{e!==F&&(C(null),oe(e))};return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:A(`settings.plugins.providerConnections`,{defaultValue:`Provider connections`})}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:A(`settings.plugins.providerConnectionsDescription`,{defaultValue:`Connect, configure, and inspect model providers through plugins.`})})]}),i&&(0,H.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,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:i}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:g,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,H.jsx)(ee,{className:`h-4 w-4`})})]})}),N&&(0,H.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,H.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:A(`settings.plugins.addNew`)}),(0,H.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,H.jsxs)(z,{variant:`outline`,size:`sm`,onClick:()=>_(!o),disabled:t||n,children:[(0,H.jsx)(S,{className:`h-4 w-4 me-2`}),A(`settings.plugins.upload`)]}),(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>v(!s),disabled:t,children:A(`settings.plugins.addJson`)})]})]}),o&&(0,H.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,H.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,H.jsx)(`input`,{ref:l,type:`file`,accept:`.json,.zip`,onChange:b,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,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>_(!1),disabled:n,children:A(`common.cancel`)})]}),n&&(0,H.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:A(`settings.plugins.uploading`)})]}),s&&(0,H.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(`textarea`,{value:c,onChange:e=>y(e.target.value),placeholder:A(`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,H.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:()=>{v(!1),y(``)},children:A(`common.cancel`)}),(0,H.jsx)(z,{size:`sm`,onClick:x,disabled:!c.trim()||t,children:A(`settings.plugins.install`)})]})]})})]}),(0,H.jsx)(`div`,{"data-testid":`provider-workspace`,className:`overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:(0,H.jsxs)(`div`,{className:`grid min-h-[30rem] grid-cols-1 lg:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.6fr)]`,children:[(0,H.jsxs)(`section`,{"data-testid":`provider-list`,"aria-label":A(`settings.plugins.providers`,{defaultValue:`Providers`}),className:`border-b border-gray-200 dark:border-dark-300 lg:border-b-0 lg:border-e`,children:[(0,H.jsxs)(`div`,{className:`border-b border-gray-200 p-4 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:A(`settings.plugins.providers`,{defaultValue:`Providers`})}),(0,H.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600 dark:bg-dark-200 dark:text-gray-300`,children:e.length})]}),(0,H.jsx)(`label`,{htmlFor:P,className:`sr-only`,children:A(`settings.plugins.searchProviders`,{defaultValue:`Search providers`})}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(p,{"aria-hidden":`true`,className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,H.jsx)(`input`,{id:P,type:`search`,value:re,onChange:e=>ie(e.target.value),placeholder:A(`settings.plugins.searchProviders`,{defaultValue:`Search providers`}),className:`w-full rounded-lg border border-gray-300 bg-white py-2 pe-3 ps-9 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]})]}),(0,H.jsx)(`div`,{className:`max-h-[32rem] space-y-2 overflow-y-auto p-3`,children:t&&e.length===0?(0,H.jsxs)(`div`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:[(0,H.jsx)(M,{className:`mx-auto mb-2 h-5 w-5 animate-spin`}),A(`settings.plugins.loading`)]}):e.length===0?(0,H.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,H.jsx)(se,{className:`mx-auto mb-3 h-9 w-9 text-gray-400`}),(0,H.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:A(`settings.plugins.noPlugins`)}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-gray-500`,children:A(`settings.plugins.noPluginsDescription`)})]}):ce.length===0?(0,H.jsx)(`p`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:A(`settings.plugins.noProvidersFound`,{defaultValue:`No providers match your search.`})}):ce.map(e=>{let t=F===e.id,n=Ce(e).length;return(0,H.jsx)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>le(e.id),className:`w-full rounded-xl border p-3 text-start transition-colors ${t?`border-blue-500 bg-blue-50/70 dark:border-blue-500 dark:bg-blue-950/20`:`border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:hover:border-dark-400 dark:hover:bg-dark-50`}`,children:(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`span`,{className:`sr-only`,children:[e.active?A(`settings.plugins.activeLabel`):A(`settings.plugins.inactive`),`.`,` `]}),(0,H.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,H.jsxs)(`span`,{className:`mt-0.5 block text-xs capitalize text-gray-500 dark:text-gray-400`,children:[e.type,` · `,n,` `,A(`settings.plugins.models`)]})]})]})},e.id)})})]}),(0,H.jsx)(`section`,{"data-testid":`provider-detail`,className:`min-w-0 p-4 sm:p-5`,children:I?(0,H.jsx)(Ct,{plugin:I,loading:t,hasApiKey:a[I.id]||!1,expanded:u===I.id,apiKey:d[I.id]||``,showApiKey:f[I.id]||!1,savingApiKey:m===I.id,refreshingModels:!!h[I.id],canManagePlugin:N,onExpand:()=>C(u===I.id?null:I.id),onActivate:()=>E(I.id),onExport:()=>O(I.id),onDelete:()=>D(I.id),onRefreshModels:()=>k(I.id),onApiKeyChange:e=>w(I.id,e),onShowApiKeyChange:e=>T(I.id,e),onSaveApiKey:()=>te(I.id),onDeleteApiKey:()=>ne(I.id)}):(0,H.jsx)(`div`,{className:`flex min-h-[24rem] items-center justify-center text-center`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(se,{className:`mx-auto mb-3 h-10 w-10 text-gray-400`}),(0,H.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:A(`settings.plugins.selectProvider`,{defaultValue:`Select a provider`})}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:A(`settings.plugins.selectProviderDescription`,{defaultValue:`Choose a provider to inspect its connection and model catalog.`})})]})})})]})})]})})}function Ct({plugin:e,loading:t,hasApiKey:n,expanded:i,apiKey:a,showApiKey:o,savingApiKey:s,refreshingModels:c,canManagePlugin:u,onExpand:f,onActivate:p,onExport:m,onDelete:h,onRefreshModels:g,onApiKeyChange:_,onShowApiKeyChange:v,onSaveApiKey:y,onDeleteApiKey:x}){let{t:S}=r(),w=!!(e.auth?.header||e.auth?.key_env),T=gt(e),E=u?e.variables||[]:(e.variables||[]).filter(e=>!T.has(e.name)),D=E.length>0,ee=w||D,ne=(0,V.useId)(),A=Ce(e),j=e.base_url||e.endpoint;return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-gray-200 pb-4 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,H.jsx)(`h4`,{className:`truncate text-lg font-semibold text-gray-900 dark:text-gray-100`,children:e.name})]}),(0,H.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e.id,` · `,(0,H.jsx)(`span`,{className:`capitalize`,children:e.type}),w&&n&&(0,H.jsxs)(`span`,{className:`text-green-600`,children:[` `,`· `,S(`settings.plugins.apiKeySet`)]})]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[ee&&(0,H.jsxs)(z,{variant:`outline`,size:`sm`,onClick:f,"aria-expanded":i,"aria-controls":ne,title:S(`settings.plugins.configure`),className:n?`text-green-600`:``,children:[w?(0,H.jsx)(C,{className:`h-4 w-4`}):(0,H.jsx)(l,{className:`h-4 w-4`}),S(`settings.plugins.configure`),i?(0,H.jsx)(te,{className:`h-3 w-3`}):(0,H.jsx)(b,{className:`h-3 w-3`})]}),(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:p,disabled:t,className:e.active?`border-green-300 text-green-600`:``,children:e.active?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(k,{className:`h-4 w-4`}),S(`settings.plugins.deactivate`)]}):S(`settings.plugins.activate`)}),u&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:m,disabled:t,title:S(`settings.plugins.exportPlugin`,`Export plugin`),className:`px-2`,children:(0,H.jsx)(d,{className:`h-4 w-4`})}),(0,H.jsx)(z,{variant:`ghost`,size:`sm`,onClick:h,disabled:t,className:`px-2 text-red-600 hover:bg-red-50 hover:text-red-700`,title:S(`settings.plugins.deletePlugin`,`Delete plugin`),children:(0,H.jsx)(O,{className:`h-4 w-4`})})]})]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,H.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:S(`settings.plugins.status`,{defaultValue:`Status`})}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:e.active?S(`settings.plugins.activeLabel`):S(`settings.plugins.inactive`)})]}),(0,H.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:S(`settings.plugins.models`)}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:A.length})]}),(0,H.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:S(`settings.plugins.defaultEndpoint`,{defaultValue:`Default endpoint`})}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-sm text-gray-900 dark:text-gray-100`,title:j,children:j})]})]})]}),i&&ee&&(0,H.jsxs)(`div`,{id:ne,children:[w&&(0,H.jsx)(wt,{plugin:e,hasApiKey:n,apiKey:a,showApiKey:o,savingApiKey:s,onApiKeyChange:_,onShowApiKeyChange:v,onSaveApiKey:y,onDeleteApiKey:x}),D&&(0,H.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-dark-300 dark:bg-dark-50`,children:[(0,H.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,H.jsx)(l,{className:`h-4 w-4 text-gray-500`}),(0,H.jsxs)(`h5`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[S(`settings.plugins.providerSettings`),` (`,E.length,`)`]})]}),(0,H.jsx)(xt,{plugin:e},e.id)]})]}),(0,H.jsx)(K,{catalog:A,canRefresh:Oe(e),refreshing:c,onRefresh:g})]})}function K({catalog:e,canRefresh:t,refreshing:n,onRefresh:i}){let{t:a}=r();return(0,H.jsxs)(`section`,{"data-testid":`provider-model-catalog`,className:`mt-5`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h5`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:a(`settings.plugins.modelCatalog`,{defaultValue:`Model catalog`})}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:a(`settings.plugins.modelCatalogDescription`,{defaultValue:`Discovered and configured models for this provider and its capabilities.`})})]}),t&&(0,H.jsxs)(z,{variant:`outline`,size:`sm`,onClick:i,disabled:n,"aria-busy":n,children:[n?(0,H.jsx)(M,{className:`h-4 w-4 animate-spin`}):(0,H.jsx)(m,{className:`h-4 w-4`}),a(`settings.plugins.refreshModels`,{defaultValue:`Refresh models`})]})]}),e.length===0?(0,H.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-dark-300 dark:text-gray-400`,children:a(`settings.plugins.noModelsConfigured`,{defaultValue:`No models are configured for this provider.`})}):(0,H.jsx)(`div`,{className:`max-h-[26rem] overflow-auto rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`table`,{className:`w-full min-w-[24rem] text-start text-sm`,children:[(0,H.jsx)(`thead`,{className:`sticky top-0 z-10 bg-gray-50 text-xs uppercase tracking-wide text-gray-500 dark:bg-dark-50 dark:text-gray-400`,children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:a(`settings.plugins.modelId`,{defaultValue:`Model ID`})}),(0,H.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:a(`settings.plugins.capabilities`,{defaultValue:`Capabilities`})})]})}),(0,H.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-xs text-gray-900 dark:text-gray-100`,children:e.id}),(0,H.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,H.jsx)(`span`,{className:`rounded-md bg-blue-50 px-2 py-0.5 text-xs text-blue-700 dark:bg-blue-950/30 dark:text-blue-300`,children:a(`settings.plugins.capability.${e.toLowerCase()}`,{defaultValue:e})},e))})})]},e.id))})]})})]})}function wt({plugin:e,hasApiKey:t,apiKey:n,showApiKey:i,savingApiKey:a,onApiKeyChange:o,onShowApiKeyChange:s,onSaveApiKey:c,onDeleteApiKey:l}){let{t:u}=r(),d=(0,V.useId)();return(0,H.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,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,H.jsx)(C,{className:`h-4 w-4 text-gray-500`}),(0,H.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.plugins.apiKeyConfiguration`)})]}),(0,H.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[u(`settings.plugins.apiKeyDescription`,{name:e.name,defaultValue:`Store a personal API key for {{name}}.`}),e.auth?.key_env&&(0,H.jsxs)(`span`,{className:`block mt-1`,children:[u(`settings.plugins.apiKeyEnvAlternative`),` `,(0,H.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,u(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,H.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,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{className:`h-4 w-4 text-green-600`}),(0,H.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:u(`settings.plugins.apiKeyConfigured`)})]}),(0,H.jsx)(z,{variant:`outline`,size:`sm`,onClick:l,disabled:a,className:`text-red-600 border-red-300 hover:bg-red-50`,children:a?(0,H.jsx)(M,{className:`h-4 w-4 animate-spin`}):u(`common.remove`)})]}):(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(`label`,{htmlFor:d,className:`sr-only`,children:u(`settings.plugins.apiKey.title`)}),(0,H.jsx)(`input`,{id:d,type:i?`text`:`password`,value:n,onChange:e=>o(e.target.value),placeholder:u(`settings.plugins.apiKeyPlaceholder`),disabled:a,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,H.jsx)(`button`,{type:`button`,onClick:()=>s(!i),"aria-controls":d,"aria-label":u(i?`settings.plugins.hideApiKey`:`settings.plugins.showApiKey`),disabled:a,className:`absolute end-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50`,children:i?(0,H.jsx)(ce,{className:`h-4 w-4`}):(0,H.jsx)(h,{className:`h-4 w-4`})})]}),(0,H.jsx)(`div`,{className:`flex justify-end`,children:(0,H.jsx)(z,{size:`sm`,onClick:c,disabled:a||!n.trim(),children:a?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(M,{className:`h-4 w-4 me-2 animate-spin`}),u(`common.saving`)]}):u(`settings.plugins.saveApiKey`)})})]})]})}function Tt({loading:e,settings:t,effectiveSettings:n,models:i,plugins:a,voices:o,testing:s,onSettingChange:c,onModelChange:l,onReset:u,onTest:d,onSave:p}){let{t:m}=r(),h=i.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,H.jsx)(`div`,{className:`space-y-6`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.tts.title`)}),(0,H.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:m(`settings.tts.description`)}),e?(0,H.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,H.jsx)(M,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,H.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:m(`settings.tts.loadingProviders`)})]}):i.length===0?(0,H.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,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(ne,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:m(`settings.tts.noProviders`)}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:m(`settings.tts.noProvidersDescription`)})]})]})}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.enable`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.enableDescription`)})]}),(0,H.jsx)(U,{checked:t.enabled,onChange:e=>c(`enabled`,e)})]})}),(0,H.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.autoPlay`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.autoPlayDescription`)})]}),(0,H.jsx)(U,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>c(`autoPlay`,e)})]})}),(0,H.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.streamSentences`)}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.streamSentencesDescription`)})]}),(0,H.jsx)(U,{checked:t.streamSentences||!1,disabled:!t.enabled,onChange:e=>c(`streamSentences`,e)})]})}),(0,H.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.tts.voiceConfiguration`)}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.tts.model`)}),(0,H.jsx)(B,{"aria-label":m(`settings.tts.model`),value:h?he(h):``,onChange:e=>{let t=i.find(t=>he(t)===e.target.value);t&&l(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:m(`settings.model.selectModel`)},...i.map(e=>({value:he(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.tts.modelDescription`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.tts.voice`)}),(0,H.jsx)(B,{"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,H.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.tts.voiceDescription`)})]})]})]}),a.length>0&&(0,H.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:m(`settings.tts.availableProviders`)}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:a.map(e=>(0,H.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,H.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,H.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,m(`settings.tts.models`),`)`]})]},e.id))})]}),(0,H.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(z,{onClick:u,variant:`outline`,className:`flex items-center gap-2`,children:[(0,H.jsx)(f,{size:16}),m(`common.reset`)]}),(0,H.jsx)(z,{onClick:d,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:s?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ie,{size:16}),m(`settings.tts.stop`)]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(v,{size:16}),m(`settings.tts.test`)]})})]}),(0,H.jsxs)(z,{onClick:p,className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{size:16}),m(`settings.saveSettings`)]})]})]})]})})}function Et({preferences:e,sessions:t,loadPreferences:n,loadSessions:r}){let[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(`skip`),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(null),h=()=>{p(null),m.current&&(m.current.value=``)};return{importing:i,showImportOptions:o,mergeStrategy:c,setMergeStrategy:l,importResult:u,setImportResult:d,importFileInputRef:m,handleExportData:()=>{let n={format:`libre-webui-export`,version:`1.0`,preferences:e,sessions:t,documents:[],exportedAt:new Date().toISOString()},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`libre-webui-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),g.success(`Data exported successfully`)},handleImportFileSelect:e=>{let t=e.target.files?.[0];t&&(p(t),s(!0),d(null))},handleConfirmImport:async()=>{if(f){a(!0);try{let e=await f.text(),t=JSON.parse(e);if(!t.format||t.format!==`libre-webui-export`)throw Error(`Invalid export format. Please use a valid Libre WebUI export file.`);let i=await L.importData(t,c===`overwrite`?`replace`:`merge`);if(i.success&&i.data)d({preferences:{imported:!0,error:null},sessions:{imported:0,skipped:0,errors:[]},documents:{imported:0,skipped:0,errors:[]}}),g.success(`Data imported successfully`),await n(),await r();else throw Error(i.error||`Import failed`)}catch(e){g.error(e instanceof Error?e.message:`Import failed`),d(null)}finally{a(!1),s(!1),h()}}},handleCancelImport:()=>{s(!1),d(null),h()}}}var Dt=Ue()||`0.0.0`,Ot=`__current_running_model__`,kt={enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},At={enabled:!1,autoPlay:!1,model:``,voice:``,speed:1,pluginId:``,streamSentences:!1},jt={enabled:!1,model:``,size:`1024x1024`,quality:`standard`,style:`vivid`,pluginId:``},Mt=({isOpen:e,onClose:t})=>{let{models:n,selectedModel:i,selectedProviderType:a,selectedProviderId:o,setSelectedModel:s,systemMessage:c,setSystemMessage:u,clearAllSessions:d,loading:f,sessions:m,loadModels:h,loadSessions:v}=Ae(),{theme:y,updateTheme:b,preferences:x,setPreferences:S,loadPreferences:C}=Le(),{plugins:w,isLoading:E,isUploading:O,error:te,loadPlugins:k,uploadPlugin:M,deletePlugin:N,activatePlugin:ie,deactivatePlugin:ae,exportPlugin:oe,clearError:P,installPlugin:ce}=Me(),{t:F}=r(),he=V.useId(),_e=Te(n,{model:i,providerType:a,providerId:o}),xe={model:x.titleSettings?.taskModel||``,providerType:x.titleSettings?.taskProviderType,providerId:x.titleSettings?.taskProviderId},Ce=Te(n,xe),we=xe.model===Ot?Ot:xe.model?Se(Ce,xe):``,De={model:x.visionModel||``,providerType:x.visionProviderType,providerId:x.visionProviderId},Oe=Te(n,De),Ne=De.model?Se(Oe,De):``,Pe=[{value:``,label:F(`settings.model.selectVisionModel`,{defaultValue:`Use the current chat model`})},...Oe.map(e=>({value:Ee(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:e.isAgent?`${e.agentName||e.name} · Agent CLI${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],Fe=[{value:``,label:F(`settings.model.autoTitle.selectTaskModel`)},{value:Ot,label:`Use current running model`},...Ce.map(e=>({value:Ee(e),label:e.isLegacySelection?`${e.name} · provider not recorded${e.isUnavailable?` (unavailable)`:``}`:e.isPersona?`${e.personaName||e.name} (persona)`:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}${e.isUnavailable?` (unavailable)`:``}`:`${e.name} · Ollama${e.isUnavailable?` (unavailable)`:``}`}))],[B,ze]=(0,V.useState)(`appearance`),[Ve,Ue]=(0,V.useState)(``),[We,Ge]=(0,V.useState)(c),[Ke,Je]=(0,V.useState)(!1),[Ye,Xe]=(0,V.useState)(null),[Qe,U]=(0,V.useState)(!1),[tt,nt]=(0,V.useState)(!1),[it,W]=(0,V.useState)(``),at=(0,V.useRef)(null),[ct,lt]=(0,V.useState)(null),[ut,dt]=(0,V.useState)({}),[ft,pt]=(0,V.useState)({}),[mt,ht]=(0,V.useState)(null),[gt,_t]=(0,V.useState)({}),[vt,yt]=(0,V.useState)(x.generationOptions||{}),[G,bt]=(0,V.useState)(x.embeddingSettings||kt),[xt,Ct]=(0,V.useState)(!1),[K,wt]=(0,V.useState)(x.ttsSettings||At),[Mt,Nt]=(0,V.useState)(!1),Pt=(0,V.useRef)(null),[q,Ft]=(0,V.useState)(x.imageGenSettings||jt),{importing:It,showImportOptions:Lt,mergeStrategy:Rt,setMergeStrategy:zt,importResult:Bt,setImportResult:Vt,importFileInputRef:Ht,handleExportData:Ut,handleImportFileSelect:Wt,handleConfirmImport:Gt,handleCancelImport:Kt}=Et({preferences:x,sessions:m,loadPreferences:C,loadSessions:v}),J=He(),{data:qt={}}=Be({queryKey:[`plugin-credentials`],queryFn:async()=>{let e=await fe.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=[]}=Be({queryKey:[`embedding-models`],queryFn:async()=>{let e=await le.getModels();return e.success&&e.data?e.data:[]},enabled:e}),Y=(0,V.useMemo)(()=>{let e=Jt.find(e=>e.id===G.model||e.rawModel===G.model);return e&&e.id!==G.model?{...G,model:e.id}:G},[Jt,G]),{data:Yt=null}=Be({queryKey:[`embedding-status`],queryFn:async()=>{let e=await ge.getEmbeddingStatus();return e.success&&e.data?e.data:null},enabled:e}),{data:Xt,isLoading:Zt}=Be({queryKey:[`tts-data`],queryFn:async()=>{let[e,t]=await Promise.all([I.getModels(),I.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),X=(0,V.useMemo)(()=>Xt?.models??[],[Xt]),Qt=Xt?.plugins??[],$t=(0,V.useMemo)(()=>de(X,K.model,K.pluginId),[X,K.model,K.pluginId]),Z=(0,V.useMemo)(()=>{if(!$t)return K;let e=pe(X,K.model,K.pluginId);return e&&K.pluginId===e.plugin?K:{...K,model:$t.model,pluginId:$t.plugin,voice:$t.config?.default_voice||``}},[$t,X,K]),en=(0,V.useMemo)(()=>pe(X,Z.model,Z.pluginId)?.config?.voices??[],[Z,X]),{data:tn,isLoading:nn}=Be({queryKey:[`image-gen-data`],queryFn:async()=>{let[e,t]=await Promise.all([ue.getModels(),ue.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Q=(0,V.useMemo)(()=>tn?.models??[],[tn]),rn=(0,V.useMemo)(()=>tn?.plugins??[],[tn]),$=(0,V.useMemo)(()=>ve(Q,q.model,q.pluginId),[Q,q.model,q.pluginId]),an=(0,V.useMemo)(()=>{if(!$)return q;let e=be(Q,q.model,q.pluginId);return e&&q.pluginId===e.plugin?q:{...q,model:$.model,pluginId:$.plugin,size:ye($.config?.sizes,q.size,$.config?.default_size,`1024x1024`),quality:ye($.config?.qualities,q.quality,$.config?.default_quality,`standard`),style:ye($.config?.styles,q.style,$.config?.default_style,`vivid`)}},[Q,q,$]),on=$?.config?.sizes??[],sn=$?.config?.qualities??[],cn=$?.config?.styles??[],ln=(0,V.useRef)(!1),un=(0,V.useRef)(c);(0,V.useEffect)(()=>{if(!e){ln.current=!1;return}ln.current&&un.current===c||(ln.current=!0,un.current=c,Ge(c),yt(x.generationOptions||{}),bt(x.embeddingSettings||kt),wt(x.ttsSettings||At),Ft(x.imageGenSettings||jt))},[e,x.embeddingSettings,x.generationOptions,x.imageGenSettings,x.ttsSettings,c]);let dn=(0,V.useRef)(!1);(0,V.useEffect)(()=>{if(!e){dn.current=!1;return}dn.current||(dn.current=!0,k(),h())},[e,k,h]),(0,V.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 fn=async e=>{let t=ut[e];if(!t?.trim()){g.error(`Please enter an API key`);return}ht(e);try{let n=await fe.setApiKey(e,t.trim());n.success?(g.success(`API key saved successfully`),await J.invalidateQueries({queryKey:[`plugin-credentials`]}),await k(),await J.invalidateQueries({queryKey:[`image-gen-data`]}),dt(t=>({...t,[e]:``})),pt(t=>({...t,[e]:!1}))):g.error(n.error||`Failed to save API key`)}catch{g.error(`Failed to save API key`)}finally{ht(null)}},pn=async e=>{ht(e);try{let t=await fe.deleteApiKey(e);t.success?(g.success(`API key removed`),await J.invalidateQueries({queryKey:[`plugin-credentials`]}),await k(),await J.invalidateQueries({queryKey:[`image-gen-data`]}),dt(t=>({...t,[e]:``}))):g.error(t.error||`Failed to remove API key`)}catch{g.error(`Failed to remove API key`)}finally{ht(null)}},mn=(e,t)=>{let n=pe(X,e,t);n&&wt(r=>({...r,model:e,pluginId:t,voice:n.config?.default_voice||r.voice}))},hn=(e,t)=>{let n=be(Q,e,t);n&&Ft(t=>({...t,model:e,pluginId:n.plugin,size:ye(n.config?.sizes,t.size,n.config?.default_size,`1024x1024`),quality:ye(n.config?.qualities,t.quality,n.config?.default_quality,`standard`),style:ye(n.config?.styles,t.style,n.config?.default_style,`vivid`)}))},gn=(e,t)=>{wt(n=>({...n,[e]:t}))},_n=async()=>{try{let e=await L.updatePreferences({ttsSettings:Z});e.success&&e.data&&(S(e.data),g.success(`TTS settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to save TTS settings: `+t)}},vn=async()=>{if(Mt){let e=Pt.current;e&&(e.pause(),e.currentTime=0,Pt.current=null),Nt(!1);return}Nt(!0);try{let e=await I.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:$t?.config?.default_format});if(e.success&&e.data?.audio){let t=`data:${e.data.mimeType};base64,${e.data.audio}`,n=new Audio(t);Pt.current=n,n.onended=()=>{Nt(!1),Pt.current=null},n.onerror=()=>{g.error(`Failed to play audio`),Nt(!1),Pt.current=null},await n.play()}else throw Error(e.message||`Failed to generate speech`)}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`TTS test failed: `+t),Nt(!1)}},yn=()=>{wt({enabled:!1,autoPlay:!1,model:X[0]?.model||``,voice:X[0]?.config?.default_voice||``,speed:1,pluginId:X[0]?.plugin||``,streamSentences:!1})},bn=(e,t)=>{Ft(n=>({...n,[e]:t}))},xn=async()=>{try{let e=await L.updatePreferences({imageGenSettings:an});e.success&&e.data&&(S(e.data),g.success(`Image generation settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to save image generation settings: `+t)}},Sn=()=>{Ft({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||``})},Cn=async()=>{try{Ct(!0),(await ge.regenerateEmbeddings()).success&&(g.success(`Embeddings regenerated successfully`),await J.invalidateQueries({queryKey:[`embedding-status`]}))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to regenerate embeddings: `+t)}finally{Ct(!1)}},wn=async e=>{try{let t=await L.updatePreferences(e);t.success&&t.data&&(S(t.data),g.success(`Settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)}},Tn=async e=>{let t=e.target.files?.[0];t&&(await M(t),U(!1),at.current&&(at.current.value=``),await h(),await J.invalidateQueries({queryKey:[`image-gen-data`]}))},En=async()=>{try{let e=JSON.parse(it);await ce(e),nt(!1),W(``),await h(),await J.invalidateQueries({queryKey:[`image-gen-data`]})}catch{P(),g.error(`Invalid JSON format`)}},Dn=async e=>{w.find(t=>t.id===e)?.active?await ae(e):await ie(e),await h(),await J.invalidateQueries({queryKey:[`image-gen-data`]})},On=async e=>{if(!gt[e]){_t(t=>({...t,[e]:!0}));try{let t=await fe.discoverModels(e);if(!t.success||!t.data){g.error(t.error||F(`settings.plugins.modelCatalogRefreshFailed`));return}await Promise.all([k(),h()]);let{outcome:n,models:r,reason:i}=t.data;n===`updated`?g.success(F(`settings.plugins.modelCatalogUpdated`,{count:r.length})):n===`unchanged`?g.success(F(`settings.plugins.modelCatalogUnchanged`)):n===`missing_credentials`?g.error(i||F(`settings.plugins.modelCatalogNeedsApiKey`)):g.error(i?`${F(`settings.plugins.modelCatalogUnavailable`)} ${i}`:F(`settings.plugins.modelCatalogUnavailable`))}catch(e){g.error(je(e,F(`settings.plugins.modelCatalogRefreshFailed`)))}finally{_t(t=>{let n={...t};return delete n[e],n})}}},kn=async e=>{window.confirm(`Are you sure you want to delete this plugin?`)&&(await N(e),await h(),await J.invalidateQueries({queryKey:[`image-gen-data`]}))},An=async e=>{await oe(e)};if(!e)return null;let jn=e=>{let t=Le.getState().theme,n=Ie({...t,mode:e});b(n)},Mn=e=>{let t=Le.getState().theme,n=Ie({...t,accent:e});b(n)},Nn=e=>{let t=Le.getState().theme,n=Ie({...t,accent:`custom`,customAccent:e});b(n)},Pn=e=>{let t=Le.getState().theme,n=Ie({...t,adaptToAccent:e});b(n)},Fn=e=>{S({showUsername:e}),L.updatePreferences({showUsername:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)})},In=e=>{S({showFollowUpSuggestions:e}),L.updatePreferences({showFollowUpSuggestions:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)})},Ln=e=>{S({hapticFeedbackEnabled:e}),e&&Re(`selection`),L.updatePreferences({hapticFeedbackEnabled:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)})},Rn=e=>{if(!e.target.value){Ae.setState({selectedModel:``,selectedProviderType:null,selectedProviderId:null}),wn({defaultModel:``,defaultProviderType:null,defaultProviderId:null});return}let t=ke(_e,e.target.value);t&&(s(t.model,t.providerType,t.providerId),S({defaultModel:t.model,defaultProviderType:t.providerType,defaultProviderId:t.providerId}),g.success(`Default model updated`))},zn=e=>{Ge(e.target.value)},Bn=()=>{u(We),wn({systemMessage:We}),g.success(`System message updated`)},Vn=async()=>{window.confirm(`Are you sure you want to delete all chat history? This action cannot be undone.`)&&(await d(),g.success(`All chat sessions deleted`))},Hn=async()=>{Je(!0),Xe(null),me.pullAllModelsStream(e=>{Xe(e)},()=>{Je(!1),Xe(null),g.success(`All models updated successfully!`),h()},e=>{Je(!1),Xe(null),g.error(`Failed to update models: `+e)})},Un=e=>{let t={...x.titleSettings,autoTitle:e,taskModel:x.titleSettings?.taskModel||``};S({titleSettings:t}),L.updatePreferences({titleSettings:t})},Wn=e=>{if(!e){let e={visionModel:``,visionProviderType:null,visionProviderId:null};S(e),L.updatePreferences(e);return}let t=ke(Oe,e);if(!t?.providerType){g.error(F(`settings.model.visionModelNoProvider`));return}let n={visionModel:t.model,visionProviderType:t.providerType,visionProviderId:t.providerId||null};S(n),L.updatePreferences(n).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(F(`settings.model.visionModelUpdateFailed`,{error:t}))})},Gn=e=>{let t=e&&e!==Ot?ke(Ce,e):null,n={...x.titleSettings,autoTitle:x.titleSettings?.autoTitle||!1,taskModel:t?.model||e,taskProviderType:t?.providerType||null,taskProviderId:t?.providerType===`plugin`&&t.providerId||null};S({titleSettings:n}),L.updatePreferences({titleSettings:n})},Kn=(e,t)=>{dt(n=>({...n,[e]:t}))},qn=(e,t)=>{pt(n=>({...n,[e]:t}))},Jn=(e,t)=>{yt(n=>({...n,[e]:t}))},Yn=async()=>{try{let e=await L.setGenerationOptions(vt);e.success&&e.data&&(S(e.data),g.success(`Generation options updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update generation options: `+t)}},Xn=async()=>{try{let e=await L.resetGenerationOptions();e.success&&e.data&&(S(e.data),yt(e.data.generationOptions||{}),g.success(`Generation options reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to reset generation options: `+t)}},Zn=(e,t)=>{bt(n=>({...n,[e]:t}))},Qn=[...Jt.map(e=>({value:e.id,label:`${e.name} (${e.pluginName||e.provider})`})),...!Jt.find(e=>e.id===Y.model||e.rawModel===Y.model)&&Y.model?[{value:Y.model,label:`${Y.model} (current)`}]:[]],$n=async()=>{try{let e=await L.setEmbeddingSettings(Y);e.success&&e.data&&(S(e.data),g.success(`Embedding settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update embedding settings: `+t)}},er=async()=>{try{let e=await L.resetEmbeddingSettings();e.success&&e.data&&(S(e.data),bt(e.data.embeddingSettings||{}),g.success(`Embedding settings reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to reset embedding settings: `+t)}},tr={appearance:`theme dark light accent color language username follow-up background interface`,data:`export import backup clear history sessions`,about:`version license update`,models:`default model system prompt title vision auto`,generation:`temperature top_p top_k seed tokens context penalty embedding chunk similarity`,documents:`upload pdf rag document embedding`,tts:`voice speech audio speak read aloud`,"image-gen":`image generation size quality style`,plugins:`api key provider connection openai anthropic groq gemini`},nr=Ve.trim().toLowerCase(),rr=e=>!nr||e.label.toLowerCase().includes(nr)||(tr[e.id]||``).includes(nr),ir=[{id:`general`,label:F(`settings.groups.general`,`General`),tabs:[{id:`appearance`,label:F(`settings.tabs.appearance`),icon:j},{id:`data`,label:F(`settings.tabs.data`),icon:re},{id:`about`,label:F(`settings.tabs.about`),icon:T}]},{id:`chat`,label:F(`settings.groups.chat`,`Chat`),tabs:[{id:`models`,label:F(`settings.tabs.model`),icon:D},{id:`generation`,label:F(`settings.tabs.generation`),icon:l},{id:`documents`,label:F(`settings.tabs.documents`),icon:_}]},{id:`media`,label:F(`settings.groups.media`,`Speech & images`),tabs:[{id:`tts`,label:F(`settings.tabs.tts`),icon:ne},{id:`image-gen`,label:F(`settings.tabs.imageGen`),icon:A}]},{id:`connections`,label:F(`settings.groups.connections`,`Connections`),tabs:[{id:`plugins`,label:F(`settings.tabs.plugins`),icon:se}]}];return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/55 backdrop-blur-sm transition-opacity duration-200`,onClick:t}),(0,H.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":he,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,H.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,H.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,H.jsx)(`h2`,{id:he,className:`text-xl font-normal tracking-[-0.025em] text-gray-950 dark:text-dark-950 sm:text-2xl rtl:tracking-normal`,children:F(`settings.title`)}),(0,H.jsx)(z,{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:F(`common.close`,{defaultValue:`Close`}),children:(0,H.jsx)(ee,{className:`h-5 w-5 sm:h-4 sm:w-4`})})]}),(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overscroll-behavior-contain sm:flex-row`,children:[(0,H.jsxs)(`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,H.jsxs)(`div`,{className:`relative mb-1 hidden sm:block`,children:[(0,H.jsx)(p,{className:`pointer-events-none absolute start-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-subtle`}),(0,H.jsx)(`input`,{type:`search`,value:Ve,onChange:e=>{let t=e.target.value;Ue(t);let n=t.trim().toLowerCase();if(!n)return;let r=ir.flatMap(e=>e.tabs).filter(e=>e.label.toLowerCase().includes(n)||(tr[e.id]||``).includes(n));r.length>0&&!r.some(e=>e.id===B)&&ze(r[0].id)},placeholder:F(`common.search`),className:`w-full rounded-lg border border-transparent bg-black/[0.04] py-1.5 pe-2.5 ps-8 text-[13px] text-ink placeholder:text-ink-subtle focus:border-primary-500/40 focus:outline-none dark:bg-white/[0.05]`})]}),(0,H.jsx)(`nav`,{className:`flex gap-1 sm:flex-col sm:gap-0`,role:`tablist`,"aria-label":F(`settings.title`,`Settings`),children:ir.map(e=>({...e,tabs:e.tabs.filter(rr)})).filter(e=>e.tabs.length>0).map(e=>(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-1 sm:flex-col sm:gap-0.5 sm:pb-2`,children:[(0,H.jsx)(`p`,{"aria-hidden":`true`,className:`hidden px-2.5 pb-1 pt-2 text-[10px] font-medium uppercase tracking-[0.08em] text-ink-subtle sm:block`,children:e.label}),e.tabs.map(e=>{let t=e.icon,n=B===e.id;return(0,H.jsxs)(`button`,{onClick:()=>ze(e.id),className:R(`flex shrink-0 items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-start transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 sm:w-full`,n?`bg-black/[0.06] text-ink dark:bg-white/[0.08]`:`text-ink-muted hover:bg-black/[0.04] hover:text-ink dark:hover:bg-white/[0.05]`),role:`tab`,"aria-selected":n,"aria-controls":`settings-tab-panel`,children:[(0,H.jsx)(t,{className:`h-4 w-4 flex-shrink-0`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`truncate whitespace-nowrap text-[13px]`,children:e.label})]},e.id)})]},e.id))})]}),(0,H.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(B){case`appearance`:return(0,H.jsx)(Ze,{theme:y,preferences:x,onThemeChange:jn,onAccentChange:Mn,onCustomAccentChange:Nn,onAdaptToAccentChange:Pn,onShowUsernameChange:Fn,onShowFollowUpsChange:In,onHapticFeedbackChange:Ln});case`models`:return(0,H.jsx)(st,{models:n,selectedModel:i,selectedProviderType:a,selectedProviderId:o,systemMessage:c,tempSystemMessage:We,loading:f,preferences:x,currentVisionModel:Ne,visionModelOptions:Pe,currentTaskModel:we,autoTitleTaskModelOptions:Fe,updatingAllModels:Ke,updateProgress:Ye,onModelChange:Rn,onSystemMessageChange:zn,onSystemMessageSave:Bn,onAutoTitleChange:Un,onAutoTitleTaskModelChange:Gn,onVisionModelChange:Wn,onUpdateAllModels:Hn});case`tts`:return(0,H.jsx)(Tt,{loading:Zt,settings:K,effectiveSettings:Z,models:X,plugins:Qt,voices:en,testing:Mt,onSettingChange:gn,onModelChange:mn,onReset:yn,onTest:vn,onSave:_n});case`image-gen`:return(0,H.jsx)(ot,{loading:nn,settings:q,effectiveSettings:an,models:Q,plugins:rn,sizes:on,qualities:sn,styles:cn,onSettingChange:bn,onModelChange:hn,onReset:Sn,onSave:xn});case`documents`:return(0,H.jsx)(et,{settings:G,effectiveSettings:Y,modelOptions:Qn,status:Yt,regenerating:xt,onSettingChange:Zn,onReset:er,onRegenerate:Cn,onSave:$n});case`plugins`:return(0,H.jsx)(St,{plugins:w,loading:E,uploading:O,error:te,hasKeys:qt,showUploadForm:Qe,showJsonForm:tt,jsonInput:it,fileInputRef:at,expandedPluginId:ct,pluginApiKeys:ut,showApiKey:ft,savingApiKey:mt,refreshingPluginIds:gt,onClearError:P,onShowUploadFormChange:U,onShowJsonFormChange:nt,onJsonInputChange:W,onFileUpload:Tn,onJsonSubmit:En,onExpandedPluginChange:lt,onPluginApiKeyChange:Kn,onShowApiKeyChange:qn,onActivatePlugin:Dn,onRefreshModels:On,onDeletePlugin:kn,onExportPlugin:An,onSaveApiKey:fn,onDeleteApiKey:pn});case`data`:return(0,H.jsx)($e,{sessionCount:m.length,loading:f,importing:It,showImportOptions:Lt,mergeStrategy:Rt,importResult:Bt,importFileInputRef:Ht,onExportData:Ut,onImportFileSelect:Wt,onClearAllHistory:Vn,onMergeStrategyChange:zt,onConfirmImport:Gt,onCancelImport:Kt,onDismissImportResult:()=>Vt(null)});case`about`:return(0,H.jsx)(qe,{appVersion:Dt});case`generation`:return(0,H.jsx)(rt,{generationOptions:vt,embeddingSettings:G,effectiveEmbeddingSettings:Y,embeddingModelOptions:Qn,embeddingStatus:Yt,onGenerationOptionChange:Jn,onEmbeddingSettingsChange:Zn,onResetGenerationOptions:Xn,onSaveGenerationOptions:Yn,onResetEmbeddingSettings:er,onSaveEmbeddingSettings:$n});default:return null}})()})]})]})})]})};export{Mt as SettingsModal};
@@ -1,19 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/authStore-DqsiGpyN.js","js/rolldown-runtime-hePW80VL.js","js/router-vendor-Ca9zqOqT.js","js/markdown-core-DHnR5Hw8.js","js/utils-vendor-1zob7nK9.js","js/logger-DSXjF4ye.js","js/chatStore-DRg2vRDS.js","js/ui-vendor-D_pYT79f.js","js/utils-BhpNrGnR.js","js/appStore-ne0eCPTX.js"])))=>i.map(i=>d[i]);
2
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,p as n}from"./router-vendor-Ca9zqOqT.js";import{a as r}from"./utils-vendor-1zob7nK9.js";import{i,t as a}from"./logger-DSXjF4ye.js";import{n as o,t as s}from"./config-DZsEwEPX.js";var c=a(`api`);o(),c.debug(`User agent:`,navigator.userAgent),c.debug(`Demo mode detected:`,i());var l=(e,t=!0)=>new Promise(n=>{setTimeout(()=>{n({success:t,data:e,error:t?void 0:`Demo mode: Backend not available`})},500)}),u=r.create({baseURL:s,timeout:3e5});u.interceptors.request.use(e=>{let t=localStorage.getItem(`auth-token`);return t&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e)),u.interceptors.response.use(e=>e,e=>{if(e.response?.status===401){c.warn(`Session expired or unauthorized, logging out...`),localStorage.removeItem(`auth-token`),t(async()=>{let{useAuthStore:e}=await import(`./authStore-DqsiGpyN.js`).then(e=>e.t);return{useAuthStore:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).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 c.error(`API Error:`,e),Promise.reject(e)});var d={getModels:()=>i()?l([]):u.get(`/agent-clis/models`).then(e=>e.data)},f=`0.19.3`,p={login:e=>i()?l({user:{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:f}}):u.post(`/auth/login`,e).then(e=>e.data),signup:e=>i()?l({user:{id:`demo-user-new`,username:e.username,email:e.email||``,role:`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token-new`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:f,turnstile:{enabled:!1}}}):u.post(`/auth/signup`,e).then(e=>e.data),logout:()=>i()?l(void 0):u.post(`/auth/logout`).then(e=>e.data),getSystemInfo:()=>(c.debug(`getSystemInfo called, demo mode:`,i()),i()?l({requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:f,turnstile:{enabled:!1}}):(c.debug(`Making API call to:`,s+`/auth/system-info`),c.debug(`Full URL from:`,window.location.origin,`-> API:`,s+`/auth/system-info`),u.get(`/auth/system-info`).then(e=>(c.debug(`getSystemInfo response:`,e.data),e.data)).catch(e=>{throw c.debug(`getSystemInfo error:`,e),e.response&&(c.debug(`Error response data:`,e.response.data),c.debug(`Error status:`,e.response.status),c.debug(`Error headers:`,e.response.headers)),e.request&&c.debug(`Network error - no response received:`,e.request),c.debug(`Error config:`,e.config),e}))),verifyToken:()=>i()?l({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):u.get(`/auth/verify`).then(e=>e.data),getEncryptionKey:()=>i()?l({encryptionKey:`demo-encryption-key-not-real`}):u.get(`/auth/encryption-key`).then(e=>e.data)},m={getUsers:()=>i()?l([{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]):u.get(`/users`).then(e=>e.data),createUser:e=>i()?l({id:`new-user-`+Date.now(),username:e.username,email:e.email,role:e.role,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):u.post(`/users`,e).then(e=>e.data),updateUser:(e,t)=>i()?l({id:e,username:t.username||`demo`,email:t.email||`demo@example.com`,role:t.role||`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):u.patch(`/users/${e}`,t).then(e=>e.data),deleteUser:e=>i()?l(void 0):u.delete(`/users/${e}`).then(e=>e.data),getPendingApprovals:()=>i()?l({count:0,latestCreatedAt:null}):u.get(`/users/pending-approvals`).then(e=>e.data),approveUser:e=>i()?l({id:e,username:`demo-user`,email:`demo@example.com`,role:`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):u.patch(`/users/${e}/approve`).then(e=>e.data),updateMyAvatar:e=>i()?l({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,avatar:e,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):u.patch(`/users/me/avatar`,{avatar:e}).then(e=>e.data)},h=[{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`}}],g=()=>[{id:`demo-session-1`,title:`Demo Chat Session`,model:h[0].name,providerType:`ollama`,providerId:null,messages:[{id:`demo-msg-1`,role:`user`,content:`Hello! Can you tell me about this demo?`,timestamp:Date.now()},{id:`demo-msg-2`,role:`assistant`,content:`This is a demo of Libre WebUI! In a real deployment, I would be powered by Ollama running locally on your machine. This demo shows the beautiful interface and features without the backend connection.`,timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()}],_=g(),v={theme:{mode:`dark`,adaptToAccent:!1,accent:`blue`,customAccent:`#2563eb`},defaultModel:`llama3.2:3b`,defaultProviderType:`ollama`,defaultProviderId:null,visionModel:``,visionProviderType:null,visionProviderId:null,systemMessage:`You are a helpful assistant.`,generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},titleSettings:{autoTitle:!1,taskModel:``,taskProviderType:null,taskProviderId:null},showUsername:!1,hapticFeedbackEnabled:!1,workRemoteProviderDisclosureDismissed:!1,backgroundSettings:{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6}},y={...v,theme:{...v.theme},generationOptions:{...v.generationOptions},embeddingSettings:{...v.embeddingSettings},titleSettings:{...v.titleSettings},backgroundSettings:{...v.backgroundSettings}},b=()=>y,x=e=>{let t=y.backgroundSettings||v.backgroundSettings;return y={...y,...e,theme:{...y.theme,...e.theme},generationOptions:{...y.generationOptions,...e.generationOptions},embeddingSettings:{...y.embeddingSettings,...e.embeddingSettings},titleSettings:e.titleSettings?{...y.titleSettings||v.titleSettings,...e.titleSettings}:y.titleSettings,backgroundSettings:e.backgroundSettings?{...t,...e.backgroundSettings}:y.backgroundSettings},y},S={getSessions:()=>u.get(`/chat/sessions`).then(e=>e.data),createSession:(e,t,n,r,i)=>u.post(`/chat/sessions`,{model:e,title:t,personaId:n,providerType:r,providerId:i}).then(e=>e.data),getSession:e=>{if(i()){let t=g().find(t=>t.id===e);return t?l(t):Promise.resolve({success:!1,error:`Session not found in demo mode`})}return u.get(`/chat/sessions/${e}`).then(e=>e.data)},updateSession:(e,t)=>{if(i()){let n=_.findIndex(t=>t.id===e),r=_[n];if(r){let e={...r,...t,updatedAt:Date.now()};return _[n]=e,l(e)}return Promise.resolve({success:!1,error:`Session not found in demo mode`})}return u.put(`/chat/sessions/${e}`,t).then(e=>e.data)},deleteSession:e=>i()?l(null):u.delete(`/chat/sessions/${e}`).then(e=>e.data),clearAllSessions:()=>u.delete(`/chat/sessions`).then(e=>e.data),generateTitle:(e,t,n,r,a)=>i()?l({title:n.substring(0,30)+(n.length>30?`...`:``),source:`fallback`,updatedAt:Date.now()}):u.post(`/chat/sessions/${e}/generate-title`,{model:t,message:n,providerType:r,providerId:a}).then(e=>e.data),getFolders:()=>i()?l([]):u.get(`/chat/folders`).then(e=>e.data),createFolder:e=>u.post(`/chat/folders`,{name:e}).then(e=>e.data),renameFolder:(e,t)=>u.put(`/chat/folders/${e}`,{name:t}).then(e=>e.data),deleteFolder:e=>u.delete(`/chat/folders/${e}`).then(e=>e.data),generateFollowUps:e=>i()?l({suggestions:[]}):u.post(`/chat/sessions/${e}/followups`).then(e=>e.data),sendMessage:(e,t,n)=>u.post(`/chat/sessions/${e}/messages`,{content:t,options:n}).then(e=>e.data),saveMessage:(e,t)=>u.post(`/chat/sessions/${e}/messages`,t).then(e=>e.data),updateMessage:(e,t,n)=>i()?l({}):u.put(`/chat/sessions/${e}/messages/${t}`,n).then(e=>e.data),generateChatResponse:(e,t,n)=>u.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(`${s}/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 l=o.body?.getReader();if(!l)throw Error(`No response body reader available`);let u=new TextDecoder,d=``,f=()=>{l.read().then(({done:e,value:t})=>{if(e){a?.();return}d+=u.decode(t,{stream:!0});let n=d.split(`
3
- `);d=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){c.error(`Failed to parse SSE data:`,e)}}}f()}).catch(e=>{i?.(e instanceof Error?e:Error(String(e)))})};return f(),()=>l.cancel()}catch(e){return i?.(e instanceof Error?e:Error(String(e))),()=>{}}}}),getMessageBranches:(e,t)=>i()?l([]):u.get(`/chat/sessions/${e}/messages/${t}/branches`).then(e=>e.data),switchMessageBranch:(e,t,n)=>i()?l({}):u.post(`/chat/sessions/${e}/messages/${t}/branch`,{branchIndex:n}).then(e=>e.data),createMessageBranch:(e,t,n)=>i()?l({}):u.post(`/chat/sessions/${e}/messages/${t}/branches`,{...n}).then(e=>e.data)},C={uploadDocument:(e,t)=>{if(i())return l({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),u.post(`/documents/upload`,n).then(e=>e.data)},getCollections:()=>i()?l([]):u.get(`/documents/collections`).then(e=>e.data),createCollection:e=>u.post(`/documents/collections`,{name:e}).then(e=>e.data),deleteCollection:e=>u.delete(`/documents/collections/${e}`).then(e=>e.data),setDocumentCollection:(e,t)=>u.put(`/documents/${e}/collection`,{collectionId:t}).then(e=>e.data),fetchWebpage:(e,t)=>i()?l({id:`demo-doc-`+Date.now(),filename:`demo-webpage.txt`,fileType:`txt`,size:0,sessionId:t,uploadedAt:Date.now()}):u.post(`/documents/fetch-url`,{url:e,sessionId:t}).then(e=>e.data),getDocuments:e=>{if(i())return l([]);let t=e?`/documents/session/${e}`:`/documents`;return u.get(t).then(e=>e.data)},getDocument:e=>i()?l({id:e,filename:`demo-document.pdf`,fileType:`pdf`,size:1024,content:`Demo document content...`,uploadedAt:Date.now()}):u.get(`/documents/${e}`).then(e=>e.data),searchDocuments:(e,t,n)=>i()?l([]):u.post(`/documents/search`,{query:e,sessionId:t,limit:n}).then(e=>e.data),deleteDocument:e=>i()?l(void 0):u.delete(`/documents/${e}`).then(e=>e.data),getEmbeddingStatus:()=>i()?l({available:!1,model:`nomic-embed-text`,chunksWithEmbeddings:0,totalChunks:0}):u.get(`/documents/embeddings/status`).then(e=>e.data),regenerateEmbeddings:()=>i()?l(void 0):u.post(`/documents/embeddings/regenerate`).then(e=>e.data)},w={getModels:()=>i()?l([{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]):u.get(`/embeddings/models`).then(e=>e.data)},T={getNotes:()=>i()?l([]):u.get(`/notes`).then(e=>e.data),createNote:(e,t)=>u.post(`/notes`,{title:e,content:t}).then(e=>e.data),updateNote:(e,t)=>u.put(`/notes/${e}`,t).then(e=>e.data),deleteNote:e=>u.delete(`/notes/${e}`).then(e=>e.data)},ee={getModels:e=>i()?l([{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}]):u.get(`/huggingface-hub/models`,{params:e}).then(e=>e.data),getTrending:e=>i()?l([]):u.get(`/huggingface-hub/trending`,{params:e}).then(e=>e.data),getModel:(e,t)=>i()?l({id:`${e}/${t}`,modelId:`${e}/${t}`,author:e,downloads:0,likes:0,tags:[],gated:!1}):u.get(`/huggingface-hub/models/${e}/${t}`).then(e=>e.data),getTasks:()=>i()?l([`text-generation`,`text-to-speech`,`text-to-image`]):u.get(`/huggingface-hub/tasks`).then(e=>e.data),clearCache:()=>i()?l(!0):u.post(`/huggingface-hub/cache/clear`).then(e=>e.data),getGgufFiles:(e,t)=>i()?l([{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`}]):u.get(`/huggingface-hub/models/${e}/${t}/gguf`).then(e=>e.data),hasGgufFiles:(e,t)=>i()?l({hasGguf:!1,count:0}):u.get(`/huggingface-hub/models/${e}/${t}/has-gguf`).then(e=>e.data)},E={getModels:()=>i()?l([{model:`gpt-image-2`,plugin:`openai`,config:{sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}}]):u.get(`/image-gen/models`).then(e=>e.data),getPlugins:()=>i()?l([{id:`openai`,name:`OpenAI GPT Image`,models:[`gpt-image-2`,`gpt-image-1.5`,`gpt-image-1`,`gpt-image-1-mini`],config:{sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}}]):u.get(`/image-gen/plugins`).then(e=>e.data),getConfig:e=>i()?l({sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}):u.get(`/image-gen/config/${e}`).then(e=>e.data),generate:e=>i()?l({images:[{url:`https://placehold.co/1024x1024/purple/white?text=Demo+Image`,revised_prompt:e.prompt}],model:e.model,pluginId:e.pluginId}):u.post(`/image-gen/generate`,e).then(e=>e.data),getGallery:e=>i()?l({images:[],total:0}):u.get(`/image-gen/gallery`,{params:e}).then(e=>e.data),getGalleryImage:e=>i()?l({id:e,userId:`demo`,prompt:`Demo image prompt`,model:`dall-e-3`,imageData:`https://placehold.co/1024x1024/purple/white?text=Demo`,createdAt:Date.now()}):u.get(`/image-gen/gallery/${e}`).then(e=>e.data),deleteGalleryImage:e=>i()?l(void 0):u.delete(`/image-gen/gallery/${e}`).then(e=>e.data)},D={connected:!1,baseUrl:`http://127.0.0.1:8766`,dashboardUrl:`http://127.0.0.1:8766/dashboard`,error:`Libre Claw daemon is not connected in demo mode.`},O={status:()=>i()?l(D):u.get(`/libre-claw/status`).then(e=>e.data),dashboard:()=>i()?l({url:D.dashboardUrl}):u.get(`/libre-claw/dashboard`).then(e=>e.data),currentModel:()=>i()?l({provider:`openrouter`,model:`openrouter/auto`}):u.get(`/libre-claw/config/model`).then(e=>e.data),updateModel:(e,t,n=!1)=>i()?l({provider:e,model:t,persist_global:n}):u.patch(`/libre-claw/config/model`,{provider:e,model:t,persist_global:n}).then(e=>e.data),currentFallback:()=>i()?l({enabled:!1,routes:[]}):u.get(`/libre-claw/config/fallback`).then(e=>e.data),updateFallback:e=>i()?l(e):u.patch(`/libre-claw/config/fallback`,e).then(e=>e.data),updateTheme:(e,t=!0)=>i()?l({theme:e,label:e,persist_global:t}):u.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()?l({summary:{},records:[],text:``}):u.get(`/libre-claw/usage?${n.toString()}`).then(e=>e.data)},listRuns:(e=20)=>i()?l({runs:[]}):u.get(`/libre-claw/runs?limit=${e}`).then(e=>e.data),startRun:e=>{if(i()){let t=new Date().toISOString();return l({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 u.post(`/libre-claw/runs`,e).then(e=>e.data)},getRun:e=>i()?l({run_id:e}):u.get(`/libre-claw/runs/${encodeURIComponent(e)}`).then(e=>e.data),getEvents:(e,t=0)=>i()?l({events:[]}):u.get(`/libre-claw/runs/${encodeURIComponent(e)}/events?after=${t}`).then(e=>e.data),cancelRun:e=>i()?l({run_id:e,cancelled:!0}):u.post(`/libre-claw/runs/${encodeURIComponent(e)}/cancel`).then(e=>e.data),resolvePermission:(e,t,n)=>i()?l({run_id:e,tool_call_id:t,resolution:n}):u.post(`/libre-claw/runs/${encodeURIComponent(e)}/permissions/${encodeURIComponent(t)}`,{resolution:n}).then(e=>e.data),listAutomations:(e=50)=>i()?l({automations:[]}):u.get(`/libre-claw/automations?limit=${e}`).then(e=>e.data),createAutomation:e=>i()?l({...e,automation_id:`demo-${Date.now()}`}):u.post(`/libre-claw/automations`,e).then(e=>e.data),updateAutomation:(e,t)=>i()?l({...t,automation_id:e}):u.patch(`/libre-claw/automations/${encodeURIComponent(e)}`,t).then(e=>e.data),pauseAutomation:e=>i()?l({automation_id:e,status:`paused`}):u.post(`/libre-claw/automations/${encodeURIComponent(e)}/pause`).then(e=>e.data),resumeAutomation:e=>i()?l({automation_id:e,status:`active`}):u.post(`/libre-claw/automations/${encodeURIComponent(e)}/resume`).then(e=>e.data),runAutomationNow:e=>i()?l({automation_id:e,run:!0}):u.post(`/libre-claw/automations/${encodeURIComponent(e)}/run`).then(e=>e.data),deleteAutomation:e=>i()?l({automation_id:e,deleted:!0}):u.delete(`/libre-claw/automations/${encodeURIComponent(e)}`).then(e=>e.data)},k={getModels:()=>u.get(`/media/models`).then(e=>e.data),generateAudio:e=>u.post(`/media/audio/generate`,e).then(e=>e.data),generateSound:e=>u.post(`/media/sound/generate`,e).then(e=>e.data),generateVideo:e=>u.post(`/media/video/generate`,e).then(e=>e.data),getVideoJob:e=>u.get(`/media/video/jobs/${e}`).then(e=>e.data),getGallery:e=>u.get(`/media/gallery`,{params:e}).then(e=>e.data),deleteGalleryItem:e=>u.delete(`/media/gallery/${e}`).then(e=>e.data),getGalleryContent:e=>u.get(`/media/gallery/${e}/content`,{responseType:`blob`}).then(e=>e.data)},A=(e,t,n)=>{let r=new AbortController,i=localStorage.getItem(`auth-token`);return(async()=>{try{let n=await fetch(e,{headers:{Accept:`text/event-stream`,...i?{Authorization:`Bearer ${i}`}:{}},cache:`no-store`,credentials:`same-origin`,signal:r.signal});if(!n.ok){let e=`Request failed with status ${n.status}`;try{let t=await n.json();typeof t.error==`string`?e=t.error:typeof t.message==`string`&&(e=t.message)}catch{}throw Error(e)}if(!n.body)throw Error(`Response stream is unavailable`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;!r.signal.aborted;){let{done:e,value:n}=await a.read();s+=o.decode(n,{stream:!e});let r=s.split(/\r?\n\r?\n/);s=r.pop()||``;for(let e of r){let n=e.split(/\r?\n/).find(e=>e.startsWith(`data:`));n&&t(JSON.parse(n.slice(5).trim()))}if(e)break}}finally{a.releaseLock()}}catch(e){r.signal.aborted||n(e instanceof Error?e.message:`Connection lost`)}})(),()=>r.abort()},te={checkHealth:()=>i()?l({status:`offline`},!1):u.get(`/ollama/health`).then(e=>e.data),getModels:()=>i()?l(h):u.get(`/ollama/models`).then(e=>e.data),pullModel:e=>i()?l(null,!1):u.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});return A(`${s}/ollama/pull/stream?${a.toString()}`,e=>{switch(e.type){case`progress`:t({status:typeof e.status==`string`?e.status:`pulling`,digest:typeof e.digest==`string`?e.digest:void 0,total:typeof e.total==`number`?e.total:void 0,completed:typeof e.completed==`number`?e.completed:void 0,percent:typeof e.percent==`number`?e.percent:void 0});break;case`complete`:n();break;case`error`:r(String(e.error||`Model pull failed`))}},r)},deleteModel:e=>i()?l(null,!1):u.delete(`/ollama/models`,{params:{name:e}}).then(e=>e.data),showModel:(e,t=!1)=>{if(i()){let t=h.find(t=>t.name===e);return l(t||null,!!t)}return u.get(`/ollama/models/show`,{params:{name:e,verbose:t}}).then(e=>e.data)},createModel:e=>i()?l(null,!1):u.post(`/ollama/models`,e).then(e=>e.data),copyModel:(e,t)=>i()?l(null,!1):u.post(`/ollama/models/copy`,{source:e,destination:t}).then(e=>e.data),pushModel:e=>i()?l(null,!1):u.post(`/ollama/models/push`,{name:e}).then(e=>e.data),pullAllModels:()=>i()?l(null,!1):u.post(`/ollama/models/pull-all`).then(e=>e.data),pullAllModelsStream:(e,t,n)=>{if(i()){let n=h,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}A(`${s}/ollama/models/pull-all/stream`,r=>{switch(r.type){case`progress`:{let t=r.status===`success`||r.status===`error`?r.status:`starting`;e({current:typeof r.current==`number`?r.current:0,total:typeof r.total==`number`?r.total:0,modelName:typeof r.modelName==`string`?r.modelName:`unknown`,status:t,error:typeof r.error==`string`?r.error:void 0});break}case`complete`:t();break;case`error`:n(String(r.error||`Model update failed`))}},n)},generateEmbeddings:e=>i()?l({embeddings:[[]]},!1):u.post(`/ollama/embed`,e).then(e=>e.data),listRunningModels:()=>i()?l([]):u.get(`/ollama/running`).then(e=>e.data),unloadModel:e=>i()?l(null):u.post(`/ollama/models/unload`,{name:e}).then(e=>e.data),unloadAllModels:()=>i()?l(null):u.post(`/ollama/models/unload-all`).then(e=>e.data),getVersion:()=>i()?l({version:`demo-mode`},!1):u.get(`/ollama/version`).then(e=>e.data),chatCompletion:e=>i()?l({message:{content:`Demo response`,role:`assistant`}},!1):u.post(`/ollama/chat`,e).then(e=>e.data),checkBlobExists:e=>i()?Promise.resolve(!1):u.head(`/ollama/blobs/${e}`).then(()=>!0).catch(()=>!1),pushBlob:(e,t)=>i()?l(null,!1):u.post(`/ollama/blobs/${e}`,t,{headers:{"Content-Type":`application/octet-stream`}}).then(e=>e.data),generateLegacyEmbeddings:e=>i()?l({embedding:[]},!1):u.post(`/ollama/embeddings`,e).then(e=>e.data),getLibraryModels:e=>{if(i())return e?.category===`cloud`?l([{name:`gpt-oss:cloud`,description:`Demo cloud model using Ollama cloud naming`,category:`cloud`,sizes:[`cloud`],pulls:`Cloud`,tags:[`cloud`]}]):l([{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 u.get(`/ollama/library${n?`?${n}`:``}`).then(e=>e.data)}},j=[[`#2563eb`,`#7c3aed`],[`#0891b2`,`#2563eb`],[`#0f766e`,`#2563eb`],[`#be123c`,`#7c3aed`],[`#ff7b52`,`#dc2626`]],M=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,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`),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=M(n),[i,a]=j[r%j.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()?l([{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}]):u.get(`/personas`).then(e=>e.data),getPersona:e=>i()?l({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()}):u.get(`/personas/${e}`).then(e=>e.data),createPersona:e=>i()?l({id:`demo-`+Date.now(),user_id:`default`,...e,created_at:Date.now(),updated_at:Date.now()}):u.post(`/personas`,e).then(e=>e.data),updatePersona:(e,t)=>i()?l({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()}):u.put(`/personas/${e}`,t).then(e=>e.data),deletePersona:e=>i()?l(void 0):u.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 u.get(`/personas/${e}/export`).then(e=>e.data)},importPersona:e=>i()?l({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}):u.post(`/personas/import`,e).then(e=>e.data),getPersonasCount:()=>i()?l({count:2}):u.get(`/personas/stats/count`).then(e=>e.data),getDefaultParameters:()=>i()?l({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}):u.get(`/personas/defaults/parameters`).then(e=>e.data),getMemoryStatus:e=>i()?l({status:`active`,memory_count:42,last_backup:Date.now()-864e5,size_mb:2.3}):u.get(`/personas/${e}/memory/status`).then(e=>e.data),wipeMemories:e=>i()?l({deleted_count:42}):u.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 u.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 u.get(`/personas/${e}/export/dna`,{responseType:`blob`}).then(e=>e.data)},importPersonaDNA:e=>{if(i())return l({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),u.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 c.error(`Error while downloading persona:`,e),Error(`Failed to download persona: ${e instanceof Error?e.message:String(e)}`)}}},z=e=>{let t=Date.now();return{range:{from:t-Math.max(0,e-1)*864e5,to:t,days:e},totals:{calls:0,successfulCalls:0,failedCalls:0,cancelledCalls:0,meteredCalls:0,promptTokens:0,completionTokens:0,reportedTokens:0,averageLatencyMs:0,uniqueUsers:0},series:[],plugins:[],models:[],capabilities:[]}},B={getUsage:(e=30)=>i()?l(z(e)):u.get(`/plugins/usage`,{params:{days:e}}).then(e=>e.data),getAllPlugins:()=>i()?l([]):u.get(`/plugins`).then(e=>e.data),discoverModels:e=>i()?l({models:[],outcome:`unavailable`}):u.post(`/plugins/discover/${encodeURIComponent(e)}`).then(e=>e.data),uploadPlugin:e=>{if(i())return l({},!1);let t=new FormData;return t.append(`plugin`,e),u.post(`/plugins/upload`,t).then(e=>e.data)},installPlugin:e=>i()?l({},!1):u.post(`/plugins/install`,e).then(e=>e.data),updatePlugin:(e,t)=>i()?l({},!1):u.put(`/plugins/${e}`,t).then(e=>e.data),deletePlugin:e=>i()?l(void 0):u.delete(`/plugins/${e}`).then(e=>e.data),activatePlugin:e=>i()?l(!1,!1):u.post(`/plugins/activate/${e}`).then(e=>e.data),deactivatePlugin:e=>{if(i())return l(void 0);let t=e?`/plugins/deactivate/${e}`:`/plugins/deactivate`;return u.post(t).then(e=>e.data)},getActivePlugin:()=>i()?l(null):u.get(`/plugins/active`).then(e=>e.data),getPluginStatus:()=>i()?l([]):u.get(`/plugins/status`).then(e=>e.data),exportPlugin:e=>i()?Promise.resolve(new Blob([`{}`],{type:`application/json`})):u.get(`/plugins/${e}/export`,{responseType:`blob`}).then(e=>e.data),getCredentials:()=>i()?l([]):u.get(`/plugins/credentials/all`).then(e=>e.data),setApiKey:(e,t)=>i()?l(!1,!1):u.post(`/plugins/${e}/credentials`,{api_key:t}).then(e=>e.data),deleteApiKey:e=>i()?l(!1,!1):u.delete(`/plugins/${e}/credentials`).then(e=>e.data),checkApiKey:e=>i()?l(!1):u.get(`/plugins/${e}/credentials/check`).then(e=>e.data),getVariables:e=>i()?l({}):u.get(`/plugins/${e}/variables`).then(e=>e.data),setVariables:(e,t,n=[])=>i()?l(!0):u.put(`/plugins/${e}/variables`,{variables:t,unset:n}).then(e=>e.data),resetVariables:e=>i()?l(!0):u.delete(`/plugins/${e}/variables`).then(e=>e.data)},V={getPreferences:()=>i()?l(b()):u.get(`/preferences`).then(e=>e.data),updatePreferences:e=>i()?l(x(e)):u.put(`/preferences`,e).then(e=>e.data),setDefaultModel:(e,t,n)=>i()?l(x({defaultModel:e,defaultProviderType:t,defaultProviderId:t===`plugin`||t===`agent`?n:null})):u.put(`/preferences/default-model`,{model:e,providerType:t,providerId:n}).then(e=>e.data),setSystemMessage:e=>i()?l(x({systemMessage:e})):u.put(`/preferences/system-message`,{message:e}).then(e=>e.data),setGenerationOptions:e=>i()?l(x({generationOptions:e})):u.put(`/preferences/generation-options`,e).then(e=>e.data),resetGenerationOptions:()=>i()?l(x({generationOptions:v.generationOptions})):u.post(`/preferences/generation-options/reset`).then(e=>e.data),setEmbeddingSettings:e=>i()?l(x({embeddingSettings:e})):u.put(`/preferences/embedding-settings`,e).then(e=>e.data),resetEmbeddingSettings:()=>i()?l(x({embeddingSettings:v.embeddingSettings})):u.post(`/preferences/embedding-settings/reset`).then(e=>e.data),importData:(e,t=`replace`)=>i()?l({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}):u.post(`/preferences/import`,{data:e,mergeStrategy:t}).then(e=>e.data)},H={getDiagnostics:()=>u.get(`/system`).then(e=>e.data)},U=new Set([`snapshot`,`run_state`,`reasoning_delta`,`assistant_delta`,`tool_call`,`tool_result`,`usage`,`skill_loaded`,`error`,`done`]),W=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,G=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()},K=(e,t,n,r,i)=>{let a=W(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||!U.has(s)||c!==r||l!==i)return;let u=a.data;return{id:o,type:s,taskId:c,runId:l,timestamp:G(a.timestamp),data:W(u)||(u===void 0?{}:{content:u})}},q=(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 K({id:r,type:`done`,taskId:t,runId:n,timestamp:Date.now(),data:{}},r,i,t,n);try{return K(JSON.parse(o),r,i,t,n)}catch{return}},J=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=q(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=q(t,this.taskId,this.runId);n&&this.onEvent(n),e=/\r?\n\r?\n/.exec(this.buffer)}}},Y=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}.`)},X=async({taskId:e,runId:t,after:n,signal:r,onEvent:i})=>{let a=localStorage.getItem(`auth-token`),o=new URL(`${s}/work/tasks/${encodeURIComponent(e)}/runs/${encodeURIComponent(t)}/events`,window.location.origin);o.searchParams.set(`after`,String(Math.max(0,Math.trunc(n))));let c=await fetch(o,{method:`GET`,headers:{Accept:`text/event-stream`,...a?{Authorization:`Bearer ${a}`}:{}},cache:`no-store`,credentials:`same-origin`,signal:r});if(!c.ok)throw await Y(c);if(!c.body)throw Error(`Work event stream has no response body.`);let l=c.body.getReader(),u=new TextDecoder,d=new J(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()}},Z=e=>`/work/tasks/${encodeURIComponent(e)}`,ne={capabilities:()=>u.get(`/work/capabilities`).then(e=>e.data),listTasks:()=>u.get(`/work/tasks`).then(e=>e.data),createTask:e=>u.post(`/work/tasks`,e).then(e=>e.data),getTask:e=>u.get(Z(e)).then(e=>e.data),getMessages:(e,t,n=200)=>u.get(`${Z(e)}/messages`,{params:{before:t,limit:n}}).then(e=>e.data),updateTask:(e,t)=>u.patch(Z(e),t).then(e=>e.data),deleteTask:e=>u.delete(Z(e)).then(e=>e.data),startRun:(e,t)=>u.post(`${Z(e)}/runs`,t).then(e=>e.data),cancelRun:e=>u.post(`${Z(e)}/cancel`).then(e=>e.data),streamRunEvents:e=>X(e),listFiles:(e,t=``)=>u.get(`${Z(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)=>u.get(`${Z(e)}/file`,{params:{path:t}}).then(e=>e.data),saveFile:(e,t,n,r)=>u.put(`${Z(e)}/file`,{content:n,expectedUpdatedAt:r},{params:{path:t}}).then(e=>e.data),getGitStatus:e=>u.get(`${Z(e)}/git`).then(e=>e.data),getGitDiff:(e,t)=>u.get(`${Z(e)}/git/diff`,{params:t?{path:t}:void 0}).then(e=>e.data),initializeGit:e=>u.post(`${Z(e)}/git/init`).then(e=>e.data),stageGitPaths:(e,t)=>u.post(`${Z(e)}/git/stage`,{paths:t}).then(e=>e.data),commitGit:(e,t)=>u.post(`${Z(e)}/git/commit`,{message:t}).then(e=>e.data),createGitBranch:(e,t)=>u.post(`${Z(e)}/git/branches`,{name:t}).then(e=>e.data),switchGitBranch:(e,t)=>u.post(`${Z(e)}/git/switch`,{name:t}).then(e=>e.data),startPreview:(e,t)=>u.post(`${Z(e)}/preview/start`,t?{command:t}:{}).then(e=>e.data),stopPreview:e=>u.post(`${Z(e)}/preview/stop`).then(e=>e.data)};function Q(e,t,n){if(t)return e.find(e=>e.model===t&&(!n||e.plugin===n))}function re(e,t,n){return Q(e,t,n)||e[0]}function ie(e){return`${encodeURIComponent(e.plugin)}::${encodeURIComponent(e.model)}`}var $={getModels:()=>i()?l([{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}}]):u.get(`/tts/models`).then(e=>e.data),getPlugins:()=>i()?l([{id:`openai`,name:`OpenAI GPT`,models:[`tts-1`,`tts-1-hd`],config:{voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`}}]):u.get(`/tts/plugins`).then(e=>e.data),getVoices:e=>i()?l({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}):u.get(`/tts/voices/${e}`).then(e=>e.data),generateBase64:e=>{if(i())return l({audio:``,format:e.response_format||`mp3`,mimeType:`audio/mpeg`,size:0});let t={...e,pluginId:e.pluginId||void 0};return u.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 u.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}}},ae=e({agentCliApi:()=>d,personaApi:()=>R,preferencesApi:()=>V});export{m as C,p as S,ee as _,$ as a,w as b,V as c,I as d,L as f,E as g,O as h,re as i,B as l,k as m,Q as n,ne as o,te as p,ie as r,H as s,ae as t,R as u,T as v,S as x,C as y};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/api-F_fsjYA7.js","js/rolldown-runtime-hePW80VL.js","js/router-vendor-Ca9zqOqT.js","js/markdown-core-DHnR5Hw8.js","js/utils-vendor-1zob7nK9.js","js/logger-DSXjF4ye.js","js/config-DZsEwEPX.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./router-vendor-Ca9zqOqT.js";import{Tn as t}from"./ui-vendor-D_pYT79f.js";import{o as n}from"./utils-vendor-1zob7nK9.js";import{t as r}from"./logger-DSXjF4ye.js";import{c as i,l as a,p as o,u as s,x as c}from"./api-F_fsjYA7.js";import{r as l}from"./utils-BhpNrGnR.js";var u=[`Chat`,`Image`,`Video`,`Audio`,`Speech`,`Transcription`,`Embedding`],d={chat:`Chat`,completion:`Chat`,embedding:`Embedding`,image:`Image`,audio:`Audio`,stt:`Transcription`,tts:`Speech`,video:`Video`},f={completion:`Chat`,embedding:`Embedding`,image:`Image`,audio:`Audio`,stt:`Transcription`,tts:`Speech`,video:`Video`};function p(e){let t=new Map,n=(e,n)=>{for(let r of e||[]){if(typeof r!=`string`||!r.trim())continue;let e=r.trim(),i=t.get(e)??new Set;i.add(n),t.set(e,i)}};n(e.model_map,d[e.type]);for(let t of Object.keys(e.capabilities||{}))n(e.capabilities?.[t]?.model_map,f[t]);return Array.from(t,([e,t])=>({id:e,capabilities:u.filter(e=>t.has(e))}))}function m(e){return e.type===`chat`||e.type===`completion`}var h=[`dall-e`,`embed`,`gpt-image`,`moderation`,`rerank`,`sora`,`stable-diffusion`,`text-to-speech`,`tts`,`whisper`];function g(e){let t=e.toLocaleLowerCase();return!h.some(e=>t.includes(e))}function _(e){let t=new Set;for(let[n,r]of Object.entries(e.capabilities||{}))if(n!==`completion`)for(let e of r?.model_map||[])t.add(e.trim());return(e.model_map||[]).filter(e=>typeof e==`string`&&e.trim().length>0&&!t.has(e.trim())&&g(e))}function v(e,t){let n=t.trim().toLocaleLowerCase();return!n||[e.name,e.id,e.type,...p(e).map(e=>e.id)].some(e=>e?.toLocaleLowerCase().includes(n))}var y=(e,t)=>{if(e&&typeof e==`object`&&`response`in e){let t=e;if(t.response?.data?.error)return t.response.data.error}return e instanceof Error?e.message:t};function b(e){return{...e,id:e.id||l(),timestamp:Date.now()}}function x(e,t){return e.currentSession?.isPrivate&&e.currentSession?.id===t}function S(e,t){return e.sessions.some(e=>e.id===t)}function C(e,t){return!!e.currentSession&&(x(e,t)||S(e,e.currentSession.id))}function w(e,t,n){if(x(e,t))return e.currentSession.messages.find(e=>e.id===n.id)?e:{currentSession:{...e.currentSession,messages:[...e.currentSession.messages,n],updatedAt:Date.now()},sessions:e.sessions};if(e.sessions.find(e=>e.id===t)?.messages.some(e=>e.id===n.id))return e;let r=e.sessions.map(e=>{if(e.id!==t)return e;let r=[...e.messages];if(n.parentId){let e=n.parentId;r=r.map(t=>t.id!==e&&t.parentId!==e?t:{...t,isActive:!1,branchIndex:t.branchIndex??0,siblingCount:(n.branchIndex||0)+1})}return{...e,messages:[...r,n],updatedAt:Date.now()}});return{sessions:r,currentSession:e.currentSession?.id===t&&r.find(e=>e.id===t)||e.currentSession}}function T(e,t,n,r){if(e.currentSession?.id!==t)return e;if(e.currentSession?.isPrivate){let t=e.currentSession.messages.find(e=>e.id===n);return!t||t.content===r?e:{sessions:e.sessions,currentSession:{...e.currentSession,messages:e.currentSession.messages.map(e=>e.id===n?{...e,content:r}:e),updatedAt:Date.now()}}}let i=e.sessions.find(e=>e.id===t),a=i?.messages.find(e=>e.id===n);if(!i||!a||a.content===r)return e;let o=e.sessions.map(e=>e.id===t?{...e,messages:e.messages.map(e=>e.id===n?{...e,content:r}:e),updatedAt:Date.now()}:e);return{sessions:o,currentSession:e.currentSession?.id===t&&o.find(e=>e.id===t)||e.currentSession}}function E(e,t,n,r,i,a,o){if(e.currentSession?.id!==t)return e;if(e.currentSession?.isPrivate)return{sessions:e.sessions,currentSession:{...e.currentSession,messages:e.currentSession.messages.map(e=>e.id===n?{...e,content:r,thinking:o,statistics:i,...a?{providerMetadata:a}:{}}:e),updatedAt:Date.now()}};let s=e.sessions.map(e=>e.id===t?{...e,messages:e.messages.map(e=>e.id===n?{...e,content:r,thinking:o,statistics:i,...a?{providerMetadata:a}:{}}:e),updatedAt:Date.now()}:e);return{sessions:s,currentSession:e.currentSession?.id===t&&s.find(e=>e.id===t)||e.currentSession}}function D(e){return e.reduce((e,t)=>(e[t.id]=t,e),{})}function O(e){return e.map(e=>({name:`persona:${e.id}`,model:e.model,size:0,digest:``,details:{parent_model:e.model,format:`persona`,family:`persona`,families:[`persona`],parameter_size:``,quantization_level:``},modified_at:new Date(e.updated_at).toISOString(),expires_at:new Date().toISOString(),size_vram:0,isPersona:!0,personaName:e.name,personaDescription:e.description}))}function k(e){return e.filter(e=>e.active&&e.type!==`tts`&&e.type!==`image`).flatMap(e=>_(e).map(t=>({name:t,model:t,size:0,digest:``,details:{parent_model:``,format:``,family:``,families:[],parameter_size:``,quantization_level:``},modified_at:new Date().toISOString(),expires_at:new Date().toISOString(),size_vram:0,isPlugin:!0,pluginId:e.id,pluginName:e.name})))}var A=`persona:`,j=`plugin:`,M=`ollama:`,N=`legacy:`,P=`agent:`,F=e=>{try{return decodeURIComponent(e)}catch{return null}};function I(e){return e.isLegacySelection?{model:e.name,providerType:null,providerId:null}:e.isPersona?{model:e.name,providerType:`ollama`,providerId:null}:e.isPlugin&&e.pluginId?{model:e.name,providerType:`plugin`,providerId:e.pluginId}:e.isAgent?{model:e.name,providerType:`agent`,providerId:e.agentId||e.name}:{model:e.name,providerType:`ollama`,providerId:null}}function L(e){return e.providerType?e.providerType===`plugin`&&e.providerId?`${j}${encodeURIComponent(e.providerId)}:${encodeURIComponent(e.model)}`:e.providerType===`agent`&&e.providerId?`${P}${encodeURIComponent(e.providerId)}:${encodeURIComponent(e.model)}`:e.providerType===`ollama`&&e.model.startsWith(A)?`${A}${encodeURIComponent(e.model.slice(8))}`:e.providerType===`ollama`?`${M}${encodeURIComponent(e.model)}`:`${N}${encodeURIComponent(e.model)}`:`${N}${encodeURIComponent(e.model)}`}function R(e){return L(I(e))}function z(e){if(e.startsWith(A)){let t=F(e.slice(8));return t===null?null:{model:`${A}${t}`,providerType:`ollama`,providerId:null}}if(e.startsWith(j)){let t=e.slice(7),n=t.indexOf(`:`);if(n<1)return null;let r=F(t.slice(0,n)),i=F(t.slice(n+1));return r&&i?{model:i,providerType:`plugin`,providerId:r}:null}if(e.startsWith(P)){let t=e.slice(6),n=t.indexOf(`:`);if(n<1)return null;let r=F(t.slice(0,n)),i=F(t.slice(n+1));return r&&i?{model:i,providerType:`agent`,providerId:r}:null}if(e.startsWith(M)){let t=F(e.slice(7));return t?{model:t,providerType:`ollama`,providerId:null}:null}if(e.startsWith(N)){let t=F(e.slice(7));return t?{model:t,providerType:null,providerId:null}:null}return null}function B(e,t){return t.providerType===`plugin`?e.find(e=>e.isPlugin&&e.pluginId===t.providerId&&e.name===t.model):t.providerType===`agent`?e.find(e=>e.isAgent&&e.name===t.model):t.providerType===`ollama`?t.model.startsWith(A)?e.find(e=>e.isPersona&&e.name===t.model):e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t.model):e.find(e=>e.isLegacySelection&&e.name===t.model)??e.find(e=>e.name===t.model)}function V(e,t){if(!t.providerType)return L(t);let n=B(e,t);return n?R(n):L(t)}function H(e,t){let n=e.find(e=>R(e)===t);return n?I(n):z(t)}function U(e){return!e.isPlugin&&!e.isPersona&&!e.isAgent&&!e.isLegacySelection&&!e.isUnavailable}function W(e,t){return t.model?!!B(e.filter(e=>!e.isLegacySelection&&!e.isUnavailable),t):!1}function G(e,t){if(!t.model)return e;if(!t.providerType){if(e.some(e=>e.isLegacySelection&&e.name===t.model))return e;let n=!!B(e,t);return[...e,{name:t.model,model:t.model,size:0,digest:``,modified_at:``,details:{},isLegacySelection:!0,isUnavailable:!n}]}if(B(e,t))return e;let n=t.providerType,r=n===`ollama`&&t.model.startsWith(A),i=n===`plugin`&&t.providerId||void 0;return[...e,{name:t.model,model:t.model,size:0,digest:``,modified_at:``,details:{},isPlugin:n===`plugin`,pluginId:i,pluginName:i,isAgent:n===`agent`,agentId:n===`agent`&&t.providerId||void 0,isPersona:r,personaName:r?t.model.slice(8):void 0,isUnavailable:!0}]}var K=r(`chat-store`),q=n((n,r)=>({sessions:[],currentSession:null,setCurrentSession:e=>{n({currentSession:e})},createSession:async(e,r,i,a,o)=>{try{n({loading:!0,error:null});let s=await c.createSession(e,r,i,a,o);if(s.success&&s.data){let e=s.data;return n(t=>({sessions:[e,...t.sessions],currentSession:e,loading:!1})),t.success(`New chat created`),e}}catch(e){let r=y(e,`Failed to create session`);n({error:r,loading:!1}),t.error(r)}},loadSessions:async()=>{try{n({loading:!0,error:null});let e=await c.getSessions();e.success&&e.data&&n(t=>{let n=e.data||[],r=n.map(e=>e.id),i=null;return t.currentSession?.isPrivate?i=t.currentSession:t.currentSession&&r.includes(t.currentSession.id)?i=n.find(e=>e.id===t.currentSession.id)||null:n.length>0&&(i=n[0],t.currentSession&&K.warn(`Previous currentSession not found in backend sessions:`,t.currentSession.id)),{sessions:n,currentSession:i,loading:!1}})}catch(e){let r=y(e,`Failed to load sessions`);n({error:r,loading:!1}),t.error(r)}},deleteSession:async e=>{try{let r=await c.deleteSession(e);r.success?(n(t=>{let n=t.sessions.filter(t=>t.id!==e),r=t.currentSession?.id===e?n[0]||null:t.currentSession;return K.debug(`Store: Updating state, sessions count:`,n.length),{sessions:n,currentSession:r}}),t.success(`Chat deleted`)):(K.error(`Store: deleteSession failed:`,r),t.error(`Failed to delete chat`))}catch(e){K.error(`Store: deleteSession error:`,e);let n=y(e,`Failed to delete session`);t.error(n)}},clearAllSessions:async()=>{try{n({loading:!0,error:null});let e=await c.clearAllSessions();e.success?(n({sessions:[],currentSession:null,loading:!1}),t.success(`All chat history cleared`)):(K.error(`Store: clearAllSessions failed:`,e),t.error(`Failed to clear chat history`),n({loading:!1}))}catch(e){K.error(`Store: clearAllSessions error:`,e);let r=y(e,`Failed to clear chat history`);t.error(r),n({loading:!1})}},clearAllState:()=>{n({sessions:[],currentSession:null,models:[],selectedModel:``,selectedProviderType:null,selectedProviderId:null,systemMessage:``,loading:!1,error:null})},applySessionTitle:(e,t,r=Date.now())=>{n(n=>({sessions:n.sessions.map(n=>n.id===e?{...n,title:t,updatedAt:r}:n),currentSession:n.currentSession?.id===e?{...n.currentSession,title:t,updatedAt:r}:n.currentSession}))},updateSessionTitle:async(e,n)=>{try{let i=await c.updateSession(e,{title:n});if(i.success&&i.data){let n=i.data.title,a=i.data.updatedAt??Date.now();r().applySessionTitle(e,n,a),t.success(`Chat title updated`)}}catch(e){let n=y(e,`Failed to update session`);t.error(n)}},addMessage:(e,i)=>{let a=r(),o=x(a,e);if(!C(a,e)){t.error(`No valid chat session. Please create or select a chat.`),K.error(`addMessage blocked: currentSession is not valid`,a.currentSession?.id);return}if(!o&&!S(a,e)){t.error(`Session not found or invalid. Please select or create a valid chat session.`),K.error(`addMessage blocked: sessionId not found in sessions`,e);return}let s=b(i);n(t=>w(t,e,s))},updateMessage:(e,t,r)=>{n(n=>T(n,e,t,r))},updateMessageWithStatistics:(e,t,r,i,a,o)=>{n(n=>E(n,e,t,r,i,a,o))},rateMessage:async(e,t,i)=>{let a=e=>e.map(e=>e.id===t?{...e,rating:i}:e),o=r().currentSession?.isPrivate;if(n(t=>({sessions:t.sessions.map(t=>t.id===e?{...t,messages:a(t.messages)}:t),currentSession:t.currentSession?.id===e?{...t.currentSession,messages:a(t.currentSession.messages)}:t.currentSession})),!o)try{await c.updateMessage(e,t,{rating:i??null})}catch(e){K.error(`Failed to save message rating:`,e)}},folders:[],loadFolders:async()=>{try{let e=await c.getFolders();e.success&&e.data&&n({folders:e.data})}catch(e){K.error(`Failed to load folders:`,e)}},createFolder:async e=>{try{let t=await c.createFolder(e);if(t.success&&t.data){let e=t.data;return n(t=>({folders:[...t.folders,e].sort((e,t)=>e.name.localeCompare(t.name))})),e}}catch(e){K.error(`Failed to create folder:`,e)}},renameFolder:async(e,t)=>{try{let r=await c.renameFolder(e,t);if(r.success&&r.data){let t=r.data;n(n=>({folders:n.folders.map(n=>n.id===e?t:n).sort((e,t)=>e.name.localeCompare(t.name))}))}}catch(e){K.error(`Failed to rename folder:`,e)}},deleteFolder:async e=>{try{(await c.deleteFolder(e)).success&&n(t=>({folders:t.folders.filter(t=>t.id!==e),sessions:t.sessions.map(t=>t.folderId===e?{...t,folderId:null}:t),currentSession:t.currentSession?.folderId===e?{...t.currentSession,folderId:null}:t.currentSession}))}catch(e){K.error(`Failed to delete folder:`,e)}},moveSessionToFolder:async(e,t)=>{n(n=>({sessions:n.sessions.map(n=>n.id===e?{...n,folderId:t}:n),currentSession:n.currentSession?.id===e?{...n.currentSession,folderId:t}:n.currentSession}));try{await c.updateSession(e,{folderId:t})}catch(e){K.error(`Failed to move session to folder:`,e)}},setSessionArchived:async(e,t)=>{n(n=>({sessions:n.sessions.map(n=>n.id===e?{...n,archived:t}:n),currentSession:n.currentSession?.id===e?{...n.currentSession,archived:t}:n.currentSession}));try{await c.updateSession(e,{archived:t})}catch(r){K.error(`Failed to update session archive state:`,r),n(n=>({sessions:n.sessions.map(n=>n.id===e?{...n,archived:!t}:n)}))}},truncateMessagesFrom:(e,t)=>{let r=e=>{let n=e.findIndex(e=>e.id===t);return n===-1?e:e.slice(0,n)};n(t=>({sessions:t.sessions.map(t=>t.id===e?{...t,messages:r(t.messages),updatedAt:Date.now()}:t),currentSession:t.currentSession?.id===e?{...t.currentSession,messages:r(t.currentSession.messages),updatedAt:Date.now()}:t.currentSession}))},models:[],loadModels:async()=>{try{n({loading:!0,error:null}),K.debug(`Loading models from API...`);let s=[],c;try{let e=await o.getModels();e.success&&e.data?(s=[...e.data],K.debug(`Ollama models loaded:`,e.data.length)):c=Error(e.error||e.message||`Ollama models are unavailable.`)}catch(e){c=e,K.warn(`Ollama models are unavailable; continuing with plugin models:`,e)}try{let e=await a.getAllPlugins();if(e.success&&e.data){let t=e.data.filter(e=>e.active&&e.type!==`tts`&&e.type!==`image`);K.debug(`🔌 Active plugins found:`,t.map(e=>e.name));let n=k(t);s.push(...n),K.debug(`Plugin models added:`,n.length)}}catch(e){K.error(`❌ Failed to load plugin models:`,e),e instanceof Error&&K.error(`❌ Plugin error details:`,{message:e.message,response:e.response?.data,status:e.response?.status,url:e.config?.url})}try{let{agentCliApi:t}=await e(async()=>{let{agentCliApi:e}=await import(`./api-F_fsjYA7.js`).then(e=>e.t);return{agentCliApi:e}},__vite__mapDeps([0,1,2,3,4,5,6])),n=await t.getModels();if(n.success&&n.data){let e=n.data.map(e=>({name:e.id,model:e.id,size:0,digest:``,modified_at:``,details:{},isAgent:!0,agentName:e.name,agentId:e.agentId}));s.push(...e),K.debug(`Agent CLI models added:`,e.length)}}catch(e){K.warn(`Agent CLI models unavailable:`,e)}let l=s.length;try{let{personaApi:t}=await e(async()=>{let{personaApi:e}=await import(`./api-F_fsjYA7.js`).then(e=>e.t);return{personaApi:e}},__vite__mapDeps([0,1,2,3,4,5,6])),r=await t.getPersonas();if(r.success&&r.data){let e=D(r.data),t=O(r.data);s.push(...t),n(t=>({...t,personas:e}))}}catch(e){K.error(`❌ Failed to load personas:`,e)}K.debug(`Total models loaded:`,s.length);let u=l===0&&c?y(c,`No model provider is available`):null,d=r(),f=d.selectedModel,p={model:f,providerType:d.selectedProviderType,providerId:d.selectedProviderId},m=!!B(s,p),h=d.selectedProviderType===`ollama`||d.selectedProviderType===`plugin`;if(f&&!m&&h){let e=`Selected model "${f}" is unavailable from ${d.selectedProviderType===`plugin`?d.selectedProviderId||`plugin`:`Ollama`}. Reactivate that provider or select another model.`;n({models:s,loading:!1,error:e}),t.error(e);return}if(f&&!m&&s.length>0){let e=I(s[0]);K.debug(`⚠️ Legacy selected model "${f}" no longer available, falling back to "${e.model}"`),n({models:s,loading:!1,selectedModel:e.model,selectedProviderType:e.providerType||null,selectedProviderId:e.providerId||null,error:u}),i.setDefaultModel(e.model,e.providerType,e.providerId).catch(e=>{K.warn(`Failed to save fallback default model:`,e)}),t.success(`Switched to ${e.model} (previous model no longer available)`)}else n({models:s,loading:!1,error:u});u&&t.error(u)}catch(e){K.error(`Error loading models:`,e);let r=y(e,`Failed to load models`);n({error:r,loading:!1}),t.error(r)}},loadPreferences:async()=>{try{let e=await i.getPreferences();if(e.success&&e.data){let{defaultModel:t,defaultProviderType:r,defaultProviderId:i,systemMessage:a}=e.data;t&&(n({selectedModel:t,selectedProviderType:r||null,selectedProviderId:r===`plugin`&&i||null}),K.debug(`✅ Loaded default model from backend:`,t)),a!==void 0&&(n({systemMessage:a}),K.debug(`✅ Loaded system message from backend`))}}catch(e){K.warn(`❌ Failed to load preferences from backend:`,e)}},selectedModel:``,selectedProviderType:null,selectedProviderId:null,setSelectedModel:(e,t=null,r=null)=>{let a=(t===`plugin`||t===`agent`)&&r||null;n({selectedModel:e,selectedProviderType:t,selectedProviderId:a}),i.setDefaultModel(e,t,a).catch(e=>{K.warn(`Failed to save default model to backend:`,e)})},updateCurrentSessionModel:async(e,i=null,a=null)=>{let o=r();if(!o.currentSession)throw Error(`No current session to update`);try{let r=await c.updateSession(o.currentSession.id,{model:e,providerType:i,providerId:i===`plugin`||i===`agent`?a:null});r.success&&r.data&&(n(t=>({sessions:t.sessions.map(e=>e.id===t.currentSession?.id?r.data:e),currentSession:r.data,selectedModel:e,selectedProviderType:i,selectedProviderId:(i===`plugin`||i===`agent`)&&a||null})),t.success(`Model updated for current chat`))}catch(e){let n=y(e,`Failed to update session model`);throw t.error(n),e}},personas:{},loadPersonas:async()=>{try{n({loading:!0,error:null});let e=await s.getPersonas();if(e.success&&e.data){let t=e.data;n({personas:D(t),loading:!1}),K.debug(`✅ Personas loaded:`,t.length)}}catch(e){let t=y(e,`Failed to load personas`);n({error:t,loading:!1}),K.error(`❌ Failed to load personas:`,t)}},getCurrentPersona:()=>{let e=r();if(!e.currentSession||!e.currentSession.model?.startsWith(`persona:`))return null;let t=e.currentSession.model.replace(`persona:`,``);return e.personas[t]||null},systemMessage:``,setSystemMessage:e=>{let t=r();if(n({systemMessage:e}),i.setSystemMessage(e).catch(e=>{K.warn(`Failed to save system message to backend:`,e)}),t.currentSession){let r=t.currentSession.messages.findIndex(e=>e.role===`system`);if(r!==-1){n(t=>{let n=t.sessions.map(n=>{if(n.id===t.currentSession?.id){let t=n.messages.map((t,n)=>n===r&&t.role===`system`?{...t,content:e,timestamp:Date.now()}:t);return{...n,messages:t,updatedAt:Date.now()}}return n});return{sessions:n,currentSession:t.currentSession?n.find(e=>e.id===t.currentSession.id)||t.currentSession:null}});let i=t.currentSession.messages[r];c.updateMessage(t.currentSession.id,i.id,{content:e}).catch(e=>{K.warn(`Failed to sync system message update to backend:`,e)}),K.debug(`✅ Updated system message in current session`)}}},loading:!1,error:null,setError:e=>n({error:e}),generatingTitleForSession:null,setGeneratingTitleForSession:e=>n({generatingTitleForSession:e}),...typeof window<`u`&&{testPluginApi:async()=>{try{K.debug(`🧪 Testing plugin API...`);let e=await a.getAllPlugins();return K.debug(`✅ Plugin API test result:`,e),e}catch(e){return K.error(`❌ Plugin API test failed:`,e),{error:e}}}}}));export{V as a,W as c,p as d,v as f,I as i,G as l,R as n,B as o,m as p,H as r,U as s,q as t,y as u};