libre-webui 0.24.0 → 0.25.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 (244) hide show
  1. package/README.md +26 -15
  2. package/backend/dist/index.d.ts.map +1 -1
  3. package/backend/dist/index.js +9 -0
  4. package/backend/dist/index.js.map +1 -1
  5. package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
  6. package/backend/dist/persistence/postgresMigrationRegistry.js +2 -0
  7. package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
  8. package/backend/dist/persistence/postgresPersonalAutomationsMigration.d.ts +8 -0
  9. package/backend/dist/persistence/postgresPersonalAutomationsMigration.d.ts.map +1 -0
  10. package/backend/dist/persistence/postgresPersonalAutomationsMigration.js +98 -0
  11. package/backend/dist/persistence/postgresPersonalAutomationsMigration.js.map +1 -0
  12. package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
  13. package/backend/dist/persistence/postgresResourceRepositories.js +274 -0
  14. package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
  15. package/backend/dist/persistence/resourceTypes.d.ts +83 -2
  16. package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
  17. package/backend/dist/persistence/resourceTypes.js.map +1 -1
  18. package/backend/dist/persistence/sqliteMigrations.d.ts +1 -0
  19. package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
  20. package/backend/dist/persistence/sqliteMigrations.js +181 -0
  21. package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
  22. package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
  23. package/backend/dist/persistence/sqliteResourceRepositories.js +233 -0
  24. package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
  25. package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
  26. package/backend/dist/persistence/sqliteToPostgresMigration.js +41 -0
  27. package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
  28. package/backend/dist/platform/jobs/domainJobContracts.d.ts +3 -0
  29. package/backend/dist/platform/jobs/domainJobContracts.d.ts.map +1 -1
  30. package/backend/dist/platform/jobs/domainJobContracts.js +3 -0
  31. package/backend/dist/platform/jobs/domainJobContracts.js.map +1 -1
  32. package/backend/dist/platform/jobs/domainJobHandlers.d.ts.map +1 -1
  33. package/backend/dist/platform/jobs/domainJobHandlers.js +101 -1
  34. package/backend/dist/platform/jobs/domainJobHandlers.js.map +1 -1
  35. package/backend/dist/routes/automations.d.ts +3 -0
  36. package/backend/dist/routes/automations.d.ts.map +1 -0
  37. package/backend/dist/routes/automations.js +232 -0
  38. package/backend/dist/routes/automations.js.map +1 -0
  39. package/backend/dist/routes/calendar.d.ts +3 -0
  40. package/backend/dist/routes/calendar.d.ts.map +1 -0
  41. package/backend/dist/routes/calendar.js +206 -0
  42. package/backend/dist/routes/calendar.js.map +1 -0
  43. package/backend/dist/routes/chat.d.ts.map +1 -1
  44. package/backend/dist/routes/chat.js +99 -7
  45. package/backend/dist/routes/chat.js.map +1 -1
  46. package/backend/dist/routes/ollama.d.ts.map +1 -1
  47. package/backend/dist/routes/ollama.js +4 -1
  48. package/backend/dist/routes/ollama.js.map +1 -1
  49. package/backend/dist/routes/search.d.ts.map +1 -1
  50. package/backend/dist/routes/search.js +5 -3
  51. package/backend/dist/routes/search.js.map +1 -1
  52. package/backend/dist/services/automationSchedulerService.d.ts +28 -0
  53. package/backend/dist/services/automationSchedulerService.d.ts.map +1 -0
  54. package/backend/dist/services/automationSchedulerService.js +191 -0
  55. package/backend/dist/services/automationSchedulerService.js.map +1 -0
  56. package/backend/dist/services/automationService.d.ts +53 -0
  57. package/backend/dist/services/automationService.d.ts.map +1 -0
  58. package/backend/dist/services/automationService.js +224 -0
  59. package/backend/dist/services/automationService.js.map +1 -0
  60. package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
  61. package/backend/dist/services/chatGenerationService.js +7 -1
  62. package/backend/dist/services/chatGenerationService.js.map +1 -1
  63. package/backend/dist/services/chatService.d.ts +9 -1
  64. package/backend/dist/services/chatService.d.ts.map +1 -1
  65. package/backend/dist/services/chatService.js +91 -13
  66. package/backend/dist/services/chatService.js.map +1 -1
  67. package/backend/dist/services/contextCompactionService.d.ts +11 -6
  68. package/backend/dist/services/contextCompactionService.d.ts.map +1 -1
  69. package/backend/dist/services/contextCompactionService.js +127 -27
  70. package/backend/dist/services/contextCompactionService.js.map +1 -1
  71. package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
  72. package/backend/dist/services/durableChatGenerationService.js +15 -3
  73. package/backend/dist/services/durableChatGenerationService.js.map +1 -1
  74. package/backend/dist/services/ollamaService.d.ts.map +1 -1
  75. package/backend/dist/services/ollamaService.js +9 -2
  76. package/backend/dist/services/ollamaService.js.map +1 -1
  77. package/backend/dist/services/pluginService.d.ts +10 -0
  78. package/backend/dist/services/pluginService.d.ts.map +1 -1
  79. package/backend/dist/services/pluginService.js +42 -7
  80. package/backend/dist/services/pluginService.js.map +1 -1
  81. package/backend/dist/services/preferencesService.d.ts.map +1 -1
  82. package/backend/dist/services/preferencesService.js +3 -0
  83. package/backend/dist/services/preferencesService.js.map +1 -1
  84. package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
  85. package/backend/dist/services/titleGenerationService.js +5 -1
  86. package/backend/dist/services/titleGenerationService.js.map +1 -1
  87. package/backend/dist/services/webSearchPlanService.d.ts +18 -0
  88. package/backend/dist/services/webSearchPlanService.d.ts.map +1 -0
  89. package/backend/dist/services/webSearchPlanService.js +160 -0
  90. package/backend/dist/services/webSearchPlanService.js.map +1 -0
  91. package/backend/dist/services/webSearchService.d.ts +9 -3
  92. package/backend/dist/services/webSearchService.d.ts.map +1 -1
  93. package/backend/dist/services/webSearchService.js +8 -2
  94. package/backend/dist/services/webSearchService.js.map +1 -1
  95. package/backend/dist/storage.d.ts +7 -1
  96. package/backend/dist/storage.d.ts.map +1 -1
  97. package/backend/dist/storage.js +65 -1
  98. package/backend/dist/storage.js.map +1 -1
  99. package/backend/dist/types/index.d.ts +79 -0
  100. package/backend/dist/types/index.d.ts.map +1 -1
  101. package/backend/dist/types/index.js.map +1 -1
  102. package/backend/dist/utils/automationSchedule.d.ts +26 -0
  103. package/backend/dist/utils/automationSchedule.d.ts.map +1 -0
  104. package/backend/dist/utils/automationSchedule.js +231 -0
  105. package/backend/dist/utils/automationSchedule.js.map +1 -0
  106. package/backend/dist/utils/chatContext.d.ts +7 -0
  107. package/backend/dist/utils/chatContext.d.ts.map +1 -1
  108. package/backend/dist/utils/chatContext.js +13 -2
  109. package/backend/dist/utils/chatContext.js.map +1 -1
  110. package/backend/dist/utils/openAIResponsesAdapter.d.ts.map +1 -1
  111. package/backend/dist/utils/openAIResponsesAdapter.js +3 -1
  112. package/backend/dist/utils/openAIResponsesAdapter.js.map +1 -1
  113. package/backend/dist/utils/pluginChatAdapter.d.ts +1 -0
  114. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
  115. package/backend/dist/utils/pluginChatAdapter.js +82 -19
  116. package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
  117. package/backend/dist/utils/pluginModelCatalog.d.ts +20 -0
  118. package/backend/dist/utils/pluginModelCatalog.d.ts.map +1 -1
  119. package/backend/dist/utils/pluginModelCatalog.js +101 -9
  120. package/backend/dist/utils/pluginModelCatalog.js.map +1 -1
  121. package/backend/dist/utils/resourceLimits.d.ts +7 -0
  122. package/backend/dist/utils/resourceLimits.d.ts.map +1 -1
  123. package/backend/dist/utils/resourceLimits.js +7 -0
  124. package/backend/dist/utils/resourceLimits.js.map +1 -1
  125. package/backend/dist/utils/thinkingOptions.d.ts +23 -3
  126. package/backend/dist/utils/thinkingOptions.d.ts.map +1 -1
  127. package/backend/dist/utils/thinkingOptions.js +35 -9
  128. package/backend/dist/utils/thinkingOptions.js.map +1 -1
  129. package/backend/dist/websocketServer.d.ts.map +1 -1
  130. package/backend/dist/websocketServer.js +9 -3
  131. package/backend/dist/websocketServer.js.map +1 -1
  132. package/backend/package.json +1 -1
  133. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  134. package/frontend/dist/assets/index-6o-Hc2wS.js +41 -0
  135. package/frontend/dist/assets/index-D-pM957b.css +1 -0
  136. package/frontend/dist/index.html +12 -12
  137. package/frontend/dist/js/ArtifactContainer-CpUi6ekF.js +1 -0
  138. package/frontend/dist/js/{ArtifactDemoPage-TONeQvof.js → ArtifactDemoPage-BeNs3gHp.js} +1 -1
  139. package/frontend/dist/js/{ArtifactSandboxFrame-CV2XXu_t.js → ArtifactSandboxFrame-qsj_Y3LV.js} +2 -2
  140. package/frontend/dist/js/ArtifactSlideOutPanel-CSFRluWA.js +1 -0
  141. package/frontend/dist/js/AutomationsPage-KUeWoZNv.js +1 -0
  142. package/frontend/dist/js/CalendarPage-D9I972w8.js +1 -0
  143. package/frontend/dist/js/ChatPage-CmBx4oAL.js +16 -0
  144. package/frontend/dist/js/{FirstTimeSetup-smhj0X6o.js → FirstTimeSetup-Df0YJni3.js} +1 -1
  145. package/frontend/dist/js/GalleryPage-bLCrdJN_.js +1 -0
  146. package/frontend/dist/js/HomePage-Uc6PEg-U.js +1 -0
  147. package/frontend/dist/js/{LibreClawPage-CRKei1MM.js → LibreClawPage-CG63DHg1.js} +1 -1
  148. package/frontend/dist/js/{ModelManagerModals-D0amaOnl.js → ModelManagerModals-DcLGYN3l.js} +1 -1
  149. package/frontend/dist/js/ModelSelector-yxJC64rM.js +1 -0
  150. package/frontend/dist/js/ModelsPage-1R_TxgmJ.js +2 -0
  151. package/frontend/dist/js/NotesPage-L65j5HoW.js +1 -0
  152. package/frontend/dist/js/PersonasPage-CKeBpHIH.js +13 -0
  153. package/frontend/dist/js/PluginUsagePage-BX1SKMbW.js +1 -0
  154. package/frontend/dist/js/{RichMessageContent-Bxi_u0gC.js → RichMessageContent-DiySVYGB.js} +1 -1
  155. package/frontend/dist/js/SettingsModal-68SG1uZ2.js +1 -0
  156. package/frontend/dist/js/SystemPage-CytpZiQV.js +1 -0
  157. package/frontend/dist/js/UserManagementPage-BzJBvZiS.js +1 -0
  158. package/frontend/dist/js/WorkPage-C8gr0QJe.js +6 -0
  159. package/frontend/dist/js/api-BDtqBtqw.js +14 -0
  160. package/frontend/dist/js/{appStore-CJtomipz.js → appStore-0JnCUlEq.js} +2 -2
  161. package/frontend/dist/js/ar-CSpi37Gr.js +2 -0
  162. package/frontend/dist/js/{authStore-BckFDL70.js → authStore-DbMdvNgJ.js} +3 -3
  163. package/frontend/dist/js/{babel-D24oDI9y.js → babel-BsYoxD-7.js} +1 -1
  164. package/frontend/dist/js/bn-CyH1BeDD.js +2 -0
  165. package/frontend/dist/js/calendarDates-Co3o_05Y.js +1 -0
  166. package/frontend/dist/js/chatStore-CHQ2uINS.js +3 -0
  167. package/frontend/dist/js/{config-CNVNpf_q.js → config-DSOYQ9a3.js} +1 -1
  168. package/frontend/dist/js/cs-Cv2NfRK5.js +2 -0
  169. package/frontend/dist/js/da-D6D6IvPK.js +2 -0
  170. package/frontend/dist/js/de-BNoJJTrT.js +2 -0
  171. package/frontend/dist/js/es-kzo9C7q_.js +2 -0
  172. package/frontend/dist/js/{estree-D1TYSBcf.js → estree-BcnBcOAx.js} +7 -7
  173. package/frontend/dist/js/fr-CjHYvJRp.js +2 -0
  174. package/frontend/dist/js/hi-BU98AdCQ.js +2 -0
  175. package/frontend/dist/js/{html-Dmddj0zf.js → html-DkY55Jys.js} +10 -10
  176. package/frontend/dist/js/id-CpdedejX.js +2 -0
  177. package/frontend/dist/js/is-Cp5dDWBH.js +2 -0
  178. package/frontend/dist/js/it-CuH_cK4U.js +2 -0
  179. package/frontend/dist/js/ja-BWXXXiHn.js +2 -0
  180. package/frontend/dist/js/ko-DQgv2M1t.js +2 -0
  181. package/frontend/dist/js/{markdown-Bl_LsHEk.js → markdown-IZSI9DXw.js} +6 -6
  182. package/frontend/dist/js/{messageCodeStyles-CgKxn4tN.js → messageCodeStyles-BFNR9Wv6.js} +2 -2
  183. package/frontend/dist/js/ms-DCcRoIcX.js +2 -0
  184. package/frontend/dist/js/nl-CbKR1_EU.js +2 -0
  185. package/frontend/dist/js/pl-CRyJZccn.js +2 -0
  186. package/frontend/dist/js/{postcss-Bx9CTcIc.js → postcss-BJ0okz7n.js} +1 -1
  187. package/frontend/dist/js/pt-BXYmHFGH.js +2 -0
  188. package/frontend/dist/js/{router-vendor-CbPDks39.js → router-vendor-DGFGM3EP.js} +1 -1
  189. package/frontend/dist/js/ru-M9SyZG4b.js +2 -0
  190. package/frontend/dist/js/{standalone-BWau8hEE.js → standalone-Csw3jfJ_.js} +5 -5
  191. package/frontend/dist/js/sv-DJ486LTU.js +2 -0
  192. package/frontend/dist/js/th-Ch7gKtZv.js +2 -0
  193. package/frontend/dist/js/tr-ClehWhSC.js +2 -0
  194. package/frontend/dist/js/{typescript-DxGn3Yn-.js → typescript-CnF4UVx7.js} +2 -2
  195. package/frontend/dist/js/{ui-jlx9WA5A.js → ui-CC-K19wO.js} +2 -2
  196. package/frontend/dist/js/ui-vendor-B1UgO3vd.js +177 -0
  197. package/frontend/dist/js/uk-BqAd5zHF.js +2 -0
  198. package/frontend/dist/js/{vi-BgRaIrQC.js → vi-D9gjlDVB.js} +2 -2
  199. package/frontend/dist/js/{workApi-DWRpZ_cq.js → workApi-C3uy9EDT.js} +3 -3
  200. package/frontend/dist/js/{yaml-DioTxVLA.js → yaml-DzT5hBSH.js} +5 -5
  201. package/frontend/dist/js/zh-DKTyHkiR.js +2 -0
  202. package/package.json +2 -2
  203. package/frontend/dist/assets/index-BlTbxYPP.js +0 -33
  204. package/frontend/dist/assets/index-CbiWSGOj.css +0 -1
  205. package/frontend/dist/js/ArtifactContainer-C-n1vPsA.js +0 -1
  206. package/frontend/dist/js/ArtifactSlideOutPanel-2exw7YqL.js +0 -1
  207. package/frontend/dist/js/ChatPage-wnyG_TyC.js +0 -23
  208. package/frontend/dist/js/GalleryPage-BZfeWlBg.js +0 -1
  209. package/frontend/dist/js/HomePage-gf4GgI6z.js +0 -1
  210. package/frontend/dist/js/ModelSelector-C5Tn6y0p.js +0 -1
  211. package/frontend/dist/js/ModelsPage-Rbags4Xq.js +0 -2
  212. package/frontend/dist/js/NotesPage-9NR9HZZ8.js +0 -1
  213. package/frontend/dist/js/PersonasPage-DYP67Qiy.js +0 -13
  214. package/frontend/dist/js/PluginUsagePage-QtCgymRu.js +0 -1
  215. package/frontend/dist/js/SettingsModal-B4RelkLP.js +0 -1
  216. package/frontend/dist/js/SystemPage-xFSTYdBS.js +0 -1
  217. package/frontend/dist/js/UserManagementPage-Cp430WCP.js +0 -1
  218. package/frontend/dist/js/WorkPage-DFES41Qm.js +0 -6
  219. package/frontend/dist/js/api-DUUxxx_B.js +0 -14
  220. package/frontend/dist/js/ar-DMH3qbt6.js +0 -2
  221. package/frontend/dist/js/bn-CGDX8khx.js +0 -2
  222. package/frontend/dist/js/chatStore-DK-_wd-j.js +0 -3
  223. package/frontend/dist/js/cs-CJLgUk3m.js +0 -2
  224. package/frontend/dist/js/da-DnZMnCVM.js +0 -2
  225. package/frontend/dist/js/de-CWpguVQ5.js +0 -2
  226. package/frontend/dist/js/es-DVU1vjm0.js +0 -2
  227. package/frontend/dist/js/fr-pWnSnypD.js +0 -2
  228. package/frontend/dist/js/hi-B6xDfxA5.js +0 -2
  229. package/frontend/dist/js/id-BThSTUAG.js +0 -2
  230. package/frontend/dist/js/is-BOohDFie.js +0 -2
  231. package/frontend/dist/js/it-BdRArcCC.js +0 -2
  232. package/frontend/dist/js/ja-5Cq35sMr.js +0 -2
  233. package/frontend/dist/js/ko-BlzNRtpQ.js +0 -2
  234. package/frontend/dist/js/ms-CtGeurkZ.js +0 -2
  235. package/frontend/dist/js/nl-MKPHGjVF.js +0 -2
  236. package/frontend/dist/js/pl-BwBrqCey.js +0 -2
  237. package/frontend/dist/js/pt-CKzoHWBB.js +0 -2
  238. package/frontend/dist/js/ru-BQC4jh0Y.js +0 -2
  239. package/frontend/dist/js/sv-Cm0qXxzM.js +0 -2
  240. package/frontend/dist/js/th-DUPbiRI2.js +0 -2
  241. package/frontend/dist/js/tr-AsFu_Br5.js +0 -2
  242. package/frontend/dist/js/ui-vendor-54SgntkX.js +0 -177
  243. package/frontend/dist/js/uk-DrMMOZ17.js +0 -2
  244. package/frontend/dist/js/zh-B4rcgcAy.js +0 -2
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{n as r}from"./react-vendor-C5yShNlM.js";import{t as i}from"./useTranslation-Bho4HCyg.js";import{t as a}from"./utils-D9W1Lnkn.js";import{D as o,Ln as s,Qt as c,St as l,Xt as u,g as d,in as f,mt as p,n as m,o as h,ut as g,xt as _,zt as v}from"./ui-vendor-B1UgO3vd.js";import{t as y}from"./logger-DSXjF4ye.js";import{g as b,v as x}from"./api-BDtqBtqw.js";import{i as ee,n as te,r as S,s as C}from"./imageGenModels-Dx_QMLJQ.js";import{t as ne}from"./appStore-0JnCUlEq.js";import{t as w}from"./Button-BPf_pOxH.js";import{n as T,t as E}from"./ui-CC-K19wO.js";import{C as re,D,E as O,S as k,w as A,x as j}from"../assets/index-6o-Hc2wS.js";var M=class extends A{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:O(t,n.data),hasPreviousPage:D(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function N(e,t){return k(e,M,t)}var P=e(t(),1),ie=r(),F=n(),I=y(`components:image-generation-panel`);function ae(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:C(e.models,t.model,void 0,``),size:C(n,t.size,e.config?.default_size,`1024x1024`),quality:r.length>0?C(r,t.quality,e.config?.default_quality,`standard`):``,style:i.length>0?C(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 oe=({isOpen:e,onClose:t,onImageGenerated:n})=>{let{t:r}=i(),c=ne(e=>e.preferences.imageGenSettings),l=c?.enabled===!0,[d,f]=(0,P.useState)([]),[p,h]=(0,P.useState)(``),[g,v]=(0,P.useState)(``),[y,b]=(0,P.useState)(``),[C,T]=(0,P.useState)(`1024x1024`),[E,re]=(0,P.useState)(`standard`),[D,O]=(0,P.useState)(``),[k,A]=(0,P.useState)(!1),[j,M]=(0,P.useState)(null),N=(0,P.useRef)(null),[oe,se]=(0,P.useState)([`512x512`,`768x768`,`1024x1024`]),[L,R]=(0,P.useState)([`standard`,`high`]),[z,ce]=(0,P.useState)([]),[B,le]=(0,P.useState)(null),[V,ue]=(0,P.useState)(``),H=P.useId(),U=(0,P.useCallback)((e,t)=>{let n=ae(e,t);h(n.pluginId),v(n.model),T(n.size),re(n.quality),O(n.style),se(n.sizes),R(n.qualities),ce(n.styles),le(n.maxPromptLength),ue(n.sizeLabel)},[]);(0,P.useEffect)(()=>{let t=!1;return e&&l&&(async()=>{try{let e=await x.getPlugins();if(t)return;let n=e.success&&e.data?e.data.filter(e=>e.models.length>0):[];f(n);let r=te(n,c);r?U(r,c):(h(``),v(``))}catch(e){if(t)return;f([]),h(``),v(``),I.error(`Failed to load image generation plugins:`,e)}})(),()=>{t=!0}},[U,l,e,c]),(0,P.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,P.useEffect)(()=>()=>{N.current?.abort(),N.current=null},[]),(0,P.useEffect)(()=>{e||N.current?.abort()},[e]);let W=()=>{N.current?.abort(),t()},de=e=>{let t=d.find(t=>t.id===e);t&&U(t,{model:g,size:C,quality:E,style:D})},G=async()=>{if(!l||!p||!g||!y.trim()){s.error(r(`imageGeneration.enterPrompt`));return}if(B&&y.length>B){s.error(r(`imageGeneration.promptTooLong`,{max:B.toLocaleString()}));return}let e=new AbortController;N.current?.abort(),N.current=e,A(!0),M(null);try{let i=await x.generate({model:g,pluginId:p,prompt:y.trim(),size:C,quality:E,...D?{style:D}:{}},e.signal);if(e.signal.aborted)return;if(i.success&&i.data?.images&&i.data.images.length>0){let e=ee(i.data.images[0]);e&&(s.success(r(`imageGeneration.success`)),n?(n(e,y.trim(),g),b(``),M(null),t()):M(e))}else s.error(r(`imageGeneration.failed`))}catch(t){if(e.signal.aborted)return;I.error(`Image generation failed:`,t);let n=t instanceof Error?t.message:r(`imageGeneration.failed`);s.error(n)}finally{N.current===e&&(N.current=null,A(!1))}},fe=()=>{N.current?.abort()},pe=()=>{if(!j)return;let e=document.createElement(`a`);e.href=j,e.download=`generated-image-${Date.now()}.${S(j)}`,document.body.appendChild(e),e.click(),document.body.removeChild(e)};if(!e||!l)return null;let me=d.find(e=>e.id===p);return(0,ie.createPortal)((0,F.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":H,children:[(0,F.jsx)(`div`,{className:`absolute inset-0 bg-black/55 backdrop-blur-sm`,onClick:W}),(0,F.jsxs)(`div`,{className:a(`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,F.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,F.jsx)(`div`,{children:(0,F.jsx)(`h2`,{id:H,className:`text-xl font-normal tracking-[-0.025em] text-gray-950 dark:text-dark-950`,children:r(`imageGeneration.title`)})}),(0,F.jsx)(`button`,{onClick:W,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,F.jsx)(m,{className:`h-5 w-5 text-gray-500 dark:text-gray-400`})})]}),(0,F.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 space-y-5 p-5 scrollbar-thin sm:p-6`,children:me?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`settings.plugins.title`)}),(0,F.jsx)(`select`,{value:p,onChange:e=>de(e.target.value),className:a(`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:d.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.model`)}),(0,F.jsx)(`select`,{value:g,onChange:e=>v(e.target.value),className:a(`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:me?.models.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})]}),z.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.style`)}),(0,F.jsx)(`select`,{value:D,onChange:e=>O(e.target.value),className:a(`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:z.map(e=>(0,F.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V||r(`imageGeneration.size`)}),(0,F.jsx)(`select`,{value:C,onChange:e=>T(e.target.value),className:a(`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:oe.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))})]}),L.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.quality`)}),(0,F.jsx)(`select`,{value:E,onChange:e=>re(e.target.value),className:a(`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,F.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:r(`imageGeneration.prompt`)}),(0,F.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value),placeholder:r(`imageGeneration.promptPlaceholder`),rows:5,className:a(`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`,B&&y.length>B&&`border-red-500 dark:border-red-500`)}),B&&(0,F.jsxs)(`div`,{className:a(`mt-1 text-end text-xs`,y.length>B?`text-red-500`:`text-gray-500 dark:text-gray-400`),children:[y.length.toLocaleString(),` /`,` `,B.toLocaleString()]})]}),j&&(0,F.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border border-gray-200/80 dark:border-white/10`,children:[(0,F.jsx)(`img`,{src:j,alt:`Generated`,className:`w-full h-auto`}),(0,F.jsx)(`button`,{onClick:pe,className:a(`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,F.jsx)(u,{className:`h-5 w-5 text-gray-700 dark:text-gray-200`})})]})]}):(0,F.jsxs)(`div`,{className:`text-center py-8`,children:[(0,F.jsx)(_,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,F.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:r(`imageGeneration.noModels`)}),(0,F.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mt-1`,children:r(`imageGeneration.configurePlugin`)})]})}),me&&(0,F.jsx)(`div`,{className:`border-t border-gray-200/70 p-4 dark:border-white/[0.08] sm:px-6 sm:py-5`,children:(0,F.jsx)(w,{onClick:k?fe:G,disabled:!k&&(!l||!y.trim()||!p||!g),className:a(`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:k?(0,F.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,F.jsx)(m,{className:`h-4 w-4`}),r(`common.cancel`)]}):(0,F.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,F.jsx)(o,{className:`h-4 w-4`}),r(`imageGeneration.generate`)]})})})]})]}),document.body)},se={video:[],audio:[]};function L({isOpen:e,initialKind:t,onClose:n,onGenerated:r}){let{t:c}=i(),l=re(),[u,d]=(0,P.useState)(t),[f,g]=(0,P.useState)(se),[_,y]=(0,P.useState)(``),[x,ee]=(0,P.useState)(``),[te,S]=(0,P.useState)(``),[C,ne]=(0,P.useState)(!1),[T,E]=(0,P.useState)(null),[D,O]=(0,P.useState)(``),[k,A]=(0,P.useState)(!1),[j,M]=(0,P.useState)(``),[N,I]=(0,P.useState)(!1),[ae,oe]=(0,P.useState)(0),[L,ue]=(0,P.useState)(``),[H,U]=(0,P.useState)(``),[W,de]=(0,P.useState)(``),[G,fe]=(0,P.useState)(!0),[pe,me]=(0,P.useState)(!0),[K,he]=(0,P.useState)(!1),[ge,_e]=(0,P.useState)([]),q=(0,P.useRef)(null),ve=P.useId(),J=()=>{ne(!1),E(null),O(``),A(!1),M(``),I(!1),oe(e=>e+1)},ye=()=>{q.current?.abort(),J(),n()};(0,P.useEffect)(()=>()=>{q.current?.abort(),q.current=null},[]),(0,P.useEffect)(()=>{e||q.current?.abort()},[e]),(0,P.useEffect)(()=>{if(!e)return;let t=!1;return b.getModels().then(e=>{t||!e.success||!e.data||g(e.data)}).catch(()=>{t||s.error(c(`mediaGeneration.loadFailed`))}).finally(()=>{t||me(!1)}),()=>{t=!0}},[e,c]),(0,P.useEffect)(()=>{if(!e)return;let t=!1;return b.listVideoJobs({limit:100,active:!0}).then(e=>{!t&&e.success&&e.data&&_e(e.data.jobs)}).catch(()=>{t||s.error(c(`mediaGeneration.jobsLoadFailed`,{defaultValue:`Failed to load saved video jobs`}))}),()=>{t=!0}},[e,c]);let Y=u===`video`?f.video:f.audio,be=ge.filter(e=>e.status!==`completed`),xe=Y.some(e=>z(e)===_)?_:Y[0]?z(Y[0]):``,X=(0,P.useMemo)(()=>Y.find(e=>z(e)===xe),[xe,Y]),Z=u===`video`?X?.config:void 0,Q=u===`audio`?X:void 0,Se=!!(Q?.mode===`speech`&&Q.config?.supports_voice_cloning),Ce=!!Q?.config?.clone_requires_transcript,$=Se&&C,we=!!(Q?.mode!==`speech`||Q.config?.allows_custom_voice!==!1||Q.config?.voices?.length),Te=Q?.mode===`speech`?Q.config?.max_characters:void 0,Ee=async(e,t,n,r=0)=>{if(e.status!==`pending`&&e.status!==`in_progress`)return e;n&&await ce(3e4,t.signal);try{let n=await b.resumeVideoJob(e.id,t.signal);if(!n.success||!n.data)throw Error(n.message||c(`mediaGeneration.failed`));let r=n.data;return _e(e=>[r,...e.filter(e=>e.id!==r.id)]),Ee(r,t,!0)}catch(n){if(t.signal.aborted||r>=4)throw n;return Ee(e,t,!0,r+1)}},De=async e=>{let t=new AbortController;q.current?.abort(),q.current=t,he(!0);try{let n=await Ee(e,t,!1);if(t.signal.aborted)return;if(n.status===`failed`)throw Error(n.error||c(`mediaGeneration.failed`));s.success(c(`mediaGeneration.success`)),r()}catch(e){if(t.signal.aborted)return;s.error(e instanceof Error?e.message:c(`mediaGeneration.failed`))}finally{q.current===t&&(q.current=null,he(!1))}},Oe=async e=>{try{let t=await b.cancelVideoJob(e.id);if(!t.success)throw Error(t.message||c(`mediaGeneration.failed`));_e(t=>t.filter(t=>t.id!==e.id)),s.success(c(`mediaGeneration.jobCancelled`,{defaultValue:`Video job cancelled at the provider`}))}catch(e){s.error(e instanceof Error?e.message:c(`mediaGeneration.failed`))}};return e?(0,ie.createPortal)((0,F.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center p-3 sm:p-6`,children:[(0,F.jsx)(`button`,{className:`absolute inset-0 bg-black/55 backdrop-blur-sm`,onClick:ye,"aria-label":c(`common.close`)}),(0,F.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,F.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,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{id:ve,className:`text-xl text-gray-950 dark:text-dark-950`,children:c(`mediaGeneration.title`)}),(0,F.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-dark-500`,children:c(`mediaGeneration.description`)})]}),(0,F.jsx)(`button`,{onClick:ye,className:`rounded-xl p-2`,children:(0,F.jsx)(m,{className:`h-5 w-5`})})]}),(0,F.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 space-y-4 p-4 sm:p-5`,children:[(0,F.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,F.jsxs)(`button`,{type:`button`,disabled:K,onClick:()=>{d(e),y(``),S(``),J()},className:a(`flex items-center justify-center gap-2 rounded-xl px-3 py-2 text-sm transition-colors`,e===u?`bg-white text-gray-950 shadow-sm dark:bg-white/10 dark:text-white`:`text-gray-500 dark:text-dark-500`,K&&`cursor-not-allowed opacity-50`),children:[e===`video`?(0,F.jsx)(v,{className:`h-4 w-4`}):(0,F.jsx)(h,{className:`h-4 w-4`}),c(`mediaGeneration.${e}`)]},e))}),u===`video`&&be.length>0&&(0,F.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,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:c(`mediaGeneration.savedJobs`,{defaultValue:`Saved video jobs`})}),(0,F.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:c(`mediaGeneration.savedJobsDescription`,{defaultValue:`Closing this panel only stops waiting. Reopen it to resume any provider job listed here.`})})]}),be.map(e=>(0,F.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,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:e.prompt||e.model}),(0,F.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:[e.model,` ·`,` `,c(`mediaGeneration.jobStatus.${e.status}`,{defaultValue:e.status.replace(`_`,` `)})]}),e.error&&(0,F.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,F.jsx)(w,{type:`button`,variant:`outline`,size:`sm`,disabled:K,onClick:()=>void De(e),children:c(`mediaGeneration.resumeJob`,{defaultValue:`Resume`})}),e.cancellable&&(0,F.jsx)(w,{type:`button`,variant:`outline`,size:`sm`,disabled:K,onClick:()=>void Oe(e),children:c(`mediaGeneration.cancelJob`,{defaultValue:`Cancel job`})})]},e.id))]}),pe?(0,F.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,F.jsx)(p,{className:`h-7 w-7 animate-spin`})}):Y.length===0?(0,F.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:c(`mediaGeneration.noModels`,{kind:c(`mediaGeneration.${u}`)})}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(R,{label:c(`mediaGeneration.model`),children:(0,F.jsx)(`select`,{value:xe,onChange:e=>{y(e.target.value),S(``),J(),ue(``),U(``),de(``),fe(!0)},className:V,children:Y.map(e=>(0,F.jsxs)(`option`,{value:z(e),children:[e.model,` (`,e.plugin,`mode`in e?` · ${c(`mediaGeneration.${e.mode}`)}`:``,`)`]},z(e)))})}),u===`audio`&&!$&&we?(0,F.jsx)(R,{label:c(`mediaGeneration.voice`),children:(0,F.jsx)(`input`,{value:te,onChange:e=>S(e.target.value),className:V,placeholder:Q?.config?.default_voice||c(`mediaGeneration.providerDefault`)})}):u===`video`?(0,F.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,F.jsx)(R,{label:c(`mediaGeneration.resolution`),children:(0,F.jsxs)(`select`,{value:L,onChange:e=>ue(e.target.value),className:V,children:[(0,F.jsx)(`option`,{value:``,children:c(`mediaGeneration.providerDefault`)}),Z?.resolutions?.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})}),(0,F.jsx)(R,{label:c(`mediaGeneration.aspectRatio`),children:(0,F.jsxs)(`select`,{value:H,onChange:e=>U(e.target.value),className:V,children:[(0,F.jsx)(`option`,{value:``,children:c(`mediaGeneration.providerDefault`)}),Z?.aspect_ratios?.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})}),(0,F.jsx)(R,{label:c(`mediaGeneration.duration`),children:(0,F.jsxs)(`select`,{value:W,onChange:e=>de(e.target.value),className:V,children:[(0,F.jsx)(`option`,{value:``,children:c(`mediaGeneration.providerDefault`)}),Z?.durations?.map(e=>(0,F.jsxs)(`option`,{value:e,children:[e,`s`]},e))]})})]}):null,Se&&(0,F.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-primary-500/20 bg-primary-500/[0.06] p-4`,children:[(0,F.jsxs)(`label`,{className:`flex items-start gap-3 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:$,onChange:e=>{e.target.checked?ne(!0):J()},className:`mt-0.5`}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`span`,{className:`block font-medium text-gray-900 dark:text-gray-100`,children:c(`mediaGeneration.cloneVoice`)}),(0,F.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-gray-500 dark:text-dark-500`,children:c(`mediaGeneration.cloneVoiceDescription`)})]})]}),$&&(0,F.jsxs)(`div`,{className:`space-y-3 border-t border-primary-500/15 pt-3`,children:[(0,F.jsx)(R,{label:c(`mediaGeneration.referenceAudio`),children:(0,F.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){s.error(c(`mediaGeneration.referenceAudioTooLarge`,{max:le(n)})),e.target.value=``,E(null);return}E(t)},className:a(V,`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`)},ae)}),(0,F.jsx)(R,{label:c(`mediaGeneration.referenceTranscript`),children:(0,F.jsx)(`textarea`,{value:D,onChange:e=>O(e.target.value),rows:3,required:Ce,className:a(V,`resize-none`),placeholder:c(`mediaGeneration.referenceTranscriptPlaceholder`)})}),(0,F.jsxs)(`label`,{className:`flex items-start gap-3 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:k,onChange:e=>{A(e.target.checked),e.target.checked||(M(``),I(!1))},className:`mt-0.5`}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`span`,{className:`block font-medium text-gray-900 dark:text-gray-100`,children:c(`mediaGeneration.saveVoiceProfile`,{defaultValue:`Save as a reusable voice`})}),(0,F.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-gray-500 dark:text-dark-500`,children:c(`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.`})})]})]}),k&&(0,F.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,F.jsx)(R,{label:c(`mediaGeneration.voiceProfileName`,{defaultValue:`Saved voice name`}),children:(0,F.jsx)(`input`,{type:`text`,value:j,onChange:e=>M(e.target.value),maxLength:80,autoComplete:`off`,className:V,placeholder:c(`mediaGeneration.voiceProfileNamePlaceholder`,{defaultValue:`For example, My voice`})})}),(0,F.jsxs)(`label`,{className:`flex items-start gap-3 text-xs text-amber-700 dark:text-amber-300`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:N,onChange:e=>I(e.target.checked),className:`mt-0.5`}),(0,F.jsx)(`span`,{children:c(`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.`})})]})]}),!k&&(0,F.jsx)(`p`,{className:`text-xs font-normal text-amber-700 dark:text-amber-300`,children:c(`mediaGeneration.cloneConsent`)})]})]}),u===`video`&&Z?.supports_audio&&(0,F.jsxs)(`label`,{className:`flex items-center gap-3 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:G,onChange:e=>fe(e.target.checked)}),c(`mediaGeneration.generateAudio`)]}),(0,F.jsxs)(R,{label:u===`video`||Q?.mode===`sound`?c(`mediaGeneration.prompt`):c(`mediaGeneration.text`),children:[(0,F.jsx)(`textarea`,{value:x,onChange:e=>ee(e.target.value),rows:6,maxLength:Te,className:a(V,`resize-none`),placeholder:c(u===`audio`&&Q?.mode===`sound`?`mediaGeneration.soundPlaceholder`:`mediaGeneration.${u}Placeholder`)}),Te&&(0,F.jsxs)(`span`,{className:`block text-end text-xs font-normal text-gray-500 dark:text-dark-500`,children:[x.length,` / `,Te]})]})]})]}),Y.length>0&&(0,F.jsx)(`div`,{className:`border-t border-gray-200/70 p-4 dark:border-white/[0.08] sm:px-5`,children:(0,F.jsxs)(w,{onClick:K?()=>{q.current?.abort()}:async()=>{if(!X||!x.trim())return;let e=new AbortController;q.current?.abort(),q.current=e,he(!0);try{if(u===`audio`){let t=B(Q?.config?.default_format),n=$?await b.cloneVoice({model:X.model,pluginId:X.plugin,input:x.trim(),referenceAudio:T,referenceText:D.trim()||void 0,responseFormat:t,saveVoiceName:k?j.trim():void 0,consentToStore:k&&N},e.signal):Q?.mode===`sound`?await b.generateSound({model:X.model,pluginId:X.plugin,prompt:x.trim(),voice:te.trim()||Q?.config?.default_voice||void 0,format:`wav`},e.signal):await b.generateAudio({model:X.model,pluginId:X.plugin,input:x.trim(),voice:te.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($&&k&&(await l.invalidateQueries({queryKey:[`tts-voice-profiles`]}),e.signal.aborted))return}else{let t=await b.generateVideo({model:X.model,pluginId:X.plugin,prompt:x.trim(),...W?{duration:Number(W)}:{},...L?{resolution:L}:{},...H?{aspect_ratio:H}:{},...Z?.supports_audio?{generate_audio:G}:{}},e.signal);if(e.signal.aborted)return;if(!t.success||!t.data)throw Error(t.message||c(`mediaGeneration.failed`));let n=t.data;_e(e=>[n,...e.filter(e=>e.id!==n.id)]);let r=await Ee(n,e,!0);if(r.status===`failed`)throw Error(r.error||c(`mediaGeneration.failed`))}if(e.signal.aborted)return;s.success($&&k?c(`mediaGeneration.successWithSavedVoice`,{name:j.trim(),defaultValue:`Media generated and “{{name}}” is now available in Speech settings`}):c(`mediaGeneration.success`)),ee(``),J(),r(),n()}catch(t){if(e.signal.aborted)return;s.error(t instanceof Error?t.message:c(`mediaGeneration.failed`))}finally{q.current===e&&(q.current=null,he(!1))}},disabled:K?!1:!X||!x.trim()||!!(Te&&x.length>Te)||$&&(!T||Ce&&!D.trim()||k&&(!j.trim()||!N)),className:`w-full gap-2`,children:[K?(0,F.jsx)(m,{className:`h-4 w-4`}):(0,F.jsx)(o,{className:`h-4 w-4`}),K?u===`video`?c(`mediaGeneration.stopWaiting`,{defaultValue:`Stop waiting`}):c(`common.cancel`):c(`mediaGeneration.generate`)]})})]})]}),document.body):null}function R({label:e,children:t}){return(0,F.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-gray-700 dark:text-gray-300`,children:[(0,F.jsx)(`span`,{children:e}),t]})}function z(e){return`${e.mode||`default`}::${e.plugin}::${e.model}`}function ce(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 B(e){return[`mp3`,`opus`,`aac`,`flac`,`wav`,`pcm`].includes(e||``)?e:`mp3`}function le(e){return e>=1048576?`${Math.ceil(e/1048576)} MB`:`${Math.ceil(e/1024)} KB`}var V=`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`,ue=({image:e,onClose:t,onDelete:n,onDownload:r})=>{let{t:o}=i();return(0,P.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,ie.createPortal)((0,F.jsxs)(`div`,{className:`fixed inset-0 z-[99999] flex items-center justify-center`,onClick:t,children:[(0,F.jsx)(`div`,{className:`absolute inset-0 bg-black/90 backdrop-blur-sm`}),(0,F.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,F.jsx)(`button`,{onClick:t,className:a(`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,F.jsx)(m,{className:`h-6 w-6 text-white`})}),(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-0`,children:(0,F.jsx)(`img`,{src:e.imageData,alt:e.prompt,className:`max-w-full max-h-[70vh] lg:max-h-[90vh] object-contain rounded-lg`})}),(0,F.jsxs)(`div`,{className:a(`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,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400 mb-1`,children:o(`gallery.prompt`)}),(0,F.jsx)(`p`,{className:`text-gray-900 dark:text-gray-100 text-sm leading-relaxed`,children:e.prompt})]}),(0,F.jsxs)(`div`,{className:`space-y-3 mb-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,F.jsx)(c,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,F.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[o(`gallery.model`),`:`]}),(0,F.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:e.model})]}),e.size&&(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,F.jsx)(g,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,F.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[o(`gallery.size`),`:`]}),(0,F.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:e.size})]}),e.quality&&(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,F.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,F.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[o(`gallery.quality`),`:`]}),(0,F.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100 capitalize`,children:e.quality})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,F.jsx)(f,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`}),(0,F.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[o(`gallery.created`),`:`]}),(0,F.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,F.jsxs)(`div`,{className:`flex gap-2 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,F.jsxs)(`button`,{onClick:()=>{if(r)r(e);else{let t=document.createElement(`a`);t.href=e.imageData,t.download=`generated-${e.id}.${S(e.imageData)}`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}},className:a(`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,F.jsx)(u,{className:`h-4 w-4`}),o(`gallery.download`)]}),n&&(0,F.jsx)(`button`,{onClick:()=>n(e.id),className:a(`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,F.jsx)(d,{className:`h-4 w-4`})})]})]})]})]}),document.body)};function H({kind:e,refreshKey:t,onCountChange:n}){let{t:r}=i(),a=re(),[o,c]=(0,P.useState)(null),[f,m]=(0,P.useState)(null),h=N({queryKey:[`media-gallery`,e||`all`,t||0],queryFn:async({pageParam:t})=>{let n=await b.getGallery({limit:20,offset:t,...e?{kind:e}:{}});if(!n.success||!n.data)throw Error(n.message||r(`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}}),g=(0,P.useMemo)(()=>h.data?.pages.flatMap(e=>e.media)||[],[h.data]),_=h.data?.pages[0]?.total||0;(0,P.useEffect)(()=>n?.(_),[n,_]);let v=async e=>{if(!f){m(e.id);try{let t=await b.deleteGalleryItem(e.id);if(!t.success)throw Error(t.message);c(null),await a.invalidateQueries({queryKey:[`media-gallery`]}),s.success(r(`imageGallery.deleteSuccess`))}catch{s.error(r(`imageGallery.deleteFailed`))}finally{m(null)}}},y=async e=>{let t=await b.getGalleryContent(e.id),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`generated-${e.id}.${de(e.mimeType)}`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)};return h.isLoading?(0,F.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,F.jsx)(p,{className:`h-8 w-8 animate-spin text-gray-400`})}):g.length===0?(0,F.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,F.jsx)(l,{className:`mb-4 h-10 w-10 text-gray-300 dark:text-gray-600`}),(0,F.jsx)(`h3`,{className:`text-lg font-medium`,children:r(`mediaGallery.empty`)}),(0,F.jsx)(`p`,{className:`mt-2 max-w-sm text-gray-500 dark:text-gray-400`,children:r(`mediaGallery.emptyHint`)})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,children:g.map(e=>(0,F.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,F.jsx)(U,{item:e,onOpenImage:t=>c(W(e,t))}),(0,F.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,F.jsx)(`p`,{className:`line-clamp-2 text-sm text-gray-800 dark:text-gray-200`,children:e.prompt}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsx)(`span`,{className:`min-w-0 truncate text-xs text-gray-500`,children:e.model}),(0,F.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,F.jsx)(`button`,{onClick:()=>void y(e),className:`rounded-lg p-1.5 hover:bg-gray-100 dark:hover:bg-white/10`,title:r(`imageGallery.download`),children:(0,F.jsx)(u,{className:`h-4 w-4`})}),(0,F.jsx)(`button`,{onClick:()=>void v(e),disabled:f===e.id,className:`rounded-lg p-1.5 hover:bg-red-500/15 hover:text-red-500`,title:r(`imageGallery.delete`),children:f===e.id?(0,F.jsx)(p,{className:`h-4 w-4 animate-spin`}):(0,F.jsx)(d,{className:`h-4 w-4`})})]})]})]})]},e.id))}),h.hasNextPage&&(0,F.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,F.jsx)(w,{variant:`outline`,disabled:h.isFetchingNextPage,onClick:()=>void h.fetchNextPage(),children:h.isFetchingNextPage?r(`common.loading`):r(`imageGallery.loadMore`,{current:g.length,total:_})})}),o&&(0,F.jsx)(ue,{image:o,onClose:()=>c(null),onDelete:e=>{let t=g.find(t=>t.id===e);t&&v(t)},onDownload:e=>{let t=g.find(t=>t.id===e.id);t&&y(t)}})]})}function U({item:e,onOpenImage:t}){let{data:n,isLoading:r}=j({queryKey:[`media-gallery-content`,e.id],queryFn:()=>b.getGalleryContent(e.id),staleTime:3e5}),i=(0,P.useMemo)(()=>n?URL.createObjectURL(n):``,[n]);return(0,P.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),r||!i?(0,F.jsx)(`div`,{className:`flex aspect-video items-center justify-center bg-gray-100 dark:bg-white/[0.03]`,children:(0,F.jsx)(p,{className:`h-6 w-6 animate-spin text-gray-400`})}):e.kind===`image`?(0,F.jsx)(`button`,{className:`block aspect-square w-full overflow-hidden`,onClick:()=>t(i),children:(0,F.jsx)(`img`,{src:i,alt:e.prompt,className:`h-full w-full object-cover`,loading:`lazy`})}):e.kind===`video`?(0,F.jsx)(`div`,{className:`aspect-video bg-black`,children:(0,F.jsx)(`video`,{src:i,controls:!0,preload:`metadata`,className:`h-full w-full object-contain`})}):(0,F.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,F.jsx)(h,{className:`h-9 w-9 text-primary-500`}),(0,F.jsx)(`audio`,{src:i,controls:!0,preload:`metadata`,className:`w-full`})]})}function W(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 de(e){let t=e.split(`/`)[1]?.split(`;`)[0];return t===`mpeg`?e.startsWith(`audio/`)?`mp3`:`mpeg`:t===`svg+xml`?`svg`:t||`bin`}var G=()=>{let{t:e}=i(),[t,n]=(0,P.useState)(null),[r,o]=(0,P.useState)(!1),[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(`all`),[d,f]=(0,P.useState)(0),p=ne(e=>e.preferences.imageGenSettings?.enabled===!0),m=(0,P.useCallback)(()=>{f(e=>e+1)},[]);return(0,F.jsxs)(T,{width:`wide`,children:[(0,F.jsx)(E,{title:e(`sidebar.navigation.imagine`),description:e(`gallery.subtitle`),meta:t!==null&&t>0?(0,F.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,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsxs)(w,{onClick:()=>{p&&o(!0)},disabled:!p,className:`gap-2 px-4`,children:[(0,F.jsx)(_,{className:`h-4 w-4`,"aria-hidden":`true`}),e(`gallery.generate`)]}),(0,F.jsxs)(w,{variant:`outline`,onClick:()=>c(`video`),className:`gap-2 px-4`,children:[(0,F.jsx)(v,{className:`h-4 w-4`,"aria-hidden":`true`}),e(`mediaGeneration.video`)]}),(0,F.jsxs)(w,{variant:`outline`,onClick:()=>c(`audio`),className:`gap-2 px-4`,children:[(0,F.jsx)(h,{className:`h-4 w-4`,"aria-hidden":`true`}),e(`mediaGeneration.audio`)]})]})}),(0,F.jsx)(`div`,{className:`mb-5 flex flex-wrap gap-2`,children:[`all`,`image`,`video`,`audio`].map(t=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>u(t),className:a(`rounded-full border px-3 py-1.5 text-sm transition-colors`,l===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,F.jsx)(H,{kind:l===`all`?void 0:l,refreshKey:d,onCountChange:n}),(0,F.jsx)(oe,{isOpen:r&&p,onClose:()=>o(!1),onImageGenerated:m}),(0,F.jsx)(L,{isOpen:s!==null,initialKind:s||`video`,onClose:()=>c(null),onGenerated:m},s||`closed`)]})};export{G as GalleryPage,G as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{d as r}from"./router-vendor-DGFGM3EP.js";import{t as i}from"./useTranslation-Bho4HCyg.js";import{a,r as o,t as s}from"./utils-D9W1Lnkn.js";import{t as c}from"./chatStore-CHQ2uINS.js";import{D as l,Dn as u,Nt as d,Sn as f,Zt as p,bn as m,c as h,ct as g,t as _,tt as v}from"./ui-vendor-B1UgO3vd.js";import{n as y,u as b}from"./authStore-DbMdvNgJ.js";import{_ as x,d as S,f as C,p as w,t as T}from"../assets/index-6o-Hc2wS.js";import{t as E}from"./work-DVgm81bJ.js";var D=e(t(),1),O=n(),k=e=>e<5?[`home.greeting.night`,`Up late`]:e<12?[`home.greeting.morning`,`Morning`]:e<18?[`home.greeting.afternoon`,`Afternoon`]:[`home.greeting.evening`,`Evening`],A=`mb-2 text-xs font-medium text-gray-500 dark:text-dark-500`,j=`group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-start text-sm text-gray-700 transition-colors hover:bg-white hover:text-gray-950 dark:text-dark-700 dark:hover:bg-dark-200 dark:hover:text-dark-950 outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,M=()=>{let{t:e,i18n:t}=i(),n=r(),{user:M,systemInfo:N,canUseWork:P,canUseAgents:F}=y(),I=c(e=>e.sessions),L=c(e=>e.models),R=b(e=>e.tasks),z=b(e=>e.capabilities),B=b(e=>e.loadTasks),V=b(e=>e.loadCapabilities),H=P(),U=F();(0,D.useEffect)(()=>{H&&(B(!0).catch(()=>{}),V().catch(()=>{}))},[H,B,V]);let[W,G]=k(new Date().getHours()),K=e(W,G),q=M?.username,J=[...I].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,4),Y=[...R].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()).slice(0,3),X=z?.activeRuntimes?.user??0,Z=a()?`⌘`:`Ctrl`,Q=J.length>0||Y.length>0,$=T(N?.version);return(0,O.jsx)(`div`,{"data-testid":`home-page`,className:`h-full overflow-y-auto scrollbar-thin`,children:(0,O.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-xl flex-col justify-center px-6 py-12`,children:[(0,O.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-gray-950 dark:text-dark-950`,children:q?`${K}, ${q}.`:`${K}.`}),(0,O.jsxs)(`p`,{"data-testid":`app-version`,className:`mt-1 font-mono text-xs text-gray-400 dark:text-dark-500`,children:[window.location.host||`Libre WebUI`,$?` · v${$}`:``]}),(0,O.jsxs)(`div`,{className:`mt-8`,children:[(0,O.jsx)(`p`,{className:A,children:e(`home.start`,`Start`)}),(0,O.jsxs)(`div`,{className:`-mx-2.5 flex flex-col`,children:[(0,O.jsxs)(`button`,{type:`button`,"data-testid":`home-new-chat`,className:j,onClick:()=>C(n),children:[(0,O.jsx)(g,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-600 dark:text-dark-500 dark:group-hover:text-dark-700`}),(0,O.jsx)(`span`,{className:`flex-1`,children:e(`tabs.newChat`,`New Chat`)}),(0,O.jsxs)(`span`,{className:`font-mono text-[10px] tracking-wide text-gray-400 opacity-0 transition-opacity group-hover:opacity-100 dark:text-dark-500`,children:[Z,`⇧O`]})]}),(0,O.jsxs)(`button`,{type:`button`,"data-testid":`home-incognito-chat`,className:j,onClick:()=>S(n),children:[(0,O.jsx)(d,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-600 dark:text-dark-500 dark:group-hover:text-dark-700`}),(0,O.jsx)(`span`,{className:`flex-1`,children:e(`chat.session.incognito`,`Incognito Chat`)})]}),H&&(0,O.jsxs)(`button`,{type:`button`,"data-testid":`home-new-work`,className:j,onClick:()=>w(n),children:[(0,O.jsx)(f,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-600 dark:text-dark-500 dark:group-hover:text-dark-700`}),(0,O.jsx)(`span`,{className:`flex-1`,children:e(`tabs.newWork`,`New Work`)}),(0,O.jsxs)(`span`,{className:`font-mono text-[10px] tracking-wide text-gray-400 opacity-0 transition-opacity group-hover:opacity-100 dark:text-dark-500`,children:[Z,`⇧U`]})]})]})]}),Q&&(0,O.jsxs)(`div`,{className:`mt-8`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between`,children:[(0,O.jsx)(`p`,{className:s(A,`mb-0`),children:e(`home.continue`,`Continue`)}),H&&X>0&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse-subtle rounded-full bg-[rgb(48,121,255)]`}),X,` `,e(`home.active`,`active`)]})]}),(0,O.jsxs)(`div`,{className:`-mx-2.5 flex flex-col`,children:[Y.map(r=>{let i=x[r.status];return(0,O.jsxs)(`button`,{type:`button`,"data-testid":`home-continue-work`,className:j,onClick:()=>n(`/work/${r.id}`),children:[(0,O.jsx)(`span`,{"aria-hidden":`true`,className:s(`h-2 w-2 shrink-0 rounded-full ring-1 ring-black/[0.06] dark:ring-white/[0.1]`,i.animated&&`animate-pulse-subtle`),style:{backgroundColor:i.color}}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.title||e(`work.tasks.untitled`,`Untitled task`)}),r.hostPath&&(0,O.jsx)(`span`,{className:`hidden max-w-[14rem] shrink-0 truncate font-mono text-[10px] text-gray-400 sm:inline dark:text-dark-500`,title:r.hostPath,children:r.hostPath}),(0,O.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:E(r)?e(i.labelKey,i.label):o(new Date(r.updatedAt).getTime(),t.language)})]},r.id)}),J.map(r=>(0,O.jsxs)(`button`,{type:`button`,"data-testid":`home-continue-chat`,className:j,onClick:()=>n(`/c/${r.id}`),children:[(0,O.jsx)(g,{className:`h-4 w-4 shrink-0 text-gray-400 dark:text-dark-500`}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.title||e(`tabs.chat`,`Chat`)}),(0,O.jsx)(`span`,{className:`hidden shrink-0 font-mono text-[10px] text-gray-400 sm:inline dark:text-dark-500`,children:r.model.startsWith(`persona:`)?L.find(e=>e.isPersona&&e.name===r.model)?.personaName||e(`chat.persona.label`,`Persona`):r.model}),(0,O.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-gray-400 dark:text-dark-500`,children:o(r.updatedAt,t.language)})]},r.id))]})]}),(0,O.jsxs)(`div`,{className:`mt-8`,children:[(0,O.jsx)(`p`,{className:A,children:e(`home.explore`,`Explore`)}),(0,O.jsx)(`div`,{className:`-mx-2.5 flex flex-col`,children:[[`/notes`,v,e(`sidebar.navigation.notes`,`Notes`)],[`/calendar`,m,e(`sidebar.navigation.calendar`,`Calendar`)],[`/automations`,_,e(`sidebar.navigation.automations`,`Automations`)],[`/models`,p,e(`sidebar.navigation.models`,`Models`)],[`/personas`,h,e(`sidebar.navigation.personas`,`Personas`)],[`/gallery`,l,e(`sidebar.navigation.imagine`,`Imagine`)],...U?[[`/agents`,u,e(`sidebar.navigation.agents`,`Agents`)]]:[]].map(([e,t,r])=>(0,O.jsxs)(`button`,{type:`button`,className:j,onClick:()=>n(e),children:[(0,O.jsx)(t,{className:`h-4 w-4 shrink-0 text-gray-400 transition-colors group-hover:text-gray-600 dark:text-dark-500 dark:group-hover:text-dark-700`}),(0,O.jsx)(`span`,{className:`flex-1`,children:r})]},e))})]})]})})};export{M as HomePage,M as default};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{n as r}from"./i18next-DgmgtwsV.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./useTranslation-Bho4HCyg.js";import{c as u,f as d,t as f,u as p}from"./utils-D9W1Lnkn.js";import{A as m,Gt as h,H as g,On as _,S as v,bn as y,dn as b,ft as x,h as S,jn as C,kt as w,mn as ee,n as T,q as te,tn as ne,y as E,z as re}from"./ui-vendor-54SgntkX.js";import{t as D}from"./logger-DSXjF4ye.js";import{_ as O}from"./api-DUUxxx_B.js";import{t as k}from"./Button-BPf_pOxH.js";import{n as ie,t as A}from"./ui-jlx9WA5A.js";var j={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},ae=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function M(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(j[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(ae),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var N=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,P=/<\/?([^\s]+?)[/\s>]/,oe=/^\s*$/,se=/^(script|style)$/i,F=`\0`,ce=Object.create(null);function I(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(F).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(F).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(F)>-1&&(e.attrs[t]=n.split(F).join(`<`))}e.children.length&&I(e.children)})}function le(e,t){let n=t&&t.components||ce,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;N.lastIndex=0;let o;for(;o=N.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(P);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=F,a=o.index+1,N.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=N.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=M(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=M(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&se.test(s.name)){t=!0,d||(d=e.toLowerCase());let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);oe.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&I(a),a}function ue(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`&quot;`)+`"`);return t.length?` `+t.join(` `):``}function de(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?ue(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(de,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function fe(e){return e.reduce(function(e,t){return e+de(``,t)},``)}var L={parse:le,stringify:fe},R=e(t()),z=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},B=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?V(t):t},pe=e=>Array.isArray(e)&&e.every(R.isValidElement),V=e=>Array.isArray(e)?e:[e],me=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},he=e=>{let t={};if(!e)return t;let n=e=>{V(e).forEach(e=>{a(e)||(z(e)?n(B(e)):c(e)&&!(0,R.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},H=(e,t,n,r)=>{if(!e)return``;let o=``,s=V(e),l=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return s.forEach((e,s)=>{if(a(e)){o+=`${e}`;return}if((0,R.isValidElement)(e)){let{props:i,type:c}=e,u=Object.keys(i).length,d=l.indexOf(c)>-1,f=i.children;if(!f&&d&&!u){o+=`<${c}/>`;return}if(!f&&(!d||u)||i.i18nIsDynamicList){o+=`<${s}></${s}>`;return}if(d&&u<=1){let e=a(f)?f:H(f,t,n,r);o+=`<${c}>${e}</${c}>`;return}let p=H(f,t,n,r);o+=`<${s}>${p}</${s}>`;return}if(e===null){i(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(c(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];o+=`{{${e}}}`;return}i(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}i(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),o},U=(e,t,n,r,i,o,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!u&&!s)return[n];let f=t??{},m=e=>{V(e).forEach(e=>{a(e)||(z(e)?m(B(e)):c(e)&&!(0,R.isValidElement)(e)&&Object.assign(f,e))})};m(e);let h=Object.keys(f),g=L.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||l.indexOf(e)>-1||h.indexOf(e)>-1}),_={...f,...o},v=(e,t,n)=>{let r=B(e),i=b(r,t.children,n);return pe(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},y=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,R.cloneElement)(e,{key:r},i?void 0:t))):n.push(...R.Children.map([e],e=>{if(e.type===R.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`children`&&t!==`i18nIsDynamicList`&&(n[t]=e.props[t])}),(0,R.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`ref`&&t!==`children`&&(n[t]=e.props[t])}),(0,R.cloneElement)(e,n,i?null:t)}))},b=(e,n,o)=>{let f=V(e),m=V(n),h={};return m.reduce((e,n,m)=>{let g=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,_,r.language);if(n.type===`tag`){let p=f[parseInt(n.name,10)];!p&&t&&(p=t[n.name]),o.length===1&&!p&&(p=o[0][n.name]),p||(p={});let x={...n.attrs};s&&Object.keys(x).forEach(e=>{let t=x[e];a(t)&&(x[e]=d(t))});let S=Object.keys(x).length===0?p:me({props:x},p),C=(0,R.isValidElement)(S),w=C&&z(n,!0)&&!n.voidElement,ee=u&&c(S)&&S.dummy&&!C,T=c(t)&&Object.hasOwnProperty.call(t,n.name);if(a(S)){let t=r.services.interpolator.interpolate(S,_,r.language);e.push(t)}else if(z(S)||w){let t=v(S,n,o);y(S,t,e,m)}else if(ee){let t=b(f,n.children,o);y(S,t,e,m)}else if(Number.isNaN(parseFloat(n.name)))if(T){let t=v(S,n,o);y(S,t,e,m,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push((0,R.createElement)(n.name,{key:`${n.name}-${m}`}));else{let t=h[n.name]||0;h[n.name]=t+1;let r,i=0;for(let e=0;e<f.length;e+=1){let a=f[e];if((0,R.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?V(B(r)):f,s=b(a,n.children,o);e.push((0,R.createElement)(n.name,{key:`${n.name}-${m}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=b(f,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(c(S)&&!C){let t=n.children[0]?g:null;t&&e.push(t)}else y(S,g,e,m,n.children.length!==1||!g)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:p().unescape,o=s?a(r.services.interpolator.interpolate(n.content,_,r.language)):r.services.interpolator.interpolate(n.content,_,r.language);t?e.push((0,R.createElement)(t,{key:`${n.name}-${m}`},o)):e.push(o)}return e},[])};return B(b([{dummy:!0,children:e||[]}],g,V(e||[]))[0])},W=(e,t,n)=>{let r=e.key||t,i=(0,R.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,R.createElement)(R.Fragment,null,i)}return(0,R.createElement)(a,{key:r})},G=(e,t)=>e.map((e,n)=>W(e,n,t)),ge=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:W(e[r],r,t)})}),n},_e=(e,t,n,r)=>e?Array.isArray(e)?G(e,t):c(e)?ge(e,t):(s(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,ve=e=>!c(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function ye({children:e,count:t,parent:n,i18nKey:i,context:o,tOptions:c={},values:l,defaults:d,components:f,ns:m,i18n:h,t:g,shouldUnescape:_,...v}){let y=h||u();if(!y)return s(y,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:i}),e;let b=g||y.t.bind(y)||(e=>e),x={...p(),...y.options?.react},S=m||b.ns||y.options?.defaultNS;S=a(S)?[S]:S||[`translation`];let{transDefaultProps:C}=x,w=C?.tOptions?{...C.tOptions,...c}:c,ee=_??C?.shouldUnescape,T=C?.values?{...C.values,...l}:l,te=C?.components?{...C.components,...f}:f,ne=H(e,x,y,i),E=d||w?.defaultValue||ne||x.transEmptyNodeValue||(typeof i==`function`?r(i):i),{hashTransKey:re}=x,D=i||(re?re(ne||E):ne||E);l=y.options?.interpolation?.defaultVariables?T&&Object.keys(T).length>0?{...T,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables}:T;let O=he(e);O&&typeof O.count==`number`&&t===void 0&&(t=O.count);let k=l||t!==void 0&&!y.options?.interpolation?.alwaysFormat||!e?w.interpolation:{interpolation:{...w.interpolation,prefix:`#$?`,suffix:`?$#`}},ie={...w,context:o||w.context,count:t,...l,...k,defaultValue:E,ns:S},A=D?b(D,ie):E;A===D&&E&&(A=E);let j=_e(te,A,y,i),ae=j||e,M=null;ve(j)&&(M=j,ae=e);let N=U(ae,M,A,y,x,ie,ee),P=n??x.defaultTransParent;return P?(0,R.createElement)(P,v,N):N}function be({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:s,defaults:c,components:l,ns:d,i18n:f,t:p,shouldUnescape:m,...h}){let{i18n:g,defaultNS:_}=(0,R.useContext)(o)||{},v=f||g||u(),y=p||v?.t.bind(v);return ye({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:s,defaults:c,components:l,ns:d||y?.ns||_||v?.options?.defaultNS,i18n:v,t:p,shouldUnescape:m,...h})}var K=n(),q=D(`pages:libre-claw`),xe={queued:`bg-gray-100 text-gray-700 dark:bg-dark-200 dark:text-dark-700`,running:`bg-primary-100 text-primary-700 dark:bg-primary-900/25 dark:text-primary-300`,blocked:`bg-amber-500/20 text-ink dark:bg-amber-900/30`,done:`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`,failed:`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300`,cancelled:`bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300`},Se={assistant_message:`text-primary-600 dark:text-primary-300`,assistant_delta:`text-primary-600 dark:text-primary-300`,user_message:`text-gray-700 dark:text-dark-700`,permission_request:`text-ink`,permission_response:`text-gray-600 dark:text-dark-600`,tool_call:`text-gray-600 dark:text-dark-600`,tool_result:`text-gray-600 dark:text-dark-600`,usage:`text-gray-600 dark:text-dark-600`,error:`text-red-600 dark:text-red-300`,run_finished:`text-emerald-600 dark:text-emerald-300`},Ce=[[`lobster`,`Lobster`],[`lobster-light`,`Lobster Light`],[`github-dark`,`GitHub Dark`],[`github-light`,`GitHub Light`],[`monokai-pro`,`Monokai Pro`],[`night-owl`,`Night Owl`],[`tokyo-night`,`Tokyo Night`],[`ayu`,`Ayu`],[`dracula`,`Dracula`],[`catppuccin-mocha`,`Catppuccin Mocha`],[`catppuccin-latte`,`Catppuccin Latte`],[`gruvbox-dark`,`Gruvbox Dark`],[`nord`,`Nord`],[`solarized-dark`,`Solarized Dark`],[`solarized-light`,`Solarized Light`],[`one-dark-pro`,`One Dark Pro`],[`rose-pine`,`Rose Pine`],[`kanagawa`,`Kanagawa`],[`matrix`,`Matrix`]],we=()=>{let{t:e}=l(),[t,n]=(0,R.useState)(null),[r,i]=(0,R.useState)([]),[a,o]=(0,R.useState)([]),[s,c]=(0,R.useState)([]),[u,d]=(0,R.useState)(null),[p,D]=(0,R.useState)(null),[j,ae]=(0,R.useState)(``),[M,N]=(0,R.useState)(null),[P,oe]=(0,R.useState)(!0),[se,F]=(0,R.useState)(!1),[ce,I]=(0,R.useState)(!1),[le,ue]=(0,R.useState)(!1),[de,fe]=(0,R.useState)(!1),[L,z]=(0,R.useState)(``),[B,pe]=(0,R.useState)(`chat`),[V,me]=(0,R.useState)(``),[he,H]=(0,R.useState)(``),[U,W]=(0,R.useState)(``),[G,ge]=(0,R.useState)(``),[_e,ve]=(0,R.useState)(!1),[ye,xe]=(0,R.useState)(`lobster`),[Se,we]=(0,R.useState)(!0),[ke,Ae]=(0,R.useState)(``),[je,Y]=(0,R.useState)(``),[X,Fe]=(0,R.useState)(``),[Ie,Le]=(0,R.useState)(`report`),Z=(0,R.useMemo)(()=>r.find(e=>e.run_id===M)||null,[r,M]),Q=(0,R.useMemo)(()=>{let e=new Set(a.filter(e=>e.type===`permission_response`).map(e=>String(e.data.tool_call_id||``)));return a.filter(t=>{if(t.type!==`permission_request`)return!1;let n=String(t.data.tool_call_id||``);return n&&!e.has(n)})},[a]),Re=(0,R.useMemo)(()=>Pe(a,e),[a,e]),$=(0,R.useCallback)(async()=>{try{let[e,t,r,a,o,s]=await Promise.all([O.status(),O.listRuns(30),O.currentModel(),O.currentFallback(),O.usage(``,100),O.listAutomations(50)]);e.success&&e.data&&n(e.data),t.success&&t.data&&(i(t.data.runs),N(e=>e||t.data?.runs[0]?.run_id||null)),r.success&&r.data&&(d(r.data),W(String(r.data.provider||``)),ge(String(r.data.model||``))),a.success&&a.data&&D(a.data),o.success&&o.data&&ae(String(o.data.text||``)),s.success&&s.data&&c(s.data.automations)}catch(t){q.error(`Failed to load Libre Claw overview:`,t),C.error(e(`libreClaw.toasts.loadStatusFailed`))}finally{oe(!1)}},[e]),ze=(0,R.useCallback)(async(e,t=!1)=>{let n=t?0:a.length>0&&a[a.length-1]?.event_id||0;try{let r=await O.getEvents(e,n);r.success&&r.data&&o(e=>t?r.data?.events||[]:[...e,...r.data?.events||[]])}catch(e){q.error(`Failed to load Libre Claw events:`,e)}},[a]);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>{$()},0);return()=>window.clearTimeout(e)},[$]),(0,R.useEffect)(()=>{if(!M){let e=window.setTimeout(()=>{o([])},0);return()=>window.clearTimeout(e)}let e=M;O.getEvents(e,0).then(e=>{e.success&&e.data&&o(e.data.events)}).catch(e=>{q.error(`Failed to load Libre Claw events:`,e)})},[M]),(0,R.useEffect)(()=>{if(!M||!Z||![`queued`,`running`,`blocked`].includes(Z.state))return;let e=window.setInterval(()=>{ze(M),O.listRuns(30).then(e=>{e.success&&e.data&&i(e.data.runs)})},1500);return()=>window.clearInterval(e)},[ze,Z,M]);let Be=async()=>{if(!L.trim()){C.error(e(`libreClaw.toasts.enterTask`));return}F(!0);try{let t=await O.startRun({message:L,kind:B,provider:V||void 0,model:he||void 0});if(t.success&&t.data){let n=t.data.run;i(e=>[n,...e.filter(e=>e.run_id!==n.run_id)]),N(n.run_id),z(``),C.success(e(`libreClaw.toasts.runStarted`))}else C.error(t.error||e(`libreClaw.toasts.startRunFailed`))}catch(t){q.error(`Failed to start Libre Claw run:`,t),C.error(e(`libreClaw.toasts.startRunFailed`))}finally{F(!1)}},Ve=async t=>{try{await O.cancelRun(t),await $(),C.success(e(`libreClaw.toasts.runCancelled`))}catch(t){q.error(`Failed to cancel Libre Claw run:`,t),C.error(e(`libreClaw.toasts.cancelRunFailed`))}},He=async(t,n)=>{if(!M)return;let r=String(t.data.tool_call_id||``);if(r)try{await O.resolvePermission(M,r,n),await ze(M,!0),C.success(e(n===`deny`?`libreClaw.toasts.denied`:`libreClaw.toasts.approved`))}catch(t){q.error(`Failed to resolve Libre Claw permission:`,t),C.error(e(`libreClaw.toasts.resolvePermissionFailed`))}},Ue=async()=>{if(!U.trim()||!G.trim()){C.error(e(`libreClaw.toasts.providerModelRequired`));return}I(!0);try{let t=await O.updateModel(U,G,_e);t.success&&t.data?(d(t.data),C.success(e(`libreClaw.toasts.modelUpdated`))):C.error(t.error||e(`libreClaw.toasts.updateModelFailed`))}catch(t){q.error(`Failed to update Libre Claw model:`,t),C.error(e(`libreClaw.toasts.updateModelFailed`))}finally{I(!1)}},We=async()=>{ue(!0);try{let t=await O.updateTheme(ye,Se);t.success?C.success(e(`libreClaw.toasts.themeUpdated`)):C.error(t.error||e(`libreClaw.toasts.updateThemeFailed`))}catch(t){q.error(`Failed to update Libre Claw theme:`,t),C.error(e(`libreClaw.toasts.updateThemeFailed`))}finally{ue(!1)}},Ge=async()=>{if(!ke.trim()||!je.trim()||!X.trim()){C.error(e(`libreClaw.toasts.automationRequired`));return}fe(!0);try{let t=await O.createAutomation({name:ke,schedule:je,prompt:X,route:Ie});t.success?(Ae(``),Y(``),Fe(``),await $(),C.success(e(`libreClaw.toasts.automationCreated`))):C.error(t.error||e(`libreClaw.toasts.createAutomationFailed`))}catch(t){q.error(`Failed to create Libre Claw automation:`,t),C.error(e(`libreClaw.toasts.createAutomationFailed`))}finally{fe(!1)}},Ke=async(t,n)=>{try{n===`pause`&&await O.pauseAutomation(t),n===`resume`&&await O.resumeAutomation(t),n===`run`&&await O.runAutomationNow(t),n===`delete`&&await O.deleteAutomation(t),await $(),C.success(e(`libreClaw.toasts.automationUpdated`))}catch(t){q.error(`Failed to update Libre Claw automation:`,t),C.error(e(`libreClaw.toasts.updateAutomationFailed`))}};return(0,K.jsxs)(ie,{width:`wide`,contentClassName:`space-y-6`,children:[(0,K.jsx)(A,{className:`mb-0`,title:e(`libreClaw.title`),description:e(`libreClaw.subtitle`),actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Te,{status:t,t:e}),(0,K.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:$,children:[(0,K.jsx)(re,{className:`h-4 w-4`}),e(`common.refresh`)]}),(0,K.jsxs)(`a`,{href:t?.dashboardUrl||`http://127.0.0.1:8766/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-xl border border-gray-200/80 bg-white/70 px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-white dark:border-white/10 dark:bg-white/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.08]`,children:[(0,K.jsx)(h,{className:`h-4 w-4`}),e(`libreClaw.dashboard`)]})]})}),!t?.connected&&!P&&(0,K.jsx)(`section`,{className:`rounded-xl border border-amber-200 bg-amber-500/10 p-4 text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(E,{className:`mt-0.5 h-5 w-5 shrink-0 text-amber-500`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`font-semibold`,children:e(`libreClaw.connection.disconnectedTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm opacity-90`,children:(0,K.jsx)(be,{i18nKey:`libreClaw.connection.disconnectedDescription`,components:{command:(0,K.jsx)(`code`,{}),env:(0,K.jsx)(`code`,{})}})}),t?.error&&(0,K.jsx)(`p`,{className:`mt-2 text-xs opacity-80`,children:t.error})]})]})}),(0,K.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.startRun.title`),icon:(0,K.jsx)(g,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`textarea`,{value:L,onChange:e=>z(e.target.value),placeholder:e(`libreClaw.startRun.placeholder`),className:`min-h-32 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-100 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800 dark:focus:border-primary-500 dark:focus:ring-primary-900/30`}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,K.jsxs)(`select`,{value:B,onChange:e=>pe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`chat`,children:e(`libreClaw.startRun.chatRun`)}),(0,K.jsx)(`option`,{value:`goal`,children:e(`libreClaw.startRun.goalMode`)})]}),(0,K.jsx)(`input`,{value:V,onChange:e=>me(e.target.value),placeholder:e(`libreClaw.startRun.providerOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:he,onChange:e=>H(e.target.value),placeholder:e(`libreClaw.startRun.modelOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(k,{onClick:Be,loading:se,children:[(0,K.jsx)(y,{className:`h-4 w-4`}),e(`libreClaw.startRun.run`)]})]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.modelRoute.title`),icon:(0,K.jsx)(w,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-1`,children:[(0,K.jsx)(`input`,{value:U,onChange:e=>W(e.target.value),placeholder:e(`libreClaw.modelRoute.providerPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:G,onChange:e=>ge(e.target.value),placeholder:e(`libreClaw.modelRoute.modelPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>ve(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]}),(0,K.jsx)(k,{variant:`secondary`,onClick:Ue,loading:ce,children:e(`libreClaw.modelRoute.saveModel`)}),(0,K.jsxs)(`div`,{className:`border-t border-gray-100 pt-3 dark:border-dark-200`,children:[(0,K.jsx)(`label`,{className:`mb-1 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-500`,children:e(`libreClaw.modelRoute.theme`)}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] lg:grid-cols-1`,children:[(0,K.jsx)(`select`,{value:ye,onChange:e=>xe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:Ce.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsx)(k,{variant:`secondary`,onClick:We,loading:le,children:e(`libreClaw.modelRoute.saveTheme`)})]}),(0,K.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:Se,onChange:e=>we(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]})]}),u&&(0,K.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(u,null,2)})]})})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.runs.title`),icon:(0,K.jsx)(_,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[r.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.runs.empty`)}),r.map(t=>(0,K.jsxs)(`button`,{onClick:()=>N(t.run_id),className:f(`w-full rounded-xl border p-3 text-start transition`,M===t.run_id?`border-primary-300 bg-primary-50 dark:border-primary-700 dark:bg-primary-900/20`:`border-gray-200 bg-white hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-50 dark:hover:bg-dark-100`),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,K.jsx)(Ee,{state:t.state,t:e})]}),(0,K.jsxs)(`div`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-dark-500`,children:[t.provider,`:`,t.model]}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:Ne(t.updated_at)})]},t.run_id))]})}),(0,K.jsxs)(J,{title:Z?Z.title:e(`libreClaw.timeline.title`),icon:(0,K.jsx)(ne,{className:`h-4 w-4`}),actions:Z&&[`queued`,`running`,`blocked`].includes(Z.state)?(0,K.jsxs)(k,{variant:`danger`,size:`sm`,onClick:()=>Ve(Z.run_id),children:[(0,K.jsx)(v,{className:`h-4 w-4`}),e(`common.cancel`)]}):null,children:[Q.length>0&&(0,K.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-xl border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-800 dark:bg-amber-900/20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,K.jsx)(m,{className:`h-4 w-4 text-amber-500`}),e(`libreClaw.approvals.needed`)]}),Q.map(t=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-white/70 p-3 dark:bg-dark-50/70`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(t.data.name||e(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto rounded bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(t.data.arguments||{},null,2)}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,K.jsxs)(k,{size:`sm`,onClick:()=>He(t,`allow_once`),children:[(0,K.jsx)(b,{className:`h-4 w-4`}),e(`libreClaw.approvals.allowOnce`)]}),(0,K.jsx)(k,{size:`sm`,variant:`secondary`,onClick:()=>He(t,`always_allow_tool`),children:e(`libreClaw.approvals.alwaysAllowTool`)}),(0,K.jsxs)(k,{size:`sm`,variant:`danger`,onClick:()=>He(t,`deny`),children:[(0,K.jsx)(T,{className:`h-4 w-4`}),e(`libreClaw.approvals.deny`)]})]})]},t.event_id))]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[a.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.timeline.empty`)}),Re.map(t=>(0,K.jsx)(Oe,{item:t,t:e},t.key))]})]})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,K.jsx)(J,{title:e(`libreClaw.automations.title`),icon:(0,K.jsx)(ee,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsx)(`input`,{value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`libreClaw.automations.namePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:je,onChange:e=>Y(e.target.value),placeholder:e(`libreClaw.automations.schedulePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`select`,{value:Ie,onChange:e=>Le(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`report`,children:e(`libreClaw.automations.routes.report`)}),(0,K.jsx)(`option`,{value:`telegram`,children:e(`libreClaw.automations.routes.telegram`)})]}),(0,K.jsx)(k,{onClick:Ge,loading:de,children:e(`libreClaw.automations.create`)})]}),(0,K.jsx)(`textarea`,{value:X,onChange:e=>Fe(e.target.value),placeholder:e(`libreClaw.automations.promptPlaceholder`),className:`min-h-24 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[s.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.automations.empty`)}),s.map(t=>(0,K.jsx)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-3 dark:border-dark-300 dark:bg-dark-50`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.name}),(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[t.schedule,` ·`,` `,e(`libreClaw.automations.routes.${t.route}`,{defaultValue:t.route}),` `,`·`,` `,e(`libreClaw.automations.status.${t.status}`,{defaultValue:t.status})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,K.jsx)(De,{title:e(`libreClaw.automations.runNow`),onClick:()=>Ke(t.automation_id,`run`),children:(0,K.jsx)(g,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:t.status===`paused`?e(`libreClaw.automations.resume`):e(`libreClaw.automations.pause`),onClick:()=>Ke(t.automation_id,t.status===`paused`?`resume`:`pause`),children:t.status===`paused`?(0,K.jsx)(g,{className:`h-4 w-4`}):(0,K.jsx)(te,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:e(`common.delete`),danger:!0,onClick:()=>Ke(t.automation_id,`delete`),children:(0,K.jsx)(S,{className:`h-4 w-4`})})]})]})},t.automation_id))]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.usageFallback.title`),icon:(0,K.jsx)(_,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.usage`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:j||e(`libreClaw.usageFallback.noUsage`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.fallbackRoute`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(p||{},null,2)})]})]})})]}),P&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-white/60 backdrop-blur-sm dark:bg-dark-50/60`,children:(0,K.jsx)(x,{className:`h-7 w-7 animate-spin text-primary-600`})})]})},Te=({status:e,t})=>{let n=!!e?.connected;return(0,K.jsxs)(`span`,{className:f(`inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium`,n?`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`:`bg-amber-500/20 text-ink dark:bg-amber-900/30`),children:[(0,K.jsx)(`span`,{className:f(`h-2 w-2 rounded-full`,n?`bg-emerald-500`:`bg-amber-500`)}),t(n?`libreClaw.status.connected`:`libreClaw.status.disconnected`),e?.health?.active_runs!==void 0&&(0,K.jsxs)(`span`,{className:`opacity-70`,children:[`·`,` `,t(`libreClaw.status.activeRuns`,{count:e.health.active_runs})]})]})},Ee=({state:e,t})=>(0,K.jsx)(`span`,{className:f(`rounded-full px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,xe[e]||xe.queued),children:t(`libreClaw.states.${e}`,{defaultValue:e})}),J=({title:e,icon:t,actions:n,children:r})=>(0,K.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/60 dark:border-white/10 dark:bg-white/[0.03]`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-5 py-4 dark:border-white/[0.08]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:[(0,K.jsx)(`span`,{className:`text-primary-600 dark:text-primary-300`,children:t}),e]}),n]}),(0,K.jsx)(`div`,{className:`p-5`,children:r})]}),De=({title:e,danger:t,onClick:n,children:r})=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:n,className:f(`inline-flex h-8 w-8 items-center justify-center rounded-lg transition-colors`,t?`text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`:`text-gray-500 hover:bg-gray-100 dark:text-dark-500 dark:hover:bg-dark-200`),children:r}),Oe=({item:e,t})=>(0,K.jsxs)(`article`,{className:f(`rounded-xl border p-3 transition-colors`,e.eventType===`assistant_message`?`border-primary-200 bg-primary-50/60 dark:border-primary-900/60 dark:bg-primary-900/10`:(e.eventType,`border-gray-200/80 bg-white/50 dark:border-white/[0.08] dark:bg-white/[0.025]`)),children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:f(`text-xs font-semibold uppercase tracking-wide`,Se[e.eventType]||`text-gray-500 dark:text-dark-500`),children:e.label}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-400 dark:text-dark-500`,children:[Le(e),` · `,Ne(e.timestamp)]})]}),(0,K.jsx)(ke,{item:e,t})]}),ke=({item:e,t})=>{if(e.kind===`assistant_message`)return(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-gray-900 dark:text-dark-900`,children:Fe(e.events)||t(`libreClaw.timeline.streaming`)});let n=e.events[0];return n?n.type===`assistant_delta`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.text||``)}):n.type===`user_message`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.content||``)}):n.type===`tool_call`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`tool_result`?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:[String(n.data.name||t(`libreClaw.fallbacks.tool`)),` ·`,` `,n.data.is_error?t(`libreClaw.timeline.resultError`):t(`libreClaw.timeline.resultOk`)]}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:String(n.data.content||``)})]}):n.type===`permission_request`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.approvals.toolApprovalRequested`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`permission_response`?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.tool`),value:String(n.data.name||n.data.tool_call_id||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.resolution`),value:String(n.data.resolution||t(`libreClaw.fallbacks.resolved`))})]}):n.type===`usage`?(0,K.jsx)(Ae,{data:n.data,t}):n.type===`run_finished`?(0,K.jsx)(je,{data:n.data,t}):n.type===`error`?(0,K.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-300`,children:String(n.data.message||t(`libreClaw.fallbacks.unknownError`))}):(0,K.jsx)(X,{value:n.data}):null},Ae=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.provider`),value:String(e.provider||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.model`),value:String(e.model||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.input`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.input_tokens),formatted:Q(e.input_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.output`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.output_tokens),formatted:Q(e.output_tokens)})}),Z(e.cached_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cached`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.cached_tokens),formatted:Q(e.cached_tokens)})}),Z(e.reasoning_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.reasoning`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.reasoning_tokens),formatted:Q(e.reasoning_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cost`),value:Re(e.cost)})]}),je=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.state`),value:t(`libreClaw.states.${String(e.state||`done`)}`,{defaultValue:String(e.state||`done`)})}),e.stop_reason!==void 0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.stopReason`),value:String(e.stop_reason)})]}),Y=({label:e,value:t})=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200/80 bg-white/50 px-2.5 py-1 text-xs text-gray-700 dark:border-white/10 dark:bg-white/[0.035] dark:text-dark-700`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-gray-500 dark:text-dark-500`,children:e}),(0,K.jsx)(`span`,{children:t})]}),X=({value:e})=>(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(e,null,2)}),Me=({text:e})=>(0,K.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-300 bg-white/30 px-4 py-8 text-center text-sm text-gray-500 dark:border-white/15 dark:bg-white/[0.02] dark:text-dark-500`,children:e}),Ne=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},Pe=(e,t)=>{let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;if(i.type===`assistant_delta`){let i=[];for(;e[r]?.type===`assistant_delta`;){let t=e[r];t&&i.push(t),r+=1}let a=i[0],o=i[i.length-1]||a;a&&o&&n.push({key:`assistant-${a.event_id}-${o.event_id}`,kind:`assistant_message`,eventType:`assistant_message`,label:t(`libreClaw.timeline.assistantResponse`),firstEventId:a.event_id,lastEventId:o.event_id,timestamp:a.timestamp,events:i});continue}n.push({key:`${i.type}-${i.event_id}`,kind:`event`,eventType:i.type,label:Ie(i.type,t),firstEventId:i.event_id,lastEventId:i.event_id,timestamp:i.timestamp,events:[i]}),r+=1}return n},Fe=e=>e.map(e=>String(e.data.text||``)).join(``),Ie=(e,t)=>({user_message:t(`libreClaw.timeline.labels.userMessage`),tool_call:t(`libreClaw.timeline.labels.toolCall`),tool_result:t(`libreClaw.timeline.labels.toolResult`),permission_request:t(`libreClaw.timeline.labels.approvalRequest`),permission_response:t(`libreClaw.timeline.labels.approvalResponse`),run_started:t(`libreClaw.timeline.labels.runStarted`),run_finished:t(`libreClaw.timeline.labels.runFinished`),usage:t(`libreClaw.timeline.labels.usage`),error:t(`libreClaw.timeline.labels.error`)})[e]||e.replace(/_/g,` `),Le=e=>e.firstEventId===e.lastEventId?`#${e.firstEventId}`:`#${e.firstEventId}-#${e.lastEventId}`,Z=e=>{let t=Number(e);return Number.isFinite(t)?t:0},Q=e=>new Intl.NumberFormat().format(Z(e)),Re=e=>{let t=Z(e);return t<=0?`$0.00`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`};export{we as default};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{n as r}from"./i18next-DgmgtwsV.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./useTranslation-Bho4HCyg.js";import{c as u,f as d,t as f,u as p}from"./utils-D9W1Lnkn.js";import{C as m,Dn as h,Fn as g,Jt as _,Mt as v,Rn as y,V as b,W as x,Y as S,_n as C,b as w,g as ee,in as T,j as te,mt as ne,n as E,xn as re}from"./ui-vendor-B1UgO3vd.js";import{t as D}from"./logger-DSXjF4ye.js";import{_ as O}from"./api-BDtqBtqw.js";import{t as k}from"./Button-BPf_pOxH.js";import{n as ie,t as A}from"./ui-CC-K19wO.js";var j={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},ae=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function M(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(j[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(ae),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var N=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,P=/<\/?([^\s]+?)[/\s>]/,oe=/^\s*$/,se=/^(script|style)$/i,F=`\0`,ce=Object.create(null);function I(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(F).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(F).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(F)>-1&&(e.attrs[t]=n.split(F).join(`<`))}e.children.length&&I(e.children)})}function le(e,t){let n=t&&t.components||ce,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;N.lastIndex=0;let o;for(;o=N.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(P);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=F,a=o.index+1,N.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=N.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=M(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=M(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&se.test(s.name)){t=!0,d||(d=e.toLowerCase());let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);oe.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&I(a),a}function ue(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`&quot;`)+`"`);return t.length?` `+t.join(` `):``}function de(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?ue(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(de,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function fe(e){return e.reduce(function(e,t){return e+de(``,t)},``)}var L={parse:le,stringify:fe},R=e(t()),z=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},B=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?V(t):t},pe=e=>Array.isArray(e)&&e.every(R.isValidElement),V=e=>Array.isArray(e)?e:[e],me=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},he=e=>{let t={};if(!e)return t;let n=e=>{V(e).forEach(e=>{a(e)||(z(e)?n(B(e)):c(e)&&!(0,R.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},H=(e,t,n,r)=>{if(!e)return``;let o=``,s=V(e),l=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return s.forEach((e,s)=>{if(a(e)){o+=`${e}`;return}if((0,R.isValidElement)(e)){let{props:i,type:c}=e,u=Object.keys(i).length,d=l.indexOf(c)>-1,f=i.children;if(!f&&d&&!u){o+=`<${c}/>`;return}if(!f&&(!d||u)||i.i18nIsDynamicList){o+=`<${s}></${s}>`;return}if(d&&u<=1){let e=a(f)?f:H(f,t,n,r);o+=`<${c}>${e}</${c}>`;return}let p=H(f,t,n,r);o+=`<${s}>${p}</${s}>`;return}if(e===null){i(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(c(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];o+=`{{${e}}}`;return}i(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}i(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),o},U=(e,t,n,r,i,o,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],u=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!u&&!s)return[n];let f=t??{},m=e=>{V(e).forEach(e=>{a(e)||(z(e)?m(B(e)):c(e)&&!(0,R.isValidElement)(e)&&Object.assign(f,e))})};m(e);let h=Object.keys(f),g=L.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||l.indexOf(e)>-1||h.indexOf(e)>-1}),_={...f,...o},v=(e,t,n)=>{let r=B(e),i=b(r,t.children,n);return pe(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},y=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,R.cloneElement)(e,{key:r},i?void 0:t))):n.push(...R.Children.map([e],e=>{if(e.type===R.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`children`&&t!==`i18nIsDynamicList`&&(n[t]=e.props[t])}),(0,R.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`ref`&&t!==`children`&&(n[t]=e.props[t])}),(0,R.cloneElement)(e,n,i?null:t)}))},b=(e,n,o)=>{let f=V(e),m=V(n),h={};return m.reduce((e,n,m)=>{let g=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,_,r.language);if(n.type===`tag`){let p=f[parseInt(n.name,10)];!p&&t&&(p=t[n.name]),o.length===1&&!p&&(p=o[0][n.name]),p||(p={});let x={...n.attrs};s&&Object.keys(x).forEach(e=>{let t=x[e];a(t)&&(x[e]=d(t))});let S=Object.keys(x).length===0?p:me({props:x},p),C=(0,R.isValidElement)(S),w=C&&z(n,!0)&&!n.voidElement,ee=u&&c(S)&&S.dummy&&!C,T=c(t)&&Object.hasOwnProperty.call(t,n.name);if(a(S)){let t=r.services.interpolator.interpolate(S,_,r.language);e.push(t)}else if(z(S)||w){let t=v(S,n,o);y(S,t,e,m)}else if(ee){let t=b(f,n.children,o);y(S,t,e,m)}else if(Number.isNaN(parseFloat(n.name)))if(T){let t=v(S,n,o);y(S,t,e,m,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push((0,R.createElement)(n.name,{key:`${n.name}-${m}`}));else{let t=h[n.name]||0;h[n.name]=t+1;let r,i=0;for(let e=0;e<f.length;e+=1){let a=f[e];if((0,R.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?V(B(r)):f,s=b(a,n.children,o);e.push((0,R.createElement)(n.name,{key:`${n.name}-${m}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=b(f,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(c(S)&&!C){let t=n.children[0]?g:null;t&&e.push(t)}else y(S,g,e,m,n.children.length!==1||!g)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:p().unescape,o=s?a(r.services.interpolator.interpolate(n.content,_,r.language)):r.services.interpolator.interpolate(n.content,_,r.language);t?e.push((0,R.createElement)(t,{key:`${n.name}-${m}`},o)):e.push(o)}return e},[])};return B(b([{dummy:!0,children:e||[]}],g,V(e||[]))[0])},W=(e,t,n)=>{let r=e.key||t,i=(0,R.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,R.createElement)(R.Fragment,null,i)}return(0,R.createElement)(a,{key:r})},G=(e,t)=>e.map((e,n)=>W(e,n,t)),ge=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:W(e[r],r,t)})}),n},_e=(e,t,n,r)=>e?Array.isArray(e)?G(e,t):c(e)?ge(e,t):(s(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,ve=e=>!c(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function ye({children:e,count:t,parent:n,i18nKey:i,context:o,tOptions:c={},values:l,defaults:d,components:f,ns:m,i18n:h,t:g,shouldUnescape:_,...v}){let y=h||u();if(!y)return s(y,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:i}),e;let b=g||y.t.bind(y)||(e=>e),x={...p(),...y.options?.react},S=m||b.ns||y.options?.defaultNS;S=a(S)?[S]:S||[`translation`];let{transDefaultProps:C}=x,w=C?.tOptions?{...C.tOptions,...c}:c,ee=_??C?.shouldUnescape,T=C?.values?{...C.values,...l}:l,te=C?.components?{...C.components,...f}:f,ne=H(e,x,y,i),E=d||w?.defaultValue||ne||x.transEmptyNodeValue||(typeof i==`function`?r(i):i),{hashTransKey:re}=x,D=i||(re?re(ne||E):ne||E);l=y.options?.interpolation?.defaultVariables?T&&Object.keys(T).length>0?{...T,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables}:T;let O=he(e);O&&typeof O.count==`number`&&t===void 0&&(t=O.count);let k=l||t!==void 0&&!y.options?.interpolation?.alwaysFormat||!e?w.interpolation:{interpolation:{...w.interpolation,prefix:`#$?`,suffix:`?$#`}},ie={...w,context:o||w.context,count:t,...l,...k,defaultValue:E,ns:S},A=D?b(D,ie):E;A===D&&E&&(A=E);let j=_e(te,A,y,i),ae=j||e,M=null;ve(j)&&(M=j,ae=e);let N=U(ae,M,A,y,x,ie,ee),P=n??x.defaultTransParent;return P?(0,R.createElement)(P,v,N):N}function be({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:s,defaults:c,components:l,ns:d,i18n:f,t:p,shouldUnescape:m,...h}){let{i18n:g,defaultNS:_}=(0,R.useContext)(o)||{},v=f||g||u(),y=p||v?.t.bind(v);return ye({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:s,defaults:c,components:l,ns:d||y?.ns||_||v?.options?.defaultNS,i18n:v,t:p,shouldUnescape:m,...h})}var K=n(),q=D(`pages:libre-claw`),xe={queued:`bg-gray-100 text-gray-700 dark:bg-dark-200 dark:text-dark-700`,running:`bg-primary-100 text-primary-700 dark:bg-primary-900/25 dark:text-primary-300`,blocked:`bg-amber-500/20 text-ink dark:bg-amber-900/30`,done:`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`,failed:`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300`,cancelled:`bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300`},Se={assistant_message:`text-primary-600 dark:text-primary-300`,assistant_delta:`text-primary-600 dark:text-primary-300`,user_message:`text-gray-700 dark:text-dark-700`,permission_request:`text-ink`,permission_response:`text-gray-600 dark:text-dark-600`,tool_call:`text-gray-600 dark:text-dark-600`,tool_result:`text-gray-600 dark:text-dark-600`,usage:`text-gray-600 dark:text-dark-600`,error:`text-red-600 dark:text-red-300`,run_finished:`text-emerald-600 dark:text-emerald-300`},Ce=[[`lobster`,`Lobster`],[`lobster-light`,`Lobster Light`],[`github-dark`,`GitHub Dark`],[`github-light`,`GitHub Light`],[`monokai-pro`,`Monokai Pro`],[`night-owl`,`Night Owl`],[`tokyo-night`,`Tokyo Night`],[`ayu`,`Ayu`],[`dracula`,`Dracula`],[`catppuccin-mocha`,`Catppuccin Mocha`],[`catppuccin-latte`,`Catppuccin Latte`],[`gruvbox-dark`,`Gruvbox Dark`],[`nord`,`Nord`],[`solarized-dark`,`Solarized Dark`],[`solarized-light`,`Solarized Light`],[`one-dark-pro`,`One Dark Pro`],[`rose-pine`,`Rose Pine`],[`kanagawa`,`Kanagawa`],[`matrix`,`Matrix`]],we=()=>{let{t:e}=l(),[t,n]=(0,R.useState)(null),[r,i]=(0,R.useState)([]),[a,o]=(0,R.useState)([]),[s,c]=(0,R.useState)([]),[u,d]=(0,R.useState)(null),[p,D]=(0,R.useState)(null),[j,ae]=(0,R.useState)(``),[M,N]=(0,R.useState)(null),[P,oe]=(0,R.useState)(!0),[se,F]=(0,R.useState)(!1),[ce,I]=(0,R.useState)(!1),[le,ue]=(0,R.useState)(!1),[de,fe]=(0,R.useState)(!1),[L,z]=(0,R.useState)(``),[B,pe]=(0,R.useState)(`chat`),[V,me]=(0,R.useState)(``),[he,H]=(0,R.useState)(``),[U,W]=(0,R.useState)(``),[G,ge]=(0,R.useState)(``),[_e,ve]=(0,R.useState)(!1),[ye,xe]=(0,R.useState)(`lobster`),[Se,we]=(0,R.useState)(!0),[ke,Ae]=(0,R.useState)(``),[je,Y]=(0,R.useState)(``),[X,Fe]=(0,R.useState)(``),[Ie,Le]=(0,R.useState)(`report`),Z=(0,R.useMemo)(()=>r.find(e=>e.run_id===M)||null,[r,M]),Q=(0,R.useMemo)(()=>{let e=new Set(a.filter(e=>e.type===`permission_response`).map(e=>String(e.data.tool_call_id||``)));return a.filter(t=>{if(t.type!==`permission_request`)return!1;let n=String(t.data.tool_call_id||``);return n&&!e.has(n)})},[a]),Re=(0,R.useMemo)(()=>Pe(a,e),[a,e]),$=(0,R.useCallback)(async()=>{try{let[e,t,r,a,o,s]=await Promise.all([O.status(),O.listRuns(30),O.currentModel(),O.currentFallback(),O.usage(``,100),O.listAutomations(50)]);e.success&&e.data&&n(e.data),t.success&&t.data&&(i(t.data.runs),N(e=>e||t.data?.runs[0]?.run_id||null)),r.success&&r.data&&(d(r.data),W(String(r.data.provider||``)),ge(String(r.data.model||``))),a.success&&a.data&&D(a.data),o.success&&o.data&&ae(String(o.data.text||``)),s.success&&s.data&&c(s.data.automations)}catch(t){q.error(`Failed to load Libre Claw overview:`,t),y.error(e(`libreClaw.toasts.loadStatusFailed`))}finally{oe(!1)}},[e]),ze=(0,R.useCallback)(async(e,t=!1)=>{let n=t?0:a.length>0&&a[a.length-1]?.event_id||0;try{let r=await O.getEvents(e,n);r.success&&r.data&&o(e=>t?r.data?.events||[]:[...e,...r.data?.events||[]])}catch(e){q.error(`Failed to load Libre Claw events:`,e)}},[a]);(0,R.useEffect)(()=>{let e=window.setTimeout(()=>{$()},0);return()=>window.clearTimeout(e)},[$]),(0,R.useEffect)(()=>{if(!M){let e=window.setTimeout(()=>{o([])},0);return()=>window.clearTimeout(e)}let e=M;O.getEvents(e,0).then(e=>{e.success&&e.data&&o(e.data.events)}).catch(e=>{q.error(`Failed to load Libre Claw events:`,e)})},[M]),(0,R.useEffect)(()=>{if(!M||!Z||![`queued`,`running`,`blocked`].includes(Z.state))return;let e=window.setInterval(()=>{ze(M),O.listRuns(30).then(e=>{e.success&&e.data&&i(e.data.runs)})},1500);return()=>window.clearInterval(e)},[ze,Z,M]);let Be=async()=>{if(!L.trim()){y.error(e(`libreClaw.toasts.enterTask`));return}F(!0);try{let t=await O.startRun({message:L,kind:B,provider:V||void 0,model:he||void 0});if(t.success&&t.data){let n=t.data.run;i(e=>[n,...e.filter(e=>e.run_id!==n.run_id)]),N(n.run_id),z(``),y.success(e(`libreClaw.toasts.runStarted`))}else y.error(t.error||e(`libreClaw.toasts.startRunFailed`))}catch(t){q.error(`Failed to start Libre Claw run:`,t),y.error(e(`libreClaw.toasts.startRunFailed`))}finally{F(!1)}},Ve=async t=>{try{await O.cancelRun(t),await $(),y.success(e(`libreClaw.toasts.runCancelled`))}catch(t){q.error(`Failed to cancel Libre Claw run:`,t),y.error(e(`libreClaw.toasts.cancelRunFailed`))}},He=async(t,n)=>{if(!M)return;let r=String(t.data.tool_call_id||``);if(r)try{await O.resolvePermission(M,r,n),await ze(M,!0),y.success(e(n===`deny`?`libreClaw.toasts.denied`:`libreClaw.toasts.approved`))}catch(t){q.error(`Failed to resolve Libre Claw permission:`,t),y.error(e(`libreClaw.toasts.resolvePermissionFailed`))}},Ue=async()=>{if(!U.trim()||!G.trim()){y.error(e(`libreClaw.toasts.providerModelRequired`));return}I(!0);try{let t=await O.updateModel(U,G,_e);t.success&&t.data?(d(t.data),y.success(e(`libreClaw.toasts.modelUpdated`))):y.error(t.error||e(`libreClaw.toasts.updateModelFailed`))}catch(t){q.error(`Failed to update Libre Claw model:`,t),y.error(e(`libreClaw.toasts.updateModelFailed`))}finally{I(!1)}},We=async()=>{ue(!0);try{let t=await O.updateTheme(ye,Se);t.success?y.success(e(`libreClaw.toasts.themeUpdated`)):y.error(t.error||e(`libreClaw.toasts.updateThemeFailed`))}catch(t){q.error(`Failed to update Libre Claw theme:`,t),y.error(e(`libreClaw.toasts.updateThemeFailed`))}finally{ue(!1)}},Ge=async()=>{if(!ke.trim()||!je.trim()||!X.trim()){y.error(e(`libreClaw.toasts.automationRequired`));return}fe(!0);try{let t=await O.createAutomation({name:ke,schedule:je,prompt:X,route:Ie});t.success?(Ae(``),Y(``),Fe(``),await $(),y.success(e(`libreClaw.toasts.automationCreated`))):y.error(t.error||e(`libreClaw.toasts.createAutomationFailed`))}catch(t){q.error(`Failed to create Libre Claw automation:`,t),y.error(e(`libreClaw.toasts.createAutomationFailed`))}finally{fe(!1)}},Ke=async(t,n)=>{try{n===`pause`&&await O.pauseAutomation(t),n===`resume`&&await O.resumeAutomation(t),n===`run`&&await O.runAutomationNow(t),n===`delete`&&await O.deleteAutomation(t),await $(),y.success(e(`libreClaw.toasts.automationUpdated`))}catch(t){q.error(`Failed to update Libre Claw automation:`,t),y.error(e(`libreClaw.toasts.updateAutomationFailed`))}};return(0,K.jsxs)(ie,{width:`wide`,contentClassName:`space-y-6`,children:[(0,K.jsx)(A,{className:`mb-0`,title:e(`libreClaw.title`),description:e(`libreClaw.subtitle`),actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Te,{status:t,t:e}),(0,K.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:$,children:[(0,K.jsx)(b,{className:`h-4 w-4`}),e(`common.refresh`)]}),(0,K.jsxs)(`a`,{href:t?.dashboardUrl||`http://127.0.0.1:8766/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-xl border border-gray-200/80 bg-white/70 px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-white dark:border-white/10 dark:bg-white/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.08]`,children:[(0,K.jsx)(_,{className:`h-4 w-4`}),e(`libreClaw.dashboard`)]})]})}),!t?.connected&&!P&&(0,K.jsx)(`section`,{className:`rounded-xl border border-amber-200 bg-amber-500/10 p-4 text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(w,{className:`mt-0.5 h-5 w-5 shrink-0 text-amber-500`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`font-semibold`,children:e(`libreClaw.connection.disconnectedTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm opacity-90`,children:(0,K.jsx)(be,{i18nKey:`libreClaw.connection.disconnectedDescription`,components:{command:(0,K.jsx)(`code`,{}),env:(0,K.jsx)(`code`,{})}})}),t?.error&&(0,K.jsx)(`p`,{className:`mt-2 text-xs opacity-80`,children:t.error})]})]})}),(0,K.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.startRun.title`),icon:(0,K.jsx)(x,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`textarea`,{value:L,onChange:e=>z(e.target.value),placeholder:e(`libreClaw.startRun.placeholder`),className:`min-h-32 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-100 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800 dark:focus:border-primary-500 dark:focus:ring-primary-900/30`}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,K.jsxs)(`select`,{value:B,onChange:e=>pe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`chat`,children:e(`libreClaw.startRun.chatRun`)}),(0,K.jsx)(`option`,{value:`goal`,children:e(`libreClaw.startRun.goalMode`)})]}),(0,K.jsx)(`input`,{value:V,onChange:e=>me(e.target.value),placeholder:e(`libreClaw.startRun.providerOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:he,onChange:e=>H(e.target.value),placeholder:e(`libreClaw.startRun.modelOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(k,{onClick:Be,loading:se,children:[(0,K.jsx)(h,{className:`h-4 w-4`}),e(`libreClaw.startRun.run`)]})]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.modelRoute.title`),icon:(0,K.jsx)(v,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-1`,children:[(0,K.jsx)(`input`,{value:U,onChange:e=>W(e.target.value),placeholder:e(`libreClaw.modelRoute.providerPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:G,onChange:e=>ge(e.target.value),placeholder:e(`libreClaw.modelRoute.modelPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>ve(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]}),(0,K.jsx)(k,{variant:`secondary`,onClick:Ue,loading:ce,children:e(`libreClaw.modelRoute.saveModel`)}),(0,K.jsxs)(`div`,{className:`border-t border-gray-100 pt-3 dark:border-dark-200`,children:[(0,K.jsx)(`label`,{className:`mb-1 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-500`,children:e(`libreClaw.modelRoute.theme`)}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] lg:grid-cols-1`,children:[(0,K.jsx)(`select`,{value:ye,onChange:e=>xe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:Ce.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsx)(k,{variant:`secondary`,onClick:We,loading:le,children:e(`libreClaw.modelRoute.saveTheme`)})]}),(0,K.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:Se,onChange:e=>we(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]})]}),u&&(0,K.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(u,null,2)})]})})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.runs.title`),icon:(0,K.jsx)(g,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[r.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.runs.empty`)}),r.map(t=>(0,K.jsxs)(`button`,{onClick:()=>N(t.run_id),className:f(`w-full rounded-xl border p-3 text-start transition`,M===t.run_id?`border-primary-300 bg-primary-50 dark:border-primary-700 dark:bg-primary-900/20`:`border-gray-200 bg-white hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-50 dark:hover:bg-dark-100`),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,K.jsx)(Ee,{state:t.state,t:e})]}),(0,K.jsxs)(`div`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-dark-500`,children:[t.provider,`:`,t.model]}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:Ne(t.updated_at)})]},t.run_id))]})}),(0,K.jsxs)(J,{title:Z?Z.title:e(`libreClaw.timeline.title`),icon:(0,K.jsx)(T,{className:`h-4 w-4`}),actions:Z&&[`queued`,`running`,`blocked`].includes(Z.state)?(0,K.jsxs)(k,{variant:`danger`,size:`sm`,onClick:()=>Ve(Z.run_id),children:[(0,K.jsx)(m,{className:`h-4 w-4`}),e(`common.cancel`)]}):null,children:[Q.length>0&&(0,K.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-xl border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-800 dark:bg-amber-900/20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,K.jsx)(te,{className:`h-4 w-4 text-amber-500`}),e(`libreClaw.approvals.needed`)]}),Q.map(t=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-white/70 p-3 dark:bg-dark-50/70`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(t.data.name||e(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto rounded bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(t.data.arguments||{},null,2)}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,K.jsxs)(k,{size:`sm`,onClick:()=>He(t,`allow_once`),children:[(0,K.jsx)(C,{className:`h-4 w-4`}),e(`libreClaw.approvals.allowOnce`)]}),(0,K.jsx)(k,{size:`sm`,variant:`secondary`,onClick:()=>He(t,`always_allow_tool`),children:e(`libreClaw.approvals.alwaysAllowTool`)}),(0,K.jsxs)(k,{size:`sm`,variant:`danger`,onClick:()=>He(t,`deny`),children:[(0,K.jsx)(E,{className:`h-4 w-4`}),e(`libreClaw.approvals.deny`)]})]})]},t.event_id))]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[a.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.timeline.empty`)}),Re.map(t=>(0,K.jsx)(Oe,{item:t,t:e},t.key))]})]})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,K.jsx)(J,{title:e(`libreClaw.automations.title`),icon:(0,K.jsx)(re,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsx)(`input`,{value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`libreClaw.automations.namePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:je,onChange:e=>Y(e.target.value),placeholder:e(`libreClaw.automations.schedulePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`select`,{value:Ie,onChange:e=>Le(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`report`,children:e(`libreClaw.automations.routes.report`)}),(0,K.jsx)(`option`,{value:`telegram`,children:e(`libreClaw.automations.routes.telegram`)})]}),(0,K.jsx)(k,{onClick:Ge,loading:de,children:e(`libreClaw.automations.create`)})]}),(0,K.jsx)(`textarea`,{value:X,onChange:e=>Fe(e.target.value),placeholder:e(`libreClaw.automations.promptPlaceholder`),className:`min-h-24 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[s.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.automations.empty`)}),s.map(t=>(0,K.jsx)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-3 dark:border-dark-300 dark:bg-dark-50`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.name}),(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[t.schedule,` ·`,` `,e(`libreClaw.automations.routes.${t.route}`,{defaultValue:t.route}),` `,`·`,` `,e(`libreClaw.automations.status.${t.status}`,{defaultValue:t.status})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,K.jsx)(De,{title:e(`libreClaw.automations.runNow`),onClick:()=>Ke(t.automation_id,`run`),children:(0,K.jsx)(x,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:t.status===`paused`?e(`libreClaw.automations.resume`):e(`libreClaw.automations.pause`),onClick:()=>Ke(t.automation_id,t.status===`paused`?`resume`:`pause`),children:t.status===`paused`?(0,K.jsx)(x,{className:`h-4 w-4`}):(0,K.jsx)(S,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:e(`common.delete`),danger:!0,onClick:()=>Ke(t.automation_id,`delete`),children:(0,K.jsx)(ee,{className:`h-4 w-4`})})]})]})},t.automation_id))]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.usageFallback.title`),icon:(0,K.jsx)(g,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.usage`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:j||e(`libreClaw.usageFallback.noUsage`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.fallbackRoute`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(p||{},null,2)})]})]})})]}),P&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-white/60 backdrop-blur-sm dark:bg-dark-50/60`,children:(0,K.jsx)(ne,{className:`h-7 w-7 animate-spin text-primary-600`})})]})},Te=({status:e,t})=>{let n=!!e?.connected;return(0,K.jsxs)(`span`,{className:f(`inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium`,n?`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`:`bg-amber-500/20 text-ink dark:bg-amber-900/30`),children:[(0,K.jsx)(`span`,{className:f(`h-2 w-2 rounded-full`,n?`bg-emerald-500`:`bg-amber-500`)}),t(n?`libreClaw.status.connected`:`libreClaw.status.disconnected`),e?.health?.active_runs!==void 0&&(0,K.jsxs)(`span`,{className:`opacity-70`,children:[`·`,` `,t(`libreClaw.status.activeRuns`,{count:e.health.active_runs})]})]})},Ee=({state:e,t})=>(0,K.jsx)(`span`,{className:f(`rounded-full px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,xe[e]||xe.queued),children:t(`libreClaw.states.${e}`,{defaultValue:e})}),J=({title:e,icon:t,actions:n,children:r})=>(0,K.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/60 dark:border-white/10 dark:bg-white/[0.03]`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-5 py-4 dark:border-white/[0.08]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:[(0,K.jsx)(`span`,{className:`text-primary-600 dark:text-primary-300`,children:t}),e]}),n]}),(0,K.jsx)(`div`,{className:`p-5`,children:r})]}),De=({title:e,danger:t,onClick:n,children:r})=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:n,className:f(`inline-flex h-8 w-8 items-center justify-center rounded-lg transition-colors`,t?`text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`:`text-gray-500 hover:bg-gray-100 dark:text-dark-500 dark:hover:bg-dark-200`),children:r}),Oe=({item:e,t})=>(0,K.jsxs)(`article`,{className:f(`rounded-xl border p-3 transition-colors`,e.eventType===`assistant_message`?`border-primary-200 bg-primary-50/60 dark:border-primary-900/60 dark:bg-primary-900/10`:(e.eventType,`border-gray-200/80 bg-white/50 dark:border-white/[0.08] dark:bg-white/[0.025]`)),children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:f(`text-xs font-semibold uppercase tracking-wide`,Se[e.eventType]||`text-gray-500 dark:text-dark-500`),children:e.label}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-400 dark:text-dark-500`,children:[Le(e),` · `,Ne(e.timestamp)]})]}),(0,K.jsx)(ke,{item:e,t})]}),ke=({item:e,t})=>{if(e.kind===`assistant_message`)return(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-gray-900 dark:text-dark-900`,children:Fe(e.events)||t(`libreClaw.timeline.streaming`)});let n=e.events[0];return n?n.type===`assistant_delta`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.text||``)}):n.type===`user_message`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.content||``)}):n.type===`tool_call`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`tool_result`?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:[String(n.data.name||t(`libreClaw.fallbacks.tool`)),` ·`,` `,n.data.is_error?t(`libreClaw.timeline.resultError`):t(`libreClaw.timeline.resultOk`)]}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:String(n.data.content||``)})]}):n.type===`permission_request`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.approvals.toolApprovalRequested`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`permission_response`?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.tool`),value:String(n.data.name||n.data.tool_call_id||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.resolution`),value:String(n.data.resolution||t(`libreClaw.fallbacks.resolved`))})]}):n.type===`usage`?(0,K.jsx)(Ae,{data:n.data,t}):n.type===`run_finished`?(0,K.jsx)(je,{data:n.data,t}):n.type===`error`?(0,K.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-300`,children:String(n.data.message||t(`libreClaw.fallbacks.unknownError`))}):(0,K.jsx)(X,{value:n.data}):null},Ae=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.provider`),value:String(e.provider||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.model`),value:String(e.model||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.input`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.input_tokens),formatted:Q(e.input_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.output`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.output_tokens),formatted:Q(e.output_tokens)})}),Z(e.cached_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cached`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.cached_tokens),formatted:Q(e.cached_tokens)})}),Z(e.reasoning_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.reasoning`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.reasoning_tokens),formatted:Q(e.reasoning_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cost`),value:Re(e.cost)})]}),je=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.state`),value:t(`libreClaw.states.${String(e.state||`done`)}`,{defaultValue:String(e.state||`done`)})}),e.stop_reason!==void 0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.stopReason`),value:String(e.stop_reason)})]}),Y=({label:e,value:t})=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200/80 bg-white/50 px-2.5 py-1 text-xs text-gray-700 dark:border-white/10 dark:bg-white/[0.035] dark:text-dark-700`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-gray-500 dark:text-dark-500`,children:e}),(0,K.jsx)(`span`,{children:t})]}),X=({value:e})=>(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(e,null,2)}),Me=({text:e})=>(0,K.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-300 bg-white/30 px-4 py-8 text-center text-sm text-gray-500 dark:border-white/15 dark:bg-white/[0.02] dark:text-dark-500`,children:e}),Ne=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},Pe=(e,t)=>{let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;if(i.type===`assistant_delta`){let i=[];for(;e[r]?.type===`assistant_delta`;){let t=e[r];t&&i.push(t),r+=1}let a=i[0],o=i[i.length-1]||a;a&&o&&n.push({key:`assistant-${a.event_id}-${o.event_id}`,kind:`assistant_message`,eventType:`assistant_message`,label:t(`libreClaw.timeline.assistantResponse`),firstEventId:a.event_id,lastEventId:o.event_id,timestamp:a.timestamp,events:i});continue}n.push({key:`${i.type}-${i.event_id}`,kind:`event`,eventType:i.type,label:Ie(i.type,t),firstEventId:i.event_id,lastEventId:i.event_id,timestamp:i.timestamp,events:[i]}),r+=1}return n},Fe=e=>e.map(e=>String(e.data.text||``)).join(``),Ie=(e,t)=>({user_message:t(`libreClaw.timeline.labels.userMessage`),tool_call:t(`libreClaw.timeline.labels.toolCall`),tool_result:t(`libreClaw.timeline.labels.toolResult`),permission_request:t(`libreClaw.timeline.labels.approvalRequest`),permission_response:t(`libreClaw.timeline.labels.approvalResponse`),run_started:t(`libreClaw.timeline.labels.runStarted`),run_finished:t(`libreClaw.timeline.labels.runFinished`),usage:t(`libreClaw.timeline.labels.usage`),error:t(`libreClaw.timeline.labels.error`)})[e]||e.replace(/_/g,` `),Le=e=>e.firstEventId===e.lastEventId?`#${e.firstEventId}`:`#${e.firstEventId}-#${e.lastEventId}`,Z=e=>{let t=Number(e);return Number.isFinite(t)?t:0},Q=e=>new Intl.NumberFormat().format(Z(e)),Re=e=>{let t=Z(e);return t<=0?`$0.00`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`};export{we as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{m as e,p as t}from"./markdown-core-BmPPZiuD.js";import{n}from"./react-vendor-C5yShNlM.js";import{t as r}from"./useTranslation-Bho4HCyg.js";import{t as i}from"./utils-D9W1Lnkn.js";import{Ht as a,Xt as o,n as s,v as c,z as l}from"./ui-vendor-54SgntkX.js";import{t as u}from"./Button-BPf_pOxH.js";e();var d=n(),f=t(),p=({models:e,showDetailsModal:t,setShowDetailsModal:n,selectedModelName:p,selectedModelDetails:m,loadingDetails:h,showCopyModal:g,setShowCopyModal:_,copySource:v,setCopySource:y,copyDestination:b,setCopyDestination:x,copying:S,handleCopyModel:C,showCreateModal:w,setShowCreateModal:T,createModelName:E,setCreateModelName:D,createModelfile:O,setCreateModelfile:k,creating:A,handleCreateModel:j,showEmbeddingsModal:M,setShowEmbeddingsModal:N,embeddingsModel:P,setEmbeddingsModel:F,embeddingsInput:I,setEmbeddingsInput:L,embeddingsResult:R,generatingEmbeddings:z,handleGenerateEmbeddings:B})=>{let{t:V}=r();return(0,f.jsxs)(f.Fragment,{children:[t&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>n(!1)}),(0,f.jsxs)(`div`,{className:i(`relative w-full max-w-2xl max-h-[85vh] overflow-hidden rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[V(`modelManager.modals.details.title`),`: `,p]}),(0,f.jsx)(`button`,{onClick:()=>n(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(s,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsx)(`div`,{className:`overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4`,children:h?(0,f.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,f.jsx)(l,{className:`h-6 w-6 animate-spin text-gray-400`})}):m?(0,f.jsxs)(f.Fragment,{children:[m.details&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.info`)}),(0,f.jsx)(`div`,{className:i(`p-3 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-50`),children:(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[m.details.family&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.family`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.family})]}),m.details.parameter_size&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.parameters`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.parameter_size})]}),m.details.quantization_level&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.quantization`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.quantization_level})]}),m.details.format&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.format`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.format})]})]})})]}),m.system&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.systemPrompt`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.system})]}),m.template&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.template`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto max-h-40`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.template})]}),m.parameters&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.parameters`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.parameters})]}),m.license&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.license`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto max-h-32`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.license})]}),m.modelfile&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.modelfile`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto max-h-60`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.modelfile})]})]}):(0,f.jsx)(`p`,{className:`text-center text-gray-500`,children:V(`modelManager.modals.details.noDetails`)})})]})]}),document.body),g&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>_(!1)}),(0,f.jsxs)(`div`,{className:i(`relative w-full max-w-md rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.copy.title`)}),(0,f.jsx)(`button`,{onClick:()=>_(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(s,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.source`)}),(0,f.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`),children:[(0,f.jsx)(`option`,{value:``,children:V(`modelManager.modals.copy.selectModel`)}),e.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.newName`)}),(0,f.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:V(`modelManager.modals.copy.placeholder`),className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]}),(0,f.jsxs)(u,{onClick:C,disabled:!v.trim()||!b.trim()||S,className:i(`w-full gap-2`,``),children:[S?(0,f.jsx)(l,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(o,{className:`h-4 w-4`}),V(S?`modelManager.modals.copy.copying`:`modelManager.modals.copy.button`)]})]})]})]}),document.body),w&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>T(!1)}),(0,f.jsxs)(`div`,{className:i(`relative w-full max-w-lg rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.create.title`)}),(0,f.jsx)(`button`,{onClick:()=>T(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(s,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.name`)}),(0,f.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:V(`modelManager.modals.create.namePlaceholder`),className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.modelfile`)}),(0,f.jsx)(`textarea`,{value:O,onChange:e=>k(e.target.value),placeholder:V(`modelManager.modals.create.modelfilePlaceholder`),rows:8,className:i(`w-full px-3 py-2 rounded-lg border text-sm font-mono`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`,`resize-none`)}),(0,f.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500`,children:[V(`modelManager.modals.create.see`),` `,(0,f.jsx)(`a`,{href:`https://github.com/ollama/ollama/blob/main/docs/modelfile.md`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 hover:underline`,children:V(`modelManager.modals.create.docs`)}),` `,V(`modelManager.modals.create.docsLink`)]})]}),(0,f.jsxs)(u,{onClick:j,disabled:!E.trim()||!O.trim()||A,className:i(`w-full gap-2`,``),children:[A?(0,f.jsx)(l,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(a,{className:`h-4 w-4`}),V(A?`modelManager.modals.create.creating`:`modelManager.modals.create.button`)]})]})]})]}),document.body),M&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>N(!1)}),(0,f.jsxs)(`div`,{className:i(`relative w-full max-w-lg rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.embeddings.title`)}),(0,f.jsx)(`button`,{onClick:()=>N(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(s,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.model`)}),(0,f.jsxs)(`select`,{value:P,onChange:e=>F(e.target.value),className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`),children:[(0,f.jsx)(`option`,{value:``,children:V(`modelManager.modals.embeddings.selectModel`)}),e.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,f.jsx)(`p`,{className:`mt-1 text-xs text-gray-500`,children:V(`modelManager.modals.embeddings.recommended`)})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.input`)}),(0,f.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:V(`modelManager.modals.embeddings.placeholder`),rows:3,className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`,`resize-none`)})]}),(0,f.jsxs)(u,{onClick:B,disabled:!P.trim()||!I.trim()||z,className:i(`w-full gap-2`,``),children:[z?(0,f.jsx)(l,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(c,{className:`h-4 w-4`}),V(z?`modelManager.modals.embeddings.generating`:`modelManager.modals.embeddings.button`)]}),R&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.result`,{count:R.length})}),(0,f.jsxs)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto max-h-32`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:[`[`,R.slice(0,10).join(`, `),R.length>10&&`, ...`,` ]`]})]})]})]})]}),document.body)]})};export{p as ModelManagerModals,p as default};
1
+ import"./rolldown-runtime-hePW80VL.js";import{m as e,p as t}from"./markdown-core-BmPPZiuD.js";import{n}from"./react-vendor-C5yShNlM.js";import{t as r}from"./useTranslation-Bho4HCyg.js";import{t as i}from"./utils-D9W1Lnkn.js";import{$t as a,Gt as o,V as s,n as c,y as l}from"./ui-vendor-B1UgO3vd.js";import{t as u}from"./Button-BPf_pOxH.js";e();var d=n(),f=t(),p=({models:e,showDetailsModal:t,setShowDetailsModal:n,selectedModelName:p,selectedModelDetails:m,loadingDetails:h,showCopyModal:g,setShowCopyModal:_,copySource:v,setCopySource:y,copyDestination:b,setCopyDestination:x,copying:S,handleCopyModel:C,showCreateModal:w,setShowCreateModal:T,createModelName:E,setCreateModelName:D,createModelfile:O,setCreateModelfile:k,creating:A,handleCreateModel:j,showEmbeddingsModal:M,setShowEmbeddingsModal:N,embeddingsModel:P,setEmbeddingsModel:F,embeddingsInput:I,setEmbeddingsInput:L,embeddingsResult:R,generatingEmbeddings:z,handleGenerateEmbeddings:B})=>{let{t:V}=r();return(0,f.jsxs)(f.Fragment,{children:[t&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>n(!1)}),(0,f.jsxs)(`div`,{className:i(`relative w-full max-w-2xl max-h-[85vh] overflow-hidden rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[V(`modelManager.modals.details.title`),`: `,p]}),(0,f.jsx)(`button`,{onClick:()=>n(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsx)(`div`,{className:`overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4`,children:h?(0,f.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,f.jsx)(s,{className:`h-6 w-6 animate-spin text-gray-400`})}):m?(0,f.jsxs)(f.Fragment,{children:[m.details&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.info`)}),(0,f.jsx)(`div`,{className:i(`p-3 rounded-lg text-sm`,`bg-gray-50 dark:bg-dark-50`),children:(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[m.details.family&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.family`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.family})]}),m.details.parameter_size&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.parameters`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.parameter_size})]}),m.details.quantization_level&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.quantization`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.quantization_level})]}),m.details.format&&(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`span`,{className:`text-gray-500`,children:[V(`modelManager.modals.details.format`),`:`]}),` `,(0,f.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100`,children:m.details.format})]})]})})]}),m.system&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.systemPrompt`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.system})]}),m.template&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.template`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto max-h-40`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.template})]}),m.parameters&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.parameters`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.parameters})]}),m.license&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.license`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto max-h-32`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.license})]}),m.modelfile&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:V(`modelManager.modals.details.modelfile`)}),(0,f.jsx)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto max-h-60`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:m.modelfile})]})]}):(0,f.jsx)(`p`,{className:`text-center text-gray-500`,children:V(`modelManager.modals.details.noDetails`)})})]})]}),document.body),g&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>_(!1)}),(0,f.jsxs)(`div`,{className:i(`relative w-full max-w-md rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.copy.title`)}),(0,f.jsx)(`button`,{onClick:()=>_(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.source`)}),(0,f.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`),children:[(0,f.jsx)(`option`,{value:``,children:V(`modelManager.modals.copy.selectModel`)}),e.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.copy.newName`)}),(0,f.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:V(`modelManager.modals.copy.placeholder`),className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]}),(0,f.jsxs)(u,{onClick:C,disabled:!v.trim()||!b.trim()||S,className:i(`w-full gap-2`,``),children:[S?(0,f.jsx)(s,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(a,{className:`h-4 w-4`}),V(S?`modelManager.modals.copy.copying`:`modelManager.modals.copy.button`)]})]})]})]}),document.body),w&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>T(!1)}),(0,f.jsxs)(`div`,{className:i(`relative w-full max-w-lg rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.create.title`)}),(0,f.jsx)(`button`,{onClick:()=>T(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.name`)}),(0,f.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:V(`modelManager.modals.create.namePlaceholder`),className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`)})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.create.modelfile`)}),(0,f.jsx)(`textarea`,{value:O,onChange:e=>k(e.target.value),placeholder:V(`modelManager.modals.create.modelfilePlaceholder`),rows:8,className:i(`w-full px-3 py-2 rounded-lg border text-sm font-mono`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`,`resize-none`)}),(0,f.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500`,children:[V(`modelManager.modals.create.see`),` `,(0,f.jsx)(`a`,{href:`https://github.com/ollama/ollama/blob/main/docs/modelfile.md`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 hover:underline`,children:V(`modelManager.modals.create.docs`)}),` `,V(`modelManager.modals.create.docsLink`)]})]}),(0,f.jsxs)(u,{onClick:j,disabled:!E.trim()||!O.trim()||A,className:i(`w-full gap-2`,``),children:[A?(0,f.jsx)(s,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(o,{className:`h-4 w-4`}),V(A?`modelManager.modals.create.creating`:`modelManager.modals.create.button`)]})]})]})]}),document.body),M&&(0,d.createPortal)((0,f.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-4`,children:[(0,f.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:()=>N(!1)}),(0,f.jsxs)(`div`,{className:i(`relative w-full max-w-lg rounded-xl border shadow-2xl`,`bg-white dark:bg-dark-100`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsxs)(`div`,{className:i(`flex items-center justify-between p-4 border-b`,`border-gray-200 dark:border-dark-300`),children:[(0,f.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:V(`modelManager.modals.embeddings.title`)}),(0,f.jsx)(`button`,{onClick:()=>N(!1),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,f.jsx)(c,{className:`h-5 w-5 text-gray-500`})})]}),(0,f.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.model`)}),(0,f.jsxs)(`select`,{value:P,onChange:e=>F(e.target.value),className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`),children:[(0,f.jsx)(`option`,{value:``,children:V(`modelManager.modals.embeddings.selectModel`)}),e.map(e=>(0,f.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,f.jsx)(`p`,{className:`mt-1 text-xs text-gray-500`,children:V(`modelManager.modals.embeddings.recommended`)})]}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.input`)}),(0,f.jsx)(`textarea`,{value:I,onChange:e=>L(e.target.value),placeholder:V(`modelManager.modals.embeddings.placeholder`),rows:3,className:i(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-gray-100`,`placeholder-gray-500`,`resize-none`)})]}),(0,f.jsxs)(u,{onClick:B,disabled:!P.trim()||!I.trim()||z,className:i(`w-full gap-2`,``),children:[z?(0,f.jsx)(s,{className:`h-4 w-4 animate-spin`}):(0,f.jsx)(l,{className:`h-4 w-4`}),V(z?`modelManager.modals.embeddings.generating`:`modelManager.modals.embeddings.button`)]}),R&&(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:V(`modelManager.modals.embeddings.result`,{count:R.length})}),(0,f.jsxs)(`pre`,{className:i(`p-3 rounded-lg text-xs overflow-x-auto max-h-32`,`bg-gray-50 dark:bg-dark-50`,`text-gray-700 dark:text-gray-300`),children:[`[`,R.slice(0,10).join(`, `),R.length>10&&`, ...`,` ]`]})]})]})]})]}),document.body)]})};export{p as ModelManagerModals,p as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{n as r}from"./react-vendor-C5yShNlM.js";import{d as i}from"./router-vendor-DGFGM3EP.js";import{t as a}from"./useTranslation-Bho4HCyg.js";import{t as o}from"./utils-D9W1Lnkn.js";import{p as s,s as c,t as l}from"./chatStore-CHQ2uINS.js";import{Cn as u,D as d,Dn as f,Et as p,F as m,Jt as h,Qt as g,Rn as _,U as v,V as y,Xt as b,_n as x,b as ee,c as te,gn as ne,n as S,pt as C,rn as w,t as T,wt as re,xt as ie}from"./ui-vendor-B1UgO3vd.js";import{t as ae}from"./logger-DSXjF4ye.js";import{h as E,y as oe}from"./api-BDtqBtqw.js";import{n as se}from"./authStore-DbMdvNgJ.js";import{x as ce}from"../assets/index-6o-Hc2wS.js";var D=e(t(),1),le=r(),O=n();function k(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ue({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:s,hfGgufFiles:c,loadingGguf:l,pullingModel:u,pullProgress:d,setHfTask:f,setHfSort:p,onToggleHfModel:m,onPullHfGguf:g,onCancelPull:_,onRefreshHfModels:v}){let{t:x}=a();return(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`select`,{value:e,onChange:e=>f(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(`option`,{value:`text-generation`,children:x(`modelManager.huggingface.taskTextGeneration`)}),(0,O.jsx)(`option`,{value:`text-to-speech`,children:x(`modelManager.huggingface.taskTextToSpeech`)}),(0,O.jsx)(`option`,{value:`text-to-image`,children:x(`modelManager.huggingface.taskTextToImage`)}),(0,O.jsx)(`option`,{value:`automatic-speech-recognition`,children:x(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,O.jsxs)(`select`,{value:t,onChange:e=>p(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,O.jsx)(`option`,{value:`downloads`,children:x(`modelManager.huggingface.sortDownloads`)}),(0,O.jsx)(`option`,{value:`likes`,children:x(`modelManager.huggingface.sortLikes`)}),(0,O.jsx)(`option`,{value:`lastModified`,children:x(`modelManager.huggingface.sortRecent`)})]})]})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:x(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(C,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(T,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:x(`modelManager.huggingface.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=s===e.id,r=c[e.id]||[],i=l===e.id;return(0,O.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,O.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),m(e.id)},children:(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,O.jsx)(T,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,O.jsx)(`span`,{className:`rounded bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(b,{className:`h-3 w-3`}),k(e.downloads)]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(re,{className:`h-3 w-3`}),k(e.likes)]}),e.pipeline_tag&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,O.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(h,{className:`h-4 w-4 text-gray-400`})}),(0,O.jsx)(ne,{className:o(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,O.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,O.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,O.jsx)(C,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,O.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:x(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,O.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:x(`modelManager.huggingface.noGgufAvailable`)}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:x(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=u===e.ollamaCommand;return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:d?.percent===void 0?`...`:`${d.percent}%`}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(S,{className:`h-4 w-4`})})]}):n?(0,O.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e.ollamaCommand,e.filename)},disabled:!!u,className:o(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,O.jsx)(b,{className:`h-3 w-3 inline mr-1`}),x(`models.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:x(`modelSelector.adminOnlyPull`)})]},e.filename)}),u?.startsWith(`hf.co/`)&&u.includes(e.id)&&d?.percent!==void 0&&(0,O.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${d.percent}%`}})})]})})]},e.id)})})]}),(0,O.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,O.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,O.jsx)(h,{className:`h-3 w-3`}),x(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),v()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(y,{className:o(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function de({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:s,getModelSubLabel:c,onModelSelect:l,onOpenGallery:u}){let{t:d}=a();return(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>{let n=r(e);return(0,O.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:o(`block w-full cursor-pointer border-b border-gray-100 px-3 py-3 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===n&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:s(e)}),c(e)&&(0,O.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:c(e)})]}),t===n&&(0,O.jsx)(x,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(g,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:d(`models.noModelsFound`)})]}),n&&(0,O.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(v,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),d(`modelSelector.actions`)]})}),(0,O.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),u()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(ie,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`gallery.generate`)}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d(`gallery.generateDescription`)})]})]})})]})]})}function fe({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:s,pullProgress:c,setLibraryCategory:l,isModelInstalled:u,onModelSelect:d,onPullModel:f,onCancelPull:p,onRefreshLibrary:m}){let{t:g}=a();return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,O.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:o(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:g(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(C,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(w,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:g(`models.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=u(e.name),r=s===e.name;return(0,O.jsxs)(`div`,{className:o(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,O.jsx)(w,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:g(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,O.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,O.jsx)(w,{className:`h-3 w-3`}),`Cloud`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,O.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,O.jsx)(b,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,O.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:c?.percent===void 0?`...`:`${c.percent}%`}),(0,O.jsx)(`button`,{onClick:p,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(S,{className:`h-4 w-4`})})]}):t?(0,O.jsx)(`button`,{onClick:()=>d(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:g(`modelSelector.use`)}):n?(0,O.jsxs)(`button`,{onClick:()=>f(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,O.jsx)(b,{className:`h-3 w-3 inline mr-1`}),g(`modelSelector.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:g(`modelSelector.adminOnlyPull`)})})]}),r&&c?.percent!==void 0&&(0,O.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${c.percent}%`}})})]},e.name)})})]}),(0,O.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,O.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,O.jsx)(h,{className:`h-3 w-3`}),g(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(y,{className:o(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var pe=ae(`components:model-selector`),A=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:h,disabled:g=!1,compact:v=!1,showImageGen:y=!1,onModelsRefresh:b,getModelValue:x,getModelLabel:C,getModelTitle:re,triggerRef:ie,triggerTestId:ae,selectTestId:k,ariaLabel:A})=>{let{t:j}=a(),[M,me]=(0,D.useState)(!1),[N,he]=(0,D.useState)(``),[P,F]=(0,D.useState)(`installed`),ge=(0,D.useRef)(null),I=(0,D.useRef)(null),L=(0,D.useRef)(null),R=(0,D.useRef)(null),_e=i(),{user:ve,systemInfo:ye}=se(),z=ve?.role===`admin`||ye?.requiresAuth===!1,[B,be]=(0,D.useState)(`all`),[xe,Se]=(0,D.useState)(``),[V,Ce]=(0,D.useState)(`text-generation`),[H,we]=(0,D.useState)(`downloads`),[Te,Ee]=(0,D.useState)(``),[U,De]=(0,D.useState)(null),[W,Oe]=(0,D.useState)({}),[ke,Ae]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[je,q]=(0,D.useState)(null),[Me,J]=(0,D.useState)(null),Ne=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Pe=[{type:`legacy`,label:j(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,O.jsx)(u,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:j(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,O.jsx)(S,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isUnavailable&&!e.isLegacySelection),color:`gray`},{type:`personas`,label:j(`modelSelector.personas`),icon:(0,O.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPersona&&!e.isUnavailable),color:`purple`},{type:`agents`,label:j(`modelSelector.agentModels`,`Agents`),icon:(0,O.jsx)(ee,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isAgent&&!e.isUnavailable),color:`green`},{type:`ollama`,label:j(`modelSelector.ollamaModels`),icon:(0,O.jsx)(f,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>s(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:j(`modelSelector.pluginModels`),icon:(0,O.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPlugin&&!e.isUnavailable),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(N.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(N.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(N.toLowerCase()))})).filter(e=>e.models.length>0),Y=e=>x?.(e)??e.name,Fe=l(e=>e.modelMetadata),X=e.find(e=>Y(e)===t);(0,D.useImperativeHandle)(ie,()=>L.current);let Z=(0,D.useCallback)((e=!0)=>{me(!1),he(``),e&&window.requestAnimationFrame(()=>L.current?.focus())},[]),{data:Ie=[],isLoading:Le,refetch:Re}=ce({queryKey:[`ollama-library-selector`,xe,B===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await E.getLibraryModels({search:xe||void 0,sort:`popular`,category:B===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:M&&P===`ollama`}),{data:ze=[],isLoading:Be,refetch:Ve}=ce({queryKey:[`hf-models-selector`,V,Te,H],queryFn:async()=>{let e=await oe.getModels({task:V,search:Te||void 0,sort:H,limit:30});return e.success&&e.data?e.data:[]},enabled:M&&P===`huggingface`}),He=Ie.filter(e=>{let t=!N||e.name.toLowerCase().includes(N.toLowerCase())||e.description.toLowerCase().includes(N.toLowerCase()),n=B===`all`||e.category===B;return t&&n}),Ue=(0,D.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Ae(e);try{let r=await oe.getGgufFiles(t,n);r.success&&r.data&&Oe(t=>({...t,[e]:r.data}))}catch(e){pe.error(`Failed to load GGUF files:`,e)}finally{Ae(null)}}},[]),We=(0,D.useCallback)(e=>{U===e?De(null):(De(e),W[e]||Ue(e))},[U,W,Ue]),Ge=(0,D.useCallback)((e,t)=>{if(!z){_.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let n=E.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),_.success(`Downloaded ${t}`),b?.()},e=>{q(null),K(null),J(null),_.error(`Failed to download: ${e}`)});J(()=>n)}catch{q(null),K(null),_.error(`Failed to start download`)}}},[z,b,G,j]);(0,D.useEffect)(()=>{let e=setTimeout(()=>{P===`huggingface`?Ee(N):P===`ollama`&&Se(N)},300);return()=>clearTimeout(e)},[N,P]),(0,D.useEffect)(()=>{if(!M)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Z();return}if(e.key===`Tab`&&I.current){let t=Array.from(I.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Z,M]),(0,D.useEffect)(()=>{M&&R.current&&R.current.focus()},[M]);let Ke=async t=>{let r=e.find(e=>Y(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?Y(r):t,a=r?.name??t;Z();try{let e=await E.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await E.unloadAllModels())}}catch(e){pe.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},qe=async e=>{if(!z){_.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let t=E.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),_.success(`Downloaded ${e}`),b?.()},e=>{q(null),K(null),J(null),_.error(`Failed to download: ${e}`)});J(()=>t)}catch{q(null),K(null),_.error(`Failed to start download`)}}},Je=()=>{Me&&(Me(),J(null),K(null),q(null),_.success(`Download cancelled`))},Ye=t=>e.some(e=>s(e)&&(e.name===t||e.name.startsWith(t+`:`))),Q=e=>{let t=Fe[c(e)]?.avatar;return t&&!e.isPersona?(0,O.jsx)(`img`,{src:t,alt:``,className:`h-4 w-4 shrink-0 rounded-full object-cover`}):e.isLegacySelection?(0,O.jsx)(u,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,O.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,O.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,O.jsx)(f,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`})},$=e=>{if(C)return C(e);let t=Fe[c(e)]?.label;return t&&!e.isPersona?t:e.isLegacySelection?`${e.name} (${j(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.name)},Xe=e=>e.isLegacySelection?e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):j(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${j(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,O.jsxs)(`div`,{className:o(`relative`,h),ref:ge,children:[(0,O.jsxs)(`button`,{ref:L,"data-testid":ae,type:`button`,onClick:()=>!g&&me(!M),disabled:g,"aria-haspopup":`dialog`,"aria-expanded":M,"aria-label":A&&X?`${A}: ${$(X)}`:A,className:o(v?`h-9 sm:h-10 px-2.5 flex items-center justify-between text-start w-full`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`border border-black/[0.06] bg-gray-100/70 dark:border-white/[0.06] dark:bg-dark-300/70`,`rounded-xl text-sm hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,g?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:v?X?re?.(X)??$(X):j(`modelSelector.selectModel`):void 0,children:[(()=>{if(!X)return v?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,O.jsx)(f,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-400 dark:text-gray-500 truncate`,children:j(`modelSelector.selectModel`)})]}):j(`modelSelector.selectModel`);if(v){let e=$(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-xs font-medium text-gray-700 dark:text-gray-200 truncate`,children:e})]})}let e=$(X),t=Xe(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,O.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),X.isPersona&&r&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,O.jsx)(u,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,O.jsx)(d,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,O.jsx)(ne,{className:o(v?`h-3 w-3`:`h-4 w-4`,`text-gray-400 flex-shrink-0 transition-transform duration-150`,M&&`rotate-180`)})]}),M&&(0,le.createPortal)((0,O.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,O.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Z()}),(0,O.jsxs)(`div`,{ref:I,role:`dialog`,"aria-modal":`true`,"aria-label":j(`modelSelector.selectModel`),className:o(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/[0.98] dark:bg-dark-25/[0.98]`,`h-[min(620px,88vh)] rounded-[1.5rem] border border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,O.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:j(`modelSelector.selectModel`)}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>Z(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:j(`common.close`),children:(0,O.jsx)(S,{className:`h-4 w-4`})})]}),(0,O.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(m,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{ref:R,type:`text`,placeholder:j(P===`installed`?`modelSelector.searchInstalled`:P===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:N,onChange:e=>he(e.target.value),className:o(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),(0,O.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,O.jsxs)(`button`,{onClick:()=>{F(`installed`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`installed`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`installed`,children:[(0,O.jsx)(p,{className:`h-4 w-4 inline me-1.5`}),j(`modelSelector.installed`)]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`ollama`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`ollama`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`ollama`,children:[(0,O.jsx)(w,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`huggingface`)},className:o(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`huggingface`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":P===`huggingface`,children:[(0,O.jsx)(T,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),P===`installed`&&(0,O.jsx)(de,{filteredGroups:Pe,selectedModel:t,showImageGen:y,getModelValue:Y,getModelIcon:Q,getModelLabel:$,getModelSubLabel:Xe,onModelSelect:Ke,onOpenGallery:()=>{Z(!1),_e(`/gallery`)}}),P===`ollama`&&(0,O.jsx)(fe,{libraryCategories:Ne,libraryCategory:B,canInstallModels:z,loadingLibrary:Le,filteredLibraryModels:He,pullingModel:G,pullProgress:je,setLibraryCategory:be,isModelInstalled:Ye,onModelSelect:Ke,onPullModel:qe,onCancelPull:Je,onRefreshLibrary:()=>{Re()}}),P===`huggingface`&&(0,O.jsx)(ue,{hfTask:V,hfSort:H,canInstallModels:z,loadingHf:Be,hfModels:ze,expandedHfModel:U,hfGgufFiles:W,loadingGguf:ke,pullingModel:G,pullProgress:je,setHfTask:Ce,setHfSort:we,onToggleHfModel:We,onPullHfGguf:Ge,onCancelPull:Je,onRefreshHfModels:()=>{Ve()}})]})]}),document.body),(0,O.jsx)(`select`,{"data-testid":k,"aria-label":A,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,O.jsx)(`option`,{value:Y(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${Y(e)}`))})]})};export{A as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/ModelManagerModals-DcLGYN3l.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-BmPPZiuD.js","js/react-vendor-C5yShNlM.js","js/useTranslation-Bho4HCyg.js","js/utils-D9W1Lnkn.js","js/utils-vendor-DWh39_3x.js","js/ui-vendor-B1UgO3vd.js","js/Button-BPf_pOxH.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{i as r}from"./router-vendor-DGFGM3EP.js";import{t as i}from"./useTranslation-Bho4HCyg.js";import{t as a}from"./utils-D9W1Lnkn.js";import{$t as o,Et as s,F as c,Fn as l,Ft as u,Gt as d,Jt as f,M as p,N as m,Pt as h,Qt as g,Rn as _,Tt as v,V as y,Xt as b,_n as x,bt as S,g as C,gn as w,gt as ee,in as T,lt as te,n as ne,pn as E,pt as D,rn as O,t as re,wt as k,y as ie}from"./ui-vendor-B1UgO3vd.js";import{t as ae}from"./logger-DSXjF4ye.js";import{h as A,y as oe}from"./api-BDtqBtqw.js";import{n as se}from"./authStore-DbMdvNgJ.js";import{t as j}from"./Button-BPf_pOxH.js";import{n as ce,t as le}from"./ui-CC-K19wO.js";import{C as ue,x as M}from"../assets/index-6o-Hc2wS.js";var N=e(t(),1),P=n();function de({expanded:e,models:t,search:n,task:r,sort:o,loadingModels:s,canInstallModels:l,expandedModelId:u,loadingGgufModelId:d,ggufFiles:p,pullingModel:m,pullProgress:h,setSearch:g,setTask:_,setSort:v,onToggle:b,onToggleModel:x,onPullGguf:S,onCancelPull:C,onRefresh:ee}){let{t:T}=i();return(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:b,"aria-expanded":e,className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(re,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:T(`modelManager.sections.huggingface`,`HuggingFace Hub`)}),t.length>0&&(0,P.jsxs)(`span`,{className:a(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,T(`modelManager.library.available`,`available`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(c,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:n,onChange:e=>g(e.target.value),placeholder:T(`modelManager.huggingface.search`,`Search HuggingFace models...`),className:a(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,P.jsxs)(`select`,{value:r,onChange:e=>_(e.target.value),className:a(`px-3 py-2 rounded-lg border text-sm min-w-[160px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,P.jsx)(`option`,{value:`text-generation`,children:T(`modelManager.huggingface.tasks.textGen`,`Text Generation`)}),(0,P.jsx)(`option`,{value:`text-to-speech`,children:T(`modelManager.huggingface.tasks.tts`,`Text to Speech`)}),(0,P.jsx)(`option`,{value:`text-to-image`,children:T(`modelManager.huggingface.tasks.image`,`Text to Image`)}),(0,P.jsx)(`option`,{value:`automatic-speech-recognition`,children:T(`modelManager.huggingface.tasks.stt`,`Speech Recognition`)})]}),(0,P.jsxs)(`select`,{value:o,onChange:e=>v(e.target.value),className:a(`px-3 py-2 rounded-lg border text-sm min-w-[140px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,P.jsx)(`option`,{value:`downloads`,children:T(`modelManager.huggingface.sort.downloads`,`Most Downloads`)}),(0,P.jsx)(`option`,{value:`likes`,children:T(`modelManager.huggingface.sort.likes`,`Most Liked`)}),(0,P.jsx)(`option`,{value:`lastModified`,children:T(`modelManager.huggingface.sort.recent`,`Recently Updated`)})]})]}),!l&&(0,P.jsx)(`p`,{className:`text-xs text-ink`,children:T(`modelManager.pull.restricted`)}),s?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(D,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,P.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:T(`modelManager.huggingface.noResults`,`No models found. Try adjusting your search or filters.`)}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:t.map(e=>(0,P.jsx)(fe,{model:e,expanded:u===e.id,loadingGguf:d===e.id,ggufFiles:p[e.id]||[],pullingModel:m,pullProgress:h,canInstallModels:l,onToggle:()=>x(e.id),onPullGguf:S,onCancelPull:C},e.id))}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,P.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,className:a(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,P.jsx)(f,{className:`h-3 w-3`}),T(`modelManager.huggingface.browseAll`,`Browse all on HuggingFace`)]}),(0,P.jsxs)(j,{onClick:ee,variant:`outline`,size:`sm`,disabled:s,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(y,{className:a(`h-3.5 w-3.5`,s&&`animate-spin`)}),T(`modelManager.library.refresh`,`Refresh`)]})]})]})]})}function fe({model:e,expanded:t,loadingGguf:n,ggufFiles:r,pullingModel:o,pullProgress:s,canInstallModels:c,onToggle:l,onPullGguf:u,onCancelPull:d}){let{t:p}=i();return(0,P.jsxs)(`div`,{className:a(`rounded-lg border transition-all overflow-hidden`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,P.jsxs)(`div`,{className:`p-4 cursor-pointer`,onClick:l,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800 truncate`,children:e.id}),e.gated&&(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded text-xs`,`bg-yellow-500/20 dark:bg-yellow-900/30`,`text-ink`),children:p(`modelManager.huggingface.gated`,`Gated`)})]}),(0,P.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-0.5`,children:[p(`modelManager.huggingface.by`,`by`),` `,e.author]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,P.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 transition-colors`,title:p(`modelManager.huggingface.viewOnHF`,`View on HuggingFace`),children:(0,P.jsx)(f,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`})}),(0,P.jsx)(w,{className:a(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(b,{className:`h-3.5 w-3.5`}),he(e.downloads)]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(k,{className:`h-3.5 w-3.5`}),he(e.likes)]}),e.pipeline_tag&&(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded`,`bg-gray-200 dark:bg-dark-300`),children:e.pipeline_tag})]})]}),t&&(0,P.jsx)(pe,{modelId:e.id,loading:n,files:r,pullingModel:o,pullProgress:s,canInstallModels:c,onPullGguf:u,onCancelPull:d})]})}function pe({modelId:e,loading:t,files:n,pullingModel:r,pullProgress:a,canInstallModels:o,onPullGguf:s,onCancelPull:c}){let{t:l}=i();return(0,P.jsx)(`div`,{className:`px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100`,children:t?(0,P.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,P.jsx)(D,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,P.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:l(`modelManager.huggingface.checkingGguf`)})]}):n.length===0?(0,P.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:l(`modelManager.huggingface.noGgufAvailable`)}):(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:l(`modelManager.huggingface.ggufFilesCount`,{count:n.length})}),n.map(e=>(0,P.jsx)(me,{file:e,pulling:r===e.ollamaCommand,pullProgress:a,canInstallModels:o,disabled:!!r||!o,onPullGguf:s,onCancelPull:c},e.filename)),r?.startsWith(`hf.co/`)&&r.includes(e)&&a?.percent!==void 0&&(0,P.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,P.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${a.percent}%`}})})]})})}function me({file:e,pulling:t,disabled:n,pullProgress:r,onPullGguf:o,onCancelPull:s}){let{t:c}=i();return(0,P.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,P.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,P.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:r?.percent===void 0?`...`:`${r.percent}%`}),(0,P.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,P.jsx)(ne,{className:`h-4 w-4`})})]}):(0,P.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),o(e.ollamaCommand,e.filename)},disabled:n,className:a(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,P.jsx)(b,{className:`h-3 w-3 inline mr-1`}),c(`models.pull`)]})]})}function he(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e}function ge({expanded:e,models:t,onToggle:n,isModelRunning:r,formatSize:o,onShowModel:c,onCopyModel:l,onDeleteModel:u}){let{t:d}=i();return(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:n,"aria-expanded":e,className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(s,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:d(`modelManager.sections.local`)}),(0,P.jsxs)(`span`,{className:a(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,d(`modelManager.local.installed`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsx)(`div`,{className:`p-4 pt-0`,children:t.length===0?(0,P.jsxs)(`div`,{className:a(`text-center py-12 rounded-lg border-2 border-dashed`,`border-gray-200 dark:border-dark-300`),children:[(0,P.jsx)(s,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,P.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-2`,children:d(`modelManager.local.noModels`)}),(0,P.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:d(`modelManager.local.pullToStart`)})]}):(0,P.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,P.jsx)(_e,{model:e,running:r(e.name),formatSize:o,onShowModel:c,onCopyModel:l,onDeleteModel:u},e.name))})})]})}function _e({model:e,running:t,formatSize:n,onShowModel:r,onCopyModel:c,onDeleteModel:l}){let{t:u}=i();return(0,P.jsx)(`div`,{className:a(`p-4 rounded-lg border transition-colors`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:bg-gray-100 dark:hover:bg-dark-200`),children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,P.jsxs)(`span`,{className:a(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse`}),u(`modelManager.local.running`)]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 mt-2`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(s,{className:`h-3.5 w-3.5`}),n(e.size)]}),e.details?.parameter_size&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(g,{className:`h-3.5 w-3.5`}),e.details.parameter_size]}),e.details?.quantization_level&&(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e.details.quantization_level}),e.details?.family&&(0,P.jsx)(`span`,{className:`text-gray-500 dark:text-gray-500`,children:e.details.family})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 mt-2`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(T,{className:`h-3 w-3`}),new Date(e.modified_at).toLocaleDateString()]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1 font-mono truncate max-w-[200px]`,title:e.digest,children:[(0,P.jsx)(v,{className:`h-3 w-3`}),e.digest.slice(0,12),`...`]})]})]}),(0,P.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,P.jsxs)(j,{onClick:()=>r(e.name),variant:`outline`,size:`sm`,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(S,{className:`h-3.5 w-3.5`}),u(`modelManager.local.info`)]}),(0,P.jsxs)(j,{onClick:()=>c(e.name),variant:`outline`,size:`sm`,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(o,{className:`h-3.5 w-3.5`}),u(`modelManager.local.copy`)]}),(0,P.jsxs)(j,{onClick:()=>l(e.name),variant:`outline`,size:`sm`,className:a(`gap-1.5`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,P.jsx)(C,{className:`h-3.5 w-3.5`}),u(`modelManager.local.delete`)]})]})]})})}function ve({expanded:e,models:t,totalAvailable:n,categories:r,filter:o,search:s,loading:l,pulling:d,canInstallModels:f,pullSectionExpanded:p,setFilter:m,setSearch:h,isModelInstalled:g,normalizeCloudPullName:_,onToggle:v,onTogglePullSection:b,onPullModel:x,onRefresh:S}){let{t:C}=i();return(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:v,"aria-expanded":e,className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:C(`modelManager.sections.library`)}),(0,P.jsxs)(`span`,{className:a(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[n,` `,C(`modelManager.library.available`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(c,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:s,onChange:e=>h(e.target.value),placeholder:C(`modelManager.library.search`),className:a(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(u,{className:`h-4 w-4 text-gray-400`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,P.jsx)(`button`,{onClick:()=>m(e),className:a(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,o===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),l?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(y,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,P.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:C(`modelManager.library.noResults`)}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.category===`cloud`?_(e.name):e.name,n=g(e.name)||g(t);return(0,P.jsx)(ye,{model:e,installed:n,pulling:d,canInstallModels:f,pullSectionExpanded:p,onTogglePullSection:b,onPullModel:x},e.name)})}),(0,P.jsx)(`div`,{className:`flex justify-center`,children:(0,P.jsxs)(j,{onClick:S,variant:`outline`,size:`sm`,disabled:l,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(y,{className:a(`h-3.5 w-3.5`,l&&`animate-spin`)}),C(`modelManager.library.refresh`)]})})]})]})}function ye({model:e,installed:t,pulling:n,canInstallModels:r,pullSectionExpanded:o,onTogglePullSection:s,onPullModel:c}){let{t:l}=i();return(0,P.jsxs)(`div`,{"data-testid":`library-model-card-${e.name}`,className:a(`p-4 rounded-lg border transition-all`,`bg-gray-50 dark:bg-dark-50`,t?`border-green-200 dark:border-green-800/50`:`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,P.jsxs)(`span`,{className:a(`flex items-center gap-1 px-1.5 py-0.5 rounded text-xs`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,P.jsx)(x,{className:`h-3 w-3`}),l(`modelManager.library.installed`)]})]}),(0,P.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-dark-600 mb-3 line-clamp-2`,children:e.description}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.sizes.slice(0,4).map(e=>(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e},e)),e.sizes.length>4&&(0,P.jsx)(`span`,{className:`text-xs text-gray-400`,children:l(`modelManager.library.more`,{count:e.sizes.length-4})})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[e.pulls&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(b,{className:`h-3 w-3`}),e.pulls]}),(0,P.jsx)(`span`,{className:a(`px-1.5 py-0.5 rounded capitalize`,e.category===`cloud`?`bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400`:`bg-gray-100 dark:bg-dark-200`),children:e.category})]}),(0,P.jsxs)(j,{"data-testid":`library-model-install-${e.name}`,onClick:()=>{o||s(),c(e.name,e.category)},variant:`outline`,size:`sm`,disabled:n||!r,className:a(`gap-1 text-xs`,``,``),children:[(0,P.jsx)(b,{className:`h-3 w-3`}),l(`modelManager.pull.button`)]})]})]})}function be({expanded:e,modelName:t,setModelName:n,pulling:r,progress:o,canInstallModels:s,popularModels:l,onToggle:u,onPull:d,onCancelPull:p,formatSize:m}){let{t:h}=i();return(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:u,"aria-expanded":e,className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(b,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:h(`modelManager.sections.pull`)})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(c,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:h(`modelManager.pull.placeholder`),className:a(`w-full rounded-xl border py-2.5 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`),disabled:r||!s,onKeyDown:e=>{e.key===`Enter`&&!r&&s&&d()}})]}),r?(0,P.jsxs)(j,{onClick:p,variant:`outline`,className:a(`px-4 py-2.5 gap-2`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,P.jsx)(ne,{className:`h-4 w-4`}),h(`modelManager.pull.cancel`)]}):(0,P.jsxs)(j,{onClick:d,disabled:!t.trim()||!s,className:a(`px-4 py-2.5 gap-2`,``),children:[(0,P.jsx)(b,{className:`h-4 w-4`}),h(`modelManager.pull.button`)]})]}),r&&o&&(0,P.jsx)(F,{progress:o,formatSize:m}),!s&&(0,P.jsx)(`p`,{className:`text-xs text-ink-muted`,children:h(`modelManager.pull.restricted`)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 mb-2`,children:h(`modelManager.pull.popular`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l.map(e=>(0,P.jsxs)(`button`,{onClick:()=>n(e.name),disabled:r||!s,className:a(`px-3 py-1.5 rounded-full text-xs font-medium transition-colors`,`bg-gray-100 dark:bg-dark-200`,`text-gray-700 dark:text-gray-300`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`border border-gray-200 dark:border-dark-300`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[e.name,(0,P.jsx)(`span`,{className:`ml-1 text-gray-400 dark:text-gray-500`,children:e.size})]},e.name))})]}),(0,P.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,className:a(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,P.jsx)(f,{className:`h-3 w-3`}),h(`modelManager.pull.browseAll`)]})]})]})}function F({progress:e,formatSize:t}){let{t:n}=i(),r=e.status===`starting`?n(`modelManager.progress.starting`):e.status.startsWith(`pulling`)?`${n(`modelManager.progress.pullingLayer`)} ${e.status.replace(`pulling `,``)}`:e.status.startsWith(`verifying sha256`)?n(`modelManager.progress.verifyingDigest`):e.status===`writing manifest`?n(`modelManager.progress.writing`):e.status===`removing any unused layers`?n(`modelManager.progress.cleaning`):e.status;return(0,P.jsxs)(`div`,{className:a(`p-4 rounded-lg border`,`bg-gray-50 dark:bg-dark-200`,`border-gray-200 dark:border-dark-300`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-800 dark:text-dark-700`,children:r}),e.percent!==void 0&&(0,P.jsxs)(`span`,{className:`text-sm font-mono text-gray-600 dark:text-dark-600`,children:[e.percent,`%`]})]}),e.percent!==void 0&&(0,P.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-400 rounded-full h-2 overflow-hidden`,children:(0,P.jsx)(`div`,{className:a(`h-2 rounded-full transition-all duration-300`,`bg-primary-500 dark:bg-primary-400`),style:{width:`${e.percent}%`}})}),e.total&&e.completed&&(0,P.jsxs)(`div`,{className:`mt-2 text-xs text-gray-600 dark:text-dark-600`,children:[t(e.completed),` / `,t(e.total)]})]})}var xe=ae(`components:model-manager`),Se=N.lazy(()=>r(()=>import(`./ModelManagerModals-DcLGYN3l.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),I=e=>{let t=e.split(`:`).pop()?.toLowerCase();return t===`cloud`||t?.endsWith(`-cloud`)===!0},Ce=e=>{let t=e.trim();if(!t||I(t))return t;let n=t.lastIndexOf(`:`);return n===-1?`${t}:cloud`:`${t.slice(0,n)}:${t.slice(n+1)}-cloud`},L=()=>{let{t:e}=i(),{user:t,systemInfo:n}=se(),{data:r}=M({queryKey:[`model-download-access`],queryFn:async()=>{let e=await A.getModelAccess();return e.success&&e.data?e.data:null},staleTime:6e4}),c=t?.role===`admin`||n?.requiresAuth===!1||r?.allowed===!0,u=ue(),[f,g]=(0,N.useState)(`all`),[v,b]=(0,N.useState)(``),[x,S]=(0,N.useState)(``),[C,T]=(0,N.useState)(!1),[ne,D]=(0,N.useState)(null),[O,k]=(0,N.useState)(null),[ae,ce]=(0,N.useState)(null),[le,fe]=(0,N.useState)(``),[pe,me]=(0,N.useState)(!1),[he,_e]=(0,N.useState)(!1),[ye,F]=(0,N.useState)(!1),[I,L]=(0,N.useState)(``),[R,we]=(0,N.useState)(``),[Te,Ee]=(0,N.useState)(!1),[De,Oe]=(0,N.useState)(!1),[z,ke]=(0,N.useState)(``),[Ae,je]=(0,N.useState)(``),[Me,Ne]=(0,N.useState)(!1),[Pe,Fe]=(0,N.useState)(!1),[Ie,Le]=(0,N.useState)(``),[Re,ze]=(0,N.useState)(``),[Be,Ve]=(0,N.useState)(null),[He,Ue]=(0,N.useState)(!1),[We,Ge]=(0,N.useState)(``),[Ke,qe]=(0,N.useState)(``),[B,Je]=(0,N.useState)(`text-generation`),[V,Ye]=(0,N.useState)(`downloads`),[Xe,Ze]=(0,N.useState)(null),[Qe,$e]=(0,N.useState)({}),[et,tt]=(0,N.useState)(null),[nt,H]=(0,N.useState)(null),[rt,U]=(0,N.useState)(null),[it,W]=(0,N.useState)(null),[G,at]=(0,N.useState)(new Set([`pull`,`local`])),K=e=>{at(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},{data:q,isLoading:ot,refetch:J}=M({queryKey:[`ollama-state`],queryFn:async()=>{let[e,t,n,r]=await Promise.all([A.getModels(),A.listRunningModels(),A.getVersion(),A.checkHealth()]);return{models:e.success&&e.data||[],runningModels:t.success&&Array.isArray(t.data)?t.data:[],ollamaVersion:n.success&&n.data?n.data.version:null,isHealthy:r.success}}}),Y=q?.models??[],X=q?.runningModels??[],st=q?.ollamaVersion??null,ct=q?.isHealthy??null,Z=(0,N.useCallback)(async()=>{await J()},[J]),{data:Q=[],isLoading:lt}=M({queryKey:[`ollama-library`],queryFn:async()=>{let e=await A.getLibraryModels();return e.success&&e.data?e.data:[]}}),{data:ut=[],isLoading:dt}=M({queryKey:[`ollama-library`,`cloud`],queryFn:async()=>{let e=await A.getLibraryModels({category:`cloud`});return e.success&&e.data?e.data:[]},enabled:f===`cloud`}),ft=()=>u.invalidateQueries({queryKey:[`ollama-library`]});(0,N.useEffect)(()=>{let e=setTimeout(()=>{qe(We)},300);return()=>clearTimeout(e)},[We]);let pt=G.has(`huggingface`),{data:mt=[],isLoading:ht}=M({queryKey:[`hf-models`,B,Ke,V],queryFn:async()=>{let e=await oe.getModels({task:B,search:Ke||void 0,sort:V,limit:30});return e.success&&e.data?e.data:[]},enabled:pt}),gt=()=>u.invalidateQueries({queryKey:[`hf-models`,B,Ke,V]}),_t=(0,N.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){tt(e);try{let r=await oe.getGgufFiles(t,n);r.success&&r.data&&$e(t=>({...t,[e]:r.data}))}catch(e){xe.error(`Failed to load GGUF files:`,e)}finally{tt(null)}}},[]),vt=(0,N.useCallback)(e=>{Xe===e?Ze(null):(Ze(e),Qe[e]||_t(e))},[Xe,Qe,_t]),yt=(0,N.useCallback)((t,n)=>{if(!c){_.error(e(`modelManager.pull.restricted`));return}if(!nt){H(t),U({status:`starting`});try{let e=A.pullModelStream(t,e=>{U(e)},()=>{U(null),H(null),W(null),_.success(`Downloaded ${n}`),Z()},e=>{U(null),H(null),W(null),_.error(`Failed to download: ${e}`)});W(()=>e)}catch{U(null),H(null),_.error(`Failed to start download`)}}},[c,nt,Z,e]),bt=(0,N.useCallback)(()=>{it&&(it(),W(null),H(null),U(null))},[it]),xt=async(t,n)=>{if(!c){_.error(e(`modelManager.pull.restricted`));return}let r=t||x.trim(),i=n===`cloud`||!t&&f===`cloud`?Ce(r):r;if(!i){_.error(e(`modelManager.pull.enterName`));return}t&&S(i),T(!0),D({status:`starting`});try{let t=A.pullModelStream(i,e=>{D(e)},()=>{D(null),T(!1),k(null),_.success(e(`modelManager.pull.success`,{name:i})),S(``),Z()},t=>{D(null),T(!1),k(null),_.error(e(`modelManager.pull.failed`)+`: `+t)});k(()=>t)}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.pull.failed`)+`: `+n),D(null),T(!1),k(null)}},St=()=>{O&&(O(),k(null),T(!1),D(null),_.success(e(`modelManager.pull.cancelled`)))},Ct=async t=>{if(confirm(e(`modelManager.local.deleteConfirm`,{name:t})))try{await A.deleteModel(t),_.success(e(`modelManager.local.deleteSuccess`,{name:t})),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.local.deleteFailed`)+`: `+n)}},wt=async t=>{_e(!0),fe(t),me(!0);try{let n=await A.showModel(t,!0);n.success&&n.data?ce(n.data):_.error(e(`modelManager.modals.details.noDetails`))}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.modals.details.noDetails`)+`: `+n)}finally{_e(!1)}},Tt=async()=>{if(!I.trim()||!R.trim()){_.error(e(`modelManager.modals.copy.enterBoth`));return}Ee(!0);try{await A.copyModel(I.trim(),R.trim()),_.success(e(`modelManager.modals.copy.success`,{name:R})),F(!1),L(``),we(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.modals.copy.failed`)+`: `+n)}finally{Ee(!1)}},Et=async()=>{if(!z.trim()||!Ae.trim()){_.error(e(`modelManager.modals.create.enterBoth`));return}Ne(!0);try{await A.createModel({model:z.trim(),modelfile:Ae.trim()}),_.success(e(`modelManager.modals.create.success`,{name:z})),Oe(!1),ke(``),je(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.modals.create.failed`)+`: `+n)}finally{Ne(!1)}},Dt=async()=>{if(!Ie.trim()||!Re.trim()){_.error(e(`modelManager.modals.embeddings.enterBoth`));return}Ue(!0),Ve(null);try{let t=await A.generateEmbeddings({model:Ie.trim(),input:Re.trim()});if(t.success&&t.data){let n=t.data.embeddings?.[0]||[];Ve(n),_.success(e(`modelManager.modals.embeddings.success`,{count:n.length}))}}catch(t){let n=t instanceof Error?t.message:String(t);_.error(e(`modelManager.modals.embeddings.failed`)+`: `+n)}finally{Ue(!1)}},$=e=>{let t=e/1073741824;return t>=1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(1)} MB`},Ot=e=>Array.isArray(X)&&X.some(t=>t.name===e),kt=()=>Y.reduce((e,t)=>e+t.size,0),At=()=>X.reduce((e,t)=>e+(t.size_vram||0),0),jt=e=>Y.some(t=>t.name===e||t.name.startsWith(e+`:`)),Mt=(f===`cloud`?ut:Q).filter(e=>{let t=f===`all`||f===`cloud`||e.category===f,n=!v||e.name.toLowerCase().includes(v.toLowerCase())||e.description.toLowerCase().includes(v.toLowerCase());return t&&n}),Nt=[`all`,...new Set([...Q.map(e=>e.category),`cloud`])],Pt=(0,N.useMemo)(()=>Q.length>0?Q.slice(0,10).map(e=>({name:e.name,category:e.category,size:e.sizes?.[0]||``})):[{name:`deepseek-r1`,category:`reasoning`,size:`7B`},{name:`llama3.2`,category:`general`,size:`3B`},{name:`gemma3`,category:`general`,size:`4B`},{name:`qwen2.5`,category:`general`,size:`7B`},{name:`mistral`,category:`general`,size:`7B`},{name:`codellama`,category:`coding`,size:`7B`},{name:`nomic-embed-text`,category:`embedding`,size:`137M`},{name:`llava`,category:`vision`,size:`7B`},{name:`phi3`,category:`general`,size:`3.8B`},{name:`gemma2`,category:`general`,size:`9B`}],[Q]),Ft=pe||ye||De||Pe;return ot?(0,P.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-gray-600 dark:text-dark-600`,children:[(0,P.jsx)(y,{className:`h-5 w-5 animate-spin`}),e(`modelManager.loading`)]})}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsx)(`div`,{className:a(`rounded-2xl border px-4 py-3`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:a(`w-2.5 h-2.5 rounded-full`,ct?`bg-green-500`:`bg-red-500`)}),(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(ct?`modelManager.systemStatus.online`:`modelManager.systemStatus.offline`)})]}),st&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(m,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[`v`,st]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(s,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[Y.length,` `,Y.length===1?e(`modelManager.systemStatus.models`):e(`modelManager.systemStatus.models_plural`)]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(ee,{className:`h-4 w-4`}),(0,P.jsx)(`span`,{children:$(kt())})]}),X.length>0&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,P.jsx)(l,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[X.length,` `,e(`modelManager.systemStatus.running`),` (`,$(At()),` `,e(`modelManager.systemStatus.vram`),`)`]})]})]}),(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,P.jsxs)(j,{onClick:Z,variant:`outline`,size:`sm`,className:a(`gap-1.5`,``,``),children:[(0,P.jsx)(y,{className:`h-3.5 w-3.5`}),e(`common.refresh`)]})})]})}),(0,P.jsx)(be,{expanded:G.has(`pull`),modelName:x,setModelName:S,pulling:C,progress:ne,canInstallModels:c,popularModels:Pt,onToggle:()=>K(`pull`),onPull:()=>xt(),onCancelPull:St,formatSize:$}),(0,P.jsx)(ve,{expanded:G.has(`library`),models:Mt,totalAvailable:Q.length,categories:Nt,filter:f,search:v,loading:lt||dt,pulling:C,canInstallModels:c,pullSectionExpanded:G.has(`pull`),setFilter:g,setSearch:b,isModelInstalled:jt,normalizeCloudPullName:Ce,onToggle:()=>K(`library`),onTogglePullSection:()=>K(`pull`),onPullModel:xt,onRefresh:ft}),(0,P.jsx)(de,{expanded:G.has(`huggingface`),models:mt,search:We,task:B,sort:V,loadingModels:ht,canInstallModels:c,expandedModelId:Xe,loadingGgufModelId:et,ggufFiles:Qe,pullingModel:nt,pullProgress:rt,setSearch:Ge,setTask:Je,setSort:Ye,onToggle:()=>K(`huggingface`),onToggleModel:vt,onPullGguf:yt,onCancelPull:bt,onRefresh:gt}),Array.isArray(X)&&X.length>0&&(0,P.jsxs)(`div`,{className:a(`rounded-2xl border p-4`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,P.jsx)(l,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.running`)}),(0,P.jsxs)(`span`,{className:a(`ms-auto rounded-full px-2 py-0.5 text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[X.length,` `,e(`modelManager.systemStatus.running`)]})]}),(0,P.jsx)(`div`,{className:`space-y-2`,children:X.map(t=>(0,P.jsxs)(`div`,{className:a(`flex items-center justify-between p-4 rounded-lg border`,`bg-white/50 dark:bg-white/[0.025]`,`border-gray-200/80 dark:border-white/[0.08]`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`div`,{className:a(`w-2 h-2 rounded-full animate-pulse`,`bg-green-500`)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:t.name}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-gray-500 dark:text-dark-500`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(te,{className:`h-3 w-3`}),e(`modelManager.systemStatus.vram`),`:`,` `,$(t.size_vram||0)]}),t.size&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(s,{className:`h-3 w-3`}),e(`models.size`),`: `,$(t.size)]})]})]})]}),(0,P.jsxs)(`div`,{className:a(`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[(0,P.jsx)(re,{className:`h-3 w-3`}),e(`modelManager.local.running`)]})]},t.name))})]}),(0,P.jsx)(ge,{expanded:G.has(`local`),models:Y,onToggle:()=>K(`local`),isModelRunning:Ot,formatSize:$,onShowModel:wt,onCopyModel:e=>{L(e),F(!0)},onDeleteModel:Ct}),(0,P.jsxs)(`div`,{className:a(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:()=>K(`advanced`),"aria-expanded":G.has(`advanced`),className:a(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(p,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.advanced`)})]}),G.has(`advanced`)?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(w,{className:`h-5 w-5 text-gray-500`})]}),G.has(`advanced`)&&(0,P.jsx)(`div`,{className:`p-4 pt-0`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,P.jsxs)(j,{onClick:()=>Oe(!0),variant:`outline`,className:a(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(d,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.createModel`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.fromModelfile`)})]})]}),(0,P.jsxs)(j,{onClick:()=>F(!0),variant:`outline`,className:a(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(o,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.copyModel`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.duplicateExisting`)})]})]}),(0,P.jsxs)(j,{onClick:()=>Fe(!0),variant:`outline`,className:a(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(ie,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.testEmbeddings`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.generateVectors`)})]})]}),(0,P.jsxs)(j,{onClick:async()=>{try{(await A.checkHealth()).success&&(await J(),_.success(e(`modelManager.advanced.healthy`)))}catch{await J(),_.error(e(`modelManager.systemStatus.offline`))}},variant:`outline`,className:a(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(h,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.healthCheck`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.testConnection`)})]})]})]})})]}),Ft&&(0,P.jsx)(N.Suspense,{fallback:null,children:(0,P.jsx)(Se,{models:Y,showDetailsModal:pe,setShowDetailsModal:me,selectedModelName:le,selectedModelDetails:ae,loadingDetails:he,showCopyModal:ye,setShowCopyModal:F,copySource:I,setCopySource:L,copyDestination:R,setCopyDestination:we,copying:Te,handleCopyModel:Tt,showCreateModal:De,setShowCreateModal:Oe,createModelName:z,setCreateModelName:ke,createModelfile:Ae,setCreateModelfile:je,creating:Me,handleCreateModel:Et,showEmbeddingsModal:Pe,setShowEmbeddingsModal:Fe,embeddingsModel:Ie,setEmbeddingsModel:Le,embeddingsInput:Re,setEmbeddingsInput:ze,embeddingsResult:Be,generatingEmbeddings:He,handleGenerateEmbeddings:Dt})})]})},R=()=>{let{t:e}=i();return(0,P.jsxs)(ce,{children:[(0,P.jsx)(le,{title:e(`models.title`),description:e(`models.subtitle`)}),(0,P.jsx)(L,{})]})};export{R as ModelsPage,R as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{t as r}from"./useTranslation-Bho4HCyg.js";import{r as i,t as a}from"./utils-D9W1Lnkn.js";import{F as o,Kt as s,Rn as c,U as l,g as u,jn as d,q as f,tt as p}from"./ui-vendor-B1UgO3vd.js";import{t as m}from"./logger-DSXjF4ye.js";import{C as h}from"./api-BDtqBtqw.js";import{t as g}from"./Button-BPf_pOxH.js";import"./ui-CC-K19wO.js";import{t as _}from"./RichMessageContent-DiySVYGB.js";var v=e(t(),1),y=n(),b=m(`pages:notes`),x=800,S=()=>{let{t:e,i18n:t}=r(),[n,m]=(0,v.useState)([]),[S,C]=(0,v.useState)(!0),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(!0),[P,F]=(0,v.useState)(`idle`),I=(0,v.useRef)(null),L=(0,v.useMemo)(()=>n.find(e=>e.id===w)??null,[n,w]);(0,v.useEffect)(()=>{let e=!1;return h.getNotes().then(t=>{e||t.success&&t.data&&m(t.data)}).catch(e=>b.error(`Failed to load notes:`,e)).finally(()=>{e||C(!1)}),()=>{e=!0}},[]);let R=(e,t=`preview`)=>{V(),T(e.id),k(e.title),j(e.content),N(t===`preview`),F(`idle`)},z=(e,t,n)=>{I.current!==null&&window.clearTimeout(I.current),F(`saving`),I.current=window.setTimeout(()=>{I.current=null,B(e,t,n)},x)},B=async(t,n,r)=>{try{let e=await h.updateNote(t,{title:n,content:r});if(e.success&&e.data){let n=e.data;m(e=>[n,...e.filter(e=>e.id!==t)].sort((e,t)=>t.updatedAt-e.updatedAt)),F(`saved`)}}catch(t){b.error(`Failed to save note:`,t),c.error(e(`notes.saveFailed`)),F(`idle`)}},V=()=>{I.current!==null&&w&&(window.clearTimeout(I.current),I.current=null,B(w,O,A))};(0,v.useEffect)(()=>()=>{I.current!==null&&window.clearTimeout(I.current)},[]);let H=async()=>{try{let e=await h.createNote(``,``);if(e.success&&e.data){let t=e.data;m(e=>[t,...e]),R(t,`edit`)}}catch(t){b.error(`Failed to create note:`,t),c.error(e(`notes.createFailed`))}},U=async t=>{if(window.confirm(e(`notes.deleteConfirm`)))try{(await h.deleteNote(t)).success&&(m(e=>e.filter(e=>e.id!==t)),w===t&&T(null))}catch(t){b.error(`Failed to delete note:`,t),c.error(e(`notes.deleteFailed`))}},W=(0,v.useMemo)(()=>{let e=E.trim().toLowerCase();return e?n.filter(t=>t.title.toLowerCase().includes(e)||t.content.toLowerCase().includes(e)):n},[n,E]);return(0,y.jsxs)(`div`,{className:`flex h-full min-h-0 overflow-hidden`,"data-testid":`notes-page`,children:[(0,y.jsxs)(`div`,{"data-testid":`notes-list`,className:a(`min-h-0 w-full shrink-0 flex-col border-e border-black/[0.06] dark:border-white/[0.07] md:w-72`,L?`hidden md:flex`:`flex`),children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4`,children:[(0,y.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`notes.title`)}),(0,y.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>void H(),className:`h-7 w-7 p-0`,title:e(`notes.new`),children:(0,y.jsx)(l,{className:`h-4 w-4`})})]}),(0,y.jsxs)(`div`,{className:`relative mx-3 mb-2`,children:[(0,y.jsx)(o,{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,y.jsx)(`input`,{type:`search`,value:E,onChange:e=>D(e.target.value),placeholder:e(`common.search`),className:`w-full rounded-lg border border-transparent bg-black/[0.04] py-1.5 pe-2.5 ps-8 text-base text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:bg-white/[0.05] dark:text-dark-900 dark:placeholder:text-dark-500 sm:text-[13px]`})]}),(0,y.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:S?null:W.length===0?(0,y.jsxs)(`div`,{className:`px-3 py-10 text-center`,children:[(0,y.jsx)(p,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,y.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:e(`notes.empty`)})]}):(0,y.jsx)(`div`,{className:`space-y-0.5`,children:W.map(n=>(0,y.jsxs)(`div`,{"data-testid":`note-list-item`,onClick:()=>R(n),className:a(`group cursor-pointer rounded-lg px-2.5 py-2 transition-colors`,w===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,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,y.jsx)(`p`,{className:`truncate text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:n.title||e(`notes.untitled`)}),(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),U(n.id)},className:`shrink-0 rounded-md p-1 text-red-500 opacity-100 transition-opacity hover:bg-red-50 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100 dark:hover:bg-red-900/20`,title:e(`common.delete`),children:(0,y.jsx)(u,{className:`h-3 w-3`})})]}),(0,y.jsxs)(`p`,{className:`mt-0.5 truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[i(n.updatedAt,t.language),n.content.trim()&&(0,y.jsxs)(y.Fragment,{children:[` · `,n.content.trim().slice(0,60)]})]})]},n.id))})})]}),(0,y.jsx)(`div`,{"data-testid":`notes-editor`,className:a(`min-w-0 flex-1 flex-col`,L?`flex`:`hidden md:flex`),children:L?(0,y.jsxs)(y.Fragment,{children:[(0,y.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,y.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>{V(),T(null),N(!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,y.jsx)(d,{className:`h-4 w-4 rtl:rotate-180`})}),M?(0,y.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:O||e(`notes.untitled`)}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`input`,{"data-testid":`notes-title-editor`,dir:`auto`,value:O,onChange:e=>{k(e.target.value),z(L.id,e.target.value,A)},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,y.jsx)(`span`,{className:`hidden shrink-0 text-[11px] text-gray-400 dark:text-dark-500 sm:inline`,"aria-live":`polite`,children:P===`saving`?e(`common.saving`):P===`saved`?e(`notes.saved`):``})]}),(0,y.jsx)(g,{size:`sm`,variant:`ghost`,onClick:()=>{M||V(),N(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(M?`common.edit`:`artifacts.preview`),"aria-label":e(M?`common.edit`:`artifacts.preview`),"data-testid":`notes-preview-toggle`,children:M?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(f,{className:`h-3.5 w-3.5`}),(0,y.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.edit`)})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(s,{className:`h-3.5 w-3.5`}),(0,y.jsx)(`span`,{className:`hidden sm:inline`,children:e(`artifacts.preview`)})]})})]}),M?(0,y.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,y.jsx)(_,{content:A,className:`mx-auto w-full max-w-5xl pb-12`})}):(0,y.jsx)(`textarea`,{"data-testid":`notes-content-editor`,dir:`auto`,value:A,onChange:e=>{j(e.target.value),z(L.id,O,e.target.value)},onBlur:V,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]`})]}):(0,y.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(p,{className:`mx-auto mb-3 h-8 w-8 text-gray-300 dark:text-dark-400`}),(0,y.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-600`,children:e(`notes.selectOrCreate`)}),(0,y.jsxs)(g,{size:`sm`,onClick:()=>void H(),className:`mt-4 gap-1.5`,children:[(0,y.jsx)(l,{className:`h-3.5 w-3.5`}),e(`notes.new`)]})]})})})]})};export{S as NotesPage,S as default};