libre-webui 0.33.0 → 0.34.1

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 (274) hide show
  1. package/backend/dist/db.d.ts +2 -2
  2. package/backend/dist/db.d.ts.map +1 -1
  3. package/backend/dist/db.js +14 -6
  4. package/backend/dist/db.js.map +1 -1
  5. package/backend/dist/env.d.ts.map +1 -1
  6. package/backend/dist/env.js +21 -9
  7. package/backend/dist/env.js.map +1 -1
  8. package/backend/dist/index.d.ts.map +1 -1
  9. package/backend/dist/index.js +24 -35
  10. package/backend/dist/index.js.map +1 -1
  11. package/backend/dist/middleware/cors.d.ts +28 -0
  12. package/backend/dist/middleware/cors.d.ts.map +1 -0
  13. package/backend/dist/middleware/cors.js +70 -0
  14. package/backend/dist/middleware/cors.js.map +1 -0
  15. package/backend/dist/middleware/preferencesBody.d.ts +4 -0
  16. package/backend/dist/middleware/preferencesBody.d.ts.map +1 -0
  17. package/backend/dist/middleware/preferencesBody.js +43 -0
  18. package/backend/dist/middleware/preferencesBody.js.map +1 -0
  19. package/backend/dist/models/personaModel.d.ts.map +1 -1
  20. package/backend/dist/models/personaModel.js +2 -2
  21. package/backend/dist/models/personaModel.js.map +1 -1
  22. package/backend/dist/models/userModel.d.ts.map +1 -1
  23. package/backend/dist/models/userModel.js +3 -3
  24. package/backend/dist/models/userModel.js.map +1 -1
  25. package/backend/dist/persistence/postgresResourceRepositories.js +3 -3
  26. package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
  27. package/backend/dist/persistence/sqliteResourceRepositories.js +3 -3
  28. package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
  29. package/backend/dist/routes/calendar.js +2 -2
  30. package/backend/dist/routes/calendar.js.map +1 -1
  31. package/backend/dist/routes/documents.js +2 -2
  32. package/backend/dist/routes/documents.js.map +1 -1
  33. package/backend/dist/routes/huggingfaceHub.d.ts.map +1 -1
  34. package/backend/dist/routes/huggingfaceHub.js +47 -21
  35. package/backend/dist/routes/huggingfaceHub.js.map +1 -1
  36. package/backend/dist/routes/preferences.d.ts.map +1 -1
  37. package/backend/dist/routes/preferences.js +2 -1
  38. package/backend/dist/routes/preferences.js.map +1 -1
  39. package/backend/dist/services/agentCliService.d.ts.map +1 -1
  40. package/backend/dist/services/agentCliService.js +3 -1
  41. package/backend/dist/services/agentCliService.js.map +1 -1
  42. package/backend/dist/services/automationService.d.ts.map +1 -1
  43. package/backend/dist/services/automationService.js +3 -4
  44. package/backend/dist/services/automationService.js.map +1 -1
  45. package/backend/dist/services/chatService.d.ts.map +1 -1
  46. package/backend/dist/services/chatService.js +11 -11
  47. package/backend/dist/services/chatService.js.map +1 -1
  48. package/backend/dist/services/chatToolRuntimeService.d.ts +11 -0
  49. package/backend/dist/services/chatToolRuntimeService.d.ts.map +1 -1
  50. package/backend/dist/services/chatToolRuntimeService.js +2 -13
  51. package/backend/dist/services/chatToolRuntimeService.js.map +1 -1
  52. package/backend/dist/services/codexOAuthService.js +11 -7
  53. package/backend/dist/services/codexOAuthService.js.map +1 -1
  54. package/backend/dist/services/documentService.d.ts.map +1 -1
  55. package/backend/dist/services/documentService.js +3 -3
  56. package/backend/dist/services/documentService.js.map +1 -1
  57. package/backend/dist/services/galleryService.d.ts.map +1 -1
  58. package/backend/dist/services/galleryService.js +2 -2
  59. package/backend/dist/services/galleryService.js.map +1 -1
  60. package/backend/dist/services/libreClawService.d.ts +1 -1
  61. package/backend/dist/services/libreClawService.d.ts.map +1 -1
  62. package/backend/dist/services/libreClawService.js +16 -16
  63. package/backend/dist/services/libreClawService.js.map +1 -1
  64. package/backend/dist/services/memoryService.d.ts.map +1 -1
  65. package/backend/dist/services/memoryService.js +2 -2
  66. package/backend/dist/services/memoryService.js.map +1 -1
  67. package/backend/dist/services/mutationEngineService.js +2 -2
  68. package/backend/dist/services/mutationEngineService.js.map +1 -1
  69. package/backend/dist/services/ollamaService.d.ts +7 -2
  70. package/backend/dist/services/ollamaService.d.ts.map +1 -1
  71. package/backend/dist/services/ollamaService.js +120 -98
  72. package/backend/dist/services/ollamaService.js.map +1 -1
  73. package/backend/dist/services/ollamaSettingsService.js +1 -1
  74. package/backend/dist/services/ollamaSettingsService.js.map +1 -1
  75. package/backend/dist/services/pluginAudioGenerationService.d.ts.map +1 -1
  76. package/backend/dist/services/pluginAudioGenerationService.js +24 -11
  77. package/backend/dist/services/pluginAudioGenerationService.js.map +1 -1
  78. package/backend/dist/services/pluginCredentialsService.js +2 -2
  79. package/backend/dist/services/pluginCredentialsService.js.map +1 -1
  80. package/backend/dist/services/pluginEmbeddingService.d.ts.map +1 -1
  81. package/backend/dist/services/pluginEmbeddingService.js +20 -16
  82. package/backend/dist/services/pluginEmbeddingService.js.map +1 -1
  83. package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -1
  84. package/backend/dist/services/pluginImageGenerationService.js +93 -62
  85. package/backend/dist/services/pluginImageGenerationService.js.map +1 -1
  86. package/backend/dist/services/pluginSTTService.d.ts.map +1 -1
  87. package/backend/dist/services/pluginSTTService.js +15 -11
  88. package/backend/dist/services/pluginSTTService.js.map +1 -1
  89. package/backend/dist/services/pluginService.d.ts.map +1 -1
  90. package/backend/dist/services/pluginService.js +26 -23
  91. package/backend/dist/services/pluginService.js.map +1 -1
  92. package/backend/dist/services/pluginTTSService.d.ts.map +1 -1
  93. package/backend/dist/services/pluginTTSService.js +34 -27
  94. package/backend/dist/services/pluginTTSService.js.map +1 -1
  95. package/backend/dist/services/pluginVariablesService.d.ts.map +1 -1
  96. package/backend/dist/services/pluginVariablesService.js +2 -2
  97. package/backend/dist/services/pluginVariablesService.js.map +1 -1
  98. package/backend/dist/services/pluginVideoGenerationService.d.ts.map +1 -1
  99. package/backend/dist/services/pluginVideoGenerationService.js +33 -24
  100. package/backend/dist/services/pluginVideoGenerationService.js.map +1 -1
  101. package/backend/dist/services/preferencesService.d.ts +5 -0
  102. package/backend/dist/services/preferencesService.d.ts.map +1 -1
  103. package/backend/dist/services/preferencesService.js +15 -10
  104. package/backend/dist/services/preferencesService.js.map +1 -1
  105. package/backend/dist/services/promptService.d.ts.map +1 -1
  106. package/backend/dist/services/promptService.js +4 -4
  107. package/backend/dist/services/promptService.js.map +1 -1
  108. package/backend/dist/services/skillService.d.ts.map +1 -1
  109. package/backend/dist/services/skillService.js +6 -6
  110. package/backend/dist/services/skillService.js.map +1 -1
  111. package/backend/dist/services/toolApprovalService.d.ts.map +1 -1
  112. package/backend/dist/services/toolApprovalService.js +2 -3
  113. package/backend/dist/services/toolApprovalService.js.map +1 -1
  114. package/backend/dist/services/toolServerService.d.ts.map +1 -1
  115. package/backend/dist/services/toolServerService.js +4 -5
  116. package/backend/dist/services/toolServerService.js.map +1 -1
  117. package/backend/dist/services/workApprovalService.d.ts.map +1 -1
  118. package/backend/dist/services/workApprovalService.js +3 -3
  119. package/backend/dist/services/workApprovalService.js.map +1 -1
  120. package/backend/dist/services/workModelProviderService.d.ts +13 -2
  121. package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
  122. package/backend/dist/services/workModelProviderService.js +16 -5
  123. package/backend/dist/services/workModelProviderService.js.map +1 -1
  124. package/backend/dist/services/workPolicyService.d.ts.map +1 -1
  125. package/backend/dist/services/workPolicyService.js +2 -2
  126. package/backend/dist/services/workPolicyService.js.map +1 -1
  127. package/backend/dist/services/workTaskService.d.ts.map +1 -1
  128. package/backend/dist/services/workTaskService.js +7 -7
  129. package/backend/dist/services/workTaskService.js.map +1 -1
  130. package/backend/dist/storage.d.ts.map +1 -1
  131. package/backend/dist/storage.js +2 -2
  132. package/backend/dist/storage.js.map +1 -1
  133. package/backend/dist/types/index.d.ts +1 -0
  134. package/backend/dist/types/index.d.ts.map +1 -1
  135. package/backend/dist/types/index.js.map +1 -1
  136. package/backend/dist/utils/backgroundSettings.d.ts +7 -0
  137. package/backend/dist/utils/backgroundSettings.d.ts.map +1 -0
  138. package/backend/dist/utils/backgroundSettings.js +39 -0
  139. package/backend/dist/utils/backgroundSettings.js.map +1 -0
  140. package/backend/dist/utils/hash.js +1 -1
  141. package/backend/dist/utils/hash.js.map +1 -1
  142. package/backend/dist/utils/pluginDefinitionTrust.js +1 -1
  143. package/backend/dist/utils/providerFetch.d.ts +90 -0
  144. package/backend/dist/utils/providerFetch.d.ts.map +1 -0
  145. package/backend/dist/utils/providerFetch.js +316 -0
  146. package/backend/dist/utils/providerFetch.js.map +1 -0
  147. package/backend/dist/utils/websocketCloseCodes.d.ts +31 -0
  148. package/backend/dist/utils/websocketCloseCodes.d.ts.map +1 -0
  149. package/backend/dist/utils/websocketCloseCodes.js +134 -0
  150. package/backend/dist/utils/websocketCloseCodes.js.map +1 -0
  151. package/backend/dist/workScreenServer.d.ts.map +1 -1
  152. package/backend/dist/workScreenServer.js +7 -2
  153. package/backend/dist/workScreenServer.js.map +1 -1
  154. package/backend/package.json +5 -14
  155. package/bin/cli-args.js +71 -0
  156. package/bin/cli.js +14 -3
  157. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  158. package/frontend/dist/assets/index-Bv773ECu.js +17 -0
  159. package/frontend/dist/assets/index-CxFIHoRc.css +1 -0
  160. package/frontend/dist/index.html +26 -25
  161. package/frontend/dist/js/{ArtifactContainer-BB6A8cT5.js → ArtifactContainer-Cdrv0kJM.js} +1 -1
  162. package/frontend/dist/js/{ArtifactDemoPage-Bf1dW5Z3.js → ArtifactDemoPage-BcXPfD-W.js} +1 -1
  163. package/frontend/dist/js/{ArtifactSandboxFrame-DsZW0Axy.js → ArtifactSandboxFrame-5qM5QELi.js} +1 -1
  164. package/frontend/dist/js/ArtifactSlideOutPanel-tuGsj_HW.js +1 -0
  165. package/frontend/dist/js/AutomationModal-DL9kNzgL.js +1 -0
  166. package/frontend/dist/js/AutomationsPage-BMtR7wCN.js +1 -0
  167. package/frontend/dist/js/{AvatarUpload-gfZ9QWR3.js → AvatarUpload-DrfSzzOZ.js} +1 -1
  168. package/frontend/dist/js/{Button-BQ5JnUVj.js → Button-BxwbQ5xw.js} +1 -1
  169. package/frontend/dist/js/CalendarPage-BBkLlXa5.js +1 -0
  170. package/frontend/dist/js/ChannelsPage-C2KWU3sZ.js +1 -0
  171. package/frontend/dist/js/ChatPage-CWsAjCPP.js +14 -0
  172. package/frontend/dist/js/ConnectModels-flyZgito.js +1 -0
  173. package/frontend/dist/js/{EvaluationsPage-Cydglp6R.js → EvaluationsPage-DUntWRVo.js} +2 -2
  174. package/frontend/dist/js/{FirstTimeSetup-C5cc-bc9.js → FirstTimeSetup-CMQ000Hh.js} +1 -1
  175. package/frontend/dist/js/{GalleryPage-Dvq2GVoH.js → GalleryPage-DNSo3Q0p.js} +1 -1
  176. package/frontend/dist/js/HomePage-BOXsuk3g.js +1 -0
  177. package/frontend/dist/js/LanguageSwitcher-BIrE0C-N.js +1 -0
  178. package/frontend/dist/js/LibreClawPage-D97-90n6.js +1 -0
  179. package/frontend/dist/js/{Logo-BlcOFpac.js → Logo-BHz_QQlV.js} +1 -1
  180. package/frontend/dist/js/{LogoMark-CNeQ6eO9.js → LogoMark-BDqTSfCe.js} +1 -1
  181. package/frontend/dist/js/ModelManagerModals-DzEVkCuT.js +1 -0
  182. package/frontend/dist/js/NotesPage-VBGqE4aV.js +3 -0
  183. package/frontend/dist/js/{PasswordStrengthMeter-DVFLKG_-.js → PasswordStrengthMeter-DLQ5jaO_.js} +1 -1
  184. package/frontend/dist/js/{PersonasPage-DK9-SDZQ.js → PersonasPage-D8-4PyoM.js} +2 -2
  185. package/frontend/dist/js/PluginUsagePage-CHcweo11.js +1 -0
  186. package/frontend/dist/js/RichMessageContent-D7wqrY68.js +1 -0
  187. package/frontend/dist/js/RichMessageContent-yWLHf4YS.js +3 -0
  188. package/frontend/dist/js/SettingsModal-CxVt1ObR.js +19 -0
  189. package/frontend/dist/js/SettingsToggle-DdhWCK7-.js +1 -0
  190. package/frontend/dist/js/{ShareDialog-CZpU1itx.js → ShareDialog-J5zbwIWY.js} +1 -1
  191. package/frontend/dist/js/{SystemPage-BVaaKTRs.js → SystemPage-CEjZpR5I.js} +1 -1
  192. package/frontend/dist/js/UserManagementPanel-Dhwk4I0s.js +1 -0
  193. package/frontend/dist/js/{WhatsNewModal-CoFCdUpf.js → WhatsNewModal-5lCndkFc.js} +1 -1
  194. package/frontend/dist/js/WorkPage-c8xOdYyy.js +7 -0
  195. package/frontend/dist/js/api-CHEuZtwG.js +1 -0
  196. package/frontend/dist/js/{api-DQdJeQjd.js → api-DEOxp9DN.js} +1 -1
  197. package/frontend/dist/js/{appNavigation-DRM2Jr4r.js → appNavigation-DToyRu19.js} +1 -1
  198. package/frontend/dist/js/appStore-Bsxed1km.js +2 -0
  199. package/frontend/dist/js/appVersion-CgCvuf4s.js +1 -0
  200. package/frontend/dist/js/{ar-C8Izi_rT.js → ar-DNI77Stn.js} +1 -1
  201. package/frontend/dist/js/authStore-8w9Idb5o.js +4 -0
  202. package/frontend/dist/js/authStore-DwmcyHDN.js +1 -0
  203. package/frontend/dist/js/{bn-BJJgi-6Q.js → bn-u6oyZr4U.js} +1 -1
  204. package/frontend/dist/js/{chatStore-8jYk48hC.js → chatStore-lyGhYu24.js} +3 -3
  205. package/frontend/dist/js/composerStyles-DqJg-2vE.js +1 -0
  206. package/frontend/dist/js/{config-D4dduT3C.js → config-B5SBQwEe.js} +1 -1
  207. package/frontend/dist/js/{cs-DheVrMUl.js → cs-BIkJ6jwb.js} +1 -1
  208. package/frontend/dist/js/{da-BLszIs3a.js → da-DV3V6XJ_.js} +1 -1
  209. package/frontend/dist/js/{de-BvWdcr7T.js → de-DdcTQ-vn.js} +1 -1
  210. package/frontend/dist/js/{es-CQ8Yauda.js → es-Cw-ozFaX.js} +1 -1
  211. package/frontend/dist/js/{evaluationsApi-CBKjxZUn.js → evaluationsApi-BvkmhMgQ.js} +1 -1
  212. package/frontend/dist/js/{fr-BD5h-w8z.js → fr-Y2NfnlYR.js} +1 -1
  213. package/frontend/dist/js/{hi-IlRhC5IE.js → hi-BKU62_1Y.js} +1 -1
  214. package/frontend/dist/js/{id-DalGMQEJ.js → id-q6wo4InR.js} +1 -1
  215. package/frontend/dist/js/{is-DuQqmHeS.js → is-_B6QblCu.js} +1 -1
  216. package/frontend/dist/js/{it-DDaqAdB1.js → it-NUupXhzK.js} +1 -1
  217. package/frontend/dist/js/{ja-CYCu9F9Y.js → ja-BUvl9RXq.js} +1 -1
  218. package/frontend/dist/js/{ko-P3JZPOXE.js → ko-df4leR83.js} +1 -1
  219. package/frontend/dist/js/{messageCodeStyles-0_YpQDk4.js → messageCodeStyles-DchDafYE.js} +2 -2
  220. package/frontend/dist/js/{ms-B3ZIqlUn.js → ms-CN-7Q9S2.js} +1 -1
  221. package/frontend/dist/js/{nl-1Qpsmmz1.js → nl-OEm4uNIo.js} +1 -1
  222. package/frontend/dist/js/{pl-ErrMri3_.js → pl-B9pHpjg7.js} +1 -1
  223. package/frontend/dist/js/{pt-0T0R9AtX.js → pt-D3uaEKud.js} +1 -1
  224. package/frontend/dist/js/{ru-B34INyPg.js → ru-z9H07lhi.js} +1 -1
  225. package/frontend/dist/js/{sv-BSqDwAur.js → sv-GkQDA4wx.js} +1 -1
  226. package/frontend/dist/js/{teamEventStream-RoMYo102.js → teamEventStream-C0_UAzCG.js} +1 -1
  227. package/frontend/dist/js/{th-DK9M4-Iy.js → th-0hzCkDzt.js} +1 -1
  228. package/frontend/dist/js/{tr-DUrkEwr1.js → tr-CZDobfHQ.js} +1 -1
  229. package/frontend/dist/js/ui-BQojEu4t.js +2 -0
  230. package/frontend/dist/js/{ui-vendor-6y6qiSk5.js → ui-vendor-BvD5yGW1.js} +1 -1
  231. package/frontend/dist/js/{uk-B5DYTi0e.js → uk-BwspIPCI.js} +1 -1
  232. package/frontend/dist/js/{useChat-ImXXcy0q.js → useChat-CDllZR7C.js} +1 -1
  233. package/frontend/dist/js/useDialogFocus-BQLdAGYH.js +1 -0
  234. package/frontend/dist/js/{useTranslation-D0mJ4NnO.js → useTranslation-rdLmo6zV.js} +1 -1
  235. package/frontend/dist/js/{utils-Bn0RE9_8.js → utils-CKWltgs8.js} +1 -1
  236. package/frontend/dist/js/utils-vendor-Bla8iz2s.js +1 -0
  237. package/frontend/dist/js/{vi-CrtPQUIM.js → vi-Dipdv5ta.js} +1 -1
  238. package/frontend/dist/js/workApi-0L8fBGq1.js +6 -0
  239. package/frontend/dist/js/workApi-BjDBLsFh.js +1 -0
  240. package/frontend/dist/js/{zh-gbOKajYe.js → zh-CgdWmtP_.js} +1 -1
  241. package/package.json +6 -16
  242. package/plugins/codex-oauth.json +1 -0
  243. package/frontend/dist/assets/index-DegYzMyw.js +0 -70
  244. package/frontend/dist/assets/index-gKj8Y1JB.css +0 -1
  245. package/frontend/dist/js/ArtifactSlideOutPanel-Cartcixp.js +0 -1
  246. package/frontend/dist/js/AutomationModal-BI_3nFeg.js +0 -1
  247. package/frontend/dist/js/AutomationsPage-ChMXj4UG.js +0 -1
  248. package/frontend/dist/js/CalendarPage-Ce1ud5St.js +0 -1
  249. package/frontend/dist/js/ChannelsPage-kl8zJ2HA.js +0 -1
  250. package/frontend/dist/js/ChatPage-Bj98c6rc.js +0 -14
  251. package/frontend/dist/js/ConnectModels-CPftHmE3.js +0 -1
  252. package/frontend/dist/js/HomePage-zVjADRoX.js +0 -1
  253. package/frontend/dist/js/LibreClawPage-x0Qmtcnc.js +0 -1
  254. package/frontend/dist/js/ModelManagerModals-K1oiXMTv.js +0 -1
  255. package/frontend/dist/js/NotesPage-BnqBv-n1.js +0 -3
  256. package/frontend/dist/js/PluginUsagePage-DX9uxdRr.js +0 -1
  257. package/frontend/dist/js/RichMessageContent-BzfhfzQ4.js +0 -1
  258. package/frontend/dist/js/RichMessageContent-XMkRvBen.js +0 -3
  259. package/frontend/dist/js/SettingsModal-CMOwEhkG.js +0 -19
  260. package/frontend/dist/js/SettingsToggle-B7UynBmZ.js +0 -1
  261. package/frontend/dist/js/UserManagementPanel-BxAvybHj.js +0 -1
  262. package/frontend/dist/js/WorkPage-Du6llCSU.js +0 -7
  263. package/frontend/dist/js/api-CatP45JH.js +0 -1
  264. package/frontend/dist/js/appStore-BXbVcTeo.js +0 -2
  265. package/frontend/dist/js/appVersion-BUroqcki.js +0 -1
  266. package/frontend/dist/js/authStore-DkqtNSYP.js +0 -4
  267. package/frontend/dist/js/authStore-bqAN5v4N.js +0 -1
  268. package/frontend/dist/js/axios-CYkJpKn8.js +0 -1
  269. package/frontend/dist/js/ui-UU79S5lB.js +0 -2
  270. package/frontend/dist/js/useDictation-eMIAncoT.js +0 -1
  271. package/frontend/dist/js/utils-vendor-BbPbaAuC.js +0 -9
  272. package/frontend/dist/js/webauthnClient-CPSq528Q.js +0 -1
  273. package/frontend/dist/js/workApi-BM8qVq_w.js +0 -1
  274. package/frontend/dist/js/workApi-xhF57amo.js +0 -6
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{t as r}from"./logger-DnuT4jgB.js";import{n as i}from"./i18next-ChipS_AK.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./useTranslation-D0mJ4NnO.js";import{c as d,f,t as p,u as m}from"./utils-Bn0RE9_8.js";import{$n as h,D as g,Jn as _,Pn as v,Pt as y,R as b,S as x,X as S,_r as C,ar as w,br as T,n as E,nn as ee,nt as D,st as O,v as te,xn as k}from"./ui-vendor-6y6qiSk5.js";import{x as A}from"./api-DQdJeQjd.js";import{t as j}from"./Button-BQ5JnUVj.js";import{a as ne,o as M}from"./ui-UU79S5lB.js";var N={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},P=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function F(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(N[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(P),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim()){if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1))}return t}var I=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,L=/<\/?([^\s]+?)[/\s>]/,re=/^\s*$/,ie=/^(script|style)$/i,R=`\0`,ae=Object.create(null);function oe(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(R).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(R).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(R)>-1&&(e.attrs[t]=n.split(R).join(`<`))}e.children.length&&oe(e.children)})}function se(e,t){let n=t&&t.components||ae,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;I.lastIndex=0;let o;for(;o=I.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(L);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=R,a=o.index+1,I.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=I.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=F(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=F(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&ie.test(s.name)){t=!0,d||=e.toLowerCase();let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);re.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&oe(a),a}function ce(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`&quot;`)+`"`);return t.length?` `+t.join(` `):``}function le(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?ce(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(le,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function ue(e){return e.reduce(function(e,t){return e+le(``,t)},``)}var de={parse:se,stringify:ue},z=e(t()),B=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},V=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?H(t):t},fe=e=>Array.isArray(e)&&e.every(z.isValidElement),H=e=>Array.isArray(e)?e:[e],pe=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},me=e=>{let t={};if(!e)return t;let n=e=>{H(e).forEach(e=>{o(e)||(B(e)?n(V(e)):l(e)&&!(0,z.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},U=(e,t,n,r)=>{if(!e)return``;let i=``,s=H(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return s.forEach((e,s)=>{if(o(e)){i+=`${e}`;return}if((0,z.isValidElement)(e)){let{props:a,type:l}=e,u=Object.keys(a).length,d=c.indexOf(l)>-1,f=a.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||a.i18nIsDynamicList){i+=`<${s}></${s}>`;return}if(d&&u<=1){let e=o(f)?f:U(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=U(f,t,n,r);i+=`<${s}>${p}</${s}>`;return}if(e===null){a(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(l(e)){let{format:t,...o}=e,s=Object.keys(o);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];i+=`{{${e}}}`;return}a(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}a(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},W=(e,t,n,r,i,a,s)=>{if(n===``)return[];let c=i.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(c.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!u&&!s)return[n];let d=t??{},p=e=>{H(e).forEach(e=>{o(e)||(B(e)?p(V(e)):l(e)&&!(0,z.isValidElement)(e)&&Object.assign(d,e))})};p(e);let h=Object.keys(d),g=de.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||c.indexOf(e)>-1||h.indexOf(e)>-1}),_={...d,...a},v=(e,t,n)=>{let r=V(e),i=b(r,t.children,n);return fe(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},y=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,z.cloneElement)(e,{key:r},i?void 0:t))):n.push(...z.Children.map([e],e=>{if(e.type===z.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`children`&&t!==`i18nIsDynamicList`&&(n[t]=e.props[t])}),(0,z.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`ref`&&t!==`children`&&(n[t]=e.props[t])}),(0,z.cloneElement)(e,n,i?null:t)}))},b=(e,n,a)=>{let d=H(e),p=H(n),h={};return p.reduce((e,n,p)=>{let g=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,_,r.language);if(n.type===`tag`){let m=d[parseInt(n.name,10)];!m&&t&&(m=t[n.name]),a.length===1&&!m&&(m=a[0][n.name]),m||={};let x={...n.attrs};s&&Object.keys(x).forEach(e=>{let t=x[e];o(t)&&(x[e]=f(t))});let S=Object.keys(x).length===0?m:pe({props:x},m),C=(0,z.isValidElement)(S),w=C&&B(n,!0)&&!n.voidElement,T=u&&l(S)&&S.dummy&&!C,E=l(t)&&Object.hasOwnProperty.call(t,n.name);if(o(S)){let t=r.services.interpolator.interpolate(S,_,r.language);e.push(t)}else if(B(S)||w){let t=v(S,n,a);y(S,t,e,p)}else if(T){let t=b(d,n.children,a);y(S,t,e,p)}else if(Number.isNaN(parseFloat(n.name))){if(E){let t=v(S,n,a);y(S,t,e,p,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&c.indexOf(n.name)>-1){if(n.voidElement)e.push((0,z.createElement)(n.name,{key:`${n.name}-${p}`}));else{let t=h[n.name]||0;h[n.name]=t+1;let r,i=0;for(let e=0;e<d.length;e+=1){let a=d[e];if((0,z.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let o=r?H(V(r)):d,s=b(o,n.children,a);e.push((0,z.createElement)(n.name,{key:`${n.name}-${p}`},s))}}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=b(d,n.children,a);e.push(`<${n.name}>${t}</${n.name}>`)}}else if(l(S)&&!C){let t=n.children[0]?g:null;t&&e.push(t)}else y(S,g,e,p,n.children.length!==1||!g)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:m().unescape,o=s?a(r.services.interpolator.interpolate(n.content,_,r.language)):r.services.interpolator.interpolate(n.content,_,r.language);t?e.push((0,z.createElement)(t,{key:`${n.name}-${p}`},o)):e.push(o)}return e},[])};return V(b([{dummy:!0,children:e||[]}],g,H(e||[]))[0])},G=(e,t,n)=>{let r=e.key||t,i=(0,z.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,z.createElement)(z.Fragment,null,i)}return(0,z.createElement)(a,{key:r})},he=(e,t)=>e.map((e,n)=>G(e,n,t)),ge=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:G(e[r],r,t)})}),n},_e=(e,t,n,r)=>e?Array.isArray(e)?he(e,t):l(e)?ge(e,t):(c(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,ve=e=>!l(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function ye({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:s={},values:l,defaults:u,components:f,ns:p,i18n:h,t:g,shouldUnescape:_,...v}){let y=h||d();if(!y)return c(y,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:r}),e;let b=g||y.t.bind(y)||(e=>e),x={...m(),...y.options?.react},S=p||b.ns||y.options?.defaultNS;S=o(S)?[S]:S||[`translation`];let{transDefaultProps:C}=x,w=C?.tOptions?{...C.tOptions,...s}:s,T=_??C?.shouldUnescape,E=C?.values?{...C.values,...l}:l,ee=C?.components?{...C.components,...f}:f,D=U(e,x,y,r),O=u||w?.defaultValue||D||x.transEmptyNodeValue||(typeof r==`function`?i(r):r),{hashTransKey:te}=x,k=r||(te?te(D||O):D||O);l=y.options?.interpolation?.defaultVariables?E&&Object.keys(E).length>0?{...E,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables}:E;let A=me(e);A&&typeof A.count==`number`&&t===void 0&&(t=A.count);let j=l||t!==void 0&&!y.options?.interpolation?.alwaysFormat||!e?w.interpolation:{interpolation:{...w.interpolation,prefix:`#$?`,suffix:`?$#`}},ne={...w,context:a||w.context,count:t,...l,...j,defaultValue:O,ns:S},M=k?b(k,ne):O;M===k&&O&&(M=O);let N=_e(ee,M,y,r),P=N||e,F=null;ve(N)&&(F=N,P=e);let I=W(P,F,M,y,x,ne,T),L=n??x.defaultTransParent;return L?(0,z.createElement)(L,v,I):I}function be({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:c,components:l,ns:u,i18n:f,t:p,shouldUnescape:m,...h}){let{i18n:g,defaultNS:_}=(0,z.useContext)(s)||{},v=f||g||d(),y=p||v?.t.bind(v);return ye({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:c,components:l,ns:u||y?.ns||_||v?.options?.defaultNS,i18n:v,t:p,shouldUnescape:m,...h})}var K=n(),q=r(`pages:libre-claw`),xe={queued:`bg-gray-100 text-gray-700 dark:bg-dark-200 dark:text-dark-700`,running:`bg-primary-100 text-primary-700 dark:bg-primary-900/25 dark:text-primary-300`,blocked:`bg-amber-500/20 text-ink dark:bg-amber-900/30`,done:`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`,failed:`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300`,cancelled:`bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300`},Se={assistant_message:`text-primary-600 dark:text-primary-300`,assistant_delta:`text-primary-600 dark:text-primary-300`,user_message:`text-gray-700 dark:text-dark-700`,permission_request:`text-ink`,permission_response:`text-gray-600 dark:text-dark-600`,tool_call:`text-gray-600 dark:text-dark-600`,tool_result:`text-gray-600 dark:text-dark-600`,usage:`text-gray-600 dark:text-dark-600`,error:`text-red-600 dark:text-red-300`,run_finished:`text-emerald-600 dark:text-emerald-300`},Ce=[[`lobster`,`Lobster`],[`lobster-light`,`Lobster Light`],[`github-dark`,`GitHub Dark`],[`github-light`,`GitHub Light`],[`monokai-pro`,`Monokai Pro`],[`night-owl`,`Night Owl`],[`tokyo-night`,`Tokyo Night`],[`ayu`,`Ayu`],[`dracula`,`Dracula`],[`catppuccin-mocha`,`Catppuccin Mocha`],[`catppuccin-latte`,`Catppuccin Latte`],[`gruvbox-dark`,`Gruvbox Dark`],[`nord`,`Nord`],[`solarized-dark`,`Solarized Dark`],[`solarized-light`,`Solarized Light`],[`one-dark-pro`,`One Dark Pro`],[`rose-pine`,`Rose Pine`],[`kanagawa`,`Kanagawa`],[`matrix`,`Matrix`]],we=()=>{let{t:e}=u(),[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)([]),[l,d]=(0,z.useState)(null),[f,m]=(0,z.useState)(null),[N,P]=(0,z.useState)(``),[F,I]=(0,z.useState)(null),[L,re]=(0,z.useState)(!0),[ie,R]=(0,z.useState)(!1),[ae,oe]=(0,z.useState)(!1),[se,ce]=(0,z.useState)(!1),[le,ue]=(0,z.useState)(!1),[de,B]=(0,z.useState)(``),[V,fe]=(0,z.useState)(`chat`),[H,pe]=(0,z.useState)(``),[me,U]=(0,z.useState)(``),[W,G]=(0,z.useState)(``),[he,ge]=(0,z.useState)(``),[_e,ve]=(0,z.useState)(!1),[ye,xe]=(0,z.useState)(`lobster`),[Se,we]=(0,z.useState)(!0),[ke,Ae]=(0,z.useState)(``),[je,Y]=(0,z.useState)(``),[X,Fe]=(0,z.useState)(``),[Ie,Le]=(0,z.useState)(`report`),Z=(0,z.useMemo)(()=>r.find(e=>e.run_id===F)||null,[r,F]),Q=(0,z.useMemo)(()=>{let e=new Set(a.filter(e=>e.type===`permission_response`).map(e=>String(e.data.tool_call_id||``)));return a.filter(t=>{if(t.type!==`permission_request`)return!1;let n=String(t.data.tool_call_id||``);return n&&!e.has(n)})},[a]),Re=(0,z.useMemo)(()=>Pe(a,e),[a,e]),$=(0,z.useCallback)(async()=>{try{let[e,t,r,a,o,s]=await Promise.all([A.status(),A.listRuns(30),A.currentModel(),A.currentFallback(),A.usage(``,100),A.listAutomations(50)]);e.success&&e.data&&n(e.data),t.success&&t.data&&(i(t.data.runs),I(e=>e||t.data?.runs[0]?.run_id||null)),r.success&&r.data&&(d(r.data),G(String(r.data.provider||``)),ge(String(r.data.model||``))),a.success&&a.data&&m(a.data),o.success&&o.data&&P(String(o.data.text||``)),s.success&&s.data&&c(s.data.automations)}catch(t){q.error(`Failed to load Libre Claw overview:`,t),T.error(e(`libreClaw.toasts.loadStatusFailed`))}finally{re(!1)}},[e]),ze=(0,z.useCallback)(async(e,t=!1)=>{let n=t?0:a.length>0&&a[a.length-1]?.event_id||0;try{let r=await A.getEvents(e,n);r.success&&r.data&&o(e=>t?r.data?.events||[]:[...e,...r.data?.events||[]])}catch(e){q.error(`Failed to load Libre Claw events:`,e)}},[a]);(0,z.useEffect)(()=>{let e=window.setTimeout(()=>{$()},0);return()=>window.clearTimeout(e)},[$]),(0,z.useEffect)(()=>{if(!F){let e=window.setTimeout(()=>{o([])},0);return()=>window.clearTimeout(e)}let e=F;A.getEvents(e,0).then(e=>{e.success&&e.data&&o(e.data.events)}).catch(e=>{q.error(`Failed to load Libre Claw events:`,e)})},[F]),(0,z.useEffect)(()=>{if(!F||!Z||![`queued`,`running`,`blocked`].includes(Z.state))return;let e=window.setInterval(()=>{ze(F),A.listRuns(30).then(e=>{e.success&&e.data&&i(e.data.runs)})},1500);return()=>window.clearInterval(e)},[ze,Z,F]);let Be=async()=>{if(!de.trim()){T.error(e(`libreClaw.toasts.enterTask`));return}R(!0);try{let t=await A.startRun({message:de,kind:V,provider:H||void 0,model:me||void 0});if(t.success&&t.data){let n=t.data.run;i(e=>[n,...e.filter(e=>e.run_id!==n.run_id)]),I(n.run_id),B(``),T.success(e(`libreClaw.toasts.runStarted`))}else T.error(t.error||e(`libreClaw.toasts.startRunFailed`))}catch(t){q.error(`Failed to start Libre Claw run:`,t),T.error(e(`libreClaw.toasts.startRunFailed`))}finally{R(!1)}},Ve=async t=>{try{await A.cancelRun(t),await $(),T.success(e(`libreClaw.toasts.runCancelled`))}catch(t){q.error(`Failed to cancel Libre Claw run:`,t),T.error(e(`libreClaw.toasts.cancelRunFailed`))}},He=async(t,n)=>{if(!F)return;let r=String(t.data.tool_call_id||``);if(r)try{await A.resolvePermission(F,r,n),await ze(F,!0),T.success(e(n===`deny`?`libreClaw.toasts.denied`:`libreClaw.toasts.approved`))}catch(t){q.error(`Failed to resolve Libre Claw permission:`,t),T.error(e(`libreClaw.toasts.resolvePermissionFailed`))}},Ue=async()=>{if(!W.trim()||!he.trim()){T.error(e(`libreClaw.toasts.providerModelRequired`));return}oe(!0);try{let t=await A.updateModel(W,he,_e);t.success&&t.data?(d(t.data),T.success(e(`libreClaw.toasts.modelUpdated`))):T.error(t.error||e(`libreClaw.toasts.updateModelFailed`))}catch(t){q.error(`Failed to update Libre Claw model:`,t),T.error(e(`libreClaw.toasts.updateModelFailed`))}finally{oe(!1)}},We=async()=>{ce(!0);try{let t=await A.updateTheme(ye,Se);t.success?T.success(e(`libreClaw.toasts.themeUpdated`)):T.error(t.error||e(`libreClaw.toasts.updateThemeFailed`))}catch(t){q.error(`Failed to update Libre Claw theme:`,t),T.error(e(`libreClaw.toasts.updateThemeFailed`))}finally{ce(!1)}},Ge=async()=>{if(!ke.trim()||!je.trim()||!X.trim()){T.error(e(`libreClaw.toasts.automationRequired`));return}ue(!0);try{let t=await A.createAutomation({name:ke,schedule:je,prompt:X,route:Ie});t.success?(Ae(``),Y(``),Fe(``),await $(),T.success(e(`libreClaw.toasts.automationCreated`))):T.error(t.error||e(`libreClaw.toasts.createAutomationFailed`))}catch(t){q.error(`Failed to create Libre Claw automation:`,t),T.error(e(`libreClaw.toasts.createAutomationFailed`))}finally{ue(!1)}},Ke=async(t,n)=>{try{n===`pause`&&await A.pauseAutomation(t),n===`resume`&&await A.resumeAutomation(t),n===`run`&&await A.runAutomationNow(t),n===`delete`&&await A.deleteAutomation(t),await $(),T.success(e(`libreClaw.toasts.automationUpdated`))}catch(t){q.error(`Failed to update Libre Claw automation:`,t),T.error(e(`libreClaw.toasts.updateAutomationFailed`))}};return(0,K.jsxs)(M,{width:`wide`,contentClassName:`space-y-6`,children:[(0,K.jsx)(ne,{className:`mb-0`,title:e(`libreClaw.title`),description:e(`libreClaw.subtitle`),actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Te,{status:t,t:e}),(0,K.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:$,children:[(0,K.jsx)(S,{className:`h-4 w-4`}),e(`common.refresh`)]}),(0,K.jsxs)(`a`,{href:t?.dashboardUrl||`http://127.0.0.1:8766/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-xl border border-gray-200/80 bg-white/70 px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-white dark:border-white/10 dark:bg-white/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.08]`,children:[(0,K.jsx)(k,{className:`h-4 w-4`}),e(`libreClaw.dashboard`)]})]})}),!t?.connected&&!L&&(0,K.jsx)(`section`,{className:`rounded-xl border border-amber-200 bg-amber-500/10 p-4 text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(x,{className:`mt-0.5 h-5 w-5 shrink-0 text-amber-500`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`font-semibold`,children:e(`libreClaw.connection.disconnectedTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm opacity-90`,children:(0,K.jsx)(be,{i18nKey:`libreClaw.connection.disconnectedDescription`,components:{command:(0,K.jsx)(`code`,{}),env:(0,K.jsx)(`code`,{})}})}),t?.error&&(0,K.jsx)(`p`,{className:`mt-2 text-xs opacity-80`,children:t.error})]})]})}),(0,K.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.startRun.title`),icon:(0,K.jsx)(D,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`textarea`,{value:de,onChange:e=>B(e.target.value),placeholder:e(`libreClaw.startRun.placeholder`),className:`min-h-32 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-100 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800 dark:focus:border-primary-500 dark:focus:ring-primary-900/30`}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,K.jsxs)(`select`,{value:V,onChange:e=>fe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`chat`,children:e(`libreClaw.startRun.chatRun`)}),(0,K.jsx)(`option`,{value:`goal`,children:e(`libreClaw.startRun.goalMode`)})]}),(0,K.jsx)(`input`,{value:H,onChange:e=>pe(e.target.value),placeholder:e(`libreClaw.startRun.providerOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:me,onChange:e=>U(e.target.value),placeholder:e(`libreClaw.startRun.modelOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(j,{onClick:Be,loading:ie,children:[(0,K.jsx)(w,{className:`h-4 w-4`}),e(`libreClaw.startRun.run`)]})]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.modelRoute.title`),icon:(0,K.jsx)(ee,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-1`,children:[(0,K.jsx)(`input`,{value:W,onChange:e=>G(e.target.value),placeholder:e(`libreClaw.modelRoute.providerPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:he,onChange:e=>ge(e.target.value),placeholder:e(`libreClaw.modelRoute.modelPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>ve(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]}),(0,K.jsx)(j,{variant:`secondary`,onClick:Ue,loading:ae,children:e(`libreClaw.modelRoute.saveModel`)}),(0,K.jsxs)(`div`,{className:`border-t border-gray-100 pt-3 dark:border-dark-200`,children:[(0,K.jsx)(`label`,{className:`mb-1 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-500`,children:e(`libreClaw.modelRoute.theme`)}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] lg:grid-cols-1`,children:[(0,K.jsx)(`select`,{value:ye,onChange:e=>xe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:Ce.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsx)(j,{variant:`secondary`,onClick:We,loading:se,children:e(`libreClaw.modelRoute.saveTheme`)})]}),(0,K.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:Se,onChange:e=>we(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]})]}),l&&(0,K.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(l,null,2)})]})})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.runs.title`),icon:(0,K.jsx)(C,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[r.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.runs.empty`)}),r.map(t=>(0,K.jsxs)(`button`,{onClick:()=>I(t.run_id),className:p(`w-full rounded-xl border p-3 text-start transition`,F===t.run_id?`border-primary-300 bg-primary-50 dark:border-primary-700 dark:bg-primary-900/20`:`border-gray-200 bg-white hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-50 dark:hover:bg-dark-100`),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,K.jsx)(Ee,{state:t.state,t:e})]}),(0,K.jsxs)(`div`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-dark-500`,children:[t.provider,`:`,t.model]}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:Ne(t.updated_at)})]},t.run_id))]})}),(0,K.jsxs)(J,{title:Z?Z.title:e(`libreClaw.timeline.title`),icon:(0,K.jsx)(v,{className:`h-4 w-4`}),actions:Z&&[`queued`,`running`,`blocked`].includes(Z.state)?(0,K.jsxs)(j,{variant:`danger`,size:`sm`,onClick:()=>Ve(Z.run_id),children:[(0,K.jsx)(g,{className:`h-4 w-4`}),e(`common.cancel`)]}):null,children:[Q.length>0&&(0,K.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-xl border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-800 dark:bg-amber-900/20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,K.jsx)(b,{className:`h-4 w-4 text-amber-500`}),e(`libreClaw.approvals.needed`)]}),Q.map(t=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-white/70 p-3 dark:bg-dark-50/70`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(t.data.name||e(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto rounded bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(t.data.arguments||{},null,2)}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,K.jsxs)(j,{size:`sm`,onClick:()=>He(t,`allow_once`),children:[(0,K.jsx)(_,{className:`h-4 w-4`}),e(`libreClaw.approvals.allowOnce`)]}),(0,K.jsx)(j,{size:`sm`,variant:`secondary`,onClick:()=>He(t,`always_allow_tool`),children:e(`libreClaw.approvals.alwaysAllowTool`)}),(0,K.jsxs)(j,{size:`sm`,variant:`danger`,onClick:()=>He(t,`deny`),children:[(0,K.jsx)(E,{className:`h-4 w-4`}),e(`libreClaw.approvals.deny`)]})]})]},t.event_id))]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[a.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.timeline.empty`)}),Re.map(t=>(0,K.jsx)(Oe,{item:t,t:e},t.key))]})]})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,K.jsx)(J,{title:e(`libreClaw.automations.title`),icon:(0,K.jsx)(h,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsx)(`input`,{value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`libreClaw.automations.namePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:je,onChange:e=>Y(e.target.value),placeholder:e(`libreClaw.automations.schedulePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`select`,{value:Ie,onChange:e=>Le(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`report`,children:e(`libreClaw.automations.routes.report`)}),(0,K.jsx)(`option`,{value:`telegram`,children:e(`libreClaw.automations.routes.telegram`)})]}),(0,K.jsx)(j,{onClick:Ge,loading:le,children:e(`libreClaw.automations.create`)})]}),(0,K.jsx)(`textarea`,{value:X,onChange:e=>Fe(e.target.value),placeholder:e(`libreClaw.automations.promptPlaceholder`),className:`min-h-24 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[s.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.automations.empty`)}),s.map(t=>(0,K.jsx)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-3 dark:border-dark-300 dark:bg-dark-50`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.name}),(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[t.schedule,` ·`,` `,e(`libreClaw.automations.routes.${t.route}`,{defaultValue:t.route}),` `,`·`,` `,e(`libreClaw.automations.status.${t.status}`,{defaultValue:t.status})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,K.jsx)(De,{title:e(`libreClaw.automations.runNow`),onClick:()=>Ke(t.automation_id,`run`),children:(0,K.jsx)(D,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:t.status===`paused`?e(`libreClaw.automations.resume`):e(`libreClaw.automations.pause`),onClick:()=>Ke(t.automation_id,t.status===`paused`?`resume`:`pause`),children:t.status===`paused`?(0,K.jsx)(D,{className:`h-4 w-4`}):(0,K.jsx)(O,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:e(`common.delete`),danger:!0,onClick:()=>Ke(t.automation_id,`delete`),children:(0,K.jsx)(te,{className:`h-4 w-4`})})]})]})},t.automation_id))]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.usageFallback.title`),icon:(0,K.jsx)(C,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.usage`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:N||e(`libreClaw.usageFallback.noUsage`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.fallbackRoute`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(f||{},null,2)})]})]})})]}),L&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-white/60 backdrop-blur-sm dark:bg-dark-50/60`,children:(0,K.jsx)(y,{className:`h-7 w-7 animate-spin text-primary-600`})})]})},Te=({status:e,t})=>{let n=!!e?.connected;return(0,K.jsxs)(`span`,{className:p(`inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium`,n?`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`:`bg-amber-500/20 text-ink dark:bg-amber-900/30`),children:[(0,K.jsx)(`span`,{className:p(`h-2 w-2 rounded-full`,n?`bg-emerald-500`:`bg-amber-500`)}),t(n?`libreClaw.status.connected`:`libreClaw.status.disconnected`),e?.health?.active_runs!==void 0&&(0,K.jsxs)(`span`,{className:`opacity-70`,children:[`·`,` `,t(`libreClaw.status.activeRuns`,{count:e.health.active_runs})]})]})},Ee=({state:e,t})=>(0,K.jsx)(`span`,{className:p(`rounded-full px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,xe[e]||xe.queued),children:t(`libreClaw.states.${e}`,{defaultValue:e})}),J=({title:e,icon:t,actions:n,children:r})=>(0,K.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/60 dark:border-white/10 dark:bg-white/[0.03]`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-5 py-4 dark:border-white/[0.08]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:[(0,K.jsx)(`span`,{className:`text-primary-600 dark:text-primary-300`,children:t}),e]}),n]}),(0,K.jsx)(`div`,{className:`p-5`,children:r})]}),De=({title:e,danger:t,onClick:n,children:r})=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:n,className:p(`inline-flex h-8 w-8 items-center justify-center rounded-lg transition-colors`,t?`text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`:`text-gray-500 hover:bg-gray-100 dark:text-dark-500 dark:hover:bg-dark-200`),children:r}),Oe=({item:e,t})=>(0,K.jsxs)(`article`,{className:p(`rounded-xl border p-3 transition-colors`,e.eventType===`assistant_message`?`border-primary-200 bg-primary-50/60 dark:border-primary-900/60 dark:bg-primary-900/10`:(e.eventType,`border-gray-200/80 bg-white/50 dark:border-white/[0.08] dark:bg-white/[0.025]`)),children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:p(`text-xs font-semibold uppercase tracking-wide`,Se[e.eventType]||`text-gray-500 dark:text-dark-500`),children:e.label}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-400 dark:text-dark-500`,children:[Le(e),` · `,Ne(e.timestamp)]})]}),(0,K.jsx)(ke,{item:e,t})]}),ke=({item:e,t})=>{if(e.kind===`assistant_message`)return(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-gray-900 dark:text-dark-900`,children:Fe(e.events)||t(`libreClaw.timeline.streaming`)});let n=e.events[0];return n?n.type===`assistant_delta`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.text||``)}):n.type===`user_message`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.content||``)}):n.type===`tool_call`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`tool_result`?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:[String(n.data.name||t(`libreClaw.fallbacks.tool`)),` ·`,` `,n.data.is_error?t(`libreClaw.timeline.resultError`):t(`libreClaw.timeline.resultOk`)]}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:String(n.data.content||``)})]}):n.type===`permission_request`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.approvals.toolApprovalRequested`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`permission_response`?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.tool`),value:String(n.data.name||n.data.tool_call_id||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.resolution`),value:String(n.data.resolution||t(`libreClaw.fallbacks.resolved`))})]}):n.type===`usage`?(0,K.jsx)(Ae,{data:n.data,t}):n.type===`run_finished`?(0,K.jsx)(je,{data:n.data,t}):n.type===`error`?(0,K.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-300`,children:String(n.data.message||t(`libreClaw.fallbacks.unknownError`))}):(0,K.jsx)(X,{value:n.data}):null},Ae=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.provider`),value:String(e.provider||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.model`),value:String(e.model||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.input`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.input_tokens),formatted:Q(e.input_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.output`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.output_tokens),formatted:Q(e.output_tokens)})}),Z(e.cached_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cached`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.cached_tokens),formatted:Q(e.cached_tokens)})}),Z(e.reasoning_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.reasoning`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.reasoning_tokens),formatted:Q(e.reasoning_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cost`),value:Re(e.cost)})]}),je=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.state`),value:t(`libreClaw.states.${String(e.state||`done`)}`,{defaultValue:String(e.state||`done`)})}),e.stop_reason!==void 0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.stopReason`),value:String(e.stop_reason)})]}),Y=({label:e,value:t})=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200/80 bg-white/50 px-2.5 py-1 text-xs text-gray-700 dark:border-white/10 dark:bg-white/[0.035] dark:text-dark-700`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-gray-500 dark:text-dark-500`,children:e}),(0,K.jsx)(`span`,{children:t})]}),X=({value:e})=>(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(e,null,2)}),Me=({text:e})=>(0,K.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-300 bg-white/30 px-4 py-8 text-center text-sm text-gray-500 dark:border-white/15 dark:bg-white/[0.02] dark:text-dark-500`,children:e}),Ne=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},Pe=(e,t)=>{let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;if(i.type===`assistant_delta`){let i=[];for(;e[r]?.type===`assistant_delta`;){let t=e[r];t&&i.push(t),r+=1}let a=i[0],o=i[i.length-1]||a;a&&o&&n.push({key:`assistant-${a.event_id}-${o.event_id}`,kind:`assistant_message`,eventType:`assistant_message`,label:t(`libreClaw.timeline.assistantResponse`),firstEventId:a.event_id,lastEventId:o.event_id,timestamp:a.timestamp,events:i});continue}n.push({key:`${i.type}-${i.event_id}`,kind:`event`,eventType:i.type,label:Ie(i.type,t),firstEventId:i.event_id,lastEventId:i.event_id,timestamp:i.timestamp,events:[i]}),r+=1}return n},Fe=e=>e.map(e=>String(e.data.text||``)).join(``),Ie=(e,t)=>({user_message:t(`libreClaw.timeline.labels.userMessage`),tool_call:t(`libreClaw.timeline.labels.toolCall`),tool_result:t(`libreClaw.timeline.labels.toolResult`),permission_request:t(`libreClaw.timeline.labels.approvalRequest`),permission_response:t(`libreClaw.timeline.labels.approvalResponse`),run_started:t(`libreClaw.timeline.labels.runStarted`),run_finished:t(`libreClaw.timeline.labels.runFinished`),usage:t(`libreClaw.timeline.labels.usage`),error:t(`libreClaw.timeline.labels.error`)})[e]||e.replace(/_/g,` `),Le=e=>e.firstEventId===e.lastEventId?`#${e.firstEventId}`:`#${e.firstEventId}-#${e.lastEventId}`,Z=e=>{let t=Number(e);return Number.isFinite(t)?t:0},Q=e=>new Intl.NumberFormat().format(Z(e)),Re=e=>{let t=Z(e);return t<=0?`$0.00`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`};export{we as default};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{i as e,r as t,t as n}from"./react-vendor-D0Ec-185.js";import{t as r}from"./useTranslation-D0mJ4NnO.js";import{t as i}from"./utils-Bn0RE9_8.js";import{Dn as a,X as o,_n as s,n as c,x as l}from"./ui-vendor-6y6qiSk5.js";import{t as u}from"./Button-BQ5JnUVj.js";e();var d=t(),f=n(),p=({models:e,showDetailsModal:t,setShowDetailsModal:n,selectedModelName:p,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}=r();return(0,f.jsxs)(f.Fragment,{children:[t&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>n(!1)}),(0,f.jsxs)(`div`,{className:i(`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,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[V(`modelManager.modals.details.title`),`: `,p]}),(0,f.jsx)(`button`,{onClick:()=>n(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsx)(`div`,{className:`overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4`,children:h?(0,f.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,f.jsx)(o,{className:`h-6 w-6 animate-spin text-gray-400`})}):m?(0,f.jsxs)(f.Fragment,{children:[m.details&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.info`)}),(0,f.jsx)(`div`,{className:i(`p-3 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-50`),children:(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[m.details.family&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.family`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.family})]}),m.details.parameter_size&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.parameters`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.parameter_size})]}),m.details.quantization_level&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.quantization`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.quantization_level})]}),m.details.format&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.format`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.format})]})]})})]}),m.system&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.systemPrompt`)}),(0,f.jsx)(`pre`,{className:i(`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,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.template`)}),(0,f.jsx)(`pre`,{className:i(`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,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.parameters`)}),(0,f.jsx)(`pre`,{className:i(`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,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.license`)}),(0,f.jsx)(`pre`,{className:i(`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,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.modelfile`)}),(0,f.jsx)(`pre`,{className:i(`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,f.jsx)(`p`,{className:`text-center text-gray-500`,children:V(`modelManager.modals.details.noDetails`)})})]})]}),document.body),g&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>_(!1)}),(0,f.jsxs)(`div`,{className:i(`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,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.copy.title`)}),(0,f.jsx)(`button`,{onClick:()=>_(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.source`)}),(0,f.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),className:i(`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,f.jsx)(`option`,{value:``,children:V(`modelManager.modals.copy.selectModel`)}),e.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.newName`)}),(0,f.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:V(`modelManager.modals.copy.placeholder`),className:i(`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,f.jsxs)(u,{onClick:C,disabled:!v.trim()||!b.trim()||S,className:i(`w-full gap-2`,``),children:[S?(0,f.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(a,{className:`h-4 w-4`}),V(S?`modelManager.modals.copy.copying`:`modelManager.modals.copy.button`)]})]})]})]}),document.body),w&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>T(!1)}),(0,f.jsxs)(`div`,{className:i(`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,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.create.title`)}),(0,f.jsx)(`button`,{onClick:()=>T(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.name`)}),(0,f.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:V(`modelManager.modals.create.namePlaceholder`),className:i(`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,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.modelfile`)}),(0,f.jsx)(`textarea`,{value:O,onChange:e=>k(e.target.value),placeholder:V(`modelManager.modals.create.modelfilePlaceholder`),rows:8,className:i(`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,f.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500`,children:[V(`modelManager.modals.create.see`),` `,(0,f.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,f.jsxs)(u,{onClick:j,disabled:!E.trim()||!O.trim()||A,className:i(`w-full gap-2`,``),children:[A?(0,f.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(s,{className:`h-4 w-4`}),V(A?`modelManager.modals.create.creating`:`modelManager.modals.create.button`)]})]})]})]}),document.body),M&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>N(!1)}),(0,f.jsxs)(`div`,{className:i(`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,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.embeddings.title`)}),(0,f.jsx)(`button`,{onClick:()=>N(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.model`)}),(0,f.jsxs)(`select`,{value:P,onChange:e=>F(e.target.value),className:i(`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,f.jsx)(`option`,{value:``,children:V(`modelManager.modals.embeddings.selectModel`)}),e.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,f.jsx)(`p`,{className:`mt-1 text-xs text-gray-500`,children:V(`modelManager.modals.embeddings.recommended`)})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.input`)}),(0,f.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:V(`modelManager.modals.embeddings.placeholder`),rows:3,className:i(`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,f.jsxs)(u,{onClick:B,disabled:!P.trim()||!I.trim()||z,className:i(`w-full gap-2`,``),children:[z?(0,f.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(l,{className:`h-4 w-4`}),V(z?`modelManager.modals.embeddings.generating`:`modelManager.modals.embeddings.button`)]}),R&&(0,f.jsxs)(`div`,{children:[(0,f.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,f.jsxs)(`pre`,{className:i(`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{p as ModelManagerModals,p as default};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{i as r}from"./router-vendor-CMbYTGdh.js";import{t as i}from"./logger-DnuT4jgB.js";import{t as a}from"./useTranslation-D0mJ4NnO.js";import{r as o,t as s}from"./utils-Bn0RE9_8.js";import{t as c}from"./chatStore-8jYk48hC.js";import{$ as l,J as ee,N as te,Pt as u,W as d,at as f,br as p,ct as m,j as h,m as ne,n as g,pr as re,pt as _,rt as v,s as y,v as ie,wn as ae,yn as b,z as x}from"./ui-vendor-6y6qiSk5.js";import{A as S,k as C}from"./api-DQdJeQjd.js";import{t as w}from"./Button-BQ5JnUVj.js";import"./ui-UU79S5lB.js";import{t as oe}from"./RichMessageContent-XMkRvBen.js";var T=e(t(),1),E=4e3,D=(e,t)=>{let n=e.split(`
2
- `),r=t.split(`
3
- `);if(n.length>E||r.length>E)return[...n.map(e=>({type:`removed`,text:e})),...r.map(e=>({type:`added`,text:e}))];let i=Array.from({length:n.length+1},()=>Array(r.length+1).fill(0));for(let e=n.length-1;e>=0;--e)for(let t=r.length-1;t>=0;--t)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0;for(;o<n.length&&s<r.length;)n[o]===r[s]?(a.push({type:`context`,text:n[o]}),o+=1,s+=1):i[o+1][s]>=i[o][s+1]?(a.push({type:`removed`,text:n[o]}),o+=1):(a.push({type:`added`,text:r[s]}),s+=1);for(;o<n.length;)a.push({type:`removed`,text:n[o]}),o+=1;for(;s<r.length;)a.push({type:`added`,text:r[s]}),s+=1;return a},O=e=>e.some(e=>e.type!==`context`),k=n(),A=i(`components:note-tools`),j=({rows:e})=>(0,k.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-lg border border-black/[0.06] font-mono text-[12px] leading-relaxed dark:border-white/[0.08]`,"data-testid":`note-diff-view`,children:e.map((e,t)=>(0,k.jsx)(`div`,{className:s(`whitespace-pre-wrap px-2`,e.type===`added`&&`bg-[rgb(76,212,117)]/[0.12] text-green-800 dark:text-green-300`,e.type===`removed`&&`bg-[rgb(255,61,129)]/[0.10] text-red-800 line-through dark:text-red-300`,e.type===`context`&&`text-gray-600 dark:text-dark-700`),children:e.text||`\xA0`},t))}),M=({note:e,currentContent:t,currentTitle:n,canWrite:r,isOwner:i,initialTab:l,onClose:te,onApplyContent:d})=>{let{t:f,i18n:re}=a(),[_,v]=(0,T.useState)(l),[y,b]=(0,T.useState)(null),[oe,E]=(0,T.useState)(null),[M,N]=(0,T.useState)(null),[P,F]=(0,T.useState)(!1),I=(0,T.useRef)(null),[L,se]=(0,T.useState)(null),[R,z]=(0,T.useState)(``),[B,V]=(0,T.useState)(`read`),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)(``),[K,ce]=(0,T.useState)(!1),[q,J]=(0,T.useState)(null),Y=c(e=>e.selectedModel),le=c(e=>e.selectedProviderType),ue=c(e=>e.selectedProviderId),X=(0,T.useCallback)(()=>{S.getRevisions(e.id).then(e=>{e.success&&Array.isArray(e.data)&&b(e.data)}).catch(e=>A.error(`Failed to load revisions:`,e))},[e.id]),Z=(0,T.useCallback)(()=>{S.getAttachments(e.id).then(e=>{e.success&&Array.isArray(e.data)&&N(e.data)}).catch(e=>A.error(`Failed to load attachments:`,e))},[e.id]),Q=(0,T.useCallback)(()=>{C.listGrants(`note`,e.id).then(e=>{e.success&&Array.isArray(e.data)&&se(e.data)}).catch(e=>A.error(`Failed to load shares:`,e))},[e.id]);(0,T.useEffect)(()=>{_===`revisions`&&y===null&&X(),_===`attachments`&&M===null&&Z(),_===`share`&&i&&L===null&&Q()},[_,y,M,L,i,X,Z,Q]);let de=async t=>{try{let n=await S.restoreRevision(e.id,t);n.success&&n.data?(d(n.data.content,n.data.title),b(null),E(null),p.success(f(`notes.revisionRestored`))):p.error(n.error||f(`notes.revisionRestoreFailed`))}catch(e){A.error(`Failed to restore revision:`,e),p.error(f(`notes.revisionRestoreFailed`))}},fe=async t=>{if(!(!t||t.length===0)){F(!0);try{let n=await S.uploadAttachment(e.id,t[0]);n.success?(Z(),p.success(f(`notes.attachmentAdded`))):p.error(n.error||f(`notes.attachmentFailed`))}catch(e){A.error(`Failed to upload attachment:`,e),p.error(f(`notes.attachmentFailed`))}finally{F(!1),I.current&&(I.current.value=``)}}},pe=async t=>{try{let n=await S.downloadAttachment(e.id,t.id),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t.filename,i.click(),URL.revokeObjectURL(r)}catch(e){A.error(`Failed to download attachment:`,e),p.error(f(`notes.attachmentDownloadFailed`))}},me=async t=>{try{(await S.deleteAttachment(e.id,t)).success&&Z()}catch(e){A.error(`Failed to delete attachment:`,e)}},he=async()=>{let t=R.trim();if(t){U(!0);try{let n=await C.resolvePrincipal(t);if(!n.success||!n.data){p.error(f(`notes.shareUserNotFound`));return}let r=await C.createGrant({resourceType:`note`,resourceId:e.id,principalType:`user`,principalId:n.data.id,permission:B});r.success?(z(``),Q(),p.success(f(`notes.shareAdded`,{username:t}))):p.error(r.error||f(`notes.shareFailed`))}catch(e){A.error(`Failed to share note:`,e),p.error(f(`notes.shareFailed`))}finally{U(!1)}}},ge=async e=>{try{(await C.deleteGrant(e)).success&&Q()}catch(e){A.error(`Failed to revoke share:`,e)}},_e=async()=>{if(!(!W.trim()||!Y)){ce(!0),J(null);try{let t=await S.assist(e.id,{instruction:W,model:Y,providerType:le,providerId:ue});t.success&&t.data?.content!==void 0?J(t.data.content):p.error(t.error||f(`notes.assistFailed`))}catch(e){A.error(`Note assist failed:`,e),p.error(f(`notes.assistFailed`))}finally{ce(!1)}}},$=(0,T.useMemo)(()=>q===null?null:D(t,q),[q,t]),ve=[{id:`revisions`,icon:(0,k.jsx)(ee,{className:`h-3.5 w-3.5`}),label:f(`notes.revisions`)},{id:`attachments`,icon:(0,k.jsx)(m,{className:`h-3.5 w-3.5`}),label:f(`notes.attachments`)},{id:`share`,icon:(0,k.jsx)(x,{className:`h-3.5 w-3.5`}),label:f(`notes.share`),hidden:!i},{id:`assist`,icon:(0,k.jsx)(h,{className:`h-3.5 w-3.5`}),label:f(`notes.assist`),hidden:!r}];return(0,k.jsxs)(`div`,{className:`absolute inset-y-0 end-0 z-30 flex w-full max-w-md flex-col border-s border-black/[0.06] bg-surface shadow-xl dark:border-white/[0.07] dark:bg-dark-100`,"data-testid":`note-tools-drawer`,role:`dialog`,"aria-label":f(`notes.tools`),children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-black/[0.06] px-3 py-2 dark:border-white/[0.07]`,children:[ve.filter(e=>!e.hidden).map(e=>(0,k.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":_===e.id,onClick:()=>v(e.id),"data-testid":`note-tools-tab-${e.id}`,className:s(`flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] transition-colors`,_===e.id?`bg-black/[0.06] text-gray-900 dark:bg-white/[0.08] dark:text-dark-900`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),children:[e.icon,e.label]},e.id)),(0,k.jsx)(`button`,{type:`button`,onClick:te,className:`ms-auto rounded-md p-1.5 text-gray-400 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-800`,"aria-label":f(`common.close`),"data-testid":`note-tools-close`,children:(0,k.jsx)(g,{className:`h-4 w-4`})})]}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 scrollbar-thin`,children:[_===`revisions`&&(0,k.jsx)(`div`,{className:`space-y-2`,children:y===null?(0,k.jsx)(u,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):y.length===0?(0,k.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:f(`notes.noRevisions`)}):y.map(e=>(0,k.jsxs)(`div`,{className:`rounded-lg border border-black/[0.06] p-2.5 dark:border-white/[0.08]`,"data-testid":`note-revision-item`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>E(t=>t===e.id?null:e.id),className:`min-w-0 flex-1 truncate text-start text-[13px] text-gray-800 dark:text-dark-800`,children:[o(e.createdAt,re.language),e.title!==n&&(0,k.jsxs)(`span`,{className:`ms-1 text-gray-400 dark:text-dark-500`,children:[`· `,e.title||f(`notes.untitled`)]})]}),r&&(0,k.jsxs)(w,{size:`sm`,variant:`ghost`,className:`h-7 gap-1 px-2 text-[11px]`,onClick:()=>void de(e.id),"data-testid":`note-revision-restore`,children:[(0,k.jsx)(ne,{className:`h-3 w-3`}),f(`notes.restore`)]})]}),oe===e.id&&(0,k.jsx)(`div`,{className:`mt-2`,children:(0,k.jsx)(j,{rows:D(e.content,t)})})]},e.id))}),_===`attachments`&&(0,k.jsxs)(`div`,{className:`space-y-2`,children:[r&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{ref:I,type:`file`,className:`hidden`,onChange:e=>void fe(e.target.files),"data-testid":`note-attachment-input`}),(0,k.jsxs)(w,{size:`sm`,variant:`outline`,className:`w-full gap-1.5`,disabled:P,onClick:()=>I.current?.click(),"data-testid":`note-attachment-upload`,children:[P?(0,k.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}):(0,k.jsx)(m,{className:`h-3.5 w-3.5`}),f(`notes.addAttachment`)]})]}),M===null?(0,k.jsx)(u,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):M.length===0?(0,k.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:f(`notes.noAttachments`)}):M.map(e=>(0,k.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/[0.06] px-2.5 py-2 dark:border-white/[0.08]`,"data-testid":`note-attachment-item`,children:[(0,k.jsx)(m,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}),(0,k.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.filename}),(0,k.jsxs)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:[Math.max(1,Math.round(e.size/1024)),` KB`]}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>void pe(e),className:`rounded-md p-1 text-gray-400 hover:text-gray-700 dark:text-dark-500 dark:hover:text-dark-800`,title:f(`common.download`),children:(0,k.jsx)(ae,{className:`h-3.5 w-3.5`})}),r&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>void me(e.id),className:`rounded-md p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:f(`common.delete`),children:(0,k.jsx)(ie,{className:`h-3.5 w-3.5`})})]},e.id))]}),_===`share`&&i&&(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,k.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&he()},placeholder:f(`notes.shareUsernamePlaceholder`),className:`min-w-0 flex-1 rounded-lg border border-black/[0.08] bg-transparent px-2.5 py-1.5 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`note-share-username`}),(0,k.jsxs)(`select`,{value:B,onChange:e=>V(e.target.value),className:`rounded-lg border border-black/[0.08] bg-transparent px-2 py-1.5 text-[12px] text-gray-700 focus:outline-none dark:border-white/[0.1] dark:bg-dark-100 dark:text-dark-800`,"data-testid":`note-share-permission`,children:[(0,k.jsx)(`option`,{value:`read`,children:f(`notes.permissionRead`)}),(0,k.jsx)(`option`,{value:`write`,children:f(`notes.permissionWrite`)})]}),(0,k.jsx)(w,{size:`sm`,disabled:H||!R.trim(),onClick:()=>void he(),"data-testid":`note-share-submit`,children:H?(0,k.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}):f(`notes.shareAction`)})]}),L===null?(0,k.jsx)(u,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):L.length===0?(0,k.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:f(`notes.notShared`)}):L.map(e=>(0,k.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-black/[0.06] px-2.5 py-2 dark:border-white/[0.08]`,"data-testid":`note-share-item`,children:[(0,k.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-dark-500`}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] text-gray-800 dark:text-dark-800`,children:e.principalId}),(0,k.jsx)(`span`,{className:`shrink-0 text-[11px] uppercase text-gray-400 dark:text-dark-500`,children:e.permission}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>void ge(e.id),className:`rounded-md p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,title:f(`notes.revokeShare`),children:(0,k.jsx)(g,{className:`h-3.5 w-3.5`})})]},e.id)),(0,k.jsx)(`p`,{className:`text-[11px] leading-relaxed text-gray-400 dark:text-dark-500`,children:f(`notes.shareHint`)})]}),_===`assist`&&r&&(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`textarea`,{value:W,onChange:e=>G(e.target.value),placeholder:f(`notes.assistPlaceholder`),rows:3,className:`w-full resize-none rounded-lg border border-black/[0.08] bg-transparent px-2.5 py-2 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`note-assist-instruction`}),(0,k.jsxs)(w,{size:`sm`,className:`w-full gap-1.5`,disabled:K||!W.trim()||!Y,onClick:()=>void _e(),"data-testid":`note-assist-generate`,children:[K?(0,k.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}):(0,k.jsx)(h,{className:`h-3.5 w-3.5`}),f(`notes.assistGenerate`)]}),!Y&&(0,k.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:f(`notes.assistNoModel`)}),q!==null&&$&&(0,k.jsxs)(`div`,{className:`space-y-2`,children:[O($)?(0,k.jsx)(j,{rows:$}):(0,k.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:f(`notes.assistNoChanges`)}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(w,{size:`sm`,className:`flex-1`,disabled:!O($),onClick:()=>{d(q),J(null),G(``),p.success(f(`notes.assistApplied`))},"data-testid":`note-assist-apply`,children:f(`notes.assistApply`)}),(0,k.jsx)(w,{size:`sm`,variant:`outline`,className:`flex-1`,onClick:()=>J(null),"data-testid":`note-assist-discard`,children:f(`notes.assistDiscard`)})]}),(0,k.jsx)(`p`,{className:`text-[11px] leading-relaxed text-gray-400 dark:text-dark-500`,children:f(`notes.assistRevisionHint`)})]})]})]})]})},N=i(`pages:notes`),P=800,F=()=>{let{t:e,i18n:t}=a(),[n,i]=(0,T.useState)([]),[c,ee]=(0,T.useState)(!0),[u,m]=(0,T.useState)(null),[h,ne]=(0,T.useState)(``),[g,x]=(0,T.useState)(``),[C,E]=(0,T.useState)(``),[D,O]=(0,T.useState)(!0),[A,j]=(0,T.useState)(`idle`),[F,I]=(0,T.useState)(null),L=(0,T.useRef)(null),[se,R]=r(),z=(0,T.useMemo)(()=>n.find(e=>e.id===u)??null,[n,u]);(0,T.useEffect)(()=>{let e=!1;return S.getNotes().then(t=>{e||t.success&&t.data&&i(t.data)}).catch(e=>N.error(`Failed to load notes:`,e)).finally(()=>{e||ee(!1)}),()=>{e=!0}},[]);let B=se.get(`note`),V=B?n.find(e=>e.id===B):void 0;V&&u!==V.id&&(m(V.id),x(V.title),E(V.content),O(!0),j(`idle`));let H=B!==null&&(V!==void 0||!c);(0,T.useEffect)(()=>{H&&R({},{replace:!0})},[H,R]);let U=!z||!z.shared,W=z?!z.shared||z.shared.permission===`write`:!1,G=(e,t=`preview`)=>{Y(),m(e.id),x(e.title),E(e.content),O(t===`preview`),j(`idle`),I(null)},K=async()=>{if(z)try{let e=await S.updateNote(z.id,{pinned:!z.pinned});if(e.success&&e.data){let t=e.data;i(e=>e.map(e=>e.id===t.id?t:e))}}catch(e){N.error(`Failed to toggle pin:`,e)}},ce=()=>{if(!z)return;let e=new Blob([C],{type:`text/markdown;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${(g||`note`).replace(/[\\/:*?"<>|]/g,`-`)}.md`,n.click(),URL.revokeObjectURL(t)},q=(e,t,n)=>{L.current!==null&&window.clearTimeout(L.current),j(`saving`),L.current=window.setTimeout(()=>{L.current=null,J(e,t,n)},P)},J=async(t,n,r)=>{try{let e=await S.updateNote(t,{title:n,content:r});if(e.success&&e.data){let n=e.data;i(e=>[n,...e.filter(e=>e.id!==t)].sort((e,t)=>t.updatedAt-e.updatedAt)),j(`saved`)}}catch(t){N.error(`Failed to save note:`,t),p.error(e(`notes.saveFailed`)),j(`idle`)}},Y=()=>{L.current!==null&&u&&(window.clearTimeout(L.current),L.current=null,J(u,g,C))};(0,T.useEffect)(()=>()=>{L.current!==null&&window.clearTimeout(L.current)},[]);let le=async()=>{try{let e=await S.createNote(``,``);if(e.success&&e.data){let t=e.data;i(e=>[t,...e]),G(t,`edit`)}}catch(t){N.error(`Failed to create note:`,t),p.error(e(`notes.createFailed`))}},ue=async t=>{if(window.confirm(e(`notes.deleteConfirm`)))try{(await S.deleteNote(t)).success&&(i(e=>e.filter(e=>e.id!==t)),u===t&&m(null))}catch(t){N.error(`Failed to delete note:`,t),p.error(e(`notes.deleteFailed`))}},X=(0,T.useMemo)(()=>{let e=h.trim().toLowerCase();return e?n.filter(t=>t.title.toLowerCase().includes(e)||t.content.toLowerCase().includes(e)):n},[n,h]);return(0,k.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden`,"data-testid":`notes-page`,children:[(0,k.jsxs)(`div`,{"data-testid":`notes-list`,className:s(`min-h-0 w-full shrink-0 flex-col border-e border-black/[0.06] dark:border-white/[0.07] md:w-72`,z?`hidden md:flex`:`flex`),children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4`,children:[(0,k.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`notes.title`)}),(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:()=>void le(),className:`h-7 w-7 p-0`,title:e(`notes.new`),children:(0,k.jsx)(l,{className:`h-4 w-4`})})]}),(0,k.jsxs)(`div`,{className:`relative mx-3 mb-2`,children:[(0,k.jsx)(d,{className:`pointer-events-none absolute start-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gray-400 dark:text-dark-500`}),(0,k.jsx)(`input`,{type:`search`,value:h,onChange:e=>ne(e.target.value),placeholder:e(`common.search`),className:`w-full rounded-lg border border-transparent bg-black/[0.04] py-1.5 pe-2.5 ps-8 text-base text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:bg-white/[0.05] dark:text-dark-900 dark:placeholder:text-dark-500 sm:text-[13px]`})]}),(0,k.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:c?null:X.length===0?(0,k.jsxs)(`div`,{className:`px-3 py-10 text-center`,children:[(0,k.jsx)(_,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,k.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:e(`notes.empty`)})]}):(0,k.jsx)(`div`,{className:`space-y-0.5`,children:X.map(n=>(0,k.jsxs)(`div`,{"data-testid":`note-list-item`,onClick:()=>G(n),className:s(`group cursor-pointer rounded-lg px-2.5 py-2 transition-colors`,u===n.id?`bg-white ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`:`hover:bg-white/60 dark:hover:bg-dark-200/60`),children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`p`,{className:`flex min-w-0 flex-1 items-center gap-1 truncate text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:[n.pinned&&(0,k.jsx)(v,{className:`h-3 w-3 shrink-0 text-primary-500`,"aria-label":e(`notes.pinned`)}),n.shared&&(0,k.jsx)(y,{className:`h-3 w-3 shrink-0 text-gray-400 dark:text-dark-500`,"aria-label":e(`notes.sharedWithYou`)}),(0,k.jsx)(`span`,{className:`truncate`,children:n.title||e(`notes.untitled`)})]}),!n.shared&&(0,k.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(n.id)},className:`shrink-0 rounded-md p-1 text-red-500 opacity-100 transition-opacity hover:bg-red-50 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100 dark:hover:bg-red-900/20`,title:e(`common.delete`),children:(0,k.jsx)(ie,{className:`h-3 w-3`})})]}),(0,k.jsxs)(`p`,{className:`mt-0.5 truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[o(n.updatedAt,t.language),n.content.trim()&&(0,k.jsxs)(k.Fragment,{children:[` · `,n.content.trim().slice(0,60)]})]})]},n.id))})})]}),(0,k.jsx)(`div`,{"data-testid":`notes-editor`,className:s(`min-w-0 flex-1 flex-col`,z?`flex`:`hidden md:flex`),children:z?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 border-b border-black/[0.06] px-2.5 py-2.5 dark:border-white/[0.07] sm:gap-2 sm:px-5 sm:py-3`,children:[(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:()=>{Y(),m(null),O(!0)},className:`h-9 w-9 shrink-0 p-0 md:hidden`,title:`${e(`common.back`)}: ${e(`notes.title`)}`,"aria-label":`${e(`common.back`)}: ${e(`notes.title`)}`,"data-testid":`notes-mobile-back`,children:(0,k.jsx)(re,{className:`h-4 w-4 rtl:rotate-180`})}),D?(0,k.jsx)(`h2`,{"data-testid":`notes-title-preview`,dir:`auto`,className:`min-w-0 flex-1 truncate text-base font-semibold text-gray-950 dark:text-dark-950 sm:text-lg`,children:g||e(`notes.untitled`)}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{"data-testid":`notes-title-editor`,dir:`auto`,readOnly:!W,value:g,onChange:e=>{x(e.target.value),q(z.id,e.target.value,C)},placeholder:e(`notes.untitled`),className:`min-w-0 flex-1 bg-transparent text-base font-semibold text-gray-950 placeholder:text-gray-400 focus:outline-none dark:text-dark-950 dark:placeholder:text-dark-500 sm:text-lg`}),(0,k.jsx)(`span`,{className:`hidden shrink-0 text-[11px] text-gray-400 dark:text-dark-500 sm:inline`,"aria-live":`polite`,children:A===`saving`?e(`common.saving`):A===`saved`?e(`notes.saved`):``})]}),U&&(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:()=>void K(),className:s(`hidden h-8 w-8 shrink-0 p-0 sm:flex`,z.pinned&&`text-primary-500`),title:z.pinned?e(`notes.unpin`):e(`notes.pin`),"aria-label":z.pinned?e(`notes.unpin`):e(`notes.pin`),"data-testid":`notes-pin-toggle`,children:(0,k.jsx)(v,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:ce,className:`hidden h-8 w-8 shrink-0 p-0 sm:flex`,title:e(`notes.export`),"aria-label":e(`notes.export`),"data-testid":`notes-export`,children:(0,k.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:()=>I(e=>e===null?`revisions`:null),className:`h-9 w-9 shrink-0 p-0 sm:h-8 sm:w-8`,title:e(`notes.tools`),"aria-label":e(`notes.tools`),"aria-expanded":F!==null,"data-testid":`notes-tools-toggle`,children:(0,k.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:()=>{D||Y(),O(e=>!e)},className:`h-9 w-9 shrink-0 gap-1.5 p-0 text-xs sm:h-8 sm:w-auto sm:px-2.5`,title:e(D?`common.edit`:`artifacts.preview`),"aria-label":e(D?`common.edit`:`artifacts.preview`),"data-testid":`notes-preview-toggle`,children:D?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f,{className:`h-3.5 w-3.5`}),(0,k.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.edit`)})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(b,{className:`h-3.5 w-3.5`}),(0,k.jsx)(`span`,{className:`hidden sm:inline`,children:e(`artifacts.preview`)})]})})]}),D?(0,k.jsx)(`div`,{"data-testid":`notes-preview`,className:`scroll-region min-h-0 flex-1 overflow-y-auto px-4 py-3 scrollbar-thin sm:px-5 sm:py-4`,children:(0,k.jsx)(oe,{content:C,allowHtml:!0,className:`mx-auto w-full max-w-5xl pb-12`})}):(0,k.jsx)(`textarea`,{"data-testid":`notes-content-editor`,dir:`auto`,readOnly:!W,value:C,onChange:e=>{E(e.target.value),q(z.id,g,e.target.value)},onBlur:Y,placeholder:e(`notes.contentPlaceholder`),className:`min-h-0 flex-1 resize-none bg-transparent px-4 py-3 font-mono text-base leading-relaxed text-gray-900 placeholder:text-gray-400 focus:outline-none dark:text-dark-900 dark:placeholder:text-dark-500 sm:px-5 sm:py-4 sm:text-[13.5px]`}),F!==null&&(0,k.jsx)(M,{note:z,currentContent:C,currentTitle:g,canWrite:W,isOwner:U,initialTab:F,onClose:()=>I(null),onApplyContent:(e,t)=>{E(e),t!==void 0&&x(t),J(z.id,t===void 0?g:t,e)}})]}):(0,k.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,k.jsxs)(`div`,{className:`text-center`,children:[(0,k.jsx)(_,{className:`mx-auto mb-3 h-8 w-8 text-gray-300 dark:text-dark-400`}),(0,k.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-600`,children:e(`notes.selectOrCreate`)}),(0,k.jsxs)(w,{size:`sm`,onClick:()=>void le(),className:`mt-4 gap-1.5`,children:[(0,k.jsx)(l,{className:`h-3.5 w-3.5`}),e(`notes.new`)]})]})})})]})};export{F as NotesPage,F as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{t as r}from"./useQuery-BKulzCS7.js";import{t as i}from"./useTranslation-D0mJ4NnO.js";import{t as a}from"./utils-Bn0RE9_8.js";import{$ as o,Fn as s,Pt as c,X as l,_r as u,ar as d,g as f,in as p,s as m,v as h,wn as g,yr as _,zn as v}from"./ui-vendor-6y6qiSk5.js";import{n as y}from"./workApi-xhF57amo.js";import{u as b}from"./api-DQdJeQjd.js";import{t as x}from"./Button-BQ5JnUVj.js";import{a as S,o as C}from"./ui-UU79S5lB.js";var w=e(t(),1),T={getAnalytics:e=>y.get(`/costs/analytics`,{params:{days:e}}).then(e=>e.data),listTariffs:()=>y.get(`/costs/tariffs`).then(e=>e.data),createTariff:e=>y.post(`/costs/tariffs`,e).then(e=>e.data),deleteTariff:e=>y.delete(`/costs/tariffs/${encodeURIComponent(e)}`).then(()=>void 0),listBudgets:()=>y.get(`/costs/budgets`).then(e=>e.data),createBudget:e=>y.post(`/costs/budgets`,e).then(e=>e.data),deleteBudget:e=>y.delete(`/costs/budgets/${encodeURIComponent(e)}`).then(()=>void 0),exportUrl:e=>`/api/costs/export?days=${e}`,exportCsv:e=>y.get(`/costs/export`,{params:{days:e},responseType:`blob`}).then(e=>e.data)},E=n(),D=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,maximumFractionDigits:e<1?4:2}).format(e),O=`w-full rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-dark-300 dark:bg-dark-50`,k=({days:e})=>{let{t}=i(),[n,r]=(0,w.useState)(null),[a,s]=(0,w.useState)([]),[l,u]=(0,w.useState)([]),[d,f]=(0,w.useState)(!0),[p,m]=(0,w.useState)(0),[v,y]=(0,w.useState)({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),[b,S]=(0,w.useState)({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`});(0,w.useEffect)(()=>{let n=!1;return Promise.all([T.getAnalytics(e),T.listTariffs(),T.listBudgets()]).then(([e,t,i])=>{n||(e.success&&e.data&&r(e.data),t.success&&t.data&&s(t.data),i.success&&i.data&&u(i.data))}).catch(()=>_.error(t(`costs.loadFailed`))).finally(()=>{n||f(!1)}),()=>{n=!0}},[e,p,t]);let C=e=>{if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0},k=async()=>{try{let e=await T.createTariff({pluginId:v.pluginId.trim(),model:v.model.trim()||void 0,inputPerMillion:C(v.inputPerMillion),outputPerMillion:C(v.outputPerMillion),unitPrice:C(v.unitPrice)});if(!e.success)throw Error(e.message);_.success(t(`costs.tariffSaved`)),y({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),m(e=>e+1)}catch(e){_.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},A=async()=>{try{let e=await T.createBudget({name:b.name.trim(),principalType:b.principalType,principalId:b.principalType===`instance`?void 0:b.principalId.trim(),period:b.period,amountUsd:Number(b.amountUsd),mode:b.mode});if(!e.success)throw Error(e.message);_.success(t(`costs.budgetSaved`)),S({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`}),m(e=>e+1)}catch(e){_.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},j=async()=>{try{let t=await T.exportCsv(e),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`libre-webui-costs.csv`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}catch{_.error(t(`costs.exportFailed`))}};return d&&!n?(0,E.jsx)(`div`,{className:`flex justify-center rounded-lg border border-gray-200 bg-white p-6 dark:border-dark-300 dark:bg-dark-100`,children:(0,E.jsx)(c,{className:`h-5 w-5 animate-spin text-gray-400`})}):(0,E.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,"data-testid":`cost-governance-panel`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`costs.title`)}),(0,E.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`costs.description`)})]}),(0,E.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void j(),children:[(0,E.jsx)(g,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.exportCsv`)]})]}),n&&(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.totalSpend`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:D(n.totalUsd)})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.meteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.meteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.unmeteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.unmeteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.topModel`)}),(0,E.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.byModel[0]?`${n.byModel[0].model} (${D(n.byModel[0].usd)})`:`—`})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.budgets`)}),(0,E.jsxs)(`div`,{className:`space-y-2`,children:[n?.budgets.map(e=>{let n=Math.min(1,e.spentUsd/e.amountUsd);return(0,E.jsxs)(`div`,{className:`rounded-lg border border-gray-200 p-2 dark:border-dark-300`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,E.jsxs)(`span`,{className:`min-w-0 truncate font-medium`,children:[e.name,(0,E.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-gray-500`,children:[t(`costs.mode.${e.mode}`),` ·`,` `,t(`costs.period.${e.period}`),` ·`,` `,e.principalType===`instance`?t(`costs.scope.instance`):`${t(`costs.scope.${e.principalType}`)}: ${e.principalId}`]})]}),(0,E.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-600 dark:text-gray-300`,children:[D(e.spentUsd),` / `,D(e.amountUsd)]}),(0,E.jsx)(`button`,{onClick:()=>{T.deleteBudget(e.id).then(()=>m(e=>e+1)).catch(()=>_.error(t(`costs.saveFailed`)))},className:`shrink-0 rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteBudget`),children:(0,E.jsx)(h,{className:`h-3.5 w-3.5`})})]}),(0,E.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded bg-gray-200 dark:bg-dark-300`,children:(0,E.jsx)(`div`,{className:n>=1?`h-full bg-red-500`:n>=.8?`h-full bg-amber-500`:`h-full bg-emerald-500`,style:{width:`${Math.round(n*100)}%`}})})]},e.id)}),l.length===0&&(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.noBudgets`)})]}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.budgetName`),value:b.name,onChange:e=>S({...b,name:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.principalType,onChange:e=>S({...b,principalType:e.target.value}),children:[(0,E.jsx)(`option`,{value:`instance`,children:t(`costs.scope.instance`)}),(0,E.jsx)(`option`,{value:`user`,children:t(`costs.scope.user`)}),(0,E.jsx)(`option`,{value:`group`,children:t(`costs.scope.group`)})]}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.principalId`),value:b.principalId,disabled:b.principalType===`instance`,onChange:e=>S({...b,principalId:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.period,onChange:e=>S({...b,period:e.target.value}),children:[(0,E.jsx)(`option`,{value:`daily`,children:t(`costs.period.daily`)}),(0,E.jsx)(`option`,{value:`weekly`,children:t(`costs.period.weekly`)}),(0,E.jsx)(`option`,{value:`monthly`,children:t(`costs.period.monthly`)})]}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(`input`,{className:O,placeholder:`USD`,inputMode:`decimal`,value:b.amountUsd,onChange:e=>S({...b,amountUsd:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.mode,onChange:e=>S({...b,mode:e.target.value}),children:[(0,E.jsx)(`option`,{value:`observe`,children:t(`costs.mode.observe`)}),(0,E.jsx)(`option`,{value:`soft`,children:t(`costs.mode.soft`)}),(0,E.jsx)(`option`,{value:`hard`,children:t(`costs.mode.hard`)})]})]}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void A(),children:[(0,E.jsx)(o,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addBudget`)]})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.tariffs`)}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,E.jsx)(`thead`,{className:`text-gray-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.plugin`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.model`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.inputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.outputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.unitPrice`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.effectiveFrom`)}),(0,E.jsx)(`th`,{})]})}),(0,E.jsxs)(`tbody`,{children:[a.map(e=>(0,E.jsxs)(`tr`,{className:`border-t border-gray-100 dark:border-dark-300`,children:[(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.plugin_id}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.model??t(`costs.allModels`)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.input_per_million===null?`—`:D(e.input_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.output_per_million===null?`—`:D(e.output_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.unit_price===null?`—`:D(e.unit_price)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.effective_from)}),(0,E.jsx)(`td`,{className:`py-1`,children:(0,E.jsx)(`button`,{onClick:()=>{T.deleteTariff(e.id).then(()=>m(e=>e+1)).catch(()=>_.error(t(`costs.saveFailed`)))},className:`rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteTariff`),children:(0,E.jsx)(h,{className:`h-3.5 w-3.5`})})})]},e.id)),a.length===0&&(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:7,className:`py-2 text-gray-500`,children:t(`costs.noTariffs`)})})]})]})}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.plugin`),value:v.pluginId,onChange:e=>y({...v,pluginId:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.modelOptional`),value:v.model,onChange:e=>y({...v,model:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.inputPerMillion`),inputMode:`decimal`,value:v.inputPerMillion,onChange:e=>y({...v,inputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.outputPerMillion`),inputMode:`decimal`,value:v.outputPerMillion,onChange:e=>y({...v,outputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.unitPrice`),inputMode:`decimal`,value:v.unitPrice,onChange:e=>y({...v,unitPrice:e.target.value})}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void k(),children:[(0,E.jsx)(o,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addTariff`)]})]})]})]})},A=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),j=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),M=e=>e>=1e4?j.format(e):A.format(e),N=e=>e?e<1e3?`${A.format(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`:`—`,P=(e,t)=>e===0?0:(e-t)/e*100,F=({analytics:e,metric:t,onMetricChange:n})=>{let{t:r}=i(),o={top:22,right:18,bottom:42,left:52},s=e.series.map(e=>e[t]),c=Math.max(1,...s),l=960-o.left-o.right,u=280-o.top-o.bottom,d=t=>o.left+(e.series.length<=1?l/2:t/(e.series.length-1)*l),f=e=>o.top+u-e/c*u,p=e.series.map((e,n)=>({x:d(n),y:f(e[t]),point:e})),m=p.map(({x:e,y:t},n)=>`${n===0?`M`:`L`} ${e} ${t}`).join(` `),h=p.length?`${m} L ${p[p.length-1].x} ${o.top+u} L ${p[0].x} ${o.top+u} Z`:``,g=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),_=Array.from(new Set([0,Math.floor((e.series.length-1)/2),e.series.length-1])).filter(e=>e>=0);return(0,E.jsxs)(`div`,{"data-testid":`plugin-usage-chart`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:r(`usageAnalytics.activity.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:r(t===`calls`?`usageAnalytics.activity.callsDescription`:`usageAnalytics.activity.tokensDescription`)})]}),(0,E.jsx)(`div`,{className:`inline-flex w-fit rounded-xl bg-gray-100 p-1 dark:bg-dark-200/80`,children:[`calls`,`tokens`].map(e=>(0,E.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===e?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),onClick:()=>n(e),children:r(`usageAnalytics.metrics.${e}`)},e))})]}),(0,E.jsx)(`div`,{className:`px-2 pb-3 pt-4 sm:px-5 sm:pt-6`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 960 280`,className:`h-auto w-full overflow-visible`,role:`img`,"aria-label":r(`usageAnalytics.activity.chartLabel`,{metric:r(`usageAnalytics.metrics.${t}`)}),children:[(0,E.jsx)(`defs`,{children:(0,E.jsxs)(`linearGradient`,{id:`plugin-usage-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,E.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.28`}),(0,E.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.015`})]})}),[0,.25,.5,.75,1].map(e=>{let t=o.top+u*e,n=Math.round(c*(1-e));return(0,E.jsxs)(`g`,{children:[(0,E.jsx)(`line`,{x1:o.left,x2:960-o.right,y1:t,y2:t,className:`stroke-gray-200 dark:stroke-white/[0.07]`,strokeDasharray:e===1?void 0:`4 8`}),(0,E.jsx)(`text`,{x:o.left-12,y:t+4,textAnchor:`end`,className:`fill-gray-400 text-[11px] dark:fill-dark-500`,children:M(n)})]},e)}),h&&(0,E.jsx)(`path`,{d:h,fill:`url(#plugin-usage-area)`}),m&&(0,E.jsx)(`path`,{d:m,fill:`none`,className:`stroke-primary-500 dark:stroke-primary-400`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(e.series.length<=31?p:[]).map(({x:e,y:n,point:i})=>(0,E.jsx)(`circle`,{cx:e,cy:n,r:`4`,className:`fill-white stroke-primary-500 dark:fill-dark-100 dark:stroke-primary-400`,strokeWidth:`2.5`,children:(0,E.jsx)(`title`,{children:`${g.format(i.timestamp)}: ${M(i[t])} ${r(`usageAnalytics.metrics.${t}`).toLocaleLowerCase()}`})},i.timestamp)),_.map(t=>{let n=e.series[t];if(!n)return null;let r=t===0?`start`:t===e.series.length-1?`end`:`middle`;return(0,E.jsx)(`text`,{x:d(t),y:270,textAnchor:r,className:`fill-gray-500 text-[12px] dark:fill-dark-500`,children:g.format(n.timestamp)},n.timestamp)})]})})]})},I=864e5,L=10,R=12,z=30,B=16,V=[`fill-blue-500`,`fill-emerald-500 dark:fill-emerald-600`,`fill-amber-500 dark:fill-amber-600`,`fill-violet-500`,`fill-rose-500`],H=[`bg-blue-500`,`bg-emerald-500 dark:bg-emerald-600`,`bg-amber-500 dark:bg-amber-600`,`bg-violet-500`,`bg-rose-500`],U=`fill-gray-400 dark:fill-gray-500`,W=`bg-gray-400 dark:bg-gray-500`,G=`fill-gray-950/[0.06] dark:fill-white/[0.07]`,K=[0,.35,.55,.75,1],q=({heatmap:e})=>{let{t,i18n:n}=i(),[r,o]=(0,w.useState)(null),{weeks:s,firstColStart:c,cellsByDay:l,maxCalls:u,modelRank:d,totalCalls:f}=(0,w.useMemo)(()=>{let t=new Map(e.cells.map(e=>[e.timestamp,e])),n=e.from,r=e.from+(e.days-1)*I,i=n-new Date(n).getUTCDay()*I;return{weeks:Math.ceil((r-i+I)/(7*I)),firstColStart:i,cellsByDay:t,maxCalls:Math.max(1,...e.cells.map(e=>e.calls)),modelRank:new Map(e.models.map((e,t)=>[e,t])),totalCalls:e.cells.reduce((e,t)=>e+t.calls,0)}},[e]),p=new Intl.DateTimeFormat(n.language,{month:`short`,timeZone:`UTC`}),m=new Intl.DateTimeFormat(n.language,{weekday:`short`,timeZone:`UTC`}),h=new Intl.DateTimeFormat(n.language,{dateStyle:`medium`,timeZone:`UTC`}),g=e.from,_=e.from+(e.days-1)*I,v=z+s*R,y=[],b=-1;for(let e=0;e<s;e++){let t=c+e*7*I,n=Math.max(t,g),r=new Date(n).getUTCMonth();r!==b&&t>=g-6*I&&((b!==-1||t>=g)&&y.push({x:z+e*R,label:p.format(n)}),b=r)}let x=e=>e<=0?0:Math.min(4,Math.max(1,Math.ceil(e/u*4))),S=e=>{let t=e.models[0]?.model,n=t===void 0?void 0:d.get(t);return n===void 0?U:V[n]},C=(e,t,n)=>{let r=e.currentTarget.closest(`[data-heatmap-wrapper]`);if(!r)return;let i=r.getBoundingClientRect(),a=e.currentTarget.getBoundingClientRect(),s=a.left-i.left+a.width/2;o({x:Math.min(Math.max(s,96),Math.max(i.width-96,96)),y:a.top-i.top,timestamp:t,calls:n.calls,models:n.models})};return(0,E.jsxs)(`section`,{"data-testid":`usage-heatmap`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:t(`usageAnalytics.heatmap.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.description`)})]}),(0,E.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.yearTotal`,{count:f,formatted:M(f)})})]}),(0,E.jsxs)(`div`,{className:`relative p-4 sm:px-5`,"data-heatmap-wrapper":!0,children:[(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 ${v} 100`,className:`h-auto w-full min-w-[640px]`,role:`img`,"aria-label":t(`usageAnalytics.heatmap.title`),onMouseLeave:()=>o(null),children:[y.map(({x:e,label:t})=>(0,E.jsx)(`text`,{x:e,y:10,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:t},`${e}-${t}`)),[1,3,5].map(e=>(0,E.jsx)(`text`,{x:0,y:B+e*R+L-2,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:m.format(new Date(Date.UTC(2023,0,1+e)))},e)),Array.from({length:s},(e,t)=>Array.from({length:7},(e,n)=>{let i=c+(t*7+n)*I;if(i<g||i>_)return null;let o=l.get(i),s=o?.calls??0,u=x(s);return(0,E.jsx)(`rect`,{x:z+t*R,y:B+n*R,width:L,height:L,rx:2,fillOpacity:u===0?1:K[u],strokeWidth:+(r?.timestamp===i),className:a(`transition-opacity`,u===0||!o?G:S(o),r?.timestamp===i?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>C(e,i,{calls:s,models:o?.models??[]}),children:(0,E.jsx)(`title`,{children:`${h.format(i)} — ${M(s)}`})},i)}))]})}),r&&(0,E.jsxs)(`div`,{className:`pointer-events-none absolute z-10 min-w-[10rem] -translate-x-1/2 -translate-y-full rounded-lg border border-gray-200/80 bg-white/95 px-3 py-2 shadow-card backdrop-blur-md dark:border-white/[0.1] dark:bg-dark-100/95`,style:{left:r.x,top:r.y-6},children:[(0,E.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:h.format(r.timestamp)}),(0,E.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:r.calls===0?t(`usageAnalytics.heatmap.noCalls`):`${M(r.calls)} ${t(`usageAnalytics.heatmap.calls`)}`}),r.models.slice(0,3).map(e=>(0,E.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 text-[11px]`,children:[(0,E.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:a(`h-2 w-2 shrink-0 rounded-[3px]`,d.has(e.model)?H[d.get(e.model)]:W)}),(0,E.jsx)(`span`,{className:`truncate font-mono text-gray-700 dark:text-dark-700`,dir:`ltr`,children:e.model})]}),(0,E.jsx)(`span`,{className:`tabular-nums text-gray-500 dark:text-dark-500`,children:M(e.calls)})]},e.model))]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5`,children:[e.models.map((e,t)=>(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,H[t])}),(0,E.jsx)(`span`,{className:`font-mono`,dir:`ltr`,children:e})]},e)),(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,W)}),t(`usageAnalytics.heatmap.other`)]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[t(`usageAnalytics.heatmap.less`),(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-gray-950/[0.06] dark:bg-white/[0.07]`}),K.slice(1).map(e=>(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-primary-500`,style:{opacity:e}},e)),t(`usageAnalytics.heatmap.more`)]})]})]})]})},J=()=>{let{t:e}=i(),[t,n]=(0,w.useState)(30),[o,h]=(0,w.useState)(`calls`),{data:g,error:_,isLoading:y,isFetching:T,refetch:D}=r({queryKey:[`plugin-usage`,t],queryFn:async()=>{let n=await b.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),O=_?_ instanceof Error?_.message:e(`usageAnalytics.loadFailed`):null,A=g?.totals,j=(0,w.useMemo)(()=>[{label:e(`usageAnalytics.cards.calls`),value:M(A?.calls??0),detail:e(`usageAnalytics.cards.callsDetail`,{count:A?.uniqueUsers??0}),icon:u},{label:e(`usageAnalytics.cards.tokens`),value:M(A?.reportedTokens??0),detail:e(`usageAnalytics.cards.tokensDetail`,{count:A?.meteredCalls??0}),icon:p},{label:e(`usageAnalytics.cards.success`),value:`${P(A?.calls??0,(A?.failedCalls??0)+(A?.cancelledCalls??0)).toFixed(1)}%`,detail:e(`usageAnalytics.cards.successDetail`,{count:A?.failedCalls??0}),icon:v},{label:e(`usageAnalytics.cards.latency`),value:N(A?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:s}],[e,A]);return y&&!g?(0,E.jsx)(C,{width:`wide`,children:(0,E.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,E.jsx)(c,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,E.jsxs)(C,{width:`wide`,children:[(0,E.jsx)(S,{eyebrow:e(`usageAnalytics.eyebrow`),title:e(`usageAnalytics.title`),description:e(`usageAnalytics.description`),actions:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`inline-flex rounded-xl border border-gray-200 bg-white/70 p-1 dark:border-white/[0.08] dark:bg-dark-100/70`,children:[7,30,90].map(r=>(0,E.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===r?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`text-gray-500 hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`),onClick:()=>n(r),children:e(`usageAnalytics.days`,{count:r})},r))}),(0,E.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void D(),disabled:T,children:[(0,E.jsx)(l,{className:a(`h-4 w-4`,T&&`animate-spin`)}),(0,E.jsx)(`span`,{className:`sr-only`,children:e(`usageAnalytics.refresh`)})]})]})}),O&&(0,E.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,E.jsx)(f,{className:`h-4 w-4 shrink-0`}),(0,E.jsx)(`span`,{children:O})]}),(0,E.jsx)(`div`,{className:`mb-6`,children:(0,E.jsx)(k,{days:t})}),g&&(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:j.map(e=>{let t=e.icon;return(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,E.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,E.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,E.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})}),g.heatmap&&g.heatmap.cells.length>0&&(0,E.jsx)(q,{heatmap:g.heatmap}),(0,E.jsx)(F,{analytics:g,metric:o,onMetricChange:h}),g.totals.calls===0?(0,E.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 px-6 py-10 text-center dark:border-white/[0.12]`,children:[(0,E.jsx)(d,{className:`mx-auto h-8 w-8 text-gray-400 dark:text-dark-500`}),(0,E.jsx)(`h2`,{className:`mt-4 text-base font-medium text-gray-900 dark:text-dark-900`,children:e(`usageAnalytics.empty.title`)}),(0,E.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.empty.description`)})]}):(0,E.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.15fr_0.85fr]`,children:[(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.models.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.description`)})]}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full min-w-[620px] text-start text-sm`,children:[(0,E.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`usageAnalytics.models.model`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.calls`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.tokens`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.models.success`)}),(0,E.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`usageAnalytics.models.latency`)})]})}),(0,E.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:g.models.slice(0,12).map(e=>(0,E.jsxs)(`tr`,{children:[(0,E.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,E.jsx)(`div`,{className:`max-w-[260px] truncate font-medium text-gray-900 dark:text-dark-900`,title:e.model,children:e.model}),(0,E.jsx)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:e.pluginName})]}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:M(e.calls)}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:e.tokens?M(e.tokens):`—`}),(0,E.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[P(e.calls,e.errors).toFixed(1),`%`]}),(0,E.jsx)(`td`,{className:`px-5 py-2.5 text-end tabular-nums text-gray-500 dark:text-dark-500`,children:N(e.averageLatencyMs)})]},`${e.pluginId}:${e.model}`))})]})})]}),(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.providers.title`)}),(0,E.jsx)(`div`,{className:`mt-5 space-y-4`,children:g.plugins.slice(0,8).map(t=>{let n=g.totals.calls?t.calls/g.totals.calls*100:0;return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`div`,{className:`truncate font-medium text-gray-900 dark:text-dark-900`,children:t.pluginName}),(0,E.jsxs)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:[M(t.tokens),` `,e(`usageAnalytics.metrics.tokens`).toLocaleLowerCase()]})]}),(0,E.jsx)(`span`,{className:`shrink-0 tabular-nums text-gray-600 dark:text-dark-600`,children:M(t.calls)})]}),(0,E.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,children:(0,E.jsx)(`div`,{className:`h-full rounded-full bg-primary-500 dark:bg-primary-400`,style:{width:`${Math.max(2,n)}%`}})})]},t.pluginId)})})]}),(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(m,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`}),(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.capabilities.title`)})]}),(0,E.jsx)(`div`,{className:`mt-5 grid grid-cols-2 gap-3`,children:g.capabilities.map(t=>(0,E.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium capitalize text-gray-500 dark:text-dark-500`,children:t.capability}),(0,E.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:M(t.calls)}),(0,E.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-500 dark:text-dark-500`,children:t.capability===`tts`?e(`usageAnalytics.capabilities.characters`,{count:M(t.inputUnits)}):t.capability===`stt`?e(`usageAnalytics.capabilities.bytes`,{count:M(t.inputUnits)}):t.capability===`image`?e(`usageAnalytics.capabilities.images`,{count:M(t.outputUnits)}):t.capability===`video`?e(`usageAnalytics.capabilities.jobs`,{count:M(t.calls)}):t.capability===`embedding`?e(`usageAnalytics.capabilities.inputs`,{count:M(t.inputUnits)}):e(`usageAnalytics.capabilities.reportedTokens`,{count:M(t.tokens)})})]},t.capability))})]})]})]}),(0,E.jsx)(`p`,{className:`px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.privacyNote`)})]})]})};export{J as default};
@@ -1 +0,0 @@
1
- import{t as e}from"./RichMessageContent-XMkRvBen.js";export{e as RichMessageContent,e as default};
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/markdownMath-CoDj1i7z.js","js/markdown-math-Dg-WB9ui.js","js/markdown-core-D067gSd8.js","js/rolldown-runtime-hePW80VL.js","js/react-vendor-D0Ec-185.js","assets/markdown-math-Ddr6Z9Sf.css","js/markdownHtml-Djpz4yB3.js","js/markdown-html-CQM6wA9G.js","js/OptimizedSyntaxHighlighter-SkJc7ZMe.js","js/OptimizedSyntaxHighlighter-CtQ_FGCX.js","js/syntax-highlight-DTWfgxYh.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{o as r}from"./logger-DnuT4jgB.js";import{t as i}from"./utils-Bn0RE9_8.js";import{t as a}from"./appStore-BXbVcTeo.js";import{a as o,i as s,n as c,r as l,s as u,t as d}from"./messageCodeStyles-0_YpQDk4.js";import{i as f,s as p}from"./markdown-core-D067gSd8.js";var m=e(t(),1),h=null,g=null,_=null,v=null,y=()=>_??=r(()=>import(`./markdownMath-CoDj1i7z.js`).then(e=>(h=e,e)),__vite__mapDeps([0,1,2,3,4,5])),b=()=>v??=r(()=>import(`./markdownHtml-Djpz4yB3.js`).then(e=>(g=e,e)),__vite__mapDeps([6,7,2,3,4])),x=e=>e.includes(`$`);function S(e){let{needsMath:t,needsHtml:n}=e,[,r]=m.useReducer(e=>e+1,0);return m.useEffect(()=>{if(!t||h)return;let e=!1;return y().then(()=>{e||r()}),()=>{e=!0}},[t]),m.useEffect(()=>{if(!n||g)return;let e=!1;return b().then(()=>{e||r()}),()=>{e=!0}},[n]),{math:t?h:null,html:n?g:null}}var C=n(),w=m.lazy(()=>r(()=>import(`./OptimizedSyntaxHighlighter-SkJc7ZMe.js`),__vite__mapDeps([8,9,3,4,10,2])));function T({children:e,className:t}){return(0,C.jsx)(`pre`,{dir:`ltr`,className:i(l,`rounded-lg`,t),children:(0,C.jsx)(`code`,{children:e})})}var E=m.memo(({content:e,className:t,allowHtml:n=!1})=>{let r=a(e=>e.theme.mode!==`light`),l=m.useMemo(()=>u(e),[e]),{math:h,html:g}=S({needsMath:x(l),needsHtml:n}),_=m.useMemo(()=>h?[f,h.remarkMath]:[f],[h]),v=m.useMemo(()=>{let e=[];return g&&e.push(g.rehypeRaw,[g.rehypeSanitize,g.richContentSanitizeSchema]),h&&e.push(h.rehypeKatex),e},[g,h]);return(0,C.jsx)(`div`,{dir:`auto`,className:i(`prose prose-sm max-w-none dark:prose-invert prose-gray`,`[&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden [&_.katex-display]:py-2`,`[&_.katex]:text-inherit`,t),children:(0,C.jsx)(p,{remarkPlugins:_,rehypePlugins:v,components:{code({className:e,children:t,node:n,...a}){let l=/language-([^\s]+)/.exec(e||``),u=String(t),f=u.replace(/\n$/,``),p=l?l[1]:null;return p||u.includes(`
3
- `)?(0,C.jsx)(o,{code:f,language:p,state:`complete`,children:(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsx)(m.Suspense,{fallback:(0,C.jsx)(T,{className:`!m-0 !rounded-none !border-none`,children:f}),children:(0,C.jsx)(w,{language:p||`text`,isDark:r,codeTheme:`night`,backgroundColor:r?d:c,borderRadius:0,customStyle:s,className:`!m-0 !rounded-none !border-none`,showLineNumbers:!0,children:f})})})}):(0,C.jsx)(`code`,{dir:`ltr`,className:i(`px-1.5 py-0.5 rounded-md bg-gray-100 dark:bg-dark-200 text-gray-800 dark:text-dark-800`,`font-mono text-[0.85em] border border-gray-200 dark:border-dark-300`,e),...a,children:t})},pre({children:e}){return(0,C.jsx)(C.Fragment,{children:e})},p({children:e,...t}){return(0,C.jsx)(`div`,{dir:`auto`,className:`mb-2.5 last:mb-0 leading-relaxed`,...t,children:e})},ul({children:e,...t}){return(0,C.jsx)(`ul`,{dir:`auto`,className:`list-disc list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},ol({children:e,...t}){return(0,C.jsx)(`ol`,{dir:`auto`,className:`list-decimal list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},li({children:e,...t}){return(0,C.jsx)(`li`,{dir:`auto`,className:`text-gray-700 dark:text-dark-700 leading-relaxed`,...t,children:e})},blockquote({children:e,...t}){return(0,C.jsx)(`blockquote`,{dir:`auto`,className:`border-s-2 border-primary-400 dark:border-primary-500 bg-primary-25 dark:bg-primary-950/30 ps-3 py-2 my-3 rounded-e-lg italic text-gray-700 dark:text-dark-700`,...t,children:e})},h1({children:e,...t}){return(0,C.jsx)(`h1`,{dir:`auto`,className:`text-xl font-bold mb-3 mt-5 first:mt-0 text-gray-900 dark:text-dark-800 border-b border-gray-200 dark:border-dark-300 pb-1.5`,...t,children:e})},h2({children:e,...t}){return(0,C.jsx)(`h2`,{dir:`auto`,className:`text-lg font-semibold mb-2 mt-5 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})},h3({children:e,...t}){return(0,C.jsx)(`h3`,{dir:`auto`,className:`text-base font-medium mb-2 mt-4 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})},table({children:e,node:t,...n}){return(0,C.jsx)(`div`,{className:i(`my-4 w-full overflow-x-auto rounded-xl border border-line bg-surface shadow-subtle`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`),tabIndex:0,children:(0,C.jsx)(`table`,{dir:`auto`,className:`w-full min-w-[42rem] border-separate border-spacing-0 text-start text-sm`,...n,children:e})})},thead({children:e,node:t,...n}){return(0,C.jsx)(`thead`,{className:`bg-surface-subtle`,...n,children:e})},tbody({children:e,node:t,...n}){return(0,C.jsx)(`tbody`,{...n,children:e})},tr({children:e,node:t,...n}){return(0,C.jsx)(`tr`,{className:`transition-colors hover:bg-black/[0.025] last:[&>td]:border-b-0 dark:hover:bg-white/[0.025]`,...n,children:e})},th({align:e,children:t,node:n,...r}){return(0,C.jsx)(`th`,{className:i(`border-b border-e border-line-strong px-3 py-2.5 align-bottom font-semibold text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...r,children:t})},td({align:e,children:t,node:n,...r}){return(0,C.jsx)(`td`,{className:i(`min-w-40 border-b border-e border-line px-3 py-2.5 align-top leading-relaxed text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...r,children:t})}},children:l})})});E.displayName=`RichMessageContent`;export{E as t};