libre-webui 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/README.md +75 -61
  2. package/backend/dist/db.d.ts.map +1 -1
  3. package/backend/dist/db.js +21 -19
  4. package/backend/dist/db.js.map +1 -1
  5. package/backend/dist/index.d.ts.map +1 -1
  6. package/backend/dist/index.js +39 -908
  7. package/backend/dist/index.js.map +1 -1
  8. package/backend/dist/middleware/auth.d.ts.map +1 -1
  9. package/backend/dist/middleware/auth.js +4 -2
  10. package/backend/dist/middleware/auth.js.map +1 -1
  11. package/backend/dist/middleware/index.d.ts.map +1 -1
  12. package/backend/dist/middleware/index.js +4 -2
  13. package/backend/dist/middleware/index.js.map +1 -1
  14. package/backend/dist/models/personaModel.d.ts.map +1 -1
  15. package/backend/dist/models/personaModel.js +11 -9
  16. package/backend/dist/models/personaModel.js.map +1 -1
  17. package/backend/dist/routes/auth.d.ts.map +1 -1
  18. package/backend/dist/routes/auth.js +36 -14
  19. package/backend/dist/routes/auth.js.map +1 -1
  20. package/backend/dist/routes/chat.d.ts.map +1 -1
  21. package/backend/dist/routes/chat.js +61 -249
  22. package/backend/dist/routes/chat.js.map +1 -1
  23. package/backend/dist/routes/documents.d.ts.map +1 -1
  24. package/backend/dist/routes/documents.js +10 -8
  25. package/backend/dist/routes/documents.js.map +1 -1
  26. package/backend/dist/routes/imageGen.d.ts.map +1 -1
  27. package/backend/dist/routes/imageGen.js +9 -7
  28. package/backend/dist/routes/imageGen.js.map +1 -1
  29. package/backend/dist/routes/libreClaw.d.ts +3 -0
  30. package/backend/dist/routes/libreClaw.d.ts.map +1 -0
  31. package/backend/dist/routes/libreClaw.js +156 -0
  32. package/backend/dist/routes/libreClaw.js.map +1 -0
  33. package/backend/dist/routes/ollama.d.ts.map +1 -1
  34. package/backend/dist/routes/ollama.js +7 -247
  35. package/backend/dist/routes/ollama.js.map +1 -1
  36. package/backend/dist/routes/plugins.d.ts.map +1 -1
  37. package/backend/dist/routes/plugins.js +7 -105
  38. package/backend/dist/routes/plugins.js.map +1 -1
  39. package/backend/dist/routes/tts.d.ts.map +1 -1
  40. package/backend/dist/routes/tts.js +7 -5
  41. package/backend/dist/routes/tts.js.map +1 -1
  42. package/backend/dist/routes/users.d.ts.map +1 -1
  43. package/backend/dist/routes/users.js +7 -5
  44. package/backend/dist/routes/users.js.map +1 -1
  45. package/backend/dist/services/assistantCompletionService.d.ts +26 -0
  46. package/backend/dist/services/assistantCompletionService.d.ts.map +1 -0
  47. package/backend/dist/services/assistantCompletionService.js +53 -0
  48. package/backend/dist/services/assistantCompletionService.js.map +1 -0
  49. package/backend/dist/services/authService.d.ts +2 -0
  50. package/backend/dist/services/authService.d.ts.map +1 -1
  51. package/backend/dist/services/authService.js +9 -5
  52. package/backend/dist/services/authService.js.map +1 -1
  53. package/backend/dist/services/chatGenerationService.d.ts +32 -0
  54. package/backend/dist/services/chatGenerationService.d.ts.map +1 -0
  55. package/backend/dist/services/chatGenerationService.js +118 -0
  56. package/backend/dist/services/chatGenerationService.js.map +1 -0
  57. package/backend/dist/services/chatRequestService.d.ts +55 -0
  58. package/backend/dist/services/chatRequestService.d.ts.map +1 -0
  59. package/backend/dist/services/chatRequestService.js +103 -0
  60. package/backend/dist/services/chatRequestService.js.map +1 -0
  61. package/backend/dist/services/chatService.d.ts +0 -1
  62. package/backend/dist/services/chatService.d.ts.map +1 -1
  63. package/backend/dist/services/chatService.js +13 -27
  64. package/backend/dist/services/chatService.js.map +1 -1
  65. package/backend/dist/services/documentService.d.ts.map +1 -1
  66. package/backend/dist/services/documentService.js +21 -19
  67. package/backend/dist/services/documentService.js.map +1 -1
  68. package/backend/dist/services/embeddingService.d.ts.map +1 -1
  69. package/backend/dist/services/embeddingService.js +3 -1
  70. package/backend/dist/services/embeddingService.js.map +1 -1
  71. package/backend/dist/services/encryptionService.d.ts.map +1 -1
  72. package/backend/dist/services/encryptionService.js +26 -24
  73. package/backend/dist/services/encryptionService.js.map +1 -1
  74. package/backend/dist/services/galleryService.d.ts.map +1 -1
  75. package/backend/dist/services/galleryService.js +8 -6
  76. package/backend/dist/services/galleryService.js.map +1 -1
  77. package/backend/dist/services/libreClawService.d.ts +105 -0
  78. package/backend/dist/services/libreClawService.d.ts.map +1 -0
  79. package/backend/dist/services/libreClawService.js +169 -0
  80. package/backend/dist/services/libreClawService.js.map +1 -0
  81. package/backend/dist/services/memoryService.d.ts +2 -13
  82. package/backend/dist/services/memoryService.d.ts.map +1 -1
  83. package/backend/dist/services/memoryService.js +37 -198
  84. package/backend/dist/services/memoryService.js.map +1 -1
  85. package/backend/dist/services/memoryUtils.d.ts +29 -0
  86. package/backend/dist/services/memoryUtils.d.ts.map +1 -0
  87. package/backend/dist/services/memoryUtils.js +165 -0
  88. package/backend/dist/services/memoryUtils.js.map +1 -0
  89. package/backend/dist/services/mutationEngineService.d.ts.map +1 -1
  90. package/backend/dist/services/mutationEngineService.js +3 -1
  91. package/backend/dist/services/mutationEngineService.js.map +1 -1
  92. package/backend/dist/services/ollamaService.d.ts.map +1 -1
  93. package/backend/dist/services/ollamaService.js +36 -34
  94. package/backend/dist/services/ollamaService.js.map +1 -1
  95. package/backend/dist/services/personaService.d.ts.map +1 -1
  96. package/backend/dist/services/personaService.js +3 -1
  97. package/backend/dist/services/personaService.js.map +1 -1
  98. package/backend/dist/services/pluginCapabilityRegistryService.d.ts +11 -0
  99. package/backend/dist/services/pluginCapabilityRegistryService.d.ts.map +1 -0
  100. package/backend/dist/services/pluginCapabilityRegistryService.js +70 -0
  101. package/backend/dist/services/pluginCapabilityRegistryService.js.map +1 -0
  102. package/backend/dist/services/pluginCredentialsService.d.ts.map +1 -1
  103. package/backend/dist/services/pluginCredentialsService.js +13 -11
  104. package/backend/dist/services/pluginCredentialsService.js.map +1 -1
  105. package/backend/dist/services/pluginEmbeddingService.d.ts +26 -0
  106. package/backend/dist/services/pluginEmbeddingService.d.ts.map +1 -0
  107. package/backend/dist/services/pluginEmbeddingService.js +159 -0
  108. package/backend/dist/services/pluginEmbeddingService.js.map +1 -0
  109. package/backend/dist/services/pluginImageGenerationService.d.ts +29 -0
  110. package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -0
  111. package/backend/dist/services/pluginImageGenerationService.js +402 -0
  112. package/backend/dist/services/pluginImageGenerationService.js.map +1 -0
  113. package/backend/dist/services/pluginService.d.ts +9 -18
  114. package/backend/dist/services/pluginService.d.ts.map +1 -1
  115. package/backend/dist/services/pluginService.js +118 -1469
  116. package/backend/dist/services/pluginService.js.map +1 -1
  117. package/backend/dist/services/pluginTTSService.d.ts +28 -0
  118. package/backend/dist/services/pluginTTSService.d.ts.map +1 -0
  119. package/backend/dist/services/pluginTTSService.js +286 -0
  120. package/backend/dist/services/pluginTTSService.js.map +1 -0
  121. package/backend/dist/services/pluginVariablesService.d.ts.map +1 -1
  122. package/backend/dist/services/pluginVariablesService.js +7 -5
  123. package/backend/dist/services/pluginVariablesService.js.map +1 -1
  124. package/backend/dist/services/preferencesService.d.ts.map +1 -1
  125. package/backend/dist/services/preferencesService.js +9 -7
  126. package/backend/dist/services/preferencesService.js.map +1 -1
  127. package/backend/dist/services/simpleGitHubOAuth.d.ts.map +1 -1
  128. package/backend/dist/services/simpleGitHubOAuth.js +10 -8
  129. package/backend/dist/services/simpleGitHubOAuth.js.map +1 -1
  130. package/backend/dist/services/simpleHuggingFaceOAuth.d.ts.map +1 -1
  131. package/backend/dist/services/simpleHuggingFaceOAuth.js +11 -9
  132. package/backend/dist/services/simpleHuggingFaceOAuth.js.map +1 -1
  133. package/backend/dist/services/systemSettingsService.d.ts.map +1 -1
  134. package/backend/dist/services/systemSettingsService.js +4 -2
  135. package/backend/dist/services/systemSettingsService.js.map +1 -1
  136. package/backend/dist/services/titleGenerationService.d.ts +55 -0
  137. package/backend/dist/services/titleGenerationService.d.ts.map +1 -0
  138. package/backend/dist/services/titleGenerationService.js +121 -0
  139. package/backend/dist/services/titleGenerationService.js.map +1 -0
  140. package/backend/dist/services/turnstileService.d.ts +13 -0
  141. package/backend/dist/services/turnstileService.d.ts.map +1 -0
  142. package/backend/dist/services/turnstileService.js +79 -0
  143. package/backend/dist/services/turnstileService.js.map +1 -0
  144. package/backend/dist/storage.d.ts +2 -22
  145. package/backend/dist/storage.d.ts.map +1 -1
  146. package/backend/dist/storage.js +22 -170
  147. package/backend/dist/storage.js.map +1 -1
  148. package/backend/dist/storageMappers.d.ts +82 -0
  149. package/backend/dist/storageMappers.d.ts.map +1 -0
  150. package/backend/dist/storageMappers.js +85 -0
  151. package/backend/dist/storageMappers.js.map +1 -0
  152. package/backend/dist/test-encryption.js +20 -18
  153. package/backend/dist/test-encryption.js.map +1 -1
  154. package/backend/dist/types/index.d.ts.map +1 -1
  155. package/backend/dist/types/index.js.map +1 -1
  156. package/backend/dist/utils/assistantBranching.d.ts +8 -0
  157. package/backend/dist/utils/assistantBranching.d.ts.map +1 -0
  158. package/backend/dist/utils/assistantBranching.js +30 -0
  159. package/backend/dist/utils/assistantBranching.js.map +1 -0
  160. package/backend/dist/utils/chatContext.d.ts +17 -0
  161. package/backend/dist/utils/chatContext.d.ts.map +1 -0
  162. package/backend/dist/utils/chatContext.js +82 -0
  163. package/backend/dist/utils/chatContext.js.map +1 -0
  164. package/backend/dist/utils/chatDocumentContext.d.ts +7 -0
  165. package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -0
  166. package/backend/dist/utils/chatDocumentContext.js +51 -0
  167. package/backend/dist/utils/chatDocumentContext.js.map +1 -0
  168. package/backend/dist/utils/logger.d.ts +12 -0
  169. package/backend/dist/utils/logger.d.ts.map +1 -0
  170. package/backend/dist/utils/logger.js +82 -0
  171. package/backend/dist/utils/logger.js.map +1 -0
  172. package/backend/dist/utils/ollamaLibrary.d.ts +17 -0
  173. package/backend/dist/utils/ollamaLibrary.d.ts.map +1 -0
  174. package/backend/dist/utils/ollamaLibrary.js +253 -0
  175. package/backend/dist/utils/ollamaLibrary.js.map +1 -0
  176. package/backend/dist/utils/ollamaStreaming.d.ts +19 -0
  177. package/backend/dist/utils/ollamaStreaming.d.ts.map +1 -0
  178. package/backend/dist/utils/ollamaStreaming.js +67 -0
  179. package/backend/dist/utils/ollamaStreaming.js.map +1 -0
  180. package/backend/dist/utils/pluginChatAdapter.d.ts +32 -0
  181. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -0
  182. package/backend/dist/utils/pluginChatAdapter.js +308 -0
  183. package/backend/dist/utils/pluginChatAdapter.js.map +1 -0
  184. package/backend/dist/utils/pluginChatContext.d.ts +23 -0
  185. package/backend/dist/utils/pluginChatContext.d.ts.map +1 -0
  186. package/backend/dist/utils/pluginChatContext.js +77 -0
  187. package/backend/dist/utils/pluginChatContext.js.map +1 -0
  188. package/backend/dist/utils/pluginResponse.d.ts +6 -0
  189. package/backend/dist/utils/pluginResponse.d.ts.map +1 -0
  190. package/backend/dist/utils/pluginResponse.js +70 -0
  191. package/backend/dist/utils/pluginResponse.js.map +1 -0
  192. package/backend/dist/utils/pluginStreamAdapter.d.ts +16 -0
  193. package/backend/dist/utils/pluginStreamAdapter.d.ts.map +1 -0
  194. package/backend/dist/utils/pluginStreamAdapter.js +141 -0
  195. package/backend/dist/utils/pluginStreamAdapter.js.map +1 -0
  196. package/backend/dist/utils/pluginStreaming.d.ts +24 -0
  197. package/backend/dist/utils/pluginStreaming.d.ts.map +1 -0
  198. package/backend/dist/utils/pluginStreaming.js +106 -0
  199. package/backend/dist/utils/pluginStreaming.js.map +1 -0
  200. package/backend/dist/utils/pluginUpload.d.ts +8 -0
  201. package/backend/dist/utils/pluginUpload.d.ts.map +1 -0
  202. package/backend/dist/utils/pluginUpload.js +51 -0
  203. package/backend/dist/utils/pluginUpload.js.map +1 -0
  204. package/backend/dist/utils/pluginValidation.d.ts +9 -0
  205. package/backend/dist/utils/pluginValidation.d.ts.map +1 -0
  206. package/backend/dist/utils/pluginValidation.js +84 -0
  207. package/backend/dist/utils/pluginValidation.js.map +1 -0
  208. package/backend/dist/utils/pluginVariableValidation.d.ts +10 -0
  209. package/backend/dist/utils/pluginVariableValidation.d.ts.map +1 -0
  210. package/backend/dist/utils/pluginVariableValidation.js +80 -0
  211. package/backend/dist/utils/pluginVariableValidation.js.map +1 -0
  212. package/backend/dist/utils/websocketMessages.d.ts +26 -0
  213. package/backend/dist/utils/websocketMessages.d.ts.map +1 -0
  214. package/backend/dist/utils/websocketMessages.js +74 -0
  215. package/backend/dist/utils/websocketMessages.js.map +1 -0
  216. package/backend/dist/websocketServer.d.ts +3 -0
  217. package/backend/dist/websocketServer.d.ts.map +1 -0
  218. package/backend/dist/websocketServer.js +332 -0
  219. package/backend/dist/websocketServer.js.map +1 -0
  220. package/backend/package.json +2 -2
  221. package/frontend/dist/assets/index-Dc8Q4dJZ.css +1 -0
  222. package/frontend/dist/assets/index-ONn9VIq7.js +5 -0
  223. package/frontend/dist/assets/markdown-math-CYlHEDRF.css +1 -0
  224. package/frontend/dist/index.html +11 -10
  225. package/frontend/dist/js/ArtifactContainer-CqKsiKz0.js +1 -0
  226. package/frontend/dist/js/ArtifactDemoPage-Dd5BjIu2.js +200 -0
  227. package/frontend/dist/js/ArtifactSlideOutPanel-Yc7ttIaY.js +1 -0
  228. package/frontend/dist/js/Button-BUjLpHmR.js +1 -0
  229. package/frontend/dist/js/ChatPage-Cpy7lQ0D.js +16 -0
  230. package/frontend/dist/js/FirstTimeSetup-DcGhm0H0.js +1 -0
  231. package/frontend/dist/js/GalleryPage-DNI2Evvf.js +1 -0
  232. package/frontend/dist/js/LibreClawPage-CmTiROsJ.js +1 -0
  233. package/frontend/dist/js/ModelManagerModals-CfvSeNsT.js +1 -0
  234. package/frontend/dist/js/ModelsPage-CeTGqx4q.js +2 -0
  235. package/frontend/dist/js/OptimizedSyntaxHighlighter-CNjLqj1Z.js +1 -0
  236. package/frontend/dist/js/PersonasPage-BUqu7gJ3.js +13 -0
  237. package/frontend/dist/js/RichMessageContent-B0JO8vkR.js +3 -0
  238. package/frontend/dist/js/SettingsModal-B5aJ5vfV.js +1 -0
  239. package/frontend/dist/js/UserManagementPage-BqIIWX2M.js +1 -0
  240. package/frontend/dist/js/api-CbmZzKBu.js +15 -0
  241. package/frontend/dist/js/ar-BAOdgn6O.js +2 -0
  242. package/frontend/dist/js/artifactHtml-B7Oy2e__.js +27 -0
  243. package/frontend/dist/js/bn-Bp2KS5mx.js +2 -0
  244. package/frontend/dist/js/cs-DOgJ0c5p.js +2 -0
  245. package/frontend/dist/js/da-BCKTkC35.js +2 -0
  246. package/frontend/dist/js/de-BXyECph5.js +2 -0
  247. package/frontend/dist/js/demoMode-BhEpMVh5.js +1 -0
  248. package/frontend/dist/js/es-Db4bDYIF.js +2 -0
  249. package/frontend/dist/js/fr-BPIkf6zH.js +2 -0
  250. package/frontend/dist/js/hi-Bm8D_Aux.js +2 -0
  251. package/frontend/dist/js/id-DiWaH74_.js +2 -0
  252. package/frontend/dist/js/is-DLgJywtZ.js +2 -0
  253. package/frontend/dist/js/it-lldrM8pE.js +2 -0
  254. package/frontend/dist/js/ja-Cfe9uZmQ.js +2 -0
  255. package/frontend/dist/js/ko-BhChO3MQ.js +2 -0
  256. package/frontend/dist/js/logger-BmpKNkls.js +1 -0
  257. package/frontend/dist/js/markdown-core-fkbHPd-g.js +16 -0
  258. package/frontend/dist/js/markdown-math-Ci4QOsf-.js +261 -0
  259. package/frontend/dist/js/ms-SWtmetXo.js +2 -0
  260. package/frontend/dist/js/nl-CUO6I3nO.js +2 -0
  261. package/frontend/dist/js/pl-BUAu96P6.js +2 -0
  262. package/frontend/dist/js/pt-DCHwoWiE.js +2 -0
  263. package/frontend/dist/js/{react-vendor-Dh6nfvM2.js → react-vendor-Co1u1rWb.js} +2 -2
  264. package/frontend/dist/js/ru-Ciz053N7.js +2 -0
  265. package/frontend/dist/js/sv-D38ZHjv-.js +2 -0
  266. package/frontend/dist/js/syntax-highlight-D5wpTVgr.js +8 -0
  267. package/frontend/dist/js/th-D2cAucvn.js +2 -0
  268. package/frontend/dist/js/tr-Go355oDu.js +2 -0
  269. package/frontend/dist/js/ui-vendor-BJAeWL11.js +177 -0
  270. package/frontend/dist/js/uk-cdzjhgya.js +2 -0
  271. package/frontend/dist/js/useBaseQuery-6OJiOiyu.js +1 -0
  272. package/frontend/dist/js/useQuery-DfkI6VAv.js +1 -0
  273. package/frontend/dist/js/utils-BaPYjs_z.js +1 -0
  274. package/frontend/dist/js/utils-vendor-BX3ZwoIK.js +9 -0
  275. package/frontend/dist/js/vi-BSOpE423.js +2 -0
  276. package/frontend/dist/js/zh-BFh6sHZG.js +2 -0
  277. package/package.json +12 -8
  278. package/backend/dist/services/openclawSessionService.d.ts +0 -63
  279. package/backend/dist/services/openclawSessionService.d.ts.map +0 -1
  280. package/backend/dist/services/openclawSessionService.js +0 -307
  281. package/backend/dist/services/openclawSessionService.js.map +0 -1
  282. package/frontend/dist/assets/index-cOuIFv6G.js +0 -314
  283. package/frontend/dist/assets/index-tuVjvNle.css +0 -1
  284. package/frontend/dist/js/ArtifactContainer-DXa2t8GS.js +0 -24
  285. package/frontend/dist/js/ArtifactDemoPage-Dms7P2gI.js +0 -98
  286. package/frontend/dist/js/ChatPage-C6hOVIAS.js +0 -15
  287. package/frontend/dist/js/GalleryPage-CGKPECJV.js +0 -1
  288. package/frontend/dist/js/ModelsPage-CNB-c-JM.js +0 -1
  289. package/frontend/dist/js/PersonasPage-hDiS0Rvl.js +0 -13
  290. package/frontend/dist/js/UserManagementPage-1H9kcHeR.js +0 -1
  291. package/frontend/dist/js/api-MQ7bONaU.js +0 -3
  292. package/frontend/dist/js/appStore-BpzQfKOd.js +0 -2
  293. package/frontend/dist/js/authStore-Cn_WS6Kb.js +0 -2
  294. package/frontend/dist/js/demoMode-PKHbba1m.js +0 -1
  295. package/frontend/dist/js/markdown-vendor-DLzJCMRQ.js +0 -22
  296. package/frontend/dist/js/ui-vendor-ClcVY3m-.js +0 -177
  297. package/frontend/dist/js/utils-vendor-BCQRX-0Q.js +0 -9
  298. package/plugins/openclaw-agent.json +0 -69
