libre-webui 0.8.6 → 0.11.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 (314) hide show
  1. package/README.md +64 -46
  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 +31 -944
  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 +7 -20
  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 -242
  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/embeddings.d.ts +3 -0
  27. package/backend/dist/routes/embeddings.d.ts.map +1 -0
  28. package/backend/dist/routes/embeddings.js +52 -0
  29. package/backend/dist/routes/embeddings.js.map +1 -0
  30. package/backend/dist/routes/imageGen.d.ts.map +1 -1
  31. package/backend/dist/routes/imageGen.js +9 -7
  32. package/backend/dist/routes/imageGen.js.map +1 -1
  33. package/backend/dist/routes/ollama.d.ts.map +1 -1
  34. package/backend/dist/routes/ollama.js +22 -239
  35. package/backend/dist/routes/ollama.js.map +1 -1
  36. package/backend/dist/routes/personas.d.ts.map +1 -1
  37. package/backend/dist/routes/personas.js +3 -1
  38. package/backend/dist/routes/personas.js.map +1 -1
  39. package/backend/dist/routes/plugins.d.ts.map +1 -1
  40. package/backend/dist/routes/plugins.js +7 -105
  41. package/backend/dist/routes/plugins.js.map +1 -1
  42. package/backend/dist/routes/tts.d.ts.map +1 -1
  43. package/backend/dist/routes/tts.js +7 -5
  44. package/backend/dist/routes/tts.js.map +1 -1
  45. package/backend/dist/routes/users.d.ts.map +1 -1
  46. package/backend/dist/routes/users.js +7 -5
  47. package/backend/dist/routes/users.js.map +1 -1
  48. package/backend/dist/services/assistantCompletionService.d.ts +26 -0
  49. package/backend/dist/services/assistantCompletionService.d.ts.map +1 -0
  50. package/backend/dist/services/assistantCompletionService.js +53 -0
  51. package/backend/dist/services/assistantCompletionService.js.map +1 -0
  52. package/backend/dist/services/authService.d.ts +2 -0
  53. package/backend/dist/services/authService.d.ts.map +1 -1
  54. package/backend/dist/services/authService.js +15 -7
  55. package/backend/dist/services/authService.js.map +1 -1
  56. package/backend/dist/services/chatGenerationService.d.ts +32 -0
  57. package/backend/dist/services/chatGenerationService.d.ts.map +1 -0
  58. package/backend/dist/services/chatGenerationService.js +118 -0
  59. package/backend/dist/services/chatGenerationService.js.map +1 -0
  60. package/backend/dist/services/chatRequestService.d.ts +55 -0
  61. package/backend/dist/services/chatRequestService.d.ts.map +1 -0
  62. package/backend/dist/services/chatRequestService.js +103 -0
  63. package/backend/dist/services/chatRequestService.js.map +1 -0
  64. package/backend/dist/services/chatService.d.ts +0 -1
  65. package/backend/dist/services/chatService.d.ts.map +1 -1
  66. package/backend/dist/services/chatService.js +17 -113
  67. package/backend/dist/services/chatService.js.map +1 -1
  68. package/backend/dist/services/documentService.d.ts.map +1 -1
  69. package/backend/dist/services/documentService.js +23 -21
  70. package/backend/dist/services/documentService.js.map +1 -1
  71. package/backend/dist/services/embeddingService.d.ts +9 -0
  72. package/backend/dist/services/embeddingService.d.ts.map +1 -0
  73. package/backend/dist/services/embeddingService.js +155 -0
  74. package/backend/dist/services/embeddingService.js.map +1 -0
  75. package/backend/dist/services/encryptionService.d.ts.map +1 -1
  76. package/backend/dist/services/encryptionService.js +26 -24
  77. package/backend/dist/services/encryptionService.js.map +1 -1
  78. package/backend/dist/services/galleryService.d.ts.map +1 -1
  79. package/backend/dist/services/galleryService.js +8 -6
  80. package/backend/dist/services/galleryService.js.map +1 -1
  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 +45 -211
  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 +5 -3
  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 +67 -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 +6 -2
  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 +21 -17
  114. package/backend/dist/services/pluginService.d.ts.map +1 -1
  115. package/backend/dist/services/pluginService.js +135 -1356
  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 +1 -0
  125. package/backend/dist/services/preferencesService.d.ts.map +1 -1
  126. package/backend/dist/services/preferencesService.js +21 -7
  127. package/backend/dist/services/preferencesService.js.map +1 -1
  128. package/backend/dist/services/simpleGitHubOAuth.d.ts.map +1 -1
  129. package/backend/dist/services/simpleGitHubOAuth.js +10 -8
  130. package/backend/dist/services/simpleGitHubOAuth.js.map +1 -1
  131. package/backend/dist/services/simpleHuggingFaceOAuth.d.ts.map +1 -1
  132. package/backend/dist/services/simpleHuggingFaceOAuth.js +11 -9
  133. package/backend/dist/services/simpleHuggingFaceOAuth.js.map +1 -1
  134. package/backend/dist/services/systemSettingsService.d.ts.map +1 -1
  135. package/backend/dist/services/systemSettingsService.js +4 -2
  136. package/backend/dist/services/systemSettingsService.js.map +1 -1
  137. package/backend/dist/services/titleGenerationService.d.ts +55 -0
  138. package/backend/dist/services/titleGenerationService.d.ts.map +1 -0
  139. package/backend/dist/services/titleGenerationService.js +121 -0
  140. package/backend/dist/services/titleGenerationService.js.map +1 -0
  141. package/backend/dist/services/turnstileService.d.ts +13 -0
  142. package/backend/dist/services/turnstileService.d.ts.map +1 -0
  143. package/backend/dist/services/turnstileService.js +79 -0
  144. package/backend/dist/services/turnstileService.js.map +1 -0
  145. package/backend/dist/storage.d.ts +2 -22
  146. package/backend/dist/storage.d.ts.map +1 -1
  147. package/backend/dist/storage.js +22 -170
  148. package/backend/dist/storage.js.map +1 -1
  149. package/backend/dist/storageMappers.d.ts +82 -0
  150. package/backend/dist/storageMappers.d.ts.map +1 -0
  151. package/backend/dist/storageMappers.js +85 -0
  152. package/backend/dist/storageMappers.js.map +1 -0
  153. package/backend/dist/test-encryption.js +20 -18
  154. package/backend/dist/test-encryption.js.map +1 -1
  155. package/backend/dist/types/index.d.ts +6 -0
  156. package/backend/dist/types/index.d.ts.map +1 -1
  157. package/backend/dist/types/index.js.map +1 -1
  158. package/backend/dist/utils/assistantBranching.d.ts +8 -0
  159. package/backend/dist/utils/assistantBranching.d.ts.map +1 -0
  160. package/backend/dist/utils/assistantBranching.js +30 -0
  161. package/backend/dist/utils/assistantBranching.js.map +1 -0
  162. package/backend/dist/utils/chatContext.d.ts +17 -0
  163. package/backend/dist/utils/chatContext.d.ts.map +1 -0
  164. package/backend/dist/utils/chatContext.js +82 -0
  165. package/backend/dist/utils/chatContext.js.map +1 -0
  166. package/backend/dist/utils/chatDocumentContext.d.ts +7 -0
  167. package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -0
  168. package/backend/dist/utils/chatDocumentContext.js +51 -0
  169. package/backend/dist/utils/chatDocumentContext.js.map +1 -0
  170. package/backend/dist/utils/logger.d.ts +12 -0
  171. package/backend/dist/utils/logger.d.ts.map +1 -0
  172. package/backend/dist/utils/logger.js +82 -0
  173. package/backend/dist/utils/logger.js.map +1 -0
  174. package/backend/dist/utils/ollamaLibrary.d.ts +17 -0
  175. package/backend/dist/utils/ollamaLibrary.d.ts.map +1 -0
  176. package/backend/dist/utils/ollamaLibrary.js +253 -0
  177. package/backend/dist/utils/ollamaLibrary.js.map +1 -0
  178. package/backend/dist/utils/ollamaStreaming.d.ts +19 -0
  179. package/backend/dist/utils/ollamaStreaming.d.ts.map +1 -0
  180. package/backend/dist/utils/ollamaStreaming.js +67 -0
  181. package/backend/dist/utils/ollamaStreaming.js.map +1 -0
  182. package/backend/dist/utils/packagePaths.d.ts +10 -0
  183. package/backend/dist/utils/packagePaths.d.ts.map +1 -0
  184. package/backend/dist/utils/packagePaths.js +81 -0
  185. package/backend/dist/utils/packagePaths.js.map +1 -0
  186. package/backend/dist/utils/pluginChatAdapter.d.ts +32 -0
  187. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -0
  188. package/backend/dist/utils/pluginChatAdapter.js +308 -0
  189. package/backend/dist/utils/pluginChatAdapter.js.map +1 -0
  190. package/backend/dist/utils/pluginChatContext.d.ts +23 -0
  191. package/backend/dist/utils/pluginChatContext.d.ts.map +1 -0
  192. package/backend/dist/utils/pluginChatContext.js +77 -0
  193. package/backend/dist/utils/pluginChatContext.js.map +1 -0
  194. package/backend/dist/utils/pluginResponse.d.ts +6 -0
  195. package/backend/dist/utils/pluginResponse.d.ts.map +1 -0
  196. package/backend/dist/utils/pluginResponse.js +70 -0
  197. package/backend/dist/utils/pluginResponse.js.map +1 -0
  198. package/backend/dist/utils/pluginStreamAdapter.d.ts +16 -0
  199. package/backend/dist/utils/pluginStreamAdapter.d.ts.map +1 -0
  200. package/backend/dist/utils/pluginStreamAdapter.js +141 -0
  201. package/backend/dist/utils/pluginStreamAdapter.js.map +1 -0
  202. package/backend/dist/utils/pluginStreaming.d.ts +24 -0
  203. package/backend/dist/utils/pluginStreaming.d.ts.map +1 -0
  204. package/backend/dist/utils/pluginStreaming.js +106 -0
  205. package/backend/dist/utils/pluginStreaming.js.map +1 -0
  206. package/backend/dist/utils/pluginUpload.d.ts +8 -0
  207. package/backend/dist/utils/pluginUpload.d.ts.map +1 -0
  208. package/backend/dist/utils/pluginUpload.js +51 -0
  209. package/backend/dist/utils/pluginUpload.js.map +1 -0
  210. package/backend/dist/utils/pluginValidation.d.ts +10 -0
  211. package/backend/dist/utils/pluginValidation.d.ts.map +1 -0
  212. package/backend/dist/utils/pluginValidation.js +94 -0
  213. package/backend/dist/utils/pluginValidation.js.map +1 -0
  214. package/backend/dist/utils/pluginVariableValidation.d.ts +10 -0
  215. package/backend/dist/utils/pluginVariableValidation.d.ts.map +1 -0
  216. package/backend/dist/utils/pluginVariableValidation.js +80 -0
  217. package/backend/dist/utils/pluginVariableValidation.js.map +1 -0
  218. package/backend/dist/utils/websocketMessages.d.ts +26 -0
  219. package/backend/dist/utils/websocketMessages.d.ts.map +1 -0
  220. package/backend/dist/utils/websocketMessages.js +74 -0
  221. package/backend/dist/utils/websocketMessages.js.map +1 -0
  222. package/backend/dist/websocketServer.d.ts +3 -0
  223. package/backend/dist/websocketServer.d.ts.map +1 -0
  224. package/backend/dist/websocketServer.js +332 -0
  225. package/backend/dist/websocketServer.js.map +1 -0
  226. package/backend/package.json +55 -0
  227. package/frontend/dist/assets/index-BxHDVIti.css +1 -0
  228. package/frontend/dist/assets/index-CDA2f43l.js +5 -0
  229. package/frontend/dist/assets/markdown-math-CYlHEDRF.css +1 -0
  230. package/frontend/dist/index.html +12 -15
  231. package/frontend/dist/js/ArtifactContainer-CA523BOS.js +1 -0
  232. package/frontend/dist/js/ArtifactDemoPage-C0p2-ccP.js +200 -0
  233. package/frontend/dist/js/ArtifactSlideOutPanel-BBYuYyr_.js +1 -0
  234. package/frontend/dist/js/Button-BmZQkAPD.js +1 -0
  235. package/frontend/dist/js/ChatPage-QSOhIynr.js +16 -0
  236. package/frontend/dist/js/FirstTimeSetup-pi-S4VU-.js +1 -0
  237. package/frontend/dist/js/GalleryPage-BPXB-D4f.js +1 -0
  238. package/frontend/dist/js/ModelManagerModals-D3SZV7CU.js +1 -0
  239. package/frontend/dist/js/ModelsPage-Fmqc1Zxb.js +2 -0
  240. package/frontend/dist/js/OptimizedSyntaxHighlighter-DlI4omE2.js +1 -0
  241. package/frontend/dist/js/PersonasPage-BuLOCG1Y.js +13 -0
  242. package/frontend/dist/js/RichMessageContent-Darvuw8F.js +3 -0
  243. package/frontend/dist/js/SettingsModal-CQhAeaia.js +1 -0
  244. package/frontend/dist/js/UserManagementPage-yX9vOase.js +1 -0
  245. package/frontend/dist/js/api-d05r9G59.js +15 -0
  246. package/frontend/dist/js/ar-BIL8U_dv.js +2 -0
  247. package/frontend/dist/js/artifactHtml-CRdkOCnz.js +27 -0
  248. package/frontend/dist/js/bn-BWQoWPn6.js +2 -0
  249. package/frontend/dist/js/cs-DOD1vscE.js +2 -0
  250. package/frontend/dist/js/da-DYPzSzX4.js +2 -0
  251. package/frontend/dist/js/de-CHd4b2Xf.js +2 -0
  252. package/frontend/dist/js/demoMode-BhEpMVh5.js +1 -0
  253. package/frontend/dist/js/es-BmDO6uNe.js +2 -0
  254. package/frontend/dist/js/fr-DW24sUV7.js +2 -0
  255. package/frontend/dist/js/hi-BRDq_y1B.js +2 -0
  256. package/frontend/dist/js/id-I_F2nstV.js +2 -0
  257. package/frontend/dist/js/is-Boj7-J12.js +2 -0
  258. package/frontend/dist/js/it-CNeHl9Fh.js +2 -0
  259. package/frontend/dist/js/ja-DrVG6G8s.js +2 -0
  260. package/frontend/dist/js/ko-BtKRwlHW.js +2 -0
  261. package/frontend/dist/js/logger-1THq8-96.js +1 -0
  262. package/frontend/dist/js/markdown-core-CEpaJrKd.js +16 -0
  263. package/frontend/dist/js/markdown-math-DAmpvM9y.js +261 -0
  264. package/frontend/dist/js/ms-Dp9MigoU.js +2 -0
  265. package/frontend/dist/js/nl-Bk9pGoCF.js +2 -0
  266. package/frontend/dist/js/pl-seE8_lLS.js +2 -0
  267. package/frontend/dist/js/pt-BAeBtldI.js +2 -0
  268. package/frontend/dist/js/{react-vendor-BUzyfgnZ.js → react-vendor-DtQrJICq.js} +4 -4
  269. package/frontend/dist/js/rolldown-runtime-QTnfLwEv.js +1 -0
  270. package/frontend/dist/js/ru-CkCpWFNb.js +2 -0
  271. package/frontend/dist/js/sv-BM7nqxmA.js +2 -0
  272. package/frontend/dist/js/syntax-highlight-B758xPeo.js +8 -0
  273. package/frontend/dist/js/th-vDIZbpa4.js +2 -0
  274. package/frontend/dist/js/tr-G2-XodhW.js +2 -0
  275. package/frontend/dist/js/ui-vendor-MCs1MDmN.js +177 -0
  276. package/frontend/dist/js/uk-DfVfZcBQ.js +2 -0
  277. package/frontend/dist/js/useBaseQuery-CrdrLcmR.js +1 -0
  278. package/frontend/dist/js/useQuery-DaEnYfWR.js +1 -0
  279. package/frontend/dist/js/utils-es0n-47H.js +1 -0
  280. package/frontend/dist/js/utils-vendor-B2ZBL57Y.js +9 -0
  281. package/frontend/dist/js/vi-Yp9yjb06.js +2 -0
  282. package/frontend/dist/js/zh-DtRb97we.js +2 -0
  283. package/package.json +16 -10
  284. package/plugins/llama-cpp.json +93 -0
  285. package/plugins/openclaw-agent.json +1 -1
  286. package/backend/dist/services/openclawSessionService.d.ts +0 -63
  287. package/backend/dist/services/openclawSessionService.d.ts.map +0 -1
  288. package/backend/dist/services/openclawSessionService.js +0 -307
  289. package/backend/dist/services/openclawSessionService.js.map +0 -1
  290. package/frontend/dist/assets/index-B1qNw5pA.js +0 -52
  291. package/frontend/dist/assets/index-DnG6512Q.css +0 -1
  292. package/frontend/dist/assets/ui-CsNe6lFV.css +0 -1
  293. package/frontend/dist/js/ArtifactContainer-Com7P5vK.js +0 -24
  294. package/frontend/dist/js/ArtifactDemoPage-Xd-Ragpf.js +0 -98
  295. package/frontend/dist/js/Button-D62PCbMW.js +0 -1
  296. package/frontend/dist/js/ChatPage-01JxVHRP.js +0 -15
  297. package/frontend/dist/js/GalleryPage-8nHGqKEu.js +0 -1
  298. package/frontend/dist/js/ModelsPage-C0MLVfwA.js +0 -1
  299. package/frontend/dist/js/OptimizedSyntaxHighlighter-DjnSqskO.js +0 -1
  300. package/frontend/dist/js/PersonasPage-D9YKnYz6.js +0 -13
  301. package/frontend/dist/js/UserManagementPage-b6NZdPTD.js +0 -1
  302. package/frontend/dist/js/api-B0pf9vdR.js +0 -1
  303. package/frontend/dist/js/api-BrzQvj_g.js +0 -3
  304. package/frontend/dist/js/appStore-k_e3JAM3.js +0 -2
  305. package/frontend/dist/js/authStore-BkobbhZS.js +0 -1
  306. package/frontend/dist/js/authStore-ge66S03D.js +0 -2
  307. package/frontend/dist/js/axios-CYrHjdt1.js +0 -1
  308. package/frontend/dist/js/demoMode-qyEGd_UM.js +0 -1
  309. package/frontend/dist/js/markdown-vendor-4lCPqxk5.js +0 -22
  310. package/frontend/dist/js/rolldown-runtime-DWy-cpC1.js +0 -1
  311. package/frontend/dist/js/ui-DuH1cD2f.js +0 -267
  312. package/frontend/dist/js/ui-vendor-BFOABH-A.js +0 -177
  313. package/frontend/dist/js/userService-BndgbS1C.js +0 -1
  314. package/frontend/dist/js/utils-vendor-MBozwMfr.js +0 -6
