libre-webui 0.2.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 (233) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +204 -0
  3. package/backend/dist/db.d.ts +19 -0
  4. package/backend/dist/db.d.ts.map +1 -0
  5. package/backend/dist/db.js +355 -0
  6. package/backend/dist/db.js.map +1 -0
  7. package/backend/dist/env.d.ts +2 -0
  8. package/backend/dist/env.d.ts.map +1 -0
  9. package/backend/dist/env.js +22 -0
  10. package/backend/dist/env.js.map +1 -0
  11. package/backend/dist/index.d.ts +4 -0
  12. package/backend/dist/index.d.ts.map +1 -0
  13. package/backend/dist/index.js +751 -0
  14. package/backend/dist/index.js.map +1 -0
  15. package/backend/dist/middleware/auth.d.ts +18 -0
  16. package/backend/dist/middleware/auth.d.ts.map +1 -0
  17. package/backend/dist/middleware/auth.js +98 -0
  18. package/backend/dist/middleware/auth.js.map +1 -0
  19. package/backend/dist/middleware/index.d.ts +5 -0
  20. package/backend/dist/middleware/index.d.ts.map +1 -0
  21. package/backend/dist/middleware/index.js +62 -0
  22. package/backend/dist/middleware/index.js.map +1 -0
  23. package/backend/dist/models/personaModel.d.ts +37 -0
  24. package/backend/dist/models/personaModel.d.ts.map +1 -0
  25. package/backend/dist/models/personaModel.js +269 -0
  26. package/backend/dist/models/personaModel.js.map +1 -0
  27. package/backend/dist/models/userModel.d.ts +86 -0
  28. package/backend/dist/models/userModel.d.ts.map +1 -0
  29. package/backend/dist/models/userModel.js +212 -0
  30. package/backend/dist/models/userModel.js.map +1 -0
  31. package/backend/dist/routes/auth.d.ts +3 -0
  32. package/backend/dist/routes/auth.d.ts.map +1 -0
  33. package/backend/dist/routes/auth.js +389 -0
  34. package/backend/dist/routes/auth.js.map +1 -0
  35. package/backend/dist/routes/chat.d.ts +3 -0
  36. package/backend/dist/routes/chat.d.ts.map +1 -0
  37. package/backend/dist/routes/chat.js +767 -0
  38. package/backend/dist/routes/chat.js.map +1 -0
  39. package/backend/dist/routes/documents.d.ts +3 -0
  40. package/backend/dist/routes/documents.d.ts.map +1 -0
  41. package/backend/dist/routes/documents.js +244 -0
  42. package/backend/dist/routes/documents.js.map +1 -0
  43. package/backend/dist/routes/ollama.d.ts +3 -0
  44. package/backend/dist/routes/ollama.d.ts.map +1 -0
  45. package/backend/dist/routes/ollama.js +549 -0
  46. package/backend/dist/routes/ollama.js.map +1 -0
  47. package/backend/dist/routes/personas.d.ts +3 -0
  48. package/backend/dist/routes/personas.d.ts.map +1 -0
  49. package/backend/dist/routes/personas.js +505 -0
  50. package/backend/dist/routes/personas.js.map +1 -0
  51. package/backend/dist/routes/plugins.d.ts +3 -0
  52. package/backend/dist/routes/plugins.d.ts.map +1 -0
  53. package/backend/dist/routes/plugins.js +417 -0
  54. package/backend/dist/routes/plugins.js.map +1 -0
  55. package/backend/dist/routes/preferences.d.ts +3 -0
  56. package/backend/dist/routes/preferences.d.ts.map +1 -0
  57. package/backend/dist/routes/preferences.js +303 -0
  58. package/backend/dist/routes/preferences.js.map +1 -0
  59. package/backend/dist/routes/tts.d.ts +3 -0
  60. package/backend/dist/routes/tts.d.ts.map +1 -0
  61. package/backend/dist/routes/tts.js +304 -0
  62. package/backend/dist/routes/tts.js.map +1 -0
  63. package/backend/dist/routes/users.d.ts +3 -0
  64. package/backend/dist/routes/users.d.ts.map +1 -0
  65. package/backend/dist/routes/users.js +246 -0
  66. package/backend/dist/routes/users.js.map +1 -0
  67. package/backend/dist/services/authService.d.ts +51 -0
  68. package/backend/dist/services/authService.d.ts.map +1 -0
  69. package/backend/dist/services/authService.js +153 -0
  70. package/backend/dist/services/authService.js.map +1 -0
  71. package/backend/dist/services/chatService.d.ts +52 -0
  72. package/backend/dist/services/chatService.d.ts.map +1 -0
  73. package/backend/dist/services/chatService.js +645 -0
  74. package/backend/dist/services/chatService.js.map +1 -0
  75. package/backend/dist/services/documentService.d.ts +34 -0
  76. package/backend/dist/services/documentService.d.ts.map +1 -0
  77. package/backend/dist/services/documentService.js +428 -0
  78. package/backend/dist/services/documentService.js.map +1 -0
  79. package/backend/dist/services/encryptionService.d.ts +62 -0
  80. package/backend/dist/services/encryptionService.d.ts.map +1 -0
  81. package/backend/dist/services/encryptionService.js +284 -0
  82. package/backend/dist/services/encryptionService.js.map +1 -0
  83. package/backend/dist/services/memoryService.d.ts +140 -0
  84. package/backend/dist/services/memoryService.d.ts.map +1 -0
  85. package/backend/dist/services/memoryService.js +867 -0
  86. package/backend/dist/services/memoryService.js.map +1 -0
  87. package/backend/dist/services/mutationEngineService.d.ts +49 -0
  88. package/backend/dist/services/mutationEngineService.d.ts.map +1 -0
  89. package/backend/dist/services/mutationEngineService.js +432 -0
  90. package/backend/dist/services/mutationEngineService.js.map +1 -0
  91. package/backend/dist/services/ollamaService.d.ts +55 -0
  92. package/backend/dist/services/ollamaService.d.ts.map +1 -0
  93. package/backend/dist/services/ollamaService.js +450 -0
  94. package/backend/dist/services/ollamaService.js.map +1 -0
  95. package/backend/dist/services/personaService.d.ts +67 -0
  96. package/backend/dist/services/personaService.d.ts.map +1 -0
  97. package/backend/dist/services/personaService.js +373 -0
  98. package/backend/dist/services/personaService.js.map +1 -0
  99. package/backend/dist/services/pluginService.d.ts +42 -0
  100. package/backend/dist/services/pluginService.d.ts.map +1 -0
  101. package/backend/dist/services/pluginService.js +961 -0
  102. package/backend/dist/services/pluginService.js.map +1 -0
  103. package/backend/dist/services/preferencesService.d.ts +35 -0
  104. package/backend/dist/services/preferencesService.d.ts.map +1 -0
  105. package/backend/dist/services/preferencesService.js +255 -0
  106. package/backend/dist/services/preferencesService.js.map +1 -0
  107. package/backend/dist/services/simpleGitHubOAuth.d.ts +48 -0
  108. package/backend/dist/services/simpleGitHubOAuth.d.ts.map +1 -0
  109. package/backend/dist/services/simpleGitHubOAuth.js +203 -0
  110. package/backend/dist/services/simpleGitHubOAuth.js.map +1 -0
  111. package/backend/dist/services/simpleHuggingFaceOAuth.d.ts +43 -0
  112. package/backend/dist/services/simpleHuggingFaceOAuth.d.ts.map +1 -0
  113. package/backend/dist/services/simpleHuggingFaceOAuth.js +159 -0
  114. package/backend/dist/services/simpleHuggingFaceOAuth.js.map +1 -0
  115. package/backend/dist/services/userService.d.ts +1 -0
  116. package/backend/dist/services/userService.d.ts.map +1 -0
  117. package/backend/dist/services/userService.js +18 -0
  118. package/backend/dist/services/userService.js.map +1 -0
  119. package/backend/dist/storage.d.ts +55 -0
  120. package/backend/dist/storage.d.ts.map +1 -0
  121. package/backend/dist/storage.js +741 -0
  122. package/backend/dist/storage.js.map +1 -0
  123. package/backend/dist/test-encryption.d.ts +2 -0
  124. package/backend/dist/test-encryption.d.ts.map +1 -0
  125. package/backend/dist/test-encryption.js +64 -0
  126. package/backend/dist/test-encryption.js.map +1 -0
  127. package/backend/dist/types/index.d.ts +523 -0
  128. package/backend/dist/types/index.d.ts.map +1 -0
  129. package/backend/dist/types/index.js +31 -0
  130. package/backend/dist/types/index.js.map +1 -0
  131. package/backend/dist/utils/generationUtils.d.ts +10 -0
  132. package/backend/dist/utils/generationUtils.d.ts.map +1 -0
  133. package/backend/dist/utils/generationUtils.js +49 -0
  134. package/backend/dist/utils/generationUtils.js.map +1 -0
  135. package/backend/dist/utils/hash.d.ts +29 -0
  136. package/backend/dist/utils/hash.d.ts.map +1 -0
  137. package/backend/dist/utils/hash.js +73 -0
  138. package/backend/dist/utils/hash.js.map +1 -0
  139. package/backend/dist/utils/jwt.d.ts +37 -0
  140. package/backend/dist/utils/jwt.d.ts.map +1 -0
  141. package/backend/dist/utils/jwt.js +86 -0
  142. package/backend/dist/utils/jwt.js.map +1 -0
  143. package/bin/cli.js +150 -0
  144. package/electron/main.js +322 -0
  145. package/frontend/dist/_redirects +1 -0
  146. package/frontend/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  147. package/frontend/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  148. package/frontend/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  149. package/frontend/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  150. package/frontend/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  151. package/frontend/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  152. package/frontend/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  153. package/frontend/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  154. package/frontend/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  155. package/frontend/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  156. package/frontend/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  157. package/frontend/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  158. package/frontend/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  159. package/frontend/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  160. package/frontend/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  161. package/frontend/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  162. package/frontend/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  163. package/frontend/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  164. package/frontend/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  165. package/frontend/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  166. package/frontend/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  167. package/frontend/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  168. package/frontend/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  169. package/frontend/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  170. package/frontend/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  171. package/frontend/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  172. package/frontend/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  173. package/frontend/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  174. package/frontend/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  175. package/frontend/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  176. package/frontend/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  177. package/frontend/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  178. package/frontend/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  179. package/frontend/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  180. package/frontend/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  181. package/frontend/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  182. package/frontend/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  183. package/frontend/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  184. package/frontend/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  185. package/frontend/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  186. package/frontend/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  187. package/frontend/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  188. package/frontend/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  189. package/frontend/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  190. package/frontend/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  191. package/frontend/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  192. package/frontend/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  193. package/frontend/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  194. package/frontend/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  195. package/frontend/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  196. package/frontend/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  197. package/frontend/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  198. package/frontend/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  199. package/frontend/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  200. package/frontend/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  201. package/frontend/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  202. package/frontend/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  203. package/frontend/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  204. package/frontend/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  205. package/frontend/dist/assets/index-CRQkB7Wz.js +3 -0
  206. package/frontend/dist/css/index-B1OjddR-.css +1 -0
  207. package/frontend/dist/favicon-dark.png +0 -0
  208. package/frontend/dist/favicon-light.png +0 -0
  209. package/frontend/dist/index.html +23 -0
  210. package/frontend/dist/js/ArtifactContainer-c_oi7XMs.js +23 -0
  211. package/frontend/dist/js/ArtifactDemoPage-CdfwJVXu.js +98 -0
  212. package/frontend/dist/js/ChatPage-CyotkmS0.js +281 -0
  213. package/frontend/dist/js/ModelsPage-DNaziPHc.js +2 -0
  214. package/frontend/dist/js/PersonasPage-DcnbJf8Q.js +13 -0
  215. package/frontend/dist/js/UserManagementPage-DtTf92dS.js +1 -0
  216. package/frontend/dist/js/markdown-vendor-D-79K2xZ.js +22 -0
  217. package/frontend/dist/js/react-vendor-N--QU9DW.js +8 -0
  218. package/frontend/dist/js/router-vendor-B-t91v39.js +3 -0
  219. package/frontend/dist/js/ui-vendor-VxSCY_bv.js +177 -0
  220. package/frontend/dist/js/utils-vendor-DNzxLBGx.js +6 -0
  221. package/frontend/dist/logo-dark.png +0 -0
  222. package/frontend/dist/logo-light.png +0 -0
  223. package/frontend/dist/logo.svg +14 -0
  224. package/package.json +128 -0
  225. package/plugins/anthropic.json +25 -0
  226. package/plugins/elevenlabs.json +58 -0
  227. package/plugins/gemini.json +57 -0
  228. package/plugins/github.json +23 -0
  229. package/plugins/groq.json +25 -0
  230. package/plugins/mistral.json +73 -0
  231. package/plugins/openai-tts.json +38 -0
  232. package/plugins/openai.json +132 -0
  233. package/plugins/openrouter.json +353 -0
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/utils-vendor-DNzxLBGx.js","js/router-vendor-B-t91v39.js","js/react-vendor-N--QU9DW.js","js/ChatPage-CyotkmS0.js","js/markdown-vendor-D-79K2xZ.js","js/ArtifactContainer-c_oi7XMs.js","js/ui-vendor-VxSCY_bv.js","js/ModelsPage-DNaziPHc.js","js/PersonasPage-DcnbJf8Q.js","js/UserManagementPage-DtTf92dS.js","js/ArtifactDemoPage-CdfwJVXu.js"])))=>i.map(i=>d[i]);
2
+ var $t=Object.defineProperty;var Wt=(r,a,t)=>a in r?$t(r,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[a]=t;var fe=(r,a,t)=>Wt(r,typeof a!="symbol"?a+"":a,t);import{j as e,_ as re}from"../js/markdown-vendor-D-79K2xZ.js";import{r as c,R as Y,u as br,a as nr,b as Bt,c as Ht,L as Ye,N as Dr,H as Kt,B as qt,d as xr,e as q}from"../js/router-vendor-B-t91v39.js";import{a as Gt,g as Vt}from"../js/react-vendor-N--QU9DW.js";import{X as ue,I as Jt,U as ar,z as j,P as Yt,B as Or,S as Qt,V as Tr,D as ze,a as Fr,M as Xt,b as et,R as Qe,C as be,G as rt,E as Ie,c as sr,d as Zt,T as tt,L as yr,e as ea,f as ra,g as ta,h as aa,i as sa,j as na,k as er,l as oa,m as zr,n as Lr,o as ia,p as Ur,q as Rr,r as at,s as la,t as U,K as st,u as Re,v as $e,w as da,x as nt,Z as ca,y as ma,A as $r,F as ua,H as ga,J as xa,N as ha}from"../js/ui-vendor-VxSCY_bv.js";import{t as pa,c as fa,a as or,b as hr}from"../js/utils-vendor-DNzxLBGx.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function t(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(o){if(o.ep)return;o.ep=!0;const i=t(o);fetch(o.href,i)}})();var Xe={},Wr;function ba(){if(Wr)return Xe;Wr=1;var r=Gt();return Xe.createRoot=r.createRoot,Xe.hydrateRoot=r.hydrateRoot,Xe}var ya=ba();const ka=Vt(ya),x=()=>{if(typeof window<"u"){const r=window.location.hostname,a=i=>i.some(l=>r===l||r.endsWith("."+l));if(a(["vercel.app","vercel.dev"])||a(["netlify.app","netlify.com"])||a(["github.io"])||r.startsWith("demo.")||r.startsWith("preview."))return!0}return!1},Br=()=>({isDemo:x(),message:"This is a demo version for presentation purposes only. The Ollama backend is not connected.",showBanner:!0,allowInteraction:!1});function M(...r){return pa(fa(r))}function va(r){const a=new Date(r),s=new Date().getTime()-a.getTime(),o=Math.floor(s/(1e3*60)),i=Math.floor(s/(1e3*60*60)),l=Math.floor(s/(1e3*60*60*24));return o<1?"Just now":o<60?`${o}m ago`:i<24?`${i}h ago`:l<7?`${l}d ago`:a.toLocaleDateString()}function ja(){return Math.random().toString(36).substring(2)+Date.now().toString(36)}function wa(r,a){return r.length<=a?r:r.substring(0,a)+"..."}function os(r){const a=/^\[Thinking:\s*([\s\S]*?)\]\s*/i,t=/^<thinking>([\s\S]*?)<\/thinking>\s*/i,s=r.match(a);if(s)return{thinking:s[1].trim(),content:r.slice(s[0].length).trim()};const o=r.match(t);return o?{thinking:o[1].trim(),content:r.slice(o[0].length).trim()}:{thinking:null,content:r}}const C=({variant:r="primary",size:a="md",loading:t=!1,disabled:s,children:o,className:i,...l})=>{const d="inline-flex items-center justify-center rounded-xl font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed active:scale-[0.98] relative overflow-hidden",h={primary:"bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500 dark:bg-primary-500 dark:hover:bg-primary-600 dark:focus:ring-primary-400",secondary:"bg-gray-50 text-gray-700 border border-gray-200 shadow-sm hover:bg-gray-100 hover:border-gray-300 hover:shadow-md focus:ring-gray-500 dark:bg-dark-200 dark:text-dark-700 dark:border-dark-300 dark:hover:bg-dark-300 dark:hover:border-dark-400",outline:"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-50 dark:hover:bg-dark-100 dark:hover:border-dark-400",ghost:"text-gray-600 hover:bg-gray-100 hover:text-gray-900 focus:ring-gray-500 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-800",danger:"bg-error-500 text-white shadow-sm hover:bg-error-600 hover:shadow-md focus:ring-error-500 dark:bg-error-600 dark:hover:bg-error-700"},g={sm:"px-3 py-1.5 text-sm gap-1.5",md:"px-4 py-2.5 text-sm gap-2",lg:"px-6 py-3 text-base gap-2.5"};return e.jsxs("button",{className:M(d,h[r],g[a],i),disabled:s||t,...l,children:[t&&e.jsxs("svg",{className:"mr-2 h-4 w-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),o]})},Na=({label:r,error:a,helper:t,className:s,id:o,...i})=>{const l=c.useId(),d=o||`input-${l}`;return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("label",{htmlFor:d,className:"block text-sm font-medium text-gray-700 dark:text-dark-700",children:r}),e.jsx("input",{id:d,className:M("block w-full rounded-xl border border-gray-200 px-4 py-3 text-sm placeholder-gray-500 shadow-sm transition-all duration-200 bg-white text-gray-900","focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 focus:outline-none focus:shadow-md","dark:border-dark-300 dark:bg-dark-100 dark:text-dark-800 dark:placeholder-dark-500","dark:focus:border-primary-400 dark:focus:ring-primary-400/20",a&&"border-error-500 focus:border-error-500 focus:ring-error-500/20",s),...i}),a&&e.jsx("p",{className:"text-sm text-error-600 dark:text-error-400",children:a}),t&&!a&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-dark-500",children:t})]})},ot=Y.forwardRef(({label:r,error:a,helper:t,className:s,id:o,...i},l)=>{const d=c.useId(),h=o||`textarea-${d}`;return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("label",{htmlFor:h,className:"block text-sm font-medium text-gray-700 dark:text-dark-700",children:r}),e.jsx("textarea",{ref:l,id:h,className:M("block w-full rounded-xl border border-gray-200 px-4 py-3 text-sm placeholder-gray-500 shadow-sm transition-all duration-200 resize-none bg-white text-gray-900","focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 focus:outline-none focus:shadow-md","dark:border-dark-300 dark:bg-dark-100 dark:text-dark-800 dark:placeholder-dark-500","dark:focus:border-primary-400 dark:focus:ring-primary-400/20",a&&"border-error-500 focus:border-error-500 focus:ring-error-500/20",s),...i}),a&&e.jsx("p",{className:"text-sm text-error-600 dark:text-error-400",children:a}),t&&!a&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-dark-500",children:t})]})});ot.displayName="Textarea";const Pe=({label:r,error:a,helper:t,options:s,className:o,id:i,...l})=>{const d=c.useId(),h=i||`select-${d}`;return e.jsxs("div",{className:"space-y-1",children:[r&&e.jsx("label",{htmlFor:h,className:"block text-sm font-medium text-gray-700 dark:text-dark-700",children:r}),e.jsx("select",{id:h,className:M("block w-full rounded-xl border border-gray-200 px-4 py-3 text-sm shadow-sm transition-all duration-200 bg-white text-gray-900","focus:border-primary-500 focus:ring-2 focus:ring-primary-500/20 focus:outline-none focus:shadow-md","dark:border-dark-300 dark:bg-dark-100 dark:text-dark-800","dark:focus:border-primary-400 dark:focus:ring-primary-400/20",a&&"border-error-500 focus:border-error-500 focus:ring-error-500/20",o),...l,children:s.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))}),a&&e.jsx("p",{className:"text-sm text-error-600 dark:text-error-400",children:a}),t&&!a&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-dark-600",children:t})]})};function Sa(r,a){let t;try{t=r()}catch{return}return{getItem:o=>{var i;const l=h=>h===null?null:JSON.parse(h,void 0),d=(i=t.getItem(o))!=null?i:null;return d instanceof Promise?d.then(l):l(d)},setItem:(o,i)=>t.setItem(o,JSON.stringify(i,void 0)),removeItem:o=>t.removeItem(o)}}const pr=r=>a=>{try{const t=r(a);return t instanceof Promise?t:{then(s){return pr(s)(t)},catch(s){return this}}}catch(t){return{then(s){return this},catch(s){return pr(s)(t)}}}},Ca=(r,a)=>(t,s,o)=>{let i={storage:Sa(()=>localStorage),partialize:u=>u,version:0,merge:(u,E)=>({...E,...u}),...a},l=!1;const d=new Set,h=new Set;let g=i.storage;if(!g)return r((...u)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),t(...u)},s,o);const k=()=>{const u=i.partialize({...s()});return g.setItem(i.name,{state:u,version:i.version})},w=o.setState;o.setState=(u,E)=>(w(u,E),k());const P=r((...u)=>(t(...u),k()),s,o);o.getInitialState=()=>P;let v;const N=()=>{var u,E;if(!g)return;l=!1,d.forEach(b=>{var A;return b((A=s())!=null?A:P)});const D=((E=i.onRehydrateStorage)==null?void 0:E.call(i,(u=s())!=null?u:P))||void 0;return pr(g.getItem.bind(g))(i.name).then(b=>{if(b)if(typeof b.version=="number"&&b.version!==i.version){if(i.migrate){const A=i.migrate(b.state,b.version);return A instanceof Promise?A.then(O=>[!0,O]):[!0,A]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,b.state];return[!1,void 0]}).then(b=>{var A;const[O,S]=b;if(v=i.merge(S,(A=s())!=null?A:P),t(v,!0),O)return k()}).then(()=>{D?.(v,void 0),v=s(),l=!0,h.forEach(b=>b(v))}).catch(b=>{D?.(void 0,b)})};return o.persist={setOptions:u=>{i={...i,...u},u.storage&&(g=u.storage)},clearStorage:()=>{g?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>N(),hasHydrated:()=>l,onHydrate:u=>(d.add(u),()=>{d.delete(u)}),onFinishHydration:u=>(h.add(u),()=>{h.delete(u)})},i.skipHydration||N(),v||P},it=Ca,te=or()(it((r,a)=>({theme:{mode:"light"},setTheme:t=>{r({theme:t}),document.documentElement.classList.remove("dark","ophelia"),t.mode==="dark"?document.documentElement.classList.add("dark"):t.mode==="ophelia"&&document.documentElement.classList.add("ophelia")},toggleTheme:()=>{const t=a().theme,s=["light","dark","ophelia"],i=(s.indexOf(t.mode)+1)%s.length;a().setTheme({mode:s[i]})},sidebarOpen:!0,sidebarCompact:!1,setSidebarOpen:t=>r({sidebarOpen:t}),setSidebarCompact:t=>r({sidebarCompact:t}),toggleSidebar:()=>r(t=>({sidebarOpen:!t.sidebarOpen})),toggleSidebarCompact:()=>r(t=>({sidebarCompact:!t.sidebarCompact})),preferences:{theme:{mode:"light"},defaultModel:"",systemMessage:"",generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:"nomic-embed-text",chunkSize:1e3,chunkOverlap:200,similarityThreshold:.3},titleSettings:{autoTitle:!1,taskModel:""},showUsername:!1,backgroundSettings:{enabled:!1,imageUrl:"",blurAmount:10,opacity:.6}},setPreferences:t=>r(s=>({preferences:{...s.preferences,...t}})),loadPreferences:async()=>{try{const{preferencesApi:t}=await re(async()=>{const{preferencesApi:o}=await Promise.resolve().then(()=>tr);return{preferencesApi:o}},void 0),s=await t.getPreferences();if(s.success&&s.data){const o=s.data;r(i=>({preferences:{...i.preferences,...o},backgroundImage:o.backgroundSettings?.imageUrl||null}))}}catch(t){console.warn("Failed to load preferences from backend:",t)}},isGenerating:!1,setIsGenerating:t=>r({isGenerating:t}),hasSeenSettingsNotification:!1,markSettingsNotificationAsSeen:()=>r({hasSeenSettingsNotification:!0}),isDemoMode:x(),demoConfig:Br(),setDemoMode:t=>{r({isDemoMode:t,demoConfig:Br()})},backgroundImage:null,setBackgroundImage:async t=>{if(r({backgroundImage:t}),t){const s=a(),o={...s.preferences,backgroundSettings:{enabled:!0,imageUrl:t,blurAmount:s.preferences.backgroundSettings?.blurAmount||10,opacity:s.preferences.backgroundSettings?.opacity||.6}};s.setPreferences(o);try{const{preferencesApi:i}=await re(async()=>{const{preferencesApi:l}=await Promise.resolve().then(()=>tr);return{preferencesApi:l}},void 0);await i.updatePreferences({backgroundSettings:o.backgroundSettings})}catch(i){console.warn("Failed to save background settings to backend:",i)}}},uploadBackgroundImage:async t=>{try{const s=new FileReader;return new Promise((o,i)=>{s.onload=async l=>{try{const d=l.target?.result;await a().setBackgroundImage(d),o()}catch(d){i(d)}},s.onerror=i,s.readAsDataURL(t)})}catch(s){throw console.error("Failed to upload background image:",s),s}},removeBackgroundImage:async()=>{r({backgroundImage:null});const t=a(),s={enabled:!1,imageUrl:"",blurAmount:t.preferences.backgroundSettings?.blurAmount||10,opacity:t.preferences.backgroundSettings?.opacity||.6};t.setPreferences({backgroundSettings:s});try{const{preferencesApi:o}=await re(async()=>{const{preferencesApi:i}=await Promise.resolve().then(()=>tr);return{preferencesApi:i}},void 0);await o.updatePreferences({backgroundSettings:s})}catch(o){console.warn("Failed to save background removal to backend:",o)}},clearUserState:()=>{r({backgroundImage:null,preferences:{theme:{mode:"light"},defaultModel:"",systemMessage:"",generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:"nomic-embed-text",chunkSize:1e3,chunkOverlap:200,similarityThreshold:.3},titleSettings:{autoTitle:!1,taskModel:""},showUsername:!1,backgroundSettings:{enabled:!1,imageUrl:"",blurAmount:10,opacity:.6}}})}}),{name:"libre-webui-app-state",partialize:r=>{const{backgroundSettings:a,...t}=r.preferences;return{theme:r.theme,sidebarOpen:r.sidebarOpen,sidebarCompact:r.sidebarCompact,preferences:t,hasSeenSettingsNotification:r.hasSeenSettingsNotification}}})),Pa=()=>{const{theme:r,setTheme:a}=te.getState();a(r)};typeof window<"u"&&Pa();const ye=({className:r,size:a="md"})=>{const t={sm:"h-12 w-12",md:"h-20 w-20",lg:"h-32 w-32"};return e.jsx("div",{className:M("flex-shrink-0 rounded-lg flex items-center justify-center bg-transparent",t[a],r),children:e.jsx("img",{src:"/logo-dark.png",alt:"Libre WebUI Logo",className:"w-full h-full object-contain",draggable:!1})})},Aa={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_VERSION:"0.2.4"},Ia=()=>window.location.protocol==="file:"?"http://localhost:3001/api":`${window.location.origin}/api`,Q=Ia(),_a=()=>{console.log("🚀 API_BASE_URL configured as:",Q),console.log("🌐 Window location:",window.location),console.log("🔧 Environment variables:",Aa)};_a();console.log("📱 User agent:",navigator.userAgent);console.log("🎭 Demo mode detected:",x());const y=(r,a=!0)=>new Promise(t=>{setTimeout(()=>{t({success:a,data:r,error:a?void 0:"Demo mode: Backend not available"})},500)}),rr=[{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"}}],lt=()=>[{id:"demo-session-1",title:"Demo Chat Session",model:rr[0].name,messages:[{id:"demo-msg-1",role:"user",content:"Hello! Can you tell me about this demo?",timestamp:Date.now()},{id:"demo-msg-2",role:"assistant",content:"This is a demo of Libre WebUI! In a real deployment, I would be powered by Ollama running locally on your machine. This demo shows the beautiful interface and features without the backend connection.",timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()}],Ea=lt(),Ma=3e5,m=hr.create({baseURL:Q,timeout:Ma});m.interceptors.request.use(r=>{const a=localStorage.getItem("auth-token");return a&&(r.headers.Authorization=`Bearer ${a}`),r},r=>Promise.reject(r));m.interceptors.response.use(r=>r,r=>(console.error("API Error:",r),Promise.reject(r)));const ce={getSessions:()=>m.get("/chat/sessions").then(r=>r.data),createSession:(r,a,t)=>m.post("/chat/sessions",{model:r,title:a,personaId:t}).then(s=>s.data),getSession:r=>{if(x()){const a=lt().find(t=>t.id===r);return a?y(a):Promise.resolve({success:!1,error:"Session not found in demo mode"})}return m.get(`/chat/sessions/${r}`).then(a=>a.data)},updateSession:(r,a)=>{if(x()){const t=Ea.find(s=>s.id===r);if(t){const s={...t,...a,updatedAt:Date.now()};return y(s)}return Promise.resolve({success:!1,error:"Session not found in demo mode"})}return m.put(`/chat/sessions/${r}`,a).then(t=>t.data)},deleteSession:r=>x()?y(null):m.delete(`/chat/sessions/${r}`).then(a=>a.data),clearAllSessions:()=>m.delete("/chat/sessions").then(r=>r.data),generateTitle:(r,a,t)=>{if(x()){const s=t.substring(0,30)+(t.length>30?"...":"");return y({title:s})}return m.post(`/chat/sessions/${r}/generate-title`,{model:a,message:t}).then(s=>s.data)},sendMessage:(r,a,t)=>m.post(`/chat/sessions/${r}/messages`,{content:a,options:t}).then(s=>s.data),saveMessage:(r,a)=>m.post(`/chat/sessions/${r}/messages`,a).then(t=>t.data),updateMessage:(r,a,t)=>x()?y({}):m.put(`/chat/sessions/${r}/messages/${a}`,t).then(s=>s.data),generateChatResponse:(r,a,t)=>m.post(`/chat/sessions/${r}/generate`,{message:a,options:t}).then(s=>s.data),generateChatStreamResponse:(r,a,t)=>({subscribe:async(s,o,i)=>{try{const l=await fetch(`${Q}/chat/sessions/${r}/generate/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:a,options:t})});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const d=l.body?.getReader();if(!d)throw new Error("No response body reader available");const h=new TextDecoder;let g="";const k=()=>{d.read().then(({done:w,value:P})=>{if(w){i?.();return}g+=h.decode(P,{stream:!0});const v=g.split(`
3
+ `);g=v.pop()||"";for(const N of v){const u=N.trim();if(u.startsWith("data: ")){const E=u.slice(6);if(E==="[DONE]"){i?.();return}try{const D=JSON.parse(E);if(s(D),D.type==="done"||D.type==="error"){D.type==="error"?o?.(D.error):i?.();return}}catch(D){console.error("Failed to parse SSE data:",D)}}}k()}).catch(w=>{o?.(w instanceof Error?w:new Error(String(w)))})};return k(),()=>d.cancel()}catch(l){return o?.(l instanceof Error?l:new Error(String(l))),()=>{}}}}),getMessageBranches:(r,a)=>x()?y([]):m.get(`/chat/sessions/${r}/messages/${a}/branches`).then(t=>t.data),switchMessageBranch:(r,a,t)=>x()?y({}):m.post(`/chat/sessions/${r}/messages/${a}/branch`,{branchIndex:t}).then(s=>s.data),createMessageBranch:(r,a,t)=>x()?y({}):m.post(`/chat/sessions/${r}/messages/${a}/branches`,{...t}).then(s=>s.data)},ke={checkHealth:()=>x()?y({status:"offline"},!1):m.get("/ollama/health").then(r=>r.data),getModels:()=>x()?y(rr):m.get("/ollama/models").then(r=>r.data),pullModel:r=>x()?y(null,!1):m.post(`/ollama/models/${r}/pull`).then(a=>a.data),pullModelStream:(r,a,t,s)=>{if(x()){let i=0;const l=setInterval(()=>{i+=Math.random()*20,i>=100?(i=100,a({status:"success",total:100,completed:100,percent:100}),clearInterval(l),setTimeout(t,500)):a({status:"pulling",total:100,completed:i,percent:Math.round(i)})},1e3);return()=>clearInterval(l)}const o=new EventSource(`${Q}/ollama/models/${r}/pull/stream`);return o.onmessage=i=>{const l=JSON.parse(i.data);switch(l.type){case"progress":a({status:l.status,digest:l.digest,total:l.total,completed:l.completed,percent:l.percent});break;case"complete":o.close(),t();break;case"error":o.close(),s(l.error);break}},o.onerror=()=>{o.close(),s("Connection to server lost")},()=>{o.close()}},deleteModel:r=>x()?y(null,!1):m.delete(`/ollama/models/${r}`).then(a=>a.data),showModel:(r,a=!1)=>{if(x()){const t=rr.find(s=>s.name===r);return y(t||null,!!t)}return m.get(`/ollama/models/${r}`,{params:{verbose:a}}).then(t=>t.data)},createModel:r=>x()?y(null,!1):m.post("/ollama/models",r).then(a=>a.data),copyModel:(r,a)=>x()?y(null,!1):m.post("/ollama/models/copy",{source:r,destination:a}).then(t=>t.data),pushModel:r=>x()?y(null,!1):m.post(`/ollama/models/${r}/push`).then(a=>a.data),pullAllModels:()=>x()?y(null,!1):m.post("/ollama/models/pull-all").then(r=>r.data),pullAllModelsStream:(r,a,t)=>{if(x()){const o=rr;let i=0;const l=setInterval(()=>{i++,i<=o.length&&r({current:i,total:o.length,modelName:o[i-1]?.name||"demo-model",status:Math.random()>.1?"success":"error",error:Math.random()>.1?void 0:"Demo error"}),i>=o.length&&(clearInterval(l),setTimeout(a,500))},1e3);return}const s=new EventSource(`${Q}/ollama/models/pull-all/stream`);s.onmessage=o=>{const i=JSON.parse(o.data);switch(i.type){case"progress":r({current:i.current,total:i.total,modelName:i.modelName,status:i.status,error:i.error});break;case"complete":s.close(),a();break;case"error":s.close(),t(i.error);break}},s.onerror=()=>{s.close(),t("Connection to server lost")}},generateEmbeddings:r=>x()?y({embeddings:[[]]},!1):m.post("/ollama/embed",r).then(a=>a.data),listRunningModels:()=>x()?y([]):m.get("/ollama/running").then(r=>r.data),getVersion:()=>x()?y({version:"demo-mode"},!1):m.get("/ollama/version").then(r=>r.data),chatCompletion:r=>x()?y({message:{content:"Demo response",role:"assistant"}},!1):m.post("/ollama/chat",r).then(a=>a.data),checkBlobExists:r=>x()?Promise.resolve(!1):m.head(`/ollama/blobs/${r}`).then(()=>!0).catch(()=>!1),pushBlob:(r,a)=>x()?y(null,!1):m.post(`/ollama/blobs/${r}`,a,{headers:{"Content-Type":"application/octet-stream"}}).then(t=>t.data),generateLegacyEmbeddings:r=>x()?y({embedding:[]},!1):m.post("/ollama/embeddings",r).then(a=>a.data),getLibraryModels:()=>x()?y([{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"]}]):m.get("/ollama/library").then(r=>r.data)},J={getAllPlugins:()=>x()?y([]):m.get("/plugins").then(r=>r.data),uploadPlugin:r=>{if(x())return y({},!1);const a=new FormData;return a.append("plugin",r),m.post("/plugins/upload",a).then(t=>t.data)},installPlugin:r=>x()?y({},!1):m.post("/plugins/install",r).then(a=>a.data),updatePlugin:(r,a)=>x()?y({},!1):m.put(`/plugins/${r}`,a).then(t=>t.data),deletePlugin:r=>x()?y(void 0):m.delete(`/plugins/${r}`).then(a=>a.data),activatePlugin:r=>x()?y({},!1):m.post(`/plugins/activate/${r}`).then(a=>a.data),deactivatePlugin:r=>{if(x())return y(void 0);const a=r?`/plugins/deactivate/${r}`:"/plugins/deactivate";return m.post(a).then(t=>t.data)},getActivePlugin:()=>x()?y(null):m.get("/plugins/active").then(r=>r.data),getPluginStatus:()=>x()?y([]):m.get("/plugins/status").then(r=>r.data),exportPlugin:r=>x()?Promise.resolve(new Blob(["{}"],{type:"application/json"})):m.get(`/plugins/${r}/export`,{responseType:"blob"}).then(a=>a.data)},B={getPreferences:()=>m.get("/preferences").then(r=>r.data),updatePreferences:r=>m.put("/preferences",r).then(a=>a.data),setDefaultModel:r=>m.put("/preferences/default-model",{model:r}).then(a=>a.data),setSystemMessage:r=>m.put("/preferences/system-message",{message:r}).then(a=>a.data),setGenerationOptions:r=>m.put("/preferences/generation-options",r).then(a=>a.data),resetGenerationOptions:()=>m.post("/preferences/generation-options/reset").then(r=>r.data),setEmbeddingSettings:r=>m.put("/preferences/embedding-settings",r).then(a=>a.data),resetEmbeddingSettings:()=>m.post("/preferences/embedding-settings/reset").then(r=>r.data),importData:(r,a="replace")=>x()?y({theme:{mode:"dark"},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}):m.post("/preferences/import",{data:r,mergeStrategy:a}).then(t=>t.data)},fr={uploadDocument:(r,a)=>{if(x())return y({id:"demo-doc-"+Date.now(),filename:r.name,fileType:r.name.endsWith(".pdf")?"pdf":"txt",size:r.size,sessionId:a,uploadedAt:Date.now()});const t=new FormData;return t.append("document",r),a&&t.append("sessionId",a),m.post("/documents/upload",t).then(s=>s.data)},getDocuments:r=>{if(x())return y([]);const a=r?`/documents/session/${r}`:"/documents";return m.get(a).then(t=>t.data)},getDocument:r=>x()?y({id:r,filename:"demo-document.pdf",fileType:"pdf",size:1024,content:"Demo document content...",uploadedAt:Date.now()}):m.get(`/documents/${r}`).then(a=>a.data),searchDocuments:(r,a,t)=>x()?y([]):m.post("/documents/search",{query:r,sessionId:a,limit:t}).then(s=>s.data),deleteDocument:r=>x()?y(void 0):m.delete(`/documents/${r}`).then(a=>a.data),getEmbeddingStatus:()=>x()?y({available:!1,model:"nomic-embed-text",chunksWithEmbeddings:0,totalChunks:0}):m.get("/documents/embeddings/status").then(r=>r.data),regenerateEmbeddings:()=>x()?y(void 0):m.post("/documents/embeddings/regenerate").then(r=>r.data)},ge={login:r=>x()?y({user:{id:"demo-user",username:"demo",email:"demo@example.com",role:"admin",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:"demo-token",systemInfo:{requiresAuth:!0,singleUserMode:!1,hasUsers:!0,version:"0.1.0"}}):m.post("/auth/login",r).then(a=>a.data),signup:r=>x()?y({user:{id:"demo-user-new",username:r.username,email:r.email||"",role:"user",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:"demo-token-new",systemInfo:{requiresAuth:!0,singleUserMode:!1,hasUsers:!0,version:"0.1.0"}}):m.post("/auth/signup",r).then(a=>a.data),logout:()=>x()?y(void 0):m.post("/auth/logout").then(r=>r.data),getSystemInfo:()=>(console.log("getSystemInfo called, demo mode:",x()),x()?y({requiresAuth:!0,singleUserMode:!1,hasUsers:!0,version:"0.1.0"}):(console.log("🔍 Making API call to:",Q+"/auth/system-info"),console.log("🌐 Full URL from:",window.location.origin,"-> API:",Q+"/auth/system-info"),m.get("/auth/system-info").then(r=>(console.log("✅ getSystemInfo response:",r.data),r.data)).catch(r=>{throw console.error("❌ getSystemInfo error:",r),r.response&&(console.error("📄 Error response data:",r.response.data),console.error("🔢 Error status:",r.response.status),console.error("🔧 Error headers:",r.response.headers)),r.request&&console.error("📡 Network error - no response received:",r.request),console.error("🎯 Error config:",r.config),r}))),verifyToken:()=>x()?y({id:"demo-user",username:"demo",email:"demo@example.com",role:"admin",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):m.get("/auth/verify").then(r=>r.data),getEncryptionKey:()=>x()?y({encryptionKey:"demo-encryption-key-not-real"}):m.get("/auth/encryption-key").then(r=>r.data)},dt={getUsers:()=>x()?y([{id:"demo-user",username:"demo",email:"demo@example.com",role:"admin",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]):m.get("/users").then(r=>r.data),createUser:r=>x()?y({id:"new-user-"+Date.now(),username:r.username,email:r.email,role:r.role,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):m.post("/users",r).then(a=>a.data),updateUser:(r,a)=>x()?y({id:r,username:a.username||"demo",email:a.email||"demo@example.com",role:a.role||"user",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):m.patch(`/users/${r}`,a).then(t=>t.data),deleteUser:r=>x()?y(void 0):m.delete(`/users/${r}`).then(a=>a.data),updateMyAvatar:r=>x()?y({id:"demo-user",username:"demo",email:"demo@example.com",role:"admin",avatar:r,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):m.patch("/users/me/avatar",{avatar:r}).then(a=>a.data)},kr={getPersonas:()=>{if(x()){const r=[{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:"/images/creative-avatar.png",background:"/backgrounds/creative-bg.png",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."},created_at:Date.now()-1728e5,updated_at:Date.now()-1728e5}];return y(r)}return m.get("/personas").then(r=>r.data)},getPersona:r=>{if(x()){const a={id:r,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()};return y(a)}return m.get(`/personas/${r}`).then(a=>a.data)},createPersona:r=>{if(x()){const a={id:"demo-"+Date.now(),user_id:"default",...r,created_at:Date.now(),updated_at:Date.now()};return y(a)}return m.post("/personas",r).then(a=>a.data)},updatePersona:(r,a)=>{if(x()){const t={id:r,user_id:"default",name:a.name||"Updated Sample Assistant",description:a.description,model:a.model||"llama3.2:latest",parameters:a.parameters||{temperature:.7,top_p:.9,context_window:4096,system_prompt:"You are a helpful assistant."},avatar:a.avatar,background:a.background,created_at:Date.now()-864e5,updated_at:Date.now()};return y(t)}return m.put(`/personas/${r}`,a).then(t=>t.data)},deletePersona:r=>x()?y(void 0):m.delete(`/personas/${r}`).then(a=>a.data),exportPersona:r=>{if(x()){const a={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(a)}return m.get(`/personas/${r}/export`).then(a=>a.data)},importPersona:r=>{if(x()){const a={id:"demo-imported-"+Date.now(),user_id:"default",name:r.name,description:r.description,model:r.model,parameters:r.params,avatar:r.avatar,background:r.background,created_at:Date.now(),updated_at:Date.now(),embedding_model:r.embedding_model,memory_settings:r.memory_settings,mutation_settings:r.mutation_settings};return y(a)}return m.post("/personas/import",r).then(a=>a.data)},getPersonasCount:()=>x()?y({count:2}):m.get("/personas/stats/count").then(r=>r.data),getDefaultParameters:()=>x()?y({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}):m.get("/personas/defaults/parameters").then(r=>r.data),getMemoryStatus:r=>x()?y({status:"active",memory_count:42,last_backup:Date.now()-864e5,size_mb:2.3}):m.get(`/personas/${r}/memory/status`).then(a=>a.data),wipeMemories:r=>x()?y({deleted_count:42}):m.delete(`/personas/${r}/memory`).then(a=>a.data),backupPersona:r=>{if(x()){const a=JSON.stringify({persona_id:r,backup_date:new Date().toISOString(),data:"demo backup data"});return Promise.resolve(new Blob([a],{type:"application/json"}))}return m.get(`/personas/${r}/backup`,{responseType:"blob"}).then(a=>a.data)},exportPersonaDNA:r=>{if(x()){const a=JSON.stringify({persona_id:r,export_date:new Date().toISOString(),dna:"demo DNA data",memories:[],learned_behaviors:{}});return Promise.resolve(new Blob([a],{type:"application/json"}))}return m.get(`/personas/${r}/export/dna`,{responseType:"blob"}).then(a=>a.data)},importPersonaDNA:r=>{if(x()){const t={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()};return y(t)}const a=new FormData;return a.append("dnaFile",r),m.post("/personas/import/dna",a).then(t=>t.data)},downloadPersona:async(r,a)=>{try{const t=await kr.exportPersona(r),s=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=`${a}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}catch(t){throw console.error("Error while downloading persona:",t),new Error(`Failed to download persona: ${t instanceof Error?t.message:String(t)}`)}}},Le={getModels:()=>x()?y([{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}}]):m.get("/tts/models").then(r=>r.data),getPlugins:()=>x()?y([{id:"openai",name:"OpenAI GPT",models:["tts-1","tts-1-hd"],config:{voices:["alloy","echo","fable","onyx","nova","shimmer"],default_voice:"alloy"}}]):m.get("/tts/plugins").then(r=>r.data),getVoices:r=>x()?y({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}):m.get(`/tts/voices/${r}`).then(a=>a.data),generateBase64:r=>x()?y({audio:"",format:r.response_format||"mp3",mimeType:"audio/mpeg",size:0}):m.post("/tts/generate-base64",r).then(a=>a.data),generate:async r=>x()?new Blob([],{type:"audio/mpeg"}):(await m.post("/tts/generate",r,{responseType:"blob"})).data,speak:async(r,a={})=>{try{a.onStart?.();const t=await Le.generateBase64({model:a.model||"tts-1",input:r,voice:a.voice,speed:a.speed,response_format:"mp3"});if(!t.success||!t.data?.audio)throw new Error(t.message||"Failed to generate speech");const s=`data:${t.data.mimeType};base64,${t.data.audio}`,o=new Audio(s);return o.onended=()=>a.onEnd?.(),o.onerror=()=>a.onError?.(new Error("Audio playback failed")),await o.play(),o}catch(t){const s=t instanceof Error?t:new Error("Unknown error");return a.onError?.(s),null}}},tr=Object.freeze(Object.defineProperty({__proto__:null,authApi:ge,chatApi:ce,documentsApi:fr,ollamaApi:ke,personaApi:kr,pluginApi:J,preferencesApi:B,ttsApi:Le,usersApi:dt},Symbol.toStringTag,{value:"Module"})),Da=({className:r=""})=>{const{preferences:a,setPreferences:t,backgroundImage:s,uploadBackgroundImage:o,removeBackgroundImage:i}=te(),l=c.useRef(null),[d,h]=c.useState(!1),[g,k]=c.useState(!1),w=a.backgroundSettings||{enabled:!1,imageUrl:"",blurAmount:10,opacity:.6},P=async S=>{if(!S.type.startsWith("image/")){j.error("Please select a valid image file");return}if(S.size>5*1024*1024){j.error("Image file size must be less than 5MB");return}h(!0);try{await o(S),j.success("Background image uploaded successfully")}catch(z){console.error("Failed to upload background:",z),j.error("Failed to upload background image")}finally{h(!1)}},v=S=>{const z=S.target.files?.[0];z&&P(z)},N=S=>{S.preventDefault(),k(!0)},u=S=>{S.preventDefault(),k(!1)},E=S=>{S.preventDefault(),k(!1);const z=S.dataTransfer.files?.[0];z&&P(z)},D=()=>{i(),j.success("Background image removed")},b=async S=>{const z=s||w.imageUrl||"",R={...w,imageUrl:z,enabled:S};if(t({backgroundSettings:R}),z||!S)try{await B.updatePreferences({backgroundSettings:R})}catch(W){console.error("Failed to update preferences:",W)}},A=async S=>{const z=s||w.imageUrl||"",R={...w,imageUrl:z,blurAmount:S};if(t({backgroundSettings:R}),z)try{await B.updatePreferences({backgroundSettings:R})}catch(W){console.error("Failed to update preferences:",W)}},O=async S=>{const z=s||w.imageUrl||"",R={...w,imageUrl:z,opacity:S};if(t({backgroundSettings:R}),z)try{await B.updatePreferences({backgroundSettings:R})}catch(W){console.error("Failed to update preferences:",W)}};return e.jsx("div",{className:`space-y-4 ${r}`,children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-md font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Background Image"}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Enable background image"}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Show custom background with blur effect"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:w.enabled,onChange:S=>b(S.target.checked)}),e.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 peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[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"})]})]}),e.jsxs("div",{className:"space-y-4",children:[s?e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("img",{src:s,alt:"Background preview",className:"w-12 h-12 object-cover rounded-md"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:"Custom background image"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Click to change or remove"})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:D,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:e.jsx(ue,{className:"h-4 w-4"})})]})}):e.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${g?"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:N,onDragLeave:u,onDrop:E,onClick:()=>l.current?.click(),children:[e.jsx(Jt,{className:"h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"Upload background image"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-4",children:"Drag and drop an image or click to browse"}),e.jsxs(C,{variant:"outline",size:"sm",disabled:d,className:"mx-auto",children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),d?"Uploading...":"Choose Image"]})]}),e.jsx("input",{ref:l,type:"file",accept:"image/*",onChange:v,className:"hidden"})]}),s&&e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Blur Amount: ",w.blurAmount,"px"]}),e.jsx("input",{type:"range",min:"0",max:"30",step:"1",value:w.blurAmount,onChange:S=>A(parseInt(S.target.value)),className:"w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Opacity: ",Math.round(w.opacity*100),"%"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.1",value:w.opacity,onChange:S=>O(parseFloat(S.target.value)),className:"w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"})]})]})]})})},de=(r,a)=>{if(r&&typeof r=="object"&&"response"in r){const t=r;if(t.response?.data?.error)return t.response.data.error}return r instanceof Error?r.message:a},me=or((r,a)=>({sessions:[],currentSession:null,setCurrentSession:t=>{r({currentSession:t})},createSession:async(t,s,o)=>{try{r({loading:!0,error:null});const i=await ce.createSession(t,s,o);if(i.success&&i.data){const l=i.data;return r(d=>({sessions:[l,...d.sessions],currentSession:l,loading:!1})),j.success("New chat created"),l}}catch(i){const l=de(i,"Failed to create session");r({error:l,loading:!1}),j.error(l)}},loadSessions:async()=>{try{r({loading:!0,error:null});const t=await ce.getSessions();t.success&&t.data&&r(s=>{const o=t.data||[],i=o.map(d=>d.id);let l=null;return s.currentSession&&i.includes(s.currentSession.id)?l=o.find(d=>d.id===s.currentSession.id)||null:o.length>0&&(l=o[0],s.currentSession&&console.warn("Previous currentSession not found in backend sessions:",s.currentSession.id)),{sessions:o,currentSession:l,loading:!1}})}catch(t){const s=de(t,"Failed to load sessions");r({error:s,loading:!1}),j.error(s)}},deleteSession:async t=>{try{const s=await ce.deleteSession(t);s.success?(r(o=>{const i=o.sessions.filter(d=>d.id!==t),l=o.currentSession?.id===t?i[0]||null:o.currentSession;return console.log("Store: Updating state, sessions count:",i.length),{sessions:i,currentSession:l}}),j.success("Chat deleted")):(console.error("Store: deleteSession failed:",s),j.error("Failed to delete chat"))}catch(s){console.error("Store: deleteSession error:",s);const o=de(s,"Failed to delete session");j.error(o)}},clearAllSessions:async()=>{try{r({loading:!0,error:null});const t=await ce.clearAllSessions();t.success?(r({sessions:[],currentSession:null,loading:!1}),j.success("All chat history cleared")):(console.error("Store: clearAllSessions failed:",t),j.error("Failed to clear chat history"),r({loading:!1}))}catch(t){console.error("Store: clearAllSessions error:",t);const s=de(t,"Failed to clear chat history");j.error(s),r({loading:!1})}},clearAllState:()=>{r({sessions:[],currentSession:null,models:[],selectedModel:"",systemMessage:"",loading:!1,error:null})},updateSessionTitle:async(t,s)=>{try{const o=await ce.updateSession(t,{title:s});o.success&&o.data&&(r(i=>({sessions:i.sessions.map(l=>l.id===t?o.data:l),currentSession:i.currentSession?.id===t?o.data:i.currentSession})),j.success("Chat title updated"))}catch(o){const i=de(o,"Failed to update session");j.error(i)}},addMessage:(t,s)=>{const o=a();if(!o.currentSession||!o.sessions.find(l=>l.id===o.currentSession?.id)){j.error("No valid chat session. Please create or select a chat."),console.error("addMessage blocked: currentSession is not valid",o.currentSession?.id);return}if(!o.sessions.find(l=>l.id===t)){j.error("Session not found or invalid. Please select or create a valid chat session."),console.error("addMessage blocked: sessionId not found in sessions",t);return}const i={...s,id:s.id||ja(),timestamp:Date.now()};r(l=>{const d=l.sessions.find(g=>g.id===t);if(d&&d.messages.find(k=>k.id===i.id))return l;const h=l.sessions.map(g=>{if(g.id===t){let k=[...g.messages];if(i.parentId){const w=i.parentId;k=k.map(P=>P.id===w||P.parentId===w?{...P,isActive:!1,branchIndex:P.branchIndex??0,siblingCount:(i.branchIndex||0)+1}:P)}return k.push(i),{...g,messages:k,updatedAt:Date.now()}}return g});return{sessions:h,currentSession:l.currentSession?.id===t&&h.find(k=>k.id===t)||l.currentSession}})},updateMessage:(t,s,o)=>{r(i=>{if(i.currentSession?.id!==t)return i;const l=i.sessions.find(k=>k.id===t);if(!l)return i;const d=l.messages.find(k=>k.id===s);if(!d||d.content===o)return i;const h=i.sessions.map(k=>{if(k.id===t){const w=k.messages.map(P=>P.id===s?{...P,content:o}:P);return{...k,messages:w,updatedAt:Date.now()}}return k}),g=i.currentSession?.id===t&&h.find(k=>k.id===t)||i.currentSession;return{sessions:h,currentSession:g}})},updateMessageWithStatistics:(t,s,o,i)=>{r(l=>{if(l.currentSession?.id!==t)return l;const d=l.sessions.map(g=>{if(g.id===t){const k=g.messages.map(w=>w.id===s?{...w,content:o,statistics:i}:w);return{...g,messages:k,updatedAt:Date.now()}}return g}),h=l.currentSession&&l.currentSession.id===t&&d.find(g=>g.id===t)||l.currentSession;return{sessions:d,currentSession:h}})},models:[],loadModels:async()=>{try{r({loading:!0,error:null}),console.log("Loading models from API...");const t=await ke.getModels();let s=[];t.success&&t.data&&(s=[...t.data],console.log("Ollama models loaded:",t.data.length));try{const o=await J.getAllPlugins();if(o.success&&o.data){const i=o.data.filter(l=>l.active&&l.type!=="tts");console.log("🔌 Active plugins found:",i.map(l=>l.name));for(const l of i)if(l.model_map){const d=l.model_map.map(h=>({name:h,model:h,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,pluginName:l.name}));s.push(...d),console.log("Plugin models added:",d.length,"from",l.name)}}}catch(o){console.error("❌ Failed to load plugin models:",o),o instanceof Error&&console.error("❌ Plugin error details:",{message:o.message,response:o.response?.data,status:o.response?.status,url:o.config?.url})}try{const{personaApi:o}=await re(async()=>{const{personaApi:l}=await Promise.resolve().then(()=>tr);return{personaApi:l}},void 0),i=await o.getPersonas();if(i.success&&i.data){const l=i.data.reduce((h,g)=>(h[g.id]=g,h),{}),d=i.data.map(h=>({name:`persona:${h.id}`,model:h.model,size:0,digest:"",details:{parent_model:h.model,format:"persona",family:"persona",families:["persona"],parameter_size:"",quantization_level:""},modified_at:new Date(h.updated_at).toISOString(),expires_at:new Date().toISOString(),size_vram:0,isPersona:!0,personaName:h.name,personaDescription:h.description}));s.push(...d),r(h=>({...h,personas:l}))}}catch(o){console.error("❌ Failed to load personas:",o)}console.log("Total models loaded:",s.length),r({models:s,loading:!1})}catch(t){console.error("Error loading models:",t);const s=de(t,"Failed to load models");r({error:s,loading:!1}),j.error(s)}},loadPreferences:async()=>{try{const t=await B.getPreferences();if(t.success&&t.data){const{defaultModel:s,systemMessage:o}=t.data;s&&(r({selectedModel:s}),console.log("✅ Loaded default model from backend:",s)),o!==void 0&&(r({systemMessage:o}),console.log("✅ Loaded system message from backend"))}}catch(t){console.warn("❌ Failed to load preferences from backend:",t)}},selectedModel:"",setSelectedModel:t=>{r({selectedModel:t}),B.setDefaultModel(t).catch(s=>{console.warn("Failed to save default model to backend:",s)})},updateCurrentSessionModel:async t=>{const s=a();if(!s.currentSession)throw new Error("No current session to update");try{const o=await ce.updateSession(s.currentSession.id,{model:t});o.success&&o.data&&(r(i=>({sessions:i.sessions.map(l=>l.id===i.currentSession?.id?o.data:l),currentSession:o.data,selectedModel:t})),j.success("Model updated for current chat"))}catch(o){const i=de(o,"Failed to update session model");throw j.error(i),o}},personas:{},loadPersonas:async()=>{try{r({loading:!0,error:null});const t=await kr.getPersonas();if(t.success&&t.data){const s=t.data;r({personas:s.reduce((o,i)=>(o[i.id]=i,o),{}),loading:!1}),console.log("✅ Personas loaded:",s.length)}}catch(t){const s=de(t,"Failed to load personas");r({error:s,loading:!1}),console.error("❌ Failed to load personas:",s)}},getCurrentPersona:()=>{const t=a();if(!t.currentSession||!t.currentSession.model?.startsWith("persona:"))return null;const s=t.currentSession.model.replace("persona:","");return t.personas[s]||null},systemMessage:"",setSystemMessage:t=>{const s=a();if(r({systemMessage:t}),B.setSystemMessage(t).catch(o=>{console.warn("Failed to save system message to backend:",o)}),s.currentSession){const o=s.currentSession.messages.findIndex(i=>i.role==="system");if(o!==-1){r(l=>{const d=l.sessions.map(g=>{if(g.id===l.currentSession?.id){const k=g.messages.map((w,P)=>P===o&&w.role==="system"?{...w,content:t,timestamp:Date.now()}:w);return{...g,messages:k,updatedAt:Date.now()}}return g}),h=l.currentSession?d.find(g=>g.id===l.currentSession.id)||l.currentSession:null;return{sessions:d,currentSession:h}});const i=s.currentSession.messages[o];ce.updateMessage(s.currentSession.id,i.id,{content:t}).catch(l=>{console.warn("Failed to sync system message update to backend:",l)}),console.log("✅ Updated system message in current session")}}},loading:!1,error:null,setError:t=>r({error:t}),generatingTitleForSession:null,setGeneratingTitleForSession:t=>r({generatingTitleForSession:t}),...typeof window<"u"&&{testPluginApi:async()=>{try{console.log("🧪 Testing plugin API...");const t=await J.getAllPlugins();return console.log("✅ Plugin API test result:",t),t}catch(t){return console.error("❌ Plugin API test failed:",t),{error:t}}}}})),vr=or((r,a)=>({plugins:[],pluginStatus:[],isLoading:!1,isUploading:!1,error:null,loadPlugins:async()=>{r({isLoading:!0,error:null});try{const t=await J.getAllPlugins();t.success&&t.data?r({plugins:t.data}):r({error:t.error||"Failed to load plugins"})}catch(t){r({error:t instanceof Error?t.message:"Failed to load plugins"})}finally{r({isLoading:!1})}},uploadPlugin:async t=>{r({isUploading:!0,error:null});try{const s=await J.uploadPlugin(t);s.success&&s.data?await a().loadPlugins():r({error:s.error||"Failed to upload plugin"})}catch(s){r({error:s instanceof Error?s.message:"Failed to upload plugin"})}finally{r({isUploading:!1})}},installPlugin:async t=>{r({isLoading:!0,error:null});try{const s=await J.installPlugin(t);s.success&&s.data?await a().loadPlugins():r({error:s.error||"Failed to install plugin"})}catch(s){r({error:s instanceof Error?s.message:"Failed to install plugin"})}finally{r({isLoading:!1})}},updatePlugin:async(t,s)=>{r({isLoading:!0,error:null});try{const o=await J.updatePlugin(t,s);o.success&&o.data?await a().loadPlugins():r({error:o.error||"Failed to update plugin"})}catch(o){r({error:o instanceof Error?o.message:"Failed to update plugin"})}finally{r({isLoading:!1})}},deletePlugin:async t=>{r({isLoading:!0,error:null});try{const s=await J.deletePlugin(t);s.success?await a().loadPlugins():r({error:s.error||"Failed to delete plugin"})}catch(s){r({error:s instanceof Error?s.message:"Failed to delete plugin"})}finally{r({isLoading:!1})}},activatePlugin:async t=>{r({isLoading:!0,error:null});try{const s=await J.activatePlugin(t);s.success?await a().loadPlugins():r({error:s.error||"Failed to activate plugin"})}catch(s){r({error:s instanceof Error?s.message:"Failed to activate plugin"})}finally{r({isLoading:!1})}},deactivatePlugin:async t=>{r({isLoading:!0,error:null});try{const s=await J.deactivatePlugin(t);s.success?await a().loadPlugins():r({error:s.error||"Failed to deactivate plugin"})}catch(s){r({error:s instanceof Error?s.message:"Failed to deactivate plugin"})}finally{r({isLoading:!1})}},loadPluginStatus:async()=>{try{const t=await J.getPluginStatus();t.success&&t.data&&r({pluginStatus:t.data})}catch(t){console.error("Failed to load plugin status:",t)}},exportPlugin:async t=>{r({isLoading:!0,error:null});try{const s=await J.exportPlugin(t),o=window.URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=`${t}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(o)}catch(s){r({error:s instanceof Error?s.message:"Failed to export plugin"})}finally{r({isLoading:!1})}},clearError:()=>r({error:null}),setError:t=>r({error:t})})),Oa="0.2.4",Hr={version:Oa},ct=({isOpen:r,onClose:a})=>{const{models:t,selectedModel:s,setSelectedModel:o,systemMessage:i,setSystemMessage:l,clearAllSessions:d,loading:h,sessions:g,loadModels:k,loadSessions:w}=me(),{theme:P,setTheme:v,preferences:N,setPreferences:u,loadPreferences:E}=te(),{plugins:D,isLoading:b,isUploading:A,error:O,loadPlugins:S,uploadPlugin:z,deletePlugin:R,activatePlugin:W,deactivatePlugin:G,exportPlugin:T,clearError:F,installPlugin:oe}=vr(),[ae,ie]=c.useState("appearance"),[X,xe]=c.useState(i),[Z,_e]=c.useState({modelsCount:0,sessionsCount:0,isHealthy:!1}),[he,Ee]=c.useState(!1),[H,pe]=c.useState(null),[We,ve]=c.useState(!1),[Be,Me]=c.useState(!1),[De,je]=c.useState(""),we=c.useRef(null),[K,Ne]=c.useState(N.generationOptions||{}),[f,$]=c.useState(N.embeddingSettings||{enabled:!1,model:"nomic-embed-text",chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7}),[_,He]=c.useState(null),[Ke,jr]=c.useState(!1),[L,Oe]=c.useState(N.ttsSettings||{enabled:!1,autoPlay:!1,model:"",voice:"",speed:1,pluginId:""}),[Se,gt]=c.useState([]),[wr,xt]=c.useState([]),[Nr,ir]=c.useState([]),[ht,Sr]=c.useState(!1),[Cr,Te]=c.useState(!1),[lr,qe]=c.useState(null),[Ge,Pr]=c.useState(!1),[pt,dr]=c.useState(!1),[cr,Ar]=c.useState("skip"),[se,Fe]=c.useState(null),[Ir,mr]=c.useState(null),Ce=c.useRef(null);c.useEffect(()=>{r&&(Ve(),_r(),ft(),xe(i),Ne(N.generationOptions||{}),$(N.embeddingSettings||{enabled:!1,model:"nomic-embed-text",chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7}),Oe(N.ttsSettings||{enabled:!1,autoPlay:!1,model:"",voice:"",speed:1,pluginId:""}),S(),k())},[r,i]);const Ve=async()=>{try{const[n,p]=await Promise.all([ke.checkHealth().catch(()=>({success:!1})),ke.getVersion().catch(()=>({success:!1,data:null}))]);_e({ollamaVersion:p.success&&p.data?p.data.version:void 0,modelsCount:t.length,sessionsCount:g.length,isHealthy:n.success})}catch(n){console.error("Failed to load system info:",n)}},_r=async()=>{try{const n=await fr.getEmbeddingStatus();n.success&&n.data&&He(n.data)}catch(n){console.error("Failed to load embedding status:",n)}},ft=async()=>{Sr(!0);try{const[n,p]=await Promise.all([Le.getModels(),Le.getPlugins()]);if(n.success&&n.data){if(gt(n.data),!L.model&&n.data.length>0){const I=n.data[0];Oe(le=>({...le,model:I.model,pluginId:I.plugin,voice:I.config?.default_voice||""})),I.config?.voices&&ir(I.config.voices)}else if(L.model){const I=n.data.find(le=>le.model===L.model);I?.config?.voices&&ir(I.config.voices)}}p.success&&p.data&&xt(p.data)}catch(n){console.error("Failed to load TTS data:",n)}finally{Sr(!1)}},bt=async n=>{const p=Se.find(I=>I.model===n);p&&(Oe(I=>({...I,model:n,pluginId:p.plugin,voice:p.config?.default_voice||I.voice})),p.config?.voices&&ir(p.config.voices))},Je=(n,p)=>{Oe(I=>({...I,[n]:p}))},yt=async()=>{try{const n=await B.updatePreferences({ttsSettings:L});n.success&&n.data&&(u(n.data),j.success("TTS settings saved successfully"))}catch(n){const p=n instanceof Error?n.message:String(n);j.error("Failed to save TTS settings: "+p)}},kt=async()=>{if(Cr){lr&&(lr.pause(),lr.currentTime=0,qe(null)),Te(!1);return}Te(!0);try{const n=await Le.generateBase64({model:L.model||"tts-1",input:"Hello! This is a test of the text-to-speech system.",voice:L.voice||"alloy",speed:L.speed||1,response_format:"mp3"});if(n.success&&n.data?.audio){const p=`data:${n.data.mimeType};base64,${n.data.audio}`,I=new Audio(p);qe(I),I.onended=()=>{Te(!1),qe(null)},I.onerror=()=>{j.error("Failed to play audio"),Te(!1),qe(null)},await I.play()}else throw new Error(n.message||"Failed to generate speech")}catch(n){const p=n instanceof Error?n.message:String(n);j.error("TTS test failed: "+p),Te(!1)}},vt=()=>{Oe({enabled:!1,autoPlay:!1,model:Se[0]?.model||"",voice:Se[0]?.config?.default_voice||"",speed:1,pluginId:Se[0]?.plugin||""})},jt=async()=>{try{jr(!0),(await fr.regenerateEmbeddings()).success&&(j.success("Embeddings regenerated successfully"),await _r())}catch(n){const p=n instanceof Error?n.message:String(n);j.error("Failed to regenerate embeddings: "+p)}finally{jr(!1)}},ur=async n=>{try{const p=await B.updatePreferences(n);p.success&&p.data&&(u(p.data),j.success("Settings updated successfully"))}catch(p){const I=p instanceof Error?p.message:String(p);j.error("Failed to update settings: "+I)}},wt=async n=>{const p=n.target.files?.[0];p&&(await z(p),ve(!1),we.current&&(we.current.value=""),await k())},Nt=async()=>{try{const n=JSON.parse(De);await oe(n),Me(!1),je(""),await k()}catch{F(),j.error("Invalid JSON format")}},St=async n=>{D.find(I=>I.id===n)?.active?await G(n):await W(n),await k()},Ct=async n=>{window.confirm("Are you sure you want to delete this plugin?")&&(await R(n),await k())},Pt=async n=>{await T(n)};if(!r)return null;const gr=n=>{const p={mode:n};v(p),ur({theme:p})},At=n=>{const p=n.target.value;o(p),ur({defaultModel:p}),j.success("Default model updated")},It=n=>{xe(n.target.value)},_t=()=>{l(X),ur({systemMessage:X}),j.success("System message updated")},Et=async()=>{window.confirm("Are you sure you want to delete all chat history? This action cannot be undone.")&&(await d(),Ve(),j.success("All chat sessions deleted"))},Mt=()=>{const n={format:"libre-webui-export",version:"1.0",preferences:N,sessions:g,documents:[],exportedAt:new Date().toISOString()},p=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),I=URL.createObjectURL(p),le=document.createElement("a");le.href=I,le.download=`libre-webui-export-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(le),le.click(),document.body.removeChild(le),URL.revokeObjectURL(I),j.success("Data exported successfully")},Dt=n=>{const p=n.target.files?.[0];p&&(mr(p),dr(!0),Fe(null))},Ot=async()=>{if(Ir){Pr(!0);try{const n=await Ir.text(),p=JSON.parse(n);if(!p.format||p.format!=="libre-webui-export")throw new Error("Invalid export format. Please use a valid Libre WebUI export file.");const I=await B.importData(p,cr==="overwrite"?"replace":"merge");if(I.success&&I.data)Fe({preferences:{imported:!0,error:null},sessions:{imported:0,skipped:0,errors:[]},documents:{imported:0,skipped:0,errors:[]}}),j.success("Data imported successfully"),await E(),await w();else throw new Error(I.error||"Import failed")}catch(n){j.error(n instanceof Error?n.message:"Import failed"),Fe(null)}finally{Pr(!1),dr(!1),mr(null),Ce.current&&(Ce.current.value="")}}},Tt=()=>{dr(!1),mr(null),Fe(null),Ce.current&&(Ce.current.value="")},Ft=async()=>{Ee(!0),pe(null),ke.pullAllModelsStream(n=>{pe(n)},()=>{Ee(!1),pe(null),j.success("All models updated successfully!"),Ve()},n=>{Ee(!1),pe(null),j.error("Failed to update models: "+n)})},ee=(n,p)=>{Ne(I=>({...I,[n]:p}))},zt=async()=>{try{const n=await B.setGenerationOptions(K);n.success&&n.data&&(u(n.data),j.success("Generation options updated successfully"))}catch(n){const p=n instanceof Error?n.message:String(n);j.error("Failed to update generation options: "+p)}},Lt=async()=>{try{const n=await B.resetGenerationOptions();n.success&&n.data&&(u(n.data),Ne(n.data.generationOptions||{}),j.success("Generation options reset to defaults"))}catch(n){const p=n instanceof Error?n.message:String(n);j.error("Failed to reset generation options: "+p)}},ne=(n,p)=>{$(I=>({...I,[n]:p}))},Er=async()=>{try{const n=await B.setEmbeddingSettings(f);n.success&&n.data&&(u(n.data),j.success("Embedding settings updated successfully"))}catch(n){const p=n instanceof Error?n.message:String(n);j.error("Failed to update embedding settings: "+p)}},Mr=async()=>{try{const n=await B.resetEmbeddingSettings();n.success&&n.data&&(u(n.data),$(n.data.embeddingSettings||{}),j.success("Embedding settings reset to defaults"))}catch(n){const p=n instanceof Error?n.message:String(n);j.error("Failed to reset embedding settings: "+p)}},Ut=[{id:"appearance",label:"Appearance",icon:Yt},{id:"models",label:"Models",icon:Or},{id:"generation",label:"Generation",icon:Qt},{id:"tts",label:"Text-to-Speech",icon:Tr},{id:"documents",label:"Documents & RAG",icon:ze},{id:"plugins",label:"Plugins",icon:Fr},{id:"system",label:"System",icon:Xt},{id:"data",label:"Data",icon:ze},{id:"about",label:"About",icon:et}],Rt=()=>{switch(ae){case"appearance":return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Appearance"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("button",{onClick:()=>gr("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 ${P.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 ophelia:border-[#262626] ophelia:text-[#e5e5e5] ophelia:bg-[#0a0a0a] ophelia:hover:bg-[#121212]"}`,children:[e.jsx(aa,{className:"h-4 w-4"}),"Light"]}),e.jsxs("button",{onClick:()=>gr("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 ${P.mode==="dark"?"bg-dark-300 text-dark-800 border border-dark-400 shadow-sm hover:bg-dark-400 focus:ring-dark-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 ophelia:border-[#262626] ophelia:text-[#e5e5e5] ophelia:bg-[#0a0a0a] ophelia:hover:bg-[#121212]"}`,children:[e.jsx(sa,{className:"h-4 w-4"}),"Dark"]}),e.jsxs("button",{onClick:()=>gr("ophelia"),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 ${P.mode==="ophelia"?"bg-purple-600 text-white shadow-sm hover:bg-purple-700 hover:shadow-md focus:ring-purple-500 border border-purple-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:[e.jsx(na,{className:"h-4 w-4"}),"AMOLED"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-md font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Chat Interface"}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Show username in chat"}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:'Display your username instead of "you" in chat messages'})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:N.showUsername,onChange:n=>{const p=n.target.checked;u({showUsername:p}),B.updatePreferences({showUsername:p})}}),e.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 peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[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"})]})]})})]}),e.jsx(Da,{})]});case"system":return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"System Status"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${Z.isHealthy?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Ollama Status"})]}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:Z.isHealthy?"Healthy":"Offline"}),Z.ollamaVersion&&e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["v",Z.ollamaVersion]})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ta,{className:"h-3 w-3 text-gray-500 dark:text-dark-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Models"})]}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:Z.modelsCount})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(sr,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Chat Sessions"})]}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:Z.sessionsCount})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ze,{className:"h-3 w-3 text-purple-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Current Model"})]}),e.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 truncate",children:s||"Not set"})]})]}),e.jsx(C,{onClick:Ve,variant:"outline",size:"sm",children:"Refresh Status"})]})});case"models":return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Model Settings"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Default Model"}),e.jsx(Pe,{value:s||"",onChange:At,options:[{value:"",label:"Select a model"},...t.map(n=>({value:n.name,label:n.name}))]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"This model will be used for new conversations"})]}),s&&e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Current Model Information"}),e.jsx("div",{className:"bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.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:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Name:"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ml-2",children:s})]}),(()=>{const n=t.find(p=>p.name===s);return n?.details?e.jsxs(e.Fragment,{children:[e.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:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Size:"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:n.details.parameter_size})]}),e.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:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Family:"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:n.details.family})]}),e.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:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Format:"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:n.details.format})]})]}):null})()]})})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"System Message"}),e.jsx(ot,{value:X,onChange:It,placeholder:"Enter a system message that will be added to the beginning of new chat sessions...",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}),e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"This message will be automatically added to the start of new conversations to set the AI's behavior and context."}),e.jsx(C,{onClick:_t,size:"sm",disabled:h||X===i,children:"Save"})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Auto Title Generation"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Enable auto-title"}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Automatically generate chat titles from the first message"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",checked:N.titleSettings?.autoTitle||!1,onChange:n=>{const p=n.target.checked,I={...N.titleSettings,autoTitle:p,taskModel:N.titleSettings?.taskModel||""};u({titleSettings:I}),B.updatePreferences({titleSettings:I})}}),e.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 peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[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"})]})]}),N.titleSettings?.autoTitle&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Model"}),e.jsx(Pe,{value:N.titleSettings?.taskModel||"",onChange:n=>{const p=n.target.value,I={...N.titleSettings,autoTitle:N.titleSettings?.autoTitle||!1,taskModel:p};u({titleSettings:I}),B.updatePreferences({titleSettings:I})},options:[{value:"",label:"Select a model for title generation"},...t.map(n=>({value:n.name,label:n.name}))]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"This model will summarize your first message to create a chat title. Use a smaller, faster model for best performance."})]})]})]})}),e.jsx("div",{className:"mt-6",children:e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Bulk Model Operations"}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Update All Models"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Pull the latest versions of all currently installed models from the registry."}),he&&H&&e.jsxs("div",{className:"mb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-gray-600 dark:text-dark-600 font-medium",children:["Updating ",H.modelName,"... (",H.current,"/",H.total,")"]}),e.jsxs("span",{className:"text-primary-600 dark:text-primary-400 font-semibold",children:[Math.round(H.current/H.total*100),"%"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-dark-300 rounded-full h-3 shadow-subtle",children:e.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:`${H.current/H.total*100}%`}})}),e.jsxs("div",{className:"text-xs flex items-center justify-between",children:[e.jsxs("span",{className:"text-gray-500 dark:text-dark-500",children:["Status:"," ",H.status==="starting"?e.jsx("span",{className:"text-accent-500 dark:text-accent-400",children:"🔄 Starting..."}):H.status==="success"?e.jsx("span",{className:"text-success-600 dark:text-success-500",children:"✓ Complete"}):H.status==="error"?e.jsxs("span",{className:"text-error-600 dark:text-error-500",children:["✗ Error: ",H.error]}):""]}),e.jsxs("span",{className:"text-gray-400 dark:text-dark-600 text-[10px]",children:[H.current," of ",H.total," ","models"]})]})]}),e.jsx(C,{onClick:Ft,variant:"outline",size:"sm",className:"w-full",disabled:he||h||t.length===0,children:he?"Updating Models...":`Update All Models (${t.length})`})]})})]})})]})});case"tts":return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Text-to-Speech Settings"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:"Configure text-to-speech for reading assistant messages aloud."}),ht?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(yr,{className:"h-8 w-8 animate-spin text-primary-500"}),e.jsx("span",{className:"ml-3 text-gray-600 dark:text-gray-400",children:"Loading TTS providers..."})]}):Se.length===0?e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Tr,{className:"h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-yellow-800 dark:text-yellow-200",children:"No TTS Providers Available"}),e.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300 mt-1",children:"To enable text-to-speech, install a TTS plugin (like OpenAI TTS or ElevenLabs) and configure the API key in your environment."})]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Enable Text-to-Speech"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Show TTS button on assistant messages"})]}),e.jsxs("label",{className:"flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:L.enabled,onChange:n=>Je("enabled",n.target.checked),className:"sr-only"}),e.jsx("div",{className:`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 ${L.enabled?"bg-primary-600 dark:bg-primary-500":"bg-gray-200 dark:bg-dark-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${L.enabled?"translate-x-6":"translate-x-1"}`})})]})]})}),e.jsx("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Auto-Play Messages"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Automatically read assistant messages aloud when they complete"})]}),e.jsxs("label",{className:"flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:L.autoPlay,onChange:n=>Je("autoPlay",n.target.checked),disabled:!L.enabled,className:"sr-only"}),e.jsx("div",{className:`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 ${L.enabled?L.autoPlay?"bg-primary-600 dark:bg-primary-500":"bg-gray-200 dark:bg-dark-300":"bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${L.autoPlay?"translate-x-6":"translate-x-1"}`})})]})]})}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-4",children:"Voice Configuration"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"TTS Model"}),e.jsx(Pe,{value:L.model,onChange:n=>bt(n.target.value),disabled:!L.enabled,options:[{value:"",label:"Select a model"},...Se.map(n=>({value:n.model,label:`${n.model} (${n.plugin})`}))]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"The AI model used for speech synthesis"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Voice"}),e.jsx(Pe,{value:L.voice,onChange:n=>Je("voice",n.target.value),disabled:!L.enabled||Nr.length===0,options:[{value:"",label:"Select a voice"},...Nr.map(n=>({value:n,label:n.charAt(0).toUpperCase()+n.slice(1)}))]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"The voice persona for speech output"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Speed: ",L.speed.toFixed(1),"x"]}),e.jsx("input",{type:"range",min:"0.25",max:"4.0",step:"0.25",value:L.speed,onChange:n=>Je("speed",parseFloat(n.target.value)),disabled:!L.enabled,className:"w-full range-slider"}),e.jsxs("div",{className:"flex justify-between text-xs text-gray-500 mt-1",children:[e.jsx("span",{children:"0.25x (Slow)"}),e.jsx("span",{children:"1.0x (Normal)"}),e.jsx("span",{children:"4.0x (Fast)"})]})]})]})]}),wr.length>0&&e.jsxs("div",{className:"bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Available TTS Providers"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:wr.map(n=>e.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:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:n.name}),e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",n.models?.length||0," models)"]})]},n.id))})]}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{onClick:vt,variant:"outline",className:"flex items-center gap-2",children:[e.jsx(Qe,{size:16}),"Reset"]}),e.jsx(C,{onClick:kt,variant:"outline",disabled:!L.enabled||!L.model,className:"flex items-center gap-2",children:Cr?e.jsxs(e.Fragment,{children:[e.jsx(ea,{size:16}),"Stop"]}):e.jsxs(e.Fragment,{children:[e.jsx(ra,{size:16}),"Test Voice"]})})]}),e.jsxs(C,{onClick:yt,className:"flex items-center gap-2",children:[e.jsx(be,{size:16}),"Save Settings"]})]})]})]})});case"documents":return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Documents & RAG Settings"}),e.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:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Vector Embeddings"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Enable semantic search using vector embeddings for better document relevance"})]}),e.jsxs("label",{className:"flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f.enabled,onChange:n=>ne("enabled",n.target.checked),className:"sr-only"}),e.jsx("div",{className:`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 ${f.enabled?"bg-primary-600 dark:bg-primary-500":"bg-gray-200 dark:bg-dark-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${f.enabled?"translate-x-6":"translate-x-1"}`})})]})]}),f.enabled&&e.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Embedding Model"}),e.jsx(Pe,{value:f.model,onChange:n=>ne("model",n.target.value),options:[{value:"nomic-embed-text",label:"nomic-embed-text"},{value:"all-minilm",label:"all-minilm"},{value:"sentence-transformers",label:"sentence-transformers"}]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Model used for generating embeddings"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Chunk Size: ",f.chunkSize]}),e.jsx("input",{type:"range",min:"500",max:"2000",step:"100",value:f.chunkSize,onChange:n=>ne("chunkSize",parseInt(n.target.value)),className:"w-full range-slider"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Size of text chunks for processing"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Chunk Overlap: ",f.chunkOverlap]}),e.jsx("input",{type:"range",min:"50",max:"500",step:"50",value:f.chunkOverlap,onChange:n=>ne("chunkOverlap",parseInt(n.target.value)),className:"w-full range-slider"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Character overlap between chunks"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Similarity Threshold:"," ",f.similarityThreshold.toFixed(2)]}),e.jsx("input",{type:"range",min:"0.3",max:"0.9",step:"0.05",value:f.similarityThreshold,onChange:n=>ne("similarityThreshold",parseFloat(n.target.value)),className:"w-full range-slider"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Minimum similarity score for search results"})]})]})]}),_&&e.jsxs("div",{className:"bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"Embedding Status"}),e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300 space-y-1",children:[e.jsxs("div",{children:["Status:"," ",e.jsx("span",{className:`font-medium ${_.available?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:_.available?"Enabled":"Disabled"})]}),e.jsxs("div",{children:["Model:"," ",e.jsx("span",{className:"font-medium",children:_.model})]}),e.jsxs("div",{children:["Chunks with embeddings:"," ",e.jsxs("span",{className:"font-medium",children:[_.chunksWithEmbeddings," /"," ",_.totalChunks]})]}),_.totalChunks>0&&e.jsxs("div",{children:["Coverage:"," ",e.jsxs("span",{className:"font-medium",children:[Math.round(_.chunksWithEmbeddings/_.totalChunks*100),"%"]})]})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(C,{onClick:Mr,variant:"outline",className:"flex items-center gap-2",children:[e.jsx(Qe,{size:16}),"Reset to Defaults"]}),f.enabled&&_&&_.totalChunks>0&&e.jsxs(C,{onClick:jt,disabled:Ke,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:[e.jsx(ze,{size:16}),Ke?"Regenerating...":"Regenerate Embeddings"]})]}),e.jsxs(C,{onClick:Er,className:"flex items-center gap-2",children:[e.jsx(be,{size:16}),"Save Settings"]})]})]})});case"plugins":return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Plugin Management"}),O&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-red-800 dark:text-red-200",children:O}),e.jsx(C,{variant:"ghost",size:"sm",onClick:F,className:"text-red-600 hover:text-red-800",children:e.jsx(ue,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Add New Plugin"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>ve(!We),disabled:b||A,children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),"Upload File"]}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>Me(!Be),disabled:b,children:"Add JSON"})]})]}),We&&e.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:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("input",{ref:we,type:"file",accept:".json,.zip",onChange:wt,className:"flex-1 p-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white",disabled:A}),e.jsx(C,{variant:"outline",size:"sm",onClick:()=>ve(!1),disabled:A,children:"Cancel"})]}),A&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-2",children:"Uploading plugin..."})]}),Be&&e.jsx("div",{className:"bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("textarea",{value:De,onChange:n=>je(n.target.value),placeholder:"Paste plugin JSON here...",className:"w-full h-32 p-3 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white font-mono text-sm",disabled:b}),e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>{Me(!1),je("")},children:"Cancel"}),e.jsx(C,{size:"sm",onClick:Nt,disabled:!De.trim()||b,children:"Install Plugin"})]})]})})]}),D.filter(n=>n.active).length>0&&e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6",children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:["Active Plugins (",D.filter(n=>n.active).length,")"]}),e.jsx("div",{className:"space-y-2",children:D.filter(n=>n.active).map(n=>e.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:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-green-800 dark:text-green-200",children:n.name}),e.jsxs("p",{className:"text-xs text-green-600 dark:text-green-300",children:[n.type," • ",n.model_map?.length||0," ","models"]})]}),e.jsx(C,{variant:"outline",size:"sm",onClick:async()=>{await G(n.id),await k()},className:"text-green-600 border-green-300 hover:bg-green-100",children:"Deactivate"})]},n.id))})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-dark-300",children:e.jsxs("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Installed Plugins (",D.length,")"]})}),b?e.jsx("div",{className:"p-8 text-center",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Loading plugins..."})}):D.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(Fr,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No plugins installed"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Upload a plugin file or add JSON configuration to get started"})]}):e.jsx("div",{className:"divide-y divide-gray-200 dark:divide-dark-300",children:D.map(n=>e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${n.active?"bg-green-500":"bg-gray-300 dark:bg-gray-600"}`}),e.jsxs("div",{children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-gray-100",children:n.name}),e.jsxs("div",{className:"flex items-center space-x-2 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:n.type}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[n.model_map?.length||0," models"]}),n.endpoint&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{className:"truncate max-w-32",children:n.endpoint})]})]})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:()=>St(n.id),disabled:b,className:n.active?"text-green-600 border-green-300":"",children:n.active?e.jsxs(e.Fragment,{children:[e.jsx(be,{className:"h-4 w-4 mr-1"}),"Active"]}):"Activate"}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>Pt(n.id),disabled:b,title:"Export plugin",children:e.jsx(Zt,{className:"h-4 w-4"})}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>Ct(n.id),disabled:b,className:"text-red-600 hover:text-red-700 hover:bg-red-50",title:"Delete plugin",children:e.jsx(tt,{className:"h-4 w-4"})})]})]})},n.id))})]})]})});case"data":return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Data Management"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Export Data"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Download your settings and chat history as a JSON file."}),e.jsx(C,{onClick:Mt,variant:"outline",size:"sm",className:"w-full",children:"Export All Data"})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Import Data"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Restore your settings and chat history from a JSON file."}),e.jsx("input",{ref:Ce,type:"file",accept:".json",onChange:Dt,className:"hidden"}),e.jsx(C,{onClick:()=>Ce.current?.click(),variant:"outline",size:"sm",className:"w-full",disabled:Ge,children:Ge?"Importing...":"Import Data"})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Clear Sessions"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Delete all chat sessions permanently. This cannot be undone."}),e.jsx(C,{onClick:Et,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:g.length===0||h,children:h?"Clearing...":`Clear All Sessions (${g.length})`})]})]}),pt&&e.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:[e.jsx("h5",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Import Options"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"How should we handle existing data with the same IDs?"}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"mergeStrategy",value:"skip",checked:cr==="skip",onChange:n=>Ar(n.target.value),className:"mr-2"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Skip duplicates (keep existing data)"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"mergeStrategy",value:"overwrite",checked:cr==="overwrite",onChange:n=>Ar(n.target.value),className:"mr-2"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Overwrite existing data"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{onClick:Ot,size:"sm",disabled:Ge,children:Ge?"Importing...":"Import"}),e.jsx(C,{onClick:Tt,variant:"outline",size:"sm",children:"Cancel"})]})]}),se&&e.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:[e.jsx("h5",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"Import Results"}),e.jsxs("div",{className:"text-xs text-gray-700 dark:text-gray-300 space-y-1",children:[e.jsxs("div",{children:["Preferences:"," ",se.preferences.imported?"✅ Imported":"❌ Failed"]}),e.jsxs("div",{children:["Sessions: ✅ ",se.sessions.imported," imported, ⏭️ ",se.sessions.skipped," skipped"]}),e.jsxs("div",{children:["Documents: ✅ ",se.documents.imported," ","imported, ⏭️ ",se.documents.skipped," skipped"]}),(se.sessions.errors.length>0||se.documents.errors.length>0)&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"font-medium",children:"Errors:"}),se.sessions.errors.map((n,p)=>e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["• ",n]},p)),se.documents.errors.map((n,p)=>e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["• ",n]},p))]})]}),e.jsx(C,{onClick:()=>Fe(null),variant:"outline",size:"sm",className:"mt-2",children:"Close"})]})]})]})});case"about":return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"libre-brand text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100 mb-4",style:{fontWeight:300,letterSpacing:"0.01em"},children:"Libre WebUI"}),e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 mb-6",children:e.jsx("span",{children:"About"})}),e.jsx("div",{className:"bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300",children:e.jsxs("div",{className:"space-y-4 text-sm text-gray-700 dark:text-gray-300",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full mt-2 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Privacy First"}),e.jsx("p",{children:"All your data stays on your machine. No telemetry, no tracking, no cloud dependencies."})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Open Source"}),e.jsx("p",{children:"100% free and open source software licensed under Apache 2.0. Community-driven development."})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-2 h-2 bg-purple-500 rounded-full mt-2 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Local Inference"}),e.jsx("p",{children:"Powered by Ollama for completely offline AI inference. No internet required once models are downloaded."})]})]})]})}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Links & Resources"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("a",{href:"https://github.com/libre-webui/libre-webui",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:[e.jsx(rt,{className:"h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"GitHub Repository"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Source code & contributions"})]}),e.jsx(Ie,{className:"h-4 w-4 text-gray-400 ml-auto opacity-0 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("a",{href:"https://librewebui.org",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:[e.jsx(Ie,{className:"h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Official Website"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Documentation & guides"})]}),e.jsx(Ie,{className:"h-4 w-4 text-gray-400 ml-auto opacity-0 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("a",{href:"https://ollama.ai",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:[e.jsx(Or,{className:"h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Ollama"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Local AI inference engine"})]}),e.jsx(Ie,{className:"h-4 w-4 text-gray-400 ml-auto opacity-0 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("a",{href:"https://github.com/libre-webui/libre-webui/issues",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:[e.jsx(sr,{className:"h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Report Issues"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Bug reports & feature requests"})]}),e.jsx(Ie,{className:"h-4 w-4 text-gray-400 ml-auto opacity-0 group-hover:opacity-100 transition-opacity"})]})]})]}),e.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:e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("a",{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${Hr.version}`,target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary-600 dark:hover:text-primary-400 transition-colors",children:["Version ",Hr.version]}),e.jsxs("span",{children:["Open source by"," ",e.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"})]})]})})]})});case"generation":return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4",children:"Generation Options"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:"Fine-tune AI generation parameters to control response behavior and quality."}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("h4",{className:"text-md font-medium text-gray-900 dark:text-gray-100 mb-4",children:"Core Parameters"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Temperature",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(0.0-2.0)"})]}),e.jsx("input",{type:"number",min:"0",max:"2",step:"0.1",value:K.temperature??"",placeholder:"0.8",onChange:n=>ee("temperature",n.target.value?parseFloat(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Controls randomness. Lower = more focused, Higher = more creative"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Top P",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(0.0-1.0)"})]}),e.jsx("input",{type:"number",min:"0",max:"1",step:"0.05",value:K.top_p??"",placeholder:"0.9",onChange:n=>ee("top_p",n.target.value?parseFloat(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Nucleus sampling. Lower = more constrained vocabulary"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Top K",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(1-100)"})]}),e.jsx("input",{type:"number",min:"1",max:"100",value:K.top_k??"",placeholder:"40",onChange:n=>ee("top_k",n.target.value?parseInt(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Limits vocabulary to top K tokens"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Min P",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(0.0-1.0)"})]}),e.jsx("input",{type:"number",min:"0",max:"1",step:"0.05",value:K.min_p??"",placeholder:"0.0",onChange:n=>ee("min_p",n.target.value?parseFloat(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Minimum probability threshold"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("h4",{className:"text-md font-medium text-gray-900 dark:text-gray-100 mb-4",children:"Generation Control"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Max Tokens"}),e.jsx("input",{type:"number",min:"-1",max:"4096",value:K.num_predict??"",placeholder:"128",onChange:n=>ee("num_predict",n.target.value?parseInt(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Maximum number of tokens to generate. Leave empty to use default. Use -1 for unlimited."})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Repeat Penalty",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(0.0-2.0)"})]}),e.jsx("input",{type:"number",min:"0",max:"2",step:"0.1",value:K.repeat_penalty??"",placeholder:"1.1",onChange:n=>ee("repeat_penalty",n.target.value?parseFloat(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Penalty for repeating tokens"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Context Length"}),e.jsx("input",{type:"number",min:"512",max:"32768",step:"512",value:K.num_ctx??"",placeholder:"2048",onChange:n=>ee("num_ctx",n.target.value?parseInt(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Context window size"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Seed",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(optional)"})]}),e.jsx("input",{type:"number",value:K.seed||"",onChange:n=>ee("seed",n.target.value?parseInt(n.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",placeholder:"Random"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Seed for reproducible outputs"})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("h4",{className:"text-md font-medium text-gray-900 dark:text-gray-100 mb-4",children:"Advanced Options"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Presence Penalty",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(-2.0-2.0)"})]}),e.jsx("input",{type:"number",min:"-2",max:"2",step:"0.1",value:K.presence_penalty??"",placeholder:"0.0",onChange:n=>ee("presence_penalty",n.target.value?parseFloat(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Penalty for token presence"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Frequency Penalty",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(-2.0-2.0)"})]}),e.jsx("input",{type:"number",min:"-2",max:"2",step:"0.1",value:K.frequency_penalty??"",placeholder:"0.0",onChange:n=>ee("frequency_penalty",n.target.value?parseFloat(n.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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Penalty for token frequency"})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Stop Sequences",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(comma-separated)"})]}),e.jsx("input",{type:"text",value:K.stop?K.stop.join(", "):"",onChange:n=>ee("stop",n.target.value?n.target.value.split(",").map(p=>p.trim()).filter(p=>p):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"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Sequences that will stop generation"})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300",children:[e.jsxs(C,{onClick:Lt,variant:"outline",className:"flex items-center gap-2",children:[e.jsx(Qe,{size:16}),"Reset to Defaults"]}),e.jsxs(C,{onClick:zt,className:"flex items-center gap-2",children:[e.jsx(be,{size:16}),"Save Options"]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Embedding Settings"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Enable Embeddings"}),e.jsxs("label",{className:"flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f.enabled,onChange:n=>ne("enabled",n.target.checked),className:"sr-only"}),e.jsx("div",{className:`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 ${f.enabled?"bg-primary-600 dark:bg-primary-500":"bg-gray-200 dark:bg-dark-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${f.enabled?"translate-x-6":"translate-x-1"}`})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Embedding Model"}),e.jsx(Pe,{value:f.model,onChange:n=>ne("model",n.target.value),options:[{value:"nomic-embed-text",label:"Nomic Embed Text"},{value:"openai-embedding",label:"OpenAI Embedding"}],disabled:!f.enabled})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Chunk Size",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(in tokens)"})]}),e.jsx("input",{type:"number",min:"1",value:f.chunkSize,onChange:n=>ne("chunkSize",parseInt(n.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:!f.enabled})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Chunk Overlap",e.jsx("span",{className:"text-xs text-gray-500 ml-1",children:"(in tokens)"})]}),e.jsx("input",{type:"number",min:"0",value:f.chunkOverlap,onChange:n=>ne("chunkOverlap",parseInt(n.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:!f.enabled})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Similarity Threshold"}),e.jsx("input",{type:"number",min:"0",max:"1",step:"0.01",value:f.similarityThreshold,onChange:n=>ne("similarityThreshold",parseFloat(n.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:!f.enabled})]})]}),_&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Embedding Status:"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:_.available?"Available":"Not Available"})]}),_.available&&e.jsxs("div",{className:"flex items-center justify-between text-sm mt-1",children:[e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Chunks with Embeddings:"}),e.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:[_.chunksWithEmbeddings," /"," ",_.totalChunks]})]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsxs(C,{onClick:Mr,variant:"outline",className:"flex items-center gap-2",children:[e.jsx(Qe,{size:16}),"Reset to Defaults"]}),e.jsxs(C,{onClick:Er,className:"flex items-center gap-2",children:[e.jsx(be,{size:16}),"Save Settings"]})]})]})})]})});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-50 transition-opacity duration-200",onClick:a}),e.jsx("div",{className:"fixed inset-0 lg:top-1/2 lg:left-1/2 lg:-translate-x-1/2 lg:-translate-y-1/2 z-50 w-full lg:max-w-4xl lg:mx-4 h-full lg:h-[85vh] p-0 lg:p-4",children:e.jsxs("div",{className:"bg-white dark:bg-dark-25 rounded-2xl shadow-2xl border border-gray-200 dark:border-dark-200 animate-scale-in flex flex-col h-full overscroll-behavior-contain",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 sm:p-6 border-b border-gray-100 dark:border-dark-200 sticky top-0 z-10 rounded-t-2xl",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Settings"}),e.jsx(C,{variant:"ghost",size:"sm",onClick:a,className:"h-9 w-9 sm:h-8 sm:w-8 p-0 hover:bg-gray-100 dark:hover:bg-gray-700 active:bg-gray-200 dark:active:bg-dark-100 touch-manipulation",title:"Close",children:e.jsx(ue,{className:"h-5 w-5 sm:h-4 sm:w-4"})})]}),e.jsxs("div",{className:"flex flex-1 min-h-0 overscroll-behavior-contain",children:[e.jsx("div",{className:"w-40 xs:w-48 sm:w-64 border-r border-gray-100 dark:border-dark-200 p-2 xs:p-3 sm:p-4 overflow-y-auto scrollbar-thin",style:{WebkitOverflowScrolling:"touch"},children:e.jsx("nav",{className:"space-y-1",children:Ut.map(n=>{const p=n.icon;return e.jsxs("button",{onClick:()=>ie(n.id),className:`w-full flex items-center gap-2 sm:gap-3 px-2 sm:px-3 py-2.5 sm:py-2.5 text-left rounded-lg transition-colors duration-200 touch-manipulation ${ae===n.id?"bg-gray-100 dark:bg-dark-100 ophelia:bg-[#0a0a0a] text-gray-900 dark:text-white ophelia:text-[#fafafa] border border-gray-200 dark:border-dark-300 ophelia:border-[rgba(38,38,38,0.3)]":"text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] hover:bg-gray-50 dark:hover:bg-dark-200 ophelia:hover:bg-[#0a0a0a] active:bg-gray-100 dark:active:bg-dark-100 ophelia:active:bg-[#121212]"}`,children:[e.jsx(p,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"text-xs sm:text-sm font-medium truncate",children:n.label})]},n.id)})})}),e.jsx("div",{className:"flex-1 p-3 xs:p-4 sm:p-6 overflow-auto overscroll-behavior-contain",style:{WebkitOverflowScrolling:"touch"},children:Rt()})]})]})})]})},Ta=({value:r,onChange:a,className:t=""})=>{const s=c.useRef(null),[o,i]=c.useState(!1),[l,d]=c.useState(!1),h=async u=>{if(!u.type.startsWith("image/")){j.error("Please select a valid image file");return}if(u.size>2*1024*1024){j.error("Avatar image size must be less than 2MB");return}i(!0);try{const E=new FileReader;E.onload=D=>{const b=D.target?.result;a(b),j.success("Avatar uploaded successfully")},E.onerror=()=>{j.error("Failed to read image file")},E.readAsDataURL(u)}catch(E){console.error("Failed to upload avatar:",E),j.error("Failed to upload avatar image")}finally{i(!1)}},g=u=>{const E=u.target.files?.[0];E&&h(E)},k=u=>{u.preventDefault(),d(!0)},w=u=>{u.preventDefault(),d(!1)},P=u=>{u.preventDefault(),d(!1);const E=u.dataTransfer.files?.[0];E&&h(E)},v=()=>{a(""),j.success("Avatar removed")},N=()=>r||null;return e.jsx("div",{className:`space-y-4 ${t}`,children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2",children:"Avatar"}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-20 h-20 rounded-full overflow-hidden bg-gray-100 dark:bg-dark-200 border-2 border-gray-300 dark:border-dark-300 flex items-center justify-center",children:N()?e.jsx("img",{src:N(),alt:"Avatar preview",className:"w-full h-full object-cover"}):e.jsx(er,{className:"h-8 w-8 text-gray-400 dark:text-gray-500"})})}),e.jsxs("div",{className:"flex-1 space-y-3",children:[r?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:"Custom avatar image"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Click to change or remove"})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:v,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:e.jsx(ue,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:`border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${l?"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:k,onDragLeave:w,onDrop:P,onClick:()=>s.current?.click(),children:[e.jsx(ar,{className:"h-8 w-8 mx-auto text-gray-400 dark:text-gray-500 mb-2"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"Upload avatar image"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"Drag and drop an image or click to browse"}),e.jsxs(C,{variant:"outline",size:"sm",disabled:o,className:"mx-auto",children:[e.jsx(ar,{className:"h-4 w-4 mr-2"}),o?"Uploading...":"Choose Image"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Or enter image URL"}),e.jsx("input",{type:"url",value:r,onChange:u=>a(u.target.value),className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800",placeholder:"https://example.com/avatar.jpg"})]})]})]}),e.jsx("input",{ref:s,type:"file",accept:"image/*",onChange:g,className:"hidden"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Supports: JPG, PNG, GIF, WebP (max 2MB). Square images work best."})]})})};class Fa{constructor(){fe(this,"ws",null);fe(this,"url");fe(this,"reconnectAttempts",0);fe(this,"maxReconnectAttempts",5);fe(this,"reconnectDelay",1e3);fe(this,"messageHandlers",new Map);let a;window.location.protocol==="file:"?a="ws://localhost:3001":a=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,this.url=`${a}/ws`,console.log("WebSocket URL constructed:",this.url)}connect(){return x()?(console.log("Demo mode active: skipping WebSocket connection."),Promise.resolve()):(console.log("WebSocket: Attempting to connect to:",this.url),new Promise((a,t)=>{try{const s=localStorage.getItem("auth-token"),o=s?`${this.url}?token=${encodeURIComponent(s)}`:this.url;console.log("WebSocket: Connecting to:",o.replace(/token=[^&]+/,"token=***")),this.ws=new WebSocket(o),this.ws.onopen=()=>{console.log("WebSocket connected successfully"),this.reconnectAttempts=0,a()},this.ws.onmessage=i=>{try{const l=JSON.parse(i.data);console.log("WebSocket: Received message:",l);const d=this.messageHandlers.get(l.type);d?d(l.data):console.warn("WebSocket: No handler for message type:",l.type)}catch(l){console.error("Failed to parse WebSocket message:",l)}},this.ws.onclose=()=>{console.log("WebSocket disconnected"),this.ws=null,this.attemptReconnect()},this.ws.onerror=i=>{console.error("WebSocket error:",i),t(i)}}catch(s){t(s)}}))}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}send(a){this.ws&&this.ws.readyState===WebSocket.OPEN?(console.log("WebSocket: Sending message:",a),this.ws.send(JSON.stringify(a))):console.warn("WebSocket is not connected. ReadyState:",this.ws?.readyState)}onMessage(a,t){this.messageHandlers.delete(a),this.messageHandlers.set(a,t)}offMessage(a){this.messageHandlers.delete(a)}attemptReconnect(){if(x()){console.log("Demo mode active: skipping WebSocket reconnection.");return}this.reconnectAttempts<this.maxReconnectAttempts?(this.reconnectAttempts++,console.log(`Attempting to reconnect... (${this.reconnectAttempts}/${this.maxReconnectAttempts})`),setTimeout(()=>{this.connect().catch(()=>{})},this.reconnectDelay*this.reconnectAttempts)):console.error("Max reconnection attempts reached")}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}}const Ue=new Fa,V=or()(it((r,a)=>({user:null,token:null,systemInfo:null,isAuthenticated:!1,isLoading:!1,login:(t,s,o)=>{localStorage.setItem("auth-token",s);const i=me.getState();i.clearAllState&&i.clearAllState(),te.getState().clearUserState(),r({user:t,token:s,systemInfo:o,isAuthenticated:!0,isLoading:!1}),setTimeout(async()=>{try{const d=vr.getState();console.log("🔄 Reinitializing app after login..."),console.log("🔌 Reconnecting WebSocket with auth token..."),Ue.disconnect(),await Ue.connect(),!(await ke.checkHealth()).success&&!x()&&console.warn("Ollama service not available after login");const g=te.getState();await Promise.all([i.loadModels(),i.loadSessions(),i.loadPreferences(),g.loadPreferences(),d.loadPlugins()]),console.log("✅ Reinitialized app after login")}catch(d){console.error("Failed to reinitialize app after login:",d)}},100)},logout:()=>{localStorage.removeItem("auth-token"),console.log("🔌 Disconnecting WebSocket on logout..."),Ue.disconnect();const t=me.getState();t.clearAllState&&t.clearAllState(),te.getState().clearUserState(),r({user:null,token:null,isAuthenticated:!1,isLoading:!1})},setUser:t=>{r({user:t})},setSystemInfo:t=>{r({systemInfo:t})},setLoading:t=>{r({isLoading:t})},isAdmin:()=>{const{user:t}=a();return t?.role==="admin"},requiresAuth:()=>{const{systemInfo:t}=a();return t?.requiresAuth??!1}}),{name:"auth-store",partialize:r=>({user:r.user,token:r.token,systemInfo:r.systemInfo,isAuthenticated:r.isAuthenticated})})),Kr=({isOpen:r,onClose:a,className:t})=>{const s=br(),o=nr(),{sessions:i,deleteSession:l,updateSessionTitle:d,selectedModel:h,models:g,currentSession:k,generatingTitleForSession:w,personas:P}=me(),{user:v,isAdmin:N,systemInfo:u,setUser:E}=V(),{backgroundImage:D,sidebarCompact:b,toggleSidebarCompact:A}=te(),[O,S]=c.useState(null),[z,R]=c.useState(""),[W,G]=c.useState(!1),[T,F]=c.useState(!1),[oe,ae]=c.useState(!1),[ie,X]=c.useState(""),[xe,Z]=c.useState(!1),_e=c.useRef(null),he=c.useRef(null),{sessionId:Ee}=Bt(),H=Ee||null,pe=k?.id||H;c.useEffect(()=>{const f=$=>{_e.current&&!_e.current.contains($.target)&&F(!1)};if(T)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[T]),c.useEffect(()=>{const f=$=>{he.current&&!he.current.contains($.target)&&window.innerWidth<768&&r&&!b&&A()};if(r&&!b&&window.innerWidth<768)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[r,b,A]),c.useEffect(()=>{v?.avatar&&X(v.avatar)},[v?.avatar]);const We=async()=>{Z(!0);try{const f=await dt.updateMyAvatar(ie||null);f.success&&f.data?(E(f.data),U.success("Profile picture updated"),ae(!1)):U.error(f.message||"Failed to update avatar")}catch(f){console.error("Failed to update avatar:",f),U.error("Failed to update profile picture")}finally{Z(!1)}},ve=()=>{const{setCurrentSession:f}=me.getState();f(null),sessionStorage.setItem("forceWelcomeScreen","true"),o("/chat",{replace:!0}),window.innerWidth<768&&!b&&A()},Be=f=>{o(`/c/${f.id}`,{replace:!0}),window.innerWidth<768&&!b&&A()},Me=async(f,$)=>{if($.stopPropagation(),window.confirm("Are you sure you want to delete this chat?"))try{const _=pe===f;if(await l(f),_){const He=i.filter(Ke=>Ke.id!==f);He.length>0?o(`/c/${He[0].id}`,{replace:!0}):o("/",{replace:!0})}}catch(_){console.error("Error deleting session:",_)}},De=(f,$)=>{$.stopPropagation(),S(f.id),R(f.title)},je=async f=>{z.trim()&&await d(f,z.trim()),S(null),R("")},we=()=>{S(null),R("")},K=async()=>{try{await ge.logout();const{logout:f}=V.getState();f(),o("/login"),U.success("Logged out successfully")}catch(f){console.error("Logout error:",f);const{logout:$}=V.getState();$(),o("/login")}},Ne=window.location.protocol==="file:";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:he,className:M("fixed inset-y-0 left-0 z-50 border-r border-gray-200 dark:border-dark-200 transform transition-all duration-300 ease-in-out shadow-xl",b?"w-18":"w-80 max-sm:w-64",r?"translate-x-0":"-translate-x-full","lg:shadow-none",D?"bg-gray-50/70 dark:bg-dark-25/70 backdrop-blur-sm":"bg-gray-50 dark:bg-dark-25","overscroll-behavior-contain",t),style:{WebkitOverflowScrolling:"touch"},children:[Ne&&e.jsx("div",{className:"absolute top-0 left-16 right-0 h-8 z-[60]",style:{WebkitAppRegion:"drag"}}),e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:M("border-b border-gray-200/60 dark:border-dark-200/60",b?"p-2":"p-3",Ne&&"pt-10"),children:[e.jsx("div",{className:M("flex items-center",b?"justify-center mb-2":"justify-between mb-2"),children:b?e.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[e.jsx(ye,{size:"sm"}),e.jsx(C,{variant:"ghost",size:"sm",onClick:A,className:"h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[rgba(147,51,234,0.15)] active:bg-gray-200 dark:active:bg-dark-100 ophelia:active:bg-[rgba(147,51,234,0.25)] touch-manipulation ophelia:text-[#a3a3a3] ophelia:hover:text-[#c084fc]",title:"Expand sidebar",children:e.jsx(zr,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"libre-brand text-base font-semibold text-gray-900 dark:text-dark-800",style:{lineHeight:1},children:"Libre WebUI"})]}),e.jsx("div",{className:"flex items-center gap-1",children:e.jsx(C,{variant:"ghost",size:"sm",onClick:A,className:"h-7 w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[rgba(147,51,234,0.15)] active:bg-gray-200 dark:active:bg-dark-100 ophelia:active:bg-[rgba(147,51,234,0.25)] touch-manipulation ophelia:text-[#a3a3a3] ophelia:hover:text-[#c084fc]",title:"Toggle sidebar size",children:e.jsx(oa,{className:"h-4 w-4"})})})]})}),!b&&e.jsxs(C,{onClick:ve,disabled:!h||g.length===0,className:"w-full bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-white shadow-sm hover:shadow-md active:shadow-lg transition-all duration-200 border-0 touch-manipulation",size:"sm",title:!h||g.length===0?"No models available. Please ensure Ollama is running and models are installed.":"",children:[e.jsx(Lr,{className:"h-4 w-4 mr-2"}),"New Chat"]}),b&&e.jsx(C,{onClick:ve,disabled:!h||g.length===0,className:"w-full h-9 bg-primary-600 hover:bg-primary-700 active:bg-primary-800 text-white shadow-sm hover:shadow-md active:shadow-lg transition-all duration-200 border-0 touch-manipulation p-0",title:!h||g.length===0?"No models available. Please ensure Ollama is running and models are installed.":"New Chat",children:e.jsx(Lr,{className:"h-4 w-4"})})]}),e.jsx("div",{className:M("py-1.5",b?"px-1":"px-2.5"),children:e.jsxs("nav",{className:M("space-y-0.5",b&&"flex flex-col items-center"),children:[e.jsxs("button",{onClick:()=>{const{setCurrentSession:f}=me.getState();f(null),sessionStorage.setItem("forceWelcomeScreen","true"),o("/chat",{replace:!0}),window.innerWidth<768&&!b&&A()},className:M("flex items-center gap-2.5 rounded-lg text-sm font-medium transition-all duration-200 text-left touch-manipulation",b?"w-11 h-11 justify-center p-0":"w-full px-2.5 py-2",s.pathname==="/chat"||s.pathname==="/"?"bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[rgba(147,51,234,0.25)] text-primary-800 dark:text-primary-200 ophelia:text-[#e9d5ff] shadow-sm":"text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] hover:bg-gray-50 dark:hover:bg-dark-200/50 ophelia:hover:bg-[rgba(147,51,234,0.1)] hover:text-gray-900 dark:hover:text-gray-100 ophelia:hover:text-[#e9d5ff] active:bg-gray-100 dark:active:bg-dark-200 ophelia:active:bg-[rgba(147,51,234,0.15)]"),title:b?"Chat":void 0,children:[e.jsx(sr,{className:"h-4 w-4 shrink-0"}),!b&&"Chat"]}),e.jsxs(Ye,{to:"/models",onClick:()=>window.innerWidth<768&&!b&&A(),className:M("flex items-center gap-2.5 rounded-lg text-sm font-medium transition-all duration-200 touch-manipulation",b?"w-11 h-11 justify-center p-0":"w-full px-2.5 py-2",s.pathname==="/models"?"bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[rgba(147,51,234,0.25)] text-primary-800 dark:text-primary-200 ophelia:text-[#e9d5ff] shadow-sm":"text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] hover:bg-gray-50 dark:hover:bg-dark-200/50 ophelia:hover:bg-[rgba(147,51,234,0.1)] hover:text-gray-900 dark:hover:text-gray-100 ophelia:hover:text-[#e9d5ff] active:bg-gray-100 dark:active:bg-dark-200 ophelia:active:bg-[rgba(147,51,234,0.15)]"),title:b?"Models":void 0,children:[e.jsx(ze,{className:"h-4 w-4 shrink-0"}),!b&&"Models"]}),e.jsxs(Ye,{to:"/personas",onClick:()=>window.innerWidth<768&&!b&&A(),className:M("flex items-center gap-2.5 rounded-lg text-sm font-medium transition-all duration-200 touch-manipulation",b?"w-11 h-11 justify-center p-0":"w-full px-2.5 py-2",s.pathname==="/personas"?"bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[rgba(147,51,234,0.25)] text-primary-800 dark:text-primary-200 ophelia:text-[#e9d5ff] shadow-sm":"text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] hover:bg-gray-50 dark:hover:bg-dark-200/50 ophelia:hover:bg-[rgba(147,51,234,0.1)] hover:text-gray-900 dark:hover:text-gray-100 ophelia:hover:text-[#e9d5ff] active:bg-gray-100 dark:active:bg-dark-200 ophelia:active:bg-[rgba(147,51,234,0.15)]"),title:b?"Personas":void 0,children:[e.jsx(er,{className:"h-4 w-4 shrink-0"}),!b&&"Personas"]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-thin border-t border-gray-200/60 dark:border-dark-200/60",style:{WebkitOverflowScrolling:"touch",overscrollBehavior:"contain",willChange:"scroll-position"},children:e.jsxs("div",{className:M("p-2.5",b&&"px-1"),children:[!b&&i.length>0&&e.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300 uppercase tracking-wide",children:"Chats"}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-500 font-medium",children:i.length})]}),i.length===0?e.jsxs("div",{className:M("text-center py-8",b?"px-1":"px-2"),children:[e.jsx("div",{className:M("mx-auto mb-3 bg-gray-100 dark:bg-dark-300 rounded-xl flex items-center justify-center",b?"w-8 h-8":"w-12 h-12"),children:e.jsx(sr,{className:M("text-gray-400 dark:text-gray-500",b?"h-4 w-4":"h-5 w-5")})}),!b&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"No chats yet"}),e.jsx("p",{className:"text-xs mt-1 text-gray-500 dark:text-gray-500",children:"Create your first chat above"})]})]}):e.jsx("div",{className:M("space-y-0.5",b&&"space-y-1"),children:i.map(f=>{const $=pe===f.id;return e.jsx("div",{className:M("group relative cursor-pointer transition-all duration-200 touch-manipulation",b?"rounded-lg p-2 flex items-center justify-center":"rounded-lg px-2.5 py-2",$?"bg-gray-100 dark:bg-dark-200":"hover:bg-gray-50 dark:hover:bg-dark-200/50"),onClick:()=>Be(f),title:b?`${f.title} - ${f.model}`:void 0,children:b?e.jsx("div",{className:"flex items-center justify-center w-full h-8",children:e.jsx("div",{className:M("w-3 h-3 rounded-full",w===f.id?"bg-primary-400 animate-pulse":$?"bg-primary-500":"bg-gray-300 dark:bg-gray-600")})}):O===f.id?e.jsxs("div",{className:"flex items-center gap-2",onClick:_=>_.stopPropagation(),children:[e.jsx(Na,{value:z,onChange:_=>R(_.target.value),onKeyDown:_=>{_.key==="Enter"?je(f.id):_.key==="Escape"&&we()},className:"text-sm h-8 ophelia:bg-[#0a0a0a] ophelia:border-[#9333ea] ophelia:text-[#fafafa] ophelia:focus:ring-[#a855f7] ophelia:focus:border-[#a855f7]",autoFocus:!0}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>je(f.id),className:"h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 ophelia:hover:bg-[rgba(147,51,234,0.2)] active:bg-gray-200 dark:active:bg-dark-400 ophelia:active:bg-[rgba(147,51,234,0.3)] touch-manipulation ophelia:text-[#a855f7] ophelia:hover:text-[#c084fc]",children:e.jsx(be,{className:"h-3 w-3"})}),e.jsx(C,{variant:"ghost",size:"sm",onClick:we,className:"h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 ophelia:hover:bg-[rgba(239,68,68,0.15)] active:bg-gray-200 dark:active:bg-dark-400 ophelia:active:bg-[rgba(239,68,68,0.25)] touch-manipulation ophelia:text-[#737373] ophelia:hover:text-[#f87171]",children:e.jsx(ue,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex-1 min-w-0 mr-2",children:[e.jsx("h3",{className:M("text-sm font-medium truncate leading-tight","text-gray-900 dark:text-gray-100"),children:w===f.id?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"animate-pulse",children:"Generating title"}),e.jsxs("span",{className:"inline-flex",children:[e.jsx("span",{className:"animate-bounce",style:{animationDelay:"0ms"},children:"."}),e.jsx("span",{className:"animate-bounce",style:{animationDelay:"150ms"},children:"."}),e.jsx("span",{className:"animate-bounce",style:{animationDelay:"300ms"},children:"."})]})]}):wa(f.title,32)}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("span",{className:M("text-xs",$?"text-gray-600 dark:text-gray-400":"text-gray-500 dark:text-gray-500"),children:va(f.updatedAt)}),e.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:"•"}),f.personaId?(()=>{const _=P[f.personaId];return _?e.jsxs("span",{className:M("flex items-center gap-1 text-xs font-medium",$?"text-primary-600 dark:text-primary-400":"text-primary-500 dark:text-primary-500"),title:_.description||_.name,children:[_.avatar&&!_.avatar.startsWith("data:")&&e.jsx("span",{className:"text-[10px]",children:_.avatar}),e.jsx("span",{className:"truncate max-w-[100px]",children:_.name})]}):e.jsx("span",{className:M("text-xs font-medium italic",$?"text-gray-500 dark:text-gray-500":"text-gray-400 dark:text-gray-600"),children:"Persona"})})():e.jsx("span",{className:M("text-xs font-medium truncate max-w-[120px]",$?"text-gray-700 dark:text-gray-300":"text-gray-600 dark:text-gray-400"),title:f.model,children:f.model})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-all duration-200 shrink-0",children:[e.jsx(C,{variant:"ghost",size:"sm",onClick:_=>De(f,_),className:"h-7 w-7 sm:h-6 sm:w-6 p-0 hover:bg-gray-200 dark:hover:bg-gray-700 active:bg-gray-300 dark:active:bg-gray-600 rounded-md touch-manipulation",title:"Rename chat",children:e.jsx(ia,{className:"h-3 w-3"})}),e.jsx(C,{variant:"ghost",size:"sm",onClick:_=>Me(f.id,_),className:"h-7 w-7 sm:h-6 sm:w-6 p-0 text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 active:bg-red-100 dark:active:bg-red-900/30 rounded-md touch-manipulation",title:"Delete chat",children:e.jsx(tt,{className:"h-3 w-3"})})]})]})},f.id)})})]})}),u?.requiresAuth&&v&&e.jsx("div",{className:M("border-t border-gray-200/60 dark:border-dark-200/60",b?"p-1.5":"p-2.5"),children:b?e.jsxs("div",{className:"flex flex-col items-center space-y-1.5",children:[v.avatar?e.jsx("img",{src:v.avatar,alt:v.username,className:"w-7 h-7 rounded-full object-cover",title:`${v.username} (${v.role})`}):e.jsx("div",{className:"w-7 h-7 bg-primary-500 rounded-full flex items-center justify-center",title:`${v.username} (${v.role})`,children:e.jsx("span",{className:"text-white text-xs font-medium",children:v.username.charAt(0).toUpperCase()})}),e.jsx("button",{onClick:()=>{G(!0),window.innerWidth<768&&!b&&A()},className:"w-9 h-9 flex items-center justify-center rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-200/50 active:bg-gray-100 dark:active:bg-dark-200 touch-manipulation transition-all duration-200",title:"Settings",children:e.jsx(Ur,{className:"h-4 w-4"})}),N()&&e.jsx(Ye,{to:"/users",onClick:()=>window.innerWidth<768&&!b&&A(),className:"w-9 h-9 flex items-center justify-center rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-200/50 active:bg-gray-100 dark:active:bg-dark-200 touch-manipulation transition-all duration-200",title:"User Management",children:e.jsx(er,{className:"h-4 w-4"})}),e.jsx("button",{onClick:K,className:"w-9 h-9 flex items-center justify-center rounded-lg text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 active:bg-red-100 dark:active:bg-red-900/30 touch-manipulation transition-all duration-200",title:"Sign Out",children:e.jsx(Rr,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"relative",ref:_e,children:[e.jsx("button",{onClick:()=>F(!T),className:"w-full p-2.5 rounded-xl bg-white/50 dark:bg-dark-200/50 ophelia:bg-[rgba(10,10,10,0.6)] border border-gray-200/30 dark:border-dark-300/30 ophelia:border-[rgba(38,38,38,0.2)] hover:bg-white/70 dark:hover:bg-dark-200/70 ophelia:hover:bg-[rgba(18,18,18,0.7)] transition-all duration-200 text-left touch-manipulation",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[v.avatar?e.jsx("img",{src:v.avatar,alt:v.username,className:"w-7 h-7 rounded-full object-cover"}):e.jsx("div",{className:"w-7 h-7 bg-primary-500 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-white text-xs font-medium",children:v.username.charAt(0).toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:v.username}),e.jsxs("div",{className:"flex items-center mt-0.5",children:[v.role==="admin"&&e.jsx(at,{size:10,className:"text-primary-500 mr-1"}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 capitalize",children:v.role})]})]}),e.jsx(zr,{className:M("h-4 w-4 text-gray-400 dark:text-gray-500 transition-transform duration-200",T&&"rotate-90")})]})}),T&&e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 py-2 bg-white dark:bg-dark-100 rounded-xl shadow-lg border border-gray-200/50 dark:border-dark-200/50 backdrop-blur-sm z-50",children:[e.jsx("div",{className:"px-3 py-2 border-b border-gray-100 dark:border-dark-200/50",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[v.avatar?e.jsx("img",{src:v.avatar,alt:v.username,className:"w-8 h-8 rounded-full object-cover"}):e.jsx("div",{className:"w-8 h-8 bg-primary-500 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-white text-sm font-medium",children:v.username.charAt(0).toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:v.username}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:v.email||"No email provided"})]})]})}),e.jsxs("div",{className:"py-1",children:[e.jsxs("button",{onClick:()=>{ae(!0),F(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-200/50 transition-colors duration-200 text-left",children:[e.jsx(la,{className:"h-4 w-4 shrink-0"}),"Change Picture"]}),e.jsxs("button",{onClick:()=>{G(!0),F(!1),window.innerWidth<768&&!b&&A()},className:"w-full flex items-center gap-3 px-3 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-200/50 transition-colors duration-200 text-left",children:[e.jsx(Ur,{className:"h-4 w-4 shrink-0"}),"Settings"]}),N()&&e.jsxs(Ye,{to:"/users",onClick:()=>{F(!1),window.innerWidth<768&&!b&&A()},className:"w-full flex items-center gap-3 px-3 py-2.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-200/50 transition-colors duration-200",children:[e.jsx(er,{className:"h-4 w-4 shrink-0"}),"User Management"]}),e.jsx("div",{className:"border-t border-gray-100 dark:border-dark-200/50 my-1"}),e.jsxs("button",{onClick:()=>{K(),F(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors duration-200 text-left",children:[e.jsx(Rr,{className:"h-4 w-4 shrink-0"}),"Log out"]})]})]})]})})]})]}),e.jsx(ct,{isOpen:W,onClose:()=>G(!1)}),oe&&Ht.createPortal(e.jsx("div",{className:"fixed inset-0 z-[2147483647] flex items-center justify-center bg-black/50",onClick:()=>ae(!1),children:e.jsxs("div",{className:"bg-white dark:bg-dark-100 rounded-xl shadow-2xl p-6 w-full max-w-md mx-4",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Change Profile Picture"}),e.jsx("button",{onClick:()=>ae(!1),className:"p-1 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-lg transition-colors",children:e.jsx(ue,{size:20,className:"text-gray-500"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ta,{value:ie,onChange:X}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-dark-300",children:[e.jsx("button",{onClick:()=>ae(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-lg transition-colors",children:"Cancel"}),e.jsx("button",{onClick:We,disabled:xe,className:"px-4 py-2 text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors",children:xe?"Saving...":"Save"})]})]})]})}),document.body)]})},qr=({children:r,requireAuth:a=!0,requireAdmin:t=!1})=>{const{isAuthenticated:s,user:o,systemInfo:i,isLoading:l}=V();return br(),l?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"})}):i&&!i.requiresAuth?e.jsx(e.Fragment,{children:r}):a&&!s?e.jsx(Dr,{to:"/login",replace:!0}):t&&(!o||o.role!=="admin")?e.jsx(Dr,{to:"/",replace:!0}):e.jsx(e.Fragment,{children:r})};class Ze extends c.Component{constructor(a){super(a),this.state={hasError:!1}}static getDerivedStateFromError(a){return{hasError:!0,error:a}}componentDidCatch(a,t){console.error("ErrorBoundary caught an error:",a,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-900 flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-md w-full bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-500 mb-4",children:e.jsx("svg",{className:"mx-auto h-12 w-12",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.732-.833-2.464 0L4.35 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:"Something went wrong"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"We encountered an unexpected error. Please try refreshing the page."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg transition-colors",children:"Refresh Page"}),!1]})})}):this.props.children}}const za=(r,a=!0)=>{const t=c.useCallback(s=>{if(!a)return;const o=s.target;if(o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.contentEditable==="true"||o.isContentEditable)return;if(s.key==="?"||s.key==="/"&&s.shiftKey){const l=r.find(d=>d.key==="?"||d.key==="h");if(l){s.preventDefault(),s.stopPropagation(),l.action();return}}const i=r.find(l=>{const d=l.key.toLowerCase()===s.key.toLowerCase(),h=!!l.metaKey,g=s.metaKey||s.ctrlKey,k=h?g:!0,w=l.ctrlKey?s.ctrlKey:!0,P=!!l.shiftKey===s.shiftKey,v=!!l.altKey===s.altKey;return d&&k&&w&&P&&v});i&&(s.preventDefault(),s.stopPropagation(),i.action())},[r,a]);c.useEffect(()=>{if(a)return document.addEventListener("keydown",t),()=>{document.removeEventListener("keydown",t)}},[t,a])},La=r=>{const a=[];r.metaKey&&a.push(navigator.platform.includes("Mac")?"⌘":"Ctrl"),r.ctrlKey&&a.push("Ctrl"),r.shiftKey&&a.push("⇧"),r.altKey&&a.push(navigator.platform.includes("Mac")?"⌥":"Alt");let t=r.key.toUpperCase();return r.key===","&&(t=","),r.key===" "&&(t="Space"),r.key==="Enter"&&(t="↩"),r.key==="Escape"&&(t="Esc"),a.push(t),a.join("+")},Ua=({isOpen:r,onClose:a,shortcuts:t})=>{if(!r)return null;const s={Navigation:t.filter(o=>o.description.includes("sidebar")||o.description.includes("Toggle")),Settings:t.filter(o=>o.description.includes("settings")||o.description.includes("dark mode")),General:t.filter(o=>!o.description.includes("sidebar")&&!o.description.includes("settings")&&!o.description.includes("dark mode")&&!o.description.includes("Toggle"))};return e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-dark-100 ophelia:bg-[#050505] rounded-xl shadow-2xl w-full max-w-md max-h-[80vh] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(st,{className:"h-5 w-5 text-gray-700 dark:text-dark-600 ophelia:text-[#a3a3a3]"}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:"Keyboard Shortcuts"})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200",children:e.jsx(ue,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[60vh]",children:[Object.entries(s).map(([o,i])=>i.length===0?null:e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-dark-600 mb-3",children:o}),e.jsx("div",{className:"space-y-2",children:i.map((l,d)=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-dark-500",children:l.description}),e.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-gray-100 dark:bg-dark-200 ophelia:bg-[#121212] text-gray-700 dark:text-dark-600 ophelia:text-[#a3a3a3] rounded border border-gray-300 dark:border-dark-400 ophelia:border-[#262626]",children:La(l)})]},d))})]},o)),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-dark-600 mb-3",children:"Chat"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-dark-500",children:"Send message"}),e.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-gray-100 dark:bg-dark-200 ophelia:bg-[#121212] text-gray-700 dark:text-dark-600 ophelia:text-[#a3a3a3] rounded border border-gray-300 dark:border-dark-400 ophelia:border-[#262626]",children:"Enter"})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-dark-500",children:"New line in message"}),e.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-gray-100 dark:bg-dark-200 ophelia:bg-[#121212] text-gray-700 dark:text-dark-600 ophelia:text-[#a3a3a3] rounded border border-gray-300 dark:border-dark-400 ophelia:border-[#262626]",children:"⇧+Enter"})]})]})]})]}),e.jsx("div",{className:"px-6 py-4 bg-gray-50 dark:bg-dark-200 ophelia:bg-[#0a0a0a] border-t border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]",children:e.jsxs("p",{className:"text-xs text-gray-500 dark:text-dark-400 ophelia:text-[#737373] text-center",children:["Press"," ",e.jsx("kbd",{className:"px-1 py-0.5 text-xs font-mono bg-gray-200 dark:bg-dark-300 ophelia:bg-[#1a1a1a] rounded",children:"?"})," ","or"," ",e.jsx("kbd",{className:"px-1 py-0.5 text-xs font-mono bg-gray-200 dark:bg-dark-300 ophelia:bg-[#1a1a1a] rounded",children:"H"})," ","to show this help"]})})]})})},Ra=({onClick:r,className:a})=>{const[t,s]=c.useState(!1);return e.jsxs(C,{variant:"ghost",size:"sm",onClick:r,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),className:M("fixed bottom-4 right-4 h-10 w-10 p-0 bg-white/80 dark:bg-dark-100/80 ophelia:bg-[rgba(10,10,10,0.9)] backdrop-blur-sm border border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a] shadow-lg hover:shadow-xl transition-all duration-200 z-50","hover:bg-white dark:hover:bg-dark-100 ophelia:hover:bg-[#121212]",a),title:"Keyboard shortcuts",children:[e.jsx(st,{className:"h-4 w-4"}),t&&e.jsx("div",{className:"absolute bottom-full mb-2 right-0 px-2 py-1 text-xs bg-gray-900 text-white rounded whitespace-nowrap",children:"Keyboard shortcuts"})]})},Gr=({message:r="This is a demo version for presentation purposes only. The Ollama backend is not connected.",onDismiss:a,className:t})=>{const[s,o]=c.useState(!1),i=()=>{o(!0),a?.()};return s?null:e.jsx("div",{className:M("bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-900/20 dark:to-orange-900/20","border-b border-amber-200 dark:border-amber-800","px-4 py-3",t),children:e.jsxs("div",{className:"flex items-center justify-between max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(et,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Demo Mode"}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-0.5",children:r})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsxs(C,{variant:"ghost",size:"sm",className:"text-amber-700 dark:text-amber-300 hover:text-amber-900 dark:hover:text-amber-100 h-8 px-2",onClick:()=>window.open("https://github.com/libre-webui/libre-webui","_blank"),title:"View on GitHub",children:[e.jsx(Ie,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"GitHub"})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:i,className:"text-amber-700 dark:text-amber-300 hover:text-amber-900 dark:hover:text-amber-100 h-8 w-8 p-0",title:"Dismiss",children:e.jsx(ue,{className:"h-4 w-4"})})]})]})})},Vr=()=>{const{preferences:r,backgroundImage:a}=te(),t=r.backgroundSettings||{enabled:!1,imageUrl:"",blurAmount:10,opacity:.6},s=a||t.imageUrl;return!t.enabled||!s?null:e.jsx("div",{className:"fixed inset-0 pointer-events-none z-0",style:{backgroundImage:`url(${s})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",filter:`blur(${t.blurAmount}px)`,opacity:t.opacity,transform:"scale(1.1)"}})};class mt{static async initializeAuth(){const{setLoading:a,setSystemInfo:t,login:s}=V.getState();try{a(!0),console.log("🔐 Starting auth initialization..."),console.log("📡 Fetching system info...");const o=await ge.getSystemInfo();console.log("📡 System info response:",o),o.success&&o.data?(console.log("✅ Setting system info:",o.data),t(o.data)):console.error("❌ System info response failed:",o);const i=localStorage.getItem("auth-token");if(i)try{const l=(await re(async()=>{const{default:g}=await import("../js/utils-vendor-DNzxLBGx.js").then(k=>k.i);return{default:g}},__vite__mapDeps([0,1,2]))).default,d=l.defaults.headers.common;l.defaults.headers.common.Authorization=`Bearer ${i}`;const h=await ge.verifyToken();if(h.success&&h.data){const g=V.getState().systemInfo;g&&s(h.data,i,g)}l.defaults.headers.common=d}catch(l){console.error("Token verification failed:",l),localStorage.removeItem("auth-token")}}catch(o){console.error("Auth initialization error:",o)}finally{a(!1)}}}const $a=()=>{hr.interceptors.request.use(r=>{const a=localStorage.getItem("auth-token");return a&&(r.headers.Authorization=`Bearer ${a}`),r},r=>Promise.reject(r)),hr.interceptors.response.use(r=>r,r=>{if(r.response?.status===401){localStorage.removeItem("auth-token");const{logout:a}=V.getState();a(),window.location.href="/login"}return Promise.reject(r)})};$a();const Wa=Object.freeze(Object.defineProperty({__proto__:null,UserService:mt},Symbol.toStringTag,{value:"Module"})),Ba=()=>{const r=c.useRef(!1),{loadSessions:a,loadModels:t,loadPreferences:s,setSelectedModel:o,models:i}=me(),{loadPreferences:l}=te(),{loadPlugins:d,plugins:h}=vr();c.useEffect(()=>{if(r.current)return;(async()=>{try{if(r.current=!0,await mt.initializeAuth(),!(await ke.checkHealth()).success)if(x()){await Promise.all([l(),s()]),await Promise.all([t(),a(),d()]);return}else{j.error("Ollama service is not available. Please make sure it's running.");return}await Promise.all([l(),s()]),await Promise.all([t(),a(),d()])}catch(k){x()?(await Promise.all([l(),s()]),await Promise.all([t(),a(),d()])):(console.error("Failed to initialize app:",k),j.error("Failed to connect to the backend service"))}})()},[l,s,t,a,d]),c.useEffect(()=>{if(i.length>0){const{selectedModel:g}=me.getState();g&&i.map(w=>w.name).includes(g)||o(i[0].name)}},[i,o]),c.useEffect(()=>{h.filter(k=>k.active).length>0&&t()},[h,t])},ut=()=>{const[r,a]=c.useState(!1),[t,s]=c.useState(!1);c.useEffect(()=>{(async()=>{try{const l=await fetch(`${Q}/auth/oauth/github/status`,{method:"GET",credentials:"include"});if(l.ok){const d=await l.json();s(d.configured||!1),console.log("GitHub OAuth configured:",d.configured)}else console.log("GitHub OAuth status check failed"),s(!1)}catch(l){console.log("GitHub OAuth not configured:",l),s(!1)}})()},[]);const o=()=>{if(!t||r)return;a(!0);const i=`${Q}/auth/oauth/github`;window.location.href=i};return t?e.jsx("button",{type:"button",onClick:o,disabled:r,className:"w-full flex items-center justify-center px-4 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm bg-white dark:bg-dark-100 text-gray-700 dark:text-dark-700 hover:bg-gray-50 dark:hover:bg-dark-150 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:r?e.jsxs("div",{className:"flex items-center",children:[e.jsx(yr,{size:16,className:"animate-spin mr-2"}),"Connecting to GitHub..."]}):e.jsxs("div",{className:"flex items-center",children:[e.jsx(rt,{size:16,className:"mr-2"}),"Continue with GitHub"]})}):null},Ha=()=>{const[r,a]=c.useState(!1),[t,s]=c.useState(!1);c.useEffect(()=>{(async()=>{try{const l=await fetch(`${Q}/auth/oauth/huggingface/status`,{method:"GET",credentials:"include"});if(l.ok){const d=await l.json();s(d.configured||!1),console.log("Hugging Face OAuth configured:",d.configured)}else console.log("Hugging Face OAuth status check failed"),s(!1)}catch(l){console.log("Hugging Face OAuth not configured:",l),s(!1)}})()},[]);const o=()=>{if(!t||r)return;a(!0);const i=`${Q}/auth/oauth/huggingface`;window.location.href=i};return t?e.jsx("button",{type:"button",onClick:o,disabled:r,className:"w-full flex items-center justify-center px-4 py-2 border border-orange-300 dark:border-orange-600 rounded-lg shadow-sm bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300 hover:bg-orange-100 dark:hover:bg-orange-900/30 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:r?e.jsxs("div",{className:"flex items-center",children:[e.jsx(yr,{size:16,className:"animate-spin mr-2"}),"Connecting to Hugging Face..."]}):e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"mr-2 text-base",children:"🤗"}),"Continue with Hugging Face"]})}):null},Ka=({onLogin:r,onShowSignup:a})=>{const[t,s]=c.useState(""),[o,i]=c.useState(""),[l,d]=c.useState(!1),[h,g]=c.useState(!1),k=nr(),{login:w}=V(),P=async N=>{if(N.preventDefault(),!t.trim()||!o.trim()){U.error("Please enter both username and password");return}g(!0);try{localStorage.removeItem("auth-token");const u=await ge.login({username:t,password:o});u.success&&u.data?(w(u.data.user,u.data.token,u.data.systemInfo),U.success("Login successful!"),r?.(),k("/")):U.error(u.message||"Login failed")}catch(u){console.error("Login error:",u),U.error("Login failed. Please check your credentials.")}finally{g(!1)}},v=N=>{if(N.key==="Enter"){const u=N.currentTarget.form;u&&u.requestSubmit()}};return e.jsxs("div",{className:"w-full max-w-md mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2",children:"Welcome Back"}),e.jsx("p",{className:"text-gray-600 dark:text-dark-500",children:"Sign in to your account to continue"})]}),e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Username"}),e.jsx("input",{id:"username",type:"text",value:t,onChange:N=>s(N.target.value),onKeyDown:v,className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"Enter your username",required:!0,disabled:h})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"password",type:l?"text":"password",value:o,onChange:N=>i(N.target.value),onKeyDown:v,className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"Enter your password",required:!0,disabled:h}),e.jsx("button",{type:"button",onClick:()=>d(!l),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700",disabled:h,children:l?e.jsx(Re,{size:20}):e.jsx($e,{size:20})})]})]}),e.jsx("button",{type:"submit",disabled:h,className:"w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:h?e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Signing in..."]}):e.jsxs("div",{className:"flex items-center",children:[e.jsx(da,{size:16,className:"mr-2"}),"Sign In"]})})]}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-300 dark:border-dark-300"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-2 bg-white dark:bg-dark-25 text-gray-500 dark:text-dark-500",children:"or"})})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[e.jsx(ut,{}),e.jsx(Ha,{})]})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsxs("p",{className:"text-sm text-gray-600 dark:text-dark-500",children:["Don't have an account?"," ",e.jsx("button",{onClick:()=>a?.(),className:"text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300 font-medium transition-colors duration-200",children:"Sign up here"})]})}),e.jsx("div",{className:"mt-4 text-center",children:e.jsx("p",{className:"text-xs text-gray-500 dark:text-dark-500",children:"Mode: Multi User"})})]})},qa=({onSignup:r,onBackToLogin:a})=>{const[t,s]=c.useState(""),[o,i]=c.useState(""),[l,d]=c.useState(""),[h,g]=c.useState(""),[k,w]=c.useState(!1),[P,v]=c.useState(!1),[N,u]=c.useState(!1),E=nr(),{login:D}=V(),b=async O=>{if(O.preventDefault(),!t.trim()||!l.trim()){U.error("Username and password are required");return}if(l!==h){U.error("Passwords do not match");return}if(l.length<6){U.error("Password must be at least 6 characters long");return}u(!0);try{const S=await ge.signup({username:t,password:l,email:o});S.success&&S.data?(D(S.data.user,S.data.token,S.data.systemInfo),U.success("Account created successfully!"),r?.(),E("/")):U.error(S.message||"Signup failed")}catch(S){console.error("Signup error:",S),U.error("Signup failed. Please try again.")}finally{u(!1)}},A=O=>{if(O.key==="Enter"){const S=O.currentTarget.form;S&&S.requestSubmit()}};return e.jsxs("div",{className:"w-full max-w-md mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2",children:"Create Account"}),e.jsx("p",{className:"text-gray-600 dark:text-dark-500",children:"Sign up for your new account"})]}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Username"}),e.jsx("input",{id:"username",type:"text",value:t,onChange:O=>s(O.target.value),onKeyDown:A,className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"Choose a username",required:!0,disabled:N})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:["Email ",e.jsx("span",{className:"text-gray-400",children:"(optional)"})]}),e.jsx("input",{id:"email",type:"email",value:o,onChange:O=>i(O.target.value),onKeyDown:A,className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"your@email.com",disabled:N})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"password",type:k?"text":"password",value:l,onChange:O=>d(O.target.value),onKeyDown:A,className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"Choose a password",required:!0,disabled:N}),e.jsx("button",{type:"button",onClick:()=>w(!k),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700",disabled:N,children:k?e.jsx(Re,{size:20}):e.jsx($e,{size:20})})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Confirm Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"confirmPassword",type:P?"text":"password",value:h,onChange:O=>g(O.target.value),onKeyDown:A,className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"Confirm your password",required:!0,disabled:N}),e.jsx("button",{type:"button",onClick:()=>v(!P),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700",disabled:N,children:P?e.jsx(Re,{size:20}):e.jsx($e,{size:20})})]})]}),e.jsx("button",{type:"submit",disabled:N,className:"w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:N?e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Creating account..."]}):e.jsxs("div",{className:"flex items-center",children:[e.jsx(nt,{size:16,className:"mr-2"}),"Create Account"]})})]}),e.jsx(ut,{}),e.jsx("div",{className:"mt-6 text-center",children:e.jsxs("p",{className:"text-sm text-gray-600 dark:text-dark-500",children:["Already have an account?"," ",e.jsx("button",{onClick:a,className:"text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300 font-medium transition-colors duration-200",children:"Sign in here"})]})}),e.jsx("div",{className:"mt-4 text-center",children:e.jsx("p",{className:"text-xs text-gray-500 dark:text-dark-500",children:"Mode: Multi User"})})]})},Jr=()=>{const r=nr(),{isAuthenticated:a,requiresAuth:t}=V(),[s,o]=c.useState(!1);return c.useEffect(()=>{a&&r("/")},[a,r]),t()?e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"sm:mx-auto sm:w-full sm:max-w-md",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(ye,{})}),e.jsx("h2",{className:"libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100",style:{fontWeight:300,letterSpacing:"0.01em"},children:"Libre WebUI"})]}),e.jsx("div",{className:"mt-8 sm:mx-auto sm:w-full sm:max-w-md",children:s?e.jsx(qa,{onBackToLogin:()=>o(!1),onSignup:()=>o(!1)}):e.jsx(Ka,{onShowSignup:()=>o(!0)})})]}):(r("/"),null)},Ga=({onComplete:r})=>{const[a,t]=c.useState("welcome"),[s,o]=c.useState(""),[i,l]=c.useState(""),[d,h]=c.useState(""),[g,k]=c.useState(!1),[w,P]=c.useState(!1),[v,N]=c.useState(!1),[u,E]=c.useState(null),[D,b]=c.useState(!1),[A,O]=c.useState(!1),{login:S}=V();c.useEffect(()=>{a==="encryption-key"&&!u&&ge.getEncryptionKey().then(T=>{T.success&&T.data&&E(T.data.encryptionKey)})},[a,u]);const z=async T=>{if(T.preventDefault(),!s.trim()||!i.trim()||!d.trim()){U.error("Please fill in all fields");return}if(i!==d){U.error("Passwords do not match");return}if(i.length<6){U.error("Password must be at least 6 characters long");return}N(!0);try{const F=await ge.signup({username:s,password:i,email:""});F.success&&F.data?(S(F.data.user,F.data.token,F.data.systemInfo),U.success("Admin account created successfully!"),t("encryption-key")):U.error(F.message||"Failed to create admin account")}catch(F){console.error("Admin creation error:",F),U.error("Failed to create admin account. Please try again.")}finally{N(!1)}},R=async()=>{if(u)try{await navigator.clipboard.writeText(u),b(!0),U.success("Encryption key copied to clipboard!"),setTimeout(()=>b(!1),3e3)}catch{U.error("Failed to copy key to clipboard")}},W=()=>{if(!A){U.error("Please confirm that you have saved the encryption key");return}r?.()},G=T=>{if(T.key==="Enter"){const F=T.currentTarget.form;F&&F.requestSubmit()}};return a==="welcome"?e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"sm:mx-auto sm:w-full sm:max-w-md",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(ye,{})}),e.jsx("h2",{className:"libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100",style:{fontWeight:300,letterSpacing:"0.01em"},children:"Welcome to Libre WebUI"})]}),e.jsx("div",{className:"mt-8 sm:mx-auto sm:w-full sm:max-w-md",children:e.jsxs("div",{className:"w-full max-w-md mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2",children:"Let's Get Started"}),e.jsx("p",{className:"text-gray-600 dark:text-dark-500",children:"Set up your Libre WebUI instance in just a few steps"})]}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(at,{className:"h-5 w-5 text-primary-600 dark:text-primary-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-dark-950",children:"Secure & Private"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-dark-500",children:"Your conversations stay on your device"})]})]}),e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(ca,{className:"h-5 w-5 text-primary-600 dark:text-primary-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-dark-950",children:"Fast & Responsive"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-dark-500",children:"Optimized for speed and performance"})]})]}),e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(ma,{className:"h-5 w-5 text-primary-600 dark:text-primary-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-dark-950",children:"Open Source"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-dark-500",children:"Free and open source software"})]})]})]}),e.jsx("button",{onClick:()=>t("create-admin"),className:"w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-colors duration-200",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{children:"Create Admin Account"}),e.jsx($r,{size:16,className:"ml-2"})]})})]})})]}):a==="encryption-key"?e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"sm:mx-auto sm:w-full sm:max-w-md",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(ye,{})}),e.jsx("h2",{className:"libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100",style:{fontWeight:300,letterSpacing:"0.01em"},children:"Save Your Encryption Key"})]}),e.jsx("div",{className:"mt-8 sm:mx-auto sm:w-full sm:max-w-lg",children:e.jsxs("div",{className:"w-full max-w-lg mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"p-3 bg-amber-100 dark:bg-amber-900/30 rounded-full",children:e.jsx(ua,{className:"h-8 w-8 text-amber-600 dark:text-amber-400"})})}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2",children:"Important: Save This Key"}),e.jsx("p",{className:"text-gray-600 dark:text-dark-500",children:"This encryption key protects your sensitive data. Store it securely - you'll need it if you ever need to restore your database."})]}),e.jsx("div",{className:"mb-6 p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(ga,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium mb-1",children:"Warning"}),e.jsx("p",{children:"If you lose this key and need to restore your database, your encrypted data (API keys, preferences) will be unrecoverable."})]})]})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Your Encryption Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-full px-3 py-3 pr-12 border border-gray-300 dark:border-dark-300 rounded-lg bg-gray-50 dark:bg-dark-100 font-mono text-sm text-gray-900 dark:text-dark-800 break-all",children:u||"Loading..."}),e.jsx("button",{type:"button",onClick:R,disabled:!u,className:"absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-500 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-700 disabled:opacity-50",title:"Copy to clipboard",children:D?e.jsx(be,{className:"h-5 w-5 text-green-500"}):e.jsx(xa,{className:"h-5 w-5"})})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-dark-500",children:"This key is also saved in your backend/.env file as ENCRYPTION_KEY"})]}),e.jsx("div",{className:"mb-6",children:e.jsxs("label",{className:"flex items-start space-x-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:T=>O(T.target.checked),className:"mt-1 h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-dark-300 rounded"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-dark-700",children:"I have saved my encryption key in a secure location and understand that losing it may result in data loss."})]})}),e.jsx("button",{onClick:W,disabled:!A,className:"w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{children:"Continue to Libre WebUI"}),e.jsx($r,{size:16,className:"ml-2"})]})})]})})]}):e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"sm:mx-auto sm:w-full sm:max-w-md",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(ye,{})}),e.jsx("h2",{className:"libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100",style:{fontWeight:300,letterSpacing:"0.01em"},children:"Create Admin Account"})]}),e.jsx("div",{className:"mt-8 sm:mx-auto sm:w-full sm:max-w-md",children:e.jsxs("div",{className:"w-full max-w-md mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2",children:"Administrator Setup"}),e.jsx("p",{className:"text-gray-600 dark:text-dark-500",children:"Create the first admin account for your Libre WebUI instance"})]}),e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Username"}),e.jsx("input",{id:"username",type:"text",value:s,onChange:T=>o(T.target.value),onKeyDown:G,className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"Enter admin username",required:!0,disabled:v})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"password",type:g?"text":"password",value:i,onChange:T=>l(T.target.value),onKeyDown:G,className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"Enter password (min 6 characters)",required:!0,disabled:v}),e.jsx("button",{type:"button",onClick:()=>k(!g),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700",disabled:v,children:g?e.jsx(Re,{size:20}):e.jsx($e,{size:20})})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2",children:"Confirm Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"confirmPassword",type:w?"text":"password",value:d,onChange:T=>h(T.target.value),onKeyDown:G,className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200",placeholder:"Confirm your password",required:!0,disabled:v}),e.jsx("button",{type:"button",onClick:()=>P(!w),className:"absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700",disabled:v,children:w?e.jsx(Re,{size:20}):e.jsx($e,{size:20})})]})]}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx("button",{type:"button",onClick:()=>t("welcome"),disabled:v,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm text-sm font-medium text-gray-700 dark:text-dark-700 bg-white dark:bg-dark-100 hover:bg-gray-50 dark:hover:bg-dark-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:"Back"}),e.jsx("button",{type:"submit",disabled:v,className:"flex-1 flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:v?e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Creating..."]}):e.jsxs("div",{className:"flex items-center",children:[e.jsx(nt,{size:16,className:"mr-2"}),"Create Admin"]})})]})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx("p",{className:"text-xs text-gray-500 dark:text-dark-500",children:"This will be the primary administrator account for your Libre WebUI instance"})})]})})]})},Va=window.location.protocol==="file:"?Kt:qt,Ja=window.location.protocol==="file:",Yr=()=>Ja?e.jsx("div",{className:"absolute top-0 left-0 right-0 h-8 z-50",style:{WebkitAppRegion:"drag"}}):null,Ae=Y.lazy(()=>re(()=>import("../js/ChatPage-CyotkmS0.js"),__vite__mapDeps([3,4,2,1,5,6,0]))),Qr=Y.lazy(()=>re(()=>import("../js/ModelsPage-DNaziPHc.js"),__vite__mapDeps([7,4,2,1,6,0]))),Xr=Y.lazy(()=>re(()=>import("../js/PersonasPage-DcnbJf8Q.js"),__vite__mapDeps([8,4,2,1,6,0]))),Ya=Y.lazy(()=>re(()=>import("../js/UserManagementPage-DtTf92dS.js"),__vite__mapDeps([9,4,2,1,6,0]))),Qa=Y.lazy(()=>re(()=>import("../js/ArtifactDemoPage-CdfwJVXu.js"),__vite__mapDeps([10,4,2,1,5,6,0]))),Zr=()=>e.jsx("div",{className:"flex items-center justify-center h-full min-h-screen",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"}),e.jsx("div",{className:"text-gray-600 dark:text-dark-600",children:"Loading..."})]})}),Xa=({onClick:r})=>{const a=br();return a.pathname==="/"||a.pathname==="/chat"||a.pathname.startsWith("/c/")?e.jsx("div",{className:"hidden lg:block",children:e.jsx(Ra,{onClick:r})}):null},Za=()=>{const[r,a]=c.useState(!1),[t,s]=c.useState(!1),[o,i]=c.useState(0),{sidebarOpen:l,sidebarCompact:d,setSidebarOpen:h,setSidebarCompact:g,toggleSidebar:k,toggleSidebarCompact:w,toggleTheme:P,backgroundImage:v,preferences:N}=te(),{systemInfo:u,isLoading:E,user:D,isAuthenticated:b}=V(),{isDemoMode:A,demoConfig:O}=te(),[S,z]=Y.useState(!1),R=Y.useRef(!1);Y.useEffect(()=>{(async()=>{if(R.current){console.log("OAuth already processing, skipping...");return}console.log("Starting OAuth callback processing..."),R.current=!0;const F=new URLSearchParams(window.location.search),oe=F.get("token"),ae=F.get("auth");if(oe&&ae==="success"){try{const ie=await fetch(`${Q}/auth/me`,{headers:{Authorization:`Bearer ${oe}`},credentials:"include"});if(ie.ok){const X=await ie.json();if(X.success&&X.data){const{login:xe,systemInfo:Z}=V.getState();xe(X.data,oe,Z||{requiresAuth:!0,singleUserMode:!1,hasUsers:!0,version:"0.1.6"}),console.log("OAuth login successful, showing toast"),j.success("GitHub login successful!")}else j.error("Failed to verify GitHub authentication")}else j.error("GitHub authentication verification failed")}catch(ie){console.error("OAuth processing error:",ie),j.error("GitHub authentication failed")}window.history.replaceState({},document.title,window.location.pathname)}console.log("OAuth processing completed"),z(!0),R.current=!1})()},[]),Ba();const W=()=>{if(v)return!0;const T=N.backgroundSettings;return T?.enabled&&T?.imageUrl},G=[{key:"b",metaKey:!0,action:()=>{window.innerWidth>=1024?l?w():(g(!1),k()):(!l&&d&&g(!1),k())},description:"Toggle sidebar"},{key:",",metaKey:!0,action:()=>a(!0),description:"Open settings"},{key:"d",metaKey:!0,action:P,description:"Toggle dark mode"},{key:"h",action:()=>s(!0),description:"Show keyboard shortcuts"},{key:"Escape",action:()=>{a(!1),s(!1)},description:"Close modals"}];return za(G),Y.useEffect(()=>(Ue.connect().catch(console.error),()=>{Ue.disconnect()}),[]),Y.useEffect(()=>{if(!u&&!E&&o<15){const T=setTimeout(async()=>{i(F=>F+1);try{const{UserService:F}=await re(async()=>{const{UserService:oe}=await Promise.resolve().then(()=>Wa);return{UserService:oe}},void 0);await F.initializeAuth()}catch{}},2e3);return()=>clearTimeout(T)}},[u,E,o]),E?e.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"sm:mx-auto sm:w-full sm:max-w-md",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(ye,{})}),e.jsx("h2",{className:"libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100",style:{fontWeight:300,letterSpacing:"0.01em"},children:"Libre WebUI"})]}),e.jsx("div",{className:"mt-8 flex flex-col items-center gap-4",children:e.jsx("div",{className:"w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin"})})]}):u?u&&u.requiresAuth&&!u.hasUsers?e.jsx(Ze,{children:e.jsx(Ga,{})}):S?e.jsx(Ze,{children:e.jsxs(Va,{children:[u&&!u.requiresAuth?e.jsxs("div",{className:M("flex h-screen text-gray-900 dark:text-dark-800 relative",W()?"bg-white/40 dark:bg-dark-50/40":"bg-white dark:bg-dark-50"),children:[e.jsx(Yr,{}),e.jsx(Vr,{}),e.jsx(Kr,{isOpen:l,onClose:()=>h(!1)}),e.jsxs("div",{className:M("flex-1 flex flex-col min-w-0 transition-all duration-300 ease-in-out relative z-10","w-full",l?d?"lg:ml-16":"lg:ml-80":"lg:ml-0",l&&d?"max-lg:ml-16":"max-lg:ml-0",W()?"bg-white/30 dark:bg-dark-50/30":"bg-white dark:bg-dark-50"),children:[A&&O.showBanner&&e.jsx(Gr,{message:O.message}),e.jsx("main",{className:M("flex-1 overflow-hidden",W()?"bg-white/20 dark:bg-dark-50/20 backdrop-blur-sm":"bg-gray-50 dark:bg-dark-100"),children:e.jsx(Ze,{children:e.jsx(c.Suspense,{fallback:e.jsx(Zr,{}),children:e.jsxs(xr,{children:[e.jsx(q,{path:"/",element:e.jsx(Ae,{})}),e.jsx(q,{path:"/chat",element:e.jsx(Ae,{})}),e.jsx(q,{path:"/c/:sessionId",element:e.jsx(Ae,{})}),e.jsx(q,{path:"/models",element:e.jsx(Qr,{})}),e.jsx(q,{path:"/personas",element:e.jsx(Xr,{})}),e.jsx(q,{path:"/login",element:e.jsx(Jr,{})})]})})})})]})]}):e.jsxs(xr,{children:[e.jsx(q,{path:"/login",element:e.jsx(Jr,{})}),e.jsx(q,{path:"/*",element:e.jsx(qr,{children:e.jsxs("div",{className:M("flex h-screen text-gray-900 dark:text-dark-800 relative",W()?"bg-white/40 dark:bg-dark-50/40":"bg-white dark:bg-dark-50"),children:[e.jsx(Yr,{}),e.jsx(Vr,{}),e.jsx(Kr,{isOpen:l,onClose:()=>h(!1)}),e.jsxs("div",{className:M("flex-1 flex flex-col min-w-0 transition-all duration-300 ease-in-out relative z-10","w-full",l?d?"lg:ml-16":"lg:ml-80":"lg:ml-0",l&&d?"max-lg:ml-16":"max-lg:ml-0",W()?"bg-white/30 dark:bg-dark-50/30":"bg-white dark:bg-dark-50"),children:[A&&O.showBanner&&e.jsx(Gr,{message:O.message}),e.jsx("main",{className:M("flex-1 overflow-hidden",W()?"bg-white/20 dark:bg-dark-50/20 backdrop-blur-sm":"bg-gray-50 dark:bg-dark-100"),children:e.jsx(Ze,{children:e.jsx(c.Suspense,{fallback:e.jsx(Zr,{}),children:e.jsxs(xr,{children:[e.jsx(q,{path:"/",element:e.jsx(Ae,{})}),e.jsx(q,{path:"/chat",element:e.jsx(Ae,{})}),e.jsx(q,{path:"/c/:sessionId",element:e.jsx(Ae,{})}),e.jsx(q,{path:"/models",element:e.jsx(Qr,{})}),e.jsx(q,{path:"/personas",element:e.jsx(Xr,{})}),e.jsx(q,{path:"/artifacts",element:e.jsx(Qa,{})}),e.jsx(q,{path:"/users",element:e.jsx(qr,{requireAdmin:!0,children:e.jsx(Ya,{})})})]})})})})]})]})})})]}),e.jsx(ct,{isOpen:r,onClose:()=>a(!1)}),e.jsx(Ua,{isOpen:t,onClose:()=>s(!1),shortcuts:G}),e.jsx(Xa,{onClick:()=>s(!0)}),e.jsx(ha,{position:"top-right",toastOptions:{duration:4e3,className:"animate-slide-up",style:{background:"var(--toast-bg)",color:"var(--toast-color)",border:"1px solid var(--toast-border)",borderRadius:"0.75rem",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",cursor:"pointer"},success:{iconTheme:{primary:"#16a34a",secondary:"#ffffff"}},error:{iconTheme:{primary:"#ef4444",secondary:"#ffffff"}}},containerStyle:{top:80,right:20}})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"})}):e.jsx("div",{className:"min-h-screen bg-dark-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{src:"./logo-dark.png",alt:"Libre WebUI",className:"h-24 w-24 rounded-xl"})}),e.jsx("h1",{className:"libre-brand text-3xl text-white mb-8",style:{fontWeight:300,letterSpacing:"0.02em"},children:"Libre WebUI"}),e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-8 h-8 border-3 border-gray-700 border-t-primary-500 rounded-full animate-spin"})}),e.jsx("p",{className:"text-gray-500 text-sm",children:o>0?`Connecting to backend... (${o}/15)`:"Starting up..."})]})})};ka.createRoot(document.getElementById("root")).render(e.jsx(Y.StrictMode,{children:e.jsx(Za,{})}));export{Ta as A,C as B,Na as I,Pe as S,ot as T,V as a,me as b,M as c,fr as d,kr as e,va as f,ce as g,ja as h,dt as i,ke as o,os as p,Le as t,te as u,Ue as w};