@@ -0,0 +1,13 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-fkbHPd-g.js";import{t as r}from"./useQuery-DfkI6VAv.js";import{t as i}from"./logger-BmpKNkls.js";import{At as a,Et as o,H as s,Lt as c,O as l,Ot as u,P as d,T as f,U as p,Vt as m,c as h,ct as g,jt as _,kt as v,l as y,m as b,n as x,nt as S,o as C,pt as w,q as T,st as E,t as D,u as O,v as k,vt as A,xt as j}from"./ui-vendor-BJAeWL11.js";import{a as M,c as N,o as P,p as F,s as I}from"./api-CbmZzKBu.js";import{t as L}from"./utils-BaPYjs_z.js";import{t as R}from"./Button-BUjLpHmR.js";import{H as z,k as B,r as V,y as H}from"../assets/index-ONn9VIq7.js";var U=e(n(),1),W=t(),G=i(`components:persona-card`),K=({persona:e,onEdit:t,onDelete:n,onDownload:i,onSelect:s,onToggleFavorite:f,isSelected:p=!1,compact:h=!1})=>{let{t:_}=B(),y=z(),[x,C]=(0,U.useState)(!1),[w,T]=(0,U.useState)(!1),A=!!(e.memory_settings?.enabled||e.mutation_settings?.enabled),{data:N=null}=r({queryKey:[`persona-memory-status`,e.id],queryFn:async()=>{let t=await M.getMemoryStatus(e.id);return t.success&&t.data?t.data:null},enabled:A}),F=()=>y.invalidateQueries({queryKey:[`persona-memory-status`,e.id]}),V=async()=>{if(confirm(_(`personaCard.wipeConfirm`))){T(!0);try{let t=await M.wipeMemories(e.id);t.success?(m.success(_(`personaCard.wipeSuccess`,{count:t.data?.deleted_count||0})),await F()):m.error(_(`personaCard.failed`,{action:`wipe memories`}))}catch(e){m.error(_(`personaCard.failed`,{action:`wipe memories`})),G.error(e)}finally{T(!1),C(!1)}}},H=async()=>{T(!0);try{let t=await M.backupPersona(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-backup.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),m.success(_(`personaCard.backupSuccess`))}catch(e){m.error(_(`personaCard.failed`,{action:`backup persona`})),G.error(e)}finally{T(!1),C(!1)}},K=async()=>{T(!0);try{let t=await M.exportPersonaDNA(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-dna.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),m.success(_(`personaCard.dnaSuccess`))}catch(e){m.error(_(`personaCard.failed`,{action:`export persona DNA`})),G.error(e)}finally{T(!1),C(!1)}},q=(t=128)=>P(e,t),J=(t=128)=>n=>{I(n.currentTarget,e.name,t)};return h?(0,W.jsxs)(`div`,{className:L(`group relative flex items-center gap-3 p-3 rounded-xl cursor-pointer transition-all duration-200`,`border border-transparent`,`hover:bg-gray-50 dark:hover:bg-dark-100`,p&&[`bg-primary-50 dark:bg-primary-900/20`,`border-primary-200 dark:border-primary-700`]),onClick:()=>s?.(e),children:[(0,W.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,W.jsx)(`img`,{src:q(64),alt:e.name,className:`w-10 h-10 rounded-full object-cover ring-2 ring-white dark:ring-dark-100`,onError:J(64)}),A&&(0,W.jsx)(`div`,{className:`absolute -bottom-0.5 -right-0.5 w-4 h-4 bg-gradient-to-br from-purple-500 to-primary-500 rounded-full flex items-center justify-center`,children:(0,W.jsx)(a,{className:`h-2.5 w-2.5 text-white`})})]}),(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`h4`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100 truncate`,children:e.name}),e.is_favorite&&(0,W.jsx)(b,{className:`h-3 w-3 text-amber-500 fill-amber-500 flex-shrink-0`})]}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:e.model})]}),p&&(0,W.jsx)(`div`,{className:`flex-shrink-0`,children:(0,W.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary-500 dark:bg-primary-600 flex items-center justify-center`,children:(0,W.jsx)(l,{className:`h-3 w-3 text-white ml-0.5`})})})]}):(0,W.jsxs)(`div`,{className:L(`group relative rounded-2xl overflow-hidden transition-all duration-300`,`bg-white dark:bg-dark-100`,`border border-gray-200/60 dark:border-dark-300/60`,`hover:border-gray-300 dark:hover:border-dark-400`,`shadow-sm hover:shadow-lg dark:shadow-none`,p&&[`ring-2 ring-primary-500 dark:ring-primary-400`,`border-primary-300 dark:border-primary-600`]),children:[(0,W.jsxs)(`div`,{className:`relative h-20`,children:[e.background?(0,W.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${e.background})`}}):(0,W.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-primary-400 via-primary-500 to-purple-600 dark:from-primary-600 dark:via-primary-700 dark:to-purple-800`}),(0,W.jsx)(`div`,{className:`absolute inset-0 bg-black/10 dark:bg-black/20`}),(0,W.jsxs)(`div`,{className:`absolute top-3 left-3 right-3 flex items-start justify-between`,children:[(0,W.jsx)(`button`,{onClick:t=>{t.stopPropagation(),f?.(e)},className:L(`p-1.5 rounded-full transition-all duration-200`,`bg-white/20 hover:bg-white/30 backdrop-blur-sm`,e.is_favorite&&`bg-amber-500/80 hover:bg-amber-500`),children:(0,W.jsx)(b,{className:L(`h-4 w-4`,e.is_favorite?`text-white fill-white`:`text-white/80 hover:text-white`)})}),A&&(0,W.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 rounded-full bg-white/20 backdrop-blur-sm text-white text-[10px] font-medium`,children:[(0,W.jsx)(a,{className:`h-3 w-3`}),_(`personaCard.enhanced`)]})]})]}),(0,W.jsx)(`div`,{className:`relative px-4 -mt-8`,children:(0,W.jsxs)(`div`,{className:`relative inline-block`,children:[(0,W.jsx)(`img`,{src:q(128),alt:e.name,className:`w-16 h-16 rounded-xl object-cover ring-4 ring-white dark:ring-dark-100 shadow-lg`,onError:J(128)}),A&&(0,W.jsx)(`div`,{className:`absolute -bottom-1 -right-1 w-6 h-6 bg-gradient-to-br from-purple-500 to-primary-500 rounded-lg flex items-center justify-center shadow-sm`,children:(0,W.jsx)(j,{className:`h-3.5 w-3.5 text-white`})})]})}),(0,W.jsxs)(`div`,{className:`px-4 pt-3 pb-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 leading-tight`,children:e.name}),(0,W.jsxs)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 flex items-center gap-1.5 mt-0.5`,children:[(0,W.jsx)(k,{className:`h-3.5 w-3.5`}),e.model]})]}),e.description&&(0,W.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2 mb-3`,children:e.description}),e.parameters.system_prompt&&(0,W.jsxs)(`div`,{className:`mb-3 p-2.5 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-100 dark:border-dark-200`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,W.jsx)(d,{className:`h-3 w-3 text-gray-400 dark:text-gray-500`}),(0,W.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider font-medium text-gray-400 dark:text-gray-500`,children:_(`personaCard.systemPrompt`)})]}),(0,W.jsxs)(`p`,{className:`text-xs text-gray-600 dark:text-gray-400 line-clamp-2 italic`,children:[`“`,e.parameters.system_prompt,`”`]})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:[(0,W.jsx)(D,{className:`h-3 w-3`}),e.parameters.temperature?.toFixed(1)||`0.7`]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center px-2 py-1 rounded-md text-[11px] font-medium bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:[`Top-P `,e.parameters.top_p?.toFixed(1)||`0.9`]}),(0,W.jsxs)(`span`,{className:`inline-flex items-center px-2 py-1 rounded-md text-[11px] font-medium bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:[(e.parameters.context_window||4096).toLocaleString(),` ctx`]})]}),A&&N&&(0,W.jsx)(`div`,{className:`mb-3 p-2.5 rounded-lg bg-gradient-to-r from-primary-50 to-purple-50 dark:from-primary-900/20 dark:to-purple-900/20 border border-primary-100 dark:border-primary-800/30`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(g,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300`,children:[N.memory_count,` `,_(`personaCard.memories`)]}),(0,W.jsx)(`span`,{className:`text-[10px] text-primary-600/70 dark:text-primary-400/70 ml-2`,children:(e=>e<1?`${(e*1024).toFixed(0)} KB`:`${e.toFixed(1)} MB`)(N.size_mb)})]})]}),N.status&&(0,W.jsx)(`span`,{className:L(`text-[10px] px-1.5 py-0.5 rounded-full font-medium`,N.status===`active`?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`),children:N.status})]})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between pt-3 border-t border-gray-100 dark:border-dark-200`,children:[s&&(0,W.jsxs)(R,{onClick:()=>s(e),size:`sm`,className:`bg-primary-500 hover:bg-primary-600 dark:bg-primary-600 dark:hover:bg-primary-500 text-white px-4`,children:[(0,W.jsx)(l,{className:`h-3.5 w-3.5 mr-1.5`}),_(`personaCard.use`)]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[(0,W.jsx)(`button`,{onClick:()=>t(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:_(`personaCard.editTooltip`),children:(0,W.jsx)(v,{className:`h-4 w-4`})}),(0,W.jsx)(`button`,{onClick:()=>i(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:_(`personaCard.downloadTooltip`),children:(0,W.jsx)(E,{className:`h-4 w-4`})}),(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`button`,{onClick:()=>C(!x),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,children:(0,W.jsx)(c,{className:`h-4 w-4`})}),x&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>C(!1)}),(0,W.jsxs)(`div`,{className:`absolute right-0 bottom-full mb-1 w-44 py-1 bg-white dark:bg-dark-100 rounded-xl shadow-lg border border-gray-200 dark:border-dark-300 z-20`,children:[A&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`button`,{onClick:H,disabled:w,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,W.jsx)(o,{className:`h-4 w-4`}),_(`personaCard.backup`)]}),(0,W.jsxs)(`button`,{onClick:K,disabled:w,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,W.jsx)(S,{className:`h-4 w-4`}),_(`personaCard.exportDNA`)]}),N&&N.memory_count>0&&(0,W.jsxs)(`button`,{onClick:V,disabled:w,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50`,children:[(0,W.jsx)(u,{className:`h-4 w-4`}),_(`personaCard.wipeMemories`)]}),(0,W.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200`})]}),(0,W.jsxs)(`button`,{onClick:()=>{n(e),C(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20`,children:[(0,W.jsx)(O,{className:`h-4 w-4`}),_(`common.delete`)]})]})]})]})]})]})]})]})},q={name:``,description:``,model:``,parameters:{temperature:.7,top_p:.9,top_k:40,context_window:4096,max_tokens:1024,system_prompt:``,repeat_penalty:1.1,presence_penalty:0,frequency_penalty:0},avatar:``,background:``,embedding_model:``,memory_settings:{enabled:!1,max_memories:1e3,auto_cleanup:!0,retention_days:90},mutation_settings:{enabled:!1,sensitivity:`medium`,auto_adapt:!0}};function J({embeddingModel:e,embeddingModels:t,onEmbeddingModelChange:n}){let{t:r}=B(),i=t.filter(e=>e.isDetectedEmbedding),a=t.filter(e=>!e.isDetectedEmbedding);return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl p-5 bg-gradient-to-br from-primary-50 to-primary-100/50 dark:from-primary-900/30 dark:to-primary-800/20 border border-primary-200/50 dark:border-primary-700/30`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,W.jsx)(g,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}),(0,W.jsx)(`h3`,{className:`font-semibold text-primary-900 dark:text-primary-100`,children:r(`personaForm.advanced.embeddingModel`)})]}),(0,W.jsx)(`p`,{className:`text-xs text-primary-600 dark:text-primary-400 mb-3`,children:r(`personaForm.advanced.embeddingHint`)}),(0,W.jsx)(`select`,{value:e,onChange:e=>n(e.target.value),className:`w-full px-3 py-2.5 border border-primary-200 dark:border-primary-700 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20`,children:t.length===0?(0,W.jsx)(`option`,{value:``,disabled:!0,children:r(`personaForm.advanced.noModels`)}):(0,W.jsxs)(W.Fragment,{children:[i.length>0&&(0,W.jsx)(`optgroup`,{label:r(`personaForm.advanced.embeddingModels`),children:i.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))}),a.length>0&&(0,W.jsx)(`optgroup`,{label:r(`personaForm.advanced.otherModels`),children:a.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))})]})}),t.length===0&&(0,W.jsx)(`div`,{className:`mt-3 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700/50 rounded-lg`,children:(0,W.jsxs)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:[r(`personaForm.advanced.installHint`),` `,(0,W.jsx)(`code`,{className:`px-1.5 py-0.5 bg-amber-100 dark:bg-amber-900/40 rounded text-xs`,children:`ollama pull nomic-embed-text`})]})}),(0,W.jsx)(`p`,{className:`text-[10px] text-primary-500 dark:text-primary-500 mt-2`,children:r(`personaForm.advanced.recommended`)})]}),(0,W.jsx)(`div`,{className:`p-4 bg-gray-50 dark:bg-dark-50 rounded-xl border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,W.jsx)(s,{className:`h-5 w-5 text-gray-400 mt-0.5 flex-shrink-0`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`personaForm.advanced.aboutTitle`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:r(`personaForm.advanced.aboutDescription`)})]})]})})]})}var Y=i(`components:persona-background-upload`),X=({value:e,onChange:t,className:n=``})=>{let{t:r}=B(),i=(0,U.useRef)(null),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),l=async e=>{if(!e.type.startsWith(`image/`)){m.error(r(`personaBackground.invalidFile`));return}if(e.size>5*1024*1024){m.error(r(`personaBackground.fileTooLarge`));return}o(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),m.success(r(`personaBackground.uploaded`))},n.onerror=()=>{m.error(r(`personaBackground.readFailed`))},n.readAsDataURL(e)}catch(e){Y.error(`Failed to upload background:`,e),m.error(r(`personaBackground.uploadFailed`))}finally{o(!1)}};return(0,W.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:r(`personaBackground.label`)}),(0,W.jsxs)(`div`,{className:`space-y-3`,children:[e?(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsx)(`div`,{className:`w-full h-32 rounded-lg bg-cover bg-center border-2 border-gray-300 dark:border-dark-300`,style:{backgroundImage:`url(${e})`}}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:r(`personaBackground.customBackground`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`personaBackground.clickToChange`)})]}),(0,W.jsx)(R,{variant:`ghost`,size:`sm`,onClick:()=>{t(``),m.success(r(`personaBackground.removed`))},className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,W.jsx)(x,{className:`h-4 w-4`})})]})]}):(0,W.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${s?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:e=>{e.preventDefault(),c(!0)},onDragLeave:e=>{e.preventDefault(),c(!1)},onDrop:e=>{e.preventDefault(),c(!1);let t=e.dataTransfer.files?.[0];t&&l(t)},onClick:()=>i.current?.click(),children:[(0,W.jsx)(p,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,W.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:r(`personaBackground.uploadBackgroundImage`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:r(`personaBackground.dragAndDrop`)}),(0,W.jsxs)(R,{variant:`outline`,size:`sm`,disabled:a,className:`mx-auto`,children:[(0,W.jsx)(h,{className:`h-4 w-4 mr-2`}),r(a?`personaBackground.uploading`:`personaBackground.chooseImage`)]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:r(`personaBackground.enterImageUrl`)}),(0,W.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/background.jpg`})]})]}),(0,W.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,onChange:e=>{let t=e.target.files?.[0];t&&l(t)},className:`hidden`}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:r(`personaBackground.supportedFormats`)})]})})};function ee({formData:e,availableModels:t,onFieldChange:n,onParameterChange:r}){let{t:i}=B();return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[i(`personaForm.basic.name`),` *`]}),(0,W.jsx)(`input`,{type:`text`,value:e.name,onChange:e=>n(`name`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,placeholder:i(`personaForm.basic.namePlaceholder`),required:!0})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[i(`personaForm.basic.model`),` *`]}),(0,W.jsxs)(`select`,{value:e.model,onChange:e=>n(`model`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,required:!0,children:[(0,W.jsx)(`option`,{value:``,children:i(`personaForm.basic.selectModel`)}),t.map(e=>(0,W.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:i(`personaForm.basic.description`)}),(0,W.jsx)(`textarea`,{value:e.description,onChange:e=>n(`description`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none`,rows:3,placeholder:i(`personaForm.basic.descriptionPlaceholder`)})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,W.jsx)(V,{value:e.avatar||``,onChange:e=>n(`avatar`,e)}),(0,W.jsx)(X,{value:e.background||``,onChange:e=>n(`background`,e)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:i(`personaForm.basic.systemPrompt`)}),(0,W.jsx)(`textarea`,{value:e.parameters.system_prompt,onChange:e=>r(`system_prompt`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none font-mono text-sm`,rows:6,placeholder:i(`personaForm.basic.systemPromptPlaceholder`)}),(0,W.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-2`,children:i(`personaForm.basic.systemPromptHint`)})]})]})}function te({persona:e,submitting:t,saveAndClose:n,lastSaved:r,onCancel:i,onSave:a,onSaveAndClose:o}){let{t:s}=B();return(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(R,{type:`button`,variant:`ghost`,onClick:i,disabled:t,className:`text-gray-600 dark:text-gray-400`,children:s(`personaForm.actions.cancel`)}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r&&(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,W.jsx)(A,{className:`h-4 w-4`}),(0,W.jsx)(`span`,{children:s(`personaForm.saved`)})]}),(0,W.jsx)(R,{type:`button`,variant:`outline`,onClick:a,disabled:t,children:s(t&&!n?`personaForm.actions.saving`:`personaForm.actions.save`)}),(0,W.jsx)(R,{type:`button`,onClick:o,disabled:t,children:s(t&&n?`personaForm.actions.saving`:e?`personaForm.actions.saveClose`:`personaForm.actions.create`)})]})]})}var Z=({label:e,value:t,min:n,max:r,step:i,onChange:a,hint:o,format:s=e=>String(e),colorClass:c=`text-gray-700 dark:text-dark-600`})=>{let l=(t-n)/(r-n)*100;return(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,W.jsx)(`label`,{className:L(`block text-sm font-medium`,c),children:e}),(0,W.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:s(t),onChange:e=>{let t=parseFloat(e.target.value);isNaN(t)||a(Math.min(r,Math.max(n,t)))},className:`w-20 px-2 py-1 text-sm text-right bg-gray-100 dark:bg-dark-200 border border-gray-300 dark:border-dark-300 rounded focus:outline-none focus:ring-1 focus:ring-primary-500 dark:text-dark-600`})]}),(0,W.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>a(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 dark:bg-dark-200 rounded-lg appearance-none cursor-pointer slider`,style:{"--progress":`${l}%`}}),o&&(0,W.jsx)(`p`,{className:L(`text-xs mt-1`,c.replace(`700`,`500`).replace(`600`,`400`)),children:o})]})},Q=({label:e,checked:t,onChange:n,colorClass:r=`text-gray-700 dark:text-dark-600`})=>(0,W.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,W.jsx)(`div`,{className:L(`relative w-10 h-5 rounded-full transition-colors`,t?`bg-primary-500 dark:bg-primary-600`:`bg-gray-300 dark:bg-dark-300`),onClick:()=>n(!t),children:(0,W.jsx)(`div`,{className:L(`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-5`)})}),(0,W.jsx)(`span`,{className:L(`text-sm font-medium`,r),children:e})]});function ne({formData:e,persona:t,memoryStatus:n,loadingMemoryStatus:r,wipingMemories:i,onSettingsChange:o,onWipeMemories:s}){let{t:c}=B();return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-emerald-200/50 dark:border-emerald-700/30`,children:[(0,W.jsx)(`div`,{className:`px-5 py-4 bg-gradient-to-r from-emerald-500 to-teal-500 dark:from-emerald-600 dark:to-teal-600`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,W.jsx)(g,{className:`h-5 w-5 text-white`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold text-white`,children:c(`personaForm.memory.title`)}),(0,W.jsx)(`p`,{className:`text-xs text-white/80`,children:c(`personaForm.memory.subtitle`)})]})]}),(0,W.jsx)(Q,{label:``,checked:e.memory_settings?.enabled||!1,onChange:e=>o(`memory_settings`,{enabled:e})})]})}),e.memory_settings?.enabled&&t?.id&&(0,W.jsx)(`div`,{className:`px-5 py-4 bg-emerald-50 dark:bg-emerald-900/20 border-b border-emerald-100 dark:border-emerald-800/30`,children:r?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,W.jsx)(f,{className:`h-4 w-4 animate-spin`}),c(`personaForm.memory.loading`)]}):n?(0,W.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,W.jsxs)(`div`,{className:`text-center`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(g,{className:`h-5 w-5`}),n.memory_count.toLocaleString()]}),(0,W.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:c(`personaForm.memory.memories`)})]}),(0,W.jsxs)(`div`,{className:`text-center`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(T,{className:`h-5 w-5`}),n.size_mb.toFixed(1)]}),(0,W.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:c(`personaForm.memory.mbUsed`)})]}),(0,W.jsxs)(`div`,{className:`text-center`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(w,{className:`h-5 w-5`}),n.last_backup?new Date(n.last_backup).toLocaleDateString():c(`personaForm.memory.never`)]}),(0,W.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:c(`personaForm.memory.lastBackup`)})]})]}):(0,W.jsx)(`p`,{className:`text-sm text-emerald-600 dark:text-emerald-400`,children:c(`personaForm.memory.noData`)})}),e.memory_settings?.enabled&&(0,W.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-4`,children:[(0,W.jsx)(Z,{label:c(`personaForm.memory.maxMemories`),value:e.memory_settings.max_memories,min:100,max:1e4,step:100,hint:c(`personaForm.memory.maxMemoriesHint`),format:e=>e.toLocaleString(),colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>o(`memory_settings`,{max_memories:e})}),(0,W.jsx)(Z,{label:c(`personaForm.memory.retention`),value:e.memory_settings.retention_days,min:7,max:365,step:7,hint:c(`personaForm.memory.retentionHint`),format:e=>`${Math.round(e)} days`,colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>o(`memory_settings`,{retention_days:e})}),(0,W.jsx)(Q,{label:c(`personaForm.memory.autoCleanup`),checked:e.memory_settings.auto_cleanup,onChange:e=>o(`memory_settings`,{auto_cleanup:e}),colorClass:`text-emerald-700 dark:text-emerald-300`}),t?.id&&n&&n.memory_count>0&&(0,W.jsx)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800/30`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:c(`personaForm.memory.wipeAll`)}),(0,W.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c(`personaForm.memory.wipeCannot`)})]}),(0,W.jsxs)(`button`,{type:`button`,onClick:s,disabled:i,className:`px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 flex items-center gap-1.5`,children:[i?(0,W.jsx)(f,{className:`h-3.5 w-3.5 animate-spin`}):(0,W.jsx)(O,{className:`h-3.5 w-3.5`}),c(i?`personaForm.memory.wiping`:`personaForm.memory.wipeButton`)]})]})})]}),!e.memory_settings?.enabled&&(0,W.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,W.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:c(`personaForm.memory.enableHint`)})})]}),(0,W.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-primary-200/50 dark:border-primary-700/30`,children:[(0,W.jsx)(`div`,{className:`px-5 py-4 bg-primary-600 dark:bg-primary-600`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,W.jsx)(y,{className:`h-5 w-5 text-white`})}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold text-white`,children:c(`personaForm.learning.title`)}),(0,W.jsx)(`p`,{className:`text-xs text-white/80`,children:c(`personaForm.learning.subtitle`)})]})]}),(0,W.jsx)(Q,{label:``,checked:e.mutation_settings?.enabled||!1,onChange:e=>o(`mutation_settings`,{enabled:e})})]})}),e.mutation_settings?.enabled&&(0,W.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-primary-700 dark:text-primary-300 mb-3`,children:c(`personaForm.learning.speed`)}),(0,W.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:[{level:`low`,icon:D,label:c(`personaForm.learning.slow`),desc:c(`personaForm.learning.slowDesc`)},{level:`medium`,icon:y,label:c(`personaForm.learning.balanced`),desc:c(`personaForm.learning.balancedDesc`)},{level:`high`,icon:a,label:c(`personaForm.learning.fast`),desc:c(`personaForm.learning.fastDesc`)}].map(({level:t,icon:n,label:r,desc:i})=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>o(`mutation_settings`,{sensitivity:t}),className:L(`p-3 rounded-xl text-center transition-all border`,e.mutation_settings?.sensitivity===t?`bg-primary-600 border-primary-600 text-white shadow-lg`:`bg-primary-50 dark:bg-primary-900/20 border-primary-200 dark:border-primary-700/30 text-primary-700 dark:text-primary-300 hover:bg-primary-100 dark:hover:bg-primary-900/30`),children:[(0,W.jsx)(n,{className:`h-5 w-5 mx-auto mb-1`}),(0,W.jsx)(`p`,{className:`text-sm font-medium`,children:r}),(0,W.jsx)(`p`,{className:`text-[10px] opacity-70`,children:i})]},t))})]}),(0,W.jsx)(Q,{label:c(`personaForm.learning.autoAdapt`),checked:e.mutation_settings.auto_adapt,onChange:e=>o(`mutation_settings`,{auto_adapt:e}),colorClass:`text-primary-700 dark:text-primary-300`}),(0,W.jsxs)(`div`,{className:`p-4 bg-primary-50 dark:bg-primary-900/20 rounded-xl`,children:[(0,W.jsxs)(`p`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300 mb-2 flex items-center gap-1.5`,children:[(0,W.jsx)(j,{className:`h-3.5 w-3.5`}),c(`personaForm.learning.whatLearns`)]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-primary-600 dark:text-primary-400`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),c(`personaForm.learning.conversationTone`)]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),c(`personaForm.learning.responseStyle`)]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),c(`personaForm.learning.userPreferences`)]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),c(`personaForm.learning.topicInterests`)]})]})]})]}),!e.mutation_settings?.enabled&&(0,W.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,W.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:c(`personaForm.learning.enableHint`)})})]})]})}function re({parameters:e,onParameterChange:t}){let{t:n}=B();return(0,W.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:(0,U.useMemo)(()=>[{key:`temperature`,label:n(`personaForm.parameters.temperature`),min:0,max:2,step:.1,hint:n(`personaForm.parameters.temperatureHint`),format:e=>e.toFixed(1)},{key:`top_p`,label:n(`personaForm.parameters.topP`),min:0,max:1,step:.1,hint:n(`personaForm.parameters.topPHint`),format:e=>e.toFixed(1)},{key:`top_k`,label:n(`personaForm.parameters.topK`),min:1,max:100,step:1,hint:n(`personaForm.parameters.topKHint`),format:e=>String(Math.round(e))},{key:`context_window`,label:n(`personaForm.parameters.contextWindow`),min:128,max:131072,step:128,hint:n(`personaForm.parameters.contextWindowHint`),format:e=>String(Math.round(e))},{key:`max_tokens`,label:n(`personaForm.parameters.maxTokens`),min:1,max:8192,step:1,hint:n(`personaForm.parameters.maxTokensHint`),format:e=>String(Math.round(e))},{key:`repeat_penalty`,label:n(`personaForm.parameters.repeatPenalty`),min:.5,max:2,step:.1,hint:n(`personaForm.parameters.repeatPenaltyHint`),format:e=>e.toFixed(1)}],[n]).map(({key:n,label:r,min:i,max:a,step:o,hint:s,format:c})=>(0,W.jsx)(Z,{label:r,value:e[n]||0,min:i,max:a,step:o,hint:s,format:c,onChange:e=>t(n,e)},n))})}var ie=i(`components:persona-form`),$=({persona:e,onSubmit:t,onCancel:n})=>{let{preferences:i}=H(),{t:o}=B(),[s,c]=(0,U.useState)(q),[l,u]=(0,U.useState)([]),[d,f]=(0,U.useState)([]),[p,h]=(0,U.useState)(!1),[g,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(!1),[x,S]=(0,U.useState)(null),[w,T]=(0,U.useState)(`basic`),[E,D]=(0,U.useState)(!1),O=(0,U.useRef)(!1),k=(0,U.useCallback)((e,t)=>{c(n=>({...n,[e]:t})),S(null)},[]),A=(0,U.useCallback)((e,t)=>{c(n=>({...n,parameters:{...n.parameters,[e]:t}})),S(null)},[]),P=(0,U.useCallback)((e,t)=>{c(n=>({...n,[e]:{...n[e],...t}})),S(null)},[]),I=(0,U.useCallback)(e=>{let t=e.reduce((e,t)=>(e.find(e=>e.id===t.id)||e.push(t),e),[]);return t.length>0?t:[{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]},[]),R=e?.id,V=!!s.memory_settings?.enabled,G=z(),{data:K=null,isLoading:Y}=r({queryKey:[`persona-memory-status`,R],queryFn:async()=>{if(!R)return null;let e=await M.getMemoryStatus(R);return e.success&&e.data?e.data:null},enabled:!!R&&V}),X=()=>G.invalidateQueries({queryKey:[`persona-memory-status`,R]}),Z=async()=>{if(e?.id&&confirm(o(`personaForm.memory.wipeConfirm`))){D(!0);try{let t=await M.wipeMemories(e.id);t.success?(m.success(o(`personaForm.memory.wipeSuccess`,{count:t.data?.deleted_count||0})),await X()):m.error(o(`personaForm.error.saveFailed`))}catch{m.error(o(`personaForm.error.saveFailed`))}finally{D(!1)}}};(0,U.useEffect)(()=>{O.current||(O.current=!0,(async()=>{h(!0);try{let[t,n,r]=await Promise.all([N.getModels(),F.getModels(),e?Promise.resolve(null):M.getDefaultParameters()]);t.success&&t.data&&u(t.data);let a=I(n.success&&n.data?n.data:[]);f(a);let o=a.find(e=>e.id===i.embeddingSettings?.model||e.rawModel===i.embeddingSettings?.model)?.id||a[0]?.id||``,s=a.find(t=>t.id===e?.embedding_model||t.rawModel===e?.embedding_model)?.id||e?.embedding_model||a[0]?.id||``;if(e)c({name:e.name,description:e.description||``,model:e.model,parameters:e.parameters,avatar:e.avatar||``,background:e.background||``,embedding_model:s,memory_settings:e.memory_settings||q.memory_settings,mutation_settings:e.mutation_settings||q.mutation_settings}),e.embedding_model&&!a.find(t=>t.id===e.embedding_model||t.rawModel===e.embedding_model)&&f(t=>I([...t,{id:e.embedding_model,name:e.embedding_model,description:`Previously selected model (not currently available)`,provider:`openai`,dimensions:0}]));else{let e=r?.success?r.data:{};c(t=>({...t,parameters:{...t.parameters,...e},embedding_model:o}))}}catch(e){ie.error(`Error loading data:`,e)}finally{h(!1)}})())},[e,I,i.embeddingSettings?.model]);let Q=async n=>{v(!0),b(n);try{let r={name:s.name,description:s.description,model:s.model,parameters:s.parameters,avatar:s.avatar,background:s.background,embedding_model:s.embedding_model,memory_settings:s.memory_settings,mutation_settings:s.mutation_settings},i=e?await M.updatePersona(e.id,r):await M.createPersona(s);i.success?(m.success(o(e?`personaForm.success.updated`:`personaForm.success.created`)),S(new Date),n&&t()):m.error(`${o(`personaForm.error.saveFailed`)}: ${i.error}`)}catch(e){m.error(`${o(`personaForm.error.saveFailed`)}: ${e instanceof Error?e.message:String(e)}`)}finally{v(!1),b(!1)}},$=(0,U.useMemo)(()=>[{id:`basic`,label:o(`personaForm.tabs.basic`),icon:C},{id:`parameters`,label:o(`personaForm.tabs.parameters`),icon:_},{id:`memory`,label:o(`personaForm.tabs.memory`),icon:a},{id:`advanced`,label:o(`personaForm.tabs.advanced`),icon:j}],[o]);return p?(0,W.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,W.jsxs)(`div`,{className:`animate-pulse flex items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary-500 border-t-transparent rounded-full animate-spin`}),(0,W.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:o(`personaForm.loading`)})]})}):(0,W.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,W.jsxs)(`div`,{className:`mb-6`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:o(e?`personaForm.title.edit`:`personaForm.title.create`)}),(0,W.jsxs)(`div`,{className:`flex items-center gap-4 mt-1`,children:[(0,W.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600`,children:o(e?`personaForm.subtitle.edit`:`personaForm.subtitle.create`)}),x&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,W.jsx)(`div`,{className:`w-2 h-2 bg-green-500 rounded-full`}),o(`personaForm.saved`),` `,x.toLocaleTimeString()]})]})]}),(0,W.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`div`,{className:`flex border-b border-gray-200 dark:border-dark-300`,children:$.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>T(e.id),className:L(`flex items-center gap-2 px-6 py-4 text-sm font-medium transition-colors`,w===e.id?`border-b-2 border-primary-500 text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-dark-600 hover:text-gray-700 dark:hover:text-dark-800`),children:[(0,W.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.id))}),(0,W.jsxs)(`div`,{className:`p-6`,children:[w===`basic`&&(0,W.jsx)(ee,{formData:s,availableModels:l,onFieldChange:k,onParameterChange:A}),w===`parameters`&&(0,W.jsx)(re,{parameters:s.parameters,onParameterChange:A}),w===`memory`&&(0,W.jsx)(ne,{formData:s,persona:e,memoryStatus:K,loadingMemoryStatus:Y,wipingMemories:E,onSettingsChange:P,onWipeMemories:Z}),w===`advanced`&&(0,W.jsx)(J,{embeddingModel:s.embedding_model,embeddingModels:d,onEmbeddingModelChange:e=>k(`embedding_model`,e)})]})]}),(0,W.jsx)(te,{persona:e,submitting:g,saveAndClose:y,lastSaved:x,onCancel:n,onSave:()=>Q(!1),onSaveAndClose:()=>Q(!0)})]})]})},ae=i(`components:persona-import-export`),oe=({personas:e,onImport:t,onClose:n})=>{let{t:r}=B(),[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(``),c=async e=>{try{let t=await M.exportPersona(e.id),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),i=URL.createObjectURL(n),a=document.createElement(`a`);a.href=i,a.download=`${e.name}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),m.success(r(`personaImportExport.exportSuccess`,{name:e.name}))}catch(e){let t=e instanceof Error?e.message:String(e);m.error(r(`personaImportExport.exportFailed`)+`: `+t)}};return(0,W.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,W.jsxs)(`div`,{className:`mb-6`,children:[(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:r(`personaImportExport.title`)}),(0,W.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mt-1`,children:r(`personaImportExport.description`)})]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:r(`personaImportExport.exportPersonas`)}),e.length===0?(0,W.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-center py-8`,children:r(`personaImportExport.noPersonasToExport`)}):(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,W.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:r(`personaImportExport.personasAvailable`,{count:e.length})}),(0,W.jsx)(R,{onClick:async()=>{try{let t=e.map(e=>M.exportPersona(e.id)),n=await Promise.all(t),i={personas:n,exportedAt:Date.now(),version:`1.0.0`,count:n.length},a=new Blob([JSON.stringify(i,null,2)],{type:`application/json`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`personas-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o),m.success(r(`personaImportExport.exportAllSuccess`,{count:e.length}))}catch(e){let t=e instanceof Error?e.message:String(e);m.error(r(`personaImportExport.exportAllFailed`)+`: `+t)}},variant:`outline`,size:`sm`,className:`px-3 py-1`,children:r(`personaImportExport.exportAll`)})]}),(0,W.jsx)(`div`,{className:`space-y-2 max-h-80 overflow-y-auto`,children:e.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-gray-50 dark:bg-dark-200 rounded-md`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`img`,{src:P(e,32),alt:e.name,className:`w-8 h-8 rounded-full`,onError:t=>I(t.currentTarget,e.name,32)}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),(0,W.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e.model})]})]}),(0,W.jsx)(R,{onClick:()=>c(e),variant:`outline`,size:`sm`,className:`px-3 py-1`,children:r(`common.export`)})]},e.id))})]})]}),(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:r(`personaImportExport.importPersonas`)}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:r(`personaImportExport.uploadJsonFile`)}),(0,W.jsx)(`input`,{type:`file`,accept:`.json`,onChange:e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{let t=e.target?.result;typeof t==`string`&&s(t)},e.readAsText(t)}},className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`})]}),(0,W.jsx)(`div`,{className:`text-center text-gray-500 dark:text-dark-500`,children:r(`common.or`).toUpperCase()}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:r(`personaImportExport.pasteJsonLabel`)}),(0,W.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`,rows:8,placeholder:r(`personaImportExport.pasteJsonPlaceholder`)})]}),(0,W.jsx)(R,{onClick:async()=>{if(!o.trim()){m.error(r(`personaImportExport.pasteJsonData`));return}a(!0);try{let e=JSON.parse(o);if(e.personas&&Array.isArray(e.personas)){let t=0,n=0;for(let r of e.personas)try{await M.importPersona(r),t++}catch(e){n++,ae.error(`Failed to import persona:`,e)}t>0?(m.success(r(`personaImportExport.importMultipleSuccess`,{count:t})),n>0&&m.error(r(`personaImportExport.importMultipleFailed`,{count:n}))):m.error(r(`personaImportExport.importNoneFailed`))}else await M.importPersona(e),m.success(r(`personaImportExport.importSuccess`));s(``),t()}catch(e){let t=e instanceof Error?e.message:String(e);m.error(r(`personaImportExport.importFailed`)+`: `+t)}finally{a(!1)}},disabled:!o.trim()||i,className:`w-full`,children:r(i?`personaImportExport.importing`:`personaImportExport.importButton`)})]})]})]}),(0,W.jsxs)(`div`,{className:`mt-6 bg-gray-50 dark:bg-dark-200 rounded-lg p-4`,children:[(0,W.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-dark-800 mb-2`,children:r(`personaImportExport.expectedFormat`)}),(0,W.jsx)(`pre`,{className:`text-xs text-gray-600 dark:text-dark-600 overflow-x-auto`,children:`{
2
+ "name": "Assistant Name",
3
+ "description": "Brief description of the assistant's personality",
4
+ "model": "model-name:version",
5
+ "params": {
6
+ "temperature": 0.8,
7
+ "top_p": 0.9,
8
+ "context_window": 4096,
9
+ "system_prompt": "You are a helpful assistant with specific traits..."
10
+ },
11
+ "avatar": "/path/to/avatar.png",
12
+ "background": "/path/to/background.png"
13
+ }`})]}),(0,W.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,W.jsx)(R,{onClick:n,variant:`outline`,children:r(`common.close`)})})]})},se=()=>{let{t:e}=B(),t=z(),[n,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(!1),{data:l=[],isLoading:u,refetch:d}=r({queryKey:[`personas`],queryFn:async()=>{let e=await M.getPersonas();if(!e.success)throw Error(e.error||`Failed to load personas`);return e.data||[]}}),f=async()=>{await t.invalidateQueries({queryKey:[`personas`]}),await d()},p=()=>{o(null),i(!0)},h=e=>{o(e),i(!0)},g=async t=>{if(confirm(e(`personaManager.deleteConfirm`,{name:t.name})))try{let n=await M.deletePersona(t.id);n.success?(m.success(e(`personaManager.deleteSuccess`,{name:t.name})),await f()):m.error(e(`personaManager.failed`,{action:`delete`})+`: `+n.error)}catch(t){let n=t instanceof Error?t.message:String(t);m.error(e(`personaManager.failed`,{action:`delete`})+`: `+n)}},_=async t=>{try{await M.downloadPersona(t.id,t.name),m.success(e(`personaManager.downloadSuccess`,{name:t.name}))}catch(t){let n=t instanceof Error?t.message:String(t);m.error(e(`personaManager.failed`,{action:`download`})+`: `+n)}};return u?(0,W.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,W.jsx)(`div`,{className:`text-gray-600 dark:text-dark-600`,children:e(`personaManager.loading`)})}):n?(0,W.jsx)($,{persona:a,onSubmit:async()=>{i(!1),o(null),await f()},onCancel:()=>{i(!1),o(null)}}):s?(0,W.jsx)(oe,{personas:l,onImport:f,onClose:()=>c(!1)}):(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:e(`personaManager.title`)}),(0,W.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mt-1`,children:e(`personaManager.subtitle`)})]}),(0,W.jsxs)(`div`,{className:`flex gap-3`,children:[(0,W.jsx)(R,{onClick:()=>c(!0),variant:`outline`,className:`px-4 py-2`,children:e(`personaManager.importExport`)}),(0,W.jsx)(R,{onClick:p,className:`px-4 py-2`,children:e(`personaManager.createButton`)})]})]}),(0,W.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`personaManager.stats.title`)}),(0,W.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600`,children:e(`personaManager.stats.count`,{count:l.length})})]}),(0,W.jsx)(`div`,{className:`text-3xl font-bold text-gray-900 dark:text-dark-800`,children:l.length})]})}),l.length===0?(0,W.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-12 shadow-sm border border-gray-200 dark:border-dark-300 text-center`,children:[(0,W.jsx)(`div`,{className:`text-gray-400 dark:text-dark-500 mb-4`,children:(0,W.jsx)(`svg`,{className:`w-16 h-16 mx-auto`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,W.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`})})}),(0,W.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-2`,children:e(`personaManager.empty.title`)}),(0,W.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-6`,children:e(`personaManager.empty.description`)}),(0,W.jsx)(R,{onClick:p,className:`px-6 py-2`,children:e(`personaManager.empty.button`)})]}):(0,W.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:l.map(e=>(0,W.jsx)(K,{persona:e,onEdit:h,onDelete:g,onDownload:_},e.id))})]})},ce=()=>{let{t:e}=B();return(0,W.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,W.jsxs)(`div`,{className:`max-w-6xl mx-auto p-6`,children:[(0,W.jsxs)(`div`,{className:`text-center max-w-md mx-auto mb-8`,children:[(0,W.jsx)(`h2`,{className:`libre-brand text-4xl sm:text-5xl font-normal text-gray-900 dark:text-dark-800 mb-3`,style:{fontWeight:300,letterSpacing:0},children:e(`personaManager.title`)}),(0,W.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 leading-relaxed`,children:e(`personaManager.subtitle`)})]}),(0,W.jsx)(se,{})]})})};export{ce as PersonasPage,ce as default};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/OptimizedSyntaxHighlighter-CNjLqj1Z.js","js/rolldown-runtime-QTnfLwEv.js","js/markdown-core-fkbHPd-g.js","js/syntax-highlight-D5wpTVgr.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n,r}from"./markdown-core-fkbHPd-g.js";import{r as i,t as a}from"./logger-BmpKNkls.js";import{ut as o,vt as s}from"./ui-vendor-BJAeWL11.js";import{t as c}from"./utils-BaPYjs_z.js";import{d as l,y as u}from"../assets/index-ONn9VIq7.js";import{n as d,t as f}from"./markdown-math-Ci4QOsf-.js";var p=e(n(),1),m=t(),h=a(`components:ui:rich-message-content`),g=p.lazy(()=>i(()=>import(`./OptimizedSyntaxHighlighter-CNjLqj1Z.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3])));function _({children:e,className:t}){return(0,m.jsx)(`pre`,{className:c(`bg-gray-100 dark:bg-dark-200 p-3 rounded-lg overflow-x-auto text-sm font-mono`,t),children:(0,m.jsx)(`code`,{children:e})})}var v=({content:e,className:t})=>{let{theme:n}=u(),[i,a]=p.useState(null),v=p.useMemo(()=>l(e),[e]),y=async e=>{try{await navigator.clipboard.writeText(e),a(e),setTimeout(()=>a(null),2e3)}catch(e){h.error(`Failed to copy text:`,e)}};return(0,m.jsx)(`div`,{className:c(`prose prose-sm max-w-none dark:prose-invert prose-gray`,`[&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden [&_.katex-display]:py-2`,`[&_.katex]:text-inherit`,t),children:(0,m.jsx)(r,{remarkPlugins:[d],rehypePlugins:[f],components:{code({className:e,children:t,node:r,...a}){let l=/language-([^\s]+)/.exec(e||``),u=String(t),d=u.replace(/\n$/,``),f=l?l[1]:null;return f||u.includes(`
3
+ `)?(0,m.jsxs)(`div`,{className:`relative group my-4 overflow-hidden rounded-xl border border-gray-200 dark:border-dark-300 shadow-sm`,children:[(0,m.jsxs)(`div`,{className:`flex items-center justify-between bg-gray-50 dark:bg-dark-100 px-4 py-3 border-b border-gray-200 dark:border-dark-300`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-gray-700 dark:text-dark-700 uppercase tracking-wide`,children:f||`text`}),(0,m.jsx)(`button`,{onClick:()=>y(d),className:`opacity-0 group-hover:opacity-100 transition-all duration-200 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-300 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-1`,title:`Copy code`,children:i===d?(0,m.jsx)(s,{className:`h-4 w-4 text-success-600 dark:text-success-400`}):(0,m.jsx)(o,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`})})]}),(0,m.jsx)(`div`,{className:`overflow-x-auto`,children:(0,m.jsx)(p.Suspense,{fallback:(0,m.jsx)(_,{className:`!m-0 !rounded-none !border-none`,children:d}),children:(0,m.jsx)(g,{language:f||`text`,isDark:n.mode===`dark`,className:`!m-0 !rounded-none !border-none`,children:d})})})]}):(0,m.jsx)(`code`,{className:c(`px-2 py-1 rounded-md bg-gray-100 dark:bg-dark-200 text-gray-800 dark:text-dark-800`,`font-mono text-sm border border-gray-200 dark:border-dark-300`,e),...a,children:t})},pre({children:e,node:t,...n}){return(0,m.jsx)(`pre`,{...n,children:e})},p({children:e,...t}){return(0,m.jsx)(`div`,{className:`mb-4 last:mb-0 leading-relaxed`,...t,children:e})},ul({children:e,...t}){return(0,m.jsx)(`ul`,{className:`list-disc list-inside mb-4 space-y-2 pl-4`,...t,children:e})},ol({children:e,...t}){return(0,m.jsx)(`ol`,{className:`list-decimal list-inside mb-4 space-y-2 pl-4`,...t,children:e})},li({children:e,...t}){return(0,m.jsx)(`li`,{className:`text-gray-700 dark:text-dark-700 leading-relaxed`,...t,children:e})},blockquote({children:e,...t}){return(0,m.jsx)(`blockquote`,{className:`border-l-4 border-primary-400 dark:border-primary-500 bg-primary-25 dark:bg-primary-950/30 pl-4 py-3 my-4 rounded-r-lg italic text-gray-700 dark:text-dark-700`,...t,children:e})},h1({children:e,...t}){return(0,m.jsx)(`h1`,{className:`text-2xl font-bold mb-4 mt-6 first:mt-0 text-gray-900 dark:text-dark-800 border-b border-gray-200 dark:border-dark-300 pb-2`,...t,children:e})},h2({children:e,...t}){return(0,m.jsx)(`h2`,{className:`text-xl font-semibold mb-3 mt-6 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})},h3({children:e,...t}){return(0,m.jsx)(`h3`,{className:`text-lg font-medium mb-3 mt-4 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})}},children:v})})};export{v as RichMessageContent,v as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-fkbHPd-g.js";import{t as r}from"./useQuery-DfkI6VAv.js";import{t as i}from"./logger-BmpKNkls.js";import{C as a,Ct as o,E as s,H as c,M as l,Nt as u,O as d,P as f,St as p,U as m,V as h,Vt as g,X as _,Y as v,Z as y,_t as b,a as x,at as S,c as ee,ct as C,h as te,ht as ne,it as re,j as ie,jt as w,n as ae,ot as T,p as oe,st as se,u as ce,vt as E,w as D}from"./ui-vendor-BJAeWL11.js";import{c as le,f as ue,h as de,i as fe,n as pe,p as me,r as O,u as he}from"./api-CbmZzKBu.js";import{t as k}from"./utils-BaPYjs_z.js";import{t as A}from"./Button-BUjLpHmR.js";import{C as ge,D as _e,E as ve,H as ye,O as be,T as xe,b as Se,f as j,g as Ce,k as M,n as N,p as we,v as Te,w as Ee,y as P}from"../assets/index-ONn9VIq7.js";var F=e(n(),1),I=t(),De=[{href:`https://github.com/libre-webui/libre-webui`,icon:y,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:_,labelKey:`settings.about.links.gitlab`,descriptionKey:`settings.about.links.gitlabDescription`},{href:`https://librewebui.org`,icon:T,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:o,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://ollama.ai`,icon:p,labelKey:`settings.about.links.ollama`,descriptionKey:`settings.about.links.ollamaDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:f,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],Oe=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function ke({appVersion:e}){let{t}=M();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-4`,children:(0,I.jsx)(N,{className:`text-gray-900 dark:text-gray-100`})}),(0,I.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,I.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,I.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,I.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:Oe.map(e=>(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,I.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,I.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,I.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:De.map(e=>{let n=e.icon;return(0,I.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 p-3 bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg hover:bg-gray-50 dark:hover:bg-dark-200 hover:border-gray-300 dark:hover:border-dark-400 transition-all duration-200 group`,children:[(0,I.jsx)(n,{className:`h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,I.jsx)(T,{className:`h-4 w-4 text-gray-400 ml-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.href)})})]}),(0,I.jsx)(`div`,{className:`mt-6 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-gray-500 dark:text-gray-400`,children:[e.includes(`-dev`)?(0,I.jsx)(`span`,{children:t(`settings.about.version`,{version:e})}):(0,I.jsx)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${e}`,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:t(`settings.about.version`,{version:e})}),(0,I.jsxs)(`span`,{children:[t(`settings.about.openSourceBy`,{company:``}),(0,I.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:`Kroonen AI`})]})]})})]})})}var L=i(`components:background-upload`),Ae=({className:e=``})=>{let{t}=M(),{preferences:n,setPreferences:r,backgroundImage:i,uploadBackgroundImage:a,removeBackgroundImage:o}=P(),s=(0,F.useRef)(null),[c,l]=(0,F.useState)(!1),[u,d]=(0,F.useState)(!1),f=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},p=async e=>{if(!e.type.startsWith(`image/`)){g.error(`Please select a valid image file`);return}if(e.size>5*1024*1024){g.error(`Image file size must be less than 5MB`);return}l(!0);try{await a(e),g.success(`Background image uploaded successfully`)}catch(e){L.error(`Failed to upload background:`,e),g.error(`Failed to upload background image`)}finally{l(!1)}},h=e=>{let t=e.target.files?.[0];t&&p(t)},_=e=>{e.preventDefault(),d(!0)},v=e=>{e.preventDefault(),d(!1)},y=e=>{e.preventDefault(),d(!1);let t=e.dataTransfer.files?.[0];t&&p(t)},b=()=>{o(),g.success(`Background image removed`)},x=async e=>{let t=i||f.imageUrl||``,n={...f,imageUrl:t,enabled:e};if(r({backgroundSettings:n}),t||!e)try{await O.updatePreferences({backgroundSettings:n})}catch(e){L.error(`Failed to update preferences:`,e)}},S=async e=>{let t=i||f.imageUrl||``,n={...f,imageUrl:t,blurAmount:e};if(r({backgroundSettings:n}),t)try{await O.updatePreferences({backgroundSettings:n})}catch(e){L.error(`Failed to update preferences:`,e)}},C=async e=>{let t=i||f.imageUrl||``,n={...f,imageUrl:t,opacity:e};if(r({backgroundSettings:n}),t)try{await O.updatePreferences({backgroundSettings:n})}catch(e){L.error(`Failed to update preferences:`,e)}};return(0,I.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,I.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,I.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:f.enabled,onChange:e=>x(e.target.checked)}),(0,I.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full 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`})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[i?(0,I.jsx)(`div`,{className:`relative`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,I.jsx)(`div`,{className:`flex-shrink-0`,children:(0,I.jsx)(`img`,{src:i,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,I.jsx)(A,{variant:`ghost`,size:`sm`,onClick:b,className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,I.jsx)(ae,{className:`h-4 w-4`})})]})}):(0,I.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${u?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:_,onDragLeave:v,onDrop:y,onClick:()=>s.current?.click(),children:[(0,I.jsx)(m,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,I.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,I.jsxs)(A,{variant:`outline`,size:`sm`,disabled:c,className:`mx-auto`,children:[(0,I.jsx)(ee,{className:`h-4 w-4 mr-2`}),t(c?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,I.jsx)(`input`,{ref:s,type:`file`,accept:`image/*`,onChange:h,className:`hidden`})]}),i&&(0,I.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.blur`),`:`,` `,f.blurAmount,`px`]}),(0,I.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:f.blurAmount,onChange:e=>S(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.opacity`),`:`,` `,Math.round(f.opacity*100),`%`]}),(0,I.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.1`,value:f.opacity,onChange:e=>C(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]})]})]})})},je=()=>{let{t:e,i18n:t}=M();return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-gray-400`}),(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.appearance.language.title`)})]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.appearance.language.description`)}),(0,I.jsx)(`select`,{"data-testid":`language-switcher-select`,value:_e(t.language),onChange:e=>{let t=e.target.value;ve(t)},className:`w-full px-3 py-2 text-sm border border-gray-200 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-primary-500`,children:be.map(e=>(0,I.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))})]})};function Me({theme:e,preferences:t,onThemeChange:n,onAccentChange:r,onCustomAccentChange:i,onShowUsernameChange:a}){let{t:o}=M(),s=e.accent||`blue`,c=e.customAccent||`#2563eb`,u=ge(e);return(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(je,{}),(0,I.jsx)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:o(`settings.appearance.title`)})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsxs)(`button`,{onClick:()=>n(`light`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`light`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,I.jsx)(oe,{className:`h-4 w-4`}),o(`settings.appearance.theme.light`)]}),(0,I.jsxs)(`button`,{onClick:()=>n(`dark`),className:`flex items-center justify-center gap-2 h-12 px-3 py-2.5 text-sm font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ${e.mode===`dark`?`bg-primary-600 text-white shadow-sm hover:bg-primary-700 hover:shadow-md focus:ring-primary-500`:`border border-gray-300 text-gray-700 bg-white shadow-sm hover:bg-gray-50 hover:border-gray-400 focus:ring-gray-500 dark:border-dark-300 dark:text-dark-700 dark:bg-dark-25 dark:hover:bg-dark-200 dark:hover:border-dark-400`}`,children:[(0,I.jsx)(l,{className:`h-4 w-4`}),o(`settings.appearance.theme.dark`)]})]}),(0,I.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 pt-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-3`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:o(`settings.appearance.accent.title`,{defaultValue:`Accent color`})})}),(0,I.jsx)(`div`,{className:`h-9 w-9 rounded-full border border-gray-200 dark:border-dark-400 shadow-inner flex-shrink-0`,style:{backgroundColor:u},"aria-hidden":`true`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-5 xs:grid-cols-6 sm:grid-cols-9 gap-2`,children:[Se.map(e=>{let t=s===e.id;return(0,I.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`relative h-10 rounded-xl border transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-50 ${t?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,style:{backgroundColor:e.color},"aria-label":o(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,I.jsx)(E,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})},e.id)}),(0,I.jsxs)(`label`,{className:`relative h-10 rounded-xl border transition-all duration-200 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-500 focus-within:ring-offset-2 dark:focus-within:ring-offset-dark-50 overflow-hidden cursor-pointer ${s===`custom`?`border-gray-900 dark:border-white shadow-md scale-105`:`border-gray-200 dark:border-dark-400 hover:scale-105 hover:shadow-sm`}`,title:o(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":o(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,I.jsx)(`input`,{type:`color`,value:c,onInput:e=>i(e.currentTarget.value),onChange:e=>i(e.target.value),className:`absolute inset-0 h-full w-full cursor-pointer opacity-0`}),(0,I.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:c},"aria-hidden":`true`}),(0,I.jsx)(ie,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:o(`settings.appearance.chatInterface.title`)}),(0,I.jsx)(`div`,{className:`space-y-3`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:o(`settings.appearance.chatInterface.showUsername`)}),(0,I.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:o(`settings.appearance.chatInterface.showUsernameDescription`)})]}),(0,I.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:t.showUsername,onChange:e=>a(e.target.checked)}),(0,I.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full 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`})]})]})})]}),(0,I.jsx)(Ae,{})]})}function Ne({sessionCount:e,loading:t,importing:n,showImportOptions:r,mergeStrategy:i,importResult:a,importFileInputRef:o,onExportData:s,onImportFileSelect:c,onClearAllHistory:l,onMergeStrategyChange:u,onConfirmImport:d,onCancelImport:f,onDismissImportResult:p}){let{t:m}=M();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.data.title`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.data.export`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:m(`settings.data.exportDescription`)}),(0,I.jsx)(A,{onClick:s,variant:`outline`,size:`sm`,className:`w-full`,children:m(`settings.data.exportAll`)})]}),(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.data.import`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:m(`settings.data.importDescription`)}),(0,I.jsx)(`input`,{ref:o,type:`file`,accept:`.json`,onChange:c,className:`hidden`}),(0,I.jsx)(A,{onClick:()=>o.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:m(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.data.clearSessions`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:m(`settings.data.clearSessionsDescription`)}),(0,I.jsx)(A,{onClick:l,variant:`outline`,size:`sm`,className:`w-full text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border-red-200 hover:border-red-300 dark:border-red-800 dark:hover:border-red-700`,disabled:e===0||t,children:t?m(`settings.data.clearing`):m(`settings.data.clearAll`,{count:e})})]})]}),r&&(0,I.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,I.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:m(`settings.data.importOptions`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:m(`settings.data.importOptionsDescription`)}),(0,I.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,I.jsxs)(`label`,{className:`flex items-center`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:i===`skip`,onChange:e=>u(e.target.value),className:`mr-2`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:m(`settings.data.skipDuplicates`)})]}),(0,I.jsxs)(`label`,{className:`flex items-center`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:i===`overwrite`,onChange:e=>u(e.target.value),className:`mr-2`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:m(`settings.data.overwrite`)})]})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(A,{onClick:d,size:`sm`,disabled:n,children:m(n?`settings.data.importing`:`settings.data.import`)}),(0,I.jsx)(A,{onClick:f,variant:`outline`,size:`sm`,children:m(`common.cancel`)})]})]}),a&&(0,I.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,I.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:m(`settings.data.importResults`)}),(0,I.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,I.jsxs)(`div`,{children:[m(`settings.data.preferences`),`:`,` `,a.preferences.imported?m(`settings.data.imported`):m(`settings.data.failed`)]}),(0,I.jsxs)(`div`,{children:[m(`settings.data.sessions`),`:`,` `,a.sessions.imported,` `,m(`settings.data.importedLabel`),`,`,a.sessions.skipped,` `,m(`settings.data.skipped`)]}),(0,I.jsxs)(`div`,{children:[m(`settings.data.documents`),`:`,` `,a.documents.imported,` `,m(`settings.data.importedLabel`),`,`,` `,a.documents.skipped,` `,m(`settings.data.skipped`)]}),(a.sessions.errors.length>0||a.documents.errors.length>0)&&(0,I.jsxs)(`div`,{className:`mt-2`,children:[(0,I.jsxs)(`p`,{className:`font-medium`,children:[m(`settings.data.errors`),`:`]}),a.sessions.errors.map((e,t)=>(0,I.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`session-${t}`)),a.documents.errors.map((e,t)=>(0,I.jsxs)(`p`,{className:`text-red-600 dark:text-red-400`,children:[`• `,e]},`document-${t}`))]})]}),(0,I.jsx)(A,{onClick:p,variant:`outline`,size:`sm`,className:`mt-2`,children:m(`common.close`)})]})]})]})})}function R({checked:e,onChange:t,disabled:n=!1}){return(0,I.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),disabled:n,className:`sr-only`}),(0,I.jsx)(`div`,{className:k(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2`,n?`bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed`:e?`bg-primary-600 dark:bg-primary-500`:`bg-gray-200 dark:bg-dark-300`),children:(0,I.jsx)(`span`,{className:k(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,e?`translate-x-6`:`translate-x-1`)})})]})}function Pe({settings:e,effectiveSettings:t,modelOptions:n,status:r,regenerating:i,onSettingChange:a,onReset:o,onRegenerate:s,onSave:c}){let{t:l}=M();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:l(`settings.documents.title`)}),(0,I.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 p-4 rounded-lg border border-gray-200 dark:border-dark-300 space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:l(`settings.documents.embeddings.title`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:l(`settings.documents.embeddings.enable`)})]}),(0,I.jsx)(R,{checked:e.enabled,onChange:e=>a(`enabled`,e)})]}),e.enabled&&(0,I.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:l(`settings.documents.embeddings.model`)}),(0,I.jsx)(j,{value:t.model,onChange:e=>a(`model`,e.target.value),options:n}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:l(`settings.documents.embeddings.modelDescription`)})]}),(0,I.jsx)(Fe,{label:l(`settings.documents.embeddings.chunkSize`),value:e.chunkSize,min:500,max:2e3,step:100,description:l(`settings.documents.embeddings.chunkSizeDescription`),onChange:e=>a(`chunkSize`,e)}),(0,I.jsx)(Fe,{label:l(`settings.documents.embeddings.chunkOverlap`),value:e.chunkOverlap,min:50,max:500,step:50,description:l(`settings.documents.embeddings.chunkOverlapDescription`),onChange:e=>a(`chunkOverlap`,e)}),(0,I.jsx)(Fe,{label:l(`settings.documents.embeddings.similarityThreshold`),value:e.similarityThreshold,min:.3,max:.9,step:.05,description:l(`settings.documents.embeddings.similarityDescription`),format:e=>e.toFixed(2),onChange:e=>a(`similarityThreshold`,e)})]})]}),r&&(0,I.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:l(`settings.documents.embeddings.status`)}),(0,I.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,I.jsxs)(`div`,{children:[l(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,I.jsx)(`span`,{className:r.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:r.available?l(`settings.documents.embeddings.available`):l(`settings.documents.embeddings.unavailable`)})]}),(0,I.jsxs)(`div`,{children:[l(`settings.documents.embeddings.model`),`:`,` `,(0,I.jsx)(`span`,{className:`font-medium`,children:r.model})]}),(0,I.jsxs)(`div`,{children:[l(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,I.jsxs)(`span`,{className:`font-medium`,children:[r.chunksWithEmbeddings,` / `,r.totalChunks]})]}),r.totalChunks>0&&(0,I.jsxs)(`div`,{children:[l(`settings.documents.embeddings.coverage`),`:`,` `,(0,I.jsxs)(`span`,{className:`font-medium`,children:[Math.round(r.chunksWithEmbeddings/r.totalChunks*100),`%`]})]})]})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(A,{onClick:o,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),l(`settings.generation.resetDefaults`)]}),e.enabled&&r&&r.totalChunks>0&&(0,I.jsxs)(A,{onClick:s,disabled:i,variant:`outline`,className:`flex items-center gap-2 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20`,children:[(0,I.jsx)(C,{size:16}),l(i?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,I.jsxs)(A,{onClick:c,className:`flex items-center gap-2`,children:[(0,I.jsx)(E,{size:16}),l(`settings.saveSettings`)]})]})]})})}function Fe({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,I.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full range-slider`}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function Ie({generationOptions:e,embeddingSettings:t,effectiveEmbeddingSettings:n,embeddingModelOptions:r,embeddingStatus:i,onGenerationOptionChange:a,onEmbeddingSettingsChange:o,onResetGenerationOptions:s,onSaveGenerationOptions:c,onResetEmbeddingSettings:l,onSaveEmbeddingSettings:u}){let{t:d}=M();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:d(`settings.generation.title`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:d(`settings.generation.description`)}),(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(z,{title:d(`settings.generation.coreParameters`),children:[(0,I.jsx)(B,{label:d(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:d(`settings.generation.temperatureDescription`),onChange:e=>a(`temperature`,e)}),(0,I.jsx)(B,{label:d(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:d(`settings.generation.topPDescription`),onChange:e=>a(`top_p`,e)}),(0,I.jsx)(B,{label:d(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:d(`settings.generation.topKDescription`),onChange:e=>a(`top_k`,e)}),(0,I.jsx)(B,{label:d(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:d(`settings.generation.minPDescription`),onChange:e=>a(`min_p`,e)})]}),(0,I.jsxs)(z,{title:d(`settings.generation.generationControl`),children:[(0,I.jsx)(B,{label:d(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:d(`settings.generation.maxTokensDescription`),onChange:e=>a(`num_predict`,e)}),(0,I.jsx)(B,{label:d(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:d(`settings.generation.repeatPenaltyDescription`),onChange:e=>a(`repeat_penalty`,e)}),(0,I.jsx)(B,{label:d(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:d(`settings.generation.contextLengthDescription`),onChange:e=>a(`num_ctx`,e)}),(0,I.jsx)(B,{label:d(`settings.generation.seed`),hint:`(${d(`settings.generation.optional`)})`,value:e.seed,placeholder:d(`settings.generation.random`),integer:!0,description:d(`settings.generation.seedDescription`),onChange:e=>a(`seed`,e)})]}),(0,I.jsxs)(z,{title:d(`settings.generation.advancedOptions`),children:[(0,I.jsx)(B,{label:d(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:d(`settings.generation.presencePenaltyDescription`),onChange:e=>a(`presence_penalty`,e)}),(0,I.jsx)(B,{label:d(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:d(`settings.generation.frequencyPenaltyDescription`),onChange:e=>a(`frequency_penalty`,e)}),(0,I.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[d(`settings.generation.stopSequences`),(0,I.jsxs)(`span`,{className:`text-xs text-gray-500 ml-1`,children:[`(`,d(`settings.generation.commaSeparated`),`)`]})]}),(0,I.jsx)(`input`,{type:`text`,value:e.stop?.join(`, `)??``,onChange:e=>a(`stop`,e.target.value?e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,placeholder:`\\\\n, ###, STOP`}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:d(`settings.generation.stopSequencesDescription`)})]})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(A,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),d(`settings.generation.resetDefaults`)]}),(0,I.jsxs)(A,{onClick:c,className:`flex items-center gap-2`,children:[(0,I.jsx)(E,{size:16}),d(`settings.generation.saveOptions`)]})]})]}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:d(`settings.generation.embeddingSettings`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:d(`settings.generation.enableEmbeddings`)}),(0,I.jsx)(R,{checked:t.enabled,onChange:e=>o(`enabled`,e)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:d(`settings.documents.embeddings.model`)}),(0,I.jsx)(j,{value:n.model,onChange:e=>o(`model`,e.target.value),options:r,disabled:!t.enabled})]}),(0,I.jsx)(V,{label:d(`settings.documents.embeddings.chunkSize`),hint:d(`settings.documents.embeddings.chunkSizeInTokens`),value:t.chunkSize,min:1,disabled:!t.enabled,onChange:e=>o(`chunkSize`,e)}),(0,I.jsx)(V,{label:d(`settings.documents.embeddings.chunkOverlap`),hint:d(`settings.documents.embeddings.chunkOverlapInTokens`),value:t.chunkOverlap,min:0,disabled:!t.enabled,onChange:e=>o(`chunkOverlap`,e)}),(0,I.jsx)(V,{label:d(`settings.documents.embeddings.similarityThreshold`),value:t.similarityThreshold,min:0,max:1,step:.01,disabled:!t.enabled,onChange:e=>o(`similarityThreshold`,e)})]}),i&&(0,I.jsxs)(`div`,{className:`mt-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,I.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[d(`settings.documents.embeddings.status`),`:`]}),(0,I.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:i.available?d(`settings.documents.embeddings.available`):d(`settings.documents.embeddings.unavailable`)})]}),i.available&&(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,I.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[d(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,I.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[i.chunksWithEmbeddings,` /`,` `,i.totalChunks]})]})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,I.jsxs)(A,{onClick:l,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),d(`settings.generation.resetDefaults`)]}),(0,I.jsxs)(A,{onClick:u,className:`flex items-center gap-2`,children:[(0,I.jsx)(E,{size:16}),d(`settings.saveSettings`)]})]})]})})]})})}function z({title:e,children:t}){return(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,I.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function B({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,I.jsx)(`span`,{className:`text-xs text-gray-500 ml-1`,children:i})]}),(0,I.jsx)(`input`,{type:`number`,min:a,max:o,step:s,value:t??``,placeholder:n,onChange:e=>l(e.target.value?c?parseInt(e.target.value):parseFloat(e.target.value):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function V({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,I.jsx)(`span`,{className:`text-xs text-gray-500 ml-1`,children:a})]}),(0,I.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,disabled:o})]})}function Le({loading:e,settings:t,effectiveSettings:n,models:r,plugins:i,sizes:a,qualities:o,styles:s,onSettingChange:c,onModelChange:l,onReset:d,onSave:f}){let{t:p}=M();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.title`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.imageGen.description`)}),e?(0,I.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,I.jsx)(u,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,I.jsx)(`span`,{className:`ml-3 text-gray-600 dark:text-gray-400`,children:p(`settings.imageGen.loadingProviders`)})]}):r.length===0?(0,I.jsx)(`div`,{className:`bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(m,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-200`,children:p(`settings.imageGen.noProviders`)}),(0,I.jsx)(`p`,{className:`text-sm text-yellow-700 dark:text-yellow-300 mt-1`,children:p(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.imageGen.enable`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.imageGen.enableDescription`)})]}),(0,I.jsx)(R,{checked:t.enabled,onChange:e=>c(`enabled`,e)})]})}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.configuration`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.model`)}),(0,I.jsx)(j,{value:n.model,onChange:e=>l(e.target.value),disabled:!t.enabled,options:[{value:``,label:p(`settings.model.selectModel`)},...r.map(e=>({value:e.model,label:`${e.model} (${e.plugin})`}))]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.modelDescription`)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.size`)}),(0,I.jsx)(j,{value:n.size,onChange:e=>c(`size`,e.target.value),disabled:!t.enabled||a.length===0,options:[...a.length>0?a.map(e=>({value:e,label:e})):[{value:`1024x1024`,label:`1024x1024`},{value:`1792x1024`,label:`1792x1024`},{value:`1024x1792`,label:`1024x1792`}]]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.sizeDescription`)})]}),o.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.quality`)}),(0,I.jsx)(j,{value:n.quality,onChange:e=>c(`quality`,e.target.value),disabled:!t.enabled,options:o.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.qualityDescription`)})]}),s.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.style`)}),(0,I.jsx)(j,{value:n.style,onChange:e=>c(`style`,e.target.value),disabled:!t.enabled,options:s.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.styleDescription`)})]})]})]}),i.length>0&&(0,I.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.imageGen.availableProviders`)}),(0,I.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:i.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,I.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,p(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(A,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),p(`common.reset`)]}),(0,I.jsxs)(A,{onClick:f,className:`flex items-center gap-2`,children:[(0,I.jsx)(E,{size:16}),p(`settings.saveSettings`)]})]})]})]})})}function Re({models:e,selectedModel:t,systemMessage:n,tempSystemMessage:r,loading:i,user:a,systemInfo:o,preferences:s,currentTaskModel:c,autoTitleTaskModelOptions:l,updatingModelPullAccess:u,updatingAllModels:d,updateProgress:f,onModelPullAccessToggle:p,onModelChange:m,onSystemMessageChange:h,onSystemMessageSave:g,onAutoTitleChange:_,onAutoTitleTaskModelChange:v,onUpdateAllModels:y}){let{t:b}=M(),x=e.find(e=>e.name===t);return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:b(`settings.model.title`)}),(0,I.jsxs)(`div`,{className:`space-y-6`,children:[a?.role===`admin`&&(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col pr-4`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:b(`settings.model.modelPullAccess`)}),(0,I.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:b(`settings.model.modelPullAccessDescription`)})]}),(0,I.jsx)(R,{checked:o?.allowUserModelPull??!0,onChange:p,disabled:u})]})}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:b(`settings.model.defaultModel`)}),(0,I.jsx)(j,{value:t||``,onChange:m,options:[{value:``,label:b(`settings.model.selectModel`)},...e.map(e=>({value:e.name,label:e.isPersona?`${e.personaName} (${b(`settings.model.persona`)})`:e.name}))]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:b(`settings.model.defaultModelDescription`)})]}),t&&(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:b(`settings.model.currentModelInfo`)}),(0,I.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,I.jsx)(H,{label:`${b(`settings.model.name`)}:`,value:t,truncate:!0}),x?.details&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(H,{label:`${b(`settings.model.size`)}:`,value:x.details.parameter_size}),(0,I.jsx)(H,{label:`${b(`settings.model.family`)}:`,value:x.details.family}),(0,I.jsx)(H,{label:`${b(`settings.model.format`)}:`,value:x.details.format})]})]})})]}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:b(`settings.systemMessage.title`)}),(0,I.jsx)(we,{value:r,onChange:h,placeholder:b(`settings.systemMessage.placeholder`),className:`w-full min-h-[100px] bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,rows:4}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:b(`settings.systemMessage.description`)}),(0,I.jsx)(A,{onClick:g,size:`sm`,disabled:i||r===n,children:b(`common.save`)})]})]})]}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:b(`settings.model.autoTitle.title`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:b(`settings.model.autoTitle.enable`)}),(0,I.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:b(`settings.model.autoTitle.enableDescription`)})]}),(0,I.jsx)(R,{checked:s.titleSettings?.autoTitle||!1,onChange:_})]}),s.titleSettings?.autoTitle&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:b(`settings.model.autoTitle.taskModel`)}),(0,I.jsx)(j,{value:c,onChange:e=>v(e.target.value),options:l}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:b(`settings.model.autoTitle.taskModelDescription`)})]})]})]})}),(0,I.jsx)(`div`,{className:`mt-6`,children:(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:b(`settings.model.bulkOperations`)}),(0,I.jsx)(`div`,{className:`space-y-3`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:b(`settings.model.updateAll`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:b(`settings.model.updateAllDescription`)}),d&&f&&(0,I.jsx)(ze,{progress:f}),(0,I.jsx)(A,{onClick:y,variant:`outline`,size:`sm`,className:`w-full`,disabled:d||i||e.length===0,children:d?b(`settings.model.updating`):b(`settings.model.updateAllButton`,{count:e.length})})]})})]})})]})})}function H({label:e,value:t,truncate:n=!1}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-white dark:bg-dark-100 rounded-md border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,I.jsx)(`span`,{className:n?`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ml-2`:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t})]})}function ze({progress:e}){let{t}=M(),n=Math.round(e.current/e.total*100);return(0,I.jsxs)(`div`,{className:`mb-4 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,I.jsx)(`span`,{className:`text-gray-600 dark:text-dark-600 font-medium`,children:t(`settings.model.updatingModel`,{name:e.modelName,current:e.current,total:e.total})}),(0,I.jsxs)(`span`,{className:`text-primary-600 dark:text-primary-400 font-semibold`,children:[n,`%`]})]}),(0,I.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-3 shadow-subtle`,children:(0,I.jsx)(`div`,{className:`bg-gradient-to-r from-primary-500 to-primary-600 dark:from-primary-400 dark:to-primary-500 h-3 rounded-full transition-all duration-500 ease-out shadow-glow`,style:{width:`${e.current/e.total*100}%`}})}),(0,I.jsxs)(`div`,{className:`text-xs flex items-center justify-between`,children:[(0,I.jsxs)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:[t(`settings.model.status`),`:`,` `,e.status===`starting`?(0,I.jsx)(`span`,{className:`text-accent-500 dark:text-accent-400`,children:t(`settings.model.statusStarting`)}):e.status===`success`?(0,I.jsx)(`span`,{className:`text-success-600 dark:text-success-500`,children:t(`settings.model.statusComplete`)}):e.status===`error`?(0,I.jsxs)(`span`,{className:`text-error-600 dark:text-error-500`,children:[t(`settings.model.statusError`),`: `,e.error]}):``]}),(0,I.jsx)(`span`,{className:`text-gray-400 dark:text-dark-600 text-[10px]`,children:t(`settings.model.modelsProgress`,{current:e.current,total:e.total})})]})]})}i(`components:hugging-face-model-browser`);var Be=({plugin:e})=>{let{t}=M(),{pluginVariables:n,fetchPluginVariables:r,updatePluginVariables:i,resetPluginVariables:o}=Te(),[s,c]=(0,F.useState)({}),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(new Set),[h,_]=(0,F.useState)({}),v=(0,F.useMemo)(()=>e.variables||[],[e.variables]),y=(0,F.useMemo)(()=>n[e.id]||{},[n,e.id]);(0,F.useEffect)(()=>{r(e.id)},[r,e.id]);let b=JSON.stringify(y),[x,ee]=(0,F.useState)(null);if(x!==b){let e=JSON.parse(b);if(!(Object.keys(e).length===0&&d)){let t={};for(let n of v){let r=e[n.name];r?.has_value&&!r.is_sensitive?t[n.name]=r.value:t[n.name]=n.default??(n.type===`boolean`?!1:n.type===`number`?0:``)}c(t),f(!0)}ee(b)}let C=async()=>{let n={};for(let e of v){let r=s[e.name];if(e.name===`endpoint`&&typeof r==`string`&&r.length>0)try{new URL(r)}catch{n[e.name]=t(`pluginManager.variables.invalidUrl`,`Must be a valid URL`)}if(e.type===`number`){let t=Number(r);e.min!==void 0&&t<e.min&&(n[e.name]=`Min: ${e.min}`),e.max!==void 0&&t>e.max&&(n[e.name]=`Max: ${e.max}`)}e.type===`string`&&typeof r==`string`&&r.length>2048&&(n[e.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(_(n),Object.keys(n).length>0)return;u(!0);let r=await i(e.id,s);u(!1),r?g.success(t(`pluginManager.variables.saved`,`Variables saved`)):g.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))},te=async()=>{await o(e.id);let n={};for(let e of v)n[e.name]=e.default??(e.type===`boolean`?!1:e.type===`number`?0:``);c(n),g.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))},ne=e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ie=e=>{let n=s[e.name],r=e.sensitive??!1,i=p.has(e.name),a=y[e.name],o=k(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-white dark:bg-dark-100`,`border-gray-300 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-blue-500/20`);switch(e.type){case`boolean`:return(0,I.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:!!(n??!1),onChange:t=>c(n=>({...n,[e.name]:t.target.checked})),className:`rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.label})]});case`select`:return(0,I.jsx)(`select`,{value:String(n??``),onChange:t=>c(n=>({...n,[e.name]:t.target.value})),className:o,children:(e.options||[]).map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))});case`number`:return(0,I.jsx)(`input`,{type:`number`,value:n??0,min:e.min,max:e.max,onChange:t=>c(n=>({...n,[e.name]:t.target.value===``?0:Number(t.target.value)})),className:o});default:return(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`input`,{type:r&&!i?`password`:`text`,value:r&&a?.has_value&&n===``?``:String(n??``),placeholder:r&&a?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):void 0,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),className:k(o,r&&`pr-10`)}),r&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>ne(e.name),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,children:i?(0,I.jsx)(S,{className:`w-4 h-4`}):(0,I.jsx)(re,{className:`w-4 h-4`})})]})}};return(0,I.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[(0,I.jsx)(`div`,{className:`space-y-3`,children:v.map(e=>(0,I.jsxs)(`div`,{children:[e.type!==`boolean`&&(0,I.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[e.label,e.required&&(0,I.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&e.type!==`boolean`&&(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:e.description}),ie(e),h[e.name]&&(0,I.jsx)(`p`,{className:`text-xs text-red-500 mt-1`,children:h[e.name]})]},e.name))}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,I.jsxs)(A,{size:`sm`,onClick:C,disabled:l,className:`gap-1.5`,children:[(0,I.jsx)(a,{className:`w-3.5 h-3.5`}),l?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,I.jsxs)(A,{variant:`outline`,size:`sm`,onClick:te,className:`gap-1.5`,children:[(0,I.jsx)(D,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function Ve({plugins:e,loading:t,uploading:n,error:r,hasKeys:i,showUploadForm:a,showJsonForm:o,jsonInput:c,fileInputRef:l,expandedPluginId:u,pluginApiKeys:d,showApiKey:f,savingApiKey:p,onClearError:m,onShowUploadFormChange:h,onShowJsonFormChange:g,onJsonInputChange:_,onFileUpload:v,onJsonSubmit:y,onExpandedPluginChange:b,onPluginApiKeyChange:x,onShowApiKeyChange:S,onActivatePlugin:C,onDeletePlugin:te,onExportPlugin:ne,onSaveApiKey:re,onDeleteApiKey:ie}){let{t:w}=M(),T=e.filter(e=>e.active);return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:w(`settings.plugins.title`)}),r&&(0,I.jsx)(`div`,{className:`p-4 bg-primary-50/80 dark:bg-primary-950/25 border border-primary-200 dark:border-primary-800/50 rounded-lg mb-4`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:r}),(0,I.jsx)(A,{variant:`ghost`,size:`sm`,onClick:m,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,I.jsx)(ae,{className:`h-4 w-4`})})]})}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:w(`settings.plugins.addNew`)}),(0,I.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,I.jsxs)(A,{variant:`outline`,size:`sm`,onClick:()=>h(!a),disabled:t||n,children:[(0,I.jsx)(ee,{className:`h-4 w-4 mr-2`}),w(`settings.plugins.upload`)]}),(0,I.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>g(!o),disabled:t,children:w(`settings.plugins.addJson`)})]})]}),a&&(0,I.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,I.jsx)(`input`,{ref:l,type:`file`,accept:`.json,.zip`,onChange:v,className:`flex-1 p-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 dark:file:bg-dark-200 dark:file:text-dark-700 hover:file:bg-gray-200 dark:hover:file:bg-dark-300`,disabled:n}),(0,I.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>h(!1),disabled:n,children:w(`common.cancel`)})]}),n&&(0,I.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:w(`settings.plugins.uploading`)})]}),o&&(0,I.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`textarea`,{value:c,onChange:e=>_(e.target.value),placeholder:w(`settings.plugins.jsonPlaceholder`),className:`w-full h-32 p-3 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500 font-mono text-sm`,disabled:t}),(0,I.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,I.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>{g(!1),_(``)},children:w(`common.cancel`)}),(0,I.jsx)(A,{size:`sm`,onClick:y,disabled:!c.trim()||t,children:w(`settings.plugins.install`)})]})]})})]}),T.length>0&&(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,I.jsxs)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:[w(`settings.plugins.active`),` (`,T.length,`)`]}),(0,I.jsx)(`div`,{className:`space-y-2`,children:T.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`font-medium text-green-800 dark:text-green-200`,children:e.name}),(0,I.jsxs)(`p`,{className:`text-xs text-green-600 dark:text-green-300`,children:[e.type,` • `,e.model_map?.length||0,` `,w(`settings.plugins.models`)]})]}),(0,I.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>C(e.id),className:`text-green-600 border-green-300 hover:bg-green-100`,children:w(`settings.plugins.deactivate`)})]},e.id))})]}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`div`,{className:`p-4 border-b border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[w(`settings.plugins.installed`),` (`,e.length,`)`]})}),t?(0,I.jsx)(`div`,{className:`p-8 text-center`,children:(0,I.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:w(`settings.plugins.loading`)})}):e.length===0?(0,I.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,I.jsx)(s,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,I.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:w(`settings.plugins.noPlugins`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:w(`settings.plugins.noPluginsDescription`)})]}):(0,I.jsx)(`div`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,I.jsx)(He,{plugin:e,loading:t,hasApiKey:i[e.id]||!1,expanded:u===e.id,apiKey:d[e.id]||``,showApiKey:f[e.id]||!1,savingApiKey:p===e.id,onExpand:()=>b(u===e.id?null:e.id),onActivate:()=>C(e.id),onExport:()=>ne(e.id),onDelete:()=>te(e.id),onApiKeyChange:t=>x(e.id,t),onShowApiKeyChange:t=>S(e.id,t),onSaveApiKey:()=>re(e.id),onDeleteApiKey:()=>ie(e.id)},e.id))})]})]})})}function He({plugin:e,loading:t,hasApiKey:n,expanded:r,apiKey:i,showApiKey:a,savingApiKey:o,onExpand:s,onActivate:c,onExport:l,onDelete:u,onApiKeyChange:d,onShowApiKeyChange:f,onSaveApiKey:p,onDeleteApiKey:m}){let{t:g}=M();return(0,I.jsxs)(`div`,{className:`p-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,I.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,I.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,I.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0 ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h5`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,I.jsxs)(`div`,{className:`flex items-center space-x-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,I.jsx)(`span`,{children:e.type}),(0,I.jsx)(`span`,{children:`•`}),(0,I.jsxs)(`span`,{children:[e.model_map?.length||0,` `,g(`settings.plugins.models`)]}),e.endpoint&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{children:`•`}),(0,I.jsx)(`span`,{className:`truncate max-w-32`,children:e.endpoint})]}),n&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{children:`•`}),(0,I.jsx)(`span`,{className:`text-green-600`,children:g(`settings.plugins.apiKeySet`)})]})]})]})]})}),(0,I.jsxs)(`div`,{className:`flex items-center space-x-1 flex-shrink-0`,children:[(0,I.jsxs)(A,{variant:`ghost`,size:`sm`,onClick:s,title:`Configure API key`,className:n?`text-green-600`:`text-amber-600`,children:[(0,I.jsx)(h,{className:`h-4 w-4`}),r?(0,I.jsx)(ne,{className:`h-3 w-3`}):(0,I.jsx)(b,{className:`h-3 w-3`})]}),(0,I.jsx)(A,{variant:`outline`,size:`sm`,onClick:c,disabled:t,className:e.active?`text-green-600 border-green-300`:``,children:e.active?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(E,{className:`h-4 w-4 mr-1`}),g(`settings.plugins.activeLabel`)]}):g(`settings.plugins.activate`)}),(0,I.jsx)(A,{variant:`ghost`,size:`sm`,onClick:l,disabled:t,title:`Export plugin`,children:(0,I.jsx)(se,{className:`h-4 w-4`})}),(0,I.jsx)(A,{variant:`ghost`,size:`sm`,onClick:u,disabled:t,className:`text-red-600 hover:text-red-700 hover:bg-red-50`,title:`Delete plugin`,children:(0,I.jsx)(ce,{className:`h-4 w-4`})})]})]}),r&&(0,I.jsx)(Ue,{plugin:e,hasApiKey:n,apiKey:i,showApiKey:a,savingApiKey:o,onApiKeyChange:d,onShowApiKeyChange:f,onSaveApiKey:p,onDeleteApiKey:m}),e.variables&&e.variables.length>0&&(0,I.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,I.jsx)(w,{className:`h-4 w-4 text-gray-500`}),(0,I.jsxs)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[g(`settings.plugins.variables`,`Variables`),` (`,e.variables.length,`)`]})]}),(0,I.jsx)(Be,{plugin:e})]})]})}function Ue({plugin:e,hasApiKey:t,apiKey:n,showApiKey:r,savingApiKey:i,onApiKeyChange:a,onShowApiKeyChange:o,onSaveApiKey:s,onDeleteApiKey:c}){let{t:l}=M();return(0,I.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,I.jsx)(h,{className:`h-4 w-4 text-gray-500`}),(0,I.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:l(`settings.plugins.apiKeyConfiguration`)})]}),(0,I.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[l(`settings.plugins.apiKeyDescription`,{name:e.name}),e.auth?.key_env&&(0,I.jsxs)(`span`,{className:`block mt-1`,children:[l(`settings.plugins.apiKeyEnvAlternative`),` `,(0,I.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,l(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,I.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(E,{className:`h-4 w-4 text-green-600`}),(0,I.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:l(`settings.plugins.apiKeyConfigured`)})]}),(0,I.jsx)(A,{variant:`outline`,size:`sm`,onClick:c,disabled:i,className:`text-red-600 border-red-300 hover:bg-red-50`,children:i?(0,I.jsx)(u,{className:`h-4 w-4 animate-spin`}):l(`common.remove`)})]}):(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`input`,{type:r?`text`:`password`,value:n,onChange:e=>a(e.target.value),placeholder:l(`settings.plugins.apiKeyPlaceholder`),className:`w-full p-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>o(!r),className:`absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600`,children:r?(0,I.jsx)(S,{className:`h-4 w-4`}):(0,I.jsx)(re,{className:`h-4 w-4`})})]}),(0,I.jsx)(`div`,{className:`flex justify-end`,children:(0,I.jsx)(A,{size:`sm`,onClick:s,disabled:i||!n.trim(),children:i?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u,{className:`h-4 w-4 mr-2 animate-spin`}),l(`common.saving`)]}):l(`settings.plugins.saveApiKey`)})})]})]})}function We({loading:e,settings:t,effectiveSettings:n,models:r,plugins:i,voices:a,testing:o,onSettingChange:s,onModelChange:c,onReset:l,onTest:f,onSave:p}){let{t:m}=M();return(0,I.jsx)(`div`,{className:`space-y-6`,children:(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.tts.title`)}),(0,I.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:m(`settings.tts.description`)}),e?(0,I.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,I.jsx)(u,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,I.jsx)(`span`,{className:`ml-3 text-gray-600 dark:text-gray-400`,children:m(`settings.tts.loadingProviders`)})]}):r.length===0?(0,I.jsx)(`div`,{className:`bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(x,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-200`,children:m(`settings.tts.noProviders`)}),(0,I.jsx)(`p`,{className:`text-sm text-yellow-700 dark:text-yellow-300 mt-1`,children:m(`settings.tts.noProvidersDescription`)})]})]})}):(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.enable`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.enableDescription`)})]}),(0,I.jsx)(R,{checked:t.enabled,onChange:e=>s(`enabled`,e)})]})}),(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.autoPlay`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.autoPlayDescription`)})]}),(0,I.jsx)(R,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>s(`autoPlay`,e)})]})}),(0,I.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:m(`settings.tts.streamSentences`)}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:m(`settings.tts.streamSentencesDescription`)})]}),(0,I.jsx)(R,{checked:t.streamSentences||!1,disabled:!t.enabled,onChange:e=>s(`streamSentences`,e)})]})}),(0,I.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:m(`settings.tts.voiceConfiguration`)}),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.tts.model`)}),(0,I.jsx)(j,{value:n.model,onChange:e=>c(e.target.value),disabled:!t.enabled,options:[{value:``,label:m(`settings.model.selectModel`)},...r.map(e=>({value:e.model,label:`${e.model} (${e.plugin})`}))]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.tts.modelDescription`)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m(`settings.tts.voice`)}),(0,I.jsx)(j,{value:n.voice,onChange:e=>s(`voice`,e.target.value),disabled:!t.enabled||a.length===0,options:[{value:``,label:m(`settings.tts.selectVoice`)},...a.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))]}),(0,I.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:m(`settings.tts.voiceDescription`)})]})]})]}),i.length>0&&(0,I.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:m(`settings.tts.availableProviders`)}),(0,I.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:i.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,I.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,I.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,I.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,m(`settings.tts.models`),`)`]})]},e.id))})]}),(0,I.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsxs)(A,{onClick:l,variant:`outline`,className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{size:16}),m(`common.reset`)]}),(0,I.jsx)(A,{onClick:f,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(te,{size:16}),m(`settings.tts.stop`)]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(d,{size:16}),m(`settings.tts.test`)]})})]}),(0,I.jsxs)(A,{onClick:p,className:`flex items-center gap-2`,children:[(0,I.jsx)(E,{size:16}),m(`settings.saveSettings`)]})]})]})]})})}function Ge({preferences:e,sessions:t,loadPreferences:n,loadSessions:r}){let[i,a]=(0,F.useState)(!1),[o,s]=(0,F.useState)(!1),[c,l]=(0,F.useState)(`skip`),[u,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(null),m=(0,F.useRef)(null),h=()=>{p(null),m.current&&(m.current.value=``)};return{importing:i,showImportOptions:o,mergeStrategy:c,setMergeStrategy:l,importResult:u,setImportResult:d,importFileInputRef:m,handleExportData:()=>{let n={format:`libre-webui-export`,version:`1.0`,preferences:e,sessions:t,documents:[],exportedAt:new Date().toISOString()},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`libre-webui-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),g.success(`Data exported successfully`)},handleImportFileSelect:e=>{let t=e.target.files?.[0];t&&(p(t),s(!0),d(null))},handleConfirmImport:async()=>{if(f){a(!0);try{let e=await f.text(),t=JSON.parse(e);if(!t.format||t.format!==`libre-webui-export`)throw Error(`Invalid export format. Please use a valid Libre WebUI export file.`);let i=await O.importData(t,c===`overwrite`?`replace`:`merge`);if(i.success&&i.data)d({preferences:{imported:!0,error:null},sessions:{imported:0,skipped:0,errors:[]},documents:{imported:0,skipped:0,errors:[]}}),g.success(`Data imported successfully`),await n(),await r();else throw Error(i.error||`Import failed`)}catch(e){g.error(e instanceof Error?e.message:`Import failed`),d(null)}finally{a(!1),s(!1),h()}}},handleCancelImport:()=>{s(!1),d(null),h()}}}var Ke=`0.12.0`,qe=`__current_running_model__`,Je={enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},Ye={enabled:!1,autoPlay:!1,model:``,voice:``,speed:1,pluginId:``,streamSentences:!1},Xe={enabled:!1,model:``,size:`1024x1024`,quality:`standard`,style:`vivid`,pluginId:``},Ze=({isOpen:e,onClose:t})=>{let{models:n,selectedModel:i,setSelectedModel:a,systemMessage:o,setSystemMessage:l,clearAllSessions:u,loading:d,sessions:f,loadModels:h,loadSessions:_}=xe(),{theme:v,setTheme:y,preferences:b,setPreferences:S,loadPreferences:ee}=P(),{user:te,systemInfo:ne,setSystemInfo:re}=Ce(),{plugins:T,isLoading:oe,isUploading:se,error:ce,loadPlugins:E,uploadPlugin:D,deletePlugin:k,activatePlugin:ge,deactivatePlugin:_e,exportPlugin:ve,clearError:be,installPlugin:Se}=Te(),{t:j}=M(),N=b.titleSettings?.taskModel||``,we=[{value:``,label:j(`settings.model.autoTitle.selectTaskModel`)},{value:qe,label:`Use current running model`},...n.map(e=>({value:e.name,label:e.name})),...![``,qe,...n.map(e=>e.name)].includes(N)&&N?[{value:N,label:`${N} (current)`}]:[]],[De,Oe]=(0,F.useState)(`appearance`),[L,Ae]=(0,F.useState)(o),[je,R]=(0,F.useState)(!1),[Fe,z]=(0,F.useState)(!1),[B,V]=(0,F.useState)(null),[H,ze]=(0,F.useState)(!1),[Be,He]=(0,F.useState)(!1),[Ue,Ze]=(0,F.useState)(``),Qe=(0,F.useRef)(null),[$e,et]=(0,F.useState)(null),[tt,nt]=(0,F.useState)({}),[rt,it]=(0,F.useState)({}),[at,ot]=(0,F.useState)(null),[st,ct]=(0,F.useState)(b.generationOptions||{}),[U,lt]=(0,F.useState)(b.embeddingSettings||Je),[ut,dt]=(0,F.useState)(!1),[W,ft]=(0,F.useState)(b.ttsSettings||Ye),[pt,G]=(0,F.useState)(!1),K=(0,F.useRef)(null),[q,mt]=(0,F.useState)(b.imageGenSettings||Xe),{importing:ht,showImportOptions:gt,mergeStrategy:_t,setMergeStrategy:vt,importResult:yt,setImportResult:bt,importFileInputRef:xt,handleExportData:St,handleImportFileSelect:Ct,handleConfirmImport:wt,handleCancelImport:Tt}=Ge({preferences:b,sessions:f,loadPreferences:ee,loadSessions:_}),Et=ye(),{data:Dt={}}=r({queryKey:[`plugin-credentials`],queryFn:async()=>{let e=await fe.getCredentials();if(!e.success||!e.data)return{};let t={};for(let n of e.data)t[n.plugin_id]=n.has_api_key;return t},enabled:e}),{data:Ot=[]}=r({queryKey:[`embedding-models`],queryFn:async()=>{let e=await me.getModels();return e.success&&e.data?e.data:[]},enabled:e}),J=(0,F.useMemo)(()=>{let e=Ot.find(e=>e.id===U.model||e.rawModel===U.model);return e&&e.id!==U.model?{...U,model:e.id}:U},[Ot,U]),{data:kt=null}=r({queryKey:[`embedding-status`],queryFn:async()=>{let e=await ue.getEmbeddingStatus();return e.success&&e.data?e.data:null},enabled:e}),{data:At,isLoading:jt}=r({queryKey:[`tts-data`],queryFn:async()=>{let[e,t]=await Promise.all([pe.getModels(),pe.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Y=(0,F.useMemo)(()=>At?.models??[],[At]),Mt=At?.plugins??[],X=(0,F.useMemo)(()=>{if(W.model||Y.length===0)return W;let e=Y[0];return{...W,model:e.model,pluginId:e.plugin,voice:e.config?.default_voice||``}},[Y,W]),Nt=(0,F.useMemo)(()=>X.model?Y.find(e=>e.model===X.model)?.config?.voices??[]:[],[X.model,Y]),{data:Pt,isLoading:Ft}=r({queryKey:[`image-gen-data`],queryFn:async()=>{let[e,t]=await Promise.all([he.getModels(),he.getPlugins()]);return{models:e.success&&e.data?e.data:[],plugins:t.success&&t.data?t.data:[]}},enabled:e}),Z=(0,F.useMemo)(()=>Pt?.models??[],[Pt]),It=(0,F.useMemo)(()=>Pt?.plugins??[],[Pt]),Q=(0,F.useMemo)(()=>Z.find(e=>e.model===q.model)||Z[0],[Z,q.model]),Lt=(0,F.useMemo)(()=>q.model||!Q?q:{...q,model:Q.model,pluginId:Q.plugin,size:Q.config?.default_size||`1024x1024`,quality:Q.config?.default_quality||`standard`,style:Q.config?.default_style||`vivid`},[q,Q]),Rt=Q?.config?.sizes??[],zt=Q?.config?.qualities??[],Bt=Q?.config?.styles??[],Vt=(0,F.useRef)(!1),Ht=(0,F.useRef)(o);(0,F.useEffect)(()=>{if(!e){Vt.current=!1;return}Vt.current&&Ht.current===o||(Vt.current=!0,Ht.current=o,Ae(o),ct(b.generationOptions||{}),lt(b.embeddingSettings||Je),ft(b.ttsSettings||Ye),mt(b.imageGenSettings||Xe))},[e,b.embeddingSettings,b.generationOptions,b.imageGenSettings,b.ttsSettings,o]);let Ut=(0,F.useRef)(!1);(0,F.useEffect)(()=>{if(!e){Ut.current=!1;return}Ut.current||(Ut.current=!0,E(),h())},[e,E,h]);let Wt=async e=>{let t=tt[e];if(!t?.trim()){g.error(`Please enter an API key`);return}ot(e);try{let n=await fe.setApiKey(e,t.trim());n.success?(g.success(`API key saved successfully`),await Et.invalidateQueries({queryKey:[`plugin-credentials`]}),nt(t=>({...t,[e]:``})),it(t=>({...t,[e]:!1})),et(null)):g.error(n.error||`Failed to save API key`)}catch{g.error(`Failed to save API key`)}finally{ot(null)}},Gt=async e=>{ot(e);try{let t=await fe.deleteApiKey(e);t.success?(g.success(`API key removed`),await Et.invalidateQueries({queryKey:[`plugin-credentials`]}),nt(t=>({...t,[e]:``}))):g.error(t.error||`Failed to remove API key`)}catch{g.error(`Failed to remove API key`)}finally{ot(null)}},Kt=async e=>{let t=Y.find(t=>t.model===e);t&&ft(n=>({...n,model:e,pluginId:t.plugin,voice:t.config?.default_voice||n.voice}))},qt=async e=>{let t=Z.find(t=>t.model===e);t&&mt(n=>({...n,model:e,pluginId:t.plugin,size:t.config?.default_size||n.size,quality:t.config?.default_quality||n.quality,style:t.config?.default_style||n.style}))},Jt=(e,t)=>{ft(n=>({...n,[e]:t}))},Yt=async()=>{try{let e=await O.updatePreferences({ttsSettings:X});e.success&&e.data&&(S(e.data),g.success(`TTS settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to save TTS settings: `+t)}},Xt=async()=>{if(pt){let e=K.current;e&&(e.pause(),e.currentTime=0,K.current=null),G(!1);return}G(!0);try{let e=await pe.generateBase64({model:X.model||`tts-1`,input:`Hello! This is a test of the text-to-speech system.`,voice:X.voice||`alloy`,speed:X.speed||1,response_format:`mp3`});if(e.success&&e.data?.audio){let t=`data:${e.data.mimeType};base64,${e.data.audio}`,n=new Audio(t);K.current=n,n.onended=()=>{G(!1),K.current=null},n.onerror=()=>{g.error(`Failed to play audio`),G(!1),K.current=null},await n.play()}else throw Error(e.message||`Failed to generate speech`)}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`TTS test failed: `+t),G(!1)}},Zt=()=>{ft({enabled:!1,autoPlay:!1,model:Y[0]?.model||``,voice:Y[0]?.config?.default_voice||``,speed:1,pluginId:Y[0]?.plugin||``,streamSentences:!1})},Qt=(e,t)=>{mt(n=>({...n,[e]:t}))},$t=async()=>{try{let e=await O.updatePreferences({imageGenSettings:Lt});e.success&&e.data&&(S(e.data),g.success(`Image generation settings saved successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to save image generation settings: `+t)}},en=()=>{mt({enabled:!1,model:Z[0]?.model||``,size:Z[0]?.config?.default_size||`1024x1024`,quality:Z[0]?.config?.default_quality||`standard`,style:Z[0]?.config?.default_style||`vivid`,pluginId:Z[0]?.plugin||``})},tn=async()=>{try{dt(!0),(await ue.regenerateEmbeddings()).success&&(g.success(`Embeddings regenerated successfully`),await Et.invalidateQueries({queryKey:[`embedding-status`]}))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to regenerate embeddings: `+t)}finally{dt(!1)}},$=async e=>{try{let t=await O.updatePreferences(e);t.success&&t.data&&(S(t.data),g.success(`Settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)}},nn=async e=>{let t=e.target.files?.[0];t&&(await D(t),ze(!1),Qe.current&&(Qe.current.value=``),await h())},rn=async()=>{try{await Se(JSON.parse(Ue)),He(!1),Ze(``),await h()}catch{be(),g.error(`Invalid JSON format`)}},an=async e=>{T.find(t=>t.id===e)?.active?await _e(e):await ge(e),await h()},on=async e=>{window.confirm(`Are you sure you want to delete this plugin?`)&&(await k(e),await h())},sn=async e=>{await ve(e)};if(!e)return null;let cn=e=>{let t=P.getState().theme,n=Ee({...t,mode:e});y(n),$({theme:n})},ln=e=>{let t=P.getState().theme,n=Ee({...t,accent:e});y(n),$({theme:n})},un=e=>{let t=P.getState().theme,n=Ee({...t,accent:`custom`,customAccent:e});y(n),$({theme:n})},dn=e=>{S({showUsername:e}),O.updatePreferences({showUsername:e}).catch(e=>{let t=e instanceof Error?e.message:String(e);g.error(`Failed to update settings: `+t)})},fn=e=>{let t=e.target.value;a(t),$({defaultModel:t}),g.success(`Default model updated`)},pn=e=>{Ae(e.target.value)},mn=()=>{l(L),$({systemMessage:L}),g.success(`System message updated`)},hn=async()=>{window.confirm(`Are you sure you want to delete all chat history? This action cannot be undone.`)&&(await u(),g.success(`All chat sessions deleted`))},gn=async()=>{R(!0),V(null),le.pullAllModelsStream(e=>{V(e)},()=>{R(!1),V(null),g.success(`All models updated successfully!`),h()},e=>{R(!1),V(null),g.error(`Failed to update models: `+e)})},_n=async e=>{z(!0);try{let t=await de.updateModelPullSetting(e);if(t.success&&t.data)re(t.data),g.success(j(`settings.model.modelPullAccessSaved`));else throw Error(t.error||`Failed to update model access`)}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`${j(`settings.model.modelPullAccessSaveFailed`)}: ${t}`)}finally{z(!1)}},vn=e=>{let t={...b.titleSettings,autoTitle:e,taskModel:b.titleSettings?.taskModel||``};S({titleSettings:t}),O.updatePreferences({titleSettings:t})},yn=e=>{let t={...b.titleSettings,autoTitle:b.titleSettings?.autoTitle||!1,taskModel:e};S({titleSettings:t}),O.updatePreferences({titleSettings:t})},bn=(e,t)=>{nt(n=>({...n,[e]:t}))},xn=(e,t)=>{it(n=>({...n,[e]:t}))},Sn=(e,t)=>{ct(n=>({...n,[e]:t}))},Cn=async()=>{try{let e=await O.setGenerationOptions(st);e.success&&e.data&&(S(e.data),g.success(`Generation options updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update generation options: `+t)}},wn=async()=>{try{let e=await O.resetGenerationOptions();e.success&&e.data&&(S(e.data),ct(e.data.generationOptions||{}),g.success(`Generation options reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to reset generation options: `+t)}},Tn=(e,t)=>{lt(n=>({...n,[e]:t}))},En=[...Ot.map(e=>({value:e.id,label:`${e.name} (${e.pluginName||e.provider})`})),...!Ot.find(e=>e.id===J.model||e.rawModel===J.model)&&J.model?[{value:J.model,label:`${J.model} (current)`}]:[]],Dn=async()=>{try{let e=await O.setEmbeddingSettings(J);e.success&&e.data&&(S(e.data),g.success(`Embedding settings updated successfully`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to update embedding settings: `+t)}},On=async()=>{try{let e=await O.resetEmbeddingSettings();e.success&&e.data&&(S(e.data),lt(e.data.embeddingSettings||{}),g.success(`Embedding settings reset to defaults`))}catch(e){let t=e instanceof Error?e.message:String(e);g.error(`Failed to reset embedding settings: `+t)}},kn=[{id:`appearance`,label:j(`settings.tabs.appearance`),icon:ie},{id:`models`,label:j(`settings.tabs.model`),icon:p},{id:`generation`,label:j(`settings.tabs.generation`),icon:w},{id:`tts`,label:j(`settings.tabs.tts`),icon:x},{id:`image-gen`,label:j(`settings.tabs.imageGen`),icon:m},{id:`documents`,label:j(`settings.tabs.documents`),icon:C},{id:`plugins`,label:j(`settings.tabs.plugins`),icon:s},{id:`data`,label:j(`settings.tabs.data`),icon:C},{id:`about`,label:j(`settings.tabs.about`),icon:c}];return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`fixed inset-0 bg-black/60 backdrop-blur-sm z-50 transition-opacity duration-200`,onClick:t}),(0,I.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:(0,I.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:[(0,I.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:[(0,I.jsx)(`h2`,{className:`text-lg sm:text-xl font-semibold text-gray-900 dark:text-gray-100`,children:j(`settings.title`)}),(0,I.jsx)(A,{variant:`ghost`,size:`sm`,onClick:t,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:(0,I.jsx)(ae,{className:`h-5 w-5 sm:h-4 sm:w-4`})})]}),(0,I.jsxs)(`div`,{className:`flex flex-1 min-h-0 overscroll-behavior-contain`,children:[(0,I.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:(0,I.jsx)(`nav`,{className:`space-y-1`,children:kn.map(e=>{let t=e.icon,n=De===e.id,r=`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 border`;return r+=n?` bg-gray-100 dark:bg-dark-100 text-gray-900 dark:text-white border-gray-200 dark:border-dark-300`:` border-transparent text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-200`,(0,I.jsxs)(`button`,{onClick:()=>Oe(e.id),className:r,children:[(0,I.jsx)(t,{className:`h-4 w-4 flex-shrink-0`}),(0,I.jsx)(`span`,{className:`text-xs sm:text-sm font-medium truncate`,children:e.label})]},e.id)})})}),(0,I.jsx)(`div`,{className:`flex-1 p-3 xs:p-4 sm:p-6 overflow-auto overscroll-behavior-contain`,style:{WebkitOverflowScrolling:`touch`},children:(()=>{switch(De){case`appearance`:return(0,I.jsx)(Me,{theme:v,preferences:b,onThemeChange:cn,onAccentChange:ln,onCustomAccentChange:un,onShowUsernameChange:dn});case`models`:return(0,I.jsx)(Re,{models:n,selectedModel:i,systemMessage:o,tempSystemMessage:L,loading:d,user:te,systemInfo:ne,preferences:b,currentTaskModel:N,autoTitleTaskModelOptions:we,updatingModelPullAccess:Fe,updatingAllModels:je,updateProgress:B,onModelPullAccessToggle:_n,onModelChange:fn,onSystemMessageChange:pn,onSystemMessageSave:mn,onAutoTitleChange:vn,onAutoTitleTaskModelChange:yn,onUpdateAllModels:gn});case`tts`:return(0,I.jsx)(We,{loading:jt,settings:W,effectiveSettings:X,models:Y,plugins:Mt,voices:Nt,testing:pt,onSettingChange:Jt,onModelChange:Kt,onReset:Zt,onTest:Xt,onSave:Yt});case`image-gen`:return(0,I.jsx)(Le,{loading:Ft,settings:q,effectiveSettings:Lt,models:Z,plugins:It,sizes:Rt,qualities:zt,styles:Bt,onSettingChange:Qt,onModelChange:qt,onReset:en,onSave:$t});case`documents`:return(0,I.jsx)(Pe,{settings:U,effectiveSettings:J,modelOptions:En,status:kt,regenerating:ut,onSettingChange:Tn,onReset:On,onRegenerate:tn,onSave:Dn});case`plugins`:return(0,I.jsx)(Ve,{plugins:T,loading:oe,uploading:se,error:ce,hasKeys:Dt,showUploadForm:H,showJsonForm:Be,jsonInput:Ue,fileInputRef:Qe,expandedPluginId:$e,pluginApiKeys:tt,showApiKey:rt,savingApiKey:at,onClearError:be,onShowUploadFormChange:ze,onShowJsonFormChange:He,onJsonInputChange:Ze,onFileUpload:nn,onJsonSubmit:rn,onExpandedPluginChange:et,onPluginApiKeyChange:bn,onShowApiKeyChange:xn,onActivatePlugin:an,onDeletePlugin:on,onExportPlugin:sn,onSaveApiKey:Wt,onDeleteApiKey:Gt});case`data`:return(0,I.jsx)(Ne,{sessionCount:f.length,loading:d,importing:ht,showImportOptions:gt,mergeStrategy:_t,importResult:yt,importFileInputRef:xt,onExportData:St,onImportFileSelect:Ct,onClearAllHistory:hn,onMergeStrategyChange:vt,onConfirmImport:wt,onCancelImport:Tt,onDismissImportResult:()=>bt(null)});case`about`:return(0,I.jsx)(ke,{appVersion:Ke});case`generation`:return(0,I.jsx)(Ie,{generationOptions:st,embeddingSettings:U,effectiveEmbeddingSettings:J,embeddingModelOptions:En,embeddingStatus:kt,onGenerationOptionChange:Sn,onEmbeddingSettingsChange:Tn,onResetGenerationOptions:wn,onSaveGenerationOptions:Cn,onResetEmbeddingSettings:On,onSaveEmbeddingSettings:Dn});default:return null}})()})]})]})})]})};export{Ze as SettingsModal};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-fkbHPd-g.js";import{t as r}from"./useQuery-DfkI6VAv.js";import{t as i}from"./logger-BmpKNkls.js";import{Bt as a,D as o,g as s,kt as c,o as l,u}from"./ui-vendor-BJAeWL11.js";import{g as d}from"./api-CbmZzKBu.js";import{t as f}from"./Button-BUjLpHmR.js";import{H as p,a as m,c as h,g,i as _,k as v,l as y,m as b,o as x,s as S}from"../assets/index-ONn9VIq7.js";var C=e(n(),1),w=t(),T=i(`components:user-manager`),E=()=>{let{t:e}=v(),t=p(),[n,i]=(0,C.useState)(!1),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)({username:``,email:``,password:``,role:`user`}),{user:A}=g(),{data:j=[],isLoading:M}=r({queryKey:[`users`],queryFn:async()=>{let t=await d.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),N=()=>t.invalidateQueries({queryKey:[`users`]}),P=async t=>{t.preventDefault();try{let t=await d.createUser(O);t.success&&t.data&&(await N(),k({username:``,email:``,password:``,role:`user`}),i(!1),a.success(e(`userManager.form.createSuccess`)))}catch(t){T.error(`Error creating user:`,t);let n=e(`userManager.form.createFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.createFailed`)),a.error(n)}},F=async t=>{if(t.preventDefault(),E)try{let t={username:O.username,email:O.email,role:O.role};O.password&&O.password.trim()!==``&&(t.password=O.password);let n=await d.updateUser(E.id,t);n.success&&n.data&&(await N(),D(null),k({username:``,email:``,password:``,role:`user`}),a.success(e(`userManager.form.updateSuccess`)))}catch(t){T.error(`Error updating user:`,t);let n=e(`userManager.form.updateFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.updateFailed`)),a.error(n)}},I=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await d.deleteUser(t)).success&&(await N(),a.success(e(`userManager.deleteSuccess`)))}catch(t){T.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),a.error(n)}},L=e=>{D(e),k({username:e.username,email:e.email||``,password:``,role:e.role})};return M?(0,w.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,w.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-gray-600 border-t-primary-500 rounded-full animate-spin`})}):(0,w.jsxs)(`div`,{className:`space-y-6`,children:[(0,w.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,w.jsx)(`div`,{}),(0,w.jsxs)(f,{onClick:()=>i(!n),className:`flex items-center space-x-2 bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600`,children:[(0,w.jsx)(o,{size:16}),(0,w.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,w.jsxs)(_,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,w.jsxs)(S,{children:[(0,w.jsx)(h,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,w.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,w.jsx)(m,{children:(0,w.jsxs)(`form`,{onSubmit:P,className:`space-y-4`,children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(y,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,w.jsx)(b,{id:`username`,value:O.username,onChange:e=>k({...O,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(y,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,w.jsx)(b,{id:`email`,type:`email`,value:O.email,onChange:e=>k({...O,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(y,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,w.jsx)(b,{id:`password`,type:`password`,value:O.password,onChange:e=>k({...O,password:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(y,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,w.jsxs)(`select`,{id:`role`,value:O.role,onChange:e=>k({...O,role:e.target.value}),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200`,children:[(0,w.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,w.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,w.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,w.jsx)(f,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,w.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>{k({username:``,email:``,password:``,role:`user`}),i(!1)},children:e(`common.cancel`)})]})]})})]}),E&&(0,w.jsxs)(_,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,w.jsxs)(S,{children:[(0,w.jsxs)(h,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,E.username]}),(0,w.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,w.jsx)(m,{children:(0,w.jsxs)(`form`,{onSubmit:F,className:`space-y-4`,children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(y,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,w.jsx)(b,{id:`edit-username`,value:O.username,onChange:e=>k({...O,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(y,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,w.jsx)(b,{id:`edit-email`,type:`email`,value:O.email,onChange:e=>k({...O,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(y,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,w.jsx)(b,{id:`edit-password`,type:`password`,value:O.password,onChange:e=>k({...O,password:e.target.value}),placeholder:e(`userManager.form.passwordHint`),className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(y,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,w.jsxs)(`select`,{id:`edit-role`,value:O.role,onChange:e=>k({...O,role:e.target.value}),disabled:E?.id===A?.id&&A?.role===`admin`,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,w.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,w.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),E?.id===A?.id&&A?.role===`admin`&&(0,w.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,w.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,w.jsx)(f,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,w.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>{D(null),k({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),(0,w.jsxs)(_,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,w.jsxs)(S,{children:[(0,w.jsxs)(h,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,j.length,`)`]}),(0,w.jsx)(x,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,w.jsx)(m,{children:(0,w.jsx)(`div`,{className:`space-y-3`,children:j.map(t=>(0,w.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,w.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,w.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,w.jsx)(s,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,w.jsx)(l,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===A?.id&&(0,w.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,w.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[t.email||e(`userManager.noEmail`),` •`,` `,t.role===`admin`?e(`userManager.roles.admin`):e(`userManager.roles.user`)]}),(0,w.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,w.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,w.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>L(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,w.jsx)(c,{size:16})}),(0,w.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>I(t.id,t.username),disabled:t.id===A?.id,className:`text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,w.jsx)(u,{size:16})})]})]},t.id))})})]})]})},D=()=>{let{t:e}=v();return(0,w.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,w.jsxs)(`div`,{className:`max-w-6xl mx-auto p-6`,children:[(0,w.jsxs)(`div`,{className:`mb-8`,children:[(0,w.jsx)(`h1`,{className:`text-3xl font-bold text-gray-900 dark:text-gray-100 mb-2`,children:e(`userManager.title`)}),(0,w.jsx)(`p`,{className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.pageDescription`)})]}),(0,w.jsx)(E,{})]})})};export{D as UserManagementPage,D as default};
@@ -0,0 +1,15 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-ONn9VIq7.js","js/rolldown-runtime-QTnfLwEv.js","js/markdown-core-fkbHPd-g.js","js/react-vendor-Co1u1rWb.js","js/logger-BmpKNkls.js","js/demoMode-BhEpMVh5.js","js/ui-vendor-BJAeWL11.js","js/utils-vendor-BX3ZwoIK.js","js/utils-BaPYjs_z.js","js/Button-BUjLpHmR.js","assets/index-Dc8Q4dJZ.css"])))=>i.map(i=>d[i]);
2
+ import{n as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./logger-BmpKNkls.js";import{a as i}from"./utils-vendor-BX3ZwoIK.js";import{n as a}from"./demoMode-BhEpMVh5.js";var o=r(`config`),s=window.location.protocol===`file:`?`http://localhost:3001/api`:`${window.location.origin}/api`,c=t(),l=()=>{c&&(o.debug(`API_BASE_URL configured as:`,s),o.debug(`Window location:`,window.location),o.debug(`Environment variables:`,{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.12.0`}))},u=r(`api`);l(),u.debug(`User agent:`,navigator.userAgent),u.debug(`Demo mode detected:`,a());var d=(e,t=!0)=>new Promise(n=>{setTimeout(()=>{n({success:t,data:e,error:t?void 0:`Demo mode: Backend not available`})},500)}),f=i.create({baseURL:s,timeout:3e5});f.interceptors.request.use(e=>{let t=localStorage.getItem(`auth-token`);return t&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e)),f.interceptors.response.use(e=>e,e=>{if(e.response?.status===401){u.warn(`Session expired or unauthorized, logging out...`),localStorage.removeItem(`auth-token`),n(async()=>{let{useAuthStore:e}=await import(`../assets/index-ONn9VIq7.js`).then(e=>e.h);return{useAuthStore:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(({useAuthStore:e})=>{e.getState().logout()});let e=window.location.protocol===`file:`;return(e?window.location.hash:window.location.pathname).includes(`/login`)||(window.location.href=e?`#/login`:`/login`),Promise.reject(Error(`Session expired`))}return u.error(`API Error:`,e),Promise.reject(e)});var p=`0.12.0`,m={login:e=>a()?d({user:{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,allowUserModelPull:!0,version:p}}):f.post(`/auth/login`,e).then(e=>e.data),signup:e=>a()?d({user:{id:`demo-user-new`,username:e.username,email:e.email||``,role:`user`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token-new`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,allowUserModelPull:!0,version:p,turnstile:{enabled:!1}}}):f.post(`/auth/signup`,e).then(e=>e.data),logout:()=>a()?d(void 0):f.post(`/auth/logout`).then(e=>e.data),getSystemInfo:()=>(u.debug(`getSystemInfo called, demo mode:`,a()),a()?d({requiresAuth:!0,hasUsers:!0,userCount:1,allowUserModelPull:!0,version:p,turnstile:{enabled:!1}}):(u.debug(`Making API call to:`,s+`/auth/system-info`),u.debug(`Full URL from:`,window.location.origin,`-> API:`,s+`/auth/system-info`),f.get(`/auth/system-info`).then(e=>(u.debug(`getSystemInfo response:`,e.data),e.data)).catch(e=>{throw u.debug(`getSystemInfo error:`,e),e.response&&(u.debug(`Error response data:`,e.response.data),u.debug(`Error status:`,e.response.status),u.debug(`Error headers:`,e.response.headers)),e.request&&u.debug(`Network error - no response received:`,e.request),u.debug(`Error config:`,e.config),e}))),verifyToken:()=>a()?d({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):f.get(`/auth/verify`).then(e=>e.data),getEncryptionKey:()=>a()?d({encryptionKey:`demo-encryption-key-not-real`}):f.get(`/auth/encryption-key`).then(e=>e.data),updateModelPullSetting:e=>a()?d({requiresAuth:!0,hasUsers:!0,userCount:1,allowUserModelPull:e,version:p,turnstile:{enabled:!1}}):f.patch(`/auth/system-settings/model-pull`,{allowUserModelPull:e}).then(e=>e.data)},h={getUsers:()=>a()?d([{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]):f.get(`/users`).then(e=>e.data),createUser:e=>a()?d({id:`new-user-`+Date.now(),username:e.username,email:e.email,role:e.role,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):f.post(`/users`,e).then(e=>e.data),updateUser:(e,t)=>a()?d({id:e,username:t.username||`demo`,email:t.email||`demo@example.com`,role:t.role||`user`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):f.patch(`/users/${e}`,t).then(e=>e.data),deleteUser:e=>a()?d(void 0):f.delete(`/users/${e}`).then(e=>e.data),updateMyAvatar:e=>a()?d({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,avatar:e,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):f.patch(`/users/me/avatar`,{avatar:e}).then(e=>e.data)},g=[{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`}}],_=()=>[{id:`demo-session-1`,title:`Demo Chat Session`,model:g[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()}],v=_(),y={theme:{mode:`dark`,accent:`blue`,customAccent:`#2563eb`},defaultModel:`llama3.2:3b`,systemMessage:`You are a helpful assistant.`,generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},titleSettings:{autoTitle:!1,taskModel:``},showUsername:!1,backgroundSettings:{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6}},b={...y,theme:{...y.theme},generationOptions:{...y.generationOptions},embeddingSettings:{...y.embeddingSettings},titleSettings:{...y.titleSettings},backgroundSettings:{...y.backgroundSettings}},x=()=>b,S=e=>{let t=b.backgroundSettings||y.backgroundSettings;return b={...b,...e,theme:{...b.theme,...e.theme},generationOptions:{...b.generationOptions,...e.generationOptions},embeddingSettings:{...b.embeddingSettings,...e.embeddingSettings},titleSettings:e.titleSettings?{...b.titleSettings||y.titleSettings,...e.titleSettings}:b.titleSettings,backgroundSettings:e.backgroundSettings?{...t,...e.backgroundSettings}:b.backgroundSettings},b},C={getSessions:()=>f.get(`/chat/sessions`).then(e=>e.data),createSession:(e,t,n)=>f.post(`/chat/sessions`,{model:e,title:t,personaId:n}).then(e=>e.data),getSession:e=>{if(a()){let t=_().find(t=>t.id===e);return t?d(t):Promise.resolve({success:!1,error:`Session not found in demo mode`})}return f.get(`/chat/sessions/${e}`).then(e=>e.data)},updateSession:(e,t)=>{if(a()){let n=v.findIndex(t=>t.id===e),r=v[n];if(r){let e={...r,...t,updatedAt:Date.now()};return v[n]=e,d(e)}return Promise.resolve({success:!1,error:`Session not found in demo mode`})}return f.put(`/chat/sessions/${e}`,t).then(e=>e.data)},deleteSession:e=>a()?d(null):f.delete(`/chat/sessions/${e}`).then(e=>e.data),clearAllSessions:()=>f.delete(`/chat/sessions`).then(e=>e.data),generateTitle:(e,t,n)=>a()?d({title:n.substring(0,30)+(n.length>30?`...`:``)}):f.post(`/chat/sessions/${e}/generate-title`,{model:t,message:n}).then(e=>e.data),sendMessage:(e,t,n)=>f.post(`/chat/sessions/${e}/messages`,{content:t,options:n}).then(e=>e.data),saveMessage:(e,t)=>f.post(`/chat/sessions/${e}/messages`,t).then(e=>e.data),updateMessage:(e,t,n)=>a()?d({}):f.put(`/chat/sessions/${e}/messages/${t}`,n).then(e=>e.data),generateChatResponse:(e,t,n)=>f.post(`/chat/sessions/${e}/generate`,{message:t,options:n}).then(e=>e.data),generateChatStreamResponse:(e,t,n)=>({subscribe:async(r,i,a)=>{try{let o=await fetch(`${s}/chat/sessions/${e}/generate/stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:t,options:n})});if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);let c=o.body?.getReader();if(!c)throw Error(`No response body reader available`);let l=new TextDecoder,d=``,f=()=>{c.read().then(({done:e,value:t})=>{if(e){a?.();return}d+=l.decode(t,{stream:!0});let n=d.split(`
3
+ `);d=n.pop()||``;for(let e of n){let t=e.trim();if(t.startsWith(`data: `)){let e=t.slice(6);if(e===`[DONE]`){a?.();return}try{let t=JSON.parse(e);if(r(t),t.type===`done`||t.type===`error`){t.type===`error`?i?.(t.error):a?.();return}}catch(e){u.error(`Failed to parse SSE data:`,e)}}}f()}).catch(e=>{i?.(e instanceof Error?e:Error(String(e)))})};return f(),()=>c.cancel()}catch(e){return i?.(e instanceof Error?e:Error(String(e))),()=>{}}}}),getMessageBranches:(e,t)=>a()?d([]):f.get(`/chat/sessions/${e}/messages/${t}/branches`).then(e=>e.data),switchMessageBranch:(e,t,n)=>a()?d({}):f.post(`/chat/sessions/${e}/messages/${t}/branch`,{branchIndex:n}).then(e=>e.data),createMessageBranch:(e,t,n)=>a()?d({}):f.post(`/chat/sessions/${e}/messages/${t}/branches`,{...n}).then(e=>e.data)},w={uploadDocument:(e,t)=>{if(a())return d({id:`demo-doc-`+Date.now(),filename:e.name,fileType:e.name.endsWith(`.pdf`)?`pdf`:`txt`,size:e.size,sessionId:t,uploadedAt:Date.now()});let n=new FormData;return n.append(`document`,e),t&&n.append(`sessionId`,t),f.post(`/documents/upload`,n).then(e=>e.data)},getDocuments:e=>{if(a())return d([]);let t=e?`/documents/session/${e}`:`/documents`;return f.get(t).then(e=>e.data)},getDocument:e=>a()?d({id:e,filename:`demo-document.pdf`,fileType:`pdf`,size:1024,content:`Demo document content...`,uploadedAt:Date.now()}):f.get(`/documents/${e}`).then(e=>e.data),searchDocuments:(e,t,n)=>a()?d([]):f.post(`/documents/search`,{query:e,sessionId:t,limit:n}).then(e=>e.data),deleteDocument:e=>a()?d(void 0):f.delete(`/documents/${e}`).then(e=>e.data),getEmbeddingStatus:()=>a()?d({available:!1,model:`nomic-embed-text`,chunksWithEmbeddings:0,totalChunks:0}):f.get(`/documents/embeddings/status`).then(e=>e.data),regenerateEmbeddings:()=>a()?d(void 0):f.post(`/documents/embeddings/regenerate`).then(e=>e.data)},T={getModels:()=>a()?d([{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]):f.get(`/embeddings/models`).then(e=>e.data)},E={getModels:e=>a()?d([{id:`meta-llama/Llama-3.3-70B-Instruct`,modelId:`meta-llama/Llama-3.3-70B-Instruct`,author:`meta-llama`,downloads:1e6,likes:5e3,tags:[`text-generation`,`llama`],pipeline_tag:`text-generation`,gated:!1}]):f.get(`/huggingface-hub/models`,{params:e}).then(e=>e.data),getTrending:e=>a()?d([]):f.get(`/huggingface-hub/trending`,{params:e}).then(e=>e.data),getModel:(e,t)=>a()?d({id:`${e}/${t}`,modelId:`${e}/${t}`,author:e,downloads:0,likes:0,tags:[],gated:!1}):f.get(`/huggingface-hub/models/${e}/${t}`).then(e=>e.data),getTasks:()=>a()?d([`text-generation`,`text-to-speech`,`text-to-image`]):f.get(`/huggingface-hub/tasks`).then(e=>e.data),clearCache:()=>a()?d(!0):f.post(`/huggingface-hub/cache/clear`).then(e=>e.data),getGgufFiles:(e,t)=>a()?d([{filename:`model-Q4_K_M.gguf`,size:45e8,sizeFormatted:`4.19 GB`,quantization:`Q4_K_M`,url:`https://huggingface.co/${e}/${t}/resolve/main/model-Q4_K_M.gguf`,ollamaCommand:`hf.co/${e}/${t}:Q4_K_M`}]):f.get(`/huggingface-hub/models/${e}/${t}/gguf`).then(e=>e.data),hasGgufFiles:(e,t)=>a()?d({hasGguf:!1,count:0}):f.get(`/huggingface-hub/models/${e}/${t}/has-gguf`).then(e=>e.data)},D={getModels:()=>a()?d([{model:`dall-e-3`,plugin:`openai`,config:{sizes:[`1024x1024`,`1792x1024`,`1024x1792`],default_size:`1024x1024`,qualities:[`standard`,`hd`],default_quality:`standard`,styles:[`vivid`,`natural`],default_style:`vivid`,max_prompt_length:4e3}}]):f.get(`/image-gen/models`).then(e=>e.data),getPlugins:()=>a()?d([{id:`openai`,name:`OpenAI DALL-E`,models:[`dall-e-3`,`dall-e-2`],config:{sizes:[`1024x1024`,`1792x1024`,`1024x1792`],default_size:`1024x1024`,qualities:[`standard`,`hd`],default_quality:`standard`}}]):f.get(`/image-gen/plugins`).then(e=>e.data),getConfig:e=>a()?d({sizes:[`1024x1024`,`1792x1024`,`1024x1792`],default_size:`1024x1024`,qualities:[`standard`,`hd`],default_quality:`standard`,styles:[`vivid`,`natural`],default_style:`vivid`,max_prompt_length:4e3}):f.get(`/image-gen/config/${e}`).then(e=>e.data),generate:e=>a()?d({images:[{url:`https://placehold.co/1024x1024/purple/white?text=Demo+Image`,revised_prompt:e.prompt}]}):f.post(`/image-gen/generate`,e).then(e=>e.data),getGallery:e=>a()?d({images:[],total:0}):f.get(`/image-gen/gallery`,{params:e}).then(e=>e.data),getGalleryImage:e=>a()?d({id:e,userId:`demo`,prompt:`Demo image prompt`,model:`dall-e-3`,imageData:`https://placehold.co/1024x1024/purple/white?text=Demo`,createdAt:Date.now()}):f.get(`/image-gen/gallery/${e}`).then(e=>e.data),deleteGalleryImage:e=>a()?d(void 0):f.delete(`/image-gen/gallery/${e}`).then(e=>e.data)},O={connected:!1,baseUrl:`http://127.0.0.1:8766`,dashboardUrl:`http://127.0.0.1:8766/dashboard`,error:`Libre Claw daemon is not connected in demo mode.`},k={status:()=>a()?d(O):f.get(`/libre-claw/status`).then(e=>e.data),dashboard:()=>a()?d({url:O.dashboardUrl}):f.get(`/libre-claw/dashboard`).then(e=>e.data),currentModel:()=>a()?d({provider:`openrouter`,model:`openrouter/auto`}):f.get(`/libre-claw/config/model`).then(e=>e.data),updateModel:(e,t,n=!1)=>a()?d({provider:e,model:t,persist_global:n}):f.patch(`/libre-claw/config/model`,{provider:e,model:t,persist_global:n}).then(e=>e.data),currentFallback:()=>a()?d({enabled:!1,routes:[]}):f.get(`/libre-claw/config/fallback`).then(e=>e.data),updateFallback:e=>a()?d(e):f.patch(`/libre-claw/config/fallback`,e).then(e=>e.data),updateTheme:(e,t=!0)=>a()?d({theme:e,label:e,persist_global:t}):f.patch(`/libre-claw/config/theme`,{theme:e,persist_global:t}).then(e=>e.data),usage:(e=``,t=250)=>{let n=new URLSearchParams({limit:String(t)});return e&&n.set(`provider`,e),a()?d({summary:{},records:[],text:``}):f.get(`/libre-claw/usage?${n.toString()}`).then(e=>e.data)},listRuns:(e=20)=>a()?d({runs:[]}):f.get(`/libre-claw/runs?limit=${e}`).then(e=>e.data),startRun:e=>{if(a()){let t=new Date().toISOString();return d({run:{run_id:`demo-${Date.now()}`,state:`queued`,title:e.message.slice(0,80)||`Libre Claw demo run`,kind:e.kind||`chat`,provider:e.provider||`openrouter`,model:e.model||`openrouter/auto`,working_directory:``,created_at:t,updated_at:t}})}return f.post(`/libre-claw/runs`,e).then(e=>e.data)},getRun:e=>a()?d({run_id:e}):f.get(`/libre-claw/runs/${encodeURIComponent(e)}`).then(e=>e.data),getEvents:(e,t=0)=>a()?d({events:[]}):f.get(`/libre-claw/runs/${encodeURIComponent(e)}/events?after=${t}`).then(e=>e.data),cancelRun:e=>a()?d({run_id:e,cancelled:!0}):f.post(`/libre-claw/runs/${encodeURIComponent(e)}/cancel`).then(e=>e.data),resolvePermission:(e,t,n)=>a()?d({run_id:e,tool_call_id:t,resolution:n}):f.post(`/libre-claw/runs/${encodeURIComponent(e)}/permissions/${encodeURIComponent(t)}`,{resolution:n}).then(e=>e.data),listAutomations:(e=50)=>a()?d({automations:[]}):f.get(`/libre-claw/automations?limit=${e}`).then(e=>e.data),createAutomation:e=>a()?d({...e,automation_id:`demo-${Date.now()}`}):f.post(`/libre-claw/automations`,e).then(e=>e.data),updateAutomation:(e,t)=>a()?d({...t,automation_id:e}):f.patch(`/libre-claw/automations/${encodeURIComponent(e)}`,t).then(e=>e.data),pauseAutomation:e=>a()?d({automation_id:e,status:`paused`}):f.post(`/libre-claw/automations/${encodeURIComponent(e)}/pause`).then(e=>e.data),resumeAutomation:e=>a()?d({automation_id:e,status:`active`}):f.post(`/libre-claw/automations/${encodeURIComponent(e)}/resume`).then(e=>e.data),runAutomationNow:e=>a()?d({automation_id:e,run:!0}):f.post(`/libre-claw/automations/${encodeURIComponent(e)}/run`).then(e=>e.data),deleteAutomation:e=>a()?d({automation_id:e,deleted:!0}):f.delete(`/libre-claw/automations/${encodeURIComponent(e)}`).then(e=>e.data)},A={checkHealth:()=>a()?d({status:`offline`},!1):f.get(`/ollama/health`).then(e=>e.data),getModels:()=>a()?d(g):f.get(`/ollama/models`).then(e=>e.data),pullModel:e=>a()?d(null,!1):f.post(`/ollama/models/pull`,{name:e}).then(e=>e.data),pullModelStream:(e,t,n,r)=>{if(a()){let e=0,r=setInterval(()=>{e+=Math.random()*20,e>=100?(e=100,t({status:`success`,total:100,completed:100,percent:100}),clearInterval(r),setTimeout(n,500)):t({status:`pulling`,total:100,completed:e,percent:Math.round(e)})},1e3);return()=>clearInterval(r)}let i=new URLSearchParams({model:e}),o=localStorage.getItem(`auth-token`);o&&i.set(`token`,o);let c=new EventSource(`${s}/ollama/pull/stream?${i.toString()}`);return c.onmessage=e=>{let i=JSON.parse(e.data);switch(i.type){case`progress`:t({status:i.status,digest:i.digest,total:i.total,completed:i.completed,percent:i.percent});break;case`complete`:c.close(),n();break;case`error`:c.close(),r(i.error);break}},c.onerror=()=>{c.close(),r(`Connection to server lost`)},()=>{c.close()}},deleteModel:e=>a()?d(null,!1):f.delete(`/ollama/models`,{params:{name:e}}).then(e=>e.data),showModel:(e,t=!1)=>{if(a()){let t=g.find(t=>t.name===e);return d(t||null,!!t)}return f.get(`/ollama/models/show`,{params:{name:e,verbose:t}}).then(e=>e.data)},createModel:e=>a()?d(null,!1):f.post(`/ollama/models`,e).then(e=>e.data),copyModel:(e,t)=>a()?d(null,!1):f.post(`/ollama/models/copy`,{source:e,destination:t}).then(e=>e.data),pushModel:e=>a()?d(null,!1):f.post(`/ollama/models/push`,{name:e}).then(e=>e.data),pullAllModels:()=>a()?d(null,!1):f.post(`/ollama/models/pull-all`).then(e=>e.data),pullAllModelsStream:(e,t,n)=>{if(a()){let n=g,r=0,i=setInterval(()=>{r++,r<=n.length&&e({current:r,total:n.length,modelName:n[r-1]?.name||`demo-model`,status:Math.random()>.1?`success`:`error`,error:Math.random()>.1?void 0:`Demo error`}),r>=n.length&&(clearInterval(i),setTimeout(t,500))},1e3);return}let r=new EventSource(`${s}/ollama/models/pull-all/stream`);r.onmessage=i=>{let a=JSON.parse(i.data);switch(a.type){case`progress`:e({current:a.current,total:a.total,modelName:a.modelName,status:a.status,error:a.error});break;case`complete`:r.close(),t();break;case`error`:r.close(),n(a.error);break}},r.onerror=()=>{r.close(),n(`Connection to server lost`)}},generateEmbeddings:e=>a()?d({embeddings:[[]]},!1):f.post(`/ollama/embed`,e).then(e=>e.data),listRunningModels:()=>a()?d([]):f.get(`/ollama/running`).then(e=>e.data),unloadModel:e=>a()?d(null):f.post(`/ollama/models/unload`,{name:e}).then(e=>e.data),unloadAllModels:()=>a()?d(null):f.post(`/ollama/models/unload-all`).then(e=>e.data),getVersion:()=>a()?d({version:`demo-mode`},!1):f.get(`/ollama/version`).then(e=>e.data),chatCompletion:e=>a()?d({message:{content:`Demo response`,role:`assistant`}},!1):f.post(`/ollama/chat`,e).then(e=>e.data),checkBlobExists:e=>a()?Promise.resolve(!1):f.head(`/ollama/blobs/${e}`).then(()=>!0).catch(()=>!1),pushBlob:(e,t)=>a()?d(null,!1):f.post(`/ollama/blobs/${e}`,t,{headers:{"Content-Type":`application/octet-stream`}}).then(e=>e.data),generateLegacyEmbeddings:e=>a()?d({embedding:[]},!1):f.post(`/ollama/embeddings`,e).then(e=>e.data),getLibraryModels:e=>{if(a())return e?.category===`cloud`?d([{name:`gpt-oss:cloud`,description:`Demo cloud model using Ollama cloud naming`,category:`cloud`,sizes:[`cloud`],pulls:`Cloud`,tags:[`cloud`]}]):d([{name:`llama3.2`,description:`Meta's latest Llama model`,category:`general`,sizes:[`1b`,`3b`],pulls:`50M+`,tags:[`general`]},{name:`deepseek-r1`,description:`Open reasoning model`,category:`reasoning`,sizes:[`7b`,`14b`,`32b`],pulls:`200M+`,tags:[`reasoning`]}]);let t=new URLSearchParams;e?.search&&t.set(`search`,e.search),e?.sort&&t.set(`sort`,e.sort),e?.category&&t.set(`category`,e.category);let n=t.toString();return f.get(`/ollama/library${n?`?${n}`:``}`).then(e=>e.data)}},j=[[`#2563eb`,`#7c3aed`],[`#0891b2`,`#2563eb`],[`#0f766e`,`#2563eb`],[`#be123c`,`#7c3aed`],[`#b45309`,`#dc2626`]],M=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)},N=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`),P=e=>{let t=e.trim().split(/[\s._-]+/).filter(Boolean);return t.length===0?`AI`:t.slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`AI`},F=(e,t=128)=>{let n=e.trim()||`AI Persona`,r=M(n),[i,a]=j[r%j.length],o=N(P(n)),s=`persona-avatar-${r}-${t}`,c=t>=96?44:24,l=`
4
+ <svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}" role="img" aria-label="${N(n)} avatar">
5
+ <defs>
6
+ <linearGradient id="${s}" x1="0" y1="0" x2="1" y2="1">
7
+ <stop offset="0%" stop-color="${i}" />
8
+ <stop offset="100%" stop-color="${a}" />
9
+ </linearGradient>
10
+ </defs>
11
+ <rect width="${t}" height="${t}" rx="${Math.round(t*.22)}" fill="url(#${s})" />
12
+ <circle cx="${t*.22}" cy="${t*.22}" r="${t*.26}" fill="rgba(255,255,255,0.16)" />
13
+ <text x="50%" y="52%" dominant-baseline="middle" text-anchor="middle" fill="white" font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="${c}" font-weight="700">${o}</text>
14
+ </svg>
15
+ `;return`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(l)}`},I=(e,t=128)=>e.avatar?.trim()||F(e.name,t),L=(e,t,n=128)=>{e.onerror=null,e.src=F(t,n)},R={getPersonas:()=>a()?d([{id:`demo-1`,user_id:`default`,name:`Creative Assistant`,description:`Helpful assistant for creative tasks`,model:`llama3.3:latest`,parameters:{temperature:.8,top_p:.9,context_window:4096,system_prompt:`You are a creative and helpful assistant. Provide thoughtful and engaging responses.`},avatar:F(`Creative Assistant`,128),created_at:Date.now()-864e5,updated_at:Date.now()-864e5},{id:`demo-2`,user_id:`default`,name:`Research Assistant`,description:`Academic assistant for research and learning`,model:`qwen3:7b`,parameters:{temperature:.3,top_p:.8,context_window:8192,system_prompt:`You are a knowledgeable research assistant. Provide detailed, informative explanations.`},avatar:F(`Research Assistant`,128),created_at:Date.now()-1728e5,updated_at:Date.now()-1728e5}]):f.get(`/personas`).then(e=>e.data),getPersona:e=>a()?d({id:e,user_id:`default`,name:`Sample Assistant`,description:`A sample assistant for demonstration`,model:`llama3.2:latest`,parameters:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},created_at:Date.now(),updated_at:Date.now()}):f.get(`/personas/${e}`).then(e=>e.data),createPersona:e=>a()?d({id:`demo-`+Date.now(),user_id:`default`,...e,created_at:Date.now(),updated_at:Date.now()}):f.post(`/personas`,e).then(e=>e.data),updatePersona:(e,t)=>a()?d({id:e,user_id:`default`,name:t.name||`Updated Sample Assistant`,description:t.description,model:t.model||`llama3.2:latest`,parameters:t.parameters||{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},avatar:t.avatar,background:t.background,created_at:Date.now()-864e5,updated_at:Date.now()}):f.put(`/personas/${e}`,t).then(e=>e.data),deletePersona:e=>a()?d(void 0):f.delete(`/personas/${e}`).then(e=>e.data),exportPersona:e=>{if(a()){let e={name:`Sample Assistant`,description:`A sample assistant for demonstration`,model:`llama3.2:latest`,params:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},exportedAt:Date.now(),version:`1.0.0`};return Promise.resolve(e)}return f.get(`/personas/${e}/export`).then(e=>e.data)},importPersona:e=>a()?d({id:`demo-imported-`+Date.now(),user_id:`default`,name:e.name,description:e.description,model:e.model,parameters:e.params,avatar:e.avatar,background:e.background,created_at:Date.now(),updated_at:Date.now(),embedding_model:e.embedding_model,memory_settings:e.memory_settings,mutation_settings:e.mutation_settings}):f.post(`/personas/import`,e).then(e=>e.data),getPersonasCount:()=>a()?d({count:2}):f.get(`/personas/stats/count`).then(e=>e.data),getDefaultParameters:()=>a()?d({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}):f.get(`/personas/defaults/parameters`).then(e=>e.data),getMemoryStatus:e=>a()?d({status:`active`,memory_count:42,last_backup:Date.now()-864e5,size_mb:2.3}):f.get(`/personas/${e}/memory/status`).then(e=>e.data),wipeMemories:e=>a()?d({deleted_count:42}):f.delete(`/personas/${e}/memory`).then(e=>e.data),backupPersona:e=>{if(a()){let t=JSON.stringify({persona_id:e,backup_date:new Date().toISOString(),data:`demo backup data`});return Promise.resolve(new Blob([t],{type:`application/json`}))}return f.get(`/personas/${e}/backup`,{responseType:`blob`}).then(e=>e.data)},exportPersonaDNA:e=>{if(a()){let t=JSON.stringify({persona_id:e,export_date:new Date().toISOString(),dna:`demo DNA data`,memories:[],learned_behaviors:{}});return Promise.resolve(new Blob([t],{type:`application/json`}))}return f.get(`/personas/${e}/export/dna`,{responseType:`blob`}).then(e=>e.data)},importPersonaDNA:e=>{if(a())return d({id:`demo-dna-`+Date.now(),user_id:`default`,name:`Imported Persona`,description:`Persona imported from DNA`,model:`llama3.2:latest`,parameters:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},created_at:Date.now(),updated_at:Date.now()});let t=new FormData;return t.append(`dnaFile`,e),f.post(`/personas/import/dna`,t).then(e=>e.data)},downloadPersona:async(e,t)=>{try{let n=await R.exportPersona(e),r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${t}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch(e){throw u.error(`Error while downloading persona:`,e),Error(`Failed to download persona: ${e instanceof Error?e.message:String(e)}`)}}},z={getAllPlugins:()=>a()?d([]):f.get(`/plugins`).then(e=>e.data),uploadPlugin:e=>{if(a())return d({},!1);let t=new FormData;return t.append(`plugin`,e),f.post(`/plugins/upload`,t).then(e=>e.data)},installPlugin:e=>a()?d({},!1):f.post(`/plugins/install`,e).then(e=>e.data),updatePlugin:(e,t)=>a()?d({},!1):f.put(`/plugins/${e}`,t).then(e=>e.data),deletePlugin:e=>a()?d(void 0):f.delete(`/plugins/${e}`).then(e=>e.data),activatePlugin:e=>a()?d({},!1):f.post(`/plugins/activate/${e}`).then(e=>e.data),deactivatePlugin:e=>{if(a())return d(void 0);let t=e?`/plugins/deactivate/${e}`:`/plugins/deactivate`;return f.post(t).then(e=>e.data)},getActivePlugin:()=>a()?d(null):f.get(`/plugins/active`).then(e=>e.data),getPluginStatus:()=>a()?d([]):f.get(`/plugins/status`).then(e=>e.data),exportPlugin:e=>a()?Promise.resolve(new Blob([`{}`],{type:`application/json`})):f.get(`/plugins/${e}/export`,{responseType:`blob`}).then(e=>e.data),getCredentials:()=>a()?d([]):f.get(`/plugins/credentials/all`).then(e=>e.data),setApiKey:(e,t)=>a()?d(!1,!1):f.post(`/plugins/${e}/credentials`,{api_key:t}).then(e=>e.data),deleteApiKey:e=>a()?d(!1,!1):f.delete(`/plugins/${e}/credentials`).then(e=>e.data),checkApiKey:e=>a()?d(!1):f.get(`/plugins/${e}/credentials/check`).then(e=>e.data),getVariables:e=>a()?d({}):f.get(`/plugins/${e}/variables`).then(e=>e.data),setVariables:(e,t)=>a()?d(!0):f.put(`/plugins/${e}/variables`,{variables:t}).then(e=>e.data),resetVariables:e=>a()?d(!0):f.delete(`/plugins/${e}/variables`).then(e=>e.data)},B={getPreferences:()=>a()?d(x()):f.get(`/preferences`).then(e=>e.data),updatePreferences:e=>a()?d(S(e)):f.put(`/preferences`,e).then(e=>e.data),setDefaultModel:e=>a()?d(S({defaultModel:e})):f.put(`/preferences/default-model`,{model:e}).then(e=>e.data),setSystemMessage:e=>a()?d(S({systemMessage:e})):f.put(`/preferences/system-message`,{message:e}).then(e=>e.data),setGenerationOptions:e=>a()?d(S({generationOptions:e})):f.put(`/preferences/generation-options`,e).then(e=>e.data),resetGenerationOptions:()=>a()?d(S({generationOptions:y.generationOptions})):f.post(`/preferences/generation-options/reset`).then(e=>e.data),setEmbeddingSettings:e=>a()?d(S({embeddingSettings:e})):f.put(`/preferences/embedding-settings`,e).then(e=>e.data),resetEmbeddingSettings:()=>a()?d(S({embeddingSettings:y.embeddingSettings})):f.post(`/preferences/embedding-settings/reset`).then(e=>e.data),importData:(e,t=`replace`)=>a()?d({theme:{mode:`dark`,accent:`blue`,customAccent:`#2563eb`},defaultModel:`llama3.2`,systemMessage:`You are a helpful assistant.`,generationOptions:{},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},showUsername:!1}):f.post(`/preferences/import`,{data:e,mergeStrategy:t}).then(e=>e.data)},V={getModels:()=>a()?d([{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}}]):f.get(`/tts/models`).then(e=>e.data),getPlugins:()=>a()?d([{id:`openai`,name:`OpenAI GPT`,models:[`tts-1`,`tts-1-hd`],config:{voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`}}]):f.get(`/tts/plugins`).then(e=>e.data),getVoices:e=>a()?d({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}):f.get(`/tts/voices/${e}`).then(e=>e.data),generateBase64:e=>a()?d({audio:``,format:e.response_format||`mp3`,mimeType:`audio/mpeg`,size:0}):f.post(`/tts/generate-base64`,e).then(e=>e.data),generate:async e=>a()?new Blob([],{type:`audio/mpeg`}):(await f.post(`/tts/generate`,e,{responseType:`blob`})).data,speak:async(e,t={})=>{try{t.onStart?.();let n=await V.generateBase64({model:t.model||`tts-1`,input:e,voice:t.voice,speed:t.speed,response_format:`mp3`});if(!n.success||!n.data?.audio)throw Error(n.message||`Failed to generate speech`);let r=`data:${n.data.mimeType};base64,${n.data.audio}`,i=new Audio(r);return i.onended=()=>t.onEnd?.(),i.onerror=()=>t.onError?.(Error(`Audio playback failed`)),await i.play(),i}catch(e){let n=e instanceof Error?e:Error(`Unknown error`);return t.onError?.(n),null}}},H=e({personaApi:()=>R,preferencesApi:()=>B});export{s as _,R as a,A as c,E as d,w as f,h as g,m as h,z as i,k as l,C as m,V as n,I as o,T as p,B as r,L as s,H as t,D as u};