libre-webui 0.37.2 → 0.39.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 (432) hide show
  1. package/README.md +29 -65
  2. package/backend/dist/db.js +1 -1
  3. package/backend/dist/index.d.ts.map +1 -1
  4. package/backend/dist/index.js +13 -36
  5. package/backend/dist/index.js.map +1 -1
  6. package/backend/dist/main.js +0 -12
  7. package/backend/dist/main.js.map +1 -1
  8. package/backend/dist/middleware/cors.d.ts.map +1 -1
  9. package/backend/dist/middleware/cors.js +5 -0
  10. package/backend/dist/middleware/cors.js.map +1 -1
  11. package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
  12. package/backend/dist/persistence/postgresExtensionRepositories.js +2 -4
  13. package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
  14. package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
  15. package/backend/dist/persistence/postgresMigrationRegistry.js +2 -0
  16. package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
  17. package/backend/dist/persistence/postgresWorkRunThinkMigration.d.ts +9 -0
  18. package/backend/dist/persistence/postgresWorkRunThinkMigration.d.ts.map +1 -0
  19. package/backend/dist/persistence/postgresWorkRunThinkMigration.js +39 -0
  20. package/backend/dist/persistence/postgresWorkRunThinkMigration.js.map +1 -0
  21. package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
  22. package/backend/dist/persistence/sqliteExtensionRepositories.js +2 -4
  23. package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
  24. package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
  25. package/backend/dist/persistence/sqliteMigrations.js +20 -0
  26. package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
  27. package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
  28. package/backend/dist/persistence/sqliteToPostgresMigration.js +1 -0
  29. package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
  30. package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts.map +1 -1
  31. package/backend/dist/platform/workPersistence/postgresWorkPersistence.js +3 -2
  32. package/backend/dist/platform/workPersistence/postgresWorkPersistence.js.map +1 -1
  33. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts.map +1 -1
  34. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js +3 -3
  35. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js.map +1 -1
  36. package/backend/dist/platform/workPersistence/types.d.ts +5 -0
  37. package/backend/dist/platform/workPersistence/types.d.ts.map +1 -1
  38. package/backend/dist/platform/workPersistence/types.js.map +1 -1
  39. package/backend/dist/routes/agentCli.d.ts.map +1 -1
  40. package/backend/dist/routes/agentCli.js +8 -3
  41. package/backend/dist/routes/agentCli.js.map +1 -1
  42. package/backend/dist/routes/{cordis.d.ts → strands.d.ts} +1 -1
  43. package/backend/dist/routes/strands.d.ts.map +1 -0
  44. package/backend/dist/routes/strands.js +300 -0
  45. package/backend/dist/routes/strands.js.map +1 -0
  46. package/backend/dist/routes/work.d.ts.map +1 -1
  47. package/backend/dist/routes/work.js +26 -23
  48. package/backend/dist/routes/work.js.map +1 -1
  49. package/backend/dist/services/agentAccessService.d.ts +0 -5
  50. package/backend/dist/services/agentAccessService.d.ts.map +1 -1
  51. package/backend/dist/services/agentAccessService.js +7 -35
  52. package/backend/dist/services/agentAccessService.js.map +1 -1
  53. package/backend/dist/services/agentCliService.d.ts +16 -23
  54. package/backend/dist/services/agentCliService.d.ts.map +1 -1
  55. package/backend/dist/services/agentCliService.js +85 -112
  56. package/backend/dist/services/agentCliService.js.map +1 -1
  57. package/backend/dist/services/authService.d.ts +3 -3
  58. package/backend/dist/services/authService.d.ts.map +1 -1
  59. package/backend/dist/services/authService.js +3 -4
  60. package/backend/dist/services/authService.js.map +1 -1
  61. package/backend/dist/services/authorizationService.d.ts +1 -1
  62. package/backend/dist/services/authorizationService.d.ts.map +1 -1
  63. package/backend/dist/services/authorizationService.js +17 -8
  64. package/backend/dist/services/authorizationService.js.map +1 -1
  65. package/backend/dist/services/followUpService.d.ts +4 -1
  66. package/backend/dist/services/followUpService.d.ts.map +1 -1
  67. package/backend/dist/services/followUpService.js +23 -2
  68. package/backend/dist/services/followUpService.js.map +1 -1
  69. package/backend/dist/services/pluginService.d.ts.map +1 -1
  70. package/backend/dist/services/pluginService.js +10 -6
  71. package/backend/dist/services/pluginService.js.map +1 -1
  72. package/backend/dist/services/pluginUsageService.d.ts +0 -34
  73. package/backend/dist/services/pluginUsageService.d.ts.map +1 -1
  74. package/backend/dist/services/pluginUsageService.js +0 -62
  75. package/backend/dist/services/pluginUsageService.js.map +1 -1
  76. package/backend/dist/services/strandsAccessService.d.ts +26 -0
  77. package/backend/dist/services/strandsAccessService.d.ts.map +1 -0
  78. package/backend/dist/services/strandsAccessService.js +95 -0
  79. package/backend/dist/services/strandsAccessService.js.map +1 -0
  80. package/backend/dist/services/thinkingSummaryService.d.ts +2 -3
  81. package/backend/dist/services/thinkingSummaryService.d.ts.map +1 -1
  82. package/backend/dist/services/thinkingSummaryService.js +13 -27
  83. package/backend/dist/services/thinkingSummaryService.js.map +1 -1
  84. package/backend/dist/services/titleGenerationService.d.ts +7 -18
  85. package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
  86. package/backend/dist/services/titleGenerationService.js +15 -36
  87. package/backend/dist/services/titleGenerationService.js.map +1 -1
  88. package/backend/dist/services/workAgentService.d.ts +1 -1
  89. package/backend/dist/services/workAgentService.d.ts.map +1 -1
  90. package/backend/dist/services/workAgentService.js +17 -60
  91. package/backend/dist/services/workAgentService.js.map +1 -1
  92. package/backend/dist/services/workModelProviderService.d.ts +1 -4
  93. package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
  94. package/backend/dist/services/workModelProviderService.js +60 -50
  95. package/backend/dist/services/workModelProviderService.js.map +1 -1
  96. package/backend/dist/services/workTaskService.d.ts +3 -2
  97. package/backend/dist/services/workTaskService.d.ts.map +1 -1
  98. package/backend/dist/services/workTaskService.js +11 -7
  99. package/backend/dist/services/workTaskService.js.map +1 -1
  100. package/backend/dist/strands/catalog.d.ts +57 -0
  101. package/backend/dist/strands/catalog.d.ts.map +1 -0
  102. package/backend/dist/strands/catalog.js +241 -0
  103. package/backend/dist/strands/catalog.js.map +1 -0
  104. package/backend/dist/strands/engine.d.ts +131 -0
  105. package/backend/dist/strands/engine.d.ts.map +1 -0
  106. package/backend/dist/strands/engine.js +477 -0
  107. package/backend/dist/strands/engine.js.map +1 -0
  108. package/backend/dist/strands/harness.d.ts +14 -0
  109. package/backend/dist/strands/harness.d.ts.map +1 -0
  110. package/backend/dist/strands/harness.js +41 -0
  111. package/backend/dist/strands/harness.js.map +1 -0
  112. package/backend/dist/strands/model.d.ts +24 -0
  113. package/backend/dist/strands/model.d.ts.map +1 -0
  114. package/backend/dist/strands/model.js +381 -0
  115. package/backend/dist/strands/model.js.map +1 -0
  116. package/backend/dist/strands/runtime.d.ts +4 -0
  117. package/backend/dist/strands/runtime.d.ts.map +1 -0
  118. package/backend/dist/{cordis/work-model.js → strands/runtime.js} +16 -12
  119. package/backend/dist/strands/runtime.js.map +1 -0
  120. package/backend/dist/strands/sandbox.d.ts +24 -0
  121. package/backend/dist/strands/sandbox.d.ts.map +1 -0
  122. package/backend/dist/strands/sandbox.js +156 -0
  123. package/backend/dist/strands/sandbox.js.map +1 -0
  124. package/backend/dist/strands/work-driver.d.ts +11 -0
  125. package/backend/dist/strands/work-driver.d.ts.map +1 -0
  126. package/backend/dist/strands/work-driver.js +443 -0
  127. package/backend/dist/strands/work-driver.js.map +1 -0
  128. package/backend/dist/strands/work-model.d.ts +7 -0
  129. package/backend/dist/strands/work-model.d.ts.map +1 -0
  130. package/backend/dist/strands/work-model.js +42 -0
  131. package/backend/dist/strands/work-model.js.map +1 -0
  132. package/backend/dist/types/work.d.ts +7 -11
  133. package/backend/dist/types/work.d.ts.map +1 -1
  134. package/backend/dist/types/work.js.map +1 -1
  135. package/backend/dist/utils/bedrockMantle.d.ts +46 -0
  136. package/backend/dist/utils/bedrockMantle.d.ts.map +1 -0
  137. package/backend/dist/utils/bedrockMantle.js +206 -0
  138. package/backend/dist/utils/bedrockMantle.js.map +1 -0
  139. package/backend/dist/utils/corsOriginPolicy.d.ts +10 -0
  140. package/backend/dist/utils/corsOriginPolicy.d.ts.map +1 -0
  141. package/backend/dist/utils/corsOriginPolicy.js +70 -0
  142. package/backend/dist/utils/corsOriginPolicy.js.map +1 -0
  143. package/backend/dist/utils/pluginChatAdapter.d.ts +36 -0
  144. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
  145. package/backend/dist/utils/pluginChatAdapter.js +122 -47
  146. package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
  147. package/backend/dist/utils/pluginDefinitionTrust.d.ts.map +1 -1
  148. package/backend/dist/utils/pluginDefinitionTrust.js +3 -2
  149. package/backend/dist/utils/pluginDefinitionTrust.js.map +1 -1
  150. package/backend/dist/utils/pluginValidation.d.ts +1 -1
  151. package/backend/dist/utils/pluginValidation.d.ts.map +1 -1
  152. package/backend/dist/utils/pluginValidation.js +11 -0
  153. package/backend/dist/utils/pluginValidation.js.map +1 -1
  154. package/backend/package.json +6 -36
  155. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  156. package/frontend/dist/artifact-runtime/babel.js +170 -170
  157. package/frontend/dist/artifact-runtime/framer-motion.js +3 -3
  158. package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
  159. package/frontend/dist/artifact-runtime/mathjs.js +1 -1
  160. package/frontend/dist/artifact-runtime/mermaid.js +1 -1
  161. package/frontend/dist/artifact-runtime/plotly.js +1 -1
  162. package/frontend/dist/artifact-runtime/react.js +3 -3
  163. package/frontend/dist/assets/index-D99DS5c6.js +57 -0
  164. package/frontend/dist/assets/index-Dz1JufgZ.css +1 -0
  165. package/frontend/dist/assets/{markdown-math-D1Bj3pDB.css → markdown-math-DzFXvcrH.css} +1 -1
  166. package/frontend/dist/index.html +34 -34
  167. package/frontend/dist/js/{ArtifactContainer-D4v4l15L.js → ArtifactContainer-Cn7X9HGm.js} +1 -1
  168. package/frontend/dist/js/{ArtifactDemoPage-B2uaVpsi.js → ArtifactDemoPage-Ddpy2O_v.js} +1 -1
  169. package/frontend/dist/js/{ArtifactSandboxFrame-DlWJHI-r.js → ArtifactSandboxFrame-CdsAqv8H.js} +1 -1
  170. package/frontend/dist/js/{ArtifactSlideOutPanel-laZ98QKB.js → ArtifactSlideOutPanel-cVd9X80o.js} +1 -1
  171. package/frontend/dist/js/AutomationModal-B4UaWjkk.js +1 -0
  172. package/frontend/dist/js/AutomationsPage-huCrvLUp.js +1 -0
  173. package/frontend/dist/js/{AvatarUpload-KaBaTKoG.js → AvatarUpload-CG-w6Mpt.js} +1 -1
  174. package/frontend/dist/js/{Button-CGMYia4g.js → Button-j68Q8KVh.js} +1 -1
  175. package/frontend/dist/js/{CalendarPage-Dc7r-86c.js → CalendarPage-CZXT1w99.js} +1 -1
  176. package/frontend/dist/js/ChannelsPage-DbtdHnSL.js +1 -0
  177. package/frontend/dist/js/ChatPage-BZE65kiq.js +14 -0
  178. package/frontend/dist/js/ConnectModels-DD4bLgdq.js +1 -0
  179. package/frontend/dist/js/{EvaluationsPage-BB7sPhIR.js → EvaluationsPage-Dq53LaXd.js} +2 -2
  180. package/frontend/dist/js/{FirstTimeSetup-elqSi9JH.js → FirstTimeSetup-BoJIfuQT.js} +1 -1
  181. package/frontend/dist/js/GalleryPage-DKwqeB2A.js +1 -0
  182. package/frontend/dist/js/HomePage-C8bCJfls.js +1 -0
  183. package/frontend/dist/js/LanguageSwitcher-B_YyU5JG.js +1 -0
  184. package/frontend/dist/js/{Logo-HZvdAk2c.js → Logo-DnfVtjgj.js} +1 -1
  185. package/frontend/dist/js/{LogoMark-GJnfMXsk.js → LogoMark-BzObGdA9.js} +1 -1
  186. package/frontend/dist/js/{ModelManagerModals-Bk6OQzJI.js → ModelManagerModals-BzjZ-QwL.js} +1 -1
  187. package/frontend/dist/js/NotesPage-CnaAp_w_.js +3 -0
  188. package/frontend/dist/js/{OptimizedSyntaxHighlighter-CzzV6ONG.js → OptimizedSyntaxHighlighter-B0g8cxZQ.js} +1 -1
  189. package/frontend/dist/js/OptimizedSyntaxHighlighter-B_BbHeO1.js +1 -0
  190. package/frontend/dist/js/{PasswordStrengthMeter-DasfJa4P.js → PasswordStrengthMeter-DI4RDv67.js} +1 -1
  191. package/frontend/dist/js/{PersonasPage-CIJINcQK.js → PersonasPage-CH3GUKph.js} +2 -2
  192. package/frontend/dist/js/PluginUsagePage-d54K2gAj.js +1 -0
  193. package/frontend/dist/js/{RichMessageContent-DxCHlUlY.js → RichMessageContent-BfYbVBFz.js} +2 -2
  194. package/frontend/dist/js/RichMessageContent-CDxxs3Tt.js +1 -0
  195. package/frontend/dist/js/SettingsModal-BvtJcvow.js +19 -0
  196. package/frontend/dist/js/{SettingsToggle-oxvw7ulA.js → SettingsToggle-DrJ0Bapi.js} +1 -1
  197. package/frontend/dist/js/{ShareDialog-Bhpt_Y1N.js → ShareDialog-DaSxkTKS.js} +1 -1
  198. package/frontend/dist/js/StrandsPage-BQwz0mWq.js +1 -0
  199. package/frontend/dist/js/{SystemPage-BfhVXqar.js → SystemPage-BqNZoFxR.js} +1 -1
  200. package/frontend/dist/js/{TurnstileWidget-CVepEMEQ.js → TurnstileWidget-tI50c7Kc.js} +1 -1
  201. package/frontend/dist/js/{UserManagementPage-2yHv89ZA.js → UserManagementPage-UvPjA9RP.js} +1 -1
  202. package/frontend/dist/js/UserManagementPanel-C3T1ReJJ.js +1 -0
  203. package/frontend/dist/js/{WhatsNewModal-Dl69bG2T.js → WhatsNewModal-CLcU2Ugk.js} +1 -1
  204. package/frontend/dist/js/WorkPage-BpjGn--1.js +8 -0
  205. package/frontend/dist/js/api-BrHW-VGd.js +14 -0
  206. package/frontend/dist/js/api-K_hhqPdx.js +1 -0
  207. package/frontend/dist/js/{appNavigation-R8iKverf.js → appNavigation-B6xYIgLi.js} +1 -1
  208. package/frontend/dist/js/appStore-DkRdQQeY.js +2 -0
  209. package/frontend/dist/js/appVersion-BVtSqLVj.js +1 -0
  210. package/frontend/dist/js/ar-XTZGEtBr.js +2 -0
  211. package/frontend/dist/js/authStore-DBS6Kbvh.js +1 -0
  212. package/frontend/dist/js/{authStore-D8fc-Hl0.js → authStore-DjAsRpNL.js} +3 -3
  213. package/frontend/dist/js/bn-JiK7ZWmy.js +2 -0
  214. package/frontend/dist/js/chatStore-DpVxt9VX.js +3 -0
  215. package/frontend/dist/js/{client-BeJbHHWx.js → client-DppLngAs.js} +2 -2
  216. package/frontend/dist/js/{config-D6Kcp5n3.js → config-4_s8hdqO.js} +1 -1
  217. package/frontend/dist/js/cs-D8ju18CO.js +2 -0
  218. package/frontend/dist/js/da-BJWcAoUc.js +2 -0
  219. package/frontend/dist/js/de-CLJLmy69.js +2 -0
  220. package/frontend/dist/js/es-BvqHEL-3.js +2 -0
  221. package/frontend/dist/js/{evaluationsApi-2YwZBPk5.js → evaluationsApi-DyuW7IJ_.js} +1 -1
  222. package/frontend/dist/js/fr-B8ZoZomI.js +2 -0
  223. package/frontend/dist/js/hi-AzJLALo-.js +2 -0
  224. package/frontend/dist/js/id-DZYGQhvC.js +2 -0
  225. package/frontend/dist/js/is-Da_kvtzW.js +2 -0
  226. package/frontend/dist/js/it-B90zSlqn.js +2 -0
  227. package/frontend/dist/js/ja-DU_K1GOr.js +2 -0
  228. package/frontend/dist/js/ko-DicfoO-e.js +2 -0
  229. package/frontend/dist/js/{markdown-CZ1tYEW8.js → markdown-DU84620G.js} +1 -1
  230. package/frontend/dist/js/{markdown-core-KjS96SYW.js → markdown-core-Cyql92Hg.js} +1 -1
  231. package/frontend/dist/js/{markdown-html-DQEwrWcf.js → markdown-html-CUc2fCgY.js} +1 -1
  232. package/frontend/dist/js/{markdown-math-CKi32S5d.js → markdown-math-DxPfMKvO.js} +1 -1
  233. package/frontend/dist/js/{markdownHtml-lrXhxBhK.js → markdownHtml-KhS0cFNH.js} +1 -1
  234. package/frontend/dist/js/markdownMath-CsfRQAcz.js +1 -0
  235. package/frontend/dist/js/{messageCodeStyles-D4haBw80.js → messageCodeStyles-CuQPkfEK.js} +1 -1
  236. package/frontend/dist/js/ms-CfH7wjUY.js +2 -0
  237. package/frontend/dist/js/nl-ELlOz-B3.js +2 -0
  238. package/frontend/dist/js/pl-33dayyUk.js +2 -0
  239. package/frontend/dist/js/pt-aIXSQPCT.js +2 -0
  240. package/frontend/dist/js/react-vendor-CR5VJ85Q.js +9 -0
  241. package/frontend/dist/js/{router-vendor-HZm4FR0A.js → router-vendor-DqMnEJWK.js} +1 -1
  242. package/frontend/dist/js/ru-BSvGtBtW.js +2 -0
  243. package/frontend/dist/js/{standalone-DbyFjvTU.js → standalone-D_lg5NC9.js} +1 -1
  244. package/frontend/dist/js/strandsApi-BFbeEpAY.js +2 -0
  245. package/frontend/dist/js/sv-B7KOz81W.js +2 -0
  246. package/frontend/dist/js/{syntax-highlight-DNc3FFCa.js → syntax-highlight-D7dQ5s5-.js} +1 -1
  247. package/frontend/dist/js/{teamEventStream-omPy51va.js → teamEventStream-DsAS6P4m.js} +1 -1
  248. package/frontend/dist/js/th-DgpjGxvA.js +2 -0
  249. package/frontend/dist/js/tr-BQTbl2h-.js +2 -0
  250. package/frontend/dist/js/{ui-D5-4niRk.js → ui-Aq8MP7Ph.js} +2 -2
  251. package/frontend/dist/js/ui-vendor-DVTj_sKN.js +1 -0
  252. package/frontend/dist/js/uk-JLymloot.js +2 -0
  253. package/frontend/dist/js/{useChat-DnGClJeX.js → useChat-D3ZAGz70.js} +4 -4
  254. package/frontend/dist/js/useDialogFocus-zSGHkpE4.js +1 -0
  255. package/frontend/dist/js/useDictation-B6l8QzeM.js +1 -0
  256. package/frontend/dist/js/{useQuery-hWmQjdLu.js → useQuery-BTKpXudI.js} +1 -1
  257. package/frontend/dist/js/{useTranslation-B9kflK9S.js → useTranslation-Boi0fB1B.js} +1 -1
  258. package/frontend/dist/js/utils-B-Bhh1pF.js +1 -0
  259. package/frontend/dist/js/utils-vendor-DPJG-EG_.js +1 -0
  260. package/frontend/dist/js/vi-BXdLOJ8q.js +2 -0
  261. package/frontend/dist/js/{work-DmJpVPPO.js → work-CdbmBok5.js} +1 -1
  262. package/frontend/dist/js/workApi-D1xtiG3Q.js +1 -0
  263. package/frontend/dist/js/{workApi-C5InfT8x.js → workApi-UPxumrEF.js} +1 -1
  264. package/frontend/dist/js/workModels-BM2Zyiba.js +1 -0
  265. package/frontend/dist/js/zh-gdUf9sXa.js +2 -0
  266. package/package.json +11 -40
  267. package/plugins/anthropic.json +3 -1
  268. package/plugins/bedrock.json +86 -0
  269. package/plugins/openrouter.json +2 -0
  270. package/backend/dist/cordis/contracts.d.ts +0 -270
  271. package/backend/dist/cordis/contracts.d.ts.map +0 -1
  272. package/backend/dist/cordis/contracts.js +0 -32
  273. package/backend/dist/cordis/contracts.js.map +0 -1
  274. package/backend/dist/cordis/dsh/chat-model.d.ts +0 -16
  275. package/backend/dist/cordis/dsh/chat-model.d.ts.map +0 -1
  276. package/backend/dist/cordis/dsh/chat-model.js +0 -104
  277. package/backend/dist/cordis/dsh/chat-model.js.map +0 -1
  278. package/backend/dist/cordis/dsh/engine-plugin.d.ts +0 -186
  279. package/backend/dist/cordis/dsh/engine-plugin.d.ts.map +0 -1
  280. package/backend/dist/cordis/dsh/engine-plugin.js +0 -1116
  281. package/backend/dist/cordis/dsh/engine-plugin.js.map +0 -1
  282. package/backend/dist/cordis/dsh/librewebui-llm-adapter.d.ts +0 -175
  283. package/backend/dist/cordis/dsh/librewebui-llm-adapter.d.ts.map +0 -1
  284. package/backend/dist/cordis/dsh/librewebui-llm-adapter.js +0 -480
  285. package/backend/dist/cordis/dsh/librewebui-llm-adapter.js.map +0 -1
  286. package/backend/dist/cordis/dsh/model-identity.d.ts +0 -12
  287. package/backend/dist/cordis/dsh/model-identity.d.ts.map +0 -1
  288. package/backend/dist/cordis/dsh/model-identity.js +0 -87
  289. package/backend/dist/cordis/dsh/model-identity.js.map +0 -1
  290. package/backend/dist/cordis/dsh/native-provider-client.d.ts +0 -44
  291. package/backend/dist/cordis/dsh/native-provider-client.d.ts.map +0 -1
  292. package/backend/dist/cordis/dsh/native-provider-client.js +0 -524
  293. package/backend/dist/cordis/dsh/native-provider-client.js.map +0 -1
  294. package/backend/dist/cordis/dsh/native-provider-plugin.d.ts +0 -11
  295. package/backend/dist/cordis/dsh/native-provider-plugin.d.ts.map +0 -1
  296. package/backend/dist/cordis/dsh/native-provider-plugin.js +0 -416
  297. package/backend/dist/cordis/dsh/native-provider-plugin.js.map +0 -1
  298. package/backend/dist/cordis/dsh/native-provider-protocol.d.ts +0 -37
  299. package/backend/dist/cordis/dsh/native-provider-protocol.d.ts.map +0 -1
  300. package/backend/dist/cordis/dsh/native-provider-protocol.js +0 -325
  301. package/backend/dist/cordis/dsh/native-provider-protocol.js.map +0 -1
  302. package/backend/dist/cordis/dsh/provider-handler.d.ts +0 -36
  303. package/backend/dist/cordis/dsh/provider-handler.d.ts.map +0 -1
  304. package/backend/dist/cordis/dsh/provider-handler.js +0 -582
  305. package/backend/dist/cordis/dsh/provider-handler.js.map +0 -1
  306. package/backend/dist/cordis/dsh/session-files.d.ts +0 -9
  307. package/backend/dist/cordis/dsh/session-files.d.ts.map +0 -1
  308. package/backend/dist/cordis/dsh/session-files.js +0 -60
  309. package/backend/dist/cordis/dsh/session-files.js.map +0 -1
  310. package/backend/dist/cordis/dsh/session-settings.d.ts +0 -15
  311. package/backend/dist/cordis/dsh/session-settings.d.ts.map +0 -1
  312. package/backend/dist/cordis/dsh/session-settings.js +0 -51
  313. package/backend/dist/cordis/dsh/session-settings.js.map +0 -1
  314. package/backend/dist/cordis/dsh/work-driver.d.ts +0 -12
  315. package/backend/dist/cordis/dsh/work-driver.d.ts.map +0 -1
  316. package/backend/dist/cordis/dsh/work-driver.js +0 -402
  317. package/backend/dist/cordis/dsh/work-driver.js.map +0 -1
  318. package/backend/dist/cordis/dsh/workspace-policy.d.ts +0 -10
  319. package/backend/dist/cordis/dsh/workspace-policy.d.ts.map +0 -1
  320. package/backend/dist/cordis/dsh/workspace-policy.js +0 -44
  321. package/backend/dist/cordis/dsh/workspace-policy.js.map +0 -1
  322. package/backend/dist/cordis/host/composition.d.ts +0 -73
  323. package/backend/dist/cordis/host/composition.d.ts.map +0 -1
  324. package/backend/dist/cordis/host/composition.js +0 -205
  325. package/backend/dist/cordis/host/composition.js.map +0 -1
  326. package/backend/dist/cordis/host/config.d.ts +0 -159
  327. package/backend/dist/cordis/host/config.d.ts.map +0 -1
  328. package/backend/dist/cordis/host/config.js +0 -184
  329. package/backend/dist/cordis/host/config.js.map +0 -1
  330. package/backend/dist/cordis/host/host.d.ts +0 -74
  331. package/backend/dist/cordis/host/host.d.ts.map +0 -1
  332. package/backend/dist/cordis/host/host.js +0 -420
  333. package/backend/dist/cordis/host/host.js.map +0 -1
  334. package/backend/dist/cordis/host/loader-entry.d.ts +0 -41
  335. package/backend/dist/cordis/host/loader-entry.d.ts.map +0 -1
  336. package/backend/dist/cordis/host/loader-entry.js +0 -52
  337. package/backend/dist/cordis/host/loader-entry.js.map +0 -1
  338. package/backend/dist/cordis/host/model.d.ts +0 -45
  339. package/backend/dist/cordis/host/model.d.ts.map +0 -1
  340. package/backend/dist/cordis/host/model.js +0 -54
  341. package/backend/dist/cordis/host/model.js.map +0 -1
  342. package/backend/dist/cordis/host/privacy.d.ts +0 -8
  343. package/backend/dist/cordis/host/privacy.d.ts.map +0 -1
  344. package/backend/dist/cordis/host/privacy.js +0 -73
  345. package/backend/dist/cordis/host/privacy.js.map +0 -1
  346. package/backend/dist/cordis/index.d.ts +0 -14
  347. package/backend/dist/cordis/index.d.ts.map +0 -1
  348. package/backend/dist/cordis/index.js +0 -30
  349. package/backend/dist/cordis/index.js.map +0 -1
  350. package/backend/dist/cordis/runtime.d.ts +0 -97
  351. package/backend/dist/cordis/runtime.d.ts.map +0 -1
  352. package/backend/dist/cordis/runtime.js +0 -231
  353. package/backend/dist/cordis/runtime.js.map +0 -1
  354. package/backend/dist/cordis/work-model.d.ts +0 -7
  355. package/backend/dist/cordis/work-model.d.ts.map +0 -1
  356. package/backend/dist/cordis/work-model.js.map +0 -1
  357. package/backend/dist/routes/cordis.d.ts.map +0 -1
  358. package/backend/dist/routes/cordis.js +0 -440
  359. package/backend/dist/routes/cordis.js.map +0 -1
  360. package/backend/dist/routes/libreClaw.d.ts +0 -3
  361. package/backend/dist/routes/libreClaw.d.ts.map +0 -1
  362. package/backend/dist/routes/libreClaw.js +0 -200
  363. package/backend/dist/routes/libreClaw.js.map +0 -1
  364. package/backend/dist/services/cordisAccessService.d.ts +0 -56
  365. package/backend/dist/services/cordisAccessService.d.ts.map +0 -1
  366. package/backend/dist/services/cordisAccessService.js +0 -98
  367. package/backend/dist/services/cordisAccessService.js.map +0 -1
  368. package/backend/dist/services/libreClawService.d.ts +0 -105
  369. package/backend/dist/services/libreClawService.d.ts.map +0 -1
  370. package/backend/dist/services/libreClawService.js +0 -169
  371. package/backend/dist/services/libreClawService.js.map +0 -1
  372. package/frontend/dist/assets/index-C8_AByBq.css +0 -1
  373. package/frontend/dist/assets/index-DWLnkKwj.js +0 -16
  374. package/frontend/dist/js/AutomationModal-CjjiEZFA.js +0 -1
  375. package/frontend/dist/js/AutomationsPage-jnWmD58y.js +0 -1
  376. package/frontend/dist/js/ChannelsPage-DHPabX1e.js +0 -1
  377. package/frontend/dist/js/ChatPage-ZvGp-iqV.js +0 -14
  378. package/frontend/dist/js/ConnectModels-aUTD6s9B.js +0 -1
  379. package/frontend/dist/js/CordisPage-DZKcpPVj.js +0 -1
  380. package/frontend/dist/js/GalleryPage-CrlNRnkn.js +0 -1
  381. package/frontend/dist/js/HomePage-lR9h7_a1.js +0 -1
  382. package/frontend/dist/js/LanguageSwitcher-CWkbzpxT.js +0 -1
  383. package/frontend/dist/js/LibreClawPage-P19FnNlu.js +0 -1
  384. package/frontend/dist/js/NotesPage-DopG0M4B.js +0 -3
  385. package/frontend/dist/js/OptimizedSyntaxHighlighter-ajqwyBQm.js +0 -1
  386. package/frontend/dist/js/PluginUsagePage-Cj0mUxD8.js +0 -1
  387. package/frontend/dist/js/RichMessageContent-BZndQSJU.js +0 -1
  388. package/frontend/dist/js/SettingsModal-wAuFQOE4.js +0 -19
  389. package/frontend/dist/js/UserManagementPanel-BU95ZPOv.js +0 -1
  390. package/frontend/dist/js/WorkPage-CSderbeT.js +0 -8
  391. package/frontend/dist/js/api-CU-JXx2u.js +0 -1
  392. package/frontend/dist/js/api-DPXCtanG.js +0 -14
  393. package/frontend/dist/js/appStore-BD70bvas.js +0 -2
  394. package/frontend/dist/js/appVersion-C7sxqgMd.js +0 -1
  395. package/frontend/dist/js/ar-Cq-DrSYL.js +0 -2
  396. package/frontend/dist/js/authStore-FNKLFUQp.js +0 -1
  397. package/frontend/dist/js/bn-BqxLh-KL.js +0 -2
  398. package/frontend/dist/js/chatStore-CK5ojwft.js +0 -3
  399. package/frontend/dist/js/cordisApi-BS8QMSV4.js +0 -2
  400. package/frontend/dist/js/cs-D2DDNZf-.js +0 -2
  401. package/frontend/dist/js/da-BciY-TSG.js +0 -2
  402. package/frontend/dist/js/de-DjU_eXQ-.js +0 -2
  403. package/frontend/dist/js/es-ChIEs80I.js +0 -2
  404. package/frontend/dist/js/fr-Bi8BGRW4.js +0 -2
  405. package/frontend/dist/js/hi-BMsCnWg7.js +0 -2
  406. package/frontend/dist/js/i18next-DOICz7ZY.js +0 -1
  407. package/frontend/dist/js/id-CpcN1vhk.js +0 -2
  408. package/frontend/dist/js/is-DkUy2cmP.js +0 -2
  409. package/frontend/dist/js/it-BglK9DRZ.js +0 -2
  410. package/frontend/dist/js/ja-IrprzwLJ.js +0 -2
  411. package/frontend/dist/js/ko--wwEsMPi.js +0 -2
  412. package/frontend/dist/js/markdownMath-B0BpyFBS.js +0 -1
  413. package/frontend/dist/js/ms-BWj59y7-.js +0 -2
  414. package/frontend/dist/js/nl-D-QndW_A.js +0 -2
  415. package/frontend/dist/js/pl-Dw7d7iDV.js +0 -2
  416. package/frontend/dist/js/pt-BI53uHJw.js +0 -2
  417. package/frontend/dist/js/react-vendor-wiHys0m2.js +0 -9
  418. package/frontend/dist/js/ru-JKyTgPg9.js +0 -2
  419. package/frontend/dist/js/sv-BIkBLPSQ.js +0 -2
  420. package/frontend/dist/js/th-CZ_LcCU0.js +0 -2
  421. package/frontend/dist/js/tr-B265byx1.js +0 -2
  422. package/frontend/dist/js/ui-vendor-BhHHyHk3.js +0 -1
  423. package/frontend/dist/js/uk-VTAlChwf.js +0 -2
  424. package/frontend/dist/js/useDialogFocus-BPTG_Zmy.js +0 -1
  425. package/frontend/dist/js/useDictation-D7zVBjDJ.js +0 -1
  426. package/frontend/dist/js/utils-p8Gt72YP.js +0 -1
  427. package/frontend/dist/js/utils-vendor-DISWt2y9.js +0 -1
  428. package/frontend/dist/js/vi-D8rXh-53.js +0 -2
  429. package/frontend/dist/js/workApi-FV75LKJn.js +0 -1
  430. package/frontend/dist/js/workModels-MzU2Ab7l.js +0 -1
  431. package/frontend/dist/js/zh-BEGd9iBD.js +0 -2
  432. package/scripts/prepare-dsh-provider.mjs +0 -124
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-CR5VJ85Q.js";import{C as i,a,n as o,o as s,r as c,t as l}from"./useQuery-BTKpXudI.js";import{t as u}from"./logger-BR4forr_.js";import{t as d}from"./useTranslation-Boi0fB1B.js";import{t as f}from"./utils-B-Bhh1pF.js";import{An as p,En as m,Kt as h,Lt as g,M as _,On as v,Rn as y,i as b,jt as x,mn as S,n as C,o as w,qt as T,v as E,wr as D}from"./ui-vendor-DVTj_sKN.js";import{t as O}from"./Button-j68Q8KVh.js";import{b as k,x as ee}from"./api-BrHW-VGd.js";import{i as A,n as j,r as M,s as N}from"./imageGenModels-Dx_QMLJQ.js";import{t as P}from"./appStore-DkRdQQeY.js";import{a as F,o as I}from"./ui-Aq8MP7Ph.js";var L=class extends c{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:o,isError:c,isRefetchError:l}=r,u=n.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=i&&u===`forward`,p=c&&u===`backward`,m=i&&u===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:a(t,n.data),hasPreviousPage:s(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:o&&!f&&!m}}};function te(e,t){return o(e,L,t)}var R=e(t(),1),ne=n(),z=r(),re=u(`components:image-generation-panel`);function ie(e,t={}){let n=e.config?.sizes&&e.config.sizes.length>0?e.config.sizes:[t.size||e.config?.default_size||`1024x1024`],r=e.config?.qualities&&e.config.qualities.length>0?e.config.qualities:e.config?.omit_quality_when_empty?[]:[t.quality||e.config?.default_quality||`standard`],i=e.config?.styles&&e.config.styles.length>0?e.config.styles:[];return{pluginId:e.id,model:N(e.models,t.model,void 0,``),size:N(n,t.size,e.config?.default_size,`1024x1024`),quality:r.length>0?N(r,t.quality,e.config?.default_quality,`standard`):``,style:i.length>0?N(i,t.style,e.config?.default_style,i[0]):``,sizes:n,qualities:r,styles:i,maxPromptLength:e.config?.max_prompt_length??null,sizeLabel:e.config?.size_label||``}}var B=({isOpen:e,onClose:t,onImageGenerated:n})=>{let{t:r}=d(),i=P(e=>e.preferences.imageGenSettings),a=i?.enabled===!0,[o,s]=(0,R.useState)([]),[c,l]=(0,R.useState)(``),[u,p]=(0,R.useState)(``),[m,g]=(0,R.useState)(``),[y,b]=(0,R.useState)(`1024x1024`),[x,S]=(0,R.useState)(`standard`),[w,T]=(0,R.useState)(``),[E,k]=(0,R.useState)(!1),[N,F]=(0,R.useState)(null),I=(0,R.useRef)(null),[L,te]=(0,R.useState)([`512x512`,`768x768`,`1024x1024`]),[B,ae]=(0,R.useState)([`standard`,`high`]),[V,H]=(0,R.useState)([]),[U,oe]=(0,R.useState)(null),[se,ce]=(0,R.useState)(``),W=R.useId(),G=(0,R.useCallback)((e,t)=>{let n=ie(e,t);l(n.pluginId),p(n.model),b(n.size),S(n.quality),T(n.style),te(n.sizes),ae(n.qualities),H(n.styles),oe(n.maxPromptLength),ce(n.sizeLabel)},[]);(0,R.useEffect)(()=>{let t=!1;return e&&a&&(async()=>{try{let e=await ee.getPlugins();if(t)return;let n=e.success&&e.data?e.data.filter(e=>e.models.length>0):[];s(n);let r=j(n,i);r?G(r,i):(l(``),p(``))}catch(e){if(t)return;s([]),l(``),p(``),re.error(`Failed to load image generation plugins:`,e)}})(),()=>{t=!0}},[G,a,e,i]),(0,R.useEffect)(()=>{if(!e)return;let n=document.body.style.overflow,r=e=>{e.key===`Escape`&&t()};return document.body.style.overflow=`hidden`,document.addEventListener(`keydown`,r),()=>{document.body.style.overflow=n,document.removeEventListener(`keydown`,r)}},[e,t]),(0,R.useEffect)(()=>()=>{I.current?.abort(),I.current=null},[]),(0,R.useEffect)(()=>{e||I.current?.abort()},[e]);let K=()=>{I.current?.abort(),t()},le=e=>{let t=o.find(t=>t.id===e);t&&G(t,{model:u,size:y,quality:x,style:w})},ue=async()=>{if(!a||!c||!u||!m.trim()){D.error(r(`imageGeneration.enterPrompt`));return}if(U&&m.length>U){D.error(r(`imageGeneration.promptTooLong`,{max:U.toLocaleString()}));return}let e=new AbortController;I.current?.abort(),I.current=e,k(!0),F(null);try{let i=await ee.generate({model:u,pluginId:c,prompt:m.trim(),size:y,quality:x,...w?{style:w}:{}},e.signal);if(e.signal.aborted)return;if(i.success&&i.data?.images&&i.data.images.length>0){let e=A(i.data.images[0]);e&&(D.success(r(`imageGeneration.success`)),n?(n(e,m.trim(),u),g(``),F(null),t()):F(e))}else D.error(r(`imageGeneration.failed`))}catch(t){if(e.signal.aborted)return;re.error(`Image generation failed:`,t);let n=t instanceof Error?t.message:r(`imageGeneration.failed`);D.error(n)}finally{I.current===e&&(I.current=null,k(!1))}},de=()=>{I.current?.abort()},fe=()=>{if(!N)return;let e=document.createElement(`a`);e.href=N,e.download=`generated-image-${Date.now()}.${M(N)}`,document.body.appendChild(e),e.click(),document.body.removeChild(e)};if(!e||!a)return null;let q=o.find(e=>e.id===c);return(0,ne.createPortal)((0,z.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center p-3 sm:p-6`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":W,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-black/55 backdrop-blur-sm`,onClick:K}),(0,z.jsxs)(`div`,{className:f(`relative bg-white/95 dark:bg-dark-25/95`,`border border-gray-200/80 dark:border-white/10`,`rounded-3xl shadow-2xl backdrop-blur-xl`,`flex max-h-[92vh] w-full max-w-2xl flex-col overflow-hidden`),onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-gray-200/70 px-5 py-4 dark:border-white/[0.08] sm:px-6 sm:py-5`,children:[(0,z.jsx)(`div`,{children:(0,z.jsx)(`h2`,{id:W,className:`text-xl font-normal tracking-[-0.025em] text-gray-950 dark:text-dark-950`,children:r(`imageGeneration.title`)})}),(0,z.jsx)(`button`,{onClick:K,className:`rounded-xl p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-dark-500 dark:hover:bg-white/[0.06] dark:hover:text-dark-900`,title:r(`common.close`,{defaultValue:`Close`}),children:(0,z.jsx)(C,{className:`h-5 w-5 text-gray-500 dark:text-gray-400`})})]}),(0,z.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 space-y-5 p-5 scrollbar-thin sm:p-6`,children:q?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`settings.plugins.title`)}),(0,z.jsx)(`select`,{value:c,onChange:e=>le(e.target.value),className:f(`w-full rounded-xl px-3 py-2.5 text-sm`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:o.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.model`)}),(0,z.jsx)(`select`,{value:u,onChange:e=>p(e.target.value),className:f(`w-full rounded-xl px-3 py-2.5 text-sm`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:q?.models.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),V.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.style`)}),(0,z.jsx)(`select`,{value:w,onChange:e=>T(e.target.value),className:f(`w-full rounded-xl px-3 py-2.5 text-sm`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:V.map(e=>(0,z.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:se||r(`imageGeneration.size`)}),(0,z.jsx)(`select`,{value:y,onChange:e=>b(e.target.value),className:f(`w-full rounded-xl px-3 py-2.5 text-sm`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:L.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),B.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.quality`)}),(0,z.jsx)(`select`,{value:x,onChange:e=>S(e.target.value),className:f(`w-full rounded-xl px-3 py-2.5 text-sm`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`text-gray-900 dark:text-gray-100`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:B.map(e=>(0,z.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.prompt`)}),(0,z.jsx)(`textarea`,{value:m,onChange:e=>g(e.target.value),placeholder:r(`imageGeneration.promptPlaceholder`),rows:5,className:f(`w-full resize-none rounded-2xl px-4 py-3 text-sm leading-6`,`bg-white/70 dark:bg-white/[0.035]`,`border border-gray-200/80 dark:border-white/10`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,U&&m.length>U&&`border-red-500 dark:border-red-500`)}),U&&(0,z.jsxs)(`div`,{className:f(`mt-1 text-end text-xs`,m.length>U?`text-red-500`:`text-gray-500 dark:text-gray-400`),children:[m.length.toLocaleString(),` /`,` `,U.toLocaleString()]})]}),N&&(0,z.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border border-gray-200/80 dark:border-white/10`,children:[(0,z.jsx)(`img`,{src:N,alt:`Generated`,className:`w-full h-auto`}),(0,z.jsx)(`button`,{onClick:fe,className:f(`absolute bottom-3 end-3 rounded-lg p-2`,`bg-white/90 dark:bg-dark-100/90`,`hover:bg-white dark:hover:bg-dark-100`,`border border-gray-200 dark:border-dark-300`,`transition-colors`),title:r(`imageGallery.download`),children:(0,z.jsx)(v,{className:`h-5 w-5 text-gray-700 dark:text-gray-200`})})]})]}):(0,z.jsxs)(`div`,{className:`text-center py-8`,children:[(0,z.jsx)(h,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,z.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:r(`imageGeneration.noModels`)}),(0,z.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mt-1`,children:r(`imageGeneration.configurePlugin`)})]})}),q&&(0,z.jsx)(`div`,{className:`border-t border-gray-200/70 p-4 dark:border-white/[0.08] sm:px-6 sm:py-5`,children:(0,z.jsx)(O,{onClick:E?de:ue,disabled:!E&&(!a||!m.trim()||!c||!u),className:f(`w-full py-2.5 rounded-xl font-medium`,`bg-primary-600 dark:bg-primary-600`,`hover:bg-primary-700 dark:hover:bg-primary-500`,`text-white`,`disabled:opacity-50 disabled:cursor-not-allowed`,`transition-colors`),children:E?(0,z.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,z.jsx)(C,{className:`h-4 w-4`}),r(`common.cancel`)]}):(0,z.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,z.jsx)(_,{className:`h-4 w-4`}),r(`imageGeneration.generate`)]})})})]})]}),document.body)},ae={video:[],audio:[]};function V({isOpen:e,initialKind:t,onClose:n,onGenerated:r}){let{t:a}=d(),o=i(),[s,c]=(0,R.useState)(t),[l,u]=(0,R.useState)(ae),[p,m]=(0,R.useState)(``),[h,v]=(0,R.useState)(``),[y,b]=(0,R.useState)(``),[x,T]=(0,R.useState)(!1),[E,ee]=(0,R.useState)(null),[A,j]=(0,R.useState)(``),[M,N]=(0,R.useState)(!1),[P,F]=(0,R.useState)(``),[I,L]=(0,R.useState)(!1),[te,re]=(0,R.useState)(null),[ie,B]=(0,R.useState)(0),[V,G]=(0,R.useState)(``),[K,le]=(0,R.useState)(``),[ue,de]=(0,R.useState)(``),[fe,q]=(0,R.useState)(!0),[pe,me]=(0,R.useState)(!0),[J,he]=(0,R.useState)(!1),[ge,_e]=(0,R.useState)([]),Y=(0,R.useRef)(null),ve=R.useId(),ye=()=>{T(!1),ee(null),j(``),N(!1),F(``),L(!1),B(e=>e+1)},be=()=>{Y.current?.abort(),ye(),n()};(0,R.useEffect)(()=>()=>{Y.current?.abort(),Y.current=null},[]),(0,R.useEffect)(()=>{e||Y.current?.abort()},[e]),(0,R.useEffect)(()=>{if(!e)return;let t=!1;return k.getModels().then(e=>{!t&&e.success&&e.data&&u(e.data)}).catch(()=>{t||D.error(a(`mediaGeneration.loadFailed`))}).finally(()=>{t||me(!1)}),()=>{t=!0}},[e,a]),(0,R.useEffect)(()=>{if(!e)return;let t=!1;return k.listVideoJobs({limit:100,active:!0}).then(e=>{!t&&e.success&&e.data&&_e(e.data.jobs)}).catch(()=>{t||D.error(a(`mediaGeneration.jobsLoadFailed`,{defaultValue:`Failed to load saved video jobs`}))}),()=>{t=!0}},[e,a]);let X=s===`video`?l.video:l.audio,xe=ge.filter(e=>e.status!==`completed`),Se=X.some(e=>U(e)===p)?p:X[0]?U(X[0]):``,Z=(0,R.useMemo)(()=>X.find(e=>U(e)===Se),[Se,X]),Ce=s===`video`?Z?.config:void 0,Q=s===`audio`?Z:void 0,we=!!(Q?.mode===`speech`&&Q.config?.supports_voice_cloning),Te=!!Q?.config?.clone_requires_transcript,$=we&&x,Ee=!!(Q?.mode!==`speech`||Q.config?.allows_custom_voice!==!1||Q.config?.voices?.length),De=Q?.mode===`speech`?Q.config?.max_characters:void 0,Oe=async(e,t,n,r=0)=>{if(e.status!==`pending`&&e.status!==`in_progress`)return e;n&&await oe(3e4,t.signal);try{let n=await k.resumeVideoJob(e.id,t.signal);if(!n.success||!n.data)throw Error(n.message||a(`mediaGeneration.failed`));let r=n.data;return _e(e=>[r,...e.filter(e=>e.id!==r.id)]),Oe(r,t,!0)}catch(n){if(t.signal.aborted||r>=4)throw n;return Oe(e,t,!0,r+1)}},ke=async e=>{let t=new AbortController;Y.current?.abort(),Y.current=t,he(!0);try{let n=await Oe(e,t,!1);if(t.signal.aborted)return;if(n.status===`failed`)throw Error(n.error||a(`mediaGeneration.failed`));D.success(a(`mediaGeneration.success`)),r()}catch(e){if(t.signal.aborted)return;D.error(e instanceof Error?e.message:a(`mediaGeneration.failed`))}finally{Y.current===t&&(Y.current=null,he(!1))}},Ae=async e=>{try{let t=await k.cancelVideoJob(e.id);if(!t.success)throw Error(t.message||a(`mediaGeneration.failed`));_e(t=>t.filter(t=>t.id!==e.id)),D.success(a(`mediaGeneration.jobCancelled`,{defaultValue:`Video job cancelled at the provider`}))}catch(e){D.error(e instanceof Error?e.message:a(`mediaGeneration.failed`))}};return e?(0,ne.createPortal)((0,z.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center p-3 sm:p-6`,children:[(0,z.jsx)(`button`,{className:`absolute inset-0 bg-black/55 backdrop-blur-sm`,onClick:be,"aria-label":a(`common.close`)}),(0,z.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":ve,className:`relative flex max-h-[92vh] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-gray-200/80 bg-white/95 shadow-2xl backdrop-blur-xl dark:border-white/10 dark:bg-dark-25/95`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.08] sm:px-5`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:ve,className:`text-xl text-gray-950 dark:text-dark-950`,children:a(`mediaGeneration.title`)}),(0,z.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-dark-500`,children:a(`mediaGeneration.description`)})]}),(0,z.jsx)(`button`,{onClick:be,className:`rounded-xl p-2`,children:(0,z.jsx)(C,{className:`h-5 w-5`})})]}),(0,z.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 space-y-4 p-4 sm:p-5`,children:[(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 rounded-xl bg-gray-100 p-1 dark:bg-white/[0.05]`,children:[`video`,`audio`].map(e=>(0,z.jsxs)(`button`,{type:`button`,disabled:J,onClick:()=>{c(e),m(``),b(``),ye()},className:f(`flex items-center justify-center gap-2 rounded-xl px-3 py-2 text-sm transition-colors`,e===s?`bg-white text-gray-950 shadow-sm dark:bg-white/10 dark:text-white`:`text-gray-500 dark:text-dark-500`,J&&`cursor-not-allowed opacity-50`),children:[e===`video`?(0,z.jsx)(S,{className:`h-4 w-4`}):(0,z.jsx)(w,{className:`h-4 w-4`}),a(`mediaGeneration.${e}`)]},e))}),s===`video`&&xe.length>0&&(0,z.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-gray-200/80 bg-gray-50/80 p-3 dark:border-white/10 dark:bg-white/[0.025]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:a(`mediaGeneration.savedJobs`,{defaultValue:`Saved video jobs`})}),(0,z.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:a(`mediaGeneration.savedJobsDescription`,{defaultValue:`Closing this panel only stops waiting. Reopen it to resume any provider job listed here.`})})]}),xe.map(e=>(0,z.jsxs)(`div`,{"data-testid":`video-job-${e.id}`,className:`flex items-center gap-3 rounded-lg border border-gray-200/70 bg-white/80 p-2.5 dark:border-white/10 dark:bg-dark-50/70`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:e.prompt||e.model}),(0,z.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:[e.model,` ·`,` `,a(`mediaGeneration.jobStatus.${e.status}`,{defaultValue:e.status.replace(`_`,` `)})]}),e.error&&(0,z.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-300`,children:e.error})]}),(e.status===`pending`||e.status===`in_progress`)&&(0,z.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:J,onClick:()=>void ke(e),children:a(`mediaGeneration.resumeJob`,{defaultValue:`Resume`})}),e.cancellable&&(0,z.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:J,onClick:()=>void Ae(e),children:a(`mediaGeneration.cancelJob`,{defaultValue:`Cancel job`})})]},e.id))]}),pe?(0,z.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,z.jsx)(g,{className:`h-7 w-7 animate-spin`})}):X.length===0?(0,z.jsx)(`div`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/10 p-4 text-sm text-amber-800 dark:text-amber-200`,children:a(`mediaGeneration.noModels`,{kind:a(`mediaGeneration.${s}`)})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(H,{label:a(`mediaGeneration.model`),children:(0,z.jsx)(`select`,{value:Se,onChange:e=>{m(e.target.value),b(``),ye(),G(``),le(``),de(``),q(!0)},className:W,children:X.map(e=>(0,z.jsxs)(`option`,{value:U(e),children:[e.model,` (`,e.plugin,`mode`in e?` · ${a(`mediaGeneration.${e.mode}`)}`:``,`)`]},U(e)))})}),s===`audio`&&!$&&Ee?(0,z.jsx)(H,{label:a(`mediaGeneration.voice`),children:(0,z.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),className:W,placeholder:Q?.config?.default_voice||a(`mediaGeneration.providerDefault`)})}):s===`video`?(0,z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,z.jsx)(H,{label:a(`mediaGeneration.resolution`),children:(0,z.jsxs)(`select`,{value:V,onChange:e=>G(e.target.value),className:W,children:[(0,z.jsx)(`option`,{value:``,children:a(`mediaGeneration.providerDefault`)}),Ce?.resolutions?.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})}),(0,z.jsx)(H,{label:a(`mediaGeneration.aspectRatio`),children:(0,z.jsxs)(`select`,{value:K,onChange:e=>le(e.target.value),className:W,children:[(0,z.jsx)(`option`,{value:``,children:a(`mediaGeneration.providerDefault`)}),Ce?.aspect_ratios?.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})}),(0,z.jsx)(H,{label:a(`mediaGeneration.duration`),children:(0,z.jsxs)(`select`,{value:ue,onChange:e=>de(e.target.value),className:W,children:[(0,z.jsx)(`option`,{value:``,children:a(`mediaGeneration.providerDefault`)}),Ce?.durations?.map(e=>(0,z.jsxs)(`option`,{value:e,children:[e,`s`]},e))]})})]}):null,we&&(0,z.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-primary-500/20 bg-primary-500/[0.06] p-4`,children:[(0,z.jsxs)(`label`,{className:`flex items-start gap-3 text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:$,onChange:e=>{e.target.checked?T(!0):ye()},className:`mt-0.5`}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`block font-medium text-gray-900 dark:text-gray-100`,children:a(`mediaGeneration.cloneVoice`)}),(0,z.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-gray-500 dark:text-dark-500`,children:a(`mediaGeneration.cloneVoiceDescription`)})]})]}),$&&(0,z.jsxs)(`div`,{className:`space-y-3 border-t border-primary-500/15 pt-3`,children:[(0,z.jsx)(H,{label:a(`mediaGeneration.referenceAudio`),children:(0,z.jsx)(`input`,{type:`file`,accept:Q?.config?.clone_audio_mime_types?.join(`,`)||`audio/wav,audio/mpeg,audio/flac,audio/ogg`,onChange:e=>{let t=e.target.files?.[0]||null,n=Q?.config?.clone_max_audio_bytes;if(t&&n&&t.size>n){D.error(a(`mediaGeneration.referenceAudioTooLarge`,{max:ce(n)})),e.target.value=``,ee(null);return}ee(t)},className:f(W,`file:me-3 file:rounded-lg file:border-0 file:bg-primary-500/10 file:px-3 file:py-1 file:text-primary-700 dark:file:text-primary-300`)},ie)}),(0,z.jsx)(H,{label:a(`mediaGeneration.referenceTranscript`),children:(0,z.jsx)(`textarea`,{value:A,onChange:e=>j(e.target.value),rows:3,required:Te,className:f(W,`resize-none`),placeholder:a(`mediaGeneration.referenceTranscriptPlaceholder`)})}),(0,z.jsxs)(`label`,{className:`flex items-start gap-3 text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:M,onChange:e=>{N(e.target.checked),e.target.checked||(F(``),L(!1))},className:`mt-0.5`}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`block font-medium text-gray-900 dark:text-gray-100`,children:a(`mediaGeneration.saveVoiceProfile`,{defaultValue:`Save as a reusable voice`})}),(0,z.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-gray-500 dark:text-dark-500`,children:a(`mediaGeneration.saveVoiceProfileDescription`,{defaultValue:`Store this reference recording and transcript securely. Libre WebUI sends them to the selected provider for every Speech batch that uses this voice.`})})]})]}),M&&(0,z.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-primary-500/15 bg-white/60 p-3 dark:bg-dark-100/50`,children:[(0,z.jsx)(H,{label:a(`mediaGeneration.voiceProfileName`,{defaultValue:`Saved voice name`}),children:(0,z.jsx)(`input`,{type:`text`,value:P,onChange:e=>F(e.target.value),maxLength:80,autoComplete:`off`,className:W,placeholder:a(`mediaGeneration.voiceProfileNamePlaceholder`,{defaultValue:`For example, My voice`})})}),(0,z.jsxs)(`label`,{className:`flex items-start gap-3 text-xs text-amber-700 dark:text-amber-300`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:I,onChange:e=>L(e.target.checked),className:`mt-0.5`}),(0,z.jsx)(`span`,{children:a(`mediaGeneration.voiceStorageConsent`,{defaultValue:`I confirm that I have the speaker’s permission to clone and store this voice. The reference stays saved until I delete it.`})})]}),(0,z.jsx)(H,{label:a(`mediaGeneration.consentTtl.label`,{defaultValue:`Consent duration`}),children:(0,z.jsxs)(`select`,{value:te??``,onChange:e=>re(e.target.value===``?null:Number(e.target.value)),className:W,children:[(0,z.jsx)(`option`,{value:``,children:a(`mediaGeneration.consentTtl.never`,{defaultValue:`Until I withdraw it`})}),(0,z.jsx)(`option`,{value:`30`,children:a(`mediaGeneration.consentTtl.days30`,{defaultValue:`30 days`})}),(0,z.jsx)(`option`,{value:`90`,children:a(`mediaGeneration.consentTtl.days90`,{defaultValue:`90 days`})}),(0,z.jsx)(`option`,{value:`365`,children:a(`mediaGeneration.consentTtl.days365`,{defaultValue:`One year`})})]})})]}),!M&&(0,z.jsx)(`p`,{className:`text-xs font-normal text-amber-700 dark:text-amber-300`,children:a(`mediaGeneration.cloneConsent`)})]})]}),s===`video`&&Ce?.supports_audio&&(0,z.jsxs)(`label`,{className:`flex items-center gap-3 text-sm`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:fe,onChange:e=>q(e.target.checked)}),a(`mediaGeneration.generateAudio`)]}),(0,z.jsxs)(H,{label:s===`video`||Q?.mode===`sound`?a(`mediaGeneration.prompt`):a(`mediaGeneration.text`),children:[(0,z.jsx)(`textarea`,{value:h,onChange:e=>v(e.target.value),rows:6,maxLength:De,className:f(W,`resize-none`),placeholder:a(s===`audio`&&Q?.mode===`sound`?`mediaGeneration.soundPlaceholder`:`mediaGeneration.${s}Placeholder`)}),De&&(0,z.jsxs)(`span`,{className:`block text-end text-xs font-normal text-gray-500 dark:text-dark-500`,children:[h.length,` / `,De]})]})]})]}),X.length>0&&(0,z.jsx)(`div`,{className:`border-t border-gray-200/70 p-4 dark:border-white/[0.08] sm:px-5`,children:(0,z.jsxs)(O,{onClick:J?()=>{Y.current?.abort()}:async()=>{if(!Z||!h.trim())return;let e=new AbortController;Y.current?.abort(),Y.current=e,he(!0);try{if(s===`audio`){let t=se(Q?.config?.default_format),n=$?await k.cloneVoice({model:Z.model,pluginId:Z.plugin,input:h.trim(),referenceAudio:E,referenceText:A.trim()||void 0,responseFormat:t,saveVoiceName:M?P.trim():void 0,consentToStore:M&&I,consentTtlDays:M&&te!==null?te:void 0},e.signal):Q?.mode===`sound`?await k.generateSound({model:Z.model,pluginId:Z.plugin,prompt:h.trim(),voice:y.trim()||Q?.config?.default_voice||void 0,format:`wav`},e.signal):await k.generateAudio({model:Z.model,pluginId:Z.plugin,input:h.trim(),voice:y.trim()||Q?.config?.default_voice||void 0,response_format:t},e.signal);if(e.signal.aborted)return;if(!n.success)throw Error(n.message);if($&&M&&(await o.invalidateQueries({queryKey:[`tts-voice-profiles`]}),e.signal.aborted))return}else{let t=await k.generateVideo({model:Z.model,pluginId:Z.plugin,prompt:h.trim(),...ue?{duration:Number(ue)}:{},...V?{resolution:V}:{},...K?{aspect_ratio:K}:{},...Ce?.supports_audio?{generate_audio:fe}:{}},e.signal);if(e.signal.aborted)return;if(!t.success||!t.data)throw Error(t.message||a(`mediaGeneration.failed`));let n=t.data;_e(e=>[n,...e.filter(e=>e.id!==n.id)]);let r=await Oe(n,e,!0);if(r.status===`failed`)throw Error(r.error||a(`mediaGeneration.failed`))}if(e.signal.aborted)return;D.success($&&M?a(`mediaGeneration.successWithSavedVoice`,{name:P.trim(),defaultValue:`Media generated and “{{name}}” is now available in Speech settings`}):a(`mediaGeneration.success`)),v(``),ye(),r(),n()}catch(t){if(e.signal.aborted)return;D.error(t instanceof Error?t.message:a(`mediaGeneration.failed`))}finally{Y.current===e&&(Y.current=null,he(!1))}},disabled:J?!1:!Z||!h.trim()||!!(De&&h.length>De)||$&&(!E||Te&&!A.trim()||M&&(!P.trim()||!I)),className:`w-full gap-2`,children:[J?(0,z.jsx)(C,{className:`h-4 w-4`}):(0,z.jsx)(_,{className:`h-4 w-4`}),J?s===`video`?a(`mediaGeneration.stopWaiting`,{defaultValue:`Stop waiting`}):a(`common.cancel`):a(`mediaGeneration.generate`)]})})]})]}),document.body):null}function H({label:e,children:t}){return(0,z.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-gray-700 dark:text-gray-300`,children:[(0,z.jsx)(`span`,{children:e}),t]})}function U(e){return`${e.mode||`default`}::${e.plugin}::${e.model}`}function oe(e,t){return t?.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=window.setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{window.clearTimeout(i),r(t?.reason)};t?.addEventListener(`abort`,a,{once:!0})})}function se(e){return[`mp3`,`opus`,`aac`,`flac`,`wav`,`pcm`].includes(e||``)?e:`mp3`}function ce(e){return e>=1048576?`${Math.ceil(e/1048576)} MB`:`${Math.ceil(e/1024)} KB`}var W=`w-full rounded-xl border border-gray-200/80 bg-white/70 px-3 py-2.5 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-primary-500/20 dark:border-white/10 dark:bg-white/[0.035] dark:text-gray-100`,G=u(`components:image-edit-panel`),K=e=>e.filter(e=>!!e.config?.edit_endpoint),le=({isOpen:e,onClose:t,source:n,onEdited:r})=>{let{t:i}=d(),[a,o]=(0,R.useState)([]),[s,c]=(0,R.useState)(``),[l,u]=(0,R.useState)(``),[f,p]=(0,R.useState)(36),[h,_]=(0,R.useState)([]),[v,y]=(0,R.useState)(!1),[x,S]=(0,R.useState)(null),[w,T]=(0,R.useState)(!1),E=(0,R.useRef)(null),A=(0,R.useRef)(null),j=(0,R.useRef)(null),M=(0,R.useRef)(!1),N=(0,R.useRef)(null),P=a.find(e=>`${e.plugin}:${e.model}`===s);(0,R.useEffect)(()=>{if(!e)return;let t=!1;return ee.getModels().then(e=>{if(t||!e.success||!e.data)return;let n=K(e.data);o(n),c(e=>n.some(t=>`${t.plugin}:${t.model}`===e)?e:n[0]?`${n[0].plugin}:${n[0].model}`:``)}),()=>{t=!0}},[e]),(0,R.useEffect)(()=>{if(!e||!n)return;let t=null,r=!1;return k.getGalleryContent(n.id).then(e=>{r||(t=URL.createObjectURL(e),S(t))}).catch(e=>{G.error(`Failed to load the source image:`,e),D.error(i(`imageEdit.loadFailed`))}),()=>{r=!0,t&&URL.revokeObjectURL(t),S(null),T(!1),_([])}},[e,n?.id]),(0,R.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let F=()=>{let e=j.current,t=E.current,n=A.current;if(!e||!t||!n)return;let r=e.getContext(`2d`);r&&(r.clearRect(0,0,e.width,e.height),r.drawImage(t,0,0,e.width,e.height),r.save(),r.globalAlpha=.55,r.drawImage(n,0,0,e.width,e.height),r.restore())},I=()=>{let e=E.current,t=j.current;if(!e||!t)return;let n=e.naturalWidth,r=e.naturalHeight;t.width=n,t.height=r;let i=document.createElement(`canvas`);i.width=n,i.height=r,A.current=i,T(!1),F()},L=e=>{let t=j.current,n=A.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=(e.clientX-r.left)/r.width*t.width,a=(e.clientY-r.top)/r.height*t.height,o=n.getContext(`2d`);if(!o)return;let s=f/r.width*t.width;o.fillStyle=`rgba(239, 68, 68, 1)`,o.beginPath(),o.arc(i,a,s,0,Math.PI*2),o.fill(),T(!0),F()},te=()=>{let e=A.current;e&&(e.getContext(`2d`)?.clearRect(0,0,e.width,e.height),T(!1),F())},re=async()=>{let e=A.current;if(!e||!w)return null;let t=document.createElement(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);return n?(n.fillStyle=`#000000`,n.fillRect(0,0,t.width,t.height),n.globalCompositeOperation=`destination-out`,n.drawImage(e,0,0),new Promise(e=>t.toBlob(t=>e(t),`image/png`))):null},ie=async()=>{if(!n||!P||!l.trim()||v)return;y(!0);let e=new AbortController;N.current=e;try{let a=await re(),o=await k.editImage({model:P.model,pluginId:P.plugin,prompt:l.trim(),sourceMediaId:n.id,images:h,...a?{mask:a}:{}},e.signal);if(!o.success)throw Error(o.message||o.error||`Edit failed`);D.success(i(`imageEdit.saved`)),r(),t()}catch(t){e.signal.aborted||(G.error(`Image edit failed:`,t),D.error(t instanceof Error?t.message:i(`imageEdit.failed`)))}finally{y(!1),N.current=null}};if(!e||!n)return null;let B=Math.max(0,(P?.config?.max_reference_images??1)-1);return(0,ne.createPortal)((0,z.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":i(`imageEdit.title`),className:`fixed inset-0 z-[70] flex items-center justify-center bg-black/50 p-4`,"data-testid":`image-edit-panel`,children:(0,z.jsxs)(`div`,{className:`flex max-h-[90vh] w-full max-w-3xl flex-col overflow-hidden rounded-2xl bg-white shadow-xl dark:bg-dark-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-dark-300`,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold text-gray-900 dark:text-gray-100`,children:[(0,z.jsx)(b,{className:`h-4 w-4`}),i(`imageEdit.title`)]}),(0,z.jsx)(`button`,{type:`button`,onClick:t,"aria-label":i(`common.close`),className:`rounded-full p-1.5 text-gray-500 hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,z.jsx)(C,{className:`h-5 w-5`})})]}),(0,z.jsx)(`div`,{className:`flex-1 space-y-4 overflow-y-auto p-4`,children:a.length===0?(0,z.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:i(`imageEdit.noModels`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`relative`,children:x?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`img`,{ref:E,src:x,alt:n.prompt,className:`hidden`,onLoad:I}),(0,z.jsx)(`canvas`,{ref:j,onPointerDown:e=>{M.current=!0,e.currentTarget.setPointerCapture(e.pointerId),L(e)},onPointerMove:e=>{M.current&&L(e)},onPointerUp:()=>{M.current=!1},className:`w-full cursor-crosshair rounded-xl border border-gray-200 dark:border-dark-300`,"data-testid":`image-edit-canvas`})]}):(0,z.jsx)(`div`,{className:`flex h-56 items-center justify-center`,children:(0,z.jsx)(g,{className:`h-6 w-6 animate-spin text-gray-400`})})}),(0,z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:i(`imageEdit.maskHint`)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-gray-600 dark:text-gray-300`,children:[i(`imageEdit.brushSize`),(0,z.jsx)(`input`,{type:`range`,min:8,max:96,value:f,onChange:e=>p(Number(e.target.value))})]}),(0,z.jsxs)(O,{type:`button`,size:`sm`,variant:`outline`,onClick:te,disabled:!w,children:[(0,z.jsx)(m,{className:`mr-1 h-3.5 w-3.5`}),i(`imageEdit.clearMask`)]})]}),(0,z.jsxs)(`label`,{className:`block text-xs font-medium text-gray-700 dark:text-gray-300`,children:[i(`imageEdit.model`),(0,z.jsx)(`select`,{value:s,onChange:e=>c(e.target.value),className:`mt-1 w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50`,children:a.map(e=>(0,z.jsxs)(`option`,{value:`${e.plugin}:${e.model}`,children:[e.plugin,` · `,e.model]},`${e.plugin}:${e.model}`))})]}),(0,z.jsxs)(`label`,{className:`block text-xs font-medium text-gray-700 dark:text-gray-300`,children:[i(`imageEdit.prompt`),(0,z.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:3,placeholder:i(`imageEdit.promptPlaceholder`),className:`mt-1 w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50`,"data-testid":`image-edit-prompt`})]}),B>0&&(0,z.jsxs)(`label`,{className:`block text-xs font-medium text-gray-700 dark:text-gray-300`,children:[i(`imageEdit.referenceImages`,{total:B}),(0,z.jsx)(`input`,{type:`file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,onChange:e=>_(Array.from(e.target.files??[]).slice(0,B)),className:`mt-1 block w-full text-xs`})]})]})}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-gray-200 px-4 py-3 dark:border-dark-300`,children:[(0,z.jsx)(O,{type:`button`,variant:`outline`,onClick:t,children:i(`common.cancel`)}),(0,z.jsxs)(O,{type:`button`,onClick:()=>void ie(),disabled:v||!P||!l.trim()||!x,"data-testid":`image-edit-submit`,children:[v?(0,z.jsx)(g,{className:`mr-1 h-4 w-4 animate-spin`}):(0,z.jsx)(b,{className:`mr-1 h-4 w-4`}),i(`imageEdit.apply`)]})]})]})}),document.body)},ue=({image:e,onClose:t,onDelete:n,onDownload:r})=>{let{t:i}=d();return(0,R.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=``}},[t]),(0,ne.createPortal)((0,z.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center`,onClick:t,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-black/90 backdrop-blur-sm`}),(0,z.jsxs)(`div`,{className:`relative flex flex-col lg:flex-row max-w-7xl max-h-[95vh] w-full mx-4 gap-4`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`button`,{onClick:t,className:f(`absolute -top-12 right-0 lg:top-0 lg:-right-12 z-10`,`p-2 rounded-full`,`bg-white/10 hover:bg-white/20`,`transition-colors`),children:(0,z.jsx)(C,{className:`h-6 w-6 text-white`})}),(0,z.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-0`,children:(0,z.jsx)(`img`,{src:e.imageData,alt:e.prompt,className:`max-w-full max-h-[70vh] lg:max-h-[90vh] object-contain rounded-lg`})}),(0,z.jsxs)(`div`,{className:f(`w-full lg:w-80 flex-shrink-0`,`bg-white dark:bg-dark-100`,`rounded-xl p-4 lg:p-5`,`overflow-y-auto max-h-[25vh] lg:max-h-[90vh]`),children:[(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400 mb-1`,children:i(`gallery.prompt`)}),(0,z.jsx)(`p`,{className:`text-gray-900 dark:text-gray-100 text-sm leading-relaxed`,children:e.prompt})]}),(0,z.jsxs)(`div`,{className:`space-y-3 mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,z.jsx)(p,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.model`),`:`]}),(0,z.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:e.model})]}),e.size&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,z.jsx)(x,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.size`),`:`]}),(0,z.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:e.size})]}),e.quality&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,z.jsx)(`span`,{className:`w-4 h-4 flex items-center justify-center text-gray-400 dark:text-gray-500 text-xs font-bold`,children:`Q`}),(0,z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.quality`),`:`]}),(0,z.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100 capitalize`,children:e.quality})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,z.jsx)(y,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[i(`gallery.created`),`:`]}),(0,z.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:(e=>new Date(e).toLocaleString(void 0,{year:`numeric`,month:`long`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}))(e.createdAt)})]})]}),(0,z.jsxs)(`div`,{className:`flex gap-2 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,z.jsxs)(`button`,{onClick:()=>{if(r)r(e);else{let t=document.createElement(`a`);t.href=e.imageData,t.download=`generated-${e.id}.${M(e.imageData)}`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}},className:f(`flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg`,`bg-primary-600 dark:bg-primary-600`,`hover:bg-primary-700 dark:hover:bg-primary-500`,`text-white font-medium text-sm`,`transition-colors`),children:[(0,z.jsx)(v,{className:`h-4 w-4`}),i(`gallery.download`)]}),n&&(0,z.jsx)(`button`,{onClick:()=>n(e.id),className:f(`p-2.5 rounded-lg`,`bg-gray-100 dark:bg-dark-200`,`hover:bg-red-100 dark:hover:bg-red-900/30`,`text-gray-600 dark:text-gray-300`,`hover:text-red-600 dark:hover:text-red-400`,`transition-colors`),title:`Delete image`,children:(0,z.jsx)(E,{className:`h-4 w-4`})})]})]})]})]}),document.body)};function de({kind:e,refreshKey:t,onCountChange:n,onEditImage:r}){let{t:a}=d(),o=i(),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(null),f=te({queryKey:[`media-gallery`,e||`all`,t||0],queryFn:async({pageParam:t})=>{let n=await k.getGallery({limit:20,offset:t,...e?{kind:e}:{}});if(!n.success||!n.data)throw Error(n.message||a(`imageGallery.loadFailed`));return n.data},initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.media.length,0);return n<e.total?n:void 0}}),p=(0,R.useMemo)(()=>f.data?.pages.flatMap(e=>e.media)||[],[f.data]),m=f.data?.pages[0]?.total||0;(0,R.useEffect)(()=>n?.(m),[n,m]);let h=async e=>{if(!l){u(e.id);try{let t=await k.deleteGalleryItem(e.id);if(!t.success)throw Error(t.message);c(null),await o.invalidateQueries({queryKey:[`media-gallery`]}),D.success(a(`imageGallery.deleteSuccess`))}catch{D.error(a(`imageGallery.deleteFailed`))}finally{u(null)}}},_=async e=>{let t=await k.getGalleryContent(e.id),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`generated-${e.id}.${pe(e.mimeType)}`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)};return f.isLoading?(0,z.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,z.jsx)(g,{className:`h-8 w-8 animate-spin text-gray-400`})}):p.length===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl border border-dashed border-gray-300 bg-white/30 px-6 py-12 text-center dark:border-white/15 dark:bg-white/[0.02]`,children:[(0,z.jsx)(T,{className:`mb-4 h-10 w-10 text-gray-300 dark:text-gray-600`}),(0,z.jsx)(`h3`,{className:`text-lg font-medium`,children:a(`mediaGallery.empty`)}),(0,z.jsx)(`p`,{className:`mt-2 max-w-sm text-gray-500 dark:text-gray-400`,children:a(`mediaGallery.emptyHint`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,children:p.map(e=>(0,z.jsxs)(`article`,{className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/70 dark:border-white/10 dark:bg-white/[0.025]`,children:[(0,z.jsx)(fe,{item:e,onOpenImage:t=>c(q(e,t))}),(0,z.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,z.jsx)(`p`,{className:`line-clamp-2 text-sm text-gray-800 dark:text-gray-200`,children:e.prompt}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-xs text-gray-500`,children:e.model}),(0,z.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[e.kind===`image`&&r&&(0,z.jsx)(`button`,{onClick:()=>r(e),className:`rounded-lg p-1.5 hover:bg-gray-100 dark:hover:bg-white/10`,title:a(`imageEdit.title`),"data-testid":`edit-image-${e.id}`,children:(0,z.jsx)(b,{className:`h-4 w-4`})}),(0,z.jsx)(`button`,{onClick:()=>void _(e),className:`rounded-lg p-1.5 hover:bg-gray-100 dark:hover:bg-white/10`,title:a(`imageGallery.download`),children:(0,z.jsx)(v,{className:`h-4 w-4`})}),(0,z.jsx)(`button`,{onClick:()=>void h(e),disabled:l===e.id,className:`rounded-lg p-1.5 hover:bg-red-500/15 hover:text-red-500`,title:a(`imageGallery.delete`),children:l===e.id?(0,z.jsx)(g,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(E,{className:`h-4 w-4`})})]})]})]})]},e.id))}),f.hasNextPage&&(0,z.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,z.jsx)(O,{variant:`outline`,disabled:f.isFetchingNextPage,onClick:()=>void f.fetchNextPage(),children:f.isFetchingNextPage?a(`common.loading`):a(`imageGallery.loadMore`,{current:p.length,total:m})})}),s&&(0,z.jsx)(ue,{image:s,onClose:()=>c(null),onDelete:e=>{let t=p.find(t=>t.id===e);t&&h(t)},onDownload:e=>{let t=p.find(t=>t.id===e.id);t&&_(t)}})]})}function fe({item:e,onOpenImage:t}){let{data:n,isLoading:r}=l({queryKey:[`media-gallery-content`,e.id],queryFn:()=>k.getGalleryContent(e.id),staleTime:3e5}),i=(0,R.useMemo)(()=>n?URL.createObjectURL(n):``,[n]),a=(0,R.useRef)(new Map);return(0,R.useEffect)(()=>{if(!i)return;let e=a.current,t=e.get(i);return t&&(clearTimeout(t),e.delete(i)),()=>{e.set(i,setTimeout(()=>{e.delete(i),URL.revokeObjectURL(i)},0))}},[i]),r||!i?(0,z.jsx)(`div`,{className:`flex aspect-video items-center justify-center bg-gray-100 dark:bg-white/[0.03]`,children:(0,z.jsx)(g,{className:`h-6 w-6 animate-spin text-gray-400`})}):e.kind===`image`?(0,z.jsx)(`button`,{className:`block aspect-square w-full overflow-hidden`,onClick:()=>t(i),children:(0,z.jsx)(`img`,{src:i,alt:e.prompt,className:`h-full w-full object-cover`,loading:`lazy`})}):e.kind===`video`?(0,z.jsx)(`div`,{className:`aspect-video bg-black`,children:(0,z.jsx)(`video`,{src:i,controls:!0,preload:`metadata`,className:`h-full w-full object-contain`})}):(0,z.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-3 bg-gradient-to-br from-primary-500/10 to-cyan-500/10 p-4`,children:[(0,z.jsx)(w,{className:`h-9 w-9 text-primary-500`}),(0,z.jsx)(`audio`,{src:i,controls:!0,preload:`metadata`,className:`w-full`})]})}function q(e,t){return{id:e.id,userId:e.userId,prompt:e.prompt,model:e.model,imageData:t,size:e.size,quality:e.quality,createdAt:e.createdAt}}function pe(e){let t=e.split(`/`)[1]?.split(`;`)[0];return t===`mpeg`?e.startsWith(`audio/`)?`mp3`:`mpeg`:t===`svg+xml`?`svg`:t||`bin`}var me=()=>{let{t:e}=d(),[t,n]=(0,R.useState)(null),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)(`all`),[l,u]=(0,R.useState)(null),[p,m]=(0,R.useState)(0),g=P(e=>e.preferences.imageGenSettings?.enabled===!0),_=(0,R.useCallback)(()=>{m(e=>e+1)},[]);return(0,z.jsxs)(I,{width:`wide`,children:[(0,z.jsx)(F,{title:e(`sidebar.navigation.imagine`),description:e(`gallery.subtitle`),meta:t!==null&&t>0?(0,z.jsx)(`span`,{className:`inline-flex rounded-full border border-gray-200/80 bg-white/60 px-2.5 py-1 text-xs text-gray-500 dark:border-white/10 dark:bg-white/[0.04] dark:text-dark-500`,children:e(`mediaGallery.itemCount`,{count:t})}):null,actions:(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(O,{onClick:()=>{g&&i(!0)},disabled:!g,className:`gap-2 px-4`,children:[(0,z.jsx)(h,{className:`h-4 w-4`,"aria-hidden":`true`}),e(`gallery.generate`)]}),(0,z.jsxs)(O,{variant:`outline`,onClick:()=>o(`video`),className:`gap-2 px-4`,children:[(0,z.jsx)(S,{className:`h-4 w-4`,"aria-hidden":`true`}),e(`mediaGeneration.video`)]}),(0,z.jsxs)(O,{variant:`outline`,onClick:()=>o(`audio`),className:`gap-2 px-4`,children:[(0,z.jsx)(w,{className:`h-4 w-4`,"aria-hidden":`true`}),e(`mediaGeneration.audio`)]})]})}),(0,z.jsx)(`div`,{className:`mb-5 flex flex-wrap gap-2`,children:[`all`,`image`,`video`,`audio`].map(t=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>c(t),className:f(`rounded-full border px-3 py-1.5 text-sm transition-colors`,s===t?`border-gray-950 bg-gray-950 text-white dark:border-white dark:bg-white dark:text-gray-950`:`border-gray-200 text-gray-600 hover:border-gray-400 dark:border-white/10 dark:text-dark-600`),children:e(`mediaGallery.filters.${t}`)},t))}),(0,z.jsx)(de,{kind:s===`all`?void 0:s,refreshKey:p,onCountChange:n,onEditImage:u}),(0,z.jsx)(le,{isOpen:l!==null,source:l,onClose:()=>u(null),onEdited:_}),(0,z.jsx)(B,{isOpen:r&&g,onClose:()=>i(!1),onImageGenerated:_}),(0,z.jsx)(V,{isOpen:a!==null,initialKind:a||`video`,onClose:()=>o(null),onGenerated:_},a||`closed`)]})};export{me as GalleryPage,me as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{d as r}from"./router-vendor-DqMnEJWK.js";import{t as i}from"./chatStore-DpVxt9VX.js";import{t as a}from"./useTranslation-Boi0fB1B.js";import{i as o,o as s,t as c}from"./utils-B-Bhh1pF.js";import{Et as l,M as u,c as d,cr as f,mt as p,nr as m,rr as h,sn as g,t as _}from"./ui-vendor-DVTj_sKN.js";import{d as v,t as y}from"./authStore-DjAsRpNL.js";import{i as b,t as x}from"./work-CdbmBok5.js";import{n as S,r as C,t as w}from"./appNavigation-B6xYIgLi.js";import{t as T}from"./appVersion-BVtSqLVj.js";var E=e(t(),1),D=n(),O=e=>e<5?`chat.greeting.night`:e<12?`chat.greeting.morning`:e<18?`chat.greeting.afternoon`:`chat.greeting.evening`,k=`mb-2 text-xs font-medium text-ink-muted`,A=`group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-start text-sm text-ink-muted transition-colors hover:bg-white hover:text-ink dark:hover:bg-dark-200 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,j=()=>{let{t:e,i18n:t}=a(),n=r(),{user:j,systemInfo:M,canUseWork:N,canUseStrands:P}=y(),F=i(e=>e.sessions),I=i(e=>e.models),L=v(e=>e.tasks),R=v(e=>e.capabilities),z=v(e=>e.loadTasks),B=v(e=>e.loadCapabilities),V=N(),H=P();(0,E.useEffect)(()=>{V&&(z(!0).catch(()=>{}),B().catch(()=>{}))},[V,z,B]);let U=e(O(new Date().getHours())),W=j?.username,G=[...F].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,4),K=[...L].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()).slice(0,3),q=R?.activeRuntimes?.user??0,J=s()?`⌘`:`Ctrl`,Y=G.length>0||K.length>0,X=T(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-ink`,children:W?`${U}, ${W}.`:`${U}.`}),(0,D.jsxs)(`p`,{"data-testid":`app-version`,className:`mt-1 font-mono text-xs text-ink-subtle`,children:[window.location.host||`Libre WebUI`,X?` · v${X}`:``]}),(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:()=>S(n),children:[(0,D.jsx)(l,{className:`h-4 w-4 shrink-0 text-ink-subtle transition-colors group-hover:text-ink-muted`}),(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-ink-subtle opacity-0 transition-opacity group-hover:opacity-100`,children:[J,`⇧O`]})]}),(0,D.jsxs)(`button`,{type:`button`,"data-testid":`home-incognito-chat`,className:A,onClick:()=>w(n),children:[(0,D.jsx)(g,{className:`h-4 w-4 shrink-0 text-ink-subtle transition-colors group-hover:text-ink-muted`}),(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:()=>C(n),children:[(0,D.jsx)(h,{className:`h-4 w-4 shrink-0 text-ink-subtle transition-colors group-hover:text-ink-muted`}),(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-ink-subtle opacity-0 transition-opacity group-hover:opacity-100`,children:[J,`⇧U`]})]})]})]}),Y&&(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:c(k,`mb-0`),children:e(`home.continue`,`Continue`)}),V&&q>0&&(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[10px] text-ink-subtle`,children:[(0,D.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse-subtle rounded-full bg-[rgb(48,121,255)]`}),q,` `,e(`home.active`,`active`)]})]}),(0,D.jsxs)(`div`,{className:`-mx-2.5 flex flex-col`,children:[K.map(r=>{let i=b[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:c(`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-ink-subtle sm:inline`,title:r.hostPath,children:r.hostPath}),(0,D.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-subtle`,children:x(r)?e(i.labelKey,i.label):o(new Date(r.updatedAt).getTime(),t.language)})]},r.id)}),G.map(r=>(0,D.jsxs)(`button`,{type:`button`,"data-testid":`home-continue-chat`,className:A,onClick:()=>n(`/c/${r.id}`),children:[(0,D.jsx)(l,{className:`h-4 w-4 shrink-0 text-ink-subtle`}),(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-ink-subtle sm:inline`,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-ink-subtle`,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`,p,e(`sidebar.navigation.notes`,`Notes`)],[`/calendar`,m,e(`sidebar.navigation.calendar`,`Calendar`)],[`/automations`,_,e(`sidebar.navigation.automations`,`Automations`)],[`/personas`,d,e(`sidebar.navigation.personas`,`Personas`)],[`/gallery`,u,e(`sidebar.navigation.imagine`,`Imagine`)],...H?[[`/strands`,f,e(`sidebar.navigation.strands`,`Strands`)]]:[]].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-ink-subtle transition-colors group-hover:text-ink-muted`}),(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{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{C as r,D as i,E as a}from"./chatStore-DpVxt9VX.js";import{t as o}from"./useTranslation-Boi0fB1B.js";import{t as s}from"./utils-B-Bhh1pF.js";import{E as c,J as l,T as u,Zn as d,_t as f,ct as p,w as m,zn as h}from"./ui-vendor-DVTj_sKN.js";import{t as g}from"./authStore-DjAsRpNL.js";import{f as _,l as v,n as y,p as b,t as x,u as S}from"./appStore-DkRdQQeY.js";var C=e(t(),1),w=e=>e===`/`||/^\/(?:chat\/?|c\/[^/]+\/?|work(?:\/[^/]+)?\/?)$/.test(e),T=524288,E=1024;function D(e,t,n=2){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)return{width:0,height:0};let r=Math.min(1/Math.max(1,n),E/Math.max(e,t),Math.sqrt(T/(e*t)));return{width:Math.max(1,Math.floor(e*r)),height:Math.max(1,Math.floor(t*r))}}function O(e,t,n,r){let i=Math.max(n/e,r/t),a=n/i,o=r/i;return{x:(e-a)/2,y:(t-o)/2,width:a,height:o}}var k=[0,48,12,60,3,51,15,63,32,16,44,28,35,19,47,31,8,56,4,52,11,59,7,55,40,24,36,20,43,27,39,23,2,50,14,62,1,49,13,61,34,18,46,30,33,17,45,29,10,58,6,54,9,57,5,53,42,26,38,22,41,25,37,21];function A(e){let t=new Float32Array(e);for(let n=0;n<t.length;n+=4){let r=Math.max(e[n],e[n+1],e[n+2]);if(r===0)continue;let i=M[e[n]]*.2126+M[e[n+1]]*.7152+M[e[n+2]]*.0722,a=N[Math.round(i*4096)],o=(a<=64?a:64+(a-64)*48/191)/r;for(let r=0;r<3;r+=1)t[n+r]=e[n+r]*o}return t}function j(e,t,n){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<0||t*n*4!==e.length)throw RangeError(`Wallpaper pixel dimensions do not match the buffer`);let r=new Uint8ClampedArray(e);for(let i=0;i<n;i+=1)for(let n=0;n<t;n+=1){let a=(i*t+n)*4,o=(k[i%8*8+n%8]+.5)/64-.5,s=Math.max(e[a],e[a+1],e[a+2]);if(s===0)continue;let c=s/255+o>=.5?255/s:0;for(let t=0;t<3;t+=1)r[a+t]=e[a+t]*c}return r}var M=Array.from({length:256},(e,t)=>{let n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),N=Uint8ClampedArray.from({length:4097},(e,t)=>{let n=t/4096;return 255*(n<=.0031308?n*12.92:1.055*n**(1/2.4)-.055)});function P(e){let t=new Uint8ClampedArray(e);for(let e=0;e<t.length;e+=4){let n=M[t[e]],r=M[t[e+1]],i=M[t[e+2]],a=n*.2126+r*.7152+i*.0722;if(a<=.16)continue;let o=.16/a;t[e]=N[Math.round(n*o*4096)],t[e+1]=N[Math.round(r*o*4096)],t[e+2]=N[Math.round(i*o*4096)]}return t}function F(e,t,n){let r=P(j(A(e),t,n));for(let e=0;e<r.length;e+=4)r[e]===0&&r[e+1]===0&&r[e+2]===0&&(r[e+3]=0);return r}var I=n();function L({settings:e,testId:t=`wallpaper-layer`}){return!e.enabled||!e.imageUrl||e.opacity===0?null:(0,I.jsx)(R,{settings:e,testId:t})}function R({settings:e,testId:t}){let n=(0,C.useRef)(null),r=(0,C.useRef)(null),[i,a]=(0,C.useState)(null),{imageUrl:o,effect:s}=e,c=x(e=>e.theme.mode),l=S(e=>e.palette?.isDark),u=c===`dark`||c===`amoled`||c===`celestial`&&l===!0,d=i?.source===o&&i.effect===s&&i.dark===u?i.state:`loading`;return(0,C.useEffect)(()=>{let e=n.current;if(!e)return;let t=!1,i,c=new Image;c.decoding=`async`,c.referrerPolicy=`no-referrer`,(s===`dither`||u)&&(c.crossOrigin=`anonymous`);let l=e=>{t||a({source:o,effect:s,state:e,dark:u})},d=()=>{if(t||!c.naturalWidth||!c.naturalHeight)return;let n=r.current,{width:i,height:a}=e.getBoundingClientRect(),o=D(i,a,s===`dither`?3:1);if(n&&o.width&&o.height)try{n.width=o.width,n.height=o.height;let e=n.getContext(`2d`,{willReadFrequently:!0});if(!e)throw Error(`Canvas unavailable`);let t=O(c.naturalWidth,c.naturalHeight,o.width,o.height);if(e.drawImage(c,t.x,t.y,t.width,t.height,0,0,o.width,o.height),s===`dither`||u){let t=e.getImageData(0,0,o.width,o.height),n=s===`dither`?F(t.data,o.width,o.height):P(t.data);t.data.set(n),e.putImageData(t,0,0)}l(`ready`)}catch{l(`fallback`)}},f=new ResizeObserver(()=>{i&&clearTimeout(i),i=setTimeout(d,100)});return f.observe(e),c.onload=d,c.onerror=()=>l(`fallback`),c.src=o,()=>{t=!0,f.disconnect(),i&&clearTimeout(i),c.onload=null,c.onerror=null,c.removeAttribute(`src`)}},[o,s,u]),(0,I.jsxs)(`div`,{ref:n,"data-testid":t,"data-effect":s,"data-state":d,"data-tone":i?.dark?`dark`:`light`,className:`account-wallpaper`,"aria-hidden":`true`,style:{"--wallpaper-intensity":e.opacity,"--wallpaper-blur":`${e.blurAmount}px`},children:[(0,I.jsxs)(`div`,{className:`account-wallpaper__art`,children:[(0,I.jsx)(`canvas`,{ref:r,"data-testid":`wallpaper-canvas`,className:`account-wallpaper__canvas`}),d===`fallback`&&(0,I.jsx)(`img`,{src:o,alt:``,draggable:!1,referrerPolicy:`no-referrer`,className:`account-wallpaper__photo`})]}),(0,I.jsx)(`div`,{className:`account-wallpaper__veil`})]})}function z({active:e=!0}){let t=x(e=>e.preferences.backgroundSettings),n=x(e=>e.backgroundImage),r=g(e=>e.user?.id),i=g(e=>e.systemInfo?.requiresAuth),a=y(t);return a.imageUrl=n??a.imageUrl,!e||i!==!1&&!r||!a.enabled||!a.imageUrl?null:(0,I.jsx)(L,{settings:a,testId:`app-background`},r??`solo`)}var B=e=>(Math.round(e)%1440+1440)%1440,V=()=>{let{t:e}=o(),t=S(e=>e.palette),n=S(e=>e.previewMinutes),r=S(e=>e.location),i=S(e=>e.weather),a=S(e=>e.weatherEnabled),d=new Date().setHours(0,0,0,0),g=a&&r?i:null,y=(0,C.useMemo)(()=>{let e=new Date(d);return`linear-gradient(to right, ${Array.from({length:17},(t,n)=>{let i=Math.min(n*1440/16,1439);return`${b(e,i,{location:r,weather:g}).sky.mid} ${n*100/16}%`}).join(`, `)})`},[d,r,g]);if(!t)return null;let x=B(n??t.solar.minutes),w=_(x),T=n!==null,E=t.solar.isDay?c:f,D=T?p:h,O=[{key:`sunrise`,minutes:t.solar.sunrise,Icon:u},{key:`sunset`,minutes:t.solar.sunset,Icon:m}];return(0,I.jsxs)(`div`,{className:`celestial-day-preview flex min-w-0 flex-col gap-3`,style:{"--celestial-day-gradient":y,"--celestial-preview-sky":`linear-gradient(${t.sky.top}, ${t.sky.mid} 65%, ${t.sky.horizon})`,"--celestial-preview-glow":t.glow},children:[(0,I.jsxs)(`div`,{className:`celestial-day-preview__header flex min-w-0 items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:e(`settings.appearance.celestial.title`)}),(0,I.jsxs)(`span`,{role:`status`,"data-testid":`celestial-preview-status`,className:`mt-1.5 inline-flex items-center gap-1.5 rounded-full border border-line bg-surface-subtle px-2 py-0.5 text-[11px] font-medium text-ink-muted`,children:[(0,I.jsx)(D,{className:`h-3 w-3`,"aria-hidden":`true`}),e(T?`settings.appearance.celestial.preview`:`settings.appearance.celestial.live`)]})]}),(0,I.jsx)(`span`,{dir:`ltr`,className:`shrink-0 text-xl font-medium tabular-nums tracking-tight text-ink`,"data-testid":`celestial-preview-clock`,children:w})]}),(0,I.jsx)(`p`,{className:`text-xs leading-5 text-ink-muted`,children:e(`settings.appearance.celestial.description`)}),(0,I.jsxs)(`div`,{className:`celestial-day-preview__scene`,"aria-hidden":`true`,dir:`ltr`,children:[(0,I.jsx)(`div`,{className:`celestial-day-preview__horizon`}),(0,I.jsx)(`div`,{className:`celestial-day-preview__orb`,"data-day":t.solar.isDay,style:{left:`clamp(22px, ${x/1439*100}%, calc(100% - 22px))`,bottom:`${20+Math.abs(t.solar.altitude)*45}%`},children:(0,I.jsx)(E,{className:`h-5 w-5`,strokeWidth:1.5})})]}),(0,I.jsxs)(`div`,{dir:`ltr`,children:[(0,I.jsx)(`input`,{type:`range`,min:0,max:1439,step:1,value:x,onChange:e=>v(Number(e.target.value)),"aria-label":e(`settings.appearance.celestial.title`),"aria-valuetext":w,"data-testid":`celestial-scrubber`,className:`celestial-day-preview__range w-full rounded-full outline-none focus-visible:ring-2 focus-visible:ring-primary-500/60 focus-visible:ring-offset-2 focus-visible:ring-offset-surface`,dir:`ltr`}),(0,I.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`celestial-time-anchors`,className:`flex justify-between gap-2 text-[11px] tabular-nums text-ink-muted`,children:[0,720,1439].map(e=>(0,I.jsx)(`span`,{children:_(e)},e))})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:O.map(({key:t,minutes:n,Icon:r})=>(0,I.jsxs)(`button`,{type:`button`,tabIndex:0,onClick:()=>v(B(n)),"data-testid":`celestial-preview-${t}`,className:`flex min-w-0 items-center gap-2 rounded-xl border border-line px-3 py-2 text-start text-ink hover:bg-interactive-hover outline-none focus-visible:ring-2 focus-visible:ring-primary-500/60`,children:[(0,I.jsx)(r,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[(0,I.jsx)(`span`,{className:`block truncate text-[11px] text-ink-muted`,children:e(`settings.appearance.celestial.${t}`)}),(0,I.jsx)(`span`,{dir:`ltr`,className:`block text-xs tabular-nums`,children:_(n)})]})]},t))}),(0,I.jsxs)(`button`,{type:`button`,tabIndex:0,onClick:()=>v(null),disabled:!T,"data-testid":`celestial-follow-clock`,className:s(`flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-xs font-medium outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-primary-500/60 motion-reduce:transition-none`,T?`border-transparent bg-ink text-ink-inverse hover:opacity-90`:`border-line text-ink-muted disabled:cursor-default`),children:[T?(0,I.jsx)(l,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):(0,I.jsx)(h,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),e(`settings.appearance.celestial.followClock`)]})]})},H=()=>typeof window<`u`&&window.PublicKeyCredential!==void 0&&typeof navigator.credentials?.create==`function`,U=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i.buffer},W=e=>{let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)},G=async e=>{let t=e.user,n={...e,challenge:U(e.challenge),user:{...t,id:U(t.id)},excludeCredentials:(e.excludeCredentials??[]).map(e=>({type:`public-key`,id:U(e.id)}))},r=await navigator.credentials.create({publicKey:n});if(!r)throw Error(`Passkey creation was cancelled`);let i=r.response;return{rawId:W(r.rawId),response:{clientDataJSON:W(i.clientDataJSON),attestationObject:W(i.attestationObject),transports:typeof i.getTransports==`function`?i.getTransports():[]}}},K=async e=>{let t={...e,challenge:U(e.challenge)},n=await navigator.credentials.get({publicKey:t});if(!n)throw Error(`Passkey sign-in was cancelled`);let r=n.response;return{rawId:W(n.rawId),response:{clientDataJSON:W(r.clientDataJSON),authenticatorData:W(r.authenticatorData),signature:W(r.signature),userHandle:r.userHandle?W(r.userHandle):null}}},q=({compact:e=!1})=>{let{t,i18n:n}=o();return(0,I.jsxs)(`div`,{className:s(`flex items-center gap-4`,!e&&`py-4`),children:[(0,I.jsxs)(`div`,{className:s(`min-w-0 flex-1`,e&&`sr-only`),children:[(0,I.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:t(`settings.appearance.language.title`)}),(0,I.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:t(`settings.appearance.language.description`)})]}),(0,I.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,I.jsx)(`select`,{"data-testid":`language-switcher-select`,"aria-label":t(`settings.appearance.language.title`),value:a(n.language),onChange:e=>{let t=e.target.value;r(t)},className:s(e?`max-w-[140px]`:`max-w-[220px]`,`h-9 cursor-pointer appearance-none rounded-full bg-surface-subtle pe-9 ps-3.5 text-sm text-ink transition-colors hover:bg-hover-solid focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`),children:i.map(t=>(0,I.jsx)(`option`,{value:t.code,children:e?t.nativeName:`${t.nativeName} (${t.name})`},t.code))}),(0,I.jsx)(d,{className:`pointer-events-none absolute end-3 top-1/2 h-4 w-4 -translate-y-1/2 text-ink-muted`})]})]})};export{V as a,w as c,H as i,G as n,z as o,K as r,L as s,q as t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-wiHys0m2.js";import{t as n}from"./utils-p8Gt72YP.js";e();var r=t(),i={sm:`text-[1.0625rem] leading-none`,md:`text-[1.625rem] leading-none`,lg:`text-[2.5rem] leading-none`},a=({className:e,size:t=`md`,wordmark:a=!0})=>(0,r.jsxs)(`span`,{dir:`ltr`,className:n(`libre-brand inline-flex items-baseline whitespace-nowrap`,i[t],e),children:[`Libre`,a&&(0,r.jsx)(`span`,{className:`ms-1 font-normal tracking-[-0.035em]`,children:`WebUI`})]});export{a as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-CR5VJ85Q.js";import{t as n}from"./utils-B-Bhh1pF.js";e();var r=t(),i={sm:`text-[1.0625rem] leading-none`,md:`text-[1.625rem] leading-none`,lg:`text-[2.5rem] leading-none`},a=({className:e,size:t=`md`,wordmark:a=!0})=>(0,r.jsxs)(`span`,{dir:`ltr`,className:n(`libre-brand inline-flex items-baseline whitespace-nowrap`,i[t],e),children:[`Libre`,a&&(0,r.jsx)(`span`,{className:`ms-1 font-normal tracking-[-0.035em]`,children:`WebUI`})]});export{a as t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-wiHys0m2.js";import{t as n}from"./utils-p8Gt72YP.js";e();var r=t(),i={sm:`h-6 w-6`,md:`h-8 w-8`,lg:`h-12 w-12`},a=({className:e,size:t=`md`,label:a=`Libre WebUI`})=>(0,r.jsxs)(`svg`,{viewBox:`0 0 64 64`,className:n(`shrink-0`,i[t],e),role:a?`img`:`presentation`,"aria-label":a??void 0,"aria-hidden":!a||void 0,focusable:`false`,children:[(0,r.jsx)(`path`,{d:`M 11.5 18.0 L 11.5 32 A 20.5 20.5 0 0 0 50.58 40.66`,fill:`none`,stroke:`currentColor`,strokeWidth:`11`,strokeLinecap:`round`}),(0,r.jsx)(`path`,{d:`M 50.58 18.0 L 50.58 25.66`,fill:`none`,stroke:`currentColor`,strokeWidth:`11`,strokeLinecap:`round`})]});export{a as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-CR5VJ85Q.js";import{t as n}from"./utils-B-Bhh1pF.js";e();var r=t(),i={sm:`h-6 w-6`,md:`h-8 w-8`,lg:`h-12 w-12`},a=({className:e,size:t=`md`,label:a=`Libre WebUI`})=>(0,r.jsxs)(`svg`,{viewBox:`0 0 64 64`,className:n(`shrink-0`,i[t],e),role:a?`img`:`presentation`,"aria-label":a??void 0,"aria-hidden":!a||void 0,focusable:`false`,children:[(0,r.jsx)(`path`,{d:`M 11.5 18.0 L 11.5 32 A 20.5 20.5 0 0 0 50.58 40.66`,fill:`none`,stroke:`currentColor`,strokeWidth:`11`,strokeLinecap:`round`}),(0,r.jsx)(`path`,{d:`M 50.58 18.0 L 50.58 25.66`,fill:`none`,stroke:`currentColor`,strokeWidth:`11`,strokeLinecap:`round`})]});export{a as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-wiHys0m2.js";import{t as i}from"./useTranslation-B9kflK9S.js";import{t as a}from"./utils-p8Gt72YP.js";import{Z as o,jn as s,n as c,x as l,xn as u}from"./ui-vendor-BhHHyHk3.js";import{t as d}from"./Button-CGMYia4g.js";import{t as f}from"./useDialogFocus-BPTG_Zmy.js";var p=e(t(),1),m=n(),h=r(),g=({models:e,showDetailsModal:t,setShowDetailsModal:n,selectedModelName:r,selectedModelDetails:g,loadingDetails:_,showCopyModal:v,setShowCopyModal:y,copySource:b,setCopySource:x,copyDestination:S,setCopyDestination:C,copying:w,handleCopyModel:T,showCreateModal:E,setShowCreateModal:D,createModelName:O,setCreateModelName:k,createModelfile:A,setCreateModelfile:j,creating:M,handleCreateModel:N,showEmbeddingsModal:P,setShowEmbeddingsModal:F,embeddingsModel:I,setEmbeddingsModel:L,embeddingsInput:R,setEmbeddingsInput:z,embeddingsResult:B,generatingEmbeddings:V,handleGenerateEmbeddings:H})=>{let{t:U}=i(),W=(0,p.useId)(),G=(0,p.useRef)(null),K=(0,p.useRef)(null),q=(0,p.useRef)(null),J=(0,p.useRef)(null);return f(G,{enabled:t,onClose:()=>n(!1)}),f(K,{enabled:v,onClose:()=>y(!1)}),f(q,{enabled:E,onClose:()=>D(!1)}),f(J,{enabled:P,onClose:()=>F(!1)}),(0,h.jsxs)(h.Fragment,{children:[t&&(0,m.createPortal)((0,h.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>n(!1)}),(0,h.jsxs)(`div`,{ref:G,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${W}-details-title`,tabIndex:-1,className:a(`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,h.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,h.jsxs)(`h3`,{id:`${W}-details-title`,className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[U(`modelManager.modals.details.title`),`: `,r]}),(0,h.jsx)(`button`,{type:`button`,"aria-label":U(`common.close`),onClick:()=>n(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,h.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,h.jsx)(`div`,{className:`overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4`,children:_?(0,h.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,h.jsx)(o,{className:`h-6 w-6 animate-spin text-gray-400`})}):g?(0,h.jsxs)(h.Fragment,{children:[g.details&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.info`)}),(0,h.jsx)(`div`,{className:a(`p-3 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-50`),children:(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[g.details.family&&(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`span`,{className:`text-gray-500`,children:[U(`modelManager.modals.details.family`),`:`]}),` `,(0,h.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:g.details.family})]}),g.details.parameter_size&&(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`span`,{className:`text-gray-500`,children:[U(`modelManager.modals.details.parameters`),`:`]}),` `,(0,h.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:g.details.parameter_size})]}),g.details.quantization_level&&(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`span`,{className:`text-gray-500`,children:[U(`modelManager.modals.details.quantization`),`:`]}),` `,(0,h.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:g.details.quantization_level})]}),g.details.format&&(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`span`,{className:`text-gray-500`,children:[U(`modelManager.modals.details.format`),`:`]}),` `,(0,h.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:g.details.format})]})]})})]}),g.system&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.systemPrompt`)}),(0,h.jsx)(`pre`,{className:a(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:g.system})]}),g.template&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.template`)}),(0,h.jsx)(`pre`,{className:a(`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:g.template})]}),g.parameters&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.parameters`)}),(0,h.jsx)(`pre`,{className:a(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:g.parameters})]}),g.license&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.license`)}),(0,h.jsx)(`pre`,{className:a(`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:g.license})]}),g.modelfile&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.modelfile`)}),(0,h.jsx)(`pre`,{className:a(`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:g.modelfile})]})]}):(0,h.jsx)(`p`,{className:`text-center text-gray-500`,children:U(`modelManager.modals.details.noDetails`)})})]})]}),document.body),v&&(0,m.createPortal)((0,h.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>y(!1)}),(0,h.jsxs)(`div`,{ref:K,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${W}-copy-title`,tabIndex:-1,className:a(`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,h.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,h.jsx)(`h3`,{id:`${W}-copy-title`,className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:U(`modelManager.modals.copy.title`)}),(0,h.jsx)(`button`,{type:`button`,"aria-label":U(`common.close`),onClick:()=>y(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,h.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,h.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-copy-source`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.copy.source`)}),(0,h.jsxs)(`select`,{id:`${W}-copy-source`,value:b,onChange:e=>x(e.target.value),className:a(`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,h.jsx)(`option`,{value:``,children:U(`modelManager.modals.copy.selectModel`)}),e.map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-copy-newName`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.copy.newName`)}),(0,h.jsx)(`input`,{id:`${W}-copy-newName`,type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:U(`modelManager.modals.copy.placeholder`),className:a(`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,h.jsxs)(d,{onClick:T,disabled:!b.trim()||!S.trim()||w,className:a(`w-full gap-2`,``),children:[w?(0,h.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(s,{className:`h-4 w-4`}),U(w?`modelManager.modals.copy.copying`:`modelManager.modals.copy.button`)]})]})]})]}),document.body),E&&(0,m.createPortal)((0,h.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>D(!1)}),(0,h.jsxs)(`div`,{ref:q,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${W}-create-title`,tabIndex:-1,className:a(`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,h.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,h.jsx)(`h3`,{id:`${W}-create-title`,className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:U(`modelManager.modals.create.title`)}),(0,h.jsx)(`button`,{type:`button`,"aria-label":U(`common.close`),onClick:()=>D(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,h.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,h.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-create-name`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.create.name`)}),(0,h.jsx)(`input`,{id:`${W}-create-name`,type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:U(`modelManager.modals.create.namePlaceholder`),className:a(`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,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-create-modelfile`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.create.modelfile`)}),(0,h.jsx)(`textarea`,{id:`${W}-create-modelfile`,value:A,onChange:e=>j(e.target.value),placeholder:U(`modelManager.modals.create.modelfilePlaceholder`),rows:8,className:a(`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,h.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500`,children:[U(`modelManager.modals.create.see`),` `,(0,h.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:U(`modelManager.modals.create.docs`)}),` `,U(`modelManager.modals.create.docsLink`)]})]}),(0,h.jsxs)(d,{onClick:N,disabled:!O.trim()||!A.trim()||M,className:a(`w-full gap-2`,``),children:[M?(0,h.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(u,{className:`h-4 w-4`}),U(M?`modelManager.modals.create.creating`:`modelManager.modals.create.button`)]})]})]})]}),document.body),P&&(0,m.createPortal)((0,h.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>F(!1)}),(0,h.jsxs)(`div`,{ref:J,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${W}-embeddings-title`,tabIndex:-1,className:a(`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,h.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,h.jsx)(`h3`,{id:`${W}-embeddings-title`,className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:U(`modelManager.modals.embeddings.title`)}),(0,h.jsx)(`button`,{type:`button`,"aria-label":U(`common.close`),onClick:()=>F(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,h.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,h.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-embeddings-model`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.embeddings.model`)}),(0,h.jsxs)(`select`,{id:`${W}-embeddings-model`,value:I,onChange:e=>L(e.target.value),className:a(`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,h.jsx)(`option`,{value:``,children:U(`modelManager.modals.embeddings.selectModel`)}),e.map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-gray-500`,children:U(`modelManager.modals.embeddings.recommended`)})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-embeddings-input`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.embeddings.input`)}),(0,h.jsx)(`textarea`,{id:`${W}-embeddings-input`,value:R,onChange:e=>z(e.target.value),placeholder:U(`modelManager.modals.embeddings.placeholder`),rows:3,className:a(`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,h.jsxs)(d,{onClick:H,disabled:!I.trim()||!R.trim()||V,className:a(`w-full gap-2`,``),children:[V?(0,h.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(l,{className:`h-4 w-4`}),U(V?`modelManager.modals.embeddings.generating`:`modelManager.modals.embeddings.button`)]}),B&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.embeddings.result`,{count:B.length})}),(0,h.jsxs)(`pre`,{className:a(`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:[`[`,B.slice(0,10).join(`, `),B.length>10&&`, ...`,` ]`]})]})]})]})]}),document.body)]})};export{g as ModelManagerModals,g as default};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-CR5VJ85Q.js";import{t as i}from"./useTranslation-Boi0fB1B.js";import{t as a}from"./utils-B-Bhh1pF.js";import{Z as o,jn as s,n as c,x as l,xn as u}from"./ui-vendor-DVTj_sKN.js";import{t as d}from"./Button-j68Q8KVh.js";import{t as f}from"./useDialogFocus-zSGHkpE4.js";var p=e(t(),1),m=n(),h=r(),g=({models:e,showDetailsModal:t,setShowDetailsModal:n,selectedModelName:r,selectedModelDetails:g,loadingDetails:_,showCopyModal:v,setShowCopyModal:y,copySource:b,setCopySource:x,copyDestination:S,setCopyDestination:C,copying:w,handleCopyModel:T,showCreateModal:E,setShowCreateModal:D,createModelName:O,setCreateModelName:k,createModelfile:A,setCreateModelfile:j,creating:M,handleCreateModel:N,showEmbeddingsModal:P,setShowEmbeddingsModal:F,embeddingsModel:I,setEmbeddingsModel:L,embeddingsInput:R,setEmbeddingsInput:z,embeddingsResult:B,generatingEmbeddings:V,handleGenerateEmbeddings:H})=>{let{t:U}=i(),W=(0,p.useId)(),G=(0,p.useRef)(null),K=(0,p.useRef)(null),q=(0,p.useRef)(null),J=(0,p.useRef)(null);return f(G,{enabled:t,onClose:()=>n(!1)}),f(K,{enabled:v,onClose:()=>y(!1)}),f(q,{enabled:E,onClose:()=>D(!1)}),f(J,{enabled:P,onClose:()=>F(!1)}),(0,h.jsxs)(h.Fragment,{children:[t&&(0,m.createPortal)((0,h.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>n(!1)}),(0,h.jsxs)(`div`,{ref:G,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${W}-details-title`,tabIndex:-1,className:a(`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,h.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,h.jsxs)(`h3`,{id:`${W}-details-title`,className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[U(`modelManager.modals.details.title`),`: `,r]}),(0,h.jsx)(`button`,{type:`button`,"aria-label":U(`common.close`),onClick:()=>n(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,h.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,h.jsx)(`div`,{className:`overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4`,children:_?(0,h.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,h.jsx)(o,{className:`h-6 w-6 animate-spin text-gray-400`})}):g?(0,h.jsxs)(h.Fragment,{children:[g.details&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.info`)}),(0,h.jsx)(`div`,{className:a(`p-3 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-50`),children:(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[g.details.family&&(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`span`,{className:`text-gray-500`,children:[U(`modelManager.modals.details.family`),`:`]}),` `,(0,h.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:g.details.family})]}),g.details.parameter_size&&(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`span`,{className:`text-gray-500`,children:[U(`modelManager.modals.details.parameters`),`:`]}),` `,(0,h.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:g.details.parameter_size})]}),g.details.quantization_level&&(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`span`,{className:`text-gray-500`,children:[U(`modelManager.modals.details.quantization`),`:`]}),` `,(0,h.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:g.details.quantization_level})]}),g.details.format&&(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`span`,{className:`text-gray-500`,children:[U(`modelManager.modals.details.format`),`:`]}),` `,(0,h.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:g.details.format})]})]})})]}),g.system&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.systemPrompt`)}),(0,h.jsx)(`pre`,{className:a(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:g.system})]}),g.template&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.template`)}),(0,h.jsx)(`pre`,{className:a(`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:g.template})]}),g.parameters&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.parameters`)}),(0,h.jsx)(`pre`,{className:a(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:g.parameters})]}),g.license&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.license`)}),(0,h.jsx)(`pre`,{className:a(`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:g.license})]}),g.modelfile&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:U(`modelManager.modals.details.modelfile`)}),(0,h.jsx)(`pre`,{className:a(`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:g.modelfile})]})]}):(0,h.jsx)(`p`,{className:`text-center text-gray-500`,children:U(`modelManager.modals.details.noDetails`)})})]})]}),document.body),v&&(0,m.createPortal)((0,h.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>y(!1)}),(0,h.jsxs)(`div`,{ref:K,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${W}-copy-title`,tabIndex:-1,className:a(`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,h.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,h.jsx)(`h3`,{id:`${W}-copy-title`,className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:U(`modelManager.modals.copy.title`)}),(0,h.jsx)(`button`,{type:`button`,"aria-label":U(`common.close`),onClick:()=>y(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,h.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,h.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-copy-source`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.copy.source`)}),(0,h.jsxs)(`select`,{id:`${W}-copy-source`,value:b,onChange:e=>x(e.target.value),className:a(`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,h.jsx)(`option`,{value:``,children:U(`modelManager.modals.copy.selectModel`)}),e.map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-copy-newName`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.copy.newName`)}),(0,h.jsx)(`input`,{id:`${W}-copy-newName`,type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:U(`modelManager.modals.copy.placeholder`),className:a(`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,h.jsxs)(d,{onClick:T,disabled:!b.trim()||!S.trim()||w,className:a(`w-full gap-2`,``),children:[w?(0,h.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(s,{className:`h-4 w-4`}),U(w?`modelManager.modals.copy.copying`:`modelManager.modals.copy.button`)]})]})]})]}),document.body),E&&(0,m.createPortal)((0,h.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>D(!1)}),(0,h.jsxs)(`div`,{ref:q,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${W}-create-title`,tabIndex:-1,className:a(`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,h.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,h.jsx)(`h3`,{id:`${W}-create-title`,className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:U(`modelManager.modals.create.title`)}),(0,h.jsx)(`button`,{type:`button`,"aria-label":U(`common.close`),onClick:()=>D(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,h.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,h.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-create-name`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.create.name`)}),(0,h.jsx)(`input`,{id:`${W}-create-name`,type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:U(`modelManager.modals.create.namePlaceholder`),className:a(`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,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-create-modelfile`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.create.modelfile`)}),(0,h.jsx)(`textarea`,{id:`${W}-create-modelfile`,value:A,onChange:e=>j(e.target.value),placeholder:U(`modelManager.modals.create.modelfilePlaceholder`),rows:8,className:a(`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,h.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500`,children:[U(`modelManager.modals.create.see`),` `,(0,h.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:U(`modelManager.modals.create.docs`)}),` `,U(`modelManager.modals.create.docsLink`)]})]}),(0,h.jsxs)(d,{onClick:N,disabled:!O.trim()||!A.trim()||M,className:a(`w-full gap-2`,``),children:[M?(0,h.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(u,{className:`h-4 w-4`}),U(M?`modelManager.modals.create.creating`:`modelManager.modals.create.button`)]})]})]})]}),document.body),P&&(0,m.createPortal)((0,h.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>F(!1)}),(0,h.jsxs)(`div`,{ref:J,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${W}-embeddings-title`,tabIndex:-1,className:a(`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,h.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,h.jsx)(`h3`,{id:`${W}-embeddings-title`,className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:U(`modelManager.modals.embeddings.title`)}),(0,h.jsx)(`button`,{type:`button`,"aria-label":U(`common.close`),onClick:()=>F(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,h.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,h.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-embeddings-model`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.embeddings.model`)}),(0,h.jsxs)(`select`,{id:`${W}-embeddings-model`,value:I,onChange:e=>L(e.target.value),className:a(`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,h.jsx)(`option`,{value:``,children:U(`modelManager.modals.embeddings.selectModel`)}),e.map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-gray-500`,children:U(`modelManager.modals.embeddings.recommended`)})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{htmlFor:`${W}-embeddings-input`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.embeddings.input`)}),(0,h.jsx)(`textarea`,{id:`${W}-embeddings-input`,value:R,onChange:e=>z(e.target.value),placeholder:U(`modelManager.modals.embeddings.placeholder`),rows:3,className:a(`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,h.jsxs)(d,{onClick:H,disabled:!I.trim()||!R.trim()||V,className:a(`w-full gap-2`,``),children:[V?(0,h.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(l,{className:`h-4 w-4`}),U(V?`modelManager.modals.embeddings.generating`:`modelManager.modals.embeddings.button`)]}),B&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:U(`modelManager.modals.embeddings.result`,{count:B.length})}),(0,h.jsxs)(`pre`,{className:a(`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:[`[`,B.slice(0,10).join(`, `),B.length>10&&`, ...`,` ]`]})]})]})]})]}),document.body)]})};export{g as ModelManagerModals,g as default};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-CR5VJ85Q.js";import{i as r}from"./router-vendor-DqMnEJWK.js";import{t as i}from"./logger-BR4forr_.js";import{t as a}from"./chatStore-DpVxt9VX.js";import{t as o}from"./useTranslation-Boi0fB1B.js";import{i as s,t as c}from"./utils-B-Bhh1pF.js";import{B as ee,Cn as te,G as ne,Lt as l,M as u,On as re,P as d,Tr as f,Y as p,et as m,gr as ie,it as h,lt as g,m as _,mt as v,n as y,ot as b,s as x,v as ae}from"./ui-vendor-DVTj_sKN.js";import{t as S}from"./Button-j68Q8KVh.js";import{A as C,k as w}from"./api-BrHW-VGd.js";import"./ui-Aq8MP7Ph.js";import{t as oe}from"./RichMessageContent-BfYbVBFz.js";var T=e(t(),1),E=4e3,D=(e,t)=>{let n=e.split(`
2
+ `),r=t.split(`
3
+ `);if(n.length>E||r.length>E)return[...n.map(e=>({type:`removed`,text:e})),...r.map(e=>({type:`added`,text:e}))];let i=Array.from({length:n.length+1},()=>Array(r.length+1).fill(0));for(let e=n.length-1;e>=0;--e)for(let t=r.length-1;t>=0;--t)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0;for(;o<n.length&&s<r.length;)n[o]===r[s]?(a.push({type:`context`,text:n[o]}),o+=1,s+=1):i[o+1][s]>=i[o][s+1]?(a.push({type:`removed`,text:n[o]}),o+=1):(a.push({type:`added`,text:r[s]}),s+=1);for(;o<n.length;)a.push({type:`removed`,text:n[o]}),o+=1;for(;s<r.length;)a.push({type:`added`,text:r[s]}),s+=1;return a},O=e=>e.some(e=>e.type!==`context`),k=n(),A=i(`components:note-tools`),j=({rows:e})=>(0,k.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-lg border border-black/[0.06] font-mono text-[12px] leading-relaxed dark:border-white/[0.08]`,"data-testid":`note-diff-view`,children:e.map((e,t)=>(0,k.jsx)(`div`,{className:c(`whitespace-pre-wrap px-2`,e.type===`added`&&`bg-[rgb(76,212,117)]/[0.12] text-green-800 dark:text-green-300`,e.type===`removed`&&`bg-[rgb(255,61,129)]/[0.10] text-red-800 line-through dark:text-red-300`,e.type===`context`&&`text-gray-600 dark:text-dark-700`),children:e.text||`\xA0`},t))}),M=({note:e,currentContent:t,currentTitle:n,canWrite:r,isOwner:i,initialTab:te,onClose:ne,onApplyContent:d})=>{let{t:m,i18n:ie}=o(),[h,v]=(0,T.useState)(te),[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,L]=(0,T.useState)(null),[R,z]=(0,T.useState)(``),[B,V]=(0,T.useState)(`read`),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)(``),[K,ce]=(0,T.useState)(!1),[q,J]=(0,T.useState)(null),Y=a(e=>e.selectedModel),X=a(e=>e.selectedProviderType),le=a(e=>e.selectedProviderId),ue=(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)(()=>{w.listGrants(`note`,e.id).then(e=>{e.success&&Array.isArray(e.data)&&L(e.data)}).catch(e=>A.error(`Failed to load shares:`,e))},[e.id]);(0,T.useEffect)(()=>{h===`revisions`&&b===null&&ue(),h===`attachments`&&M===null&&Z(),h===`share`&&i&&I===null&&Q()},[h,b,M,I,i,ue,Z,Q]);let de=async t=>{try{let n=await C.restoreRevision(e.id,t);n.success&&n.data?(d(n.data.content,n.data.title),x(null),E(null),f.success(m(`notes.revisionRestored`))):f.error(n.error||m(`notes.revisionRestoreFailed`))}catch(e){A.error(`Failed to restore revision:`,e),f.error(m(`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(),f.success(m(`notes.attachmentAdded`))):f.error(n.error||m(`notes.attachmentFailed`))}catch(e){A.error(`Failed to upload attachment:`,e),f.error(m(`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),f.error(m(`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=R.trim();if(t){U(!0);try{let n=await w.resolvePrincipal(t);if(!n.success||!n.data){f.error(m(`notes.shareUserNotFound`));return}let r=await w.createGrant({resourceType:`note`,resourceId:e.id,principalType:`user`,principalId:n.data.id,permission:B});r.success?(z(``),Q(),f.success(m(`notes.shareAdded`,{username:t}))):f.error(r.error||m(`notes.shareFailed`))}catch(e){A.error(`Failed to share note:`,e),f.error(m(`notes.shareFailed`))}finally{U(!1)}}},ge=async e=>{try{(await w.deleteGrant(e)).success&&Q()}catch(e){A.error(`Failed to revoke share:`,e)}},_e=async()=>{if(W.trim()&&Y){ce(!0),J(null);try{let t=await C.assist(e.id,{instruction:W,model:Y,providerType:X,providerId:le});t.success&&t.data?.content!==void 0?J(t.data.content):f.error(t.error||m(`notes.assistFailed`))}catch(e){A.error(`Note assist failed:`,e),f.error(m(`notes.assistFailed`))}finally{ce(!1)}}},$=(0,T.useMemo)(()=>q===null?null:D(t,q),[q,t]),ve=[{id:`revisions`,icon:(0,k.jsx)(p,{className:`h-3.5 w-3.5`}),label:m(`notes.revisions`)},{id:`attachments`,icon:(0,k.jsx)(g,{className:`h-3.5 w-3.5`}),label:m(`notes.attachments`)},{id:`share`,icon:(0,k.jsx)(ee,{className:`h-3.5 w-3.5`}),label:m(`notes.share`),hidden:!i},{id:`assist`,icon:(0,k.jsx)(u,{className:`h-3.5 w-3.5`}),label:m(`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":m(`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":h===e.id,onClick:()=>v(e.id),"data-testid":`note-tools-tab-${e.id}`,className:c(`flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] transition-colors`,h===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:ne,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":m(`common.close`),"data-testid":`note-tools-close`,children:(0,k.jsx)(y,{className:`h-4 w-4`})})]}),(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 scrollbar-thin`,children:[h===`revisions`&&(0,k.jsx)(`div`,{className:`space-y-2`,children:b===null?(0,k.jsx)(l,{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:m(`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:[s(e.createdAt,ie.language),e.title!==n&&(0,k.jsxs)(`span`,{className:`ms-1 text-gray-400 dark:text-dark-500`,children:[`· `,e.title||m(`notes.untitled`)]})]}),r&&(0,k.jsxs)(S,{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)(_,{className:`h-3 w-3`}),m(`notes.restore`)]})]}),oe===e.id&&(0,k.jsx)(`div`,{className:`mt-2`,children:(0,k.jsx)(j,{rows:D(e.content,t)})})]},e.id))}),h===`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)(S,{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)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,k.jsx)(g,{className:`h-3.5 w-3.5`}),m(`notes.addAttachment`)]})]}),M===null?(0,k.jsx)(l,{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:m(`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)(g,{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:m(`common.download`),children:(0,k.jsx)(re,{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:m(`common.delete`),children:(0,k.jsx)(ae,{className:`h-3.5 w-3.5`})})]},e.id))]}),h===`share`&&i&&(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,k.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),onKeyDown:e=>{e.key===`Enter`&&he()},placeholder:m(`notes.shareUsernamePlaceholder`),className:`min-w-0 flex-1 rounded-lg border border-black/[0.08] bg-transparent px-2.5 py-1.5 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.1] dark:text-dark-900`,"data-testid":`note-share-username`}),(0,k.jsxs)(`select`,{value:B,onChange:e=>V(e.target.value),className:`rounded-lg border border-black/[0.08] bg-transparent px-2 py-1.5 text-[12px] text-gray-700 focus:outline-none dark:border-white/[0.1] dark:bg-dark-100 dark:text-dark-800`,"data-testid":`note-share-permission`,children:[(0,k.jsx)(`option`,{value:`read`,children:m(`notes.permissionRead`)}),(0,k.jsx)(`option`,{value:`write`,children:m(`notes.permissionWrite`)})]}),(0,k.jsx)(S,{size:`sm`,disabled:H||!R.trim(),onClick:()=>void he(),"data-testid":`note-share-submit`,children:H?(0,k.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):m(`notes.shareAction`)})]}),I===null?(0,k.jsx)(l,{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:m(`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)(ee,{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:m(`notes.revokeShare`),children:(0,k.jsx)(y,{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:m(`notes.shareHint`)})]}),h===`assist`&&r&&(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`textarea`,{value:W,onChange:e=>G(e.target.value),placeholder:m(`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)(S,{size:`sm`,className:`w-full gap-1.5`,disabled:K||!W.trim()||!Y,onClick:()=>void _e(),"data-testid":`note-assist-generate`,children:[K?(0,k.jsx)(l,{className:`h-3.5 w-3.5 animate-spin`}):(0,k.jsx)(u,{className:`h-3.5 w-3.5`}),m(`notes.assistGenerate`)]}),!Y&&(0,k.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:m(`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:m(`notes.assistNoChanges`)}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(S,{size:`sm`,className:`flex-1`,disabled:!O($),onClick:()=>{d(q),J(null),G(``),f.success(m(`notes.assistApplied`))},"data-testid":`note-assist-apply`,children:m(`notes.assistApply`)}),(0,k.jsx)(S,{size:`sm`,variant:`outline`,className:`flex-1`,onClick:()=>J(null),"data-testid":`note-assist-discard`,children:m(`notes.assistDiscard`)})]}),(0,k.jsx)(`p`,{className:`text-[11px] leading-relaxed text-gray-400 dark:text-dark-500`,children:m(`notes.assistRevisionHint`)})]})]})]})]})},N=i(`pages:notes`),se=800,P=()=>{let{t:e,i18n:t}=o(),[n,i]=(0,T.useState)([]),[a,ee]=(0,T.useState)(!0),[l,u]=(0,T.useState)(null),[p,g]=(0,T.useState)(``),[_,y]=(0,T.useState)(``),[w,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),L=(0,T.useRef)(null),[R,z]=r(),B=(0,T.useMemo)(()=>n.find(e=>e.id===l)??null,[n,l]);(0,T.useEffect)(()=>{let e=!1;return C.getNotes().then(t=>{e||t.success&&t.data&&i(t.data)}).catch(e=>N.error(`Failed to load notes:`,e)).finally(()=>{e||ee(!1)}),()=>{e=!0}},[]);let V=R.get(`note`),H=V?n.find(e=>e.id===V):void 0;H&&l!==H.id&&(u(H.id),y(H.title),E(H.content),O(!0),j(`idle`));let U=V!==null&&(H!==void 0||!a);(0,T.useEffect)(()=>{U&&z({},{replace:!0})},[U,z]);let W=!B||!B.shared,G=B?!B.shared||B.shared.permission===`write`:!1,K=(e,t=`preview`)=>{X(),u(e.id),y(e.title),E(e.content),O(t===`preview`),j(`idle`),F(null)},ce=async()=>{if(B)try{let e=await C.updateNote(B.id,{pinned:!B.pinned});if(e.success&&e.data){let t=e.data;i(e=>e.map(e=>e.id===t.id?t:e))}}catch(e){N.error(`Failed to toggle pin:`,e)}},q=()=>{if(!B)return;let e=new Blob([w],{type:`text/markdown;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${(_||`note`).replace(/[\\/:*?"<>|]/g,`-`)}.md`,n.click(),URL.revokeObjectURL(t)},J=(e,t,n)=>{I.current!==null&&window.clearTimeout(I.current),j(`saving`),I.current=window.setTimeout(()=>{I.current=null,Y(e,t,n)},se)},Y=async(t,n,r)=>{try{let e=await C.updateNote(t,{title:n,content:r});if(e.success&&e.data){let n=e.data;i(e=>[n,...e.filter(e=>e.id!==t)].sort((e,t)=>t.updatedAt-e.updatedAt)),j(`saved`)}}catch(t){N.error(`Failed to save note:`,t),f.error(e(`notes.saveFailed`)),j(`idle`)}},X=()=>{I.current!==null&&l&&(window.clearTimeout(I.current),I.current=null,Y(l,_,w))};(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;i(e=>[t,...e]),K(t,`edit`)}}catch(t){N.error(`Failed to create note:`,t),f.error(e(`notes.createFailed`))}},ue=async t=>{if(window.confirm(e(`notes.deleteConfirm`)))try{(await C.deleteNote(t)).success&&(i(e=>e.filter(e=>e.id!==t)),l===t&&u(null))}catch(t){N.error(`Failed to delete note:`,t),f.error(e(`notes.deleteFailed`))}},Z=(0,T.useMemo)(()=>{let e=p.trim().toLowerCase();return e?n.filter(t=>t.title.toLowerCase().includes(e)||t.content.toLowerCase().includes(e)):n},[n,p]);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:c(`min-h-0 w-full shrink-0 flex-col border-e border-black/[0.06] dark:border-white/[0.07] md:w-72`,B?`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)(S,{size:`sm`,variant:`ghost`,onClick:()=>void le(),className:`h-7 w-7 p-0`,title:e(`notes.new`),children:(0,k.jsx)(m,{className:`h-4 w-4`})})]}),(0,k.jsxs)(`div`,{className:`relative mx-3 mb-2`,children:[(0,k.jsx)(ne,{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`,{ref:L,type:`search`,value:p,onChange:e=>g(e.target.value),placeholder:e(`common.search`),"aria-label":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:a?null:Z.length===0?(0,k.jsxs)(`div`,{className:`px-3 py-10 text-center`,children:[(0,k.jsx)(v,{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-500 dark:text-dark-500`,role:`status`,children:p.trim()?e(`common.noResults`):e(`notes.empty`)}),p.trim()&&(0,k.jsx)(S,{size:`sm`,variant:`ghost`,className:`mt-2`,onClick:()=>{g(``),L.current?.focus()},children:e(`common.clear`)})]}):(0,k.jsx)(`div`,{className:`space-y-0.5`,children:Z.map(n=>(0,k.jsxs)(`div`,{"data-testid":`note-list-item`,className:c(`group relative flex items-center rounded-lg transition-colors`,l===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)(`button`,{type:`button`,tabIndex:0,onClick:()=>K(n),"aria-label":n.title||e(`notes.untitled`),"aria-current":l===n.id?`true`:void 0,className:`min-w-0 flex-1 rounded-lg px-2.5 py-2 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas`,children:[(0,k.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 truncate text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:[n.pinned&&(0,k.jsx)(h,{className:`h-3 w-3 shrink-0 text-primary-500`,"aria-label":e(`notes.pinned`)}),n.shared&&(0,k.jsx)(x,{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`)})]}),(0,k.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-gray-500 dark:text-dark-500`,children:[s(n.updatedAt,t.language),n.content.trim()&&(0,k.jsxs)(k.Fragment,{children:[` · `,n.content.trim().slice(0,60)]})]})]}),!n.shared&&(0,k.jsx)(`button`,{type:`button`,tabIndex:0,onClick:()=>void ue(n.id),className:`me-1.5 shrink-0 rounded-md p-1.5 text-gray-500 opacity-100 transition-opacity hover:bg-red-50 hover:text-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100 dark:text-dark-500 dark:hover:bg-red-900/20 dark:hover:text-red-400`,title:e(`common.delete`),"aria-label":`${e(`common.delete`)}: ${n.title||e(`notes.untitled`)}`,children:(0,k.jsx)(ae,{className:`h-3 w-3`,"aria-hidden":`true`})})]},n.id))})})]}),(0,k.jsx)(`div`,{"data-testid":`notes-editor`,className:c(`min-w-0 flex-1 flex-col`,B?`flex`:`hidden md:flex`),children:B?(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)(S,{size:`sm`,variant:`ghost`,onClick:()=>{X(),u(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)(ie,{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:_||e(`notes.untitled`)}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{"data-testid":`notes-title-editor`,dir:`auto`,readOnly:!G,value:_,onChange:e=>{y(e.target.value),J(B.id,e.target.value,w)},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`):``})]}),W&&(0,k.jsx)(S,{size:`sm`,variant:`ghost`,onClick:()=>void ce(),className:c(`hidden h-8 w-8 shrink-0 p-0 sm:flex`,B.pinned&&`text-primary-500`),title:B.pinned?e(`notes.unpin`):e(`notes.pin`),"aria-label":B.pinned?e(`notes.unpin`):e(`notes.pin`),"data-testid":`notes-pin-toggle`,children:(0,k.jsx)(h,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(S,{size:`sm`,variant:`ghost`,onClick:q,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)(re,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(S,{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)(d,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(S,{size:`sm`,variant:`ghost`,onClick:()=>{D||X(),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)(te,{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:w,allowHtml:!0,className:`mx-auto w-full max-w-5xl pb-12`})}):(0,k.jsx)(`textarea`,{"data-testid":`notes-content-editor`,dir:`auto`,readOnly:!G,value:w,onChange:e=>{E(e.target.value),J(B.id,_,e.target.value)},onBlur:X,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:B,currentContent:w,currentTitle:_,canWrite:G,isOwner:W,initialTab:P,onClose:()=>F(null),onApplyContent:(e,t)=>{E(e),t!==void 0&&y(t),Y(B.id,t===void 0?_: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)(v,{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)(S,{size:`sm`,onClick:()=>void le(),className:`mt-4 gap-1.5`,children:[(0,k.jsx)(m,{className:`h-3.5 w-3.5`}),e(`notes.new`)]})]})})})]})};export{P as NotesPage,P as default};
@@ -1,2 +1,2 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-wiHys0m2.js";import{C as n,D as r,E as i,O as a,S as o,T as s,_ as c,a as l,b as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E,w as ee,x as D,y as O}from"./syntax-highlight-DNc3FFCa.js";import{v as k,y as A}from"./markdown-core-KjS96SYW.js";function j(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function M(e,t){if(e==null)return{};var n,r,i=j(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function N(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function P(e){if(Array.isArray(e))return N(e)}function F(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function I(e,t){if(e){if(typeof e==`string`)return N(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?N(e,t):void 0}}function L(){throw TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-CR5VJ85Q.js";import{C as n,D as r,E as i,O as a,S as o,T as s,_ as c,a as l,b as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E,w as ee,x as D,y as O}from"./syntax-highlight-D7dQ5s5-.js";import{v as k,y as A}from"./markdown-core-Cyql92Hg.js";function j(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function M(e,t){if(e==null)return{};var n,r,i=j(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function N(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function P(e){if(Array.isArray(e))return N(e)}function F(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function I(e,t){if(e){if(typeof e==`string`)return N(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?N(e,t):void 0}}function L(){throw TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function R(e){return P(e)||F(e)||I(e)||L()}function z(e){"@babel/helpers - typeof";return z=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},z(e)}function B(e,t){if(z(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(z(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function V(e){var t=B(e,`string`);return z(t)==`symbol`?t:t+``}function H(e,t,n){return(t=V(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U(){return U=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},U.apply(null,arguments)}var W={0:`�`,128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`};function G(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=48&&t<=57}function K(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}function q(e){let t=typeof e==`string`?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}function J(e){return q(e)||G(e)}var Y=[``,`Named character references must be terminated by a semicolon`,`Numeric character references must be terminated by a semicolon`,`Named character references cannot be empty`,`Numeric character references cannot be empty`,`Named character references must be known`,`Numeric character references cannot be disallowed`,`Numeric character references cannot be outside the permissible Unicode range`];function X(e,t){let n=t||{},r=typeof n.additional==`string`?n.additional.charCodeAt(0):n.additional,i=[],a=0,o=-1,s=``,c,l;n.position&&(`start`in n.position||`indent`in n.position?(l=n.position.indent,c=n.position.start):c=n.position);let u=(c?c.line:0)||1,d=(c?c.column:0)||1,f=m(),p;for(a--;++a<=e.length;)if(p===10&&(d=(l?l[o]:0)||1),p=e.charCodeAt(a),p===38){let t=e.charCodeAt(a+1);if(t===9||t===10||t===12||t===32||t===38||t===60||Number.isNaN(t)||r&&t===r){s+=String.fromCharCode(p),d++;continue}let o=a+1,c=o,l=o,u;if(t===35){l=++c;let t=e.charCodeAt(l);t===88||t===120?(u=`hexadecimal`,l=++c):u=`decimal`}else u=`named`;let _=``,v=``,y=``,b=u===`named`?J:u===`decimal`?G:K;for(l--;++l<=e.length;){let t=e.charCodeAt(l);if(!b(t))break;y+=String.fromCharCode(t),u===`named`&&A.includes(y)&&(_=y,v=k(y))}let x=e.charCodeAt(l)===59;if(x){l++;let e=u===`named`&&k(y);e&&(_=y,v=e)}let S=1+l-o,C=``;if(x||n.nonTerminated!==!1){if(!y)u!==`named`&&h(4,S);else if(u===`named`){if(x&&!v)h(5,1);else if(_!==y&&(l=c+_.length,S=1+l-c,x=!1),!x){let t=_?1:3;if(n.attribute){let n=e.charCodeAt(l);n===61?(h(t,S),v=``):J(n)?v=``:h(t,S)}else h(t,S)}C=v}else{x||h(2,S);let e=Number.parseInt(y,u===`hexadecimal`?16:10);if(Z(e))h(7,S),C=`�`;else if(e in W)h(6,S),C=W[e];else{let t=``;te(e)&&h(6,S),e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10|55296),e=56320|e&1023),C=t+String.fromCharCode(e)}}}if(C){g(),f=m(),a=l-1,d+=l-o+1,i.push(C);let t=m();t.offset++,n.reference&&n.reference.call(n.referenceContext||void 0,C,{start:f,end:t},e.slice(o-1,l)),f=t}else y=e.slice(o-1,l),s+=y,d+=y.length,a=l-1}else p===10&&(u++,o++,d=0),Number.isNaN(p)?g():(s+=String.fromCharCode(p),d++);return i.join(``);function m(){return{line:u,column:d,offset:a+((c?c.offset:0)||0)}}function h(e,t){let r;n.warning&&(r=m(),r.column+=t,r.offset+=t,n.warning.call(n.warningContext||void 0,Y[e],r,e))}function g(){s&&=(i.push(s),n.text&&n.text.call(n.textContext||void 0,s,{start:f,end:m()}),``)}}function Z(e){return e>=55296&&e<=57343||e>1114111}function te(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534}e();var Q=t(),ne={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`},$={bash:r,c:i,cpp:s,css:ee,csharp:n,diff:o,go:D,java:u,javascript:O,json:E,jsx:c,kotlin:m,markdown:h,markup:v,php:x,python:p,ruby:f,rust:T,"shell-session":_,sql:d,swift:C,tsx:b,typescript:l,yaml:g};Object.entries($).forEach(([e,t])=>{a.registerLanguage(e,t)}),a.alias(`markup`,[`html`,`xml`,`svg`]);var re=new Set(Object.keys($)),ie=({children:e,language:t,isDark:n=!1,className:r=``,backgroundColor:i,borderRadius:o=`0.5rem`,customStyle:s,showLineNumbers:c=!1,codeTheme:l=`default`,preTag:u})=>{let d=ne[t.toLowerCase()]||t.toLowerCase();return re.has(d)?(0,Q.jsx)(`div`,{dir:`ltr`,className:`text-left`,children:(0,Q.jsx)(a,{language:d,style:n?l===`night`?S:y:w,className:r,customStyle:{margin:0,padding:`0.75rem`,borderRadius:o,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,Q.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,Q.jsx)(`code`,{className:``,children:e})})};export{R as a,H as i,X as n,M as o,U as r,ie as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./OptimizedSyntaxHighlighter-B0g8cxZQ.js";export{e as OptimizedSyntaxHighlighter,e as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-wiHys0m2.js";import{t as n}from"./useTranslation-B9kflK9S.js";import{t as r}from"./utils-p8Gt72YP.js";import{Qn as i,n as a}from"./ui-vendor-BhHHyHk3.js";e();var o=`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`,s=e=>{let t={minLength:e.length>=12,withinBytes:new TextEncoder().encode(e).length<=72,hasCase:/[A-Z]/.test(e)&&/[a-z]/.test(e),hasNumber:/[0-9]/.test(e)},n=t.minLength&&t.withinBytes&&t.hasCase&&t.hasNumber,r=Number(t.minLength)+Number(t.hasCase)+Number(t.hasNumber),i=e.length>=16||/[^A-Za-z0-9]/.test(e),a;return a=t.withinBytes?r<=1?+(e.length>0):r===2?2:i?4:3:1,{checks:t,satisfied:n,score:a,level:a<=1?`weak`:a===2?`fair`:a===3?`good`:`strong`}},c=e=>e.length<12?`Password must be at least 12 characters.`:new TextEncoder().encode(e).length>72?`Password must be no more than 72 UTF-8 bytes.`:/[A-Z]/.test(e)?/[a-z]/.test(e)?/[0-9]/.test(e)?null:`Password must contain a number.`:`Password must contain a lowercase letter.`:`Password must contain an uppercase letter.`,l=t(),u={weak:`bg-red-500`,fair:`bg-amber-500`,good:`bg-lime-500`,strong:`bg-green-500`},d={weak:`text-red-600 dark:text-red-400`,fair:`text-amber-600 dark:text-amber-400`,good:`text-lime-600 dark:text-lime-400`,strong:`text-green-600 dark:text-green-400`},f=({met:e,label:t})=>(0,l.jsxs)(`li`,{className:r(`flex items-center gap-1.5`,e?`text-green-600 dark:text-green-400`:`text-gray-500 dark:text-dark-500`),children:[e?(0,l.jsx)(i,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`}):(0,l.jsx)(a,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`}),(0,l.jsx)(`span`,{children:t})]}),p=({password:e})=>{let{t}=n();if(!e)return(0,l.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:o});let i=s(e);return(0,l.jsxs)(`div`,{className:`mt-2 space-y-1.5`,"data-testid":`password-strength-meter`,"aria-live":`polite`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`div`,{className:`flex flex-1 gap-1`,children:[1,2,3,4].map(e=>(0,l.jsx)(`div`,{className:r(`h-1 flex-1 rounded-full transition-colors motion-reduce:transition-none`,e<=i.score?u[i.level]:`bg-gray-200 dark:bg-dark-300`)},e))}),(0,l.jsx)(`span`,{"data-testid":`password-strength-label`,className:r(`text-xs font-medium`,d[i.level]),children:t(`passwordStrength.levels.${i.level}`)})]}),(0,l.jsxs)(`ul`,{className:`space-y-0.5 text-xs`,children:[(0,l.jsx)(f,{met:i.checks.minLength,label:t(`passwordStrength.checks.minLength`)}),(0,l.jsx)(f,{met:i.checks.hasCase,label:t(`passwordStrength.checks.hasCase`)}),(0,l.jsx)(f,{met:i.checks.hasNumber,label:t(`passwordStrength.checks.hasNumber`)}),!i.checks.withinBytes&&(0,l.jsx)(f,{met:!1,label:t(`passwordStrength.checks.tooLong`)})]})]})};export{c as n,p as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{i as e,t}from"./react-vendor-CR5VJ85Q.js";import{t as n}from"./useTranslation-Boi0fB1B.js";import{t as r}from"./utils-B-Bhh1pF.js";import{Qn as i,n as a}from"./ui-vendor-DVTj_sKN.js";e();var o=`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`,s=e=>{let t={minLength:e.length>=12,withinBytes:new TextEncoder().encode(e).length<=72,hasCase:/[A-Z]/.test(e)&&/[a-z]/.test(e),hasNumber:/[0-9]/.test(e)},n=t.minLength&&t.withinBytes&&t.hasCase&&t.hasNumber,r=Number(t.minLength)+Number(t.hasCase)+Number(t.hasNumber),i=e.length>=16||/[^A-Za-z0-9]/.test(e),a;return a=t.withinBytes?r<=1?+(e.length>0):r===2?2:i?4:3:1,{checks:t,satisfied:n,score:a,level:a<=1?`weak`:a===2?`fair`:a===3?`good`:`strong`}},c=e=>e.length<12?`Password must be at least 12 characters.`:new TextEncoder().encode(e).length>72?`Password must be no more than 72 UTF-8 bytes.`:/[A-Z]/.test(e)?/[a-z]/.test(e)?/[0-9]/.test(e)?null:`Password must contain a number.`:`Password must contain a lowercase letter.`:`Password must contain an uppercase letter.`,l=t(),u={weak:`bg-red-500`,fair:`bg-amber-500`,good:`bg-lime-500`,strong:`bg-green-500`},d={weak:`text-red-600 dark:text-red-400`,fair:`text-amber-600 dark:text-amber-400`,good:`text-lime-600 dark:text-lime-400`,strong:`text-green-600 dark:text-green-400`},f=({met:e,label:t})=>(0,l.jsxs)(`li`,{className:r(`flex items-center gap-1.5`,e?`text-green-600 dark:text-green-400`:`text-gray-500 dark:text-dark-500`),children:[e?(0,l.jsx)(i,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`}):(0,l.jsx)(a,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`}),(0,l.jsx)(`span`,{children:t})]}),p=({password:e})=>{let{t}=n();if(!e)return(0,l.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:o});let i=s(e);return(0,l.jsxs)(`div`,{className:`mt-2 space-y-1.5`,"data-testid":`password-strength-meter`,"aria-live":`polite`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`div`,{className:`flex flex-1 gap-1`,children:[1,2,3,4].map(e=>(0,l.jsx)(`div`,{className:r(`h-1 flex-1 rounded-full transition-colors motion-reduce:transition-none`,e<=i.score?u[i.level]:`bg-gray-200 dark:bg-dark-300`)},e))}),(0,l.jsx)(`span`,{"data-testid":`password-strength-label`,className:r(`text-xs font-medium`,d[i.level]),children:t(`passwordStrength.levels.${i.level}`)})]}),(0,l.jsxs)(`ul`,{className:`space-y-0.5 text-xs`,children:[(0,l.jsx)(f,{met:i.checks.minLength,label:t(`passwordStrength.checks.minLength`)}),(0,l.jsx)(f,{met:i.checks.hasCase,label:t(`passwordStrength.checks.hasCase`)}),(0,l.jsx)(f,{met:i.checks.hasNumber,label:t(`passwordStrength.checks.hasNumber`)}),!i.checks.withinBytes&&(0,l.jsx)(f,{met:!1,label:t(`passwordStrength.checks.tooLong`)})]})]})};export{c as n,p as t};