libre-webui 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (588) hide show
  1. package/README.md +32 -22
  2. package/backend/dist/index.d.ts.map +1 -1
  3. package/backend/dist/index.js +33 -4
  4. package/backend/dist/index.js.map +1 -1
  5. package/backend/dist/middleware/auth.d.ts +7 -0
  6. package/backend/dist/middleware/auth.d.ts.map +1 -1
  7. package/backend/dist/middleware/auth.js +26 -0
  8. package/backend/dist/middleware/auth.js.map +1 -1
  9. package/backend/dist/middleware/index.d.ts +20 -0
  10. package/backend/dist/middleware/index.d.ts.map +1 -1
  11. package/backend/dist/middleware/index.js +105 -2
  12. package/backend/dist/middleware/index.js.map +1 -1
  13. package/backend/dist/models/personaModel.d.ts.map +1 -1
  14. package/backend/dist/models/personaModel.js +2 -0
  15. package/backend/dist/models/personaModel.js.map +1 -1
  16. package/backend/dist/observability/otel.d.ts +40 -0
  17. package/backend/dist/observability/otel.d.ts.map +1 -0
  18. package/backend/dist/observability/otel.js +337 -0
  19. package/backend/dist/observability/otel.js.map +1 -0
  20. package/backend/dist/observability/requestContext.d.ts +14 -0
  21. package/backend/dist/observability/requestContext.d.ts.map +1 -0
  22. package/backend/dist/observability/requestContext.js +21 -0
  23. package/backend/dist/observability/requestContext.js.map +1 -0
  24. package/backend/dist/persistence/chatGenerationTypes.d.ts +9 -0
  25. package/backend/dist/persistence/chatGenerationTypes.d.ts.map +1 -1
  26. package/backend/dist/persistence/extensionTypes.d.ts +13 -0
  27. package/backend/dist/persistence/extensionTypes.d.ts.map +1 -1
  28. package/backend/dist/persistence/extensionTypes.js.map +1 -1
  29. package/backend/dist/persistence/index.d.ts +1 -1
  30. package/backend/dist/persistence/index.d.ts.map +1 -1
  31. package/backend/dist/persistence/index.js.map +1 -1
  32. package/backend/dist/persistence/postgresAgentFoundationMigration.d.ts +9 -0
  33. package/backend/dist/persistence/postgresAgentFoundationMigration.d.ts.map +1 -0
  34. package/backend/dist/persistence/postgresAgentFoundationMigration.js +164 -0
  35. package/backend/dist/persistence/postgresAgentFoundationMigration.js.map +1 -0
  36. package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
  37. package/backend/dist/persistence/postgresExtensionRepositories.js +46 -2
  38. package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
  39. package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.d.ts +10 -0
  40. package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.d.ts.map +1 -0
  41. package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.js +148 -0
  42. package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.js.map +1 -0
  43. package/backend/dist/persistence/postgresMfaPushRecoveryMigration.d.ts +9 -0
  44. package/backend/dist/persistence/postgresMfaPushRecoveryMigration.d.ts.map +1 -0
  45. package/backend/dist/persistence/postgresMfaPushRecoveryMigration.js +107 -0
  46. package/backend/dist/persistence/postgresMfaPushRecoveryMigration.js.map +1 -0
  47. package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
  48. package/backend/dist/persistence/postgresMigrationRegistry.js +12 -0
  49. package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
  50. package/backend/dist/persistence/postgresNotesV2Migration.d.ts +4 -0
  51. package/backend/dist/persistence/postgresNotesV2Migration.d.ts.map +1 -0
  52. package/backend/dist/persistence/postgresNotesV2Migration.js +57 -0
  53. package/backend/dist/persistence/postgresNotesV2Migration.js.map +1 -0
  54. package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
  55. package/backend/dist/persistence/postgresResourceRepositories.js +1930 -133
  56. package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
  57. package/backend/dist/persistence/postgresSecurityRepositories.d.ts.map +1 -1
  58. package/backend/dist/persistence/postgresSecurityRepositories.js +150 -0
  59. package/backend/dist/persistence/postgresSecurityRepositories.js.map +1 -1
  60. package/backend/dist/persistence/postgresSkillFilesMigration.d.ts +9 -0
  61. package/backend/dist/persistence/postgresSkillFilesMigration.d.ts.map +1 -0
  62. package/backend/dist/persistence/postgresSkillFilesMigration.js +50 -0
  63. package/backend/dist/persistence/postgresSkillFilesMigration.js.map +1 -0
  64. package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts +10 -0
  65. package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts.map +1 -0
  66. package/backend/dist/persistence/postgresTeamCollaborationMigration.js +161 -0
  67. package/backend/dist/persistence/postgresTeamCollaborationMigration.js.map +1 -0
  68. package/backend/dist/persistence/resourceTypes.d.ts +600 -3
  69. package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
  70. package/backend/dist/persistence/resourceTypes.js.map +1 -1
  71. package/backend/dist/persistence/securityTypes.d.ts +59 -0
  72. package/backend/dist/persistence/securityTypes.d.ts.map +1 -1
  73. package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
  74. package/backend/dist/persistence/sqliteExtensionRepositories.js +26 -4
  75. package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
  76. package/backend/dist/persistence/sqliteMigrations.d.ts +10 -0
  77. package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
  78. package/backend/dist/persistence/sqliteMigrations.js +1492 -131
  79. package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
  80. package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
  81. package/backend/dist/persistence/sqliteResourceRepositories.js +1657 -134
  82. package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
  83. package/backend/dist/persistence/sqliteSecurityRepositories.d.ts.map +1 -1
  84. package/backend/dist/persistence/sqliteSecurityRepositories.js +134 -0
  85. package/backend/dist/persistence/sqliteSecurityRepositories.js.map +1 -1
  86. package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
  87. package/backend/dist/persistence/sqliteToPostgresMigration.js +302 -3
  88. package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
  89. package/backend/dist/platform/jobs/domainJobContracts.d.ts +10 -0
  90. package/backend/dist/platform/jobs/domainJobContracts.d.ts.map +1 -1
  91. package/backend/dist/platform/jobs/domainJobContracts.js +10 -0
  92. package/backend/dist/platform/jobs/domainJobContracts.js.map +1 -1
  93. package/backend/dist/platform/jobs/domainJobHandlers.d.ts.map +1 -1
  94. package/backend/dist/platform/jobs/domainJobHandlers.js +374 -4
  95. package/backend/dist/platform/jobs/domainJobHandlers.js.map +1 -1
  96. package/backend/dist/platform/jobs/embeddedDurableJobWorker.d.ts.map +1 -1
  97. package/backend/dist/platform/jobs/embeddedDurableJobWorker.js +4 -2
  98. package/backend/dist/platform/jobs/embeddedDurableJobWorker.js.map +1 -1
  99. package/backend/dist/platform/jobs/postgresDurableJobWorker.d.ts.map +1 -1
  100. package/backend/dist/platform/jobs/postgresDurableJobWorker.js +4 -2
  101. package/backend/dist/platform/jobs/postgresDurableJobWorker.js.map +1 -1
  102. package/backend/dist/platform/storage/pgVectorStore.d.ts +2 -1
  103. package/backend/dist/platform/storage/pgVectorStore.d.ts.map +1 -1
  104. package/backend/dist/platform/storage/pgVectorStore.js +51 -0
  105. package/backend/dist/platform/storage/pgVectorStore.js.map +1 -1
  106. package/backend/dist/platform/storage/platformDomainRepositories.d.ts +8 -2
  107. package/backend/dist/platform/storage/platformDomainRepositories.d.ts.map +1 -1
  108. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.d.ts.map +1 -1
  109. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js +25 -4
  110. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js.map +1 -1
  111. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts +2 -1
  112. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts.map +1 -1
  113. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js +35 -0
  114. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js.map +1 -1
  115. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.d.ts.map +1 -1
  116. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js +26 -3
  117. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js.map +1 -1
  118. package/backend/dist/platform/storage/vectorStore.d.ts +14 -0
  119. package/backend/dist/platform/storage/vectorStore.d.ts.map +1 -1
  120. package/backend/dist/platform/storage/vectorStore.js.map +1 -1
  121. package/backend/dist/routes/access.d.ts.map +1 -1
  122. package/backend/dist/routes/access.js +84 -3
  123. package/backend/dist/routes/access.js.map +1 -1
  124. package/backend/dist/routes/auth.d.ts.map +1 -1
  125. package/backend/dist/routes/auth.js +419 -1
  126. package/backend/dist/routes/auth.js.map +1 -1
  127. package/backend/dist/routes/calendar.d.ts.map +1 -1
  128. package/backend/dist/routes/calendar.js +125 -22
  129. package/backend/dist/routes/calendar.js.map +1 -1
  130. package/backend/dist/routes/channels.d.ts +3 -0
  131. package/backend/dist/routes/channels.d.ts.map +1 -0
  132. package/backend/dist/routes/channels.js +447 -0
  133. package/backend/dist/routes/channels.js.map +1 -0
  134. package/backend/dist/routes/chat.d.ts.map +1 -1
  135. package/backend/dist/routes/chat.js +195 -7
  136. package/backend/dist/routes/chat.js.map +1 -1
  137. package/backend/dist/routes/costs.d.ts +3 -0
  138. package/backend/dist/routes/costs.d.ts.map +1 -0
  139. package/backend/dist/routes/costs.js +191 -0
  140. package/backend/dist/routes/costs.js.map +1 -0
  141. package/backend/dist/routes/documents.d.ts.map +1 -1
  142. package/backend/dist/routes/documents.js +68 -21
  143. package/backend/dist/routes/documents.js.map +1 -1
  144. package/backend/dist/routes/evaluations.d.ts +3 -0
  145. package/backend/dist/routes/evaluations.d.ts.map +1 -0
  146. package/backend/dist/routes/evaluations.js +352 -0
  147. package/backend/dist/routes/evaluations.js.map +1 -0
  148. package/backend/dist/routes/imageGen.d.ts.map +1 -1
  149. package/backend/dist/routes/imageGen.js +2 -1
  150. package/backend/dist/routes/imageGen.js.map +1 -1
  151. package/backend/dist/routes/media.d.ts.map +1 -1
  152. package/backend/dist/routes/media.js +228 -7
  153. package/backend/dist/routes/media.js.map +1 -1
  154. package/backend/dist/routes/notes.d.ts.map +1 -1
  155. package/backend/dist/routes/notes.js +149 -36
  156. package/backend/dist/routes/notes.js.map +1 -1
  157. package/backend/dist/routes/notifications.d.ts +3 -0
  158. package/backend/dist/routes/notifications.d.ts.map +1 -0
  159. package/backend/dist/routes/notifications.js +213 -0
  160. package/backend/dist/routes/notifications.js.map +1 -0
  161. package/backend/dist/routes/openaiCompat.d.ts +3 -0
  162. package/backend/dist/routes/openaiCompat.d.ts.map +1 -0
  163. package/backend/dist/routes/openaiCompat.js +314 -0
  164. package/backend/dist/routes/openaiCompat.js.map +1 -0
  165. package/backend/dist/routes/personas.js +1 -1
  166. package/backend/dist/routes/personas.js.map +1 -1
  167. package/backend/dist/routes/prompts.d.ts +3 -0
  168. package/backend/dist/routes/prompts.d.ts.map +1 -0
  169. package/backend/dist/routes/prompts.js +173 -0
  170. package/backend/dist/routes/prompts.js.map +1 -0
  171. package/backend/dist/routes/push.d.ts +3 -0
  172. package/backend/dist/routes/push.d.ts.map +1 -0
  173. package/backend/dist/routes/push.js +105 -0
  174. package/backend/dist/routes/push.js.map +1 -0
  175. package/backend/dist/routes/recovery.d.ts +3 -0
  176. package/backend/dist/routes/recovery.d.ts.map +1 -0
  177. package/backend/dist/routes/recovery.js +83 -0
  178. package/backend/dist/routes/recovery.js.map +1 -0
  179. package/backend/dist/routes/search.d.ts.map +1 -1
  180. package/backend/dist/routes/search.js +29 -1
  181. package/backend/dist/routes/search.js.map +1 -1
  182. package/backend/dist/routes/skills.d.ts +3 -0
  183. package/backend/dist/routes/skills.d.ts.map +1 -0
  184. package/backend/dist/routes/skills.js +246 -0
  185. package/backend/dist/routes/skills.js.map +1 -0
  186. package/backend/dist/routes/stt.d.ts.map +1 -1
  187. package/backend/dist/routes/stt.js +2 -1
  188. package/backend/dist/routes/stt.js.map +1 -1
  189. package/backend/dist/routes/tools.d.ts +3 -0
  190. package/backend/dist/routes/tools.d.ts.map +1 -0
  191. package/backend/dist/routes/tools.js +359 -0
  192. package/backend/dist/routes/tools.js.map +1 -0
  193. package/backend/dist/routes/tts.d.ts.map +1 -1
  194. package/backend/dist/routes/tts.js +63 -8
  195. package/backend/dist/routes/tts.js.map +1 -1
  196. package/backend/dist/routes/users.d.ts.map +1 -1
  197. package/backend/dist/routes/users.js +35 -0
  198. package/backend/dist/routes/users.js.map +1 -1
  199. package/backend/dist/routes/voiceAccess.d.ts +3 -0
  200. package/backend/dist/routes/voiceAccess.d.ts.map +1 -0
  201. package/backend/dist/routes/voiceAccess.js +102 -0
  202. package/backend/dist/routes/voiceAccess.js.map +1 -0
  203. package/backend/dist/services/apiTokenService.d.ts +2 -2
  204. package/backend/dist/services/apiTokenService.d.ts.map +1 -1
  205. package/backend/dist/services/apiTokenService.js +7 -0
  206. package/backend/dist/services/apiTokenService.js.map +1 -1
  207. package/backend/dist/services/authService.d.ts +6 -0
  208. package/backend/dist/services/authService.d.ts.map +1 -1
  209. package/backend/dist/services/authService.js +9 -0
  210. package/backend/dist/services/authService.js.map +1 -1
  211. package/backend/dist/services/authorizationService.d.ts +8 -4
  212. package/backend/dist/services/authorizationService.d.ts.map +1 -1
  213. package/backend/dist/services/authorizationService.js +31 -1
  214. package/backend/dist/services/authorizationService.js.map +1 -1
  215. package/backend/dist/services/automationSchedulerService.d.ts.map +1 -1
  216. package/backend/dist/services/automationSchedulerService.js +40 -3
  217. package/backend/dist/services/automationSchedulerService.js.map +1 -1
  218. package/backend/dist/services/automationService.d.ts +4 -1
  219. package/backend/dist/services/automationService.d.ts.map +1 -1
  220. package/backend/dist/services/automationService.js +25 -2
  221. package/backend/dist/services/automationService.js.map +1 -1
  222. package/backend/dist/services/builtinToolsService.d.ts +20 -0
  223. package/backend/dist/services/builtinToolsService.d.ts.map +1 -0
  224. package/backend/dist/services/builtinToolsService.js +661 -0
  225. package/backend/dist/services/builtinToolsService.js.map +1 -0
  226. package/backend/dist/services/calendarService.d.ts +74 -0
  227. package/backend/dist/services/calendarService.d.ts.map +1 -0
  228. package/backend/dist/services/calendarService.js +339 -0
  229. package/backend/dist/services/calendarService.js.map +1 -0
  230. package/backend/dist/services/channelService.d.ts +195 -0
  231. package/backend/dist/services/channelService.d.ts.map +1 -0
  232. package/backend/dist/services/channelService.js +1057 -0
  233. package/backend/dist/services/channelService.js.map +1 -0
  234. package/backend/dist/services/chatRequestService.d.ts.map +1 -1
  235. package/backend/dist/services/chatRequestService.js +29 -1
  236. package/backend/dist/services/chatRequestService.js.map +1 -1
  237. package/backend/dist/services/chatService.d.ts +61 -1
  238. package/backend/dist/services/chatService.d.ts.map +1 -1
  239. package/backend/dist/services/chatService.js +218 -1
  240. package/backend/dist/services/chatService.js.map +1 -1
  241. package/backend/dist/services/chatToolRuntimeService.d.ts +55 -0
  242. package/backend/dist/services/chatToolRuntimeService.d.ts.map +1 -0
  243. package/backend/dist/services/chatToolRuntimeService.js +389 -0
  244. package/backend/dist/services/chatToolRuntimeService.js.map +1 -0
  245. package/backend/dist/services/costGovernanceService.d.ts +102 -0
  246. package/backend/dist/services/costGovernanceService.d.ts.map +1 -0
  247. package/backend/dist/services/costGovernanceService.js +463 -0
  248. package/backend/dist/services/costGovernanceService.js.map +1 -0
  249. package/backend/dist/services/dataArchiveService.d.ts +6 -0
  250. package/backend/dist/services/dataArchiveService.d.ts.map +1 -1
  251. package/backend/dist/services/dataArchiveService.js +26 -4
  252. package/backend/dist/services/dataArchiveService.js.map +1 -1
  253. package/backend/dist/services/documentMediaExtractionService.d.ts +40 -0
  254. package/backend/dist/services/documentMediaExtractionService.d.ts.map +1 -0
  255. package/backend/dist/services/documentMediaExtractionService.js +157 -0
  256. package/backend/dist/services/documentMediaExtractionService.js.map +1 -0
  257. package/backend/dist/services/documentService.d.ts +64 -1
  258. package/backend/dist/services/documentService.d.ts.map +1 -1
  259. package/backend/dist/services/documentService.js +342 -83
  260. package/backend/dist/services/documentService.js.map +1 -1
  261. package/backend/dist/services/durableChatGenerationService.d.ts +9 -0
  262. package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
  263. package/backend/dist/services/durableChatGenerationService.js +152 -11
  264. package/backend/dist/services/durableChatGenerationService.js.map +1 -1
  265. package/backend/dist/services/encryptionService.d.ts +6 -0
  266. package/backend/dist/services/encryptionService.d.ts.map +1 -1
  267. package/backend/dist/services/encryptionService.js +12 -0
  268. package/backend/dist/services/encryptionService.js.map +1 -1
  269. package/backend/dist/services/evaluationService.d.ts +111 -0
  270. package/backend/dist/services/evaluationService.d.ts.map +1 -0
  271. package/backend/dist/services/evaluationService.js +403 -0
  272. package/backend/dist/services/evaluationService.js.map +1 -0
  273. package/backend/dist/services/galleryService.d.ts +6 -0
  274. package/backend/dist/services/galleryService.d.ts.map +1 -1
  275. package/backend/dist/services/galleryService.js +26 -0
  276. package/backend/dist/services/galleryService.js.map +1 -1
  277. package/backend/dist/services/mcpClientService.d.ts +29 -0
  278. package/backend/dist/services/mcpClientService.d.ts.map +1 -0
  279. package/backend/dist/services/mcpClientService.js +189 -0
  280. package/backend/dist/services/mcpClientService.js.map +1 -0
  281. package/backend/dist/services/mfaService.d.ts +64 -0
  282. package/backend/dist/services/mfaService.d.ts.map +1 -0
  283. package/backend/dist/services/mfaService.js +263 -0
  284. package/backend/dist/services/mfaService.js.map +1 -0
  285. package/backend/dist/services/noteService.d.ts +71 -0
  286. package/backend/dist/services/noteService.d.ts.map +1 -0
  287. package/backend/dist/services/noteService.js +397 -0
  288. package/backend/dist/services/noteService.js.map +1 -0
  289. package/backend/dist/services/notificationService.d.ts +60 -0
  290. package/backend/dist/services/notificationService.d.ts.map +1 -0
  291. package/backend/dist/services/notificationService.js +340 -0
  292. package/backend/dist/services/notificationService.js.map +1 -0
  293. package/backend/dist/services/openApiToolService.d.ts +38 -0
  294. package/backend/dist/services/openApiToolService.d.ts.map +1 -0
  295. package/backend/dist/services/openApiToolService.js +254 -0
  296. package/backend/dist/services/openApiToolService.js.map +1 -0
  297. package/backend/dist/services/personaService.d.ts +18 -2
  298. package/backend/dist/services/personaService.d.ts.map +1 -1
  299. package/backend/dist/services/personaService.js +113 -4
  300. package/backend/dist/services/personaService.js.map +1 -1
  301. package/backend/dist/services/pluginImageGenerationService.d.ts +19 -0
  302. package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -1
  303. package/backend/dist/services/pluginImageGenerationService.js +121 -0
  304. package/backend/dist/services/pluginImageGenerationService.js.map +1 -1
  305. package/backend/dist/services/pluginService.d.ts +7 -0
  306. package/backend/dist/services/pluginService.d.ts.map +1 -1
  307. package/backend/dist/services/pluginService.js +8 -2
  308. package/backend/dist/services/pluginService.js.map +1 -1
  309. package/backend/dist/services/preferencesService.d.ts +1 -1
  310. package/backend/dist/services/preferencesService.d.ts.map +1 -1
  311. package/backend/dist/services/preferencesService.js +1 -0
  312. package/backend/dist/services/preferencesService.js.map +1 -1
  313. package/backend/dist/services/promptService.d.ts +74 -0
  314. package/backend/dist/services/promptService.d.ts.map +1 -0
  315. package/backend/dist/services/promptService.js +513 -0
  316. package/backend/dist/services/promptService.js.map +1 -0
  317. package/backend/dist/services/recoveryDrillService.d.ts +57 -0
  318. package/backend/dist/services/recoveryDrillService.d.ts.map +1 -0
  319. package/backend/dist/services/recoveryDrillService.js +363 -0
  320. package/backend/dist/services/recoveryDrillService.js.map +1 -0
  321. package/backend/dist/services/resourceGrantService.d.ts.map +1 -1
  322. package/backend/dist/services/resourceGrantService.js +62 -17
  323. package/backend/dist/services/resourceGrantService.js.map +1 -1
  324. package/backend/dist/services/searchService.d.ts +29 -0
  325. package/backend/dist/services/searchService.d.ts.map +1 -0
  326. package/backend/dist/services/searchService.js +0 -0
  327. package/backend/dist/services/searchService.js.map +1 -0
  328. package/backend/dist/services/securityAuditService.d.ts.map +1 -1
  329. package/backend/dist/services/securityAuditService.js +2 -1
  330. package/backend/dist/services/securityAuditService.js.map +1 -1
  331. package/backend/dist/services/sharedResourceAccess.d.ts +25 -0
  332. package/backend/dist/services/sharedResourceAccess.d.ts.map +1 -0
  333. package/backend/dist/services/sharedResourceAccess.js +59 -0
  334. package/backend/dist/services/sharedResourceAccess.js.map +1 -0
  335. package/backend/dist/services/skillService.d.ts +137 -0
  336. package/backend/dist/services/skillService.d.ts.map +1 -0
  337. package/backend/dist/services/skillService.js +852 -0
  338. package/backend/dist/services/skillService.js.map +1 -0
  339. package/backend/dist/services/toolAccessService.d.ts +9 -0
  340. package/backend/dist/services/toolAccessService.d.ts.map +1 -0
  341. package/backend/dist/services/toolAccessService.js +60 -0
  342. package/backend/dist/services/toolAccessService.js.map +1 -0
  343. package/backend/dist/services/toolApprovalService.d.ts +34 -0
  344. package/backend/dist/services/toolApprovalService.d.ts.map +1 -0
  345. package/backend/dist/services/toolApprovalService.js +188 -0
  346. package/backend/dist/services/toolApprovalService.js.map +1 -0
  347. package/backend/dist/services/toolGatewayService.d.ts +53 -0
  348. package/backend/dist/services/toolGatewayService.d.ts.map +1 -0
  349. package/backend/dist/services/toolGatewayService.js +249 -0
  350. package/backend/dist/services/toolGatewayService.js.map +1 -0
  351. package/backend/dist/services/toolServerService.d.ts +57 -0
  352. package/backend/dist/services/toolServerService.d.ts.map +1 -0
  353. package/backend/dist/services/toolServerService.js +521 -0
  354. package/backend/dist/services/toolServerService.js.map +1 -0
  355. package/backend/dist/services/voiceAccessService.d.ts +10 -0
  356. package/backend/dist/services/voiceAccessService.d.ts.map +1 -0
  357. package/backend/dist/services/voiceAccessService.js +74 -0
  358. package/backend/dist/services/voiceAccessService.js.map +1 -0
  359. package/backend/dist/services/voiceProfileService.d.ts +20 -0
  360. package/backend/dist/services/voiceProfileService.d.ts.map +1 -1
  361. package/backend/dist/services/voiceProfileService.js +60 -0
  362. package/backend/dist/services/voiceProfileService.js.map +1 -1
  363. package/backend/dist/services/webPushService.d.ts +71 -0
  364. package/backend/dist/services/webPushService.d.ts.map +1 -0
  365. package/backend/dist/services/webPushService.js +328 -0
  366. package/backend/dist/services/webPushService.js.map +1 -0
  367. package/backend/dist/services/webauthnService.d.ts +58 -0
  368. package/backend/dist/services/webauthnService.d.ts.map +1 -0
  369. package/backend/dist/services/webauthnService.js +300 -0
  370. package/backend/dist/services/webauthnService.js.map +1 -0
  371. package/backend/dist/storage.d.ts +28 -1
  372. package/backend/dist/storage.d.ts.map +1 -1
  373. package/backend/dist/storage.js +100 -1
  374. package/backend/dist/storage.js.map +1 -1
  375. package/backend/dist/storageMappers.d.ts +2 -2
  376. package/backend/dist/storageMappers.d.ts.map +1 -1
  377. package/backend/dist/storageMappers.js.map +1 -1
  378. package/backend/dist/types/index.d.ts +199 -3
  379. package/backend/dist/types/index.d.ts.map +1 -1
  380. package/backend/dist/types/index.js.map +1 -1
  381. package/backend/dist/types/tools.d.ts +137 -0
  382. package/backend/dist/types/tools.d.ts.map +1 -0
  383. package/backend/dist/types/tools.js +25 -0
  384. package/backend/dist/types/tools.js.map +1 -0
  385. package/backend/dist/utils/chatDocumentContext.d.ts +26 -1
  386. package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -1
  387. package/backend/dist/utils/chatDocumentContext.js +87 -18
  388. package/backend/dist/utils/chatDocumentContext.js.map +1 -1
  389. package/backend/dist/utils/documentExtraction.d.ts +97 -0
  390. package/backend/dist/utils/documentExtraction.d.ts.map +1 -0
  391. package/backend/dist/utils/documentExtraction.js +651 -0
  392. package/backend/dist/utils/documentExtraction.js.map +1 -0
  393. package/backend/dist/utils/hybridRetrieval.d.ts +34 -0
  394. package/backend/dist/utils/hybridRetrieval.d.ts.map +1 -0
  395. package/backend/dist/utils/hybridRetrieval.js +119 -0
  396. package/backend/dist/utils/hybridRetrieval.js.map +1 -0
  397. package/backend/dist/utils/icsCalendar.d.ts +27 -0
  398. package/backend/dist/utils/icsCalendar.d.ts.map +1 -0
  399. package/backend/dist/utils/icsCalendar.js +313 -0
  400. package/backend/dist/utils/icsCalendar.js.map +1 -0
  401. package/backend/dist/utils/imageEditUpload.d.ts +29 -0
  402. package/backend/dist/utils/imageEditUpload.d.ts.map +1 -0
  403. package/backend/dist/utils/imageEditUpload.js +82 -0
  404. package/backend/dist/utils/imageEditUpload.js.map +1 -0
  405. package/backend/dist/utils/logRedaction.d.ts +2 -0
  406. package/backend/dist/utils/logRedaction.d.ts.map +1 -0
  407. package/backend/dist/utils/logRedaction.js +66 -0
  408. package/backend/dist/utils/logRedaction.js.map +1 -0
  409. package/backend/dist/utils/logger.d.ts +3 -0
  410. package/backend/dist/utils/logger.d.ts.map +1 -1
  411. package/backend/dist/utils/logger.js +63 -20
  412. package/backend/dist/utils/logger.js.map +1 -1
  413. package/backend/dist/utils/pluginChatAdapter.d.ts +5 -1
  414. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
  415. package/backend/dist/utils/pluginChatAdapter.js +83 -0
  416. package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
  417. package/backend/dist/utils/pluginDefinitionTrust.js +1 -1
  418. package/backend/dist/utils/resourceLimits.d.ts +61 -2
  419. package/backend/dist/utils/resourceLimits.d.ts.map +1 -1
  420. package/backend/dist/utils/resourceLimits.js +59 -0
  421. package/backend/dist/utils/resourceLimits.js.map +1 -1
  422. package/backend/dist/utils/toolEgress.d.ts +23 -0
  423. package/backend/dist/utils/toolEgress.d.ts.map +1 -0
  424. package/backend/dist/utils/toolEgress.js +169 -0
  425. package/backend/dist/utils/toolEgress.js.map +1 -0
  426. package/backend/dist/utils/totp.d.ts +19 -0
  427. package/backend/dist/utils/totp.d.ts.map +1 -0
  428. package/backend/dist/utils/totp.js +117 -0
  429. package/backend/dist/utils/totp.js.map +1 -0
  430. package/backend/dist/utils/webauthn.d.ts +43 -0
  431. package/backend/dist/utils/webauthn.d.ts.map +1 -0
  432. package/backend/dist/utils/webauthn.js +294 -0
  433. package/backend/dist/utils/webauthn.js.map +1 -0
  434. package/backend/dist/utils/websocketMessages.d.ts +6 -0
  435. package/backend/dist/utils/websocketMessages.d.ts.map +1 -1
  436. package/backend/dist/utils/websocketMessages.js +8 -0
  437. package/backend/dist/utils/websocketMessages.js.map +1 -1
  438. package/backend/dist/utils/zipArchive.d.ts +32 -0
  439. package/backend/dist/utils/zipArchive.d.ts.map +1 -0
  440. package/backend/dist/utils/zipArchive.js +171 -0
  441. package/backend/dist/utils/zipArchive.js.map +1 -0
  442. package/backend/dist/websocketServer.d.ts.map +1 -1
  443. package/backend/dist/websocketServer.js +142 -35
  444. package/backend/dist/websocketServer.js.map +1 -1
  445. package/backend/package.json +1 -1
  446. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  447. package/frontend/dist/assets/index-DBAf_VaS.js +47 -0
  448. package/frontend/dist/assets/index-kn_Axjts.css +1 -0
  449. package/frontend/dist/fonts/jetbrains-mono-latin-400-normal.woff2 +0 -0
  450. package/frontend/dist/fonts/jetbrains-mono-latin-700-normal.woff2 +0 -0
  451. package/frontend/dist/fonts/jetbrains-mono.css +24 -0
  452. package/frontend/dist/index.html +27 -20
  453. package/frontend/dist/js/ArtifactContainer-C9zNtCay.js +1 -0
  454. package/frontend/dist/js/{ArtifactDemoPage-BeNs3gHp.js → ArtifactDemoPage-C-EBFBCt.js} +1 -1
  455. package/frontend/dist/js/ArtifactSandboxFrame-CTA1j_d1.js +111 -0
  456. package/frontend/dist/js/ArtifactSlideOutPanel-BOENbOiv.js +1 -0
  457. package/frontend/dist/js/AutomationsPage-C58MQ4te.js +1 -0
  458. package/frontend/dist/js/{Button-BPf_pOxH.js → Button-C0r3J9G_.js} +1 -1
  459. package/frontend/dist/js/CalendarPage-BcdAZ292.js +1 -0
  460. package/frontend/dist/js/ChannelsPage-DPr9Yajs.js +1 -0
  461. package/frontend/dist/js/ChatPage-DsbB748s.js +14 -0
  462. package/frontend/dist/js/EvaluationsPage-FWIJu2fI.js +2 -0
  463. package/frontend/dist/js/FirstTimeSetup-Cy-w6xko.js +1 -0
  464. package/frontend/dist/js/GalleryPage-DDAtxM-x.js +1 -0
  465. package/frontend/dist/js/HomePage-DLKwmE7n.js +1 -0
  466. package/frontend/dist/js/LibreClawPage-vKOj-9w9.js +1 -0
  467. package/frontend/dist/js/{ModelManagerModals-DcLGYN3l.js → ModelManagerModals-BY5TK38_.js} +1 -1
  468. package/frontend/dist/js/ModelSelector-CoCS6MZ9.js +1 -0
  469. package/frontend/dist/js/NotesPage-BElIpXgA.js +3 -0
  470. package/frontend/dist/js/OptimizedSyntaxHighlighter-xgyE3dRA.js +1 -0
  471. package/frontend/dist/js/PersonasPage-P40jVbfU.js +13 -0
  472. package/frontend/dist/js/PluginUsagePage-CKUEPCJN.js +1 -0
  473. package/frontend/dist/js/RichMessageContent-Bm2WaEGi.js +3 -0
  474. package/frontend/dist/js/SettingsModal-DxSGzx9A.js +19 -0
  475. package/frontend/dist/js/{SettingsToggle-woG_WebF.js → SettingsToggle-BIVyfGjl.js} +1 -1
  476. package/frontend/dist/js/SystemPage-BT07dTMT.js +1 -0
  477. package/frontend/dist/js/UserManagementPage-B9Vz5cm3.js +1 -0
  478. package/frontend/dist/js/WorkPage-qoN_e_jK.js +6 -0
  479. package/frontend/dist/js/api-D7Ff5M2Q.js +14 -0
  480. package/frontend/dist/js/appStore-DmV5wqDz.js +2 -0
  481. package/frontend/dist/js/ar-YHHTVP8f.js +2 -0
  482. package/frontend/dist/js/artifactHtml-DDmfpcB0.js +41 -0
  483. package/frontend/dist/js/{authStore-DbMdvNgJ.js → authStore-BYW8-kP6.js} +3 -3
  484. package/frontend/dist/js/{babel-BsYoxD-7.js → babel-DSqqk5kt.js} +1 -1
  485. package/frontend/dist/js/bn-C8VTxBVl.js +2 -0
  486. package/frontend/dist/js/chatStore-D-NTlArO.js +3 -0
  487. package/frontend/dist/js/{config-DSOYQ9a3.js → config-BqZ5304Q.js} +1 -1
  488. package/frontend/dist/js/cs-CCngB5fC.js +2 -0
  489. package/frontend/dist/js/da-CM2PP2ma.js +2 -0
  490. package/frontend/dist/js/de-BqVkD-dw.js +2 -0
  491. package/frontend/dist/js/es-BtWsWBjZ.js +2 -0
  492. package/frontend/dist/js/{estree-BcnBcOAx.js → estree-DPkpBuOU.js} +3 -3
  493. package/frontend/dist/js/evaluationsApi-Dnf2dTd-.js +1 -0
  494. package/frontend/dist/js/fr-C68w9abT.js +2 -0
  495. package/frontend/dist/js/hi-DtBlcyXZ.js +2 -0
  496. package/frontend/dist/js/{html-DkY55Jys.js → html-BpGUXG8E.js} +2 -2
  497. package/frontend/dist/js/id-BWzIu8tn.js +2 -0
  498. package/frontend/dist/js/is-yeFwu4dJ.js +2 -0
  499. package/frontend/dist/js/it-AxEMG8Jg.js +2 -0
  500. package/frontend/dist/js/ja-B-VyokB8.js +2 -0
  501. package/frontend/dist/js/ko-CvwzYr9k.js +2 -0
  502. package/frontend/dist/js/{markdown-IZSI9DXw.js → markdown-DCBRWJSK.js} +3 -3
  503. package/frontend/dist/js/markdown-core-BK7WVOb7.js +32 -0
  504. package/frontend/dist/js/{markdown-math-DK846gXU.js → markdown-math-e1ByS3KY.js} +5 -5
  505. package/frontend/dist/js/messageCodeStyles-BQwf7sSz.js +2 -0
  506. package/frontend/dist/js/ms-BhEwb4b7.js +2 -0
  507. package/frontend/dist/js/nl-Dq-QRx1L.js +2 -0
  508. package/frontend/dist/js/pl-BNEy8mQm.js +2 -0
  509. package/frontend/dist/js/{postcss-BJ0okz7n.js → postcss-Bg15EcFE.js} +1 -1
  510. package/frontend/dist/js/pt-_3Jl3FdY.js +2 -0
  511. package/frontend/dist/js/{react-vendor-C5yShNlM.js → react-vendor-BG_HPV6X.js} +1 -1
  512. package/frontend/dist/js/router-vendor-CbexJIsv.js +1 -0
  513. package/frontend/dist/js/ru-IhQiJ8ta.js +2 -0
  514. package/frontend/dist/js/{standalone-Csw3jfJ_.js → standalone-BFrK0R2A.js} +3 -3
  515. package/frontend/dist/js/sv-DWunXUNz.js +2 -0
  516. package/frontend/dist/js/{syntax-highlight-3EEX6CGL.js → syntax-highlight-P2zo9o06.js} +4 -4
  517. package/frontend/dist/js/th-DVnW2yyh.js +2 -0
  518. package/frontend/dist/js/tr-Do8CFmhR.js +2 -0
  519. package/frontend/dist/js/{typescript-CnF4UVx7.js → typescript-DYVyvmm_.js} +1 -1
  520. package/frontend/dist/js/ui-db9meqAB.js +2 -0
  521. package/frontend/dist/js/ui-vendor-C0DZ8-Cm.js +177 -0
  522. package/frontend/dist/js/uk-BNPKIZga.js +2 -0
  523. package/frontend/dist/js/{useTranslation-Bho4HCyg.js → useTranslation-5b5UhAc9.js} +1 -1
  524. package/frontend/dist/js/{utils-D9W1Lnkn.js → utils-BGrdX9ie.js} +1 -1
  525. package/frontend/dist/js/{utils-vendor-DWh39_3x.js → utils-vendor-9bQ62WeD.js} +1 -1
  526. package/frontend/dist/js/vi-CZMFo9je.js +2 -0
  527. package/frontend/dist/js/{workApi-C3uy9EDT.js → workApi-CcprMH_1.js} +3 -3
  528. package/frontend/dist/js/{yaml-DzT5hBSH.js → yaml-DUeWcOOH.js} +2 -2
  529. package/frontend/dist/js/zh-Pg0881v0.js +2 -0
  530. package/frontend/dist/manifest.webmanifest +32 -0
  531. package/frontend/dist/sw.js +125 -0
  532. package/package.json +2 -2
  533. package/plugins/openai.json +52 -9
  534. package/frontend/dist/assets/index-6o-Hc2wS.js +0 -41
  535. package/frontend/dist/assets/index-D-pM957b.css +0 -1
  536. package/frontend/dist/js/ArtifactContainer-CpUi6ekF.js +0 -1
  537. package/frontend/dist/js/ArtifactSandboxFrame-qsj_Y3LV.js +0 -151
  538. package/frontend/dist/js/ArtifactSlideOutPanel-CSFRluWA.js +0 -1
  539. package/frontend/dist/js/AutomationsPage-KUeWoZNv.js +0 -1
  540. package/frontend/dist/js/CalendarPage-D9I972w8.js +0 -1
  541. package/frontend/dist/js/ChatPage-CmBx4oAL.js +0 -16
  542. package/frontend/dist/js/FirstTimeSetup-Df0YJni3.js +0 -1
  543. package/frontend/dist/js/GalleryPage-bLCrdJN_.js +0 -1
  544. package/frontend/dist/js/HomePage-Uc6PEg-U.js +0 -1
  545. package/frontend/dist/js/LibreClawPage-CG63DHg1.js +0 -1
  546. package/frontend/dist/js/ModelSelector-yxJC64rM.js +0 -1
  547. package/frontend/dist/js/ModelsPage-1R_TxgmJ.js +0 -2
  548. package/frontend/dist/js/NotesPage-L65j5HoW.js +0 -1
  549. package/frontend/dist/js/OptimizedSyntaxHighlighter-Dz7D1LPB.js +0 -1
  550. package/frontend/dist/js/PersonasPage-CKeBpHIH.js +0 -13
  551. package/frontend/dist/js/PluginUsagePage-BX1SKMbW.js +0 -1
  552. package/frontend/dist/js/RichMessageContent-DiySVYGB.js +0 -3
  553. package/frontend/dist/js/SettingsModal-68SG1uZ2.js +0 -1
  554. package/frontend/dist/js/SystemPage-CytpZiQV.js +0 -1
  555. package/frontend/dist/js/UserManagementPage-BzJBvZiS.js +0 -1
  556. package/frontend/dist/js/WorkPage-C8gr0QJe.js +0 -6
  557. package/frontend/dist/js/api-BDtqBtqw.js +0 -14
  558. package/frontend/dist/js/appStore-0JnCUlEq.js +0 -2
  559. package/frontend/dist/js/ar-CSpi37Gr.js +0 -2
  560. package/frontend/dist/js/bn-CyH1BeDD.js +0 -2
  561. package/frontend/dist/js/chatStore-CHQ2uINS.js +0 -3
  562. package/frontend/dist/js/cs-Cv2NfRK5.js +0 -2
  563. package/frontend/dist/js/da-D6D6IvPK.js +0 -2
  564. package/frontend/dist/js/de-BNoJJTrT.js +0 -2
  565. package/frontend/dist/js/es-kzo9C7q_.js +0 -2
  566. package/frontend/dist/js/fr-CjHYvJRp.js +0 -2
  567. package/frontend/dist/js/hi-BU98AdCQ.js +0 -2
  568. package/frontend/dist/js/id-CpdedejX.js +0 -2
  569. package/frontend/dist/js/is-Cp5dDWBH.js +0 -2
  570. package/frontend/dist/js/it-CuH_cK4U.js +0 -2
  571. package/frontend/dist/js/ja-BWXXXiHn.js +0 -2
  572. package/frontend/dist/js/ko-DQgv2M1t.js +0 -2
  573. package/frontend/dist/js/markdown-core-BmPPZiuD.js +0 -31
  574. package/frontend/dist/js/messageCodeStyles-BFNR9Wv6.js +0 -2
  575. package/frontend/dist/js/ms-DCcRoIcX.js +0 -2
  576. package/frontend/dist/js/nl-CbKR1_EU.js +0 -2
  577. package/frontend/dist/js/pl-CRyJZccn.js +0 -2
  578. package/frontend/dist/js/pt-BXYmHFGH.js +0 -2
  579. package/frontend/dist/js/router-vendor-DGFGM3EP.js +0 -1
  580. package/frontend/dist/js/ru-M9SyZG4b.js +0 -2
  581. package/frontend/dist/js/sv-DJ486LTU.js +0 -2
  582. package/frontend/dist/js/th-Ch7gKtZv.js +0 -2
  583. package/frontend/dist/js/tr-ClehWhSC.js +0 -2
  584. package/frontend/dist/js/ui-CC-K19wO.js +0 -2
  585. package/frontend/dist/js/ui-vendor-B1UgO3vd.js +0 -177
  586. package/frontend/dist/js/uk-BqAd5zHF.js +0 -2
  587. package/frontend/dist/js/vi-D9gjlDVB.js +0 -2
  588. package/frontend/dist/js/zh-DKTyHkiR.js +0 -2
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{f as r}from"./router-vendor-CbexJIsv.js";import{t as i}from"./useTranslation-5b5UhAc9.js";import{a,r as o,t as s}from"./utils-BGrdX9ie.js";import{t as c}from"./chatStore-D-NTlArO.js";import{Kn as l,Wn as u,Xt as d,Zn as f,c as p,k as m,lt as h,t as g,yt as _}from"./ui-vendor-C0DZ8-Cm.js";import{n as v,u as y}from"./authStore-BYW8-kP6.js";import{h as b,m as x,p as S,t as C,x as w}from"../assets/index-DBAf_VaS.js";import{t as T}from"./work-DVgm81bJ.js";var E=e(t(),1),D=n(),O=e=>e<5?[`home.greeting.night`,`Up late`]:e<12?[`home.greeting.morning`,`Morning`]:e<18?[`home.greeting.afternoon`,`Afternoon`]:[`home.greeting.evening`,`Evening`],k=`mb-2 text-xs font-medium text-gray-500 dark:text-dark-500`,A=`group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-start text-sm text-gray-700 transition-colors hover:bg-white hover:text-gray-950 dark:text-dark-700 dark:hover:bg-dark-200 dark:hover:text-dark-950 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,j=()=>{let{t:e,i18n:t}=i(),n=r(),{user:j,systemInfo:M,canUseWork:N,canUseAgents:P}=v(),F=c(e=>e.sessions),I=c(e=>e.models),L=y(e=>e.tasks),R=y(e=>e.capabilities),z=y(e=>e.loadTasks),B=y(e=>e.loadCapabilities),V=N(),H=P();(0,E.useEffect)(()=>{V&&(z(!0).catch(()=>{}),B().catch(()=>{}))},[V,z,B]);let[U,W]=O(new Date().getHours()),G=e(U,W),K=j?.username,q=[...F].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,4),J=[...L].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()).slice(0,3),Y=R?.activeRuntimes?.user??0,X=a()?`⌘`:`Ctrl`,Z=q.length>0||J.length>0,Q=C(M?.version);return(0,D.jsx)(`div`,{"data-testid":`home-page`,className:`h-full overflow-y-auto scrollbar-thin`,children:(0,D.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-xl flex-col justify-center px-6 py-12`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-gray-950 dark:text-dark-950`,children:K?`${G}, ${K}.`:`${G}.`}),(0,D.jsxs)(`p`,{"data-testid":`app-version`,className:`mt-1 font-mono text-xs text-gray-400 dark:text-dark-500`,children:[window.location.host||`Libre WebUI`,Q?` · v${Q}`:``]}),(0,D.jsxs)(`div`,{className:`mt-8`,children:[(0,D.jsx)(`p`,{className:k,children:e(`home.start`,`Start`)}),(0,D.jsxs)(`div`,{className:`-mx-2.5 flex flex-col`,children:[(0,D.jsxs)(`button`,{type:`button`,"data-testid":`home-new-chat`,className:A,onClick:()=>x(n),children:[(0,D.jsx)(_,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-600 dark:text-dark-500 dark:group-hover:text-dark-700`}),(0,D.jsx)(`span`,{className:`flex-1`,children:e(`tabs.newChat`,`New Chat`)}),(0,D.jsxs)(`span`,{className:`font-mono text-[10px] tracking-wide text-gray-400 opacity-0 transition-opacity group-hover:opacity-100 dark:text-dark-500`,children:[X,`⇧O`]})]}),(0,D.jsxs)(`button`,{type:`button`,"data-testid":`home-incognito-chat`,className:A,onClick:()=>S(n),children:[(0,D.jsx)(d,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-600 dark:text-dark-500 dark:group-hover:text-dark-700`}),(0,D.jsx)(`span`,{className:`flex-1`,children:e(`chat.session.incognito`,`Incognito Chat`)})]}),V&&(0,D.jsxs)(`button`,{type:`button`,"data-testid":`home-new-work`,className:A,onClick:()=>b(n),children:[(0,D.jsx)(l,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-600 dark:text-dark-500 dark:group-hover:text-dark-700`}),(0,D.jsx)(`span`,{className:`flex-1`,children:e(`tabs.newWork`,`New Work`)}),(0,D.jsxs)(`span`,{className:`font-mono text-[10px] tracking-wide text-gray-400 opacity-0 transition-opacity group-hover:opacity-100 dark:text-dark-500`,children:[X,`⇧U`]})]})]})]}),Z&&(0,D.jsxs)(`div`,{className:`mt-8`,children:[(0,D.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between`,children:[(0,D.jsx)(`p`,{className:s(k,`mb-0`),children:e(`home.continue`,`Continue`)}),V&&Y>0&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:[(0,D.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse-subtle rounded-full bg-[rgb(48,121,255)]`}),Y,` `,e(`home.active`,`active`)]})]}),(0,D.jsxs)(`div`,{className:`-mx-2.5 flex flex-col`,children:[J.map(r=>{let i=w[r.status];return(0,D.jsxs)(`button`,{type:`button`,"data-testid":`home-continue-work`,className:A,onClick:()=>n(`/work/${r.id}`),children:[(0,D.jsx)(`span`,{"aria-hidden":`true`,className:s(`h-2 w-2 shrink-0 rounded-full ring-1 ring-black/[0.06] dark:ring-white/[0.1]`,i.animated&&`animate-pulse-subtle`),style:{backgroundColor:i.color}}),(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.title||e(`work.tasks.untitled`,`Untitled task`)}),r.hostPath&&(0,D.jsx)(`span`,{className:`hidden max-w-[14rem] shrink-0 truncate font-mono text-[10px] text-gray-400 sm:inline dark:text-dark-500`,title:r.hostPath,children:r.hostPath}),(0,D.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:T(r)?e(i.labelKey,i.label):o(new Date(r.updatedAt).getTime(),t.language)})]},r.id)}),q.map(r=>(0,D.jsxs)(`button`,{type:`button`,"data-testid":`home-continue-chat`,className:A,onClick:()=>n(`/c/${r.id}`),children:[(0,D.jsx)(_,{className:`h-4 w-4 shrink-0 text-gray-400 dark:text-dark-500`}),(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.title||e(`tabs.chat`,`Chat`)}),(0,D.jsx)(`span`,{className:`hidden shrink-0 font-mono text-[10px] text-gray-400 sm:inline dark:text-dark-500`,children:r.model.startsWith(`persona:`)?I.find(e=>e.isPersona&&e.name===r.model)?.personaName||e(`chat.persona.label`,`Persona`):r.model}),(0,D.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:o(r.updatedAt,t.language)})]},r.id))]})]}),(0,D.jsxs)(`div`,{className:`mt-8`,children:[(0,D.jsx)(`p`,{className:k,children:e(`home.explore`,`Explore`)}),(0,D.jsx)(`div`,{className:`-mx-2.5 flex flex-col`,children:[[`/notes`,h,e(`sidebar.navigation.notes`,`Notes`)],[`/calendar`,u,e(`sidebar.navigation.calendar`,`Calendar`)],[`/automations`,g,e(`sidebar.navigation.automations`,`Automations`)],[`/personas`,p,e(`sidebar.navigation.personas`,`Personas`)],[`/gallery`,m,e(`sidebar.navigation.imagine`,`Imagine`)],...H?[[`/agents`,f,e(`sidebar.navigation.agents`,`Agents`)]]:[]].map(([e,t,r])=>(0,D.jsxs)(`button`,{type:`button`,className:A,onClick:()=>n(e),children:[(0,D.jsx)(t,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-600 dark:text-dark-500 dark:group-hover:text-dark-700`}),(0,D.jsx)(`span`,{className:`flex-1`,children:r})]},e))})]})]})})};export{j as HomePage,j as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{n as r}from"./i18next-DgmgtwsV.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./useTranslation-5b5UhAc9.js";import{c as u,f as d,t as f,u as p}from"./utils-BGrdX9ie.js";import{Bn as m,Dn as h,Gn as g,I as _,J as v,Ot as y,Q as b,T as x,Yt as S,Zn as C,_ as w,fr as T,lr as E,mn as ee,n as D,rt as O,x as te}from"./ui-vendor-C0DZ8-Cm.js";import{t as k}from"./logger-DSXjF4ye.js";import{b as A}from"./api-D7Ff5M2Q.js";import{t as j}from"./Button-C0r3J9G_.js";import{a as ne,o as M}from"./ui-db9meqAB.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},re=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function P(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(re),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 F=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,I=/<\/?([^\s]+?)[/\s>]/,ie=/^\s*$/,ae=/^(script|style)$/i,L=`\0`,oe=Object.create(null);function R(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(L).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(L).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(L)>-1&&(e.attrs[t]=n.split(L).join(`<`))}e.children.length&&R(e.children)})}function se(e,t){let n=t&&t.components||oe,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;F.lastIndex=0;let o;for(;o=F.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(I);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=L,a=o.index+1,F.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=F.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=P(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=P(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&ae.test(s.name)){t=!0,d||(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);ie.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&R(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 z={parse:se,stringify:ue},B=e(t()),V=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},H=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?U(t):t},de=e=>Array.isArray(e)&&e.every(B.isValidElement),U=e=>Array.isArray(e)?e:[e],fe=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},pe=e=>{let t={};if(!e)return t;let n=e=>{U(e).forEach(e=>{a(e)||(V(e)?n(H(e)):c(e)&&!(0,B.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},W=(e,t,n,r)=>{if(!e)return``;let o=``,s=U(e),l=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return s.forEach((e,s)=>{if(a(e)){o+=`${e}`;return}if((0,B.isValidElement)(e)){let{props:i,type:c}=e,u=Object.keys(i).length,d=l.indexOf(c)>-1,f=i.children;if(!f&&d&&!u){o+=`<${c}/>`;return}if(!f&&(!d||u)||i.i18nIsDynamicList){o+=`<${s}></${s}>`;return}if(d&&u<=1){let e=a(f)?f:W(f,t,n,r);o+=`<${c}>${e}</${c}>`;return}let p=W(f,t,n,r);o+=`<${s}>${p}</${s}>`;return}if(e===null){i(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(c(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];o+=`{{${e}}}`;return}i(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}i(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),o},G=(e,t,n,r,i,o,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!u&&!s)return[n];let f=t??{},m=e=>{U(e).forEach(e=>{a(e)||(V(e)?m(H(e)):c(e)&&!(0,B.isValidElement)(e)&&Object.assign(f,e))})};m(e);let h=Object.keys(f),g=z.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||l.indexOf(e)>-1||h.indexOf(e)>-1}),_={...f,...o},v=(e,t,n)=>{let r=H(e),i=b(r,t.children,n);return de(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},y=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,B.cloneElement)(e,{key:r},i?void 0:t))):n.push(...B.Children.map([e],e=>{if(e.type===B.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,B.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,B.cloneElement)(e,n,i?null:t)}))},b=(e,n,o)=>{let f=U(e),m=U(n),h={};return m.reduce((e,n,m)=>{let g=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,_,r.language);if(n.type===`tag`){let p=f[parseInt(n.name,10)];!p&&t&&(p=t[n.name]),o.length===1&&!p&&(p=o[0][n.name]),p||(p={});let x={...n.attrs};s&&Object.keys(x).forEach(e=>{let t=x[e];a(t)&&(x[e]=d(t))});let S=Object.keys(x).length===0?p:fe({props:x},p),C=(0,B.isValidElement)(S),w=C&&V(n,!0)&&!n.voidElement,T=u&&c(S)&&S.dummy&&!C,E=c(t)&&Object.hasOwnProperty.call(t,n.name);if(a(S)){let t=r.services.interpolator.interpolate(S,_,r.language);e.push(t)}else if(V(S)||w){let t=v(S,n,o);y(S,t,e,m)}else if(T){let t=b(f,n.children,o);y(S,t,e,m)}else if(Number.isNaN(parseFloat(n.name)))if(E){let t=v(S,n,o);y(S,t,e,m,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push((0,B.createElement)(n.name,{key:`${n.name}-${m}`}));else{let t=h[n.name]||0;h[n.name]=t+1;let r,i=0;for(let e=0;e<f.length;e+=1){let a=f[e];if((0,B.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?U(H(r)):f,s=b(a,n.children,o);e.push((0,B.createElement)(n.name,{key:`${n.name}-${m}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=b(f,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(c(S)&&!C){let t=n.children[0]?g:null;t&&e.push(t)}else y(S,g,e,m,n.children.length!==1||!g)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:p().unescape,o=s?a(r.services.interpolator.interpolate(n.content,_,r.language)):r.services.interpolator.interpolate(n.content,_,r.language);t?e.push((0,B.createElement)(t,{key:`${n.name}-${m}`},o)):e.push(o)}return e},[])};return H(b([{dummy:!0,children:e||[]}],g,U(e||[]))[0])},me=(e,t,n)=>{let r=e.key||t,i=(0,B.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,B.createElement)(B.Fragment,null,i)}return(0,B.createElement)(a,{key:r})},he=(e,t)=>e.map((e,n)=>me(e,n,t)),ge=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:me(e[r],r,t)})}),n},_e=(e,t,n,r)=>e?Array.isArray(e)?he(e,t):c(e)?ge(e,t):(s(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,ve=e=>!c(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:i,context:o,tOptions:c={},values:l,defaults:d,components:f,ns:m,i18n:h,t:g,shouldUnescape:_,...v}){let y=h||u();if(!y)return s(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:i}),e;let b=g||y.t.bind(y)||(e=>e),x={...p(),...y.options?.react},S=m||b.ns||y.options?.defaultNS;S=a(S)?[S]:S||[`translation`];let{transDefaultProps:C}=x,w=C?.tOptions?{...C.tOptions,...c}:c,T=_??C?.shouldUnescape,E=C?.values?{...C.values,...l}:l,ee=C?.components?{...C.components,...f}:f,D=W(e,x,y,i),O=d||w?.defaultValue||D||x.transEmptyNodeValue||(typeof i==`function`?r(i):i),{hashTransKey:te}=x,k=i||(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=pe(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:o||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,i),re=N||e,P=null;ve(N)&&(P=N,re=e);let F=G(re,P,M,y,x,ne,T),I=n??x.defaultTransParent;return I?(0,B.createElement)(I,v,F):F}function be({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:s,defaults:c,components:l,ns:d,i18n:f,t:p,shouldUnescape:m,...h}){let{i18n:g,defaultNS:_}=(0,B.useContext)(o)||{},v=f||g||u(),y=p||v?.t.bind(v);return ye({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:s,defaults:c,components:l,ns:d||y?.ns||_||v?.options?.defaultNS,i18n:v,t:p,shouldUnescape:m,...h})}var K=n(),q=k(`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}=l(),[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)([]),[s,c]=(0,B.useState)([]),[u,d]=(0,B.useState)(null),[p,k]=(0,B.useState)(null),[N,re]=(0,B.useState)(``),[P,F]=(0,B.useState)(null),[I,ie]=(0,B.useState)(!0),[ae,L]=(0,B.useState)(!1),[oe,R]=(0,B.useState)(!1),[se,ce]=(0,B.useState)(!1),[le,ue]=(0,B.useState)(!1),[z,V]=(0,B.useState)(``),[H,de]=(0,B.useState)(`chat`),[U,fe]=(0,B.useState)(``),[pe,W]=(0,B.useState)(``),[G,me]=(0,B.useState)(``),[he,ge]=(0,B.useState)(``),[_e,ve]=(0,B.useState)(!1),[ye,xe]=(0,B.useState)(`lobster`),[Se,we]=(0,B.useState)(!0),[ke,Ae]=(0,B.useState)(``),[je,Y]=(0,B.useState)(``),[X,Fe]=(0,B.useState)(``),[Ie,Le]=(0,B.useState)(`report`),Z=(0,B.useMemo)(()=>r.find(e=>e.run_id===P)||null,[r,P]),Q=(0,B.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,B.useMemo)(()=>Pe(a,e),[a,e]),$=(0,B.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),F(e=>e||t.data?.runs[0]?.run_id||null)),r.success&&r.data&&(d(r.data),me(String(r.data.provider||``)),ge(String(r.data.model||``))),a.success&&a.data&&k(a.data),o.success&&o.data&&re(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{ie(!1)}},[e]),ze=(0,B.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,B.useEffect)(()=>{let e=window.setTimeout(()=>{$()},0);return()=>window.clearTimeout(e)},[$]),(0,B.useEffect)(()=>{if(!P){let e=window.setTimeout(()=>{o([])},0);return()=>window.clearTimeout(e)}let e=P;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)})},[P]),(0,B.useEffect)(()=>{if(!P||!Z||![`queued`,`running`,`blocked`].includes(Z.state))return;let e=window.setInterval(()=>{ze(P),A.listRuns(30).then(e=>{e.success&&e.data&&i(e.data.runs)})},1500);return()=>window.clearInterval(e)},[ze,Z,P]);let Be=async()=>{if(!z.trim()){T.error(e(`libreClaw.toasts.enterTask`));return}L(!0);try{let t=await A.startRun({message:z,kind:H,provider:U||void 0,model:pe||void 0});if(t.success&&t.data){let n=t.data.run;i(e=>[n,...e.filter(e=>e.run_id!==n.run_id)]),F(n.run_id),V(``),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{L(!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(!P)return;let r=String(t.data.tool_call_id||``);if(r)try{await A.resolvePermission(P,r,n),await ze(P,!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(!G.trim()||!he.trim()){T.error(e(`libreClaw.toasts.providerModelRequired`));return}R(!0);try{let t=await A.updateModel(G,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{R(!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)(v,{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)(ee,{className:`h-4 w-4`}),e(`libreClaw.dashboard`)]})]})}),!t?.connected&&!I&&(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)(te,{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)(b,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`textarea`,{value:z,onChange:e=>V(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:H,onChange:e=>de(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:U,onChange:e=>fe(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:pe,onChange:e=>W(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:ae,children:[(0,K.jsx)(C,{className:`h-4 w-4`}),e(`libreClaw.startRun.run`)]})]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.modelRoute.title`),icon:(0,K.jsx)(S,{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:G,onChange:e=>me(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:oe,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`)]})]}),u&&(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(u,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)(E,{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:()=>F(t.run_id),className:f(`w-full rounded-xl border p-3 text-start transition`,P===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)(h,{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)(x,{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)(_,{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)(m,{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)(D,{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)(g,{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)(b,{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)(b,{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)(w,{className:`h-4 w-4`})})]})]})},t.automation_id))]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.usageFallback.title`),icon:(0,K.jsx)(E,{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(p||{},null,2)})]})]})})]}),I&&(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:f(`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:f(`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:f(`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:f(`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:f(`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:f(`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 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{m as e,p as t}from"./markdown-core-BmPPZiuD.js";import{n}from"./react-vendor-C5yShNlM.js";import{t as r}from"./useTranslation-Bho4HCyg.js";import{t as i}from"./utils-D9W1Lnkn.js";import{$t as a,Gt as o,V as s,n as c,y as l}from"./ui-vendor-B1UgO3vd.js";import{t as u}from"./Button-BPf_pOxH.js";e();var d=n(),f=t(),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)(s,{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)(s,{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)(s,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(o,{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)(s,{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
+ import"./rolldown-runtime-hePW80VL.js";import{_ as e,g as t}from"./markdown-core-BK7WVOb7.js";import{n}from"./react-vendor-BG_HPV6X.js";import{t as r}from"./useTranslation-5b5UhAc9.js";import{t as i}from"./utils-BGrdX9ie.js";import{J as a,b as o,bn as s,n as c,un as l}from"./ui-vendor-C0DZ8-Cm.js";import{t as u}from"./Button-C0r3J9G_.js";e();var d=n(),f=t(),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)(a,{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)(a,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(s,{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)(a,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(l,{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)(a,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(o,{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};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{n as r}from"./react-vendor-BG_HPV6X.js";import{f as i}from"./router-vendor-CbexJIsv.js";import{t as a}from"./useTranslation-5b5UhAc9.js";import{t as o}from"./utils-BGrdX9ie.js";import{m as s,s as c,t as l}from"./chatStore-D-NTlArO.js";import{Bn as u,Dt as d,En as f,H as p,It as m,J as h,Vt as g,X as _,Zn as v,_n as y,c as b,fr as x,k as ee,mn as S,n as C,qn as w,t as T,x as te,yn as ne,zn as re,zt as ie}from"./ui-vendor-C0DZ8-Cm.js";import{t as ae}from"./logger-DSXjF4ye.js";import{S as oe,v as E}from"./api-D7Ff5M2Q.js";import{n as se}from"./authStore-BYW8-kP6.js";import{D as ce}from"../assets/index-DBAf_VaS.js";var D=e(t(),1),le=r(),O=n();function k(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ue({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:s,hfGgufFiles:c,loadingGguf:l,pullingModel:u,pullProgress:f,setHfTask:p,setHfSort:m,onToggleHfModel:g,onPullHfGguf:_,onCancelPull:v,onRefreshHfModels:b}){let{t:x}=a();return(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`select`,{value:e,onChange:e=>p(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(`option`,{value:`text-generation`,children:x(`modelManager.huggingface.taskTextGeneration`)}),(0,O.jsx)(`option`,{value:`text-to-speech`,children:x(`modelManager.huggingface.taskTextToSpeech`)}),(0,O.jsx)(`option`,{value:`text-to-image`,children:x(`modelManager.huggingface.taskTextToImage`)}),(0,O.jsx)(`option`,{value:`automatic-speech-recognition`,children:x(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,O.jsxs)(`select`,{value:t,onChange:e=>m(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(`option`,{value:`downloads`,children:x(`modelManager.huggingface.sortDownloads`)}),(0,O.jsx)(`option`,{value:`likes`,children:x(`modelManager.huggingface.sortLikes`)}),(0,O.jsx)(`option`,{value:`lastModified`,children:x(`modelManager.huggingface.sortRecent`)})]})]})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:x(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(d,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(T,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:x(`modelManager.huggingface.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=s===e.id,r=c[e.id]||[],i=l===e.id;return(0,O.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,O.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e.id)},children:(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,O.jsx)(T,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,O.jsx)(`span`,{className:`rounded bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(y,{className:`h-3 w-3`}),k(e.downloads)]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(ie,{className:`h-3 w-3`}),k(e.likes)]}),e.pipeline_tag&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,O.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(S,{className:`h-4 w-4 text-gray-400`})}),(0,O.jsx)(re,{className:o(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,O.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,O.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,O.jsx)(d,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,O.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:x(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,O.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:x(`modelManager.huggingface.noGgufAvailable`)}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:x(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=u===e.ollamaCommand;return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:f?.percent===void 0?`...`:`${f.percent}%`}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),v()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(C,{className:`h-4 w-4`})})]}):n?(0,O.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),_(e.ollamaCommand,e.filename)},disabled:!!u,className:o(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,O.jsx)(y,{className:`h-3 w-3 inline mr-1`}),x(`models.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:x(`modelSelector.adminOnlyPull`)})]},e.filename)}),u?.startsWith(`hf.co/`)&&u.includes(e.id)&&f?.percent!==void 0&&(0,O.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${f.percent}%`}})})]})})]},e.id)})})]}),(0,O.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,O.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,O.jsx)(S,{className:`h-3 w-3`}),x(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),b()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(h,{className:o(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function de({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:s,getModelSubLabel:c,onModelSelect:l,onOpenGallery:d}){let{t:f}=a();return(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>{let n=r(e);return(0,O.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:o(`block w-full cursor-pointer border-b border-gray-100 px-3 py-3 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===n&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:s(e)}),c(e)&&(0,O.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:c(e)})]}),t===n&&(0,O.jsx)(u,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(ne,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:f(`models.noModelsFound`)})]}),n&&(0,O.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(_,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),f(`modelSelector.actions`)]})}),(0,O.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),d()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(m,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:f(`gallery.generate`)}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:f(`gallery.generateDescription`)})]})]})})]})]})}function fe({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:s,pullProgress:c,setLibraryCategory:l,isModelInstalled:u,onModelSelect:p,onPullModel:m,onCancelPull:g,onRefreshLibrary:_}){let{t:v}=a();return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,O.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:o(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:v(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(d,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(f,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:v(`models.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=u(e.name),r=s===e.name;return(0,O.jsxs)(`div`,{className:o(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,O.jsx)(f,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:v(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,O.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,O.jsx)(f,{className:`h-3 w-3`}),`Cloud`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,O.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,O.jsx)(y,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,O.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:c?.percent===void 0?`...`:`${c.percent}%`}),(0,O.jsx)(`button`,{onClick:g,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(C,{className:`h-4 w-4`})})]}):t?(0,O.jsx)(`button`,{onClick:()=>p(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:v(`modelSelector.use`)}):n?(0,O.jsxs)(`button`,{onClick:()=>m(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,O.jsx)(y,{className:`h-3 w-3 inline mr-1`}),v(`modelSelector.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:v(`modelSelector.adminOnlyPull`)})})]}),r&&c?.percent!==void 0&&(0,O.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${c.percent}%`}})})]},e.name)})})]}),(0,O.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,O.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,O.jsx)(S,{className:`h-3 w-3`}),v(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(h,{className:o(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var pe=ae(`components:model-selector`),A=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:u,disabled:d=!1,compact:m=!1,showImageGen:h=!1,onModelsRefresh:_,getModelValue:y,getModelLabel:S,getModelTitle:ne,triggerRef:ie,triggerTestId:ae,selectTestId:k,ariaLabel:A})=>{let{t:j}=a(),[M,me]=(0,D.useState)(!1),[N,he]=(0,D.useState)(``),[P,F]=(0,D.useState)(`installed`),ge=(0,D.useRef)(null),I=(0,D.useRef)(null),L=(0,D.useRef)(null),R=(0,D.useRef)(null),_e=i(),{user:ve,systemInfo:ye}=se(),z=ve?.role===`admin`||ye?.requiresAuth===!1,[B,be]=(0,D.useState)(`all`),[xe,Se]=(0,D.useState)(``),[V,Ce]=(0,D.useState)(`text-generation`),[H,we]=(0,D.useState)(`downloads`),[Te,Ee]=(0,D.useState)(``),[U,De]=(0,D.useState)(null),[W,Oe]=(0,D.useState)({}),[ke,Ae]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[je,q]=(0,D.useState)(null),[Me,J]=(0,D.useState)(null),Ne=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Pe=[{type:`legacy`,label:j(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,O.jsx)(w,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:j(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,O.jsx)(C,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isUnavailable&&!e.isLegacySelection),color:`gray`},{type:`personas`,label:j(`modelSelector.personas`),icon:(0,O.jsx)(b,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPersona&&!e.isUnavailable),color:`purple`},{type:`agents`,label:j(`modelSelector.agentModels`,`Agents`),icon:(0,O.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isAgent&&!e.isUnavailable),color:`green`},{type:`ollama`,label:j(`modelSelector.ollamaModels`),icon:(0,O.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>s(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:j(`modelSelector.pluginModels`),icon:(0,O.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPlugin&&!e.isUnavailable),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(N.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(N.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(N.toLowerCase()))})).filter(e=>e.models.length>0),Y=e=>y?.(e)??e.name,Fe=l(e=>e.modelMetadata),X=e.find(e=>Y(e)===t);(0,D.useImperativeHandle)(ie,()=>L.current);let Z=(0,D.useCallback)((e=!0)=>{me(!1),he(``),e&&window.requestAnimationFrame(()=>L.current?.focus())},[]),{data:Ie=[],isLoading:Le,refetch:Re}=ce({queryKey:[`ollama-library-selector`,xe,B===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await E.getLibraryModels({search:xe||void 0,sort:`popular`,category:B===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:M&&P===`ollama`}),{data:ze=[],isLoading:Be,refetch:Ve}=ce({queryKey:[`hf-models-selector`,V,Te,H],queryFn:async()=>{let e=await oe.getModels({task:V,search:Te||void 0,sort:H,limit:30});return e.success&&e.data?e.data:[]},enabled:M&&P===`huggingface`}),He=Ie.filter(e=>{let t=!N||e.name.toLowerCase().includes(N.toLowerCase())||e.description.toLowerCase().includes(N.toLowerCase()),n=B===`all`||e.category===B;return t&&n}),Ue=(0,D.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Ae(e);try{let r=await oe.getGgufFiles(t,n);r.success&&r.data&&Oe(t=>({...t,[e]:r.data}))}catch(e){pe.error(`Failed to load GGUF files:`,e)}finally{Ae(null)}}},[]),We=(0,D.useCallback)(e=>{U===e?De(null):(De(e),W[e]||Ue(e))},[U,W,Ue]),Ge=(0,D.useCallback)((e,t)=>{if(!z){x.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let n=E.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),x.success(`Downloaded ${t}`),_?.()},e=>{q(null),K(null),J(null),x.error(`Failed to download: ${e}`)});J(()=>n)}catch{q(null),K(null),x.error(`Failed to start download`)}}},[z,_,G,j]);(0,D.useEffect)(()=>{let e=setTimeout(()=>{P===`huggingface`?Ee(N):P===`ollama`&&Se(N)},300);return()=>clearTimeout(e)},[N,P]),(0,D.useEffect)(()=>{if(!M)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Z();return}if(e.key===`Tab`&&I.current){let t=Array.from(I.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Z,M]),(0,D.useEffect)(()=>{M&&R.current&&R.current.focus()},[M]);let Ke=async t=>{let r=e.find(e=>Y(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?Y(r):t,a=r?.name??t;Z();try{let e=await E.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await E.unloadAllModels())}}catch(e){pe.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},qe=async e=>{if(!z){x.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let t=E.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),x.success(`Downloaded ${e}`),_?.()},e=>{q(null),K(null),J(null),x.error(`Failed to download: ${e}`)});J(()=>t)}catch{q(null),K(null),x.error(`Failed to start download`)}}},Je=()=>{Me&&(Me(),J(null),K(null),q(null),x.success(`Download cancelled`))},Ye=t=>e.some(e=>s(e)&&(e.name===t||e.name.startsWith(t+`:`))),Q=e=>{let t=Fe[c(e)]?.avatar;return t&&!e.isPersona?(0,O.jsx)(`img`,{src:t,alt:``,className:`h-4 w-4 shrink-0 rounded-full object-cover`}):e.isLegacySelection?(0,O.jsx)(w,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,O.jsx)(b,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,O.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,O.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`})},$=e=>{if(S)return S(e);let t=Fe[c(e)]?.label;return t&&!e.isPersona?t:e.isLegacySelection?`${e.name} (${j(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.name)},Xe=e=>e.isLegacySelection?e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):j(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${j(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,O.jsxs)(`div`,{className:o(`relative`,u),ref:ge,children:[(0,O.jsxs)(`button`,{ref:L,"data-testid":ae,type:`button`,onClick:()=>!d&&me(!M),disabled:d,"aria-haspopup":`dialog`,"aria-expanded":M,"aria-label":A&&X?`${A}: ${$(X)}`:A,className:o(m?`h-9 sm:h-10 px-2.5 flex items-center justify-between text-start w-full`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`border border-black/[0.06] bg-gray-100/70 dark:border-white/[0.06] dark:bg-dark-300/70`,`rounded-xl text-sm hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,d?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:m?X?ne?.(X)??$(X):j(`modelSelector.selectModel`):void 0,children:[(()=>{if(!X)return m?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,O.jsx)(v,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-400 dark:text-gray-500 truncate`,children:j(`modelSelector.selectModel`)})]}):j(`modelSelector.selectModel`);if(m){let e=$(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-xs font-medium text-gray-700 dark:text-gray-200 truncate`,children:e})]})}let e=$(X),t=Xe(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,O.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),X.isPersona&&r&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,O.jsx)(w,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,O.jsx)(ee,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,O.jsx)(re,{className:o(m?`h-3 w-3`:`h-4 w-4`,`text-gray-400 flex-shrink-0 transition-transform duration-150`,M&&`rotate-180`)})]}),M&&(0,le.createPortal)((0,O.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,O.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Z()}),(0,O.jsxs)(`div`,{ref:I,role:`dialog`,"aria-modal":`true`,"aria-label":j(`modelSelector.selectModel`),className:o(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/[0.98] dark:bg-dark-25/[0.98]`,`h-[min(620px,88vh)] rounded-[1.5rem] border border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,O.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:j(`modelSelector.selectModel`)}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>Z(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:j(`common.close`),children:(0,O.jsx)(C,{className:`h-4 w-4`})})]}),(0,O.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(p,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{ref:R,type:`text`,placeholder:j(P===`installed`?`modelSelector.searchInstalled`:P===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:N,onChange:e=>he(e.target.value),className:o(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),(0,O.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,O.jsxs)(`button`,{onClick:()=>{F(`installed`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`installed`?`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`),"aria-pressed":P===`installed`,children:[(0,O.jsx)(g,{className:`h-4 w-4 inline me-1.5`}),j(`modelSelector.installed`)]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`ollama`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`ollama`?`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`),"aria-pressed":P===`ollama`,children:[(0,O.jsx)(f,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`huggingface`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`huggingface`?`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`),"aria-pressed":P===`huggingface`,children:[(0,O.jsx)(T,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),P===`installed`&&(0,O.jsx)(de,{filteredGroups:Pe,selectedModel:t,showImageGen:h,getModelValue:Y,getModelIcon:Q,getModelLabel:$,getModelSubLabel:Xe,onModelSelect:Ke,onOpenGallery:()=>{Z(!1),_e(`/gallery`)}}),P===`ollama`&&(0,O.jsx)(fe,{libraryCategories:Ne,libraryCategory:B,canInstallModels:z,loadingLibrary:Le,filteredLibraryModels:He,pullingModel:G,pullProgress:je,setLibraryCategory:be,isModelInstalled:Ye,onModelSelect:Ke,onPullModel:qe,onCancelPull:Je,onRefreshLibrary:()=>{Re()}}),P===`huggingface`&&(0,O.jsx)(ue,{hfTask:V,hfSort:H,canInstallModels:z,loadingHf:Be,hfModels:ze,expandedHfModel:U,hfGgufFiles:W,loadingGguf:ke,pullingModel:G,pullProgress:je,setHfTask:Ce,setHfSort:we,onToggleHfModel:We,onPullHfGguf:Ge,onCancelPull:Je,onRefreshHfModels:()=>{Ve()}})]})]}),document.body),(0,O.jsx)(`select`,{"data-testid":k,"aria-label":A,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,O.jsx)(`option`,{value:Y(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${Y(e)}`))})]})};export{A as t};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{i as r}from"./router-vendor-CbexJIsv.js";import{t as i}from"./useTranslation-5b5UhAc9.js";import{r as a,t as o}from"./utils-BGrdX9ie.js";import{t as s}from"./chatStore-D-NTlArO.js";import{$ as c,H as ee,K as l,L as u,Ot as d,X as f,_ as te,_n as ne,ar as re,fn as p,fr as m,it as h,j as ie,k as g,lt as _,n as v,p as y,s as ae,tt as b}from"./ui-vendor-C0DZ8-Cm.js";import{t as x}from"./logger-DSXjF4ye.js";import{O as S,k as C}from"./api-D7Ff5M2Q.js";import{t as w}from"./Button-C0r3J9G_.js";import"./ui-db9meqAB.js";import{t as oe}from"./RichMessageContent-Bm2WaEGi.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=x(`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:o(`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:c,initialTab:ee,onClose:f,onApplyContent:re})=>{let{t:p,i18n:ie}=i(),[_,ae]=(0,T.useState)(ee),[b,x]=(0,T.useState)(null),[oe,E]=(0,T.useState)(null),[M,N]=(0,T.useState)(null),[se,P]=(0,T.useState)(!1),F=(0,T.useRef)(null),[I,ce]=(0,T.useState)(null),[L,R]=(0,T.useState)(``),[z,B]=(0,T.useState)(`read`),[V,H]=(0,T.useState)(!1),[U,W]=(0,T.useState)(``),[G,K]=(0,T.useState)(!1),[q,J]=(0,T.useState)(null),Y=s(e=>e.selectedModel),le=s(e=>e.selectedProviderType),ue=s(e=>e.selectedProviderId),X=(0,T.useCallback)(()=>{C.getRevisions(e.id).then(e=>{e.success&&Array.isArray(e.data)&&x(e.data)}).catch(e=>A.error(`Failed to load revisions:`,e))},[e.id]),Z=(0,T.useCallback)(()=>{C.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)(()=>{S.listGrants(`note`,e.id).then(e=>{e.success&&Array.isArray(e.data)&&ce(e.data)}).catch(e=>A.error(`Failed to load shares:`,e))},[e.id]);(0,T.useEffect)(()=>{_===`revisions`&&b===null&&X(),_===`attachments`&&M===null&&Z(),_===`share`&&c&&I===null&&Q()},[_,b,M,I,c,X,Z,Q]);let de=async t=>{try{let n=await C.restoreRevision(e.id,t);n.success&&n.data?(re(n.data.content,n.data.title),x(null),E(null),m.success(p(`notes.revisionRestored`))):m.error(n.error||p(`notes.revisionRestoreFailed`))}catch(e){A.error(`Failed to restore revision:`,e),m.error(p(`notes.revisionRestoreFailed`))}},fe=async t=>{if(!(!t||t.length===0)){P(!0);try{let n=await C.uploadAttachment(e.id,t[0]);n.success?(Z(),m.success(p(`notes.attachmentAdded`))):m.error(n.error||p(`notes.attachmentFailed`))}catch(e){A.error(`Failed to upload attachment:`,e),m.error(p(`notes.attachmentFailed`))}finally{P(!1),F.current&&(F.current.value=``)}}},pe=async t=>{try{let n=await C.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),m.error(p(`notes.attachmentDownloadFailed`))}},me=async t=>{try{(await C.deleteAttachment(e.id,t)).success&&Z()}catch(e){A.error(`Failed to delete attachment:`,e)}},he=async()=>{let t=L.trim();if(t){H(!0);try{let n=await S.resolvePrincipal(t);if(!n.success||!n.data){m.error(p(`notes.shareUserNotFound`));return}let r=await S.createGrant({resourceType:`note`,resourceId:e.id,principalType:`user`,principalId:n.data.id,permission:z});r.success?(R(``),Q(),m.success(p(`notes.shareAdded`,{username:t}))):m.error(r.error||p(`notes.shareFailed`))}catch(e){A.error(`Failed to share note:`,e),m.error(p(`notes.shareFailed`))}finally{H(!1)}}},ge=async e=>{try{(await S.deleteGrant(e)).success&&Q()}catch(e){A.error(`Failed to revoke share:`,e)}},_e=async()=>{if(!(!U.trim()||!Y)){K(!0),J(null);try{let t=await C.assist(e.id,{instruction:U,model:Y,providerType:le,providerId:ue});t.success&&t.data?.content!==void 0?J(t.data.content):m.error(t.error||p(`notes.assistFailed`))}catch(e){A.error(`Note assist failed:`,e),m.error(p(`notes.assistFailed`))}finally{K(!1)}}},$=(0,T.useMemo)(()=>q===null?null:D(t,q),[q,t]),ve=[{id:`revisions`,icon:(0,k.jsx)(l,{className:`h-3.5 w-3.5`}),label:p(`notes.revisions`)},{id:`attachments`,icon:(0,k.jsx)(h,{className:`h-3.5 w-3.5`}),label:p(`notes.attachments`)},{id:`share`,icon:(0,k.jsx)(u,{className:`h-3.5 w-3.5`}),label:p(`notes.share`),hidden:!c},{id:`assist`,icon:(0,k.jsx)(g,{className:`h-3.5 w-3.5`}),label:p(`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":p(`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:()=>ae(e.id),"data-testid":`note-tools-tab-${e.id}`,className:o(`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:f,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":p(`common.close`),"data-testid":`note-tools-close`,children:(0,k.jsx)(v,{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:b===null?(0,k.jsx)(d,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):b.length===0?(0,k.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:p(`notes.noRevisions`)}):b.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:[a(e.createdAt,ie.language),e.title!==n&&(0,k.jsxs)(`span`,{className:`ms-1 text-gray-400 dark:text-dark-500`,children:[`· `,e.title||p(`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)(y,{className:`h-3 w-3`}),p(`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:F,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:se,onClick:()=>F.current?.click(),"data-testid":`note-attachment-upload`,children:[se?(0,k.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,k.jsx)(h,{className:`h-3.5 w-3.5`}),p(`notes.addAttachment`)]})]}),M===null?(0,k.jsx)(d,{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:p(`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)(h,{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:p(`common.download`),children:(0,k.jsx)(ne,{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:p(`common.delete`),children:(0,k.jsx)(te,{className:`h-3.5 w-3.5`})})]},e.id))]}),_===`share`&&c&&(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:L,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key===`Enter`&&he()},placeholder:p(`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:z,onChange:e=>B(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:p(`notes.permissionRead`)}),(0,k.jsx)(`option`,{value:`write`,children:p(`notes.permissionWrite`)})]}),(0,k.jsx)(w,{size:`sm`,disabled:V||!L.trim(),onClick:()=>void he(),"data-testid":`note-share-submit`,children:V?(0,k.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):p(`notes.shareAction`)})]}),I===null?(0,k.jsx)(d,{className:`mx-auto h-4 w-4 animate-spin text-gray-400`}):I.length===0?(0,k.jsx)(`p`,{className:`text-center text-xs text-gray-400 dark:text-dark-500`,children:p(`notes.notShared`)}):I.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)(u,{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:p(`notes.revokeShare`),children:(0,k.jsx)(v,{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:p(`notes.shareHint`)})]}),_===`assist`&&r&&(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`textarea`,{value:U,onChange:e=>W(e.target.value),placeholder:p(`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:G||!U.trim()||!Y,onClick:()=>void _e(),"data-testid":`note-assist-generate`,children:[G?(0,k.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,k.jsx)(g,{className:`h-3.5 w-3.5`}),p(`notes.assistGenerate`)]}),!Y&&(0,k.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:p(`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:p(`notes.assistNoChanges`)}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(w,{size:`sm`,className:`flex-1`,disabled:!O($),onClick:()=>{re(q),J(null),W(``),m.success(p(`notes.assistApplied`))},"data-testid":`note-assist-apply`,children:p(`notes.assistApply`)}),(0,k.jsx)(w,{size:`sm`,variant:`outline`,className:`flex-1`,onClick:()=>J(null),"data-testid":`note-assist-discard`,children:p(`notes.assistDiscard`)})]}),(0,k.jsx)(`p`,{className:`text-[11px] leading-relaxed text-gray-400 dark:text-dark-500`,children:p(`notes.assistRevisionHint`)})]})]})]})]})},N=x(`pages:notes`),se=800,P=()=>{let{t:e,i18n:t}=i(),[n,s]=(0,T.useState)([]),[l,u]=(0,T.useState)(!0),[d,h]=(0,T.useState)(null),[g,v]=(0,T.useState)(``),[y,x]=(0,T.useState)(``),[S,E]=(0,T.useState)(``),[D,O]=(0,T.useState)(!0),[A,j]=(0,T.useState)(`idle`),[P,F]=(0,T.useState)(null),I=(0,T.useRef)(null),[ce,L]=r(),R=(0,T.useMemo)(()=>n.find(e=>e.id===d)??null,[n,d]);(0,T.useEffect)(()=>{let e=!1;return C.getNotes().then(t=>{e||t.success&&t.data&&s(t.data)}).catch(e=>N.error(`Failed to load notes:`,e)).finally(()=>{e||u(!1)}),()=>{e=!0}},[]);let z=ce.get(`note`),B=z?n.find(e=>e.id===z):void 0;B&&d!==B.id&&(h(B.id),x(B.title),E(B.content),O(!0),j(`idle`));let V=z!==null&&(B!==void 0||!l);(0,T.useEffect)(()=>{V&&L({},{replace:!0})},[V,L]);let H=!R||!R.shared,U=R?!R.shared||R.shared.permission===`write`:!1,W=(e,t=`preview`)=>{Y(),h(e.id),x(e.title),E(e.content),O(t===`preview`),j(`idle`),F(null)},G=async()=>{if(R)try{let e=await C.updateNote(R.id,{pinned:!R.pinned});if(e.success&&e.data){let t=e.data;s(e=>e.map(e=>e.id===t.id?t:e))}}catch(e){N.error(`Failed to toggle pin:`,e)}},K=()=>{if(!R)return;let e=new Blob([S],{type:`text/markdown;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${(y||`note`).replace(/[\\/:*?"<>|]/g,`-`)}.md`,n.click(),URL.revokeObjectURL(t)},q=(e,t,n)=>{I.current!==null&&window.clearTimeout(I.current),j(`saving`),I.current=window.setTimeout(()=>{I.current=null,J(e,t,n)},se)},J=async(t,n,r)=>{try{let e=await C.updateNote(t,{title:n,content:r});if(e.success&&e.data){let n=e.data;s(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),m.error(e(`notes.saveFailed`)),j(`idle`)}},Y=()=>{I.current!==null&&d&&(window.clearTimeout(I.current),I.current=null,J(d,y,S))};(0,T.useEffect)(()=>()=>{I.current!==null&&window.clearTimeout(I.current)},[]);let le=async()=>{try{let e=await C.createNote(``,``);if(e.success&&e.data){let t=e.data;s(e=>[t,...e]),W(t,`edit`)}}catch(t){N.error(`Failed to create note:`,t),m.error(e(`notes.createFailed`))}},ue=async t=>{if(window.confirm(e(`notes.deleteConfirm`)))try{(await C.deleteNote(t)).success&&(s(e=>e.filter(e=>e.id!==t)),d===t&&h(null))}catch(t){N.error(`Failed to delete note:`,t),m.error(e(`notes.deleteFailed`))}},X=(0,T.useMemo)(()=>{let e=g.trim().toLowerCase();return e?n.filter(t=>t.title.toLowerCase().includes(e)||t.content.toLowerCase().includes(e)):n},[n,g]);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:o(`min-h-0 w-full shrink-0 flex-col border-e border-black/[0.06] dark:border-white/[0.07] md:w-72`,R?`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)(f,{className:`h-4 w-4`})})]}),(0,k.jsxs)(`div`,{className:`relative mx-3 mb-2`,children:[(0,k.jsx)(ee,{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:g,onChange:e=>v(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:l?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:()=>W(n),className:o(`group cursor-pointer rounded-lg px-2.5 py-2 transition-colors`,d===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)(c,{className:`h-3 w-3 shrink-0 text-primary-500`,"aria-label":e(`notes.pinned`)}),n.shared&&(0,k.jsx)(ae,{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)(te,{className:`h-3 w-3`})})]}),(0,k.jsxs)(`p`,{className:`mt-0.5 truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[a(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:o(`min-w-0 flex-1 flex-col`,R?`flex`:`hidden md:flex`),children:R?(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(),h(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:y||e(`notes.untitled`)}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{"data-testid":`notes-title-editor`,dir:`auto`,readOnly:!U,value:y,onChange:e=>{x(e.target.value),q(R.id,e.target.value,S)},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`):``})]}),H&&(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:()=>void G(),className:o(`hidden h-8 w-8 shrink-0 p-0 sm:flex`,R.pinned&&`text-primary-500`),title:R.pinned?e(`notes.unpin`):e(`notes.pin`),"aria-label":R.pinned?e(`notes.unpin`):e(`notes.pin`),"data-testid":`notes-pin-toggle`,children:(0,k.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:K,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)(ne,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(w,{size:`sm`,variant:`ghost`,onClick:()=>F(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":P!==null,"data-testid":`notes-tools-toggle`,children:(0,k.jsx)(ie,{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)(b,{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)(p,{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:S,allowHtml:!0,className:`mx-auto w-full max-w-5xl pb-12`})}):(0,k.jsx)(`textarea`,{"data-testid":`notes-content-editor`,dir:`auto`,readOnly:!U,value:S,onChange:e=>{E(e.target.value),q(R.id,y,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]`}),P!==null&&(0,k.jsx)(M,{note:R,currentContent:S,currentTitle:y,canWrite:U,isOwner:H,initialTab:P,onClose:()=>F(null),onApplyContent:(e,t)=>{E(e),t!==void 0&&x(t),J(R.id,t===void 0?y: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)(f,{className:`h-3.5 w-3.5`}),e(`notes.new`)]})]})})})]})};export{P as NotesPage,P as default};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{C as r,D as i,E as a,O as o,S as s,T as c,_ as l,a as u,b as d,c as f,d as p,f as m,g as h,h as g,i as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,t as T,u as E,v as D,w as O,x as k,y as A}from"./syntax-highlight-P2zo9o06.js";var j=e({OptimizedSyntaxHighlighter:()=>I,default:()=>I});t();var M=n(),N={js:`javascript`,ts:`typescript`,py:`python`,sh:`bash`,shell:`bash`,zsh:`bash`,terminal:`shell-session`,console:`shell-session`,html:`markup`,xml:`markup`,svg:`markup`,"c++":`cpp`,cs:`csharp`,"c#":`csharp`,golang:`go`,kt:`kotlin`,rb:`ruby`,rs:`rust`,yml:`yaml`},P={bash:i,c:a,cpp:c,css:O,csharp:r,diff:s,go:k,java:d,javascript:A,json:D,jsx:l,kotlin:h,markdown:g,markup:y,php:S,python:m,ruby:p,rust:E,"shell-session":v,sql:f,swift:w,tsx:x,typescript:u,yaml:_};Object.entries(P).forEach(([e,t])=>{o.registerLanguage(e,t)}),o.alias(`markup`,[`html`,`xml`,`svg`]);var F=new Set(Object.keys(P)),I=({children:e,language:t,isDark:n=!1,className:r=``,backgroundColor:i,borderRadius:a=`0.5rem`,customStyle:s,showLineNumbers:c=!1,codeTheme:l=`default`,preTag:u})=>{let d=N[t.toLowerCase()]||t.toLowerCase();return F.has(d)?(0,M.jsx)(`div`,{dir:`ltr`,className:`text-left`,children:(0,M.jsx)(o,{language:d,style:n?l===`night`?C:b:T,className:r,customStyle:{margin:0,padding:`0.75rem`,borderRadius:a,fontSize:`0.875rem`,fontFamily:`"JetBrains Mono", ui-monospace, SFMono-Regular, monospace`,...s,...i?{background:i,backgroundColor:i}:{}},showLineNumbers:c,lineNumberStyle:{minWidth:`2.5em`,paddingRight:`1.25em`,color:n?`#6E7681`:`#9CA3AF`,userSelect:`none`},...u?{PreTag:u}:{},children:e})}):(0,M.jsx)(u??`pre`,{dir:`ltr`,style:{...s,...i?{backgroundColor:i}:{}},className:`${n?`bg-dark-50 text-dark-900`:`bg-gray-100 text-gray-900`} overflow-x-auto rounded-lg p-3 text-left font-mono text-sm ${r}`,children:(0,M.jsx)(`code`,{className:``,children:e})})};export{j as n,I as t};
@@ -0,0 +1,13 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{t as r}from"./useTranslation-5b5UhAc9.js";import{t as i}from"./utils-BGrdX9ie.js";import{t as a}from"./chatStore-D-NTlArO.js";import{A as o,B as s,Bn as c,Dn as l,Ft as u,It as d,J as f,L as p,O as m,Ot as h,Q as g,Vt as _,Z as v,_ as y,_n as b,c as x,cn as ee,f as S,fr as C,g as w,gn as T,h as E,k as D,n as O,qn as k,sr as te,t as A,vn as j,w as M,yt as N}from"./ui-vendor-C0DZ8-Cm.js";import{t as P}from"./logger-DSXjF4ye.js";import{A as F,d as I,f as L,g as R,h as z,j as ne,m as B,p as V}from"./api-D7Ff5M2Q.js";import{t as H}from"./appStore-DmV5wqDz.js";import{t as U}from"./Button-C0r3J9G_.js";import{a as re,o as W}from"./ui-db9meqAB.js";import{C as ie,D as G,E as ae,k as K}from"../assets/index-DBAf_VaS.js";var q=e(t(),1),J=n(),Y=P(`components:persona-card`),oe=({persona:e,onEdit:t,onDelete:n,onDownload:a,onSelect:o,onToggleFavorite:c,isSelected:l=!1,compact:u=!1})=>{let{t:d}=r(),f=K(),[h,_]=(0,q.useState)(!1),[v,x]=(0,q.useState)(!1),[S,w]=(0,q.useState)(!1),O=!!(e.memory_settings?.enabled||e.mutation_settings?.enabled),{data:P=null}=G({queryKey:[`persona-memory-status`,e.id],queryFn:async()=>{let t=await B.getMemoryStatus(e.id);return t.success&&t.data?t.data:null},enabled:O}),F=()=>f.invalidateQueries({queryKey:[`persona-memory-status`,e.id]}),I=async()=>{if(confirm(d(`personaCard.wipeConfirm`))){w(!0);try{let t=await B.wipeMemories(e.id);t.success?(C.success(d(`personaCard.wipeSuccess`,{count:t.data?.deleted_count||0})),await F()):C.error(d(`personaCard.failed`,{action:`wipe memories`}))}catch(e){C.error(d(`personaCard.failed`,{action:`wipe memories`})),Y.error(e)}finally{w(!1),_(!1)}}},L=async()=>{w(!0);try{let t=await B.backupPersona(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-backup.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),C.success(d(`personaCard.backupSuccess`))}catch(e){C.error(d(`personaCard.failed`,{action:`backup persona`})),Y.error(e)}finally{w(!1),_(!1)}},ne=async()=>{w(!0);try{let t=await B.exportPersonaDNA(e.id),n=window.URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.name.toLowerCase().replace(/\s+/g,`-`)}-dna.json`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),C.success(d(`personaCard.dnaSuccess`))}catch(e){C.error(d(`personaCard.failed`,{action:`export persona DNA`})),Y.error(e)}finally{w(!1),_(!1)}},V=(t=128)=>z(e,t),H=(t=128)=>n=>{R(n.currentTarget,e.name,t)};return u?(0,J.jsxs)(`div`,{className:i(`group relative flex items-center gap-3 p-3 rounded-xl cursor-pointer transition-all duration-200`,`border border-transparent`,`hover:bg-gray-50 dark:hover:bg-dark-100`,l&&[`bg-primary-50 dark:bg-primary-900/20`,`border-primary-200 dark:border-primary-700`]),onClick:()=>o?.(e),children:[(0,J.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,J.jsx)(`img`,{src:V(64),alt:e.name,className:`w-10 h-10 rounded-full object-cover ring-2 ring-white dark:ring-dark-100`,onError:H(64)}),O&&(0,J.jsx)(`div`,{className:`absolute -bottom-0.5 -end-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-primary-600`,children:(0,J.jsx)(D,{className:`h-2.5 w-2.5 text-white`})})]}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`h4`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100 truncate`,children:e.name}),e.is_favorite&&(0,J.jsx)(M,{className:`h-3 w-3 text-amber-500 fill-amber-500 flex-shrink-0`})]}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:e.model})]}),l&&(0,J.jsx)(`div`,{className:`flex-shrink-0`,children:(0,J.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-primary-500 dark:bg-primary-600 flex items-center justify-center`,children:(0,J.jsx)(g,{className:`h-3 w-3 text-white rtl:rotate-180`})})})]}):(0,J.jsxs)(`div`,{className:i(`group relative overflow-hidden rounded-2xl transition-[border-color,background-color] duration-200`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`hover:border-gray-300 dark:hover:border-white/20`,l&&[`ring-2 ring-primary-500 dark:ring-primary-400`,`border-primary-300 dark:border-primary-600`]),children:[(0,J.jsxs)(`div`,{className:`relative h-24`,children:[e.background?(0,J.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${e.background})`}}):(0,J.jsx)(`div`,{className:`absolute inset-0 bg-gray-200 dark:bg-dark-200`}),e.background&&(0,J.jsx)(`div`,{className:`absolute inset-0 bg-black/15 dark:bg-black/25`}),(0,J.jsxs)(`div`,{className:`absolute inset-x-3 top-3 flex items-start justify-between`,children:[(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),c?.(e)},className:i(`p-1.5 rounded-full transition-all duration-200`,`border border-white/30 bg-black/20 text-white backdrop-blur-sm hover:bg-black/30`,e.is_favorite&&`bg-amber-500/80 hover:bg-amber-500`),children:(0,J.jsx)(M,{className:i(`h-4 w-4`,e.is_favorite?`fill-ink text-ink dark:fill-ink-inverse dark:text-ink-inverse`:`text-white/80 hover:text-white`)})}),O&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 rounded-full border border-white/30 bg-black/20 px-2 py-1 text-[10px] font-medium text-white backdrop-blur-sm`,children:[(0,J.jsx)(D,{className:`h-3 w-3`}),d(`personaCard.enhanced`)]})]})]}),(0,J.jsx)(`div`,{className:`relative -mt-8 px-4`,children:(0,J.jsxs)(`div`,{className:`relative inline-block`,children:[(0,J.jsx)(`img`,{src:V(128),alt:e.name,className:`h-16 w-16 rounded-xl object-cover ring-4 ring-white dark:ring-dark-100`,onError:H(128)}),O&&(0,J.jsx)(`div`,{className:`absolute -bottom-1 -end-1 flex h-6 w-6 items-center justify-center rounded-lg bg-primary-600 ring-2 ring-white dark:ring-dark-100`,children:(0,J.jsx)(k,{className:`h-3.5 w-3.5 text-white`})})]})}),(0,J.jsxs)(`div`,{className:`px-4 pt-3 pb-4`,children:[(0,J.jsxs)(`div`,{className:`mb-3`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 leading-tight`,children:e.name}),(0,J.jsxs)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 flex items-center gap-1.5 mt-0.5`,children:[(0,J.jsx)(s,{className:`h-3.5 w-3.5`}),e.model]})]}),e.description&&(0,J.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2 mb-3`,children:e.description}),e.parameters.system_prompt&&(0,J.jsxs)(`div`,{className:`mb-3 rounded-xl border border-gray-200/70 bg-gray-50/70 p-2.5 dark:border-white/[0.08] dark:bg-white/[0.025]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,J.jsx)(N,{className:`h-3 w-3 text-gray-400 dark:text-gray-500`}),(0,J.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider font-medium text-gray-400 dark:text-gray-500`,children:d(`personaCard.systemPrompt`)})]}),(0,J.jsxs)(`p`,{className:`line-clamp-2 text-xs leading-5 text-gray-600 dark:text-gray-400`,children:[`“`,e.parameters.system_prompt,`”`]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[(0,J.jsx)(A,{className:`h-3 w-3`}),e.parameters.temperature?.toFixed(1)||`0.7`]}),(0,J.jsxs)(`span`,{className:`inline-flex items-center rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[`Top-P `,e.parameters.top_p?.toFixed(1)||`0.9`]}),(0,J.jsxs)(`span`,{className:`inline-flex items-center rounded-lg border border-gray-200/70 px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-white/[0.08] dark:text-gray-400`,children:[(e.parameters.context_window||4096).toLocaleString(),` ctx`]})]}),O&&P&&(0,J.jsx)(`div`,{className:`mb-3 rounded-xl border border-primary-200/70 bg-primary-50/50 p-2.5 dark:border-primary-800/40 dark:bg-primary-900/10`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(j,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`span`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300`,children:[P.memory_count,` `,d(`personaCard.memories`)]}),(0,J.jsx)(`span`,{className:`ms-2 text-[10px] text-primary-600/70 dark:text-primary-400/70`,children:(e=>e<1?`${(e*1024).toFixed(0)} KB`:`${e.toFixed(1)} MB`)(P.size_mb)})]})]}),P.status&&(0,J.jsx)(`span`,{className:i(`text-[10px] px-1.5 py-0.5 rounded-full font-medium`,P.status===`active`?`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`),children:P.status})]})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-200/70 pt-3 dark:border-white/[0.08]`,children:[o&&(0,J.jsxs)(U,{onClick:()=>o(e),size:`sm`,className:`px-4`,children:[(0,J.jsx)(g,{className:`me-1.5 h-3.5 w-3.5 rtl:rotate-180`}),d(`personaCard.use`)]}),(0,J.jsxs)(`div`,{className:`ms-auto flex items-center gap-1`,children:[(0,J.jsx)(`button`,{onClick:()=>t(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:d(`personaCard.editTooltip`),children:(0,J.jsx)(m,{className:`h-4 w-4`})}),!e.shared&&(0,J.jsx)(`button`,{onClick:()=>x(!0),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:d(`personaCard.shareTooltip`),"data-testid":`persona-share`,children:(0,J.jsx)(p,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{onClick:()=>a(e),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:d(`personaCard.downloadTooltip`),children:(0,J.jsx)(b,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(`button`,{onClick:()=>_(!h),className:`p-2 rounded-lg text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-dark-200 transition-colors`,title:d(`common.more`,{defaultValue:`More`}),children:(0,J.jsx)(T,{className:`h-4 w-4`})}),h&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>_(!1)}),(0,J.jsxs)(`div`,{className:`absolute end-0 bottom-full z-20 mb-1 w-44 rounded-xl border border-gray-200 bg-white py-1 shadow-lg dark:border-white/10 dark:bg-dark-100`,children:[O&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{onClick:L,disabled:S,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,J.jsx)(te,{className:`h-4 w-4`}),d(`personaCard.backup`)]}),(0,J.jsxs)(`button`,{onClick:ne,disabled:S,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-dark-50 disabled:opacity-50`,children:[(0,J.jsx)(ee,{className:`h-4 w-4`}),d(`personaCard.exportDNA`)]}),P&&P.memory_count>0&&(0,J.jsxs)(`button`,{onClick:I,disabled:S,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 disabled:opacity-50`,children:[(0,J.jsx)(E,{className:`h-4 w-4`}),d(`personaCard.wipeMemories`)]}),(0,J.jsx)(`div`,{className:`my-1 border-t border-gray-100 dark:border-dark-200`})]}),(0,J.jsxs)(`button`,{onClick:()=>{n(e),_(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20`,children:[(0,J.jsx)(y,{className:`h-4 w-4`}),d(`common.delete`)]})]})]})]})]})]})]}),v&&(0,J.jsx)(ie,{resourceType:`persona`,resourceId:e.id,resourceLabel:e.name,onClose:()=>x(!1)})]})},X={name:``,description:``,model:``,parameters:{temperature:.7,top_p:.9,top_k:40,context_window:4096,max_tokens:1024,system_prompt:``,repeat_penalty:1.1,presence_penalty:0,frequency_penalty:0},avatar:``,background:``,embedding_model:``,memory_settings:{enabled:!1,max_memories:1e3,auto_cleanup:!0,retention_days:90},mutation_settings:{enabled:!1,sensitivity:`medium`,auto_adapt:!0}};function se({embeddingModel:e,embeddingModels:t,onEmbeddingModelChange:n}){let{t:i}=r(),a=t.filter(e=>e.isDetectedEmbedding),o=t.filter(e=>!e.isDetectedEmbedding);return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`rounded-xl p-5 bg-gradient-to-br from-primary-50 to-primary-100/50 dark:from-primary-900/30 dark:to-primary-800/20 border border-primary-200/50 dark:border-primary-700/30`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,J.jsx)(j,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}),(0,J.jsx)(`h3`,{className:`font-semibold text-primary-900 dark:text-primary-100`,children:i(`personaForm.advanced.embeddingModel`)})]}),(0,J.jsx)(`p`,{className:`text-xs text-primary-600 dark:text-primary-400 mb-3`,children:i(`personaForm.advanced.embeddingHint`)}),(0,J.jsx)(`select`,{value:e,onChange:e=>n(e.target.value),className:`w-full px-3 py-2.5 border border-primary-200 dark:border-primary-700 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20`,children:t.length===0?(0,J.jsx)(`option`,{value:``,disabled:!0,children:i(`personaForm.advanced.noModels`)}):(0,J.jsxs)(J.Fragment,{children:[a.length>0&&(0,J.jsx)(`optgroup`,{label:i(`personaForm.advanced.embeddingModels`),children:a.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))}),o.length>0&&(0,J.jsx)(`optgroup`,{label:i(`personaForm.advanced.otherModels`),children:o.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))})]})}),t.length===0&&(0,J.jsx)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-700/50 dark:bg-amber-900/20`,children:(0,J.jsxs)(`p`,{className:`text-sm text-ink`,children:[i(`personaForm.advanced.installHint`),` `,(0,J.jsx)(`code`,{className:`rounded bg-amber-500/20 px-1.5 py-0.5 text-xs dark:bg-amber-900/40`,children:`ollama pull nomic-embed-text`})]})}),(0,J.jsx)(`p`,{className:`text-[10px] text-primary-500 dark:text-primary-500 mt-2`,children:i(`personaForm.advanced.recommended`)})]}),(0,J.jsx)(`div`,{className:`p-4 bg-gray-50 dark:bg-dark-50 rounded-xl border border-gray-200 dark:border-dark-300`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(u,{className:`h-5 w-5 text-gray-400 mt-0.5 flex-shrink-0`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:i(`personaForm.advanced.aboutTitle`)}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:i(`personaForm.advanced.aboutDescription`)})]})]})})]})}var ce=P(`components:persona-background-upload`),le=({value:e,onChange:t,className:n=``})=>{let{t:i}=r(),a=(0,q.useRef)(null),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(!1),u=async e=>{if(!e.type.startsWith(`image/`)){C.error(i(`personaBackground.invalidFile`));return}if(e.size>5242880){C.error(i(`personaBackground.fileTooLarge`));return}s(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),C.success(i(`personaBackground.uploaded`))},n.onerror=()=>{C.error(i(`personaBackground.readFailed`))},n.readAsDataURL(e)}catch(e){ce.error(`Failed to upload background:`,e),C.error(i(`personaBackground.uploadFailed`))}finally{s(!1)}};return(0,J.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:i(`personaBackground.label`)}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[e?(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`div`,{className:`w-full h-32 rounded-lg bg-cover bg-center border-2 border-gray-300 dark:border-dark-300`,style:{backgroundImage:`url(${e})`}}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:i(`personaBackground.customBackground`)}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:i(`personaBackground.clickToChange`)})]}),(0,J.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>{t(``),C.success(i(`personaBackground.removed`))},className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,J.jsx)(O,{className:`h-4 w-4`})})]})]}):(0,J.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${c?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:e=>{e.preventDefault(),l(!1)},onDrop:e=>{e.preventDefault(),l(!1);let t=e.dataTransfer.files?.[0];t&&u(t)},onClick:()=>a.current?.click(),children:[(0,J.jsx)(d,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,J.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:i(`personaBackground.uploadBackgroundImage`)}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:i(`personaBackground.dragAndDrop`)}),(0,J.jsxs)(U,{variant:`outline`,size:`sm`,disabled:o,className:`mx-auto`,children:[(0,J.jsx)(S,{className:`h-4 w-4 mr-2`}),i(o?`personaBackground.uploading`:`personaBackground.chooseImage`)]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:i(`personaBackground.enterImageUrl`)}),(0,J.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/background.jpg`})]})]}),(0,J.jsx)(`input`,{ref:a,type:`file`,accept:`image/*`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)},className:`hidden`}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:i(`personaBackground.supportedFormats`)})]})})};function ue({formData:e,availableModels:t,onFieldChange:n,onParameterChange:i}){let{t:a}=r(),o=(0,q.useMemo)(()=>t.filter(e=>!e.isPlugin),[t]),s=(0,q.useMemo)(()=>{let e=new Map;for(let n of t){if(!n.isPlugin)continue;let t=n.pluginName||n.pluginId||`Provider`,r=e.get(t);r?r.push(n):e.set(t,[n])}return[...e.entries()].sort(([e],[t])=>e.localeCompare(t))},[t]);return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[a(`personaForm.basic.name`),` *`]}),(0,J.jsx)(`input`,{type:`text`,value:e.name,onChange:e=>n(`name`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,placeholder:a(`personaForm.basic.namePlaceholder`),required:!0})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:[a(`personaForm.basic.model`),` *`]}),(0,J.jsxs)(`select`,{value:e.model,onChange:e=>n(`model`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors`,required:!0,children:[(0,J.jsx)(`option`,{value:``,children:a(`personaForm.basic.selectModel`)}),e.model&&!t.some(t=>t.name===e.model)&&(0,J.jsx)(`option`,{value:e.model,children:e.model}),o.length>0&&(0,J.jsx)(`optgroup`,{label:`Ollama`,children:o.map(e=>(0,J.jsx)(`option`,{value:e.name,children:e.name},e.name))}),s.map(([e,t])=>(0,J.jsx)(`optgroup`,{label:e,children:t.map(e=>(0,J.jsx)(`option`,{value:e.name,children:e.name},e.name))},e))]})]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:a(`personaForm.basic.description`)}),(0,J.jsx)(`textarea`,{value:e.description,onChange:e=>n(`description`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none`,rows:3,placeholder:a(`personaForm.basic.descriptionPlaceholder`)})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,J.jsx)(ae,{value:e.avatar||``,onChange:e=>n(`avatar`,e)}),(0,J.jsx)(le,{value:e.background||``,onChange:e=>n(`background`,e)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:a(`personaForm.basic.systemPrompt`)}),(0,J.jsx)(`textarea`,{value:e.parameters.system_prompt,onChange:e=>i(`system_prompt`,e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-colors resize-none font-mono text-sm`,rows:6,placeholder:a(`personaForm.basic.systemPromptPlaceholder`)}),(0,J.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-2`,children:a(`personaForm.basic.systemPromptHint`)})]})]})}function de({persona:e,submitting:t,saveAndClose:n,lastSaved:i,onCancel:a,onSave:o,onSaveAndClose:s}){let{t:l}=r();return(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(U,{type:`button`,variant:`ghost`,onClick:a,disabled:t,className:`text-gray-600 dark:text-gray-400`,children:l(`personaForm.actions.cancel`)}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,J.jsx)(c,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{children:l(`personaForm.saved`)})]}),(0,J.jsx)(U,{type:`button`,variant:`outline`,onClick:o,disabled:t,children:l(t&&!n?`personaForm.actions.saving`:`personaForm.actions.save`)}),(0,J.jsx)(U,{type:`button`,onClick:s,disabled:t,children:l(t&&n?`personaForm.actions.saving`:e?`personaForm.actions.saveClose`:`personaForm.actions.create`)})]})]})}var fe=P(`components:persona-bindings`),pe=[`web_search`,`search_documents`,`list_documents`,`read_document`,`load_skill`];function me({bindings:e,onChange:t}){let{t:n}=r(),[i,a]=(0,q.useState)([]),[o,s]=(0,q.useState)([]),[c,l]=(0,q.useState)([]),[u,d]=(0,q.useState)([]),[f,p]=(0,q.useState)(!0);(0,q.useEffect)(()=>{let e=!1;return Promise.all([I.listServers(),L.list(),V.list(),F.getCollections()]).then(([t,n,r,i])=>{e||(t.success&&t.data&&a(t.data),n.success&&n.data&&s(n.data),r.success&&r.data&&l(r.data),i.success&&i.data&&d(i.data))}).catch(e=>{fe.error(`Failed to load bindable resources:`,e)}).finally(()=>{e||p(!1)}),()=>{e=!0}},[]);let m=n=>t({...e??{},...n}),g=(t,n)=>{let r=e?.[t]??[];m({[t]:r.includes(n)?r.filter(e=>e!==n):[...r,n]})};return f?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,J.jsx)(h,{className:`h-5 w-5 animate-spin text-gray-400`})}):(0,J.jsxs)(`div`,{className:`space-y-6`,"data-testid":`persona-bindings-tab`,children:[(0,J.jsx)(Z,{title:n(`personaForm.bindings.toolServers`),hint:n(`personaForm.bindings.toolServersHint`),emptyLabel:n(`personaForm.bindings.noToolServers`),options:i.map(e=>({id:e.id,label:e.name,detail:e.description})),selected:e?.tool_server_ids??[],onToggle:e=>g(`tool_server_ids`,e),testId:`persona-binding-tool-servers`}),(0,J.jsx)(Z,{title:n(`personaForm.bindings.builtinTools`),hint:n(`personaForm.bindings.builtinToolsHint`),emptyLabel:n(`personaForm.bindings.noBuiltinTools`),options:pe.map(e=>({id:e,label:n(`personaForm.bindings.builtin.${e}`),detail:e})),selected:e?.builtin_tools??[],onToggle:e=>g(`builtin_tools`,e),testId:`persona-binding-builtin-tools`}),(0,J.jsx)(Z,{title:n(`personaForm.bindings.skills`),hint:n(`personaForm.bindings.skillsHint`),emptyLabel:n(`personaForm.bindings.noSkills`),options:o.map(e=>({id:e.id,label:e.name,detail:`$${e.slug}`})),selected:e?.skill_ids??[],onToggle:e=>g(`skill_ids`,e),testId:`persona-binding-skills`}),(0,J.jsx)(Z,{title:n(`personaForm.bindings.collections`),hint:n(`personaForm.bindings.collectionsHint`),emptyLabel:n(`personaForm.bindings.noCollections`),options:u.map(e=>({id:e.id,label:e.name})),selected:e?.knowledge_collection_ids??[],onToggle:t=>{let n=e?.knowledge_collection_ids??[];m({knowledge_collection_ids:n.includes(t)?n.filter(e=>e!==t):[...n,t]})},testId:`persona-binding-collections`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-800`,children:n(`personaForm.bindings.prompt`)}),(0,J.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-gray-500 dark:text-dark-600`,children:n(`personaForm.bindings.promptHint`)}),(0,J.jsxs)(`select`,{value:e?.prompt_id??``,onChange:e=>m({prompt_id:e.target.value||void 0}),"data-testid":`persona-binding-prompt`,"aria-label":n(`personaForm.bindings.prompt`),className:`w-full rounded-lg border border-gray-200 bg-white px-3 py-2.5 text-sm text-gray-900 focus:ring-2 focus:ring-primary-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,J.jsx)(`option`,{value:``,children:n(`personaForm.bindings.noPrompt`)}),c.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,J.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:n(`personaForm.bindings.version`,{version:e?.version??0})})]})}function Z({title:e,hint:t,emptyLabel:n,options:r,selected:i,onToggle:a,testId:o}){return(0,J.jsxs)(`div`,{"data-testid":o,children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-800`,children:e}),(0,J.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-gray-500 dark:text-dark-600`,children:t}),r.length===0?(0,J.jsx)(`p`,{className:`rounded-lg border border-dashed border-gray-200 px-3 py-4 text-center text-xs text-gray-400 dark:border-dark-300 dark:text-dark-500`,children:n}):(0,J.jsx)(`div`,{className:`space-y-1`,children:r.map(e=>(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-1.5 transition-colors hover:bg-gray-50 dark:hover:bg-dark-200`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:i.includes(e.id),onChange:()=>a(e.id),className:`h-4 w-4 rounded border-gray-300 dark:border-dark-400`}),(0,J.jsx)(`span`,{className:`text-sm text-gray-900 dark:text-dark-800`,children:e.label}),e.detail&&(0,J.jsx)(`span`,{className:`truncate text-xs text-gray-400 dark:text-dark-500`,children:e.detail})]},e.id))})]})}var Q=({label:e,value:t,min:n,max:r,step:a,onChange:o,hint:s,format:c=e=>String(e),colorClass:l=`text-gray-700 dark:text-dark-600`})=>{let u=(t-n)/(r-n)*100;return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`label`,{className:i(`block text-sm font-medium`,l),children:e}),(0,J.jsx)(`input`,{type:`number`,min:n,max:r,step:a,value:c(t),onChange:e=>{let t=parseFloat(e.target.value);isNaN(t)||o(Math.min(r,Math.max(n,t)))},className:`w-20 px-2 py-1 text-sm text-right bg-gray-100 dark:bg-dark-200 border border-gray-300 dark:border-dark-300 rounded focus:outline-none focus:ring-1 focus:ring-primary-500 dark:text-dark-600`})]}),(0,J.jsx)(`input`,{type:`range`,min:n,max:r,step:a,value:t,onChange:e=>o(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 dark:bg-dark-200 rounded-lg appearance-none cursor-pointer slider`,style:{"--progress":`${u}%`}}),s&&(0,J.jsx)(`p`,{className:i(`text-xs mt-1`,l.replace(`700`,`500`).replace(`600`,`400`)),children:s})]})},$=({label:e,checked:t,onChange:n,colorClass:r=`text-gray-700 dark:text-dark-600`})=>(0,J.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,J.jsx)(`div`,{className:i(`relative w-10 h-5 rounded-full transition-colors`,t?`bg-primary-500 dark:bg-primary-600`:`bg-gray-300 dark:bg-dark-300`),onClick:()=>n(!t),children:(0,J.jsx)(`div`,{className:i(`absolute top-0.5 start-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-5 rtl:-translate-x-5`)})}),(0,J.jsx)(`span`,{className:i(`text-sm font-medium`,r),children:e})]});function he({formData:e,persona:t,memoryStatus:n,loadingMemoryStatus:a,wipingMemories:o,onSettingsChange:s,onWipeMemories:c}){let{t:u}=r();return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-emerald-200/50 dark:border-emerald-700/30`,children:[(0,J.jsx)(`div`,{className:`px-5 py-4 bg-gradient-to-r from-emerald-500 to-teal-500 dark:from-emerald-600 dark:to-teal-600`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,J.jsx)(j,{className:`h-5 w-5 text-white`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`font-semibold text-white`,children:u(`personaForm.memory.title`)}),(0,J.jsx)(`p`,{className:`text-xs text-white/80`,children:u(`personaForm.memory.subtitle`)})]})]}),(0,J.jsx)($,{label:``,checked:e.memory_settings?.enabled||!1,onChange:e=>s(`memory_settings`,{enabled:e})})]})}),e.memory_settings?.enabled&&t?.id&&(0,J.jsx)(`div`,{className:`px-5 py-4 bg-emerald-50 dark:bg-emerald-900/20 border-b border-emerald-100 dark:border-emerald-800/30`,children:a?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-emerald-600 dark:text-emerald-400`,children:[(0,J.jsx)(f,{className:`h-4 w-4 animate-spin`}),u(`personaForm.memory.loading`)]}):n?(0,J.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,J.jsx)(j,{className:`h-5 w-5`}),n.memory_count.toLocaleString()]}),(0,J.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:u(`personaForm.memory.memories`)})]}),(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,J.jsx)(_,{className:`h-5 w-5`}),n.size_mb.toFixed(1)]}),(0,J.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:u(`personaForm.memory.mbUsed`)})]}),(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-2xl font-bold text-emerald-700 dark:text-emerald-300`,children:[(0,J.jsx)(l,{className:`h-5 w-5`}),n.last_backup?new Date(n.last_backup).toLocaleDateString():u(`personaForm.memory.never`)]}),(0,J.jsx)(`p`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:u(`personaForm.memory.lastBackup`)})]})]}):(0,J.jsx)(`p`,{className:`text-sm text-emerald-600 dark:text-emerald-400`,children:u(`personaForm.memory.noData`)})}),e.memory_settings?.enabled&&(0,J.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-4`,children:[(0,J.jsx)(Q,{label:u(`personaForm.memory.maxMemories`),value:e.memory_settings.max_memories,min:100,max:1e4,step:100,hint:u(`personaForm.memory.maxMemoriesHint`),format:e=>e.toLocaleString(),colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>s(`memory_settings`,{max_memories:e})}),(0,J.jsx)(Q,{label:u(`personaForm.memory.retention`),value:e.memory_settings.retention_days,min:7,max:365,step:7,hint:u(`personaForm.memory.retentionHint`),format:e=>`${Math.round(e)} days`,colorClass:`text-emerald-700 dark:text-emerald-300`,onChange:e=>s(`memory_settings`,{retention_days:e})}),(0,J.jsx)($,{label:u(`personaForm.memory.autoCleanup`),checked:e.memory_settings.auto_cleanup,onChange:e=>s(`memory_settings`,{auto_cleanup:e}),colorClass:`text-emerald-700 dark:text-emerald-300`}),t?.id&&n&&n.memory_count>0&&(0,J.jsx)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800/30`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-medium text-red-700 dark:text-red-300`,children:u(`personaForm.memory.wipeAll`)}),(0,J.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u(`personaForm.memory.wipeCannot`)})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:c,disabled:o,className:`px-3 py-1.5 bg-red-500 hover:bg-red-600 text-white text-sm font-medium rounded-lg transition-colors disabled:opacity-50 flex items-center gap-1.5`,children:[o?(0,J.jsx)(f,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(y,{className:`h-3.5 w-3.5`}),u(o?`personaForm.memory.wiping`:`personaForm.memory.wipeButton`)]})]})})]}),!e.memory_settings?.enabled&&(0,J.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,J.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:u(`personaForm.memory.enableHint`)})})]}),(0,J.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-primary-200/50 dark:border-primary-700/30`,children:[(0,J.jsx)(`div`,{className:`px-5 py-4 bg-primary-600 dark:bg-primary-600`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-white/20 flex items-center justify-center`,children:(0,J.jsx)(w,{className:`h-5 w-5 text-white`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`font-semibold text-white`,children:u(`personaForm.learning.title`)}),(0,J.jsx)(`p`,{className:`text-xs text-white/80`,children:u(`personaForm.learning.subtitle`)})]})]}),(0,J.jsx)($,{label:``,checked:e.mutation_settings?.enabled||!1,onChange:e=>s(`mutation_settings`,{enabled:e})})]})}),e.mutation_settings?.enabled&&(0,J.jsxs)(`div`,{className:`p-5 bg-white dark:bg-dark-100 space-y-5`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-primary-700 dark:text-primary-300 mb-3`,children:u(`personaForm.learning.speed`)}),(0,J.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:[{level:`low`,icon:A,label:u(`personaForm.learning.slow`),desc:u(`personaForm.learning.slowDesc`)},{level:`medium`,icon:w,label:u(`personaForm.learning.balanced`),desc:u(`personaForm.learning.balancedDesc`)},{level:`high`,icon:D,label:u(`personaForm.learning.fast`),desc:u(`personaForm.learning.fastDesc`)}].map(({level:t,icon:n,label:r,desc:a})=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>s(`mutation_settings`,{sensitivity:t}),className:i(`p-3 rounded-xl text-center transition-all border`,e.mutation_settings?.sensitivity===t?`bg-primary-600 border-primary-600 text-white shadow-lg`:`bg-primary-50 dark:bg-primary-900/20 border-primary-200 dark:border-primary-700/30 text-primary-700 dark:text-primary-300 hover:bg-primary-100 dark:hover:bg-primary-900/30`),children:[(0,J.jsx)(n,{className:`h-5 w-5 mx-auto mb-1`}),(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:r}),(0,J.jsx)(`p`,{className:`text-[10px] opacity-70`,children:a})]},t))})]}),(0,J.jsx)($,{label:u(`personaForm.learning.autoAdapt`),checked:e.mutation_settings.auto_adapt,onChange:e=>s(`mutation_settings`,{auto_adapt:e}),colorClass:`text-primary-700 dark:text-primary-300`}),(0,J.jsxs)(`div`,{className:`p-4 bg-primary-50 dark:bg-primary-900/20 rounded-xl`,children:[(0,J.jsxs)(`p`,{className:`text-xs font-medium text-primary-700 dark:text-primary-300 mb-2 flex items-center gap-1.5`,children:[(0,J.jsx)(k,{className:`h-3.5 w-3.5`}),u(`personaForm.learning.whatLearns`)]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-primary-600 dark:text-primary-400`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),u(`personaForm.learning.conversationTone`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),u(`personaForm.learning.responseStyle`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),u(`personaForm.learning.userPreferences`)]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(`div`,{className:`w-1 h-1 rounded-full bg-primary-400`}),u(`personaForm.learning.topicInterests`)]})]})]})]}),!e.mutation_settings?.enabled&&(0,J.jsx)(`div`,{className:`p-5 bg-gray-50 dark:bg-dark-50`,children:(0,J.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:u(`personaForm.learning.enableHint`)})})]})]})}function ge({parameters:e,onParameterChange:t}){let{t:n}=r(),i=(0,q.useMemo)(()=>[{key:`temperature`,label:n(`personaForm.parameters.temperature`),min:0,max:2,step:.1,hint:n(`personaForm.parameters.temperatureHint`),format:e=>e.toFixed(1)},{key:`top_p`,label:n(`personaForm.parameters.topP`),min:0,max:1,step:.1,hint:n(`personaForm.parameters.topPHint`),format:e=>e.toFixed(1)},{key:`top_k`,label:n(`personaForm.parameters.topK`),min:1,max:100,step:1,hint:n(`personaForm.parameters.topKHint`),format:e=>String(Math.round(e))},{key:`context_window`,label:n(`personaForm.parameters.contextWindow`),min:128,max:131072,step:128,hint:n(`personaForm.parameters.contextWindowHint`),format:e=>String(Math.round(e))},{key:`max_tokens`,label:n(`personaForm.parameters.maxTokens`),min:1,max:8192,step:1,hint:n(`personaForm.parameters.maxTokensHint`),format:e=>String(Math.round(e))},{key:`repeat_penalty`,label:n(`personaForm.parameters.repeatPenalty`),min:.5,max:2,step:.1,hint:n(`personaForm.parameters.repeatPenaltyHint`),format:e=>e.toFixed(1)}],[n]);return(0,J.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:i.map(({key:n,label:r,min:i,max:a,step:o,hint:s,format:c})=>(0,J.jsx)(Q,{label:r,value:e[n]||0,min:i,max:a,step:o,hint:s,format:c,onChange:e=>t(n,e)},n))})}var _e=P(`components:persona-form`),ve=({persona:e,onSubmit:t,onCancel:n})=>{let{preferences:s}=H(),{t:c}=r(),[l,u]=(0,q.useState)(X),d=a(e=>e.models),f=a(e=>e.loadModels),p=(0,q.useMemo)(()=>d.filter(e=>!e.isPersona&&!e.isAgent&&!e.isUnavailable&&!e.isLegacySelection),[d]),[m,h]=(0,q.useState)([]),[g,_]=(0,q.useState)(!1),[y,b]=(0,q.useState)(!1),[ee,S]=(0,q.useState)(!1),[w,T]=(0,q.useState)(null),[E,O]=(0,q.useState)(`basic`),[te,A]=(0,q.useState)(!1),j=(0,q.useRef)(!1),M=(0,q.useCallback)((e,t)=>{u(n=>({...n,[e]:t})),T(null)},[]),N=(0,q.useCallback)((e,t)=>{u(n=>({...n,parameters:{...n.parameters,[e]:t}})),T(null)},[]),P=(0,q.useCallback)((e,t)=>{u(n=>({...n,[e]:{...n[e],...t}})),T(null)},[]),F=(0,q.useCallback)(e=>{let t=e.reduce((e,t)=>(e.find(e=>e.id===t.id)||e.push(t),e),[]);return t.length>0?t:[{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]},[]),I=e?.id,L=!!l.memory_settings?.enabled,R=K(),{data:z=null,isLoading:V}=G({queryKey:[`persona-memory-status`,I],queryFn:async()=>{if(!I)return null;let e=await B.getMemoryStatus(I);return e.success&&e.data?e.data:null},enabled:!!I&&L}),U=()=>R.invalidateQueries({queryKey:[`persona-memory-status`,I]}),re=async()=>{if(e?.id&&confirm(c(`personaForm.memory.wipeConfirm`))){A(!0);try{let t=await B.wipeMemories(e.id);t.success?(C.success(c(`personaForm.memory.wipeSuccess`,{count:t.data?.deleted_count||0})),await U()):C.error(c(`personaForm.error.saveFailed`))}catch{C.error(c(`personaForm.error.saveFailed`))}finally{A(!1)}}};(0,q.useEffect)(()=>{j.current||(j.current=!0,(async()=>{_(!0);try{let[t,n]=await Promise.all([ne.getModels(),e?Promise.resolve(null):B.getDefaultParameters(),a.getState().models.length===0?f({quiet:!0}):Promise.resolve()]),r=F(t.success&&t.data?t.data:[]);h(r);let i=r.find(e=>e.id===s.embeddingSettings?.model||e.rawModel===s.embeddingSettings?.model)?.id||r[0]?.id||``,o=r.find(t=>t.id===e?.embedding_model||t.rawModel===e?.embedding_model)?.id||e?.embedding_model||r[0]?.id||``;if(e)u({name:e.name,description:e.description||``,model:e.model,parameters:e.parameters,avatar:e.avatar||``,background:e.background||``,embedding_model:o,memory_settings:e.memory_settings||X.memory_settings,mutation_settings:e.mutation_settings||X.mutation_settings,bindings:e.bindings}),e.embedding_model&&!r.find(t=>t.id===e.embedding_model||t.rawModel===e.embedding_model)&&h(t=>F([...t,{id:e.embedding_model,name:e.embedding_model,description:`Previously selected model (not currently available)`,provider:`openai`,dimensions:0}]));else{let e=n?.success?n.data:{};u(t=>({...t,parameters:{...t.parameters,...e},embedding_model:i}))}}catch(e){_e.error(`Error loading data:`,e)}finally{_(!1)}})())},[e,F,f,s.embeddingSettings?.model]);let W=async n=>{b(!0),S(n);try{let r={name:l.name,description:l.description,model:l.model,parameters:l.parameters,avatar:l.avatar,background:l.background,embedding_model:l.embedding_model,memory_settings:l.memory_settings,mutation_settings:l.mutation_settings,bindings:l.bindings},i=e?await B.updatePersona(e.id,r):await B.createPersona(l);i.success?(C.success(c(e?`personaForm.success.updated`:`personaForm.success.created`)),T(new Date),n&&t()):C.error(`${c(`personaForm.error.saveFailed`)}: ${i.error}`)}catch(e){C.error(`${c(`personaForm.error.saveFailed`)}: ${e instanceof Error?e.message:String(e)}`)}finally{b(!1),S(!1)}},ie=(0,q.useMemo)(()=>[{id:`basic`,label:c(`personaForm.tabs.basic`),icon:x},{id:`parameters`,label:c(`personaForm.tabs.parameters`),icon:o},{id:`memory`,label:c(`personaForm.tabs.memory`),icon:D},{id:`bindings`,label:c(`personaForm.tabs.bindings`),icon:v},{id:`advanced`,label:c(`personaForm.tabs.advanced`),icon:k}],[c]);return g?(0,J.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,J.jsxs)(`div`,{className:`animate-pulse flex items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary-500 border-t-transparent rounded-full animate-spin`}),(0,J.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:c(`personaForm.loading`)})]})}):(0,J.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,J.jsxs)(`div`,{className:`mb-6`,children:[(0,J.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:c(e?`personaForm.title.edit`:`personaForm.title.create`)}),(0,J.jsxs)(`div`,{className:`flex items-center gap-4 mt-1`,children:[(0,J.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600`,children:c(e?`personaForm.subtitle.edit`:`personaForm.subtitle.create`)}),w&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,J.jsx)(`div`,{className:`w-2 h-2 bg-green-500 rounded-full`}),c(`personaForm.saved`),` `,w.toLocaleTimeString()]})]})]}),(0,J.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,J.jsx)(`div`,{className:`flex border-b border-gray-200 dark:border-dark-300`,children:ie.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>O(e.id),className:i(`flex items-center gap-2 px-6 py-4 text-sm font-medium transition-colors`,E===e.id?`border-b-2 border-primary-500 text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-dark-600 hover:text-gray-700 dark:hover:text-dark-800`),children:[(0,J.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.id))}),(0,J.jsxs)(`div`,{className:`p-6`,children:[E===`basic`&&(0,J.jsx)(ue,{formData:l,availableModels:p,onFieldChange:M,onParameterChange:N}),E===`parameters`&&(0,J.jsx)(ge,{parameters:l.parameters,onParameterChange:N}),E===`memory`&&(0,J.jsx)(he,{formData:l,persona:e,memoryStatus:z,loadingMemoryStatus:V,wipingMemories:te,onSettingsChange:P,onWipeMemories:re}),E===`bindings`&&(0,J.jsx)(me,{bindings:l.bindings,onChange:e=>M(`bindings`,e)}),E===`advanced`&&(0,J.jsx)(se,{embeddingModel:l.embedding_model,embeddingModels:m,onEmbeddingModelChange:e=>M(`embedding_model`,e)})]})]}),(0,J.jsx)(de,{persona:e,submitting:y,saveAndClose:ee,lastSaved:w,onCancel:n,onSave:()=>W(!1),onSaveAndClose:()=>W(!0)})]})]})},ye=P(`components:persona-import-export`),be=({personas:e,onImport:t,onClose:n})=>{let{t:i}=r(),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(``),l=async e=>{try{let t=await B.exportPersona(e.id),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=`${e.name}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r),C.success(i(`personaImportExport.exportSuccess`,{name:e.name}))}catch(e){let t=e instanceof Error?e.message:String(e);C.error(i(`personaImportExport.exportFailed`)+`: `+t)}};return(0,J.jsxs)(`div`,{className:`max-w-4xl mx-auto`,children:[(0,J.jsxs)(`div`,{className:`mb-6`,children:[(0,J.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-dark-800`,children:i(`personaImportExport.title`)}),(0,J.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mt-1`,children:i(`personaImportExport.description`)})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,J.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:i(`personaImportExport.exportPersonas`)}),e.length===0?(0,J.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-center py-8`,children:i(`personaImportExport.noPersonasToExport`)}):(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,J.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-dark-600`,children:i(`personaImportExport.personasAvailable`,{count:e.length})}),(0,J.jsx)(U,{onClick:async()=>{try{let t=e.map(e=>B.exportPersona(e.id)),n=await Promise.all(t),r={personas:n,exportedAt:Date.now(),version:`1.0.0`,count:n.length},a=new Blob([JSON.stringify(r,null,2)],{type:`application/json`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=`personas-export-${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o),C.success(i(`personaImportExport.exportAllSuccess`,{count:e.length}))}catch(e){let t=e instanceof Error?e.message:String(e);C.error(i(`personaImportExport.exportAllFailed`)+`: `+t)}},variant:`outline`,size:`sm`,className:`px-3 py-1`,children:i(`personaImportExport.exportAll`)})]}),(0,J.jsx)(`div`,{className:`space-y-2 max-h-80 overflow-y-auto`,children:e.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-gray-50 dark:bg-dark-200 rounded-md`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`img`,{src:z(e,32),alt:e.name,className:`w-8 h-8 rounded-full`,onError:t=>R(t.currentTarget,e.name,32)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),(0,J.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e.model})]})]}),(0,J.jsx)(U,{onClick:()=>l(e),variant:`outline`,size:`sm`,className:`px-3 py-1`,children:i(`common.export`)})]},e.id))})]})]}),(0,J.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-6 shadow-sm border border-gray-200 dark:border-dark-300`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-4`,children:i(`personaImportExport.importPersonas`)}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:i(`personaImportExport.uploadJsonFile`)}),(0,J.jsx)(`input`,{type:`file`,accept:`.json`,onChange:e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{let t=e.target?.result;typeof t==`string`&&c(t)},e.readAsText(t)}},className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`})]}),(0,J.jsx)(`div`,{className:`text-center text-gray-500 dark:text-dark-500`,children:i(`common.or`).toUpperCase()}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-700 mb-2`,children:i(`personaImportExport.pasteJsonLabel`)}),(0,J.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-700`,rows:8,placeholder:i(`personaImportExport.pasteJsonPlaceholder`)})]}),(0,J.jsx)(U,{onClick:async()=>{if(!s.trim()){C.error(i(`personaImportExport.pasteJsonData`));return}o(!0);try{let e=JSON.parse(s);if(e.personas&&Array.isArray(e.personas)){let t=0,n=0;for(let r of e.personas)try{await B.importPersona(r),t++}catch(e){n++,ye.error(`Failed to import persona:`,e)}t>0?(C.success(i(`personaImportExport.importMultipleSuccess`,{count:t})),n>0&&C.error(i(`personaImportExport.importMultipleFailed`,{count:n}))):C.error(i(`personaImportExport.importNoneFailed`))}else await B.importPersona(e),C.success(i(`personaImportExport.importSuccess`));c(``),t()}catch(e){let t=e instanceof Error?e.message:String(e);C.error(i(`personaImportExport.importFailed`)+`: `+t)}finally{o(!1)}},disabled:!s.trim()||a,className:`w-full`,children:i(a?`personaImportExport.importing`:`personaImportExport.importButton`)})]})]})]}),(0,J.jsxs)(`div`,{className:`mt-6 bg-gray-50 dark:bg-dark-200 rounded-lg p-4`,children:[(0,J.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-dark-800 mb-2`,children:i(`personaImportExport.expectedFormat`)}),(0,J.jsx)(`pre`,{className:`text-xs text-gray-600 dark:text-dark-600 overflow-x-auto`,children:`{
2
+ "name": "Assistant Name",
3
+ "description": "Brief description of the assistant's personality",
4
+ "model": "model-name:version",
5
+ "params": {
6
+ "temperature": 0.8,
7
+ "top_p": 0.9,
8
+ "context_window": 4096,
9
+ "system_prompt": "You are a helpful assistant with specific traits..."
10
+ },
11
+ "avatar": "/path/to/avatar.png",
12
+ "background": "/path/to/background.png"
13
+ }`})]}),(0,J.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,J.jsx)(U,{onClick:n,variant:`outline`,children:i(`common.close`)})})]})},xe=()=>{let{t:e}=r(),t=K(),[n,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(!1),{data:l=[],isLoading:u,refetch:d}=G({queryKey:[`personas`],queryFn:async()=>{let e=await B.getPersonas();if(!e.success)throw Error(e.error||`Failed to load personas`);return e.data||[]}}),f=async()=>{await t.invalidateQueries({queryKey:[`personas`]}),await d()},p=()=>{o(null),i(!0)},m=e=>{o(e),i(!0)},h=async t=>{if(confirm(e(`personaManager.deleteConfirm`,{name:t.name})))try{let n=await B.deletePersona(t.id);n.success?(C.success(e(`personaManager.deleteSuccess`,{name:t.name})),await f()):C.error(e(`personaManager.failed`,{action:`delete`})+`: `+n.error)}catch(t){let n=t instanceof Error?t.message:String(t);C.error(e(`personaManager.failed`,{action:`delete`})+`: `+n)}},g=async t=>{try{await B.downloadPersona(t.id,t.name),C.success(e(`personaManager.downloadSuccess`,{name:t.name}))}catch(t){let n=t instanceof Error?t.message:String(t);C.error(e(`personaManager.failed`,{action:`download`})+`: `+n)}};return u?(0,J.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,J.jsx)(`div`,{className:`text-gray-600 dark:text-dark-600`,children:e(`personaManager.loading`)})}):n?(0,J.jsx)(ve,{persona:a,onSubmit:async()=>{i(!1),o(null),await f()},onCancel:()=>{i(!1),o(null)}}):s?(0,J.jsx)(be,{personas:l,onImport:f,onClose:()=>c(!1)}):(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:[(0,J.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e(`personaManager.stats.title`)}),` `,`· `,e(`personaManager.stats.count`,{count:l.length})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(U,{onClick:()=>c(!0),variant:`outline`,className:`px-4`,children:e(`personaManager.importExport`)}),(0,J.jsx)(U,{onClick:p,className:`px-4`,children:e(`personaManager.createButton`)})]})]}),l.length===0?(0,J.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 bg-white/40 p-12 text-center dark:border-white/15 dark:bg-white/[0.025]`,children:[(0,J.jsx)(`div`,{className:`text-gray-400 dark:text-dark-500 mb-4`,children:(0,J.jsx)(`svg`,{className:`w-16 h-16 mx-auto`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,J.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`})})}),(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800 mb-2`,children:e(`personaManager.empty.title`)}),(0,J.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-6`,children:e(`personaManager.empty.description`)}),(0,J.jsx)(U,{onClick:p,className:`px-6 py-2`,children:e(`personaManager.empty.button`)})]}):(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3`,children:l.map(e=>(0,J.jsx)(oe,{persona:e,onEdit:m,onDelete:h,onDownload:g},e.id))})]})},Se=()=>{let{t:e}=r();return(0,J.jsxs)(W,{children:[(0,J.jsx)(re,{title:e(`personaManager.title`),description:e(`personaManager.subtitle`)}),(0,J.jsx)(xe,{})]})};export{Se as PersonasPage,Se as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{t as r}from"./useTranslation-5b5UhAc9.js";import{t as i}from"./utils-BGrdX9ie.js";import{J as a,On as o,Ot as s,X as c,Zn as l,Zt as u,_ as d,_n as f,dr as p,h as m,jn as h,lr as g,s as _}from"./ui-vendor-C0DZ8-Cm.js";import{r as v}from"./workApi-CcprMH_1.js";import{u as y}from"./api-D7Ff5M2Q.js";import{t as b}from"./Button-C0r3J9G_.js";import{a as x,o as S}from"./ui-db9meqAB.js";import{D as C}from"../assets/index-DBAf_VaS.js";var w=e(t(),1),T={getAnalytics:e=>v.get(`/costs/analytics`,{params:{days:e}}).then(e=>e.data),listTariffs:()=>v.get(`/costs/tariffs`).then(e=>e.data),createTariff:e=>v.post(`/costs/tariffs`,e).then(e=>e.data),deleteTariff:e=>v.delete(`/costs/tariffs/${encodeURIComponent(e)}`).then(()=>void 0),listBudgets:()=>v.get(`/costs/budgets`).then(e=>e.data),createBudget:e=>v.post(`/costs/budgets`,e).then(e=>e.data),deleteBudget:e=>v.delete(`/costs/budgets/${encodeURIComponent(e)}`).then(()=>void 0),exportUrl:e=>`/api/costs/export?days=${e}`,exportCsv:e=>v.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}=r(),[n,i]=(0,w.useState)(null),[a,o]=(0,w.useState)([]),[l,u]=(0,w.useState)([]),[m,h]=(0,w.useState)(!0),[g,_]=(0,w.useState)(0),[v,y]=(0,w.useState)({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),[x,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,r])=>{n||(e.success&&e.data&&i(e.data),t.success&&t.data&&o(t.data),r.success&&r.data&&u(r.data))}).catch(()=>p.error(t(`costs.loadFailed`))).finally(()=>{n||h(!1)}),()=>{n=!0}},[e,g,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);p.success(t(`costs.tariffSaved`)),y({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),_(e=>e+1)}catch(e){p.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},A=async()=>{try{let e=await T.createBudget({name:x.name.trim(),principalType:x.principalType,principalId:x.principalType===`instance`?void 0:x.principalId.trim(),period:x.period,amountUsd:Number(x.amountUsd),mode:x.mode});if(!e.success)throw Error(e.message);p.success(t(`costs.budgetSaved`)),S({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`}),_(e=>e+1)}catch(e){p.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{p.error(t(`costs.exportFailed`))}};return m&&!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)(s,{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)(b,{size:`sm`,variant:`outline`,onClick:()=>void j(),children:[(0,E.jsx)(f,{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(()=>_(e=>e+1)).catch(()=>p.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)(d,{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:x.name,onChange:e=>S({...x,name:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:x.principalType,onChange:e=>S({...x,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:x.principalId,disabled:x.principalType===`instance`,onChange:e=>S({...x,principalId:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:x.period,onChange:e=>S({...x,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:x.amountUsd,onChange:e=>S({...x,amountUsd:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:x.mode,onChange:e=>S({...x,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)(b,{size:`sm`,onClick:()=>void A(),children:[(0,E.jsx)(c,{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(()=>_(e=>e+1)).catch(()=>p.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)(d,{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)(b,{size:`sm`,onClick:()=>void k(),children:[(0,E.jsx)(c,{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:a}=r(),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:a(`usageAnalytics.activity.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:a(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:i(`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:a(`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":a(`usageAnalytics.activity.chartLabel`,{metric:a(`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:r})=>(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(r.timestamp)}: ${M(r[t])} ${a(`usageAnalytics.metrics.${t}`).toLocaleLowerCase()}`})},r.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}=r(),[a,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 r=c+(t*7+n)*I;if(r<g||r>_)return null;let o=l.get(r),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:+(a?.timestamp===r),className:i(`transition-opacity`,u===0||!o?G:S(o),a?.timestamp===r?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>C(e,r,{calls:s,models:o?.models??[]}),children:(0,E.jsx)(`title`,{children:`${h.format(r)} — ${M(s)}`})},r)}))]})}),a&&(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:a.x,top:a.y-6},children:[(0,E.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:h.format(a.timestamp)}),(0,E.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:a.calls===0?t(`usageAnalytics.heatmap.noCalls`):`${M(a.calls)} ${t(`usageAnalytics.heatmap.calls`)}`}),a.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:i(`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:i(`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:i(`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}=r(),[t,n]=(0,w.useState)(30),[c,d]=(0,w.useState)(`calls`),{data:f,error:p,isLoading:v,isFetching:T,refetch:D}=C({queryKey:[`plugin-usage`,t],queryFn:async()=>{let n=await y.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),O=p?p instanceof Error?p.message:e(`usageAnalytics.loadFailed`):null,A=f?.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:g},{label:e(`usageAnalytics.cards.tokens`),value:M(A?.reportedTokens??0),detail:e(`usageAnalytics.cards.tokensDetail`,{count:A?.meteredCalls??0}),icon:u},{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:h},{label:e(`usageAnalytics.cards.latency`),value:N(A?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:o}],[e,A]);return v&&!f?(0,E.jsx)(S,{width:`wide`,children:(0,E.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,E.jsx)(s,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,E.jsxs)(S,{width:`wide`,children:[(0,E.jsx)(x,{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:i(`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)(b,{variant:`outline`,size:`sm`,onClick:()=>void D(),disabled:T,children:[(0,E.jsx)(a,{className:i(`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)(m,{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})}),f&&(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)})}),f.heatmap&&f.heatmap.cells.length>0&&(0,E.jsx)(q,{heatmap:f.heatmap}),(0,E.jsx)(F,{analytics:f,metric:c,onMetricChange:d}),f.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)(l,{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:f.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:f.plugins.slice(0,8).map(t=>{let n=f.totals.calls?t.calls/f.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)(_,{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:f.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};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/OptimizedSyntaxHighlighter-xgyE3dRA.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-BK7WVOb7.js","js/syntax-highlight-P2zo9o06.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{_ as n,g as r,l as i,n as a,o,r as s,t as c}from"./markdown-core-BK7WVOb7.js";import{a as l}from"./router-vendor-CbexJIsv.js";import{t as u}from"./utils-BGrdX9ie.js";import{t as d}from"./appStore-DmV5wqDz.js";import{a as f,i as p,n as m,r as h,s as g,t as _}from"./messageCodeStyles-BQwf7sSz.js";import{n as v,t as y}from"./markdown-math-e1ByS3KY.js";var b=t(n(),1),x=`clipPath.clipRule.d.dominantBaseline.fill.fillOpacity.fillRule.fontFamily.fontSize.fontStyle.fontWeight.letterSpacing.markerEnd.markerMid.markerStart.mask.opacity.paintOrder.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.textAnchor.transform.vectorEffect`.split(`.`),S=Object.fromEntries(Object.entries({svg:[`viewBox`,`xmlns`,`preserveAspectRatio`,`role`,`ariaLabel`],g:[],defs:[],symbol:[`viewBox`,`preserveAspectRatio`],use:[`href`,`x`,`y`],title:[],desc:[],path:[`pathLength`],circle:[`cx`,`cy`,`r`],ellipse:[`cx`,`cy`,`rx`,`ry`],rect:[`x`,`y`,`rx`,`ry`],line:[`x1`,`y1`,`x2`,`y2`],polyline:[`points`],polygon:[`points`],text:[`x`,`y`,`dx`,`dy`,`rotate`,`textLength`],tspan:[`x`,`y`,`dx`,`dy`,`rotate`],linearGradient:[`x1`,`y1`,`x2`,`y2`,`gradientUnits`,`gradientTransform`,`spreadMethod`,`href`],radialGradient:[`cx`,`cy`,`r`,`fx`,`fy`,`gradientUnits`,`gradientTransform`,`spreadMethod`,`href`],stop:[`offset`,`stopColor`,`stopOpacity`],clipPath:[`clipPathUnits`],mask:[`maskUnits`,`maskContentUnits`,`x`,`y`],pattern:[`patternUnits`,`patternContentUnits`,`patternTransform`,`viewBox`,`x`,`y`],marker:[`markerWidth`,`markerHeight`,`markerUnits`,`refX`,`refY`,`orient`,`viewBox`]}).map(([e,t])=>[e,[...x,...t]])),C={...a,clobberPrefix:``,tagNames:[...a.tagNames??[],...Object.keys(S)],attributes:{...a.attributes,...S,code:[[`className`,/^language-./,`math-inline`,`math-display`]]},protocols:{...a.protocols,href:[...a.protocols?.href??[]]}},w=e({RichMessageContent:()=>O,default:()=>O}),T=r(),E=b.lazy(()=>l(()=>import(`./OptimizedSyntaxHighlighter-xgyE3dRA.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3])));function D({children:e,className:t}){return(0,T.jsx)(`pre`,{dir:`ltr`,className:u(h,`rounded-lg`,t),children:(0,T.jsx)(`code`,{children:e})})}var O=({content:e,className:t,allowHtml:n=!1})=>{let r=d(e=>e.theme.mode!==`light`),a=b.useMemo(()=>g(e),[e]),l=b.useMemo(()=>n?[s,[c,C],y]:[y],[n]);return(0,T.jsx)(`div`,{dir:`auto`,className:u(`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,T.jsx)(i,{remarkPlugins:[o,v],rehypePlugins:l,components:{code({className:e,children:t,node:n,...i}){let a=/language-([^\s]+)/.exec(e||``),o=String(t),s=o.replace(/\n$/,``),c=a?a[1]:null;return c||o.includes(`
3
+ `)?(0,T.jsx)(f,{code:s,language:c,state:`complete`,children:(0,T.jsx)(`div`,{className:`overflow-x-auto`,children:(0,T.jsx)(b.Suspense,{fallback:(0,T.jsx)(D,{className:`!m-0 !rounded-none !border-none`,children:s}),children:(0,T.jsx)(E,{language:c||`text`,isDark:r,codeTheme:`night`,backgroundColor:r?_:m,borderRadius:0,customStyle:p,className:`!m-0 !rounded-none !border-none`,showLineNumbers:!0,children:s})})})}):(0,T.jsx)(`code`,{dir:`ltr`,className:u(`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),...i,children:t})},pre({children:e}){return(0,T.jsx)(T.Fragment,{children:e})},p({children:e,...t}){return(0,T.jsx)(`div`,{dir:`auto`,className:`mb-2.5 last:mb-0 leading-relaxed`,...t,children:e})},ul({children:e,...t}){return(0,T.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,T.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,T.jsx)(`li`,{dir:`auto`,className:`text-gray-700 dark:text-dark-700 leading-relaxed`,...t,children:e})},blockquote({children:e,...t}){return(0,T.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,T.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,T.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,T.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,T.jsx)(`div`,{className:u(`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,T.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,T.jsx)(`thead`,{className:`bg-surface-subtle`,...n,children:e})},tbody({children:e,node:t,...n}){return(0,T.jsx)(`tbody`,{...n,children:e})},tr({children:e,node:t,...n}){return(0,T.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,T.jsx)(`th`,{className:u(`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,T.jsx)(`td`,{className:u(`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:a})})};export{w as n,O as t};