@@ -0,0 +1,16 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-CEpaJrKd.js";import{n as r}from"./react-vendor-DtQrJICq.js";import{t as i}from"./useQuery-DaEnYfWR.js";import{t as a}from"./logger-1THq8-96.js";import{$ as o,A as s,At as c,Ct as l,Dt as u,E as d,Et as f,H as p,I as m,J as h,L as g,Lt as _,M as v,N as y,Nt as b,O as x,Rt as S,S as C,T as w,U as T,Z as E,_t as D,a as O,bt as k,c as A,ct as j,g as M,gt as N,ht as P,i as ee,it as F,jt as te,kt as ne,n as I,o as re,p as ie,pt as L,q as ae,r as R,rt as oe,st as z,t as se,tt as B,v as ce,vt as le,w as V,wt as ue,x as H,xt as de,yt as fe}from"./ui-vendor-MCs1MDmN.js";import{n as pe}from"./demoMode-BhEpMVh5.js";import{a as U,c as me,d as he,l as ge,n as _e,o as ve,p as ye,s as be,u as xe}from"./api-d05r9G59.js";import{i as Se,n as Ce,r as we,t as W}from"./utils-es0n-47H.js";import{t as G}from"./Button-BmZQkAPD.js";import{A as Te,M as Ee,T as K,_ as q,f as De,g as Oe,j as ke,k as J,p as Ae,u as je,y as Me}from"../assets/index-CDA2f43l.js";import{a as Ne,i as Pe}from"./artifactHtml-CRdkOCnz.js";import{t as Fe}from"./ArtifactContainer-CA523BOS.js";var Ie=e(r(),1),Y=e(n(),1),X=t(),Le=({statistics:e,className:t=``})=>{let[n,r]=(0,Y.useState)(!1),{t:i}=J(),a=e=>{if(e==null)return`N/A`;let t=e/1e6;return t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(2)}s`},o=e=>e?`${e.toFixed(1)} t/s`:`N/A`,s=e.prompt_eval_count||0,c=e.eval_count||0,l=s+c,u=a(e.total_duration),d=o(e.tokens_per_second);return(0,X.jsxs)(`div`,{className:`text-xs text-gray-500 dark:text-dark-500 mt-2 ${t}`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-4 mb-1`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-gray-600 dark:text-dark-600`,children:[(0,X.jsx)(ae,{size:12,className:`text-primary-500`}),c,` tokens`]}),(0,X.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:d}),(0,X.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:u}),e.model&&(0,X.jsx)(`span`,{className:`text-gray-400 dark:text-dark-400 bg-gray-100 dark:bg-dark-200 px-2 py-0.5 rounded-full truncate max-w-32 sm:max-w-48`,title:e.model,children:e.model})]}),(0,X.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-1 text-gray-400 dark:text-dark-400 hover:text-gray-600 dark:hover:text-dark-600 transition-colors`,children:[n?(0,X.jsx)(f,{size:12}):(0,X.jsx)(ue,{size:12}),(0,X.jsx)(`span`,{children:i(`generationStats.details`)})]}),n&&(0,X.jsxs)(`div`,{className:`mt-2 p-3 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg text-xs space-y-2`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2`,children:[(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.promptTokens`)}),` `,s]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generatedTokens`)}),` `,c]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.totalTokens`)}),` `,l]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.speed`)}),` `,d]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.promptEval`)}),` `,a(e.prompt_eval_duration)]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generation`)}),` `,a(e.eval_duration)]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.modelLoad`)}),` `,a(e.load_duration)]}),(0,X.jsxs)(`div`,{className:`text-gray-700 dark:text-dark-700`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.totalTime`)}),` `,u]})]}),e.created_at&&(0,X.jsxs)(`div`,{className:`pt-2 border-t border-gray-200 dark:border-dark-300 text-gray-600 dark:text-dark-600`,children:[(0,X.jsx)(`span`,{className:`font-medium text-gray-800 dark:text-dark-800`,children:i(`generationStats.generatedAt`)}),` `,new Date(e.created_at).toLocaleTimeString()]})]})]})},Re=a(`components:ttsbutton`),ze=null,Be=null,Ve=0,He=300*1e3;async function Ue(){let e=Date.now();return ze!==null&&e-Ve<He?ze:Be||(Be=(async()=>{try{let t=await _e.getModels();return t.success&&t.data&&t.data.length>0?(ze=t.data,Ve=e,t.data):(ze=[],Ve=e,[])}catch{return ze=[],Ve=e,[]}finally{Be=null}})(),Be)}function We(e){return e.split(/(?<=[.!?]["']?\s)|(?<=[.!?]["']?$)/).map(e=>e.trim()).filter(e=>e.length>0)}var Ge=({text:e,className:t,size:n=`sm`})=>{let{t:r}=J(),{preferences:i}=Me(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(!1),_=(0,Y.useRef)([]),v=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{let e=!0;return Ue().then(t=>{e&&(f(t),m(t.length>0))}),()=>{e=!1}},[]);let y=(0,Y.useCallback)(async(e,t,n,i)=>{let a=await _e.generateBase64({model:t,input:e,voice:n,speed:i,response_format:`mp3`});if(!a.success||!a.data?.audio)throw Error(a.message||r(`ttsButton.generateFailed`));let o=`data:${a.data.mimeType};base64,${a.data.audio}`,s=new Audio(o);return h.current=s,new Promise((e,t)=>{s.onended=()=>{h.current=null,e()},s.onerror=()=>{h.current=null,t(Error(r(`ttsButton.playbackFailed`)))},s.play().catch(t)})},[r]),b=(0,Y.useCallback)(async(e,t,n,r)=>{_.current=e,v.current=0,g.current=!1;let i=null,a=async e=>{try{let i=await _e.generateBase64({model:t,input:e,voice:n,speed:r,response_format:`mp3`});return!i.success||!i.data?.audio?null:{audioUrl:`data:${i.data.mimeType};base64,${i.data.audio}`,mimeType:i.data.mimeType}}catch{return null}};e.length>0&&(i=a(e[0]));for(let t=0;t<e.length&&!g.current;t++){v.current=t;try{let n=await i;if(g.current)break;if(i=t+1<e.length?a(e[t+1]):null,!n){Re.warn(`Failed to generate audio for sentence ${t+1}, skipping`);continue}let r=new Audio(n.audioUrl);h.current=r,await new Promise((e,t)=>{r.onended=()=>{h.current=null,e()},r.onerror=()=>{h.current=null,e()},r.play().catch(()=>{e()})})}catch(e){Re.error(`Error playing sentence ${t+1}:`,e)}}},[]),x=(0,Y.useCallback)(()=>{g.current=!0,h.current&&(h.current.pause(),h.current.currentTime=0,h.current=null),o(!1),c(!1)},[]),S=async()=>{if(!s){if(a){x();return}c(!0),u(null),g.current=!1;try{let t=i.ttsSettings,n=t?.model||d[0]?.model||`tts-1`,a=t?.voice||d[0]?.config?.default_voice||`alloy`,s=t?.speed||1;if(t?.streamSentences){let t=We(e);if(t.length===0)throw Error(r(`ttsButton.generateFailed`));c(!1),o(!0),await b(t,n,a,s),g.current||o(!1)}else await y(e,n,a,s),c(!1),o(!0),h.current&&(h.current.onended=()=>{o(!1),h.current=null},h.current.onerror=()=>{u(r(`ttsButton.playbackFailed`)),o(!1),h.current=null})}catch(e){u(e instanceof Error?e.message:r(`ttsButton.generateFailed`)),Re.error(`TTS error:`,e),o(!1),c(!1)}}};if((0,Y.useEffect)(()=>()=>{g.current=!0,h.current&&(h.current.pause(),h.current=null)},[]),p===!1||p===null)return null;let C={sm:`h-6 w-6 p-1`,md:`h-8 w-8 p-1.5`,lg:`h-10 w-10 p-2`},w={sm:`h-3.5 w-3.5`,md:`h-4 w-4`,lg:`h-5 w-5`};return(0,X.jsx)(`button`,{onClick:S,disabled:s||!e,title:l||r(a?`ttsButton.stopSpeaking`:s?`ttsButton.generatingSpeech`:`ttsButton.readAloud`),className:W(`rounded-full transition-all duration-200`,`hover:bg-gray-100 dark:hover:bg-dark-200`,`focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-1`,`disabled:opacity-50 disabled:cursor-not-allowed`,l?`text-red-500 dark:text-red-400`:a?`text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-gray-400`,C[n],t),children:s?(0,X.jsx)(T,{className:W(w[n],`animate-spin`)}):a?(0,X.jsx)(M,{className:w[n]}):l?(0,X.jsx)(ee,{className:w[n]}):(0,X.jsx)(O,{className:w[n]})})},Ke=/```([^\n`]*)\n([\s\S]*?)\n```/g,qe=/[\w@./-]+\.(?:html?|css|mjs|js|jsx|ts|tsx|svg|json|py)/i,Je=[`html`,`react`,`svg`,`mermaid`,`chart`,`code`,`text`,`json`],Ye=[{regex:/<artifact\s+type="([^"]+)"\s+title="([^"]+)"[^>]*>([\s\S]*?)<\/artifact>/gi,extract:e=>({type:tt(e[1]),title:Xe(e[2]).trim()||`Artifact`,content:e[3].trim()})},{regex:/<artifact\s+type="([^"]+)"[^>]*>([\s\S]*?)<\/artifact>/gi,extract:e=>{let t=tt(e[1]);return{type:t,title:`${t.toUpperCase()} Artifact`,content:e[2].trim()}}}];function Xe(e){if(typeof document<`u`){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent||t.innerText||``}return e.replace(/<[^>]+>/g,``).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`)}function Ze(e){let t=e.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(t)return Xe(t[1]).trim()||null;let n=e.match(/<h1[^>]*>([\s\S]*?)<\/h1>/i);return n&&Xe(n[1]).trim()||null}function Qe(e){let t=e.match(/(?:function|const)\s+(\w+)/);if(t)return t[1];let n=e.match(/class\s+(\w+)/);return n?n[1]:null}function $e(e){if(e.includes(`def main(`))return`Python Script`;let t=e.match(/class\s+(\w+)/);if(t)return`${t[1]} Class`;let n=e.match(/def\s+(\w+)/);return n&&n[1]!==`__init__`?`${n[1]} Function`:null}function et(e){let t=e.match(/function\s+(\w+)/);if(t)return`${t[1]} Function`;let n=e.match(/(?:const|let)\s+(\w+)\s*=/);return n?n[1]:null}function tt(e){let t=e.trim().toLowerCase();return Je.includes(t)?t:`text`}function Z(e){if(!e)return;let t=e.trim().toLowerCase().replace(/^\./,``).replace(/[,:;]+$/,``);switch(t){case`htm`:case`html`:return`html`;case`js`:case`mjs`:case`javascript`:return`javascript`;case`jsx`:case`tsx`:case`react`:return`react`;case`ts`:case`typescript`:return`typescript`;case`py`:case`python`:return`python`;case`css`:case`svg`:case`json`:return t;default:return t||void 0}}function nt(e){let t=[],n=new RegExp(Ke),r;for(;(r=n.exec(e))!==null;){let n=r[1].trim(),i=rt(n,at(e,r.index));t.push({raw:r[0],info:n,content:r[2].trim(),start:r.index,end:r.index+r[0].length,language:i.language,fileName:i.fileName})}return t}function rt(e,t){let n=it(e)||t,r=e.split(/\s+/).filter(Boolean)[0]?.replace(/[{}[\]()]/g,``);return{language:(r&&!qe.test(r)&&!r.includes(`=`)?Z(r):void 0)||Z(st(n)),fileName:n}}function it(e){let t=e.match(/(?:file(?:name)?|path|name)\s*=\s*["']?([^"'\s]+)["']?/i);if(t&&qe.test(t[1]))return ot(t[1]);let n=e.match(qe);return n?ot(n[0]):void 0}function at(e,t){let n=e.slice(Math.max(0,t-180),t).split(`
2
+ `).slice(-3).reverse();for(let e of n){let t=e.trim().replace(/^#{1,6}\s*/,``).replace(/^[-*]\s*/,``).replace(/[::]\s*$/,``).match(qe);if(t)return ot(t[0])}}function ot(e){return e.replace(/^["'`]+|["'`:]+$/g,``)}function st(e){return e?.match(/\.([a-z0-9]+)$/i)?.[1]}function ct(e){return e?.split(/[\\/]/).pop()}function Q(e){let t=ct(e);if(!t)return null;let n=t.replace(/\.[^.]+$/,``);return/^(index|main|app)$/i.test(n)?null:n.replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function lt(e){let t=Date.now();return{...e,id:`artifact-${t}-${Math.random().toString(36).slice(2,11)}`,createdAt:t,updatedAt:t}}function ut(e){let t=Z(e.language)||Z(st(e.fileName));switch(t){case`html`:return{type:`html`,title:Ze(e.content)||Q(e.fileName)||`HTML Document`};case`svg`:return{type:`svg`,title:Q(e.fileName)||`SVG Image`};case`react`:return{type:`react`,title:Qe(e.content)||Q(e.fileName)||`React Component`,language:`jsx`};case`json`:return{type:`json`,title:Q(e.fileName)||`JSON Data`};case`python`:return{type:`code`,title:$e(e.content)||Q(e.fileName)||`Python Code`,language:`python`};case`css`:return{type:`code`,title:Q(e.fileName)||`CSS Styles`,language:`css`};case`javascript`:return{type:`code`,title:et(e.content)||Q(e.fileName)||`JavaScript Code`,language:`javascript`};case`typescript`:return{type:`code`,title:Q(e.fileName)||`TypeScript Code`,language:`typescript`};default:return t?{type:`code`,title:Q(e.fileName)||`${t.toUpperCase()} Code`,language:t}:null}}function dt(e){return(Z(e.language)||Z(st(e.fileName)))===`html`}function ft(e){return(Z(e.language)||Z(st(e.fileName)))===`css`}function pt(e){return(Z(e.language)||Z(st(e.fileName)))===`javascript`}function mt(e){let t=nt(e),n=t.filter(dt);if(n.length===0)return null;let r=t.filter(ft),i=t.filter(pt);if(r.length===0&&i.length===0)return null;let a=n.find(e=>/(^|[/\\])index\.html?$/i.test(e.fileName||``))||n[0],o=Ne(ht(a.content,r,i),r.map(e=>e.content),i.map(e=>e.content));return bt(o,`html`)?{artifact:lt({type:`html`,title:Ze(o)||Q(a.fileName)||`Interactive HTML App`,description:`Bundled generated HTML, CSS, and JavaScript files into one runnable artifact.`,content:o}),ranges:[a,...r,...i]}:null}function ht(e,t,n){let r=e;for(let e of t){let t=ct(e.fileName);t&&(r=r.replace(RegExp(`<link\\b[^>]*href=["'][^"']*${yt(t)}["'][^>]*>`,`gi`),``))}for(let e of n){let t=ct(e.fileName);t&&(r=r.replace(RegExp(`<script\\b[^>]*src=["'][^"']*${yt(t)}["'][^>]*>\\s*<\\/script>`,`gi`),``))}return r}function gt(e){let t=/<!doctype\s+html|<html[\s>]/i.exec(e);if(!t||t.index===void 0)return null;let n=nt(e);if(_t(t.index,n))return null;let r=t.index,i=/<\/html>/gi;i.lastIndex=r;let a=i.exec(e),o=a?a.index+a[0].length:e.length,s=e.slice(r,o).trim();return bt(s,`html`)?{artifact:lt({type:`html`,title:Ze(s)||`HTML Document`,content:s}),ranges:[{start:r,end:o}]}:null}function _t(e,t){return t.some(t=>e>=t.start&&e<=t.end)}function vt(e,t){return[...t].sort((e,t)=>t.start-e.start).reduce((e,t)=>`${e.slice(0,t.start)}${e.slice(t.end)}`,e)}function yt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function bt(e,t){if(t===`html`){let t=e.trim(),n=/<[^>]+>/.test(t),r=/<(canvas|script|style|button|form|input|select|textarea|video|audio)\b/i.test(t)||/\bon(?:click|input|submit|keydown|keyup|mousemove)=/i.test(t);return n&&(Pe(t)||t.length>160||r)}if(t===`svg`)return/<svg[^>]*>/.test(e);if(t===`react`)return/<[A-Z][^>]*>/.test(e)||/return\s*\(/.test(e);if(t===`json`)try{return JSON.parse(e),e.trim().length>100}catch{return!1}if(t===`code`){let t=e.split(`
3
+ `).length,n=e.trim().length,r=/function|class|def |import |from |const |let |var |if |for |while |try |catch/.test(e);return(n>500||t>15)&&r}return e.trim().length>200}function xt(e){let t=[],n=e;for(let e of Ye){e.regex.lastIndex=0;let r=[],i;for(;(i=e.regex.exec(n))!==null;){let n=e.extract(i);bt(n.content,n.type)&&(t.push(lt({type:n.type,title:n.title,content:n.content})),r.push({start:i.index,end:i.index+i[0].length}))}n=vt(n,r)}let r=mt(n);for(;r;)t.push(r.artifact),n=vt(n,r.ranges),r=mt(n);let i=gt(n);i&&(t.push(i.artifact),n=vt(n,i.ranges));let a=nt(n),o=[];for(let e of a){let n=ut(e);!n||!bt(e.content,n.type)||(t.push(lt({type:n.type,title:n.title,content:e.content,language:n.language})),o.push(e))}return n=vt(n,o),{content:n.trim(),artifacts:t}}var St=a(`components:chat-message`),Ct=({message:e,isStreaming:t=!1,className:n,isLastAssistantMessage:r=!1,onRegenerate:i})=>{let{t:a}=J(),o=e.role===`user`,s=e.role===`system`,{preferences:c}=Me(),{user:p}=Oe(),{setSystemMessage:m,getCurrentPersona:h}=K(),g=h(),[_,y]=(0,Y.useState)(!1),[b,S]=(0,Y.useState)(e.content),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)(!1),[P,ee]=(0,Y.useState)(!1),F=(0,Y.useRef)(null),te=(0,Y.useRef)(t),ie=(0,Y.useRef)(!1),L=async()=>{try{await navigator.clipboard.writeText(e.content),ee(!0),setTimeout(()=>ee(!1),2e3)}catch(e){St.error(`Failed to copy message:`,e)}},{thinkingContent:ae,parsedContent:R,artifacts:oe}=(0,Y.useMemo)(()=>{if(o||s||!e.content)return{thinkingContent:null,parsedContent:e.content,artifacts:e.artifacts||[]};let n=Se(e.content),r=n.content;if(e.artifacts&&e.artifacts.length>0)return{thinkingContent:n.thinking,parsedContent:r,artifacts:e.artifacts};if(!t){let e=xt(r);return{thinkingContent:n.thinking,parsedContent:e.content,artifacts:e.artifacts}}return{thinkingContent:n.thinking,parsedContent:r,artifacts:[]}},[e.content,e.artifacts,o,s,t]);(0,Y.useEffect)(()=>{let e=te.current&&!t;return te.current=t,e&&!ie.current&&!o&&!s&&R&&c.ttsSettings?.enabled&&c.ttsSettings?.autoPlay&&(ie.current=!0,(async()=>{N(!0);try{let e=await _e.generateBase64({model:c.ttsSettings?.model||`tts-1`,input:R,voice:c.ttsSettings?.voice||`alloy`,speed:c.ttsSettings?.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);F.current=n,n.onended=()=>{N(!1),F.current=null},n.onerror=()=>{N(!1),F.current=null},await n.play()}}catch(e){St.error(`Auto-play TTS failed:`,e),N(!1)}})()),()=>{F.current&&(F.current.pause(),F.current=null)}},[t,o,s,R,c.ttsSettings]);let z=()=>s?a(`chatMessage.system`):o?c.showUsername&&p?.username?p.username:a(`chatMessage.you`):g?.name?g.name:e.model||a(`chatMessage.assistant`),se=()=>{y(!0),S(e.content)},B=async()=>{D(!0);try{m(b),y(!1),St.debug(`✅ System message updated:`,b)}catch(e){St.error(`Failed to save system message:`,e)}finally{D(!1)}},ce=()=>{y(!1),S(e.content)},V=(e,t=100)=>e.length<=t?e:e.substring(0,t)+`...`,ue=s&&e.content.length>100;return(0,X.jsxs)(`div`,{className:W(`flex transition-colors group my-2`,o?`justify-end`:`justify-start`,n),children:[(0,X.jsxs)(`div`,{className:W(`flex gap-3 sm:gap-4`,o?`flex-row-reverse max-w-[85%] sm:max-w-[75%]`:s?`w-full`:`max-w-[85%] sm:max-w-[75%]`),children:[!s&&(0,X.jsx)(`div`,{className:W(`flex shrink-0 items-center justify-center shadow-sm overflow-hidden mt-1`,o?`h-8 w-8 rounded-full bg-primary-600 text-white`:g?.avatar?`h-8 w-8 rounded-full bg-white dark:bg-dark-100`:`h-8 px-2 rounded-full bg-white dark:bg-dark-100`),children:o?p?.avatar?(0,X.jsx)(`img`,{src:p.avatar,alt:p.username,className:`w-full h-full object-cover`}):(0,X.jsx)(re,{className:`h-4 w-4`}):g?.avatar?(0,X.jsx)(`img`,{src:g.avatar,alt:g.name||`Assistant`,className:`w-full h-full object-cover`}):(0,X.jsx)(`span`,{className:`libre-brand text-xs text-gray-700 dark:text-gray-200`,children:`Libre`})}),(0,X.jsxs)(`div`,{className:W(`flex-1 min-w-0 rounded-2xl sm:rounded-3xl p-4 sm:p-5`,o?`bg-primary-600/90 dark:bg-primary-700/90 text-white`:s?`bg-transparent p-2 py-3`:`bg-white/95 dark:bg-dark-100/95 backdrop-blur-md shadow-sm border border-gray-200/50 dark:border-dark-300/50`),children:[!s&&(0,X.jsxs)(`div`,{className:W(`flex items-center gap-3 mb-2`,o&&`flex-row-reverse`),children:[(0,X.jsx)(`span`,{className:W(`text-sm font-semibold`,o?`text-white/90`:`text-gray-900 dark:text-dark-800`),children:z()}),e.model&&!o&&g?.name&&(0,X.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-dark-600 bg-gray-100 dark:bg-dark-200 px-2 py-0.5 rounded-full truncate max-w-32 sm:max-w-48`,title:e.model,children:e.model}),(0,X.jsx)(`span`,{className:W(`text-xs`,o?`text-white/60`:`text-gray-400 dark:text-dark-500`),children:Ce(e.timestamp)}),!o&&!s&&!t&&R&&(0,X.jsx)(Ge,{text:R,size:`sm`,className:W(`transition-opacity`,M?`opacity-100 text-primary-600 dark:text-primary-400`:`opacity-0 group-hover:opacity-100`)}),!s&&!t&&(0,X.jsx)(`button`,{onClick:L,className:`p-1 rounded hover:bg-gray-100 dark:hover:bg-dark-200 transition-opacity opacity-0 group-hover:opacity-100`,title:a(P?`chatMessage.copied`:`chatMessage.copyMessage`),children:P?(0,X.jsx)(u,{className:`h-3.5 w-3.5 text-green-500 dark:text-green-400`}):(0,X.jsx)(le,{className:`h-3.5 w-3.5 text-gray-500 dark:text-gray-400`})}),!o&&!s&&!t&&r&&i&&(0,X.jsx)(`button`,{onClick:i,className:`p-1 rounded hover:bg-gray-100 dark:hover:bg-dark-200 transition-opacity opacity-0 group-hover:opacity-100`,title:a(`chatMessage.regenerateResponse`),children:(0,X.jsx)(x,{className:`h-3.5 w-3.5 text-gray-500 dark:text-gray-400`})})]}),(0,X.jsxs)(`div`,{className:W(o?`text-white`:`text-gray-700 dark:text-dark-700`),children:[e.images&&e.images.length>0&&(0,X.jsx)(`div`,{className:`mb-3 grid grid-cols-2 sm:grid-cols-3 gap-2 max-w-lg`,children:e.images.map((e,t)=>(0,X.jsx)(`div`,{className:`aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:(0,X.jsx)(`img`,{src:e,alt:`Uploaded image ${t+1}`,className:`w-full h-full object-cover cursor-pointer hover:opacity-90 transition-opacity`,onClick:()=>T(e)})},t))}),o?(0,X.jsx)(`p`,{className:`whitespace-pre-wrap leading-relaxed`,children:e.content}):s?(0,X.jsxs)(`div`,{className:`bg-gray-50/30 dark:bg-dark-50/30 rounded-md p-2 border border-gray-100/50 dark:border-dark-200/50 relative z-0`,children:[(0,X.jsxs)(`div`,{className:`text-xs font-medium mb-1 text-gray-500 dark:text-gray-400 flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(C,{className:`h-2.5 w-2.5 opacity-50`}),a(`chatMessage.system`)]}),(0,X.jsx)(`div`,{className:`flex items-center gap-1`,children:_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{onClick:B,disabled:E,className:`p-1 hover:bg-gray-100 dark:hover:bg-dark-200 rounded transition-colors disabled:opacity-50`,title:a(`chatMessage.saveChanges`),children:(0,X.jsx)(d,{className:`h-3 w-3 text-green-600 dark:text-green-400`})}),(0,X.jsx)(`button`,{onClick:ce,disabled:E,className:`p-1 hover:bg-gray-100 dark:hover:bg-dark-200 rounded transition-colors disabled:opacity-50`,title:a(`chatMessage.cancelEditing`),children:(0,X.jsx)(I,{className:`h-3 w-3 text-red-600 dark:text-red-400`})})]}):(0,X.jsx)(`button`,{onClick:se,className:`p-1 hover:bg-gray-100 dark:hover:bg-dark-200 rounded transition-colors`,title:a(`chatMessage.editSystemMessage`),children:(0,X.jsx)(v,{className:`h-3 w-3 text-gray-600 dark:text-gray-400`})})})]}),_?(0,X.jsx)(`textarea`,{value:b,onChange:e=>S(e.target.value),className:`w-full min-h-[100px] p-3 text-sm text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400 focus:border-transparent`,placeholder:a(`chatMessage.systemMessagePlaceholder`),disabled:E}):(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`whitespace-pre-wrap leading-relaxed text-xs text-gray-500 dark:text-gray-400`,children:O?e.content:V(e.content)}),ue&&(0,X.jsx)(`button`,{onClick:()=>k(!O),className:`mt-1 flex items-center gap-1 text-xs text-gray-400 dark:text-gray-500 hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:O?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{className:`h-3 w-3`}),a(`chatMessage.showLess`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(f,{className:`h-3 w-3`}),a(`chatMessage.showMore`)]})})]})]}):(0,X.jsxs)(`div`,{className:`relative`,children:[ae&&(0,X.jsxs)(`div`,{className:`mb-3`,children:[(0,X.jsxs)(`button`,{onClick:()=>j(!A),className:`flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,children:[(0,X.jsx)(ne,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`font-medium`,children:a(`chatMessage.thinking`)}),A?(0,X.jsx)(l,{className:`h-4 w-4`}):(0,X.jsx)(f,{className:`h-4 w-4`})]}),A&&(0,X.jsx)(`div`,{className:`mt-2 p-3 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,X.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-300 whitespace-pre-wrap leading-relaxed`,children:ae})})]}),(0,X.jsx)(je,{content:R,isStreaming:t}),t&&!R.includes("```")&&(0,X.jsx)(`div`,{className:`inline-block w-2 h-5 bg-primary-500 animate-pulse ml-1 rounded-sm`})]}),!o&&!s&&oe.length>0&&(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Fe,{artifacts:oe})}),!o&&!s&&e.statistics&&(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(Le,{statistics:e.statistics})})]})]})]}),w&&(0,Ie.createPortal)((0,X.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm`,onClick:()=>T(null),children:[(0,X.jsx)(`button`,{className:`absolute top-6 right-6 p-3 bg-white/20 hover:bg-white/40 rounded-full text-white transition-all shadow-lg border border-white/30`,onClick:e=>{e.stopPropagation(),T(null)},children:(0,X.jsx)(I,{className:`h-7 w-7`})}),(0,X.jsx)(`img`,{src:w,alt:a(`chatMessage.fullSizeImage`),className:`max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl`,onClick:e=>e.stopPropagation()})]}),document.body)]})},wt=({messages:e,isStreaming:t=!1,streamingMessage:n,streamingMessageId:r,isLastAssistantMessage:i=!1,onRegenerate:a,onSelectBranch:o,className:s})=>{if(e.length===1){let o=e[0],c=t&&r===o.id;return(0,X.jsx)(Ct,{message:c&&n?{...o,content:n}:o,isStreaming:c,isLastAssistantMessage:i,onRegenerate:a,className:s})}return(0,X.jsxs)(`div`,{className:W(`relative py-1`,s),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 px-4 pb-2 text-[10px] text-gray-400 dark:text-gray-500`,children:[(0,X.jsx)(oe,{className:`h-3 w-3`}),(0,X.jsxs)(`span`,{children:[e.length,` variants`]})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 px-4`,children:e.map((e,s)=>{let c=e.isActive!==!1,l=t&&r===e.id,d=l&&n?{...e,content:n}:e;return(0,X.jsxs)(`div`,{className:W(`relative rounded-lg overflow-hidden transition-all duration-200`,`border shadow-sm`,c||l?`border-primary-300 dark:border-primary-600 shadow-primary-100 dark:shadow-primary-900/20`:`border-gray-200 dark:border-dark-300 hover:border-gray-300 dark:hover:border-dark-400`,!c&&!l&&`cursor-pointer hover:shadow-md`),onClick:()=>!c&&!l&&o?.(e.id),children:[(0,X.jsxs)(`div`,{className:W(`flex items-center justify-between px-2.5 py-1 text-[11px]`,c||l?`bg-primary-50/80 dark:bg-primary-900/20 text-primary-600 dark:text-primary-400`:`bg-gray-50/80 dark:bg-dark-100/80 text-gray-500 dark:text-gray-500`),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:s+1}),l&&(0,X.jsx)(`span`,{className:`text-[10px] opacity-70 animate-pulse`,children:`generating...`})]}),c&&!l&&(0,X.jsx)(u,{className:`h-3 w-3`}),!c&&!l&&(0,X.jsx)(`span`,{className:`text-[10px] opacity-50`,children:`select`})]}),(0,X.jsx)(`div`,{className:W(`bg-white dark:bg-dark-50`,!c&&!l&&`opacity-80`),children:(0,X.jsx)(Ct,{message:d,isStreaming:l,isLastAssistantMessage:i&&(c||l),onRegenerate:c&&!t?a:void 0,className:`!bg-transparent !p-3 !text-sm`})})]},e.id)})})]})},Tt={web_search:w,web_fetch:B,exec:ie,browser:B,Read:j,Write:j,Edit:j,image:h,memory_search:N,memory_get:N,working:R,thinking:R,default:R},Et={web_search:`Searching the web`,web_fetch:`Fetching page`,exec:`Running command`,browser:`Using browser`,Read:`Reading file`,Write:`Writing file`,Edit:`Editing file`,image:`Analyzing image`,memory_search:`Searching memory`,memory_get:`Reading memory`,cron:`Managing schedule`,message:`Sending message`,tts:`Generating speech`,nodes:`Checking devices`,sessions_spawn:`Spawning agent`,canvas:`Rendering canvas`,process:`Managing process`,working:`Using tools`,thinking:`Thinking`},Dt=({tools:e,className:t})=>{if(e.length===0)return null;let n=e.filter(e=>e.phase!==`result`&&e.phase!==`done`);return n.length===0?null:(0,X.jsx)(`div`,{className:W(`flex flex-col gap-1 py-2 px-1`,t),children:n.map(e=>{let t=Tt[e.name]||Tt.default,n=Et[e.name]||`Using ${e.name}`,r=e.phase===`result`;return(0,X.jsxs)(`div`,{className:W(`flex items-center gap-2 text-sm transition-all duration-300`,r?`text-green-600 dark:text-green-400 opacity-60`:`text-gray-500 dark:text-gray-400`),children:[(0,X.jsx)(`div`,{className:W(`flex items-center justify-center w-5 h-5`,!r&&`animate-spin-slow`),children:(0,X.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(`span`,{className:`text-xs font-medium`,children:r?`✓ ${n}`:`${n}…`}),!r&&(0,X.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,X.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`0ms`}}),(0,X.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`150ms`}}),(0,X.jsx)(`div`,{className:`w-1 h-1 bg-current rounded-full animate-bounce`,style:{animationDelay:`300ms`}})]})]},e.toolCallId)})})};a(`components:chat-messages`);var Ot=({messages:e,streamingMessage:t,streamingMessageId:n,isStreaming:r=!1,toolActivities:i=[],className:a,onRegenerate:o,onSelectBranch:s})=>{let{t:c}=J(),l=(0,Y.useRef)(null),u=(0,Y.useRef)(),d=(0,Y.useRef)(null),f=(0,Y.useRef)(!1),[p,m]=(0,Y.useState)(!1),h=(0,Y.useMemo)(()=>{let t=[],n=new Set,r=[...e].sort((e,t)=>e.role===`system`&&t.role!==`system`?-1:t.role===`system`&&e.role!==`system`?1:e.parentId===t.parentId?(e.branchIndex||0)-(t.branchIndex||0):e.timestamp-t.timestamp);for(let i of r){if(n.has(i.id))continue;let r=i.parentId;if(r){let a=t.findIndex(e=>e.id===r);if(a>=0)t[a].messages.push(i);else{let a=e.find(e=>e.id===r);a&&!n.has(r)?(t.push({id:r,messages:[a,i],messageIndex:t.length}),n.add(r)):t.push({id:i.id,messages:[i],messageIndex:t.length})}n.add(i.id)}else{let r=e.filter(e=>e.parentId===i.id);r.length>0?(t.push({id:i.id,messages:[i,...r],messageIndex:t.length}),n.add(i.id),r.forEach(e=>n.add(e.id))):(t.push({id:i.id,messages:[i],messageIndex:t.length}),n.add(i.id))}}return t.sort((e,t)=>{let n=e.messages[0],r=t.messages[0];return n.role===`system`&&r.role!==`system`?-1:r.role===`system`&&n.role!==`system`?1:n.timestamp-r.timestamp})},[e]),g=(0,Y.useCallback)((e=!1)=>{f.current&&!e||l.current?.scrollIntoView({behavior:`smooth`})},[]),_=(0,Y.useCallback)(()=>{let t=d.current;if(!t)return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t,a=r-n-i<100;f.current=!a,m(!a&&e.length>0)},[e.length]),v=(0,Y.useRef)(e.length);if((0,Y.useEffect)(()=>{e.length>v.current&&!f.current&&g(),v.current=e.length},[e.length,g]),(0,Y.useEffect)(()=>{r&&t&&!f.current&&requestAnimationFrame(()=>{let e=d.current;e&&(e.scrollTop=e.scrollHeight)})},[r,t]),(0,Y.useEffect)(()=>{let e=u.current;return()=>{e&&clearTimeout(e)}},[]),e.length===0&&!r)return(0,X.jsx)(`div`,{className:W(`flex-1 flex items-center justify-center p-4 sm:p-8`,a),children:(0,X.jsxs)(`div`,{className:`text-center text-gray-500 dark:text-dark-600 max-w-md`,children:[(0,X.jsx)(`div`,{className:`text-5xl sm:text-7xl mb-4 sm:mb-6 opacity-60`,children:`💬`}),(0,X.jsx)(`h3`,{className:`text-lg sm:text-xl font-semibold mb-2 sm:mb-3 text-gray-700 dark:text-dark-700`,children:c(`chatMessage.startConversation`)}),(0,X.jsx)(`p`,{className:`text-sm leading-relaxed px-4`,children:c(`chatMessage.startConversationDescription`)})]})});let y=-1;for(let e=h.length-1;e>=0;e--)if(h[e].messages.some(e=>e.role===`assistant`)){y=e;break}return(0,X.jsxs)(`div`,{ref:d,onScroll:_,className:W(`relative flex-1 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-600`,`scrollbar-track-transparent hover:scrollbar-thumb-gray-400 dark:hover:scrollbar-thumb-gray-500`,`overscroll-behavior-y-contain`,`[-webkit-overflow-scrolling:touch]`,a),style:{WebkitOverflowScrolling:`touch`,overscrollBehaviorY:`contain`,WebkitAppRegion:`no-drag`},children:[(0,X.jsxs)(`div`,{className:`max-w-5xl mx-auto px-3 sm:px-4 md:px-6 w-full min-w-0`,children:[h.map((e,i)=>{let a=i===y,c=r&&e.messages.some(e=>e.id===n);if(e.messages.length===1){let s=e.messages[0],c=r&&s.id===n;return(0,X.jsx)(Ct,{message:c&&t?{...s,content:t}:s,isStreaming:c,isLastAssistantMessage:a,onRegenerate:a?o:void 0,className:i===0?`mt-3 sm:mt-4 md:mt-6`:``},s.id)}return(0,X.jsx)(wt,{messages:e.messages,isStreaming:c,streamingMessage:t,streamingMessageId:n||void 0,isLastAssistantMessage:a,onRegenerate:a?o:void 0,onSelectBranch:s,className:i===0?`mt-3 sm:mt-4 md:mt-6`:``},e.id)}),r&&i.length>0&&(0,X.jsx)(Dt,{tools:i,className:`ml-10 sm:ml-12`}),(0,X.jsx)(`div`,{ref:l,className:`h-3 sm:h-4 md:h-6`})]}),p&&(0,X.jsxs)(`button`,{onClick:()=>{f.current=!1,l.current?.scrollIntoView({behavior:`smooth`}),m(!1)},className:W(`absolute bottom-4 left-1/2 -translate-x-1/2 z-10`,`flex items-center justify-center gap-1.5`,`px-3 py-2 rounded-full`,`bg-white/95 dark:bg-dark-100/95`,`border border-gray-200/50 dark:border-dark-300/50`,`shadow-lg backdrop-blur-sm`,`text-gray-600 dark:text-dark-600`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`hover:text-gray-900 dark:hover:text-dark-800`,`transition-all duration-200`,`hover:shadow-xl hover:scale-105 active:scale-95`),title:c(`chatMessage.scrollToBottom`),children:[(0,X.jsx)(b,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-xs font-medium`,children:c(`chatMessage.newMessages`)})]})]})};function kt(e){let t=(e.match(/```/g)||[]).length,n=t%2==1,r=null;if(n){let t=e.lastIndexOf("```");if(t!==-1){let n=e.slice(t+3).match(/^(\w+)/);n&&(r=n[1])}}return{hasCodeBlocks:t>0,isInCodeBlock:n,language:r}}var At=Y.forwardRef(({value:e,onChange:t,className:n,placeholder:r,disabled:i,onKeyDown:a,...o},s)=>{let{hasCodeBlocks:c,isInCodeBlock:l,language:u}=(0,Y.useMemo)(()=>kt(e),[e]);return(0,X.jsxs)(`div`,{className:`relative w-full`,children:[(0,X.jsx)(`textarea`,{ref:s,value:e,onChange:t,onKeyDown:a,placeholder:r,disabled:i,className:W(`w-full resize-none transition-all duration-200`,l&&[`font-mono text-[13px]`,`bg-gray-50 dark:bg-dark-100/50`,`rounded-lg`],n),...o}),c&&(0,X.jsx)(`div`,{className:`absolute right-0 top-0 pointer-events-none flex items-center gap-1`,children:(0,X.jsxs)(`div`,{className:W(`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-500 dark:text-gray-400`,`border border-gray-200/50 dark:border-dark-300/50`,l&&`animate-pulse`),children:[(0,X.jsx)(k,{className:`h-3 w-3`}),u&&(0,X.jsx)(`span`,{children:u}),!u&&l&&(0,X.jsx)(`span`,{children:`code`})]})})]})});At.displayName=`CodeAwareTextarea`;var jt=a(`components:media-upload`),Mt=({images:e,onImagesChange:t,maxImages:n=5,sessionId:r,onDocumentUploaded:i,disabled:a=!1,className:o})=>{let{t:s}=J(),c=(0,Y.useRef)(null),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)([]),h=async e=>{if(!(!e||a))for(let t=0;t<e.length;t++){let n=e[t];n.type.startsWith(`image/`)?await g(n):n.type.includes(`pdf`)||n.type.includes(`text`)?await _(n):S.error(`File type not supported: ${n.name}`)}},g=async r=>{if(n-e.length<=0){S.error(`Maximum ${n} images allowed`);return}if(r.size>10*1024*1024){S.error(`Image ${r.name} is too large (max 10MB)`);return}let i=new FileReader;i.onload=n=>{n.target?.result&&t([...e,n.target.result])},i.readAsDataURL(r)},_=async e=>{if(e.size>10*1024*1024){S.error(`File size must be less than 10MB`);return}f(!0);try{let t=await he.uploadDocument(e,r);if(t.success&&t.data){let n=t.data;m(e=>[...e,n]),i?.(n),S.success(`Document "${e.name}" uploaded`)}else S.error(t.error||`Failed to upload document`)}catch(e){jt.error(`Document upload error:`,e),S.error(`Failed to upload document`)}finally{f(!1)}},v=e=>{e.preventDefault(),a||u(!0)},y=e=>{e.preventDefault(),u(!1)},b=e=>{e.preventDefault(),u(!1),a||h(e.dataTransfer.files)},x=n=>{t(e.filter((e,t)=>t!==n))},C=async e=>{try{let t=await he.deleteDocument(e);t.success?(m(t=>t.filter(t=>t.id!==e)),S.success(`Document removed`)):S.error(t.error||`Failed to remove document`)}catch(e){jt.error(`Error removing document:`,e),S.error(`Failed to remove document`)}},w=e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(1))+` `+n[r]},E=e.length>0||p.length>0;return(0,X.jsxs)(`div`,{className:W(`space-y-3`,o),children:[(0,X.jsxs)(`div`,{className:W(`border-2 border-dashed rounded-xl p-6 transition-all duration-200 cursor-pointer`,`border-gray-300 dark:border-gray-600`,`hover:border-primary-400 dark:hover:border-primary-500`,l&&`border-primary-500 dark:border-primary-400 bg-primary-50/50 dark:bg-primary-900/10`,a&&`opacity-50 cursor-not-allowed`),onDragOver:v,onDragLeave:y,onDrop:b,onClick:()=>!a&&c.current?.click(),children:[(0,X.jsx)(`input`,{ref:c,type:`file`,multiple:!0,accept:`image/*,.pdf,.txt`,onChange:e=>{h(e.target.files),e.target.value=``},className:`hidden`,disabled:a}),(0,X.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[d?(0,X.jsx)(T,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2 animate-spin`}):(0,X.jsx)(A,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2`}),(0,X.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:[s(`chat.mediaUpload.dropImagesHere`),` `,(0,X.jsx)(`span`,{className:`text-primary-600 dark:text-primary-400 font-medium`,children:s(`chat.mediaUpload.browse`)})]}),(0,X.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:s(`chat.mediaUpload.supportedFormats`)})]})]}),E&&(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.map((e,t)=>(0,X.jsxs)(`div`,{className:`relative group w-16 h-16 rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[(0,X.jsx)(`img`,{src:e,alt:`Upload ${t+1}`,className:`w-full h-full object-cover`}),(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),x(t)},className:`absolute top-0.5 right-0.5 p-0.5 rounded-full bg-black/60 hover:bg-black/80 text-white opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,X.jsx)(I,{className:`h-3 w-3`})})]},`img-${t}`)),p.map(e=>(0,X.jsxs)(`div`,{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[e.fileType===`pdf`?(0,X.jsx)(j,{className:`w-4 h-4 text-red-500 flex-shrink-0`}):(0,X.jsx)(z,{className:`w-4 h-4 text-blue-500 flex-shrink-0`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-gray-900 dark:text-gray-100 truncate max-w-[100px]`,children:e.filename}),(0,X.jsx)(`p`,{className:`text-[10px] text-gray-500 dark:text-gray-400`,children:w(e.size)})]}),(0,X.jsx)(`button`,{onClick:t=>{t.stopPropagation(),C(e.id)},className:`p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-red-500 transition-colors`,children:(0,X.jsx)(I,{className:`h-3 w-3`})})]},e.id))]})]})},Nt=a(`components:document-indicator`),Pt=({sessionId:e,className:t=``})=>{let[n,r]=(0,Y.useState)([]);if((0,Y.useEffect)(()=>{e&&(async()=>{try{let t=await he.getDocuments(e);t.success&&t.data&&r(t.data)}catch(e){Nt.error(`Failed to load documents:`,e)}})()},[e]),!e||n.length===0)return null;let i=n.reduce((e,t)=>e+t.size,0);return(0,X.jsxs)(`div`,{className:`
4
+ inline-flex items-center space-x-1 px-2 py-1
5
+ bg-blue-50 dark:bg-blue-900/20
6
+ border border-blue-200 dark:border-blue-800
7
+ rounded-md text-xs
8
+ ${t}
9
+ `,title:`${n.length} document(s) available for context - Total: ${(e=>{if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(1))+` `+n[r]})(i)}`,children:[(0,X.jsx)(te,{className:`w-3 h-3 text-blue-600 dark:text-blue-400`}),(0,X.jsxs)(`span`,{className:`text-blue-700 dark:text-blue-300 font-medium`,children:[n.length,` doc`,n.length===1?``:`s`]})]})},Ft=a(`components:structured-output`),It=[{key:`none`,value:null},{key:`json`,value:`json`},{key:`list`,value:{type:`object`,properties:{items:{type:`array`,items:{type:`string`}}},required:[`items`]}},{key:`summary`,value:{type:`object`,properties:{title:{type:`string`},summary:{type:`string`},key_points:{type:`array`,items:{type:`string`}}},required:[`title`,`summary`,`key_points`]}},{key:`analysis`,value:{type:`object`,properties:{analysis:{type:`string`},pros:{type:`array`,items:{type:`string`}},cons:{type:`array`,items:{type:`string`}},recommendation:{type:`string`}},required:[`analysis`,`pros`,`cons`,`recommendation`]}},{key:`custom`,value:`custom`}],Lt=({format:e,onFormatChange:t,className:n})=>{let{t:r}=J(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(``),c=()=>It.map(e=>({key:e.key,label:r(`chat.structuredOutput.${e.key}`),value:e.value,description:r(`chat.structuredOutput.${e.key}Description`)})),l=()=>{let t=c();return e===null?t[0]:e===`json`?t[1]:typeof e==`object`?t.find(t=>typeof t.value==`object`&&JSON.stringify(t.value)===JSON.stringify(e))||{key:`customSchema`,label:r(`chat.structuredOutput.custom`),value:e,description:r(`chat.structuredOutput.customSchema`)}:t[0]},u=e=>{let n=c().find(t=>t.label===e);if(n){if(n.value===`custom`){a(!0);return}a(!1),t(n.value)}};return(0,X.jsxs)(`div`,{className:W(`space-y-3`,n),children:[(0,X.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsx)(C,{className:`h-4 w-4 text-gray-500 mr-2`}),(0,X.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`chat.structuredOutput.title`)})]})}),(0,X.jsx)(De,{value:l().label,onChange:e=>u(e.target.value),options:c().map(e=>({value:e.label,label:e.label}))}),(0,X.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:l().description}),i&&(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(Ae,{value:o,onChange:e=>s(e.target.value),placeholder:`{
10
+ "type": "object",
11
+ "properties": {
12
+ "field1": { "type": "string" },
13
+ "field2": { "type": "number" }
14
+ },
15
+ "required": ["field1"]
16
+ }`,rows:8,className:`font-mono text-sm`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(G,{onClick:()=>{try{t(JSON.parse(o)),a(!1)}catch(e){Ft.error(`Invalid JSON schema:`,e)}},size:`sm`,disabled:!o.trim(),children:r(`chat.structuredOutput.applySchema`)}),(0,X.jsx)(G,{onClick:()=>{a(!1),s(``)},variant:`outline`,size:`sm`,children:r(`chat.structuredOutput.cancel`)})]})]}),(()=>{let e=l();return!e.value||e.value===`json`?null:(0,X.jsxs)(`div`,{className:`mt-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md`,children:[(0,X.jsxs)(`div`,{className:`flex items-center mb-2`,children:[(0,X.jsx)(fe,{className:`h-4 w-4 text-gray-500 mr-2`}),(0,X.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`chat.structuredOutput.schemaPreview`)})]}),(0,X.jsx)(`pre`,{className:`text-xs text-gray-700 dark:text-gray-300 overflow-x-auto`,children:JSON.stringify(e.value,null,2)})]})})(),e&&(0,X.jsxs)(`div`,{className:`flex items-center text-xs text-green-600 dark:text-green-400`,children:[(0,X.jsx)(j,{className:`h-3 w-3 mr-1`}),r(`chat.structuredOutput.enabled`)]})]})};function Rt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function zt({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:a,hfGgufFiles:o,loadingGguf:s,pullingModel:c,pullProgress:l,setHfTask:u,setHfSort:d,onToggleHfModel:m,onPullHfGguf:h,onCancelPull:g,onRefreshHfModels:_}){let{t:v}=J();return(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(`select`,{value:e,onChange:e=>u(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,X.jsx)(`option`,{value:`text-generation`,children:v(`modelManager.huggingface.taskTextGeneration`)}),(0,X.jsx)(`option`,{value:`text-to-speech`,children:v(`modelManager.huggingface.taskTextToSpeech`)}),(0,X.jsx)(`option`,{value:`text-to-image`,children:v(`modelManager.huggingface.taskTextToImage`)}),(0,X.jsx)(`option`,{value:`automatic-speech-recognition`,children:v(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,X.jsxs)(`select`,{value:t,onChange:e=>d(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,X.jsx)(`option`,{value:`downloads`,children:v(`modelManager.huggingface.sortDownloads`)}),(0,X.jsx)(`option`,{value:`likes`,children:v(`modelManager.huggingface.sortLikes`)}),(0,X.jsx)(`option`,{value:`lastModified`,children:v(`modelManager.huggingface.sortRecent`)})]})]})}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[!n&&(0,X.jsx)(`div`,{className:`mx-3 mt-3 mb-1 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300`,children:v(`modelSelector.pullRestricted`)}),r?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(p,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,X.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,X.jsx)(se,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,X.jsx)(`p`,{className:`text-sm`,children:v(`modelManager.huggingface.noModelsFound`)})]}):(0,X.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=a===e.id,r=o[e.id]||[],i=s===e.id;return(0,X.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,X.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),m(e.id)},children:(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`p-2 rounded-lg bg-yellow-100 dark:bg-yellow-900/30 flex-shrink-0`,children:(0,X.jsx)(se,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-400`,children:`Gated`})]}),(0,X.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(P,{className:`h-3 w-3`}),Rt(e.downloads)]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(E,{className:`h-3 w-3`}),Rt(e.likes)]}),e.pipeline_tag&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,X.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,X.jsx)(L,{className:`h-4 w-4 text-gray-400`})}),(0,X.jsx)(f,{className:W(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,X.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,X.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,X.jsx)(p,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,X.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:v(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,X.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:v(`modelManager.huggingface.noGgufAvailable`)}):(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:v(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=c===e.ollamaCommand;return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,X.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:l?.percent===void 0?`...`:`${l.percent}%`}),(0,X.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),g()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,X.jsx)(I,{className:`h-4 w-4`})})]}):n?(0,X.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),h(e.ollamaCommand,e.filename)},disabled:!!c,className:W(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,X.jsx)(P,{className:`h-3 w-3 inline mr-1`}),v(`models.pull`)]}):(0,X.jsx)(`span`,{className:`px-2 py-1 rounded text-[11px] font-medium bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300`,children:v(`modelSelector.adminOnlyPull`)})]},e.filename)}),c?.startsWith(`hf.co/`)&&c.includes(e.id)&&l?.percent!==void 0&&(0,X.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,X.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${l.percent}%`}})})]})})]},e.id)})})]}),(0,X.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,X.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,X.jsx)(L,{className:`h-3 w-3`}),v(`modelManager.huggingface.browseAllLink`)]}),(0,X.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,X.jsx)(x,{className:W(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function Bt({filteredGroups:e,selectedModel:t,showImageGen:n,getModelIcon:r,getModelLabel:i,getModelSubLabel:a,onModelSelect:o,onOpenGallery:c}){let{t:l}=J();return(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>(0,X.jsx)(`div`,{onMouseDown:t=>{t.preventDefault(),o(e.name)},className:W(`px-3 py-3 cursor-pointer border-b border-gray-100 dark:border-dark-200 last:border-b-0`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,t===e.name&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r(e),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:i(e)}),a(e)&&(0,X.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:a(e)})]}),t===e.name&&(0,X.jsx)(u,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},e.name))]},e.type)):(0,X.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,X.jsx)(D,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,X.jsx)(`p`,{className:`text-sm`,children:l(`models.noModelsFound`)})]}),n&&(0,X.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(s,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),l(`modelSelector.actions`)]})}),(0,X.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),c()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(h,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,X.jsxs)(`div`,{className:`flex-1`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:l(`gallery.generate`)}),(0,X.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:l(`gallery.generateDescription`)})]})]})})]})]})}function Vt({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:a,pullProgress:o,setLibraryCategory:s,isModelInstalled:c,onModelSelect:l,onPullModel:u,onCancelPull:d,onRefreshLibrary:f}){let{t:m}=J();return(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,X.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),s(e)},className:W(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[!n&&(0,X.jsx)(`div`,{className:`mx-3 mt-3 mb-1 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-300`,children:m(`modelSelector.pullRestricted`)}),r?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,X.jsx)(p,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,X.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,X.jsx)(de,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,X.jsx)(`p`,{className:`text-sm`,children:m(`models.noModelsFound`)})]}):(0,X.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.slice(0,50).map(e=>{let t=c(e.name),r=a===e.name;return(0,X.jsxs)(`div`,{className:W(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,X.jsx)(de,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:m(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,X.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,X.jsx)(de,{className:`h-3 w-3`}),`Cloud`]})]}),(0,X.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,X.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,X.jsx)(P,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,X.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:o?.percent===void 0?`...`:`${o.percent}%`}),(0,X.jsx)(`button`,{onClick:d,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,X.jsx)(I,{className:`h-4 w-4`})})]}):t?(0,X.jsx)(`button`,{onClick:()=>l(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:m(`modelSelector.use`)}):n?(0,X.jsxs)(`button`,{onClick:()=>u(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,X.jsx)(P,{className:`h-3 w-3 inline mr-1`}),m(`modelSelector.pull`)]}):(0,X.jsx)(`span`,{className:`px-2 py-1 rounded text-[11px] font-medium bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300`,children:m(`modelSelector.adminOnlyPull`)})})]}),r&&o?.percent!==void 0&&(0,X.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${o.percent}%`}})})]},e.name)})})]}),(0,X.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,X.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,X.jsx)(L,{className:`h-3 w-3`}),m(`modelManager.huggingface.browseAllLink`)]}),(0,X.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),f()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,X.jsx)(x,{className:W(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var Ht=a(`components:model-selector`),Ut=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:a,disabled:s=!1,compact:l=!1,showImageGen:u=!1,onModelsRefresh:d})=>{let{t:p}=J(),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(`installed`),b=(0,Y.useRef)(null),x=(0,Y.useRef)(null),C=ke(),{user:T,systemInfo:E}=Oe(),D=T?.role===`admin`||(E?.allowUserModelPull??!0),[O,k]=(0,Y.useState)(`all`),[A,j]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(`text-generation`),[P,ee]=(0,Y.useState)(`downloads`),[F,te]=(0,Y.useState)(``),[I,ie]=(0,Y.useState)(null),[L,ae]=(0,Y.useState)({}),[R,oe]=(0,Y.useState)(null),[z,B]=(0,Y.useState)(null),[le,V]=(0,Y.useState)(null),[ue,H]=(0,Y.useState)(null),fe=[`all`,`popular`,`chat`,`code`,`vision`,`embedding`,`cloud`],pe=[{type:`personas`,label:p(`modelSelector.personas`),icon:(0,X.jsx)(re,{className:`h-4 w-4 text-purple-600 dark:text-purple-400`}),models:e.filter(e=>e.isPersona),color:`purple`},{type:`ollama`,label:p(`modelSelector.ollamaModels`),icon:(0,X.jsx)(c,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),models:e.filter(e=>!e.isPersona&&!e.isPlugin&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:p(`modelSelector.pluginModels`),icon:(0,X.jsx)(se,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),models:e.filter(e=>e.isPlugin),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(g.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(g.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(g.toLowerCase()))})).filter(e=>e.models.length>0),U=e.find(e=>e.name===t||t.startsWith(`persona:`)&&e.name===t),{data:he=[],isLoading:ge,refetch:_e}=i({queryKey:[`ollama-library-selector`,A,O],queryFn:async()=>{let e=await me.getLibraryModels({search:A||void 0,sort:`popular`,category:O===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:m&&v===`ollama`}),{data:ve=[],isLoading:ye,refetch:be}=i({queryKey:[`hf-models-selector`,M,F,P],queryFn:async()=>{let e=await xe.getModels({task:M,search:F||void 0,sort:P,limit:30});return e.success&&e.data?e.data:[]},enabled:m&&v===`huggingface`}),Se=he.filter(e=>{let t=!g||e.name.toLowerCase().includes(g.toLowerCase())||e.description.toLowerCase().includes(g.toLowerCase()),n=O===`all`||e.category===O;return t&&n}),Ce=(0,Y.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){oe(e);try{let r=await xe.getGgufFiles(t,n);r.success&&r.data&&ae(t=>({...t,[e]:r.data}))}catch(e){Ht.error(`Failed to load GGUF files:`,e)}finally{oe(null)}}},[]),we=(0,Y.useCallback)(e=>{I===e?ie(null):(ie(e),L[e]||Ce(e))},[I,L,Ce]),G=(0,Y.useCallback)((e,t)=>{if(!D){S.error(p(`modelSelector.pullRestricted`));return}if(!z){B(e),V({status:`starting`});try{let n=me.pullModelStream(e,e=>{V(e)},()=>{V(null),B(null),H(null),S.success(`Downloaded ${t}`),d?.()},e=>{V(null),B(null),H(null),S.error(`Failed to download: ${e}`)});H(()=>n)}catch{V(null),B(null),S.error(`Failed to start download`)}}},[D,d,z,p]);(0,Y.useEffect)(()=>{let e=setTimeout(()=>{v===`huggingface`?te(g):v===`ollama`&&j(g)},300);return()=>clearTimeout(e)},[g,v]),(0,Y.useEffect)(()=>{let e=e=>{b.current&&!b.current.contains(e.target)&&(h(!1),_(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,Y.useEffect)(()=>{m&&x.current&&x.current.focus()},[m]);let Te=async e=>{h(!1),_(``);try{let t=await me.listRunningModels();if(t.success&&t.data){let n=t.data;n.length>0&&(n.some(t=>t.name===e||e.startsWith(`persona:`))||await me.unloadAllModels())}}catch(e){Ht.warn(`Failed to unload models before switch:`,e)}n({target:{value:e}})},Ee=async e=>{if(!D){S.error(p(`modelSelector.pullRestricted`));return}if(!z){B(e),V({status:`starting`});try{let t=me.pullModelStream(e,e=>{V(e)},()=>{V(null),B(null),H(null),S.success(`Downloaded ${e}`),d?.()},e=>{V(null),B(null),H(null),S.error(`Failed to download: ${e}`)});H(()=>t)}catch{V(null),B(null),S.error(`Failed to start download`)}}},K=()=>{ue&&(ue(),H(null),B(null),V(null),S.success(`Download cancelled`))},q=t=>e.some(e=>e.name===t||e.name.startsWith(t+`:`)),De=e=>e.isPersona?(0,X.jsx)(re,{className:`h-4 w-4 text-purple-600 dark:text-purple-400`}):e.isPlugin?(0,X.jsx)(se,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,X.jsx)(c,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),Ae=e=>e.isPersona?e.personaName||e.name:e.isPlugin?`${e.name}`:e.name,je=e=>e.isPersona?`via ${e.model}`:e.isPlugin?`via ${e.pluginName}`:null;return(0,X.jsxs)(`div`,{className:W(`relative`,a),ref:b,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>!s&&h(!m),disabled:s,className:W(l?`h-[44px] sm:h-[52px] px-3 flex items-center justify-between text-left w-full `:`w-full flex items-center justify-between gap-2 px-3 py-2 text-left `,`bg-gray-50 dark:bg-dark-200 border border-gray-200 dark:border-dark-300`,`rounded-lg text-sm hover:bg-gray-100 dark:hover:bg-dark-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500`,s?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:l?U?Ae(U):p(`modelSelector.selectModel`):void 0,children:[(()=>{if(!U)return l?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,X.jsx)(c,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-gray-400 dark:text-gray-500 truncate`,children:p(`modelSelector.selectModel`)})]}):p(`modelSelector.selectModel`);if(l){let e=Ae(U);return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[De(U),(0,X.jsx)(`span`,{className:`text-xs font-medium text-gray-700 dark:text-gray-200 truncate`,children:e})]})}let e=Ae(U),t=je(U);return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[De(U),(0,X.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e}),t&&(0,X.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),U.isPersona&&r&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[(0,X.jsx)(ne,{className:`h-3 w-3 text-purple-600 dark:text-purple-400`}),r.embedding_model&&(0,X.jsx)(ce,{className:`h-3 w-3 text-purple-500 dark:text-purple-300`})]})]})})(),(0,X.jsx)(f,{className:W(l?`h-3 w-3`:`h-4 w-4`,`text-gray-400 flex-shrink-0`,m&&`rotate-180`)})]}),m&&(0,Ie.createPortal)((0,X.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-start sm:items-center justify-center p-2 sm:p-4`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>h(!1)}),(0,X.jsxs)(`div`,{className:W(`relative bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 shadow-2xl`,`w-full max-w-md sm:w-[480px] sm:max-w-[90vw]`,`mt-2 sm:mt-0 rounded-xl`,`h-[85vh] sm:h-[600px] flex flex-col`),onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,X.jsx)(`div`,{className:`p-3 border-b border-gray-200 dark:border-dark-200`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(w,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,X.jsx)(`input`,{ref:x,type:`text`,placeholder:p(v===`installed`?`modelSelector.searchInstalled`:v===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:g,onChange:e=>_(e.target.value),className:W(`w-full pl-10 pr-4 py-2.5 text-sm bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300 rounded-lg`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]})}),(0,X.jsxs)(`div`,{className:`flex border-b border-gray-200 dark:border-dark-300`,children:[(0,X.jsxs)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),y(`installed`)},className:W(`flex-1 px-4 py-2.5 text-sm font-medium transition-colors`,v===`installed`?`text-primary-600 dark:text-primary-400 border-b-2 border-primary-500`:`text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300`),children:[(0,X.jsx)(o,{className:`h-4 w-4 inline mr-1.5`}),p(`modelSelector.installed`)]}),(0,X.jsxs)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),y(`ollama`)},className:W(`flex-1 px-4 py-2.5 text-sm font-medium transition-colors`,v===`ollama`?`text-primary-600 dark:text-primary-400 border-b-2 border-primary-500`:`text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300`),children:[(0,X.jsx)(de,{className:`h-4 w-4 inline mr-1.5`}),`Ollama`]}),(0,X.jsxs)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),y(`huggingface`)},className:W(`flex-1 px-4 py-2.5 text-sm font-medium transition-colors`,v===`huggingface`?`text-primary-600 dark:text-primary-400 border-b-2 border-primary-500`:`text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300`),children:[(0,X.jsx)(se,{className:`h-4 w-4 inline mr-1.5`}),`HuggingFace`]})]})]}),v===`installed`&&(0,X.jsx)(Bt,{filteredGroups:pe,selectedModel:t,showImageGen:u,getModelIcon:De,getModelLabel:Ae,getModelSubLabel:je,onModelSelect:Te,onOpenGallery:()=>{h(!1),C(`/gallery`)}}),v===`ollama`&&(0,X.jsx)(Vt,{libraryCategories:fe,libraryCategory:O,canInstallModels:D,loadingLibrary:ge,filteredLibraryModels:Se,pullingModel:z,pullProgress:le,setLibraryCategory:k,isModelInstalled:q,onModelSelect:Te,onPullModel:Ee,onCancelPull:K,onRefreshLibrary:()=>{_e()}}),v===`huggingface`&&(0,X.jsx)(zt,{hfTask:M,hfSort:P,canInstallModels:D,loadingHf:ye,hfModels:ve,expandedHfModel:I,hfGgufFiles:L,loadingGguf:R,pullingModel:z,pullProgress:le,setHfTask:N,setHfSort:ee,onToggleHfModel:we,onPullHfGguf:G,onCancelPull:K,onRefreshHfModels:()=>{be()}})]})]}),document.body),(0,X.jsx)(`select`,{value:t,onChange:n,className:`sr-only`,tabIndex:-1,children:e.map(e=>(0,X.jsx)(`option`,{value:e.name,children:Ae(e)},e.name))})]})},Wt=a(`components:chat-input`),Gt=({onSendMessage:e,onStopGeneration:t,disabled:n=!1})=>{let{t:r}=J(),[i,a]=(0,Y.useState)(``),[o,c]=(0,Y.useState)([]),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(!1),[p,h]=(0,Y.useState)(null),[g,v]=(0,Y.useState)(!1),{isGenerating:b,setBackgroundImage:x}=Me(),{currentSession:S,models:C}=K(),w=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{(async()=>{try{let e=await ge.getPlugins();v(!!(e.success&&e.data&&e.data.length>0))}catch{v(!1)}})()},[]);let T=t=>{t.preventDefault(),!(!i.trim()||b)&&(e(i.trim(),o.length>0?o:void 0,l||void 0),a(``),c([]))},E=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),T(e))},D=()=>{t()};(0,Y.useEffect)(()=>{let e=w.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,200)+`px`)},[i]),(0,Y.useEffect)(()=>{(async()=>{if(S?.personaId)try{let e=await U.getPersona(S.personaId);if(e.success&&e.data)h(e.data);else{Wt.warn(`Persona ${S.personaId} not found, clearing reference`),h(null);let{setCurrentSession:e}=K.getState();e({...S,personaId:void 0})}}catch(e){if(Wt.error(`Failed to load current persona:`,e),h(null),S){let{setCurrentSession:e}=K.getState();e({...S,personaId:void 0})}}else h(null)})()},[S?.personaId]);let O=async e=>{let t=e.target.value;if(S)try{if(t.startsWith(`persona:`)){let e=t.replace(`persona:`,``),n=await U.getPersona(e);if(!n.success||!n.data){_.error(`Failed to load persona details`);return}let i=n.data,a=await ye.updateSession(S.id,{personaId:e,model:t});if(a.success&&a.data){let{sessions:e}=K.getState(),t=e.map(e=>e.id===S.id?a.data:e);K.setState({sessions:t,currentSession:a.data}),i.background&&x(i.background),_.success(r(`chat.persona.applied`))}}else{let e=await ye.updateSession(S.id,{model:t,personaId:void 0});if(e.success&&e.data){let{sessions:t}=K.getState(),n=t.map(t=>t.id===S.id?e.data:t);K.setState({sessions:n,currentSession:e.data}),x(null),_.success(r(`chat.model.updated`))}}}catch(e){Wt.error(`Failed to update session:`,e),_.error(`Failed to update session`)}},k=o.length>0||l!==null;return(0,X.jsx)(`div`,{className:`pointer-events-none`,children:(0,X.jsxs)(`div`,{className:`max-w-5xl mx-auto px-3 sm:px-4 md:px-6 w-full pointer-events-auto`,children:[d&&(0,X.jsxs)(`div`,{className:`mb-2 p-3 rounded-2xl bg-white/95 dark:bg-dark-100/95 backdrop-blur-md border border-gray-200/50 dark:border-dark-300/50 shadow-lg`,children:[(0,X.jsx)(Mt,{images:o,onImagesChange:c,maxImages:5,sessionId:S?.id,disabled:n}),(0,X.jsx)(Lt,{format:l,onFormatChange:u})]}),(0,X.jsxs)(`div`,{className:`py-2 sm:py-3`,children:[(0,X.jsx)(`form`,{onSubmit:T,children:(0,X.jsxs)(`div`,{className:W(`flex items-center gap-2 p-2 sm:p-3 rounded-2xl sm:rounded-3xl border transition-all duration-300 ease-out shadow-lg`,`bg-white/95 dark:bg-dark-100/95 backdrop-blur-md`,`border-gray-200/50 dark:border-dark-300/50`,`hover:border-gray-300/70 dark:hover:border-dark-400/70`,`focus-within:border-primary-400/70 dark:focus-within:border-primary-500/70`,`focus-within:shadow-xl`),children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>f(!d),className:W(`h-8 w-8 sm:h-9 sm:w-9 !p-0 rounded-full flex-shrink-0`,`hover:bg-gray-100 dark:hover:bg-dark-200/80`,`transition-all duration-200 touch-manipulation`,`hover:scale-105 active:scale-95`,k&&`text-primary-600 dark:text-primary-400`,d&&`bg-gray-100 dark:bg-dark-200/80`),title:r(`chat.input.attachments`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`},children:k?(0,X.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,X.jsx)(y,{className:`h-4 w-4`}),(0,X.jsx)(`div`,{className:`absolute -top-0.5 -right-0.5 h-2 w-2 bg-primary-500 dark:bg-primary-400 rounded-full ring-2 ring-white dark:ring-dark-50`})]}):d?(0,X.jsx)(m,{className:`h-4 w-4`}):(0,X.jsx)(s,{className:`h-4 w-4`})}),(0,X.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,X.jsx)(At,{ref:w,value:i,onChange:e=>a(e.target.value),onKeyDown:E,placeholder:r(`chat.input.placeholder`),disabled:n,className:`!border-0 !bg-transparent !shadow-none !p-0 !m-0 !rounded-none !focus:ring-0 !focus:border-0 !focus:shadow-none !focus:bg-transparent min-h-[32px] sm:min-h-[36px] max-h-[120px] resize-none scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400 focus:outline-none placeholder:text-gray-500 dark:placeholder:text-dark-500 text-base sm:text-sm leading-none touch-manipulation`,rows:1,style:{boxShadow:`none !important`,border:`none !important`,outline:`none !important`,padding:`0 !important`,margin:`0 !important`,lineHeight:`1.2 !important`,verticalAlign:`middle`}})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 sm:gap-2 flex-shrink-0`,children:[S&&C.length>0&&(0,X.jsx)(`div`,{className:`hidden sm:block`,children:(0,X.jsx)(Ut,{models:C,selectedModel:S.personaId?`persona:${S.personaId}`:S.model,onModelChange:O,currentPersona:p,className:`min-w-[160px] max-w-[240px] border-0 bg-gray-100/80 dark:bg-dark-100/80 rounded-xl text-sm hover:bg-gray-200/80 dark:hover:bg-dark-200/60 transition-colors duration-200`,compact:!0,showImageGen:g})}),b?(0,X.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:D,className:W(`h-8 w-8 sm:h-9 sm:w-9 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`bg-red-50 dark:bg-red-900/20`,`text-red-500 dark:text-red-400`,`hover:bg-red-100 dark:hover:bg-red-900/30`,`transition-all duration-200 touch-manipulation`,`hover:scale-105 active:scale-95`),title:r(`chat.input.stopGeneration`),children:(0,X.jsx)(M,{className:`h-4 w-4`})}):(0,X.jsx)(G,{type:`submit`,variant:`ghost`,size:`sm`,disabled:!i.trim()||n,className:W(`h-8 w-8 sm:h-9 sm:w-9 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`text-gray-400 dark:text-dark-500`,`disabled:opacity-40 disabled:hover:bg-transparent disabled:cursor-not-allowed`,`transition-all duration-200 touch-manipulation`,i.trim()&&!n&&[`bg-primary-500 dark:bg-primary-600`,`text-white dark:text-white`,`hover:bg-primary-600 dark:hover:bg-primary-500`,`shadow-md hover:shadow-lg`,`hover:scale-105 active:scale-95`]),title:r(`chat.input.sendMessage`),children:(0,X.jsx)(V,{className:`h-4 w-4`})})]})]})}),S&&C.length>0&&(0,X.jsx)(`div`,{className:`sm:hidden mt-3`,children:(0,X.jsx)(Ut,{models:C,selectedModel:S.personaId?`persona:${S.personaId}`:S.model,onModelChange:O,currentPersona:p,className:`w-full rounded-xl bg-gray-100/80 dark:bg-dark-100/80 border-0 transition-colors duration-200`,compact:!0,showImageGen:g})}),(0,X.jsxs)(`div`,{className:`mt-2 flex items-center justify-center gap-2 text-xs text-gray-500 dark:text-dark-600`,children:[(0,X.jsx)(Pt,{sessionId:S?.id}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsxs)(`a`,{href:`https://librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`libre-brand underline hover:text-primary-600 dark:hover:text-primary-400 transition-colors`,style:{fontSize:`1.1em`,lineHeight:1},children:[`Libre `,(0,X.jsx)(`span`,{children:`WebUI`})]}),` `,(0,X.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,style:{fontSize:`0.55rem`},children:[`v`,`0.11.0`]}),` `,(0,X.jsx)(`span`,{className:`text-gray-300 dark:text-gray-600 opacity-50`,children:`•`}),` `,(0,X.jsx)(`span`,{className:`text-gray-400 dark:text-gray-500`,style:{fontSize:`0.55rem`},children:r(`chat.footer.disclaimer`)}),k&&(0,X.jsxs)(`span`,{className:`ml-2 text-primary-600 dark:text-primary-400`,children:[`•`,` `,o.length>0&&r(`chat.footer.images`,{count:o.length}),o.length>0&&l&&` • `,l&&r(`chat.footer.structuredOutput`)]})]})]})]})]})})},Kt=({persona:e,onClear:t,className:n})=>{let[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(null),[o,s]=(0,Y.useState)({top:0,left:0});(0,Y.useEffect)(()=>{if(r&&a.current){let e=a.current.getBoundingClientRect();s({top:e.bottom+8,left:e.left})}},[r]);let c=!!(e.memory_settings?.enabled||e.mutation_settings?.enabled),l=()=>ve(e,64),u=t=>{be(t.currentTarget,e.name,64)};return(0,X.jsxs)(`div`,{className:W(`relative`,n),children:[(0,X.jsxs)(`button`,{ref:a,onClick:()=>i(!r),className:W(`flex items-center gap-2 px-3 py-1.5 rounded-full transition-all duration-200`,`bg-primary-50 dark:bg-primary-900/30`,`border border-primary-200 dark:border-primary-700/50`,`hover:bg-primary-100 dark:hover:bg-primary-900/40`,`text-primary-700 dark:text-primary-300`),children:[(0,X.jsx)(`img`,{src:l(),alt:e.name,className:`w-5 h-5 rounded-full object-cover`,onError:u}),(0,X.jsx)(`span`,{className:`text-sm font-medium max-w-[120px] truncate`,children:e.name}),c&&(0,X.jsx)(ce,{className:`h-3 w-3 text-purple-500 dark:text-purple-400`}),(0,X.jsx)(f,{className:W(`h-3.5 w-3.5 transition-transform duration-200`,r&&`rotate-180`)})]}),r&&(0,Ie.createPortal)((0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`fixed inset-0 z-[9998]`,onClick:()=>i(!1)}),(0,X.jsx)(`div`,{className:`fixed w-72 z-[9999]`,style:{top:o.top,left:o.left},children:(0,X.jsxs)(`div`,{className:W(`rounded-xl overflow-hidden shadow-xl`,`bg-white dark:bg-dark-100`,`border border-gray-200 dark:border-dark-300`),children:[(0,X.jsxs)(`div`,{className:`relative h-16`,children:[e.background?(0,X.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${e.background})`}}):(0,X.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,X.jsx)(`div`,{className:`absolute inset-0 bg-black/10`}),t&&(0,X.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t(),i(!1)},className:`absolute top-2 right-2 p-1 rounded-full bg-white/20 hover:bg-white/30 backdrop-blur-sm transition-colors`,title:`Remove persona`,children:(0,X.jsx)(I,{className:`h-3.5 w-3.5 text-white`})}),c&&(0,X.jsxs)(`div`,{className:`absolute top-2 left-2 flex items-center gap-1 px-2 py-0.5 rounded-full bg-white/20 backdrop-blur-sm text-white text-[10px] font-medium`,children:[(0,X.jsx)(ne,{className:`h-3 w-3`}),`Enhanced`]})]}),(0,X.jsx)(`div`,{className:`relative px-4 -mt-6`,children:(0,X.jsx)(`img`,{src:l(),alt:e.name,className:`w-12 h-12 rounded-lg object-cover ring-3 ring-white dark:ring-dark-100 shadow-md`,onError:u})}),(0,X.jsxs)(`div`,{className:`px-4 pt-2 pb-4`,children:[(0,X.jsx)(`h4`,{className:`text-base font-semibold text-gray-900 dark:text-gray-100`,children:e.name}),(0,X.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 flex items-center gap-1 mt-0.5`,children:[(0,X.jsx)(H,{className:`h-3 w-3`}),e.model]}),e.description&&(0,X.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-400 mt-2 line-clamp-2`,children:e.description}),e.parameters.system_prompt&&(0,X.jsxs)(`div`,{className:`mt-3 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-100 dark:border-dark-200`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 mb-1`,children:[(0,X.jsx)(g,{className:`h-2.5 w-2.5 text-gray-400`}),(0,X.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider font-medium text-gray-400`,children:`System`})]}),(0,X.jsxs)(`p`,{className:`text-[11px] text-gray-600 dark:text-gray-400 line-clamp-2 italic`,children:[`“`,e.parameters.system_prompt,`”`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-3`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:[(0,X.jsx)(se,{className:`h-2.5 w-2.5`}),e.parameters.temperature?.toFixed(1)||`0.7`]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] 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`]}),e.memory_settings?.enabled&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-medium bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300`,children:[(0,X.jsx)(ne,{className:`h-2.5 w-2.5`}),`Memory`]})]})]})]})})]}),document.body)]})},qt=({images:e,onImagesChange:t,maxImages:n=5,className:r})=>{let{t:i}=J(),a=(0,Y.useRef)(null),[o,s]=(0,Y.useState)(!1),c=r=>{if(!r)return;let i=[],a=n-e.length;for(let n=0;n<Math.min(r.length,a);n++){let o=r[n];if(!o.type.startsWith(`image/`)){S.error(`File ${o.name} is not an image`);continue}if(o.size>10*1024*1024){S.error(`Image ${o.name} is too large (max 10MB)`);continue}let s=new FileReader;s.onload=n=>{n.target?.result&&(i.push(n.target.result),i.length===Math.min(r.length,a)&&t([...e,...i]))},s.readAsDataURL(o)}r.length>a&&S.error(`Only ${a} more images can be added`)},l=e=>{e.preventDefault(),s(!0)},u=e=>{e.preventDefault(),s(!1)},d=e=>{e.preventDefault(),s(!1),c(e.dataTransfer.files)},f=n=>{t(e.filter((e,t)=>t!==n))},p=e.length<n;return(0,X.jsxs)(`div`,{className:W(`space-y-3`,r),children:[p&&(0,X.jsxs)(`div`,{className:W(`border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-4 transition-colors`,`hover:border-primary-400 dark:hover:border-primary-500`,o&&`border-primary-500 bg-primary-50 dark:bg-primary-900/20`),onDragOver:l,onDragLeave:u,onDrop:d,children:[(0,X.jsx)(`input`,{ref:a,type:`file`,multiple:!0,accept:`image/*`,onChange:e=>c(e.target.files),className:`hidden`}),(0,X.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,X.jsx)(A,{className:`h-8 w-8 text-gray-400 dark:text-gray-500 mb-2`}),(0,X.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-2`,children:[i(`chat.mediaUpload.dropImagesHere`),` `,(0,X.jsx)(`button`,{onClick:()=>a.current?.click(),className:`text-primary-600 dark:text-primary-400 hover:underline font-medium`,children:i(`chat.mediaUpload.browse`)})]}),(0,X.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:i(`chat.mediaUpload.supportedFormats`)})]})]}),e.length>0&&(0,X.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3`,children:e.map((e,t)=>(0,X.jsxs)(`div`,{className:`relative group aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700`,children:[(0,X.jsx)(`img`,{src:e,alt:`Upload ${t+1}`,className:`w-full h-full object-cover`}),(0,X.jsx)(`div`,{className:`absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-50 transition-all duration-200 flex items-center justify-center`,children:(0,X.jsx)(G,{variant:`ghost`,size:`sm`,onClick:()=>f(t),className:`opacity-0 group-hover:opacity-100 transition-opacity bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 hover:bg-red-100 dark:hover:bg-red-900/20 hover:text-red-600 dark:hover:text-red-400 p-1 rounded-full`,children:(0,X.jsx)(I,{className:`h-4 w-4`})})})]},t))}),p&&e.length>0&&(0,X.jsxs)(G,{variant:`outline`,size:`sm`,onClick:()=>a.current?.click(),className:`w-full sm:w-auto`,children:[(0,X.jsx)(h,{className:`h-4 w-4 mr-2`}),`Add More Images (`,e.length,`/`,n,`)`]})]})},$=a(`use-chat`),Jt=new Set([`New Chat`,`New Demo Session`]),Yt=e=>!e||Jt.has(e),Xt=e=>{let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)([]),{addMessage:l,updateMessage:u,updateMessageWithStatistics:d,updateSessionTitle:f,setGeneratingTitleForSession:p}=K(),{setIsGenerating:m,preferences:h}=Me(),g=(0,Y.useRef)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(!1),y=(0,Y.useRef)(null),b=(0,Y.useRef)(``),x=(0,Y.useRef)(0),C=(0,Y.useRef)(),w=(0,Y.useRef)(null),T=(0,Y.useRef)(``),E=(0,Y.useCallback)(()=>{w.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(w.current),w.current=null},[]),D=(0,Y.useCallback)((e,t=!1)=>{if(T.current=e,t||typeof window>`u`){E(),n(e);return}w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null,n(T.current)}))},[E]),O=(0,Y.useCallback)(()=>{E(),T.current=``,n(``)},[E]),k=(0,Y.useCallback)(()=>{_.current=null,v.current=!1,y.current=null},[]),A=(0,Y.useCallback)(e=>{let t=Me.getState().preferences.titleSettings,n=_.current,r=v.current&&y.current===e;$.debug(`Auto-title check:`,{firstMessage:n,autoTitle:t?.autoTitle,taskModel:t?.taskModel,shouldGenerateTitle:r}),n&&r&&t?.autoTitle&&t?.taskModel&&($.debug(`Triggering auto-title generation...`),p(e),ye.generateTitle(e,t.taskModel,n).then(t=>{$.debug(`Title generation response:`,t),t.success&&t.data?.title&&f(e,t.data.title)}).catch(e=>{$.error(`Failed to generate title:`,e)}).finally(()=>{p(null)})),k()},[k,p,f]);return(0,Y.useEffect)(()=>()=>{q.offMessage(`user_message`),q.offMessage(`assistant_chunk`),q.offMessage(`assistant_complete`),q.offMessage(`tool_status`),q.offMessage(`error`)},[e]),(0,Y.useEffect)(()=>{if(!e){q.offMessage(`user_message`),q.offMessage(`assistant_chunk`),q.offMessage(`assistant_complete`),q.offMessage(`tool_status`),q.offMessage(`error`);return}return q.onMessage(`user_message`,()=>{}),q.onMessage(`assistant_chunk`,t=>{let n=t,r=n.messageId||g.current;r&&(b.current=n.total,D(n.total,n.done),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{u(e,r,b.current),x.current=Date.now()},n.done?0:200))}),q.onMessage(`tool_status`,e=>{let t=e;c(e=>e.find(e=>e.toolCallId===t.toolCallId)?e.map(e=>e.toolCallId===t.toolCallId?{...e,phase:t.phase}:e):[...e,{toolCallId:t.toolCallId,name:t.name,phase:t.phase,startedAt:Date.now()}])}),q.onMessage(`assistant_complete`,t=>{let n=t;$.debug(`Hook: Received assistant_complete for session:`,e,`messageId:`,n.messageId,`with statistics:`,!!n.statistics),o(!1),O(),m(!1),c([]);let r=n.messageId||g.current;n&&r&&d(e,r,b.current||n.content,n.statistics),A(e),g.current=null,b.current=``,C.current&&clearTimeout(C.current),x.current=0}),q.onMessage(`error`,e=>{let t=e;if(o(!1),O(),m(!1),g.current=null,t.code===`SESSION_NOT_FOUND`){$.warn(`Session not found, redirecting to create new session...`),S.error(`Session not found. Creating a new session...`),window.location.href=`/`;return}S.error(t.error),k()}),o(!1),O(),g.current=null,()=>{C.current&&clearTimeout(C.current),E()}},[e,u,d,m,D,O,E,A,k]),{sendMessage:(0,Y.useCallback)(async(t,n,r)=>{if(!(!e||!t.trim()&&(!n||n.length===0)))try{m(!0),o(!0),O(),C.current&&clearTimeout(C.current),x.current=Date.now();let a=K.getState().currentSession,s=a?.isPrivate===!0,c=a?.messages?.some(e=>e.role===`user`);!s&&!c&&Yt(a?.title)?(_.current=t.trim(),v.current=!0,y.current=e):(_.current=null,v.current=!1,y.current=null),l(e,{role:`user`,content:t.trim(),images:n});let d=we();if(g.current=d,i(d),l(e,{role:`assistant`,content:``,id:d}),pe()){let n=`Demo response for: ${t.trim()}`;window.setTimeout(()=>{u(e,d,n),o(!1),O(),i(null),m(!1),A(e),g.current=null,b.current=``},500);return}q.isConnected||await q.connect();let f=s?a?.messages?.filter(e=>e.role!==`system`&&e.id!==d).map(e=>({role:e.role,content:e.content,images:e.images})):void 0;q.send({type:`chat_stream`,data:{sessionId:e,content:t.trim(),images:n,format:r,options:h.generationOptions,assistantMessageId:d,isPrivate:s,model:s?a?.model:void 0,messageHistory:f}})}catch(e){$.error(`Failed to send message:`,e),o(!1),O(),i(null),m(!1),g.current=null,S.error(`Failed to send message`)}},[e,l,u,m,O,A,h.generationOptions]),stopGeneration:(0,Y.useCallback)(()=>{o(!1),O(),i(null),m(!1),g.current=null},[m,O]),regenerateLastMessage:(0,Y.useCallback)(async()=>{let t=K.getState().currentSession;if(!t||!e)return;let n=t.messages,r=-1,a=-1;for(let e=n.length-1;e>=0;e--)if(n[e].role===`assistant`){a=e;break}if(a>0){for(let e=a-1;e>=0;e--)if(n[e].role===`user`){r=e;break}}if(r===-1||a===-1){S.error(`No message to regenerate`);return}let s=n[r],c=n[a];try{m(!0),o(!0),O(),C.current&&clearTimeout(C.current),x.current=Date.now();let t=we();g.current=t,i(t),l(e,{role:`assistant`,content:``,id:t,parentId:c.parentId||c.id,branchIndex:c.siblingCount||1,isActive:!0}),q.isConnected||await q.connect(),q.send({type:`chat_stream`,data:{sessionId:e,content:s.content,images:s.images,options:h.generationOptions,assistantMessageId:t,regenerate:!0,originalMessageId:c.id}})}catch(e){$.error(`Failed to regenerate message:`,e),o(!1),O(),i(null),m(!1),g.current=null,S.error(`Failed to regenerate message`)}},[e,m,O,l,h.generationOptions]),selectBranch:(0,Y.useCallback)(async t=>{let n=K.getState().currentSession;if(!n||!e)return;let r=n.messages.find(e=>e.id===t);if(!r){S.error(`Message not found`);return}if(r.isActive!==!1)return;let i=r.parentId||r.id,a=r.branchIndex||0;try{let r=await ye.switchMessageBranch(e,t,a);if(r.success&&r.data){let r=n.messages.map(e=>e.id===i||e.parentId===i?{...e,isActive:e.id===t}:e),o={...n,messages:r,updatedAt:Date.now()};K.setState(t=>({sessions:t.sessions.map(t=>t.id===e?o:t),currentSession:o})),S.success(`Switched to variant ${a+1}`)}else S.error(r.error||`Failed to select branch`)}catch(e){$.error(`Failed to select branch:`,e),S.error(`Failed to select branch`)}},[e]),isStreaming:a,streamingMessage:t,streamingMessageId:r,toolActivities:s}},Zt=a(`pages:chat-page`),Qt=(e,t)=>{let n=new Date().getHours(),r=e?`, ${e}`:``;return n>=5&&n<12?{greeting:`${t?t(`chat.greeting.morning`):`Good morning`}${r}`,timeSuffix:`today`}:n>=12&&n<17?{greeting:`${t?t(`chat.greeting.afternoon`):`Good afternoon`}${r}`,timeSuffix:`today`}:n>=17&&n<21?{greeting:`${t?t(`chat.greeting.evening`):`Good evening`}${r}`,timeSuffix:`tonight`}:{greeting:`${t?t(`chat.greeting.night`):`Good night`}${r}`,timeSuffix:`tonight`}},$t=()=>{let{t:e}=J(),{sessionId:t}=Ee(),n=ke(),r=Te(),{currentSession:i,sessions:a,models:o,selectedModel:c,setSelectedModel:l,createSession:u,setCurrentSession:d,loadSessions:f,getCurrentPersona:p}=K(),{user:h}=Oe(),{sendMessage:g,stopGeneration:_,regenerateLastMessage:v,selectBranch:b,isStreaming:x,streamingMessage:S,streamingMessageId:C,toolActivities:w}=Xt(i?.id||``),T=p(),{greeting:E,timeSuffix:D}=(0,Y.useMemo)(()=>Qt(h?.username,e),[h?.username,e]),[O,k]=(0,Y.useState)(``),[A,j]=(0,Y.useState)([]),[M,N]=(0,Y.useState)(!1),P=(0,Y.useRef)(null),[ee,te]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{a.length===0&&f()},[f,a.length]),(0,Y.useEffect)(()=>{(async()=>{try{let e=await ge.getPlugins();te(!!(e.success&&e.data&&e.data.length>0))}catch{te(!1)}})()},[]),(0,Y.useEffect)(()=>{(()=>{if(sessionStorage.getItem(`forceWelcomeScreen`)){sessionStorage.removeItem(`forceWelcomeScreen`);return}if(!i?.isPrivate&&a.length!==0)if(t){let e=a.find(e=>e.id===t);e&&e.id!==i?.id?d(e):e||(Zt.warn(`Session ${t} not found for current user, redirecting...`),a.length>0?n(`/c/${a[0].id}`,{replace:!0}):n(`/`,{replace:!0}))}else !t&&a.length>0&&r.pathname===`/`&&n(`/c/${a[0].id}`,{replace:!0})})()},[t,a,d,n,i?.id,i?.isPrivate,r.pathname]),(0,Y.useEffect)(()=>{if(i?.id){let e=sessionStorage.getItem(`pendingMessage`);if(e){sessionStorage.removeItem(`pendingMessage`);try{let t=JSON.parse(e);setTimeout(()=>{g(t.content,t.images)},100)}catch(e){Zt.error(`Failed to parse pending message:`,e)}}}},[i?.id,g]),(0,Y.useEffect)(()=>{let e=P.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,200)+`px`)},[O]);let ne=async e=>{if(e.preventDefault(),!O.trim()||!c)return;let t={content:O.trim(),images:A.length>0?A:void 0};sessionStorage.setItem(`pendingMessage`,JSON.stringify(t)),k(``),j([]);let r=await u(c);r&&n(`/c/${r.id}`,{replace:!0})},I=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ne(e))},re=async e=>{let t=e.target.value;l(t)},ie=(e,t,n)=>{i&&g(e,t,n)};if(!i){let t=A.length>0;return(0,X.jsxs)(`div`,{className:`h-full flex-1 flex flex-col items-center justify-center p-4 sm:p-8 relative`,children:[(0,X.jsxs)(`button`,{onClick:()=>{if(!c&&o.length===0)return;let t=Date.now();d({id:`private-${t}`,title:e(`chat.session.private`),model:c||o[0]?.name||``,messages:[],createdAt:t,updatedAt:t,isPrivate:!0})},disabled:!c&&o.length===0,className:`absolute top-4 right-4 flex items-center gap-2 px-3 py-1.5 rounded-full border border-gray-300 dark:border-dark-400 bg-transparent hover:bg-gray-100 dark:hover:bg-dark-200 text-gray-500 dark:text-gray-400 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,title:e(`chat.session.privateTooltip`),children:[(0,X.jsx)(F,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-sm`,children:e(`chat.session.private`)})]}),(0,X.jsxs)(`div`,{className:`w-full max-w-2xl mx-auto flex flex-col items-center justify-center`,children:[(0,X.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-medium text-gray-800 dark:text-gray-100 mb-2 text-center`,style:{fontWeight:400},children:E}),(0,X.jsx)(`p`,{className:`text-base sm:text-lg text-gray-500 dark:text-gray-400 mb-8 text-center`,children:e(D===`today`?`chat.welcome.helpToday`:`chat.welcome.helpTonight`)}),o.length>0?(0,X.jsxs)(`div`,{className:`w-full`,children:[M&&(0,X.jsx)(`div`,{className:`mb-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-2xl`,children:(0,X.jsx)(qt,{images:A,onImagesChange:j,maxImages:5})}),(0,X.jsx)(`form`,{onSubmit:ne,children:(0,X.jsxs)(`div`,{className:W(`flex items-center gap-2 p-2 sm:p-3 rounded-2xl sm:rounded-3xl border transition-all duration-200`,`bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300`,`hover:border-gray-300 dark:hover:border-dark-400`,`focus-within:border-primary-400 dark:focus-within:border-primary-500 focus-within:bg-white dark:focus-within:bg-dark-50`,`shadow-sm hover:shadow-md focus-within:shadow-lg`),children:[(0,X.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>N(!M),className:W(`h-8 w-8 sm:h-9 sm:w-9 !p-0 rounded-full flex-shrink-0`,`hover:bg-gray-200 dark:hover:bg-dark-200 transition-colors touch-manipulation`,t&&`text-primary-600 dark:text-primary-400`,M&&`bg-gray-200 dark:bg-dark-200`),title:e(`chat.input.attachImages`),style:{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0`},children:t?(0,X.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,X.jsx)(y,{className:`h-4 w-4`}),(0,X.jsx)(`div`,{className:`absolute -top-0.5 -right-0.5 h-1.5 w-1.5 bg-primary-500 rounded-full`})]}):M?(0,X.jsx)(m,{className:`h-4 w-4`}):(0,X.jsx)(s,{className:`h-4 w-4`})}),(0,X.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,X.jsx)(At,{ref:P,value:O,onChange:e=>k(e.target.value),onKeyDown:I,placeholder:e(`chat.input.messagePlaceholder`),className:`!border-0 !bg-transparent !shadow-none !p-0 !m-0 !rounded-none !focus:ring-0 !focus:border-0 !focus:shadow-none !focus:bg-transparent min-h-[32px] sm:min-h-[36px] max-h-[120px] resize-none scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400 focus:outline-none placeholder:text-gray-500 dark:placeholder:text-dark-500 text-base sm:text-sm leading-none touch-manipulation`,rows:1,style:{boxShadow:`none !important`,border:`none !important`,outline:`none !important`,padding:`0 !important`,margin:`0 !important`,lineHeight:`1.2 !important`,verticalAlign:`middle`}})}),(0,X.jsx)(`div`,{className:`hidden sm:block`,children:(0,X.jsx)(Ut,{models:o,selectedModel:c,onModelChange:re,className:`min-w-[140px] max-w-[200px] border-0 bg-gray-100 dark:bg-dark-100 rounded-xl text-sm`,compact:!0,showImageGen:ee})}),(0,X.jsx)(G,{type:`submit`,variant:`ghost`,size:`sm`,disabled:!O.trim()||!c,className:W(`h-8 w-8 sm:h-9 sm:w-9 p-0 rounded-full flex-shrink-0 flex items-center justify-center`,`hover:bg-primary-100 dark:hover:bg-primary-900/30 text-primary-600 dark:text-primary-400`,`disabled:text-gray-400 dark:disabled:text-dark-500 disabled:hover:bg-transparent`,`transition-all duration-150 touch-manipulation`,O.trim()&&c&&`hover:scale-105 active:scale-95`),title:e(`chat.input.sendMessage`),children:(0,X.jsx)(V,{className:`h-4 w-4`})})]})}),(0,X.jsx)(`div`,{className:`sm:hidden mt-4`,children:(0,X.jsx)(Ut,{models:o,selectedModel:c,onModelChange:re,className:`w-full rounded-xl bg-gray-100 dark:bg-dark-100 border-0`,compact:!0,showImageGen:ee})}),(0,X.jsxs)(`div`,{className:`mt-4 text-center`,children:[(0,X.jsxs)(`a`,{href:`https://librewebui.org`,target:`_blank`,rel:`noopener noreferrer`,className:`libre-brand underline hover:text-primary-600 dark:hover:text-primary-400 transition-colors text-gray-500 dark:text-gray-400`,style:{fontSize:`0.75rem`,lineHeight:1},children:[`Libre `,(0,X.jsx)(`span`,{children:`WebUI`})]}),` `,(0,X.jsxs)(`span`,{className:`text-gray-400 dark:text-gray-500`,style:{fontSize:`0.55rem`},children:[`v`,`0.11.0`]}),` `,(0,X.jsx)(`span`,{className:`text-gray-300 dark:text-gray-600 opacity-50`,children:`•`}),` `,(0,X.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:e(`chat.footer.disclaimer`)})]})]}):(0,X.jsx)(`div`,{className:`w-full max-w-md`,children:(0,X.jsxs)(`div`,{className:`p-6 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-xl`,children:[(0,X.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-dark-700 mb-4`,children:e(`chat.model.noModelsDescription`)}),(0,X.jsx)(`code`,{className:`block text-xs bg-gray-100 dark:bg-dark-200 p-3 rounded-lg font-mono text-gray-800 dark:text-dark-600`,children:e(`chat.model.pullCommand`)})]})})]})]})}return(0,X.jsxs)(`div`,{className:`flex flex-col h-full relative`,style:T?.background?{backgroundImage:`url(${T.background})`,backgroundSize:`cover`,backgroundPosition:`center`,backgroundRepeat:`no-repeat`}:void 0,children:[T?.background&&(0,X.jsx)(`div`,{className:`absolute inset-0 bg-white/80 dark:bg-black/80 backdrop-blur-sm`}),(0,X.jsxs)(`div`,{className:`flex flex-col h-full relative z-10`,children:[i?.isPrivate&&(0,X.jsx)(`div`,{className:`flex-shrink-0 px-4 py-2 border-b border-gray-200 dark:border-dark-300 bg-gray-50/80 dark:bg-dark-100/80 backdrop-blur-sm`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-gray-600 dark:text-gray-400`,children:[(0,X.jsx)(F,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e(`chat.session.privateMode`)}),(0,X.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[`— `,e(`chat.session.privateDescription`)]})]})}),T&&!i?.isPrivate&&(0,X.jsx)(`div`,{className:`flex-shrink-0 px-4 py-2 border-b border-gray-100 dark:border-dark-200 bg-white/50 dark:bg-dark-100/50 backdrop-blur-sm`,children:(0,X.jsx)(Kt,{persona:T,onClear:()=>{if(i){let{sessions:e}=K.getState(),t={...i,model:T.model,personaId:void 0},n=e.map(e=>e.id===i.id?t:e);K.setState({sessions:n,currentSession:t})}}})}),(0,X.jsx)(Ot,{messages:i.messages,streamingMessage:S,streamingMessageId:C,isStreaming:x,toolActivities:w,onRegenerate:v,onSelectBranch:b,className:`flex-1`}),(0,X.jsx)(Gt,{onSendMessage:ie,onStopGeneration:_,disabled:!i})]})]})};export{$t as ChatPage,$t 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-CEpaJrKd.js";import{t as r}from"./logger-1THq8-96.js";import{Dt as i,K as a,Lt as o,Mt as s,b as c,dt as l,ft as u,s as d,t as f,tt as p,u as m,vt as h}from"./ui-vendor-MCs1MDmN.js";import{m as g}from"./api-d05r9G59.js";import{g as _,k as v,n as y,t as b}from"../assets/index-CDA2f43l.js";var x=e(n(),1),S=t(),C=r(`components:first-time-setup`),w=({onComplete:e})=>{let{t}=v(),[n,r]=(0,x.useState)(`welcome`),[w,T]=(0,x.useState)(``),[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(``),[A,j]=(0,x.useState)(!1),[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(!1),[I,L]=(0,x.useState)(null),[R,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(!1),[H,U]=(0,x.useState)(``),{login:W,systemInfo:G}=_(),K=G?.turnstile?.siteKey,q=!!(G?.turnstile?.enabled&&K),J=(0,x.useCallback)(e=>{U(e)},[]),Y=(0,x.useMemo)(()=>P||q&&!H,[P,q,H]);(0,x.useEffect)(()=>{n===`encryption-key`&&!I&&g.getEncryptionKey().then(e=>{e.success&&e.data&&L(e.data.encryptionKey)})},[n,I]);let X=async e=>{if(e.preventDefault(),!w.trim()||!E.trim()||!O.trim()){o.error(t(`setup.admin.fillAllFields`));return}if(E!==O){o.error(t(`auth.signup.passwordMismatch`));return}if(E.length<6){o.error(t(`auth.signup.passwordTooShort`));return}if(q&&!H){o.error(t(`auth.signup.tryAgain`));return}F(!0);try{let e=await g.signup({username:w,password:E,email:``,turnstileToken:H});e.success&&e.data?(W(e.data.user,e.data.token,e.data.systemInfo),o.success(t(`setup.admin.success`)),r(`encryption-key`)):o.error(e.message||t(`setup.admin.failed`))}catch(e){C.error(`Admin creation error:`,e),o.error(t(`setup.admin.failed`))}finally{U(``),F(!1)}},Z=async()=>{if(I)try{await navigator.clipboard.writeText(I),z(!0),o.success(t(`setup.encryptionKey.copied`)),setTimeout(()=>z(!1),3e3)}catch{o.error(t(`setup.encryptionKey.copyFailed`))}},Q=()=>{if(!B){o.error(t(`setup.encryptionKey.confirmRequired`));return}e?.()},$=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return n===`welcome`?(0,S.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,S.jsx)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:(0,S.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,S.jsx)(y,{className:`text-gray-900 dark:text-gray-100`})})}),(0,S.jsx)(`div`,{className:`mt-8 sm:mx-auto sm:w-full sm:max-w-md`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-md mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200`,children:[(0,S.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2`,children:t(`setup.welcome.subtitle`)}),(0,S.jsx)(`p`,{className:`text-gray-600 dark:text-dark-500`,children:t(`setup.welcome.description`)})]}),(0,S.jsxs)(`div`,{className:`space-y-4 mb-6`,children:[(0,S.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,S.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,S.jsx)(c,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-950`,children:t(`setup.welcome.features.secure.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:t(`setup.welcome.features.secure.description`)})]})]}),(0,S.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,S.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,S.jsx)(f,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-950`,children:t(`setup.welcome.features.fast.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:t(`setup.welcome.features.fast.description`)})]})]}),(0,S.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,S.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,S.jsx)(p,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-950`,children:t(`setup.welcome.features.openSource.title`)}),(0,S.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:t(`setup.welcome.features.openSource.description`)})]})]})]}),(0,S.jsx)(`button`,{onClick:()=>r(`create-admin`),className:`w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-colors duration-200`,children:(0,S.jsxs)(`div`,{className:`flex items-center`,children:[(0,S.jsx)(`span`,{children:t(`setup.welcome.createAdmin`)}),(0,S.jsx)(s,{size:16,className:`ml-2`})]})})]})})]}):n===`encryption-key`?(0,S.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,S.jsxs)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:[(0,S.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,S.jsx)(y,{className:`text-gray-900 dark:text-gray-100`})}),(0,S.jsx)(`h2`,{className:`libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100`,style:{fontWeight:300,letterSpacing:0},children:t(`setup.encryptionKey.title`)})]}),(0,S.jsx)(`div`,{className:`mt-8 sm:mx-auto sm:w-full sm:max-w-lg`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-lg mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200`,children:[(0,S.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,S.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,S.jsx)(`div`,{className:`p-3 bg-amber-100 dark:bg-amber-900/30 rounded-full`,children:(0,S.jsx)(a,{className:`h-8 w-8 text-amber-600 dark:text-amber-400`})})}),(0,S.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2`,children:t(`setup.encryptionKey.subtitle`)}),(0,S.jsx)(`p`,{className:`text-gray-600 dark:text-dark-500`,children:t(`setup.encryptionKey.description`)})]}),(0,S.jsx)(`div`,{className:`mb-6 p-4 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg`,children:(0,S.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,S.jsx)(m,{className:`h-5 w-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5`}),(0,S.jsxs)(`div`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:[(0,S.jsx)(`p`,{className:`font-medium mb-1`,children:t(`setup.encryptionKey.warning`)}),(0,S.jsx)(`p`,{children:t(`setup.encryptionKey.warningText`)})]})]})}),(0,S.jsxs)(`div`,{className:`mb-6`,children:[(0,S.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:t(`setup.encryptionKey.label`)}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`div`,{className:`w-full px-3 py-3 pr-12 border border-gray-300 dark:border-dark-300 rounded-lg bg-gray-50 dark:bg-dark-100 font-mono text-sm text-gray-900 dark:text-dark-800 break-all`,children:I||t(`setup.encryptionKey.loading`)}),(0,S.jsx)(`button`,{type:`button`,onClick:Z,disabled:!I,className:`absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-500 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-700 disabled:opacity-50`,title:t(`setup.encryptionKey.copyToClipboard`),children:R?(0,S.jsx)(i,{className:`h-5 w-5 text-green-500`}):(0,S.jsx)(h,{className:`h-5 w-5`})})]}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`setup.encryptionKey.envNote`)})]}),(0,S.jsx)(`div`,{className:`mb-6`,children:(0,S.jsxs)(`label`,{className:`flex items-start space-x-3 cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:B,onChange:e=>V(e.target.checked),className:`mt-1 h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-dark-300 rounded`}),(0,S.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-dark-700`,children:t(`setup.encryptionKey.acknowledgment`)})]})}),(0,S.jsx)(`button`,{onClick:Q,disabled:!B,className:`w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200`,children:(0,S.jsxs)(`div`,{className:`flex items-center`,children:[(0,S.jsx)(`span`,{children:t(`setup.encryptionKey.continue`)}),(0,S.jsx)(s,{size:16,className:`ml-2`})]})})]})})]}):(0,S.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,S.jsxs)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:[(0,S.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,S.jsx)(y,{className:`text-gray-900 dark:text-gray-100`})}),(0,S.jsx)(`h2`,{className:`libre-brand mt-6 text-center text-2xl sm:text-3xl font-normal text-gray-900 dark:text-gray-100`,style:{fontWeight:300,letterSpacing:0},children:t(`setup.admin.title`)})]}),(0,S.jsx)(`div`,{className:`mt-8 sm:mx-auto sm:w-full sm:max-w-md`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-md mx-auto bg-white dark:bg-dark-25 rounded-xl shadow-card hover:shadow-card-hover transition-shadow duration-200 p-6 border border-gray-200 dark:border-dark-200`,children:[(0,S.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,S.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-950 mb-2`,children:t(`setup.admin.subtitle`)}),(0,S.jsx)(`p`,{className:`text-gray-600 dark:text-dark-500`,children:t(`setup.admin.description`)})]}),(0,S.jsxs)(`form`,{onSubmit:X,className:`space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`username`,className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:t(`auth.login.username`)}),(0,S.jsx)(`input`,{id:`username`,type:`text`,value:w,onChange:e=>T(e.target.value),onKeyDown:$,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200`,placeholder:t(`setup.admin.usernamePlaceholder`),required:!0,disabled:P})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`password`,className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:t(`auth.login.password`)}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`input`,{id:`password`,type:A?`text`:`password`,value:E,onChange:e=>D(e.target.value),onKeyDown:$,className:`w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200`,placeholder:t(`setup.admin.passwordPlaceholder`),required:!0,disabled:P}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>j(!A),className:`absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700`,disabled:P,children:A?(0,S.jsx)(u,{size:20}):(0,S.jsx)(l,{size:20})})]})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`confirmPassword`,className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:t(`auth.signup.confirmPassword`)}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`input`,{id:`confirmPassword`,type:M?`text`:`password`,value:O,onChange:e=>k(e.target.value),onKeyDown:$,className:`w-full px-3 py-2 pr-10 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 transition-colors duration-200`,placeholder:t(`setup.admin.confirmPlaceholder`),required:!0,disabled:P}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>N(!M),className:`absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-dark-500 dark:hover:text-dark-700`,disabled:P,children:M?(0,S.jsx)(u,{size:20}):(0,S.jsx)(l,{size:20})})]})]}),q&&K&&(0,S.jsx)(b,{siteKey:K,disabled:P,errorMessage:t(`auth.signup.tryAgain`),onTokenChange:J}),(0,S.jsxs)(`div`,{className:`flex space-x-3`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>r(`welcome`),disabled:P,className:`flex-1 px-4 py-2 border border-gray-300 dark:border-dark-300 rounded-lg shadow-sm text-sm font-medium text-gray-700 dark:text-dark-700 bg-white dark:bg-dark-100 hover:bg-gray-50 dark:hover:bg-dark-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200`,children:t(`common.back`)}),(0,S.jsx)(`button`,{type:`submit`,disabled:Y,className:`flex-1 flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200`,children:P?(0,S.jsxs)(`div`,{className:`flex items-center`,children:[(0,S.jsx)(`div`,{className:`animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2`}),t(`setup.admin.creating`)]}):(0,S.jsxs)(`div`,{className:`flex items-center`,children:[(0,S.jsx)(d,{size:16,className:`mr-2`}),t(`setup.admin.createAdmin`)]})})]})]}),(0,S.jsx)(`div`,{className:`mt-6 text-center`,children:(0,S.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:t(`setup.admin.note`)})})]})})]})};export{w as FirstTimeSetup};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-CEpaJrKd.js";import{n as r}from"./react-vendor-DtQrJICq.js";import{n as i,t as a}from"./useBaseQuery-CrdrLcmR.js";import{t as o}from"./logger-1THq8-96.js";import{A as s,J as c,Lt as l,St as u,U as d,Y as f,_t as p,d as m,ht as h,n as g,v as _,z as v}from"./ui-vendor-MCs1MDmN.js";import{l as y}from"./api-d05r9G59.js";import{t as b}from"./utils-es0n-47H.js";import{t as x}from"./Button-BmZQkAPD.js";import{I as S,L as C,N as w,k as T}from"../assets/index-CDA2f43l.js";var E=class extends i{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:S(t,n.data),hasPreviousPage:C(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function D(e,t){return a(e,E,t)}var O=e(n(),1),k=e(r(),1),A=t(),j=({image:e,onClose:t,onDelete:n,onDownload:r})=>{let{t:i}=T();return(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=``}},[t]),(0,k.createPortal)((0,A.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center`,onClick:t,children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/90 backdrop-blur-sm`}),(0,A.jsxs)(`div`,{className:`relative flex flex-col lg:flex-row max-w-7xl max-h-[95vh] w-full mx-4 gap-4`,onClick:e=>e.stopPropagation(),children:[(0,A.jsx)(`button`,{onClick:t,className:b(`absolute -top-12 right-0 lg:top-0 lg:-right-12 z-10`,`p-2 rounded-full`,`bg-white/10 hover:bg-white/20`,`transition-colors`),children:(0,A.jsx)(g,{className:`h-6 w-6 text-white`})}),(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-0`,children:(0,A.jsx)(`img`,{src:e.imageData,alt:e.prompt,className:`max-w-full max-h-[70vh] lg:max-h-[90vh] object-contain rounded-lg`})}),(0,A.jsxs)(`div`,{className:b(`w-full lg:w-80 flex-shrink-0`,`bg-white dark:bg-dark-100`,`rounded-xl p-4 lg:p-5`,`overflow-y-auto max-h-[25vh] lg:max-h-[90vh]`),children:[(0,A.jsxs)(`div`,{className:`mb-4`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400 mb-1`,children:i(`gallery.prompt`)}),(0,A.jsx)(`p`,{className:`text-gray-900 dark:text-gray-100 text-sm leading-relaxed`,children:e.prompt})]}),(0,A.jsxs)(`div`,{className:`space-y-3 mb-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(p,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,A.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.model`),`:`]}),(0,A.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:e.model})]}),e.size&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(v,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,A.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.size`),`:`]}),(0,A.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:e.size})]}),e.quality&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(`span`,{className:`w-4 h-4 flex items-center justify-center text-gray-400 dark:text-gray-500 text-xs font-bold`,children:`Q`}),(0,A.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.quality`),`:`]}),(0,A.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100 capitalize`,children:e.quality})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,A.jsx)(u,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,A.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.created`),`:`]}),(0,A.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:(e=>new Date(e).toLocaleString(void 0,{year:`numeric`,month:`long`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}))(e.createdAt)})]})]}),(0,A.jsxs)(`div`,{className:`flex gap-2 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,A.jsxs)(`button`,{onClick:()=>{if(r)r(e);else{let t=document.createElement(`a`);t.href=e.imageData,t.download=`generated-${e.id}.png`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}},className:b(`flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg`,`bg-primary-600 dark:bg-primary-600`,`hover:bg-primary-700 dark:hover:bg-primary-500`,`text-white font-medium text-sm`,`transition-colors`),children:[(0,A.jsx)(h,{className:`h-4 w-4`}),i(`gallery.download`)]}),n&&(0,A.jsx)(`button`,{onClick:()=>n(e.id),className:b(`p-2.5 rounded-lg`,`bg-gray-100 dark:bg-dark-200`,`hover:bg-red-100 dark:hover:bg-red-900/30`,`text-gray-600 dark:text-gray-300`,`hover:text-red-600 dark:hover:text-red-400`,`transition-colors`),title:`Delete image`,children:(0,A.jsx)(m,{className:`h-4 w-4`})})]})]})]})]}),document.body)},M=o(`components:image-gallery`),N=({onImageCountChange:e})=>{let{t}=T(),n=w(),[r,i]=(0,O.useState)(null),[a,o]=(0,O.useState)(null),{data:s,fetchNextPage:c,hasNextPage:u,isFetchingNextPage:p,isLoading:g}=D({queryKey:[`image-gallery`],queryFn:async({pageParam:e})=>{let n=await y.getGallery({limit:20,offset:e});if(!n.success||!n.data)throw Error(t(`imageGallery.loadFailed`));return n.data},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.images.length,0);return n<e.total?n:void 0}}),_=(0,O.useMemo)(()=>s?.pages.flatMap(e=>e.images)??[],[s]),v=s?.pages[0]?.total??0,x=p;(0,O.useEffect)(()=>{e?.(v)},[v,e]);let S=()=>{c()},C=async(e,s)=>{if(s.stopPropagation(),!a){o(e);try{(await y.deleteGalleryImage(e)).success?(await n.invalidateQueries({queryKey:[`image-gallery`]}),l.success(t(`imageGallery.deleteSuccess`)),r?.id===e&&i(null)):l.error(t(`imageGallery.deleteFailed`))}catch(e){M.error(`Failed to delete image:`,e),l.error(t(`imageGallery.deleteFailed`))}finally{o(null)}}},E=(e,t)=>{t.stopPropagation();let n=document.createElement(`a`);n.href=e.imageData,n.download=`generated-${e.id}.png`,document.body.appendChild(n),n.click(),document.body.removeChild(n)},k=e=>new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`});return g?(0,A.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,A.jsx)(d,{className:`h-8 w-8 animate-spin text-gray-400 dark:text-gray-500`})}):_.length===0?(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 text-center`,children:[(0,A.jsx)(f,{className:`h-16 w-16 text-gray-300 dark:text-gray-600 mb-4`}),(0,A.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`imageGallery.noImages`)}),(0,A.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 max-w-sm`,children:t(`imageGallery.noImagesHint`)})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:b(`columns-1 sm:columns-2 lg:columns-3 xl:columns-4`,`gap-4 space-y-4`),children:_.map(e=>(0,A.jsxs)(`div`,{className:b(`break-inside-avoid group relative cursor-pointer`,`rounded-xl overflow-hidden`,`bg-gray-100 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`hover:border-gray-300 dark:hover:border-dark-400`,`transition-all duration-200`,`hover:shadow-lg dark:hover:shadow-dark-400/20`),onClick:()=>i(e),children:[(0,A.jsx)(`img`,{src:e.imageData,alt:e.prompt,className:`w-full h-auto object-cover`,loading:`lazy`}),(0,A.jsxs)(`div`,{className:b(`absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent`,`opacity-0 group-hover:opacity-100 transition-opacity duration-200`,`flex flex-col justify-end p-3`),children:[(0,A.jsx)(`p`,{className:`text-white text-sm line-clamp-2 mb-2`,children:e.prompt}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(`span`,{className:`text-white/70 text-xs`,children:k(e.createdAt)}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(`button`,{onClick:t=>E(e,t),className:b(`p-1.5 rounded-lg`,`bg-white/20 hover:bg-white/30`,`transition-colors`),title:t(`imageGallery.download`),children:(0,A.jsx)(h,{className:`h-4 w-4 text-white`})}),(0,A.jsx)(`button`,{onClick:t=>C(e.id,t),disabled:a===e.id,className:b(`p-1.5 rounded-lg`,`bg-white/20 hover:bg-red-500/80`,`transition-colors`,a===e.id&&`opacity-50 cursor-not-allowed`),title:t(`imageGallery.delete`),children:a===e.id?(0,A.jsx)(d,{className:`h-4 w-4 text-white animate-spin`}):(0,A.jsx)(m,{className:`h-4 w-4 text-white`})})]})]})]})]},e.id))}),u&&(0,A.jsx)(`div`,{className:`flex justify-center mt-8`,children:(0,A.jsx)(`button`,{onClick:S,disabled:x,className:b(`px-6 py-2.5 rounded-xl font-medium`,`bg-gray-100 dark:bg-dark-200`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`text-gray-700 dark:text-gray-200`,`border border-gray-200 dark:border-dark-300`,`transition-colors`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:x?(0,A.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(d,{className:`h-4 w-4 animate-spin`}),t(`common.loading`)]}):t(`imageGallery.loadMore`,{current:_.length,total:v})})}),r&&(0,A.jsx)(j,{image:r,onClose:()=>i(null),onDelete:e=>{C(e,{stopPropagation:()=>{}})},onDownload:e=>{E(e,{stopPropagation:()=>{}})}})]})},P=o(`components:image-generation-panel`),F=({isOpen:e,onClose:t,onImageGenerated:n})=>{let{t:r}=T(),[i,a]=(0,O.useState)([]),[o,s]=(0,O.useState)(``),[u,f]=(0,O.useState)(``),[p,m]=(0,O.useState)(``),[v,S]=(0,O.useState)(`1024x1024`),[C,w]=(0,O.useState)(`standard`),[E,D]=(0,O.useState)(!1),[j,M]=(0,O.useState)(null),[N,F]=(0,O.useState)([`512x512`,`768x768`,`1024x1024`]),[I,L]=(0,O.useState)([`standard`,`high`]),[R,z]=(0,O.useState)(null);(0,O.useEffect)(()=>{e&&(async()=>{try{let e=await y.getPlugins();if(e.success&&e.data&&(a(e.data),e.data.length>0)){let t=e.data[0];s(t.id),t.models.length>0&&f(t.models[0]),t.config?.sizes&&(F(t.config.sizes),S(t.config.default_size||t.config.sizes[0]||`1024x1024`)),t.config?.qualities&&(L(t.config.qualities),w(t.config.default_quality||t.config.qualities[0]||`standard`)),z(t.config?.max_prompt_length??null)}}catch(e){P.error(`Failed to load image generation plugins:`,e)}})()},[e]);let[B,V]=(0,O.useState)(o);if(o!==B){V(o);let e=i.find(e=>e.id===o);e&&(e.models.length>0&&!e.models.includes(u)&&f(e.models[0]),e.config?.sizes&&(F(e.config.sizes),e.config.sizes.includes(v)||S(e.config.default_size||e.config.sizes[0])),e.config?.qualities&&(L(e.config.qualities),e.config.qualities.includes(C)||w(e.config.default_quality||e.config.qualities[0])),z(e.config?.max_prompt_length??null))}let H=async()=>{if(!u||!p.trim()){l.error(r(`imageGeneration.enterPrompt`));return}if(R&&p.length>R){l.error(r(`imageGeneration.promptTooLong`,{max:R.toLocaleString()}));return}D(!0),M(null);try{let e=await y.generate({model:u,prompt:p.trim(),size:v,quality:C});if(e.success&&e.data?.images&&e.data.images.length>0){let i=e.data.images[0],a=null;i.b64_json?a=`data:image/png;base64,${i.b64_json}`:i.url&&(a=i.url),a&&(l.success(r(`imageGeneration.success`)),n?(n(a,p.trim(),u),m(``),M(null),t()):M(a))}else l.error(r(`imageGeneration.failed`))}catch(e){P.error(`Image generation failed:`,e);let t=e instanceof Error?e.message:r(`imageGeneration.failed`);l.error(t)}finally{D(!1)}},U=()=>{if(!j)return;let e=document.createElement(`a`);e.href=j,e.download=`generated-image-${Date.now()}.png`,document.body.appendChild(e),e.click(),document.body.removeChild(e)};if(!e)return null;let W=i.find(e=>e.id===o);return(0,k.createPortal)((0,A.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center p-4`,children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,A.jsxs)(`div`,{className:b(`relative bg-white dark:bg-dark-100`,`border border-gray-200 dark:border-dark-300`,`rounded-2xl shadow-2xl`,`w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col`),onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-dark-300`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(c,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}),(0,A.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:r(`imageGeneration.title`)})]}),(0,A.jsx)(`button`,{onClick:t,className:`p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,children:(0,A.jsx)(g,{className:`h-5 w-5 text-gray-500 dark:text-gray-400`})})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:i.length===0?(0,A.jsxs)(`div`,{className:`text-center py-8`,children:[(0,A.jsx)(c,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,A.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:r(`imageGeneration.noModels`)}),(0,A.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mt-1`,children:r(`imageGeneration.configurePlugin`)})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`settings.plugins.title`)}),(0,A.jsx)(`select`,{value:o,onChange:e=>s(e.target.value),className:b(`w-full px-3 py-2 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:i.map(e=>(0,A.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.model`)}),(0,A.jsx)(`select`,{value:u,onChange:e=>f(e.target.value),className:b(`w-full px-3 py-2 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:W?.models.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.size`)}),(0,A.jsx)(`select`,{value:v,onChange:e=>S(e.target.value),className:b(`w-full px-3 py-2 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:N.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.quality`)}),(0,A.jsx)(`select`,{value:C,onChange:e=>w(e.target.value),className:b(`w-full px-3 py-2 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:I.map(e=>(0,A.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.prompt`)}),(0,A.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),placeholder:r(`imageGeneration.promptPlaceholder`),rows:5,className:b(`w-full px-3 py-2 rounded-lg text-sm resize-none`,`bg-gray-50 dark:bg-dark-200`,`border border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,R&&p.length>R&&`border-red-500 dark:border-red-500`)}),R&&(0,A.jsxs)(`div`,{className:b(`text-xs mt-1 text-right`,p.length>R?`text-red-500`:`text-gray-500 dark:text-gray-400`),children:[p.length.toLocaleString(),` /`,` `,R.toLocaleString()]})]}),j&&(0,A.jsxs)(`div`,{className:`relative rounded-xl overflow-hidden border border-gray-200 dark:border-dark-300`,children:[(0,A.jsx)(`img`,{src:j,alt:`Generated`,className:`w-full h-auto`}),(0,A.jsx)(`button`,{onClick:U,className:b(`absolute bottom-3 right-3 p-2 rounded-lg`,`bg-white/90 dark:bg-dark-100/90`,`hover:bg-white dark:hover:bg-dark-100`,`border border-gray-200 dark:border-dark-300`,`transition-colors`),title:r(`imageGallery.download`),children:(0,A.jsx)(h,{className:`h-5 w-5 text-gray-700 dark:text-gray-200`})})]})]})}),i.length>0&&(0,A.jsx)(`div`,{className:`p-4 border-t border-gray-200 dark:border-dark-300`,children:(0,A.jsx)(x,{onClick:H,disabled:E||!p.trim()||!u,className:b(`w-full py-2.5 rounded-xl font-medium`,`bg-primary-600 dark:bg-primary-600`,`hover:bg-primary-700 dark:hover:bg-primary-500`,`text-white`,`disabled:opacity-50 disabled:cursor-not-allowed`,`transition-colors`),children:E?(0,A.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,A.jsx)(d,{className:`h-4 w-4 animate-spin`}),r(`imageGeneration.generating`)]}):(0,A.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,A.jsx)(_,{className:`h-4 w-4`}),r(`imageGeneration.generate`)]})})})]})]}),document.body)},I=()=>{let{t:e}=T(),[t,n]=(0,O.useState)(null),[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(0),c=(0,O.useCallback)(()=>{o(e=>e+1)},[]);return(0,A.jsxs)(`div`,{className:`h-full overflow-auto`,children:[(0,A.jsxs)(`div`,{className:`max-w-7xl mx-auto p-6`,children:[(0,A.jsxs)(`div`,{className:`text-center max-w-md mx-auto mb-8`,children:[(0,A.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(`sidebar.navigation.imagine`)}),(0,A.jsxs)(`p`,{className:`text-gray-600 dark:text-dark-600 leading-relaxed`,children:[e(`gallery.subtitle`),t!==null&&t>0&&(0,A.jsxs)(`span`,{className:`text-gray-400 dark:text-gray-500`,children:[` `,`· `,e(`gallery.imageCount`,{count:t})]})]}),(0,A.jsxs)(x,{onClick:()=>i(!0),className:b(`mt-4 px-6 py-2.5 rounded-xl font-medium`,`bg-primary-600 dark:bg-primary-600`,`hover:bg-primary-700 dark:hover:bg-primary-500`,`text-white`,`transition-colors`),children:[(0,A.jsx)(s,{className:`h-4 w-4 mr-2`}),e(`gallery.generate`)]})]}),(0,A.jsx)(N,{onImageCountChange:n},a)]}),(0,A.jsx)(F,{isOpen:r,onClose:()=>i(!1),onImageGenerated:c})]})};export{I as GalleryPage,I 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-CEpaJrKd.js";import{n as r}from"./react-vendor-DtQrJICq.js";import{O as i,f as a,n as o,ut as s,vt as c}from"./ui-vendor-MCs1MDmN.js";import{t as l}from"./utils-es0n-47H.js";import{t as u}from"./Button-BmZQkAPD.js";import{k as d}from"../assets/index-CDA2f43l.js";n();var f=e(r(),1),p=t(),m=({models:e,showDetailsModal:t,setShowDetailsModal:n,selectedModelName:r,selectedModelDetails:m,loadingDetails:h,showCopyModal:g,setShowCopyModal:_,copySource:v,setCopySource:y,copyDestination:b,setCopyDestination:x,copying:S,handleCopyModel:C,showCreateModal:w,setShowCreateModal:T,createModelName:E,setCreateModelName:D,createModelfile:O,setCreateModelfile:k,creating:A,handleCreateModel:j,showEmbeddingsModal:M,setShowEmbeddingsModal:N,embeddingsModel:P,setEmbeddingsModel:F,embeddingsInput:I,setEmbeddingsInput:L,embeddingsResult:R,generatingEmbeddings:z,handleGenerateEmbeddings:B})=>{let{t:V}=d();return(0,p.jsxs)(p.Fragment,{children:[t&&(0,f.createPortal)((0,p.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>n(!1)}),(0,p.jsxs)(`div`,{className:l(`relative w-full max-w-2xl max-h-[85vh] overflow-hidden rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,p.jsxs)(`div`,{className:l(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,p.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[V(`modelManager.modals.details.title`),`: `,r]}),(0,p.jsx)(`button`,{onClick:()=>n(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,p.jsx)(o,{className:`h-5 w-5 text-gray-500`})})]}),(0,p.jsx)(`div`,{className:`overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4`,children:h?(0,p.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,p.jsx)(i,{className:`h-6 w-6 animate-spin text-gray-400`})}):m?(0,p.jsxs)(p.Fragment,{children:[m.details&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.info`)}),(0,p.jsx)(`div`,{className:l(`p-3 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-50`),children:(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[m.details.family&&(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.family`),`:`]}),` `,(0,p.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.family})]}),m.details.parameter_size&&(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.parameters`),`:`]}),` `,(0,p.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.parameter_size})]}),m.details.quantization_level&&(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.quantization`),`:`]}),` `,(0,p.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.quantization_level})]}),m.details.format&&(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.format`),`:`]}),` `,(0,p.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.format})]})]})})]}),m.system&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.systemPrompt`)}),(0,p.jsx)(`pre`,{className:l(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.system})]}),m.template&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.template`)}),(0,p.jsx)(`pre`,{className:l(`p-3 rounded-lg text-xs overflow-x-auto max-h-40`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.template})]}),m.parameters&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.parameters`)}),(0,p.jsx)(`pre`,{className:l(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.parameters})]}),m.license&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.license`)}),(0,p.jsx)(`pre`,{className:l(`p-3 rounded-lg text-xs overflow-x-auto max-h-32`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.license})]}),m.modelfile&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.modelfile`)}),(0,p.jsx)(`pre`,{className:l(`p-3 rounded-lg text-xs overflow-x-auto max-h-60`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.modelfile})]})]}):(0,p.jsx)(`p`,{className:`text-center text-gray-500`,children:V(`modelManager.modals.details.noDetails`)})})]})]}),document.body),g&&(0,f.createPortal)((0,p.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>_(!1)}),(0,p.jsxs)(`div`,{className:l(`relative w-full max-w-md rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,p.jsxs)(`div`,{className:l(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,p.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.copy.title`)}),(0,p.jsx)(`button`,{onClick:()=>_(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,p.jsx)(o,{className:`h-5 w-5 text-gray-500`})})]}),(0,p.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.source`)}),(0,p.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),className:l(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`),children:[(0,p.jsx)(`option`,{value:``,children:V(`modelManager.modals.copy.selectModel`)}),e.map(e=>(0,p.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.newName`)}),(0,p.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:V(`modelManager.modals.copy.placeholder`),className:l(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]}),(0,p.jsxs)(u,{onClick:C,disabled:!v.trim()||!b.trim()||S,className:l(`w-full gap-2`,``),children:[S?(0,p.jsx)(i,{className:`h-4 w-4 animate-spin`}):(0,p.jsx)(c,{className:`h-4 w-4`}),V(S?`modelManager.modals.copy.copying`:`modelManager.modals.copy.button`)]})]})]})]}),document.body),w&&(0,f.createPortal)((0,p.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>T(!1)}),(0,p.jsxs)(`div`,{className:l(`relative w-full max-w-lg rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,p.jsxs)(`div`,{className:l(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,p.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.create.title`)}),(0,p.jsx)(`button`,{onClick:()=>T(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,p.jsx)(o,{className:`h-5 w-5 text-gray-500`})})]}),(0,p.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.name`)}),(0,p.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:V(`modelManager.modals.create.namePlaceholder`),className:l(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.modelfile`)}),(0,p.jsx)(`textarea`,{value:O,onChange:e=>k(e.target.value),placeholder:V(`modelManager.modals.create.modelfilePlaceholder`),rows:8,className:l(`w-full px-3 py-2 rounded-lg border text-sm font-mono`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`,`resize-none`)}),(0,p.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500`,children:[V(`modelManager.modals.create.see`),` `,(0,p.jsx)(`a`,{href:`https://github.com/ollama/ollama/blob/main/docs/modelfile.md`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 hover:underline`,children:V(`modelManager.modals.create.docs`)}),` `,V(`modelManager.modals.create.docsLink`)]})]}),(0,p.jsxs)(u,{onClick:j,disabled:!E.trim()||!O.trim()||A,className:l(`w-full gap-2`,``),children:[A?(0,p.jsx)(i,{className:`h-4 w-4 animate-spin`}):(0,p.jsx)(s,{className:`h-4 w-4`}),V(A?`modelManager.modals.create.creating`:`modelManager.modals.create.button`)]})]})]})]}),document.body),M&&(0,f.createPortal)((0,p.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,p.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>N(!1)}),(0,p.jsxs)(`div`,{className:l(`relative w-full max-w-lg rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,p.jsxs)(`div`,{className:l(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,p.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.embeddings.title`)}),(0,p.jsx)(`button`,{onClick:()=>N(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,p.jsx)(o,{className:`h-5 w-5 text-gray-500`})})]}),(0,p.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.model`)}),(0,p.jsxs)(`select`,{value:P,onChange:e=>F(e.target.value),className:l(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`),children:[(0,p.jsx)(`option`,{value:``,children:V(`modelManager.modals.embeddings.selectModel`)}),e.map(e=>(0,p.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,p.jsx)(`p`,{className:`mt-1 text-xs text-gray-500`,children:V(`modelManager.modals.embeddings.recommended`)})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.input`)}),(0,p.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:V(`modelManager.modals.embeddings.placeholder`),rows:3,className:l(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`,`resize-none`)})]}),(0,p.jsxs)(u,{onClick:B,disabled:!P.trim()||!I.trim()||z,className:l(`w-full gap-2`,``),children:[z?(0,p.jsx)(i,{className:`h-4 w-4 animate-spin`}):(0,p.jsx)(a,{className:`h-4 w-4`}),V(z?`modelManager.modals.embeddings.generating`:`modelManager.modals.embeddings.button`)]}),R&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.result`,{count:R.length})}),(0,p.jsxs)(`pre`,{className:l(`p-3 rounded-lg text-xs overflow-x-auto max-h-32`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:[`[`,R.slice(0,10).join(`, `),R.length>10&&`, ...`,` ]`]})]})]})]})]}),document.body)]})};export{m as ModelManagerModals,m as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/ModelManagerModals-D3SZV7CU.js","assets/index-CDA2f43l.js","js/rolldown-runtime-QTnfLwEv.js","js/logger-1THq8-96.js","js/demoMode-BhEpMVh5.js","js/Button-BmZQkAPD.js","js/utils-es0n-47H.js","js/utils-vendor-B2ZBL57Y.js","js/markdown-core-CEpaJrKd.js","js/api-d05r9G59.js","js/ui-vendor-MCs1MDmN.js","js/react-vendor-DtQrJICq.js","assets/index-BxHDVIti.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-CEpaJrKd.js";import{t as r}from"./useQuery-DaEnYfWR.js";import{r as i,t as a}from"./logger-1THq8-96.js";import{$ as o,C as s,Ct as c,Dt as l,Et as u,Ft as d,H as f,O as p,Q as m,R as h,Rt as g,S as ee,St as _,T as v,W as te,Z as y,_t as b,at as ne,d as x,f as S,ht as C,n as w,ot as re,pt as T,q as ie,t as ae,ut as oe,vt as se,xt as ce}from"./ui-vendor-MCs1MDmN.js";import{c as E,u as le}from"./api-d05r9G59.js";import{t as D}from"./utils-es0n-47H.js";import{t as O}from"./Button-BmZQkAPD.js";import{N as ue,g as de,k}from"../assets/index-CDA2f43l.js";var A=e(n(),1),j=t();function fe({expanded:e,models:t,search:n,task:r,sort:i,loadingModels:a,canInstallModels:o,expandedModelId:s,loadingGgufModelId:l,ggufFiles:d,pullingModel:m,pullProgress:h,setSearch:g,setTask:ee,setSort:_,onToggle:te,onToggleModel:y,onPullGguf:b,onCancelPull:ne,onRefresh:x}){let{t:S}=k();return(0,j.jsxs)(`div`,{className:D(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,j.jsxs)(`button`,{onClick:te,className:D(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:D(`p-2 rounded-lg`,`bg-yellow-100 dark:bg-yellow-900/30`),children:(0,j.jsx)(ae,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400`})}),(0,j.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:S(`modelManager.sections.huggingface`,`HuggingFace Hub`)}),t.length>0&&(0,j.jsxs)(`span`,{className:D(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,S(`modelManager.library.available`,`available`)]})]}),e?(0,j.jsx)(c,{className:`h-5 w-5 text-gray-500`}):(0,j.jsx)(u,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,j.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,j.jsxs)(`div`,{className:`relative flex-1`,children:[(0,j.jsx)(v,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,j.jsx)(`input`,{type:`text`,value:n,onChange:e=>g(e.target.value),placeholder:S(`modelManager.huggingface.search`,`Search HuggingFace models...`),className:D(`w-full pl-10 pr-4 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,j.jsxs)(`select`,{value:r,onChange:e=>ee(e.target.value),className:D(`px-3 py-2 rounded-lg border text-sm min-w-[160px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,j.jsx)(`option`,{value:`text-generation`,children:S(`modelManager.huggingface.tasks.textGen`,`Text Generation`)}),(0,j.jsx)(`option`,{value:`text-to-speech`,children:S(`modelManager.huggingface.tasks.tts`,`Text to Speech`)}),(0,j.jsx)(`option`,{value:`text-to-image`,children:S(`modelManager.huggingface.tasks.image`,`Text to Image`)}),(0,j.jsx)(`option`,{value:`automatic-speech-recognition`,children:S(`modelManager.huggingface.tasks.stt`,`Speech Recognition`)})]}),(0,j.jsxs)(`select`,{value:i,onChange:e=>_(e.target.value),className:D(`px-3 py-2 rounded-lg border text-sm min-w-[140px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,j.jsx)(`option`,{value:`downloads`,children:S(`modelManager.huggingface.sort.downloads`,`Most Downloads`)}),(0,j.jsx)(`option`,{value:`likes`,children:S(`modelManager.huggingface.sort.likes`,`Most Liked`)}),(0,j.jsx)(`option`,{value:`lastModified`,children:S(`modelManager.huggingface.sort.recent`,`Recently Updated`)})]})]}),!o&&(0,j.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:S(`modelManager.pull.restricted`)}),a?(0,j.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,j.jsx)(f,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,j.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:S(`modelManager.huggingface.noResults`,`No models found. Try adjusting your search or filters.`)}):(0,j.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:t.map(e=>(0,j.jsx)(pe,{model:e,expanded:s===e.id,loadingGguf:l===e.id,ggufFiles:d[e.id]||[],pullingModel:m,pullProgress:h,canInstallModels:o,onToggle:()=>y(e.id),onPullGguf:b,onCancelPull:ne},e.id))}),(0,j.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,j.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,className:D(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,j.jsx)(T,{className:`h-3 w-3`}),S(`modelManager.huggingface.browseAll`,`Browse all on HuggingFace`)]}),(0,j.jsxs)(O,{onClick:x,variant:`outline`,size:`sm`,disabled:a,className:D(`gap-1.5`,``,``),children:[(0,j.jsx)(p,{className:D(`h-3.5 w-3.5`,a&&`animate-spin`)}),S(`modelManager.library.refresh`,`Refresh`)]})]})]})]})}function pe({model:e,expanded:t,loadingGguf:n,ggufFiles:r,pullingModel:i,pullProgress:a,canInstallModels:o,onToggle:s,onPullGguf:c,onCancelPull:l}){let{t:d}=k();return(0,j.jsxs)(`div`,{className:D(`rounded-lg border transition-all overflow-hidden`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,j.jsxs)(`div`,{className:`p-4 cursor-pointer`,onClick:s,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,j.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800 truncate`,children:e.id}),e.gated&&(0,j.jsx)(`span`,{className:D(`px-1.5 py-0.5 rounded text-xs`,`bg-yellow-100 dark:bg-yellow-900/30`,`text-yellow-700 dark:text-yellow-400`),children:d(`modelManager.huggingface.gated`,`Gated`)})]}),(0,j.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-0.5`,children:[d(`modelManager.huggingface.by`,`by`),` `,e.author]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,j.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 transition-colors`,title:d(`modelManager.huggingface.viewOnHF`,`View on HuggingFace`),children:(0,j.jsx)(T,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`})}),(0,j.jsx)(u,{className:D(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(C,{className:`h-3.5 w-3.5`}),M(e.downloads)]}),(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(y,{className:`h-3.5 w-3.5`}),M(e.likes)]}),e.pipeline_tag&&(0,j.jsx)(`span`,{className:D(`px-1.5 py-0.5 rounded`,`bg-gray-200 dark:bg-dark-300`),children:e.pipeline_tag})]})]}),t&&(0,j.jsx)(me,{modelId:e.id,loading:n,files:r,pullingModel:i,pullProgress:a,canInstallModels:o,onPullGguf:c,onCancelPull:l})]})}function me({modelId:e,loading:t,files:n,pullingModel:r,pullProgress:i,canInstallModels:a,onPullGguf:o,onCancelPull:s}){let{t:c}=k();return(0,j.jsx)(`div`,{className:`px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100`,children:t?(0,j.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,j.jsx)(f,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,j.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:c(`modelManager.huggingface.checkingGguf`)})]}):n.length===0?(0,j.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:c(`modelManager.huggingface.noGgufAvailable`)}):(0,j.jsxs)(`div`,{className:`space-y-2`,children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:c(`modelManager.huggingface.ggufFilesCount`,{count:n.length})}),n.map(e=>(0,j.jsx)(he,{file:e,pulling:r===e.ollamaCommand,pullProgress:i,canInstallModels:a,disabled:!!r||!a,onPullGguf:o,onCancelPull:s},e.filename)),r?.startsWith(`hf.co/`)&&r.includes(e)&&i?.percent!==void 0&&(0,j.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,j.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${i.percent}%`}})})]})})}function he({file:e,pulling:t,disabled:n,pullProgress:r,onPullGguf:i,onCancelPull:a}){let{t:o}=k();return(0,j.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300`,children:[(0,j.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,j.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,j.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:r?.percent===void 0?`...`:`${r.percent}%`}),(0,j.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,j.jsx)(w,{className:`h-4 w-4`})})]}):(0,j.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(e.ollamaCommand,e.filename)},disabled:n,className:D(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,j.jsx)(C,{className:`h-3 w-3 inline mr-1`}),o(`models.pull`)]})]})}function M(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e}function ge({expanded:e,models:t,onToggle:n,isModelRunning:r,formatSize:i,onShowModel:a,onCopyModel:s,onDeleteModel:l}){let{t:d}=k();return(0,j.jsxs)(`div`,{className:D(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,j.jsxs)(`button`,{onClick:n,className:D(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:D(`p-2 rounded-lg`,`bg-blue-100 dark:bg-blue-900/30`),children:(0,j.jsx)(o,{className:`h-5 w-5 text-blue-600 dark:text-blue-400`})}),(0,j.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:d(`modelManager.sections.local`)}),(0,j.jsxs)(`span`,{className:D(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,d(`modelManager.local.installed`)]})]}),e?(0,j.jsx)(c,{className:`h-5 w-5 text-gray-500`}):(0,j.jsx)(u,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,j.jsx)(`div`,{className:`p-4 pt-0`,children:t.length===0?(0,j.jsxs)(`div`,{className:D(`text-center py-12 rounded-lg border-2 border-dashed`,`border-gray-200 dark:border-dark-300`),children:[(0,j.jsx)(o,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,j.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-2`,children:d(`modelManager.local.noModels`)}),(0,j.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:d(`modelManager.local.pullToStart`)})]}):(0,j.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,j.jsx)(_e,{model:e,running:r(e.name),formatSize:i,onShowModel:a,onCopyModel:s,onDeleteModel:l},e.name))})})]})}function _e({model:e,running:t,formatSize:n,onShowModel:r,onCopyModel:i,onDeleteModel:a}){let{t:s}=k();return(0,j.jsx)(`div`,{className:D(`p-4 rounded-lg border transition-colors`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:bg-gray-100 dark:hover:bg-dark-200`),children:(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,j.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,j.jsxs)(`span`,{className:D(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,j.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse`}),s(`modelManager.local.running`)]})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 mt-2`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(o,{className:`h-3.5 w-3.5`}),n(e.size)]}),e.details?.parameter_size&&(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(b,{className:`h-3.5 w-3.5`}),e.details.parameter_size]}),e.details?.quantization_level&&(0,j.jsx)(`span`,{className:D(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e.details.quantization_level}),e.details?.family&&(0,j.jsx)(`span`,{className:`text-gray-500 dark:text-gray-500`,children:e.details.family})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 mt-2`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(_,{className:`h-3 w-3`}),new Date(e.modified_at).toLocaleDateString()]}),(0,j.jsxs)(`span`,{className:`flex items-center gap-1 font-mono truncate max-w-[200px]`,title:e.digest,children:[(0,j.jsx)(m,{className:`h-3 w-3`}),e.digest.slice(0,12),`...`]})]})]}),(0,j.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,j.jsxs)(O,{onClick:()=>r(e.name),variant:`outline`,size:`sm`,className:D(`gap-1.5`,``,``),children:[(0,j.jsx)(ie,{className:`h-3.5 w-3.5`}),s(`modelManager.local.info`)]}),(0,j.jsxs)(O,{onClick:()=>i(e.name),variant:`outline`,size:`sm`,className:D(`gap-1.5`,``,``),children:[(0,j.jsx)(se,{className:`h-3.5 w-3.5`}),s(`modelManager.local.copy`)]}),(0,j.jsxs)(O,{onClick:()=>a(e.name),variant:`outline`,size:`sm`,className:D(`gap-1.5`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,j.jsx)(x,{className:`h-3.5 w-3.5`}),s(`modelManager.local.delete`)]})]})]})})}function ve({expanded:e,models:t,totalAvailable:n,categories:r,filter:i,search:a,loading:o,pulling:s,canInstallModels:l,pullSectionExpanded:d,setFilter:f,setSearch:m,isModelInstalled:h,normalizeCloudPullName:g,onToggle:ee,onTogglePullSection:_,onPullModel:te,onRefresh:y}){let{t:b}=k();return(0,j.jsxs)(`div`,{className:D(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,j.jsxs)(`button`,{onClick:ee,className:D(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:D(`p-2 rounded-lg`,`bg-blue-100 dark:bg-blue-900/30`),children:(0,j.jsx)(ce,{className:`h-5 w-5 text-blue-600 dark:text-blue-400`})}),(0,j.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:b(`modelManager.sections.library`)}),(0,j.jsxs)(`span`,{className:D(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[n,` `,b(`modelManager.library.available`)]})]}),e?(0,j.jsx)(c,{className:`h-5 w-5 text-gray-500`}):(0,j.jsx)(u,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,j.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,j.jsxs)(`div`,{className:`relative flex-1`,children:[(0,j.jsx)(v,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,j.jsx)(`input`,{type:`text`,value:a,onChange:e=>m(e.target.value),placeholder:b(`modelManager.library.search`),className:D(`w-full pl-10 pr-4 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(re,{className:`h-4 w-4 text-gray-400`}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,j.jsx)(`button`,{onClick:()=>f(e),className:D(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,i===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),o?(0,j.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,j.jsx)(p,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,j.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:b(`modelManager.library.noResults`)}):(0,j.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.category===`cloud`?g(e.name):e.name;return(0,j.jsx)(ye,{model:e,installed:h(e.name)||h(t),pulling:s,canInstallModels:l,pullSectionExpanded:d,onTogglePullSection:_,onPullModel:te},e.name)})}),(0,j.jsx)(`div`,{className:`flex justify-center`,children:(0,j.jsxs)(O,{onClick:y,variant:`outline`,size:`sm`,disabled:o,className:D(`gap-1.5`,``,``),children:[(0,j.jsx)(p,{className:D(`h-3.5 w-3.5`,o&&`animate-spin`)}),b(`modelManager.library.refresh`)]})})]})]})}function ye({model:e,installed:t,pulling:n,canInstallModels:r,pullSectionExpanded:i,onTogglePullSection:a,onPullModel:o}){let{t:s}=k();return(0,j.jsxs)(`div`,{"data-testid":`library-model-card-${e.name}`,className:D(`p-4 rounded-lg border transition-all`,`bg-gray-50 dark:bg-dark-50`,t?`border-green-200 dark:border-green-800/50`:`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,j.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,j.jsxs)(`span`,{className:D(`flex items-center gap-1 px-1.5 py-0.5 rounded text-xs`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,j.jsx)(l,{className:`h-3 w-3`}),s(`modelManager.library.installed`)]})]}),(0,j.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-dark-600 mb-3 line-clamp-2`,children:e.description}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.sizes.slice(0,4).map(e=>(0,j.jsx)(`span`,{className:D(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e},e)),e.sizes.length>4&&(0,j.jsx)(`span`,{className:`text-xs text-gray-400`,children:s(`modelManager.library.more`,{count:e.sizes.length-4})})]}),(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[e.pulls&&(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(C,{className:`h-3 w-3`}),e.pulls]}),(0,j.jsx)(`span`,{className:D(`px-1.5 py-0.5 rounded capitalize`,e.category===`cloud`?`bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400`:`bg-gray-100 dark:bg-dark-200`),children:e.category})]}),(0,j.jsxs)(O,{"data-testid":`library-model-pull-${e.name}`,onClick:()=>{i||a(),o(e.name,e.category)},variant:`outline`,size:`sm`,disabled:n||!r,className:D(`gap-1 text-xs`,``,``),children:[(0,j.jsx)(C,{className:`h-3 w-3`}),s(`modelManager.pull.button`)]})]})]})}function be({expanded:e,modelName:t,setModelName:n,pulling:r,progress:i,canInstallModels:a,popularModels:o,onToggle:s,onPull:l,onCancelPull:d,formatSize:f}){let{t:p}=k();return(0,j.jsxs)(`div`,{className:D(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,j.jsxs)(`button`,{onClick:s,className:D(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:D(`p-2 rounded-lg`,`bg-primary-100 dark:bg-primary-900/30`),children:(0,j.jsx)(C,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,j.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:p(`modelManager.sections.pull`)})]}),e?(0,j.jsx)(c,{className:`h-5 w-5 text-gray-500`}):(0,j.jsx)(u,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,j.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(`div`,{className:`relative flex-1`,children:[(0,j.jsx)(v,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,j.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:p(`modelManager.pull.placeholder`),className:D(`w-full pl-10 pr-4 py-2.5 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`),disabled:r||!a,onKeyDown:e=>{e.key===`Enter`&&!r&&a&&l()}})]}),r?(0,j.jsxs)(O,{onClick:d,variant:`outline`,className:D(`px-4 py-2.5 gap-2`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,j.jsx)(w,{className:`h-4 w-4`}),p(`modelManager.pull.cancel`)]}):(0,j.jsxs)(O,{onClick:l,disabled:!t.trim()||!a,className:D(`px-4 py-2.5 gap-2`,``),children:[(0,j.jsx)(C,{className:`h-4 w-4`}),p(`modelManager.pull.button`)]})]}),r&&i&&(0,j.jsx)(xe,{progress:i,formatSize:f}),!a&&(0,j.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:p(`modelManager.pull.restricted`)}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 mb-2`,children:p(`modelManager.pull.popular`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.map(e=>(0,j.jsxs)(`button`,{onClick:()=>n(e.name),disabled:r||!a,className:D(`px-3 py-1.5 rounded-full text-xs font-medium transition-colors`,`bg-gray-100 dark:bg-dark-200`,`text-gray-700 dark:text-gray-300`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`border border-gray-200 dark:border-dark-300`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[e.name,(0,j.jsx)(`span`,{className:`ml-1 text-gray-400 dark:text-gray-500`,children:e.size})]},e.name))})]}),(0,j.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,className:D(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,j.jsx)(T,{className:`h-3 w-3`}),p(`modelManager.pull.browseAll`)]})]})]})}function xe({progress:e,formatSize:t}){let{t:n}=k(),r=e.status===`starting`?n(`modelManager.progress.starting`):e.status.startsWith(`pulling`)?`${n(`modelManager.progress.pullingLayer`)} ${e.status.replace(`pulling `,``)}`:e.status.startsWith(`verifying sha256`)?n(`modelManager.progress.verifyingDigest`):e.status===`writing manifest`?n(`modelManager.progress.writing`):e.status===`removing any unused layers`?n(`modelManager.progress.cleaning`):e.status;return(0,j.jsxs)(`div`,{className:D(`p-4 rounded-lg border`,`bg-gray-50 dark:bg-dark-200`,`border-gray-200 dark:border-dark-300`),children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,j.jsx)(`span`,{className:`text-sm font-medium text-gray-800 dark:text-dark-700`,children:r}),e.percent!==void 0&&(0,j.jsxs)(`span`,{className:`text-sm font-mono text-gray-600 dark:text-dark-600`,children:[e.percent,`%`]})]}),e.percent!==void 0&&(0,j.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-400 rounded-full h-2 overflow-hidden`,children:(0,j.jsx)(`div`,{className:D(`h-2 rounded-full transition-all duration-300`,`bg-primary-500 dark:bg-primary-400`),style:{width:`${e.percent}%`}})}),e.total&&e.completed&&(0,j.jsxs)(`div`,{className:`mt-2 text-xs text-gray-600 dark:text-dark-600`,children:[t(e.completed),` / `,t(e.total)]})]})}var Se=a(`components:model-manager`),Ce=A.lazy(()=>i(()=>import(`./ModelManagerModals-D3SZV7CU.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),N=e=>{let t=e.split(`:`).pop()?.toLowerCase();return t===`cloud`||t?.endsWith(`-cloud`)===!0},we=e=>{let t=e.trim();if(!t||N(t))return t;let n=t.lastIndexOf(`:`);return n===-1?`${t}:cloud`:`${t.slice(0,n)}:${t.slice(n+1)}-cloud`},P=()=>{let{t:e}=k(),{user:t,systemInfo:n}=de(),i=t?.role===`admin`||(n?.allowUserModelPull??!0),a=ue(),[l,f]=(0,A.useState)(`all`),[m,_]=(0,A.useState)(``),[v,y]=(0,A.useState)(``),[b,x]=(0,A.useState)(!1),[C,w]=(0,A.useState)(null),[re,T]=(0,A.useState)(null),[ie,ce]=(0,A.useState)(null),[pe,me]=(0,A.useState)(``),[he,M]=(0,A.useState)(!1),[_e,ye]=(0,A.useState)(!1),[xe,N]=(0,A.useState)(!1),[P,F]=(0,A.useState)(``),[I,Te]=(0,A.useState)(``),[Ee,De]=(0,A.useState)(!1),[Oe,ke]=(0,A.useState)(!1),[L,Ae]=(0,A.useState)(``),[R,je]=(0,A.useState)(``),[Me,Ne]=(0,A.useState)(!1),[Pe,Fe]=(0,A.useState)(!1),[z,Ie]=(0,A.useState)(``),[Le,Re]=(0,A.useState)(``),[ze,Be]=(0,A.useState)(null),[Ve,He]=(0,A.useState)(!1),[Ue,We]=(0,A.useState)(``),[Ge,Ke]=(0,A.useState)(``),[B,qe]=(0,A.useState)(`text-generation`),[V,Je]=(0,A.useState)(`downloads`),[Ye,Xe]=(0,A.useState)(null),[Ze,Qe]=(0,A.useState)({}),[$e,et]=(0,A.useState)(null),[tt,H]=(0,A.useState)(null),[nt,U]=(0,A.useState)(null),[rt,W]=(0,A.useState)(null),[G,it]=(0,A.useState)(new Set([`pull`,`local`])),K=e=>{it(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},{data:q,isLoading:at,refetch:J}=r({queryKey:[`ollama-state`],queryFn:async()=>{let[e,t,n,r]=await Promise.all([E.getModels(),E.listRunningModels(),E.getVersion(),E.checkHealth()]);return{models:e.success&&e.data||[],runningModels:t.success&&Array.isArray(t.data)?t.data:[],ollamaVersion:n.success&&n.data?n.data.version:null,isHealthy:r.success}}}),Y=q?.models??[],X=q?.runningModels??[],ot=q?.ollamaVersion??null,st=q?.isHealthy??null,Z=(0,A.useCallback)(async()=>{await J()},[J]),{data:Q=[],isLoading:ct}=r({queryKey:[`ollama-library`],queryFn:async()=>{let e=await E.getLibraryModels();return e.success&&e.data?e.data:[]}}),{data:lt=[],isLoading:ut}=r({queryKey:[`ollama-library`,`cloud`],queryFn:async()=>{let e=await E.getLibraryModels({category:`cloud`});return e.success&&e.data?e.data:[]},enabled:l===`cloud`}),dt=()=>a.invalidateQueries({queryKey:[`ollama-library`]});(0,A.useEffect)(()=>{let e=setTimeout(()=>{Ke(Ue)},300);return()=>clearTimeout(e)},[Ue]);let ft=G.has(`huggingface`),{data:pt=[],isLoading:mt}=r({queryKey:[`hf-models`,B,Ge,V],queryFn:async()=>{let e=await le.getModels({task:B,search:Ge||void 0,sort:V,limit:30});return e.success&&e.data?e.data:[]},enabled:ft}),ht=()=>a.invalidateQueries({queryKey:[`hf-models`,B,Ge,V]}),gt=(0,A.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){et(e);try{let r=await le.getGgufFiles(t,n);r.success&&r.data&&Qe(t=>({...t,[e]:r.data}))}catch(e){Se.error(`Failed to load GGUF files:`,e)}finally{et(null)}}},[]),_t=(0,A.useCallback)(e=>{Ye===e?Xe(null):(Xe(e),Ze[e]||gt(e))},[Ye,Ze,gt]),vt=(0,A.useCallback)((t,n)=>{if(!i){g.error(e(`modelManager.pull.restricted`));return}if(!tt){H(t),U({status:`starting`});try{let e=E.pullModelStream(t,e=>{U(e)},()=>{U(null),H(null),W(null),g.success(`Downloaded ${n}`),Z()},e=>{U(null),H(null),W(null),g.error(`Failed to download: ${e}`)});W(()=>e)}catch{U(null),H(null),g.error(`Failed to start download`)}}},[i,tt,Z,e]),yt=(0,A.useCallback)(()=>{rt&&(rt(),W(null),H(null),U(null))},[rt]),bt=async(t,n)=>{if(!i){g.error(e(`modelManager.pull.restricted`));return}let r=t||v.trim(),a=n===`cloud`||!t&&l===`cloud`?we(r):r;if(!a){g.error(e(`modelManager.pull.enterName`));return}t&&y(a),x(!0),w({status:`starting`});try{let t=E.pullModelStream(a,e=>{w(e)},()=>{w(null),x(!1),T(null),g.success(e(`modelManager.pull.success`,{name:a})),y(``),Z()},t=>{w(null),x(!1),T(null),g.error(e(`modelManager.pull.failed`)+`: `+t)});T(()=>t)}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.pull.failed`)+`: `+n),w(null),x(!1),T(null)}},xt=()=>{re&&(re(),T(null),x(!1),w(null),g.success(e(`modelManager.pull.cancelled`)))},St=async t=>{if(confirm(e(`modelManager.local.deleteConfirm`,{name:t})))try{await E.deleteModel(t),g.success(e(`modelManager.local.deleteSuccess`,{name:t})),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.local.deleteFailed`)+`: `+n)}},Ct=async t=>{ye(!0),me(t),M(!0);try{let n=await E.showModel(t,!0);n.success&&n.data?ce(n.data):g.error(e(`modelManager.modals.details.noDetails`))}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.modals.details.noDetails`)+`: `+n)}finally{ye(!1)}},wt=async()=>{if(!P.trim()||!I.trim()){g.error(e(`modelManager.modals.copy.enterBoth`));return}De(!0);try{await E.copyModel(P.trim(),I.trim()),g.success(e(`modelManager.modals.copy.success`,{name:I})),N(!1),F(``),Te(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.modals.copy.failed`)+`: `+n)}finally{De(!1)}},Tt=async()=>{if(!L.trim()||!R.trim()){g.error(e(`modelManager.modals.create.enterBoth`));return}Ne(!0);try{await E.createModel({model:L.trim(),modelfile:R.trim()}),g.success(e(`modelManager.modals.create.success`,{name:L})),ke(!1),Ae(``),je(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.modals.create.failed`)+`: `+n)}finally{Ne(!1)}},Et=async()=>{if(!z.trim()||!Le.trim()){g.error(e(`modelManager.modals.embeddings.enterBoth`));return}He(!0),Be(null);try{let t=await E.generateEmbeddings({model:z.trim(),input:Le.trim()});if(t.success&&t.data){let n=t.data.embeddings?.[0]||[];Be(n),g.success(e(`modelManager.modals.embeddings.success`,{count:n.length}))}}catch(t){let n=t instanceof Error?t.message:String(t);g.error(e(`modelManager.modals.embeddings.failed`)+`: `+n)}finally{He(!1)}},$=e=>{let t=e/(1024*1024*1024);return t>=1?`${t.toFixed(2)} GB`:`${(e/(1024*1024)).toFixed(1)} MB`},Dt=e=>Array.isArray(X)&&X.some(t=>t.name===e),Ot=()=>Y.reduce((e,t)=>e+t.size,0),kt=()=>X.reduce((e,t)=>e+(t.size_vram||0),0),At=e=>Y.some(t=>t.name===e||t.name.startsWith(e+`:`)),jt=(l===`cloud`?lt:Q).filter(e=>{let t=l===`all`||l===`cloud`||e.category===l,n=!m||e.name.toLowerCase().includes(m.toLowerCase())||e.description.toLowerCase().includes(m.toLowerCase());return t&&n}),Mt=[`all`,...new Set([...Q.map(e=>e.category),`cloud`])],Nt=(0,A.useMemo)(()=>Q.length>0?Q.slice(0,10).map(e=>({name:e.name,category:e.category,size:e.sizes?.[0]||``})):[{name:`deepseek-r1`,category:`reasoning`,size:`7B`},{name:`llama3.2`,category:`general`,size:`3B`},{name:`gemma3`,category:`general`,size:`4B`},{name:`qwen2.5`,category:`general`,size:`7B`},{name:`mistral`,category:`general`,size:`7B`},{name:`codellama`,category:`coding`,size:`7B`},{name:`nomic-embed-text`,category:`embedding`,size:`137M`},{name:`llava`,category:`vision`,size:`7B`},{name:`phi3`,category:`general`,size:`3.8B`},{name:`gemma2`,category:`general`,size:`9B`}],[Q]),Pt=he||xe||Oe||Pe;return at?(0,j.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-gray-600 dark:text-dark-600`,children:[(0,j.jsx)(p,{className:`h-5 w-5 animate-spin`}),e(`modelManager.loading`)]})}):(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(`div`,{className:D(`rounded-xl p-4 border`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`div`,{className:D(`w-2.5 h-2.5 rounded-full`,st?`bg-green-500`:`bg-red-500`)}),(0,j.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(st?`modelManager.systemStatus.online`:`modelManager.systemStatus.offline`)})]}),ot&&(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,j.jsx)(s,{className:`h-4 w-4`}),(0,j.jsxs)(`span`,{children:[`v`,ot]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,j.jsx)(o,{className:`h-4 w-4`}),(0,j.jsxs)(`span`,{children:[Y.length,` `,Y.length===1?e(`modelManager.systemStatus.models`):e(`modelManager.systemStatus.models_plural`)]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,j.jsx)(te,{className:`h-4 w-4`}),(0,j.jsx)(`span`,{children:$(Ot())})]}),X.length>0&&(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,j.jsx)(d,{className:`h-4 w-4`}),(0,j.jsxs)(`span`,{children:[X.length,` `,e(`modelManager.systemStatus.running`),` (`,$(kt()),` `,e(`modelManager.systemStatus.vram`),`)`]})]})]}),(0,j.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,j.jsxs)(O,{onClick:Z,variant:`outline`,size:`sm`,className:D(`gap-1.5`,``,``),children:[(0,j.jsx)(p,{className:`h-3.5 w-3.5`}),e(`common.refresh`)]})})]})}),(0,j.jsx)(be,{expanded:G.has(`pull`),modelName:v,setModelName:y,pulling:b,progress:C,canInstallModels:i,popularModels:Nt,onToggle:()=>K(`pull`),onPull:()=>bt(),onCancelPull:xt,formatSize:$}),(0,j.jsx)(ve,{expanded:G.has(`library`),models:jt,totalAvailable:Q.length,categories:Mt,filter:l,search:m,loading:ct||ut,pulling:b,canInstallModels:i,pullSectionExpanded:G.has(`pull`),setFilter:f,setSearch:_,isModelInstalled:At,normalizeCloudPullName:we,onToggle:()=>K(`library`),onTogglePullSection:()=>K(`pull`),onPullModel:bt,onRefresh:dt}),(0,j.jsx)(fe,{expanded:G.has(`huggingface`),models:pt,search:Ue,task:B,sort:V,loadingModels:mt,canInstallModels:i,expandedModelId:Ye,loadingGgufModelId:$e,ggufFiles:Ze,pullingModel:tt,pullProgress:nt,setSearch:We,setTask:qe,setSort:Je,onToggle:()=>K(`huggingface`),onToggleModel:_t,onPullGguf:vt,onCancelPull:yt,onRefresh:ht}),Array.isArray(X)&&X.length>0&&(0,j.jsxs)(`div`,{className:D(`rounded-xl p-4 border`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,j.jsx)(`div`,{className:D(`p-2 rounded-lg`,`bg-green-100 dark:bg-green-900/30`),children:(0,j.jsx)(d,{className:`h-5 w-5 text-green-600 dark:text-green-400`})}),(0,j.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.running`)}),(0,j.jsxs)(`span`,{className:D(`ml-auto px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[X.length,` `,e(`modelManager.systemStatus.running`)]})]}),(0,j.jsx)(`div`,{className:`space-y-2`,children:X.map(t=>(0,j.jsxs)(`div`,{className:D(`flex items-center justify-between p-4 rounded-lg border`,`bg-green-50 dark:bg-green-900/10`,`border-green-200 dark:border-green-800/50`),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:D(`w-2 h-2 rounded-full animate-pulse`,`bg-green-500`)}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`font-medium text-green-800 dark:text-green-400`,children:t.name}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-green-600 dark:text-green-500`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(h,{className:`h-3 w-3`}),e(`modelManager.systemStatus.vram`),`:`,` `,$(t.size_vram||0)]}),t.size&&(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(o,{className:`h-3 w-3`}),e(`models.size`),`: `,$(t.size)]})]})]})]}),(0,j.jsxs)(`div`,{className:D(`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,j.jsx)(ae,{className:`h-3 w-3`}),e(`modelManager.local.running`)]})]},t.name))})]}),(0,j.jsx)(ge,{expanded:G.has(`local`),models:Y,onToggle:()=>K(`local`),isModelRunning:Dt,formatSize:$,onShowModel:Ct,onCopyModel:e=>{F(e),N(!0)},onDeleteModel:St}),(0,j.jsxs)(`div`,{className:D(`rounded-xl border overflow-hidden`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,j.jsxs)(`button`,{onClick:()=>K(`advanced`),className:D(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:D(`p-2 rounded-lg`,`bg-amber-100 dark:bg-amber-900/30`),children:(0,j.jsx)(ee,{className:`h-5 w-5 text-amber-600 dark:text-amber-400`})}),(0,j.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.advanced`)})]}),G.has(`advanced`)?(0,j.jsx)(c,{className:`h-5 w-5 text-gray-500`}):(0,j.jsx)(u,{className:`h-5 w-5 text-gray-500`})]}),G.has(`advanced`)&&(0,j.jsx)(`div`,{className:`p-4 pt-0`,children:(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,j.jsxs)(O,{onClick:()=>ke(!0),variant:`outline`,className:D(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,j.jsx)(oe,{className:`h-5 w-5 text-purple-500`}),(0,j.jsxs)(`div`,{className:`text-left`,children:[(0,j.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.createModel`)}),(0,j.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.fromModelfile`)})]})]}),(0,j.jsxs)(O,{onClick:()=>N(!0),variant:`outline`,className:D(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,j.jsx)(se,{className:`h-5 w-5 text-blue-500`}),(0,j.jsxs)(`div`,{className:`text-left`,children:[(0,j.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.copyModel`)}),(0,j.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.duplicateExisting`)})]})]}),(0,j.jsxs)(O,{onClick:()=>Fe(!0),variant:`outline`,className:D(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,j.jsx)(S,{className:`h-5 w-5 text-green-500`}),(0,j.jsxs)(`div`,{className:`text-left`,children:[(0,j.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.testEmbeddings`)}),(0,j.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.generateVectors`)})]})]}),(0,j.jsxs)(O,{onClick:async()=>{try{(await E.checkHealth()).success&&(await J(),g.success(e(`modelManager.advanced.healthy`)))}catch{await J(),g.error(e(`modelManager.systemStatus.offline`))}},variant:`outline`,className:D(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,j.jsx)(ne,{className:`h-5 w-5 text-rose-500`}),(0,j.jsxs)(`div`,{className:`text-left`,children:[(0,j.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.healthCheck`)}),(0,j.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.testConnection`)})]})]})]})})]}),Pt&&(0,j.jsx)(A.Suspense,{fallback:null,children:(0,j.jsx)(Ce,{models:Y,showDetailsModal:he,setShowDetailsModal:M,selectedModelName:pe,selectedModelDetails:ie,loadingDetails:_e,showCopyModal:xe,setShowCopyModal:N,copySource:P,setCopySource:F,copyDestination:I,setCopyDestination:Te,copying:Ee,handleCopyModel:wt,showCreateModal:Oe,setShowCreateModal:ke,createModelName:L,setCreateModelName:Ae,createModelfile:R,setCreateModelfile:je,creating:Me,handleCreateModel:Tt,showEmbeddingsModal:Pe,setShowEmbeddingsModal:Fe,embeddingsModel:z,setEmbeddingsModel:Ie,embeddingsInput:Le,setEmbeddingsInput:Re,embeddingsResult:ze,generatingEmbeddings:Ve,handleGenerateEmbeddings:Et})})]})},F=()=>{let{t:e}=k();return(0,j.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,j.jsxs)(`div`,{className:`max-w-6xl mx-auto p-6`,children:[(0,j.jsxs)(`div`,{className:`text-center max-w-md mx-auto mb-8`,children:[(0,j.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(`models.title`)}),(0,j.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 leading-relaxed`,children:e(`models.subtitle`)})]}),(0,j.jsx)(P,{})]})})};export{F as ModelsPage,F as default};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./markdown-core-CEpaJrKd.js";import{_ as r,a as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b}from"./syntax-highlight-B758xPeo.js";var x=e({OptimizedSyntaxHighlighter:()=>E,default:()=>E});n();var S=t(),C={js:`javascript`,ts:`typescript`,py:`python`,sh:`bash`,shell:`bash`,zsh:`bash`,terminal:`shell-session`,console:`shell-session`,html:`markup`,xml:`markup`,svg:`markup`,"c++":`cpp`},w={bash:r,c,cpp:l,css:f,diff:h,java:s,javascript:o,json:y,jsx:d,markdown:a,markup:_,python:m,"shell-session":i,tsx:u,typescript:g};Object.entries(w).forEach(([e,t])=>{b.registerLanguage(e,t)}),b.alias(`markup`,[`html`,`xml`,`svg`]);var T=new Set(Object.keys(w)),E=({children:e,language:t,isDark:n=!1,className:r=``})=>{let i=C[t.toLowerCase()]||t.toLowerCase();return T.has(i)?(0,S.jsx)(b,{language:i,style:n?p:v,className:r,customStyle:{margin:0,padding:`0.75rem`,borderRadius:`0.5rem`,fontSize:`0.875rem`},showLineNumbers:!1,children:e}):(0,S.jsx)(`pre`,{className:`bg-gray-100 dark:bg-dark-200 p-3 rounded-lg overflow-x-auto text-sm font-mono ${r}`,children:(0,S.jsx)(`code`,{className:``,children:e})})};export{x as n,E as t};