libre-webui 0.36.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/README.md +59 -0
  2. package/backend/dist/cordis/contracts.d.ts +270 -0
  3. package/backend/dist/cordis/contracts.d.ts.map +1 -0
  4. package/backend/dist/cordis/contracts.js +32 -0
  5. package/backend/dist/cordis/contracts.js.map +1 -0
  6. package/backend/dist/cordis/dsh/chat-model.d.ts +16 -0
  7. package/backend/dist/cordis/dsh/chat-model.d.ts.map +1 -0
  8. package/backend/dist/cordis/dsh/chat-model.js +104 -0
  9. package/backend/dist/cordis/dsh/chat-model.js.map +1 -0
  10. package/backend/dist/cordis/dsh/engine-plugin.d.ts +186 -0
  11. package/backend/dist/cordis/dsh/engine-plugin.d.ts.map +1 -0
  12. package/backend/dist/cordis/dsh/engine-plugin.js +1116 -0
  13. package/backend/dist/cordis/dsh/engine-plugin.js.map +1 -0
  14. package/backend/dist/cordis/dsh/librewebui-llm-adapter.d.ts +175 -0
  15. package/backend/dist/cordis/dsh/librewebui-llm-adapter.d.ts.map +1 -0
  16. package/backend/dist/cordis/dsh/librewebui-llm-adapter.js +480 -0
  17. package/backend/dist/cordis/dsh/librewebui-llm-adapter.js.map +1 -0
  18. package/backend/dist/cordis/dsh/model-identity.d.ts +12 -0
  19. package/backend/dist/cordis/dsh/model-identity.d.ts.map +1 -0
  20. package/backend/dist/cordis/dsh/model-identity.js +87 -0
  21. package/backend/dist/cordis/dsh/model-identity.js.map +1 -0
  22. package/backend/dist/cordis/dsh/native-provider-client.d.ts +44 -0
  23. package/backend/dist/cordis/dsh/native-provider-client.d.ts.map +1 -0
  24. package/backend/dist/cordis/dsh/native-provider-client.js +524 -0
  25. package/backend/dist/cordis/dsh/native-provider-client.js.map +1 -0
  26. package/backend/dist/cordis/dsh/native-provider-plugin.d.ts +11 -0
  27. package/backend/dist/cordis/dsh/native-provider-plugin.d.ts.map +1 -0
  28. package/backend/dist/cordis/dsh/native-provider-plugin.js +416 -0
  29. package/backend/dist/cordis/dsh/native-provider-plugin.js.map +1 -0
  30. package/backend/dist/cordis/dsh/native-provider-protocol.d.ts +37 -0
  31. package/backend/dist/cordis/dsh/native-provider-protocol.d.ts.map +1 -0
  32. package/backend/dist/cordis/dsh/native-provider-protocol.js +325 -0
  33. package/backend/dist/cordis/dsh/native-provider-protocol.js.map +1 -0
  34. package/backend/dist/cordis/dsh/provider-handler.d.ts +36 -0
  35. package/backend/dist/cordis/dsh/provider-handler.d.ts.map +1 -0
  36. package/backend/dist/cordis/dsh/provider-handler.js +582 -0
  37. package/backend/dist/cordis/dsh/provider-handler.js.map +1 -0
  38. package/backend/dist/cordis/dsh/session-files.d.ts +9 -0
  39. package/backend/dist/cordis/dsh/session-files.d.ts.map +1 -0
  40. package/backend/dist/cordis/dsh/session-files.js +60 -0
  41. package/backend/dist/cordis/dsh/session-files.js.map +1 -0
  42. package/backend/dist/cordis/dsh/session-settings.d.ts +15 -0
  43. package/backend/dist/cordis/dsh/session-settings.d.ts.map +1 -0
  44. package/backend/dist/cordis/dsh/session-settings.js +51 -0
  45. package/backend/dist/cordis/dsh/session-settings.js.map +1 -0
  46. package/backend/dist/cordis/dsh/work-driver.d.ts +12 -0
  47. package/backend/dist/cordis/dsh/work-driver.d.ts.map +1 -0
  48. package/backend/dist/cordis/dsh/work-driver.js +402 -0
  49. package/backend/dist/cordis/dsh/work-driver.js.map +1 -0
  50. package/backend/dist/cordis/dsh/workspace-policy.d.ts +10 -0
  51. package/backend/dist/cordis/dsh/workspace-policy.d.ts.map +1 -0
  52. package/backend/dist/cordis/dsh/workspace-policy.js +44 -0
  53. package/backend/dist/cordis/dsh/workspace-policy.js.map +1 -0
  54. package/backend/dist/cordis/host/composition.d.ts +73 -0
  55. package/backend/dist/cordis/host/composition.d.ts.map +1 -0
  56. package/backend/dist/cordis/host/composition.js +205 -0
  57. package/backend/dist/cordis/host/composition.js.map +1 -0
  58. package/backend/dist/cordis/host/config.d.ts +159 -0
  59. package/backend/dist/cordis/host/config.d.ts.map +1 -0
  60. package/backend/dist/cordis/host/config.js +184 -0
  61. package/backend/dist/cordis/host/config.js.map +1 -0
  62. package/backend/dist/cordis/host/host.d.ts +74 -0
  63. package/backend/dist/cordis/host/host.d.ts.map +1 -0
  64. package/backend/dist/cordis/host/host.js +420 -0
  65. package/backend/dist/cordis/host/host.js.map +1 -0
  66. package/backend/dist/cordis/host/loader-entry.d.ts +41 -0
  67. package/backend/dist/cordis/host/loader-entry.d.ts.map +1 -0
  68. package/backend/dist/cordis/host/loader-entry.js +52 -0
  69. package/backend/dist/cordis/host/loader-entry.js.map +1 -0
  70. package/backend/dist/cordis/host/model.d.ts +45 -0
  71. package/backend/dist/cordis/host/model.d.ts.map +1 -0
  72. package/backend/dist/cordis/host/model.js +54 -0
  73. package/backend/dist/cordis/host/model.js.map +1 -0
  74. package/backend/dist/cordis/host/privacy.d.ts +8 -0
  75. package/backend/dist/cordis/host/privacy.d.ts.map +1 -0
  76. package/backend/dist/cordis/host/privacy.js +73 -0
  77. package/backend/dist/cordis/host/privacy.js.map +1 -0
  78. package/backend/dist/cordis/index.d.ts +14 -0
  79. package/backend/dist/cordis/index.d.ts.map +1 -0
  80. package/backend/dist/cordis/index.js +30 -0
  81. package/backend/dist/cordis/index.js.map +1 -0
  82. package/backend/dist/cordis/runtime.d.ts +97 -0
  83. package/backend/dist/cordis/runtime.d.ts.map +1 -0
  84. package/backend/dist/cordis/runtime.js +231 -0
  85. package/backend/dist/cordis/runtime.js.map +1 -0
  86. package/backend/dist/cordis/work-model.d.ts +7 -0
  87. package/backend/dist/cordis/work-model.d.ts.map +1 -0
  88. package/backend/dist/cordis/work-model.js +30 -0
  89. package/backend/dist/cordis/work-model.js.map +1 -0
  90. package/backend/dist/db.js +1 -1
  91. package/backend/dist/index.d.ts.map +1 -1
  92. package/backend/dist/index.js +9 -0
  93. package/backend/dist/index.js.map +1 -1
  94. package/backend/dist/main.js +12 -0
  95. package/backend/dist/main.js.map +1 -1
  96. package/backend/dist/persistence/extensionTypes.d.ts +2 -0
  97. package/backend/dist/persistence/extensionTypes.d.ts.map +1 -1
  98. package/backend/dist/persistence/extensionTypes.js.map +1 -1
  99. package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
  100. package/backend/dist/persistence/postgresExtensionRepositories.js +38 -0
  101. package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
  102. package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
  103. package/backend/dist/persistence/postgresResourceRepositories.js +6 -1
  104. package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
  105. package/backend/dist/persistence/resourceTypes.d.ts +3 -1
  106. package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
  107. package/backend/dist/persistence/resourceTypes.js.map +1 -1
  108. package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
  109. package/backend/dist/persistence/sqliteExtensionRepositories.js +40 -0
  110. package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
  111. package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
  112. package/backend/dist/persistence/sqliteResourceRepositories.js +7 -1
  113. package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
  114. package/backend/dist/routes/agentCli.d.ts.map +1 -1
  115. package/backend/dist/routes/agentCli.js +34 -2
  116. package/backend/dist/routes/agentCli.js.map +1 -1
  117. package/backend/dist/routes/chat.d.ts.map +1 -1
  118. package/backend/dist/routes/chat.js +9 -1
  119. package/backend/dist/routes/chat.js.map +1 -1
  120. package/backend/dist/routes/cordis.d.ts +3 -0
  121. package/backend/dist/routes/cordis.d.ts.map +1 -0
  122. package/backend/dist/routes/cordis.js +440 -0
  123. package/backend/dist/routes/cordis.js.map +1 -0
  124. package/backend/dist/routes/libreClaw.js +1 -1
  125. package/backend/dist/routes/libreClaw.js.map +1 -1
  126. package/backend/dist/routes/work.d.ts.map +1 -1
  127. package/backend/dist/routes/work.js +23 -8
  128. package/backend/dist/routes/work.js.map +1 -1
  129. package/backend/dist/services/agentAccessService.d.ts +4 -0
  130. package/backend/dist/services/agentAccessService.d.ts.map +1 -1
  131. package/backend/dist/services/agentAccessService.js +48 -16
  132. package/backend/dist/services/agentAccessService.js.map +1 -1
  133. package/backend/dist/services/agentCliService.d.ts +42 -1
  134. package/backend/dist/services/agentCliService.d.ts.map +1 -1
  135. package/backend/dist/services/agentCliService.js +206 -7
  136. package/backend/dist/services/agentCliService.js.map +1 -1
  137. package/backend/dist/services/agentCliUsage.d.ts +22 -0
  138. package/backend/dist/services/agentCliUsage.d.ts.map +1 -0
  139. package/backend/dist/services/agentCliUsage.js +192 -0
  140. package/backend/dist/services/agentCliUsage.js.map +1 -0
  141. package/backend/dist/services/authService.d.ts +3 -0
  142. package/backend/dist/services/authService.d.ts.map +1 -1
  143. package/backend/dist/services/authService.js +4 -1
  144. package/backend/dist/services/authService.js.map +1 -1
  145. package/backend/dist/services/chatGenerationService.d.ts +7 -0
  146. package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
  147. package/backend/dist/services/chatGenerationService.js +32 -1
  148. package/backend/dist/services/chatGenerationService.js.map +1 -1
  149. package/backend/dist/services/cordisAccessService.d.ts +56 -0
  150. package/backend/dist/services/cordisAccessService.d.ts.map +1 -0
  151. package/backend/dist/services/cordisAccessService.js +98 -0
  152. package/backend/dist/services/cordisAccessService.js.map +1 -0
  153. package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
  154. package/backend/dist/services/durableChatGenerationService.js +9 -1
  155. package/backend/dist/services/durableChatGenerationService.js.map +1 -1
  156. package/backend/dist/services/emailService.d.ts.map +1 -1
  157. package/backend/dist/services/emailService.js +8 -1
  158. package/backend/dist/services/emailService.js.map +1 -1
  159. package/backend/dist/services/pluginService.d.ts.map +1 -1
  160. package/backend/dist/services/pluginService.js +7 -26
  161. package/backend/dist/services/pluginService.js.map +1 -1
  162. package/backend/dist/services/pluginUsageService.d.ts +52 -0
  163. package/backend/dist/services/pluginUsageService.d.ts.map +1 -1
  164. package/backend/dist/services/pluginUsageService.js +89 -1
  165. package/backend/dist/services/pluginUsageService.js.map +1 -1
  166. package/backend/dist/services/systemSettingsService.d.ts +1 -1
  167. package/backend/dist/services/systemSettingsService.d.ts.map +1 -1
  168. package/backend/dist/services/systemSettingsService.js +1 -1
  169. package/backend/dist/services/systemSettingsService.js.map +1 -1
  170. package/backend/dist/services/thinkingSummaryService.d.ts +3 -0
  171. package/backend/dist/services/thinkingSummaryService.d.ts.map +1 -1
  172. package/backend/dist/services/thinkingSummaryService.js +56 -17
  173. package/backend/dist/services/thinkingSummaryService.js.map +1 -1
  174. package/backend/dist/services/titleGenerationService.d.ts +22 -2
  175. package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
  176. package/backend/dist/services/titleGenerationService.js +63 -8
  177. package/backend/dist/services/titleGenerationService.js.map +1 -1
  178. package/backend/dist/services/workAgentService.d.ts +1 -1
  179. package/backend/dist/services/workAgentService.d.ts.map +1 -1
  180. package/backend/dist/services/workAgentService.js +76 -12
  181. package/backend/dist/services/workAgentService.js.map +1 -1
  182. package/backend/dist/services/workModelProviderService.d.ts +5 -0
  183. package/backend/dist/services/workModelProviderService.d.ts.map +1 -1
  184. package/backend/dist/services/workModelProviderService.js +52 -3
  185. package/backend/dist/services/workModelProviderService.js.map +1 -1
  186. package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
  187. package/backend/dist/services/workRuntimeService.js +4 -1
  188. package/backend/dist/services/workRuntimeService.js.map +1 -1
  189. package/backend/dist/services/workTaskService.d.ts.map +1 -1
  190. package/backend/dist/services/workTaskService.js +6 -6
  191. package/backend/dist/services/workTaskService.js.map +1 -1
  192. package/backend/dist/types/work.d.ts +12 -1
  193. package/backend/dist/types/work.d.ts.map +1 -1
  194. package/backend/dist/utils/pluginStreamAdapter.d.ts.map +1 -1
  195. package/backend/dist/utils/pluginStreamAdapter.js +18 -4
  196. package/backend/dist/utils/pluginStreamAdapter.js.map +1 -1
  197. package/backend/dist/utils/pluginStreaming.d.ts +6 -0
  198. package/backend/dist/utils/pluginStreaming.d.ts.map +1 -1
  199. package/backend/dist/utils/pluginStreaming.js +10 -0
  200. package/backend/dist/utils/pluginStreaming.js.map +1 -1
  201. package/backend/dist/utils/smtpClient.d.ts +5 -1
  202. package/backend/dist/utils/smtpClient.d.ts.map +1 -1
  203. package/backend/dist/utils/smtpClient.js +29 -3
  204. package/backend/dist/utils/smtpClient.js.map +1 -1
  205. package/backend/dist/websocketServer.d.ts.map +1 -1
  206. package/backend/dist/websocketServer.js +4 -0
  207. package/backend/dist/websocketServer.js.map +1 -1
  208. package/backend/package.json +37 -2
  209. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  210. package/frontend/dist/artifact-runtime/framer-motion.js +3 -3
  211. package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
  212. package/frontend/dist/artifact-runtime/react.js +5 -5
  213. package/frontend/dist/artifact-runtime/recharts.js +45 -45
  214. package/frontend/dist/assets/index-BrDSO609.js +20 -0
  215. package/frontend/dist/assets/index-C8_AByBq.css +1 -0
  216. package/frontend/dist/index.html +33 -31
  217. package/frontend/dist/js/{ArtifactContainer-B8tyPtWd.js → ArtifactContainer-B1-GVzVf.js} +1 -1
  218. package/frontend/dist/js/{ArtifactDemoPage-BwRfWoSK.js → ArtifactDemoPage-goftRHdk.js} +1 -1
  219. package/frontend/dist/js/{ArtifactSandboxFrame-Ctcwt_l2.js → ArtifactSandboxFrame-_8RA8_JV.js} +1 -1
  220. package/frontend/dist/js/ArtifactSlideOutPanel-DlkOZI5N.js +1 -0
  221. package/frontend/dist/js/{AutomationModal-mTYs9LrJ.js → AutomationModal-BaaxZF1M.js} +1 -1
  222. package/frontend/dist/js/AutomationsPage-DY2x7zVm.js +1 -0
  223. package/frontend/dist/js/{AvatarUpload-wWUAi3e2.js → AvatarUpload-CH_n1Ef0.js} +1 -1
  224. package/frontend/dist/js/{Button-ZQ6BePid.js → Button-CGMYia4g.js} +1 -1
  225. package/frontend/dist/js/{CalendarPage-Ch4racU2.js → CalendarPage-DLo5nm3Q.js} +1 -1
  226. package/frontend/dist/js/ChannelsPage-DnQI7mzq.js +1 -0
  227. package/frontend/dist/js/ChatPage-BaDkJnEC.js +14 -0
  228. package/frontend/dist/js/ConnectModels-B4dGb5yc.js +1 -0
  229. package/frontend/dist/js/CordisPage-CPiYn2Bx.js +1 -0
  230. package/frontend/dist/js/{EvaluationsPage-DHPnNBkW.js → EvaluationsPage-DpdGpd7x.js} +2 -2
  231. package/frontend/dist/js/{FirstTimeSetup-CoF83yY8.js → FirstTimeSetup-By8OE1JS.js} +1 -1
  232. package/frontend/dist/js/GalleryPage-ByZyIhZQ.js +1 -0
  233. package/frontend/dist/js/HomePage-Btc-Mvin.js +1 -0
  234. package/frontend/dist/js/{LanguageSwitcher-CogfczNm.js → LanguageSwitcher-B3CxRW6J.js} +1 -1
  235. package/frontend/dist/js/LibreClawPage-3Sonm1gu.js +1 -0
  236. package/frontend/dist/js/{Logo-C9fsEUaY.js → Logo-HZvdAk2c.js} +1 -1
  237. package/frontend/dist/js/{LogoMark-Cvu5CQOW.js → LogoMark-GJnfMXsk.js} +1 -1
  238. package/frontend/dist/js/{ModelManagerModals-Bc2Woor7.js → ModelManagerModals-Bk6OQzJI.js} +1 -1
  239. package/frontend/dist/js/NotesPage-lFhfjMqJ.js +3 -0
  240. package/frontend/dist/js/{OptimizedSyntaxHighlighter-aKWyHj_c.js → OptimizedSyntaxHighlighter-CzzV6ONG.js} +1 -1
  241. package/frontend/dist/js/OptimizedSyntaxHighlighter-ajqwyBQm.js +1 -0
  242. package/frontend/dist/js/{PasswordStrengthMeter-BJr4eBbo.js → PasswordStrengthMeter-DasfJa4P.js} +1 -1
  243. package/frontend/dist/js/{PersonasPage-ff5opf9B.js → PersonasPage-nOThOpXp.js} +2 -2
  244. package/frontend/dist/js/PluginUsagePage-BRbHeRf7.js +1 -0
  245. package/frontend/dist/js/{RichMessageContent-BNNylVAb.js → RichMessageContent-BZ7KKJKK.js} +2 -2
  246. package/frontend/dist/js/RichMessageContent-oyydJjgc.js +1 -0
  247. package/frontend/dist/js/SettingsModal-VpsAx2Ns.js +19 -0
  248. package/frontend/dist/js/{SettingsToggle-CKLHOUt-.js → SettingsToggle-oxvw7ulA.js} +1 -1
  249. package/frontend/dist/js/{ShareDialog-DykD70uB.js → ShareDialog-CnxPGPb_.js} +1 -1
  250. package/frontend/dist/js/SystemPage-D2ikvhDp.js +1 -0
  251. package/frontend/dist/js/{TurnstileWidget-BO2ceTt8.js → TurnstileWidget-CVepEMEQ.js} +1 -1
  252. package/frontend/dist/js/{UserManagementPage-Ch-PvYQ9.js → UserManagementPage-2yHv89ZA.js} +1 -1
  253. package/frontend/dist/js/UserManagementPanel-vxpiyiTZ.js +1 -0
  254. package/frontend/dist/js/{WhatsNewModal-Bu4H4MEb.js → WhatsNewModal-DAAFzY0d.js} +1 -1
  255. package/frontend/dist/js/WorkPage-BYpYD9mr.js +8 -0
  256. package/frontend/dist/js/api-C0ligMmL.js +1 -0
  257. package/frontend/dist/js/api-CVUaOaq4.js +14 -0
  258. package/frontend/dist/js/{appNavigation-CVsQuDI1.js → appNavigation-CqtrZ9bm.js} +1 -1
  259. package/frontend/dist/js/{appStore-Din-tTD9.js → appStore-Biw63DtJ.js} +2 -2
  260. package/frontend/dist/js/appVersion-D78eXAb-.js +1 -0
  261. package/frontend/dist/js/ar-Cq-DrSYL.js +2 -0
  262. package/frontend/dist/js/authStore-2DsDTcIu.js +1 -0
  263. package/frontend/dist/js/{authStore-Cm8P6rYs.js → authStore-C5qKrmn4.js} +3 -3
  264. package/frontend/dist/js/bn-BqxLh-KL.js +2 -0
  265. package/frontend/dist/js/chatStore-DQhEqb9F.js +3 -0
  266. package/frontend/dist/js/client-gf5bjBrn.js +2 -0
  267. package/frontend/dist/js/composerStyles-C83jssgZ.js +1 -0
  268. package/frontend/dist/js/{config-DHea4b8N.js → config-CNvgxwAm.js} +1 -1
  269. package/frontend/dist/js/cordisApi-BYjA4EOQ.js +2 -0
  270. package/frontend/dist/js/cs-D2DDNZf-.js +2 -0
  271. package/frontend/dist/js/da-BciY-TSG.js +2 -0
  272. package/frontend/dist/js/de-DjU_eXQ-.js +2 -0
  273. package/frontend/dist/js/es-ChIEs80I.js +2 -0
  274. package/frontend/dist/js/{estree-DCT3Jm65.js → estree-DGmLqopC.js} +17 -17
  275. package/frontend/dist/js/evaluationsApi-Bg12ekHo.js +1 -0
  276. package/frontend/dist/js/fr-Bi8BGRW4.js +2 -0
  277. package/frontend/dist/js/hi-BMsCnWg7.js +2 -0
  278. package/frontend/dist/js/{html-CBXMuS97.js → html-BryNQ_yx.js} +6 -6
  279. package/frontend/dist/js/id-CpcN1vhk.js +2 -0
  280. package/frontend/dist/js/is-DkUy2cmP.js +2 -0
  281. package/frontend/dist/js/it-BglK9DRZ.js +2 -0
  282. package/frontend/dist/js/ja-IrprzwLJ.js +2 -0
  283. package/frontend/dist/js/ko--wwEsMPi.js +2 -0
  284. package/frontend/dist/js/{markdown-Bo71X2X2.js → markdown-CZ1tYEW8.js} +17 -17
  285. package/frontend/dist/js/{markdown-core-BFkBYv2v.js → markdown-core-KjS96SYW.js} +1 -1
  286. package/frontend/dist/js/{markdown-html-CwjnwJbl.js → markdown-html-DQEwrWcf.js} +1 -1
  287. package/frontend/dist/js/{markdown-math-CJvHdD1l.js → markdown-math-CKi32S5d.js} +1 -1
  288. package/frontend/dist/js/{markdownHtml-egpK3_YY.js → markdownHtml-lrXhxBhK.js} +1 -1
  289. package/frontend/dist/js/markdownMath-B0BpyFBS.js +1 -0
  290. package/frontend/dist/js/{messageCodeStyles-euWoxwoo.js → messageCodeStyles-DJZ4QMVq.js} +2 -2
  291. package/frontend/dist/js/ms-BWj59y7-.js +2 -0
  292. package/frontend/dist/js/nl-D-QndW_A.js +2 -0
  293. package/frontend/dist/js/pl-Dw7d7iDV.js +2 -0
  294. package/frontend/dist/js/pt-BI53uHJw.js +2 -0
  295. package/frontend/dist/js/react-vendor-wiHys0m2.js +9 -0
  296. package/frontend/dist/js/router-vendor-HZm4FR0A.js +1 -0
  297. package/frontend/dist/js/ru-JKyTgPg9.js +2 -0
  298. package/frontend/dist/js/{standalone-6z5x8CWe.js → standalone-DbyFjvTU.js} +1 -1
  299. package/frontend/dist/js/sv-BIkBLPSQ.js +2 -0
  300. package/frontend/dist/js/{syntax-highlight-7t8DGG2n.js → syntax-highlight-DNc3FFCa.js} +1 -1
  301. package/frontend/dist/js/{teamEventStream-DGgjrVqw.js → teamEventStream-PXiwR5Kr.js} +1 -1
  302. package/frontend/dist/js/th-CZ_LcCU0.js +2 -0
  303. package/frontend/dist/js/tr-B265byx1.js +2 -0
  304. package/frontend/dist/js/{typescript-CslHIgIJ.js → typescript-DUM5niRM.js} +1 -1
  305. package/frontend/dist/js/{ui-CNcEDQ95.js → ui-DDMjO5dd.js} +2 -2
  306. package/frontend/dist/js/ui-vendor-BhHHyHk3.js +1 -0
  307. package/frontend/dist/js/uk-VTAlChwf.js +2 -0
  308. package/frontend/dist/js/{useChat-YRODF1y1.js → useChat-DaIZ2Dbu.js} +1 -1
  309. package/frontend/dist/js/{useDialogFocus-BQLdAGYH.js → useDialogFocus-BPTG_Zmy.js} +1 -1
  310. package/frontend/dist/js/useDictation-BXyX1U8r.js +1 -0
  311. package/frontend/dist/js/useQuery-hWmQjdLu.js +1 -0
  312. package/frontend/dist/js/{useTranslation-Kn7_iLGj.js → useTranslation-B9kflK9S.js} +1 -1
  313. package/frontend/dist/js/{utils-Dq1w7K0c.js → utils-p8Gt72YP.js} +1 -1
  314. package/frontend/dist/js/{utils-vendor-dx9vGAt3.js → utils-vendor-DISWt2y9.js} +1 -1
  315. package/frontend/dist/js/vi-D8rXh-53.js +2 -0
  316. package/frontend/dist/js/{workStatus-oU04ZrUq.js → work-DmJpVPPO.js} +1 -1
  317. package/frontend/dist/js/workApi-BIS9RxRi.js +1 -0
  318. package/frontend/dist/js/workApi-C3Td_lFD.js +5 -0
  319. package/frontend/dist/js/workModels-MzU2Ab7l.js +1 -0
  320. package/frontend/dist/js/zh-BEGd9iBD.js +2 -0
  321. package/package.json +43 -8
  322. package/scripts/prepare-dsh-provider.mjs +124 -0
  323. package/frontend/dist/assets/index-BXTzjRcS.js +0 -92
  324. package/frontend/dist/assets/index-uzzNXp5R.css +0 -1
  325. package/frontend/dist/js/ArtifactSlideOutPanel-DPWGjHhp.js +0 -1
  326. package/frontend/dist/js/AutomationsPage-DvsLZWtg.js +0 -1
  327. package/frontend/dist/js/ChannelsPage-D252gXwf.js +0 -1
  328. package/frontend/dist/js/ChatPage-D_CzOiHw.js +0 -14
  329. package/frontend/dist/js/ConnectModels-DYOtIOEY.js +0 -1
  330. package/frontend/dist/js/GalleryPage-BpK-vrvd.js +0 -1
  331. package/frontend/dist/js/HomePage-zJkkDNJl.js +0 -1
  332. package/frontend/dist/js/LibreClawPage-CAgNj9GM.js +0 -1
  333. package/frontend/dist/js/NotesPage-CNTqlwNc.js +0 -3
  334. package/frontend/dist/js/OptimizedSyntaxHighlighter-BFjOBavF.js +0 -1
  335. package/frontend/dist/js/PluginUsagePage-Cp4j4-VZ.js +0 -1
  336. package/frontend/dist/js/RichMessageContent-BOY5jqj-.js +0 -1
  337. package/frontend/dist/js/SettingsModal-WAdVG4-g.js +0 -19
  338. package/frontend/dist/js/SystemPage-Dwi8leEQ.js +0 -1
  339. package/frontend/dist/js/UserManagementPanel-CfG67c_k.js +0 -1
  340. package/frontend/dist/js/WorkPage-D_cL9wp4.js +0 -8
  341. package/frontend/dist/js/api-29NO19CP.js +0 -14
  342. package/frontend/dist/js/api-DhafOTdF.js +0 -1
  343. package/frontend/dist/js/appVersion-BNuquyI6.js +0 -1
  344. package/frontend/dist/js/ar-WHne6B0o.js +0 -2
  345. package/frontend/dist/js/authStore-snvjjOuX.js +0 -1
  346. package/frontend/dist/js/bn-BZvCjqwO.js +0 -2
  347. package/frontend/dist/js/chatStore-BPpcL4I5.js +0 -3
  348. package/frontend/dist/js/composerStyles-bNlrIugf.js +0 -1
  349. package/frontend/dist/js/cs-DfSqWQ9V.js +0 -2
  350. package/frontend/dist/js/da-BmMLW4Dl.js +0 -2
  351. package/frontend/dist/js/de-BQMiQwQT.js +0 -2
  352. package/frontend/dist/js/es-DXf6jt4Z.js +0 -2
  353. package/frontend/dist/js/evaluationsApi-Btc9Mg9z.js +0 -1
  354. package/frontend/dist/js/fr-BD6nT1oc.js +0 -2
  355. package/frontend/dist/js/hi-BSuNic-8.js +0 -2
  356. package/frontend/dist/js/id-wodbwt3B.js +0 -2
  357. package/frontend/dist/js/is-CEjw-OJE.js +0 -2
  358. package/frontend/dist/js/it-X_pq8C7q.js +0 -2
  359. package/frontend/dist/js/ja-DWM2HZZd.js +0 -2
  360. package/frontend/dist/js/ko-DFi2khBB.js +0 -2
  361. package/frontend/dist/js/markdownMath-mesq3ZcY.js +0 -1
  362. package/frontend/dist/js/ms-DNQateTR.js +0 -2
  363. package/frontend/dist/js/nl-DSWhi8W8.js +0 -2
  364. package/frontend/dist/js/pl-W9WEDpZ3.js +0 -2
  365. package/frontend/dist/js/pt-DCCGvdNt.js +0 -2
  366. package/frontend/dist/js/react-vendor-D0Ec-185.js +0 -9
  367. package/frontend/dist/js/router-vendor-CM0PhOMl.js +0 -1
  368. package/frontend/dist/js/ru-D-Ww6dXe.js +0 -2
  369. package/frontend/dist/js/sv-B0Iry-H3.js +0 -2
  370. package/frontend/dist/js/th-CEZS0WeE.js +0 -2
  371. package/frontend/dist/js/tr-BFJ8TeYb.js +0 -2
  372. package/frontend/dist/js/ui-vendor-LatG6rFF.js +0 -177
  373. package/frontend/dist/js/uk-BmW3yDel.js +0 -2
  374. package/frontend/dist/js/useQuery-C3O4CZ54.js +0 -1
  375. package/frontend/dist/js/vi-Cu25FXnp.js +0 -2
  376. package/frontend/dist/js/work-DVgm81bJ.js +0 -1
  377. package/frontend/dist/js/workApi-BdUNugC3.js +0 -1
  378. package/frontend/dist/js/workApi-OieM8qEL.js +0 -6
  379. package/frontend/dist/js/zh-CuCAx3oH.js +0 -2
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{C as r,t as i}from"./useQuery-C3O4CZ54.js";import{t as a}from"./useTranslation-Kn7_iLGj.js";import{r as o,t as s}from"./utils-Dq1w7K0c.js";import{It as c,Rn as l,Sr as u,U as d,Xt as f,Z as p,ar as m,g as h,ht as g,jn as _,kt as v,sr as y,yr as b,z as x}from"./ui-vendor-LatG6rFF.js";import{n as S,t as C}from"./workApi-OieM8qEL.js";import{o as w}from"./api-29NO19CP.js";import{t as T}from"./authStore-Cm8P6rYs.js";import{t as E}from"./Button-ZQ6BePid.js";import{a as D,o as O}from"./ui-CNcEDQ95.js";var k=e(t(),1),A={getDrills:()=>S.get(`/recovery/drills`).then(e=>e.data),runDrill:()=>S.post(`/recovery/drills/run`).then(e=>e.data)},j=n(),M=e=>e===null?`—`:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`,N=e=>e===null?`—`:e>=3600?`${(e/3600).toFixed(1)} h`:e>=60?`${Math.round(e/60)} min`:`${e} s`,P=()=>{let{t:e}=a(),{user:t}=T(),[n,r]=(0,k.useState)(null),[i,o]=(0,k.useState)(!1),s=(0,k.useCallback)(async()=>{try{let e=await A.getDrills();e.success&&e.data&&r(e.data)}catch{}},[]);if((0,k.useEffect)(()=>{if(t?.role!==`admin`)return;let e=setTimeout(()=>void s(),0);return()=>clearTimeout(e)},[t?.role,s]),t?.role!==`admin`||!n)return null;let l=n.drills[0],d=n.drills.find(e=>e.status===`passed`),f=async()=>{o(!0);try{let t=await A.runDrill();t.success&&t.data?t.data.status===`passed`?u.success(e(`systemPage.recovery.passed`)):u.error(t.data.error||e(`systemPage.recovery.failed`)):u.error(t.message||e(`systemPage.recovery.failed`))}catch(t){let n=t;u.error(n.response?.data?.message||e(`systemPage.recovery.failed`))}finally{o(!1),await s()}};return(0,j.jsxs)(`section`,{"data-testid":`recovery-drills-panel`,className:`rounded-2xl border border-gray-200 bg-white p-4 dark:border-dark-200 dark:bg-dark-25`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100`,children:[(0,j.jsx)(b,{className:`h-4 w-4 text-primary-500`}),e(`systemPage.recovery.title`)]}),(0,j.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:n.supported?n.intervalHours?e(`systemPage.recovery.scheduleOn`,{hours:n.intervalHours}):e(`systemPage.recovery.scheduleOff`):e(`systemPage.recovery.teamUnsupported`)})]}),n.supported&&(0,j.jsx)(E,{size:`sm`,onClick:()=>void f(),disabled:i,children:i?(0,j.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(c,{className:`h-4 w-4 animate-spin`}),e(`systemPage.recovery.running`)]}):e(`systemPage.recovery.runNow`)})]}),d&&(0,j.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.lastPassed`)}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:new Date(d.startedAt).toLocaleString()})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.restoreTime`)}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d.restoreMs===null?`—`:`${(d.restoreMs/1e3).toFixed(1)} s`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.drillSpacing`)}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:N(d.rpoSeconds)})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.archiveSize`)}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:M(d.snapshotBytes)})]})]}),l&&l.status===`failed`&&(0,j.jsxs)(`p`,{className:`mt-3 rounded-lg bg-red-50 px-3 py-2 text-xs text-red-700 dark:bg-red-950/30 dark:text-red-300`,children:[e(`systemPage.recovery.lastFailed`,{date:new Date(l.startedAt).toLocaleString()}),l.error?` — ${l.error}`:``]}),n.drills.length>0&&(0,j.jsx)(`div`,{className:`mt-3 max-h-48 overflow-y-auto`,children:(0,j.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`text-left text-gray-500 dark:text-dark-500`,children:[(0,j.jsx)(`th`,{className:`py-1 pe-3 font-medium`,children:e(`systemPage.recovery.columns.when`)}),(0,j.jsx)(`th`,{className:`py-1 pe-3 font-medium`,children:e(`systemPage.recovery.columns.origin`)}),(0,j.jsx)(`th`,{className:`py-1 pe-3 font-medium`,children:e(`systemPage.recovery.columns.status`)}),(0,j.jsx)(`th`,{className:`py-1 font-medium`,children:e(`systemPage.recovery.columns.restore`)})]})}),(0,j.jsx)(`tbody`,{children:n.drills.slice(0,10).map(t=>(0,j.jsxs)(`tr`,{className:`border-t border-gray-100 text-gray-700 dark:border-dark-200 dark:text-dark-800`,children:[(0,j.jsx)(`td`,{className:`py-1 pe-3`,children:new Date(t.startedAt).toLocaleString()}),(0,j.jsx)(`td`,{className:`py-1 pe-3`,children:t.origin===`manual`?e(`systemPage.recovery.originManual`):e(`systemPage.recovery.originScheduled`)}),(0,j.jsx)(`td`,{className:`py-1 pe-3`,children:(0,j.jsx)(`span`,{className:t.status===`passed`?`text-green-600 dark:text-green-400`:t.status===`failed`?`text-red-600 dark:text-red-400`:`text-gray-500 dark:text-dark-500`,children:e(`systemPage.recovery.status.${t.status}`)})}),(0,j.jsx)(`td`,{className:`py-1`,children:t.restoreMs===null?`—`:`${(t.restoreMs/1e3).toFixed(1)} s`})]},t.id))})]})})]})},F=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),I=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),L=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),R=e=>{if(!Number.isFinite(e)||e<0)return`—`;if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${F.format(e/1024**n)} ${t[n]}`},z=e=>{if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/60),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:i>0?`${i}m`:`${Math.floor(e)}s`},B=e=>Math.min(100,Math.max(0,Number.isFinite(e)?e:0)),V=e=>{switch(e.toLowerCase()){case`running`:return`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`;case`paused`:return`bg-amber-500/10 text-amber-700 dark:text-amber-300`;case`exited`:case`dead`:return`bg-gray-500/10 text-gray-600 dark:text-dark-600`;default:return`bg-primary-500/10 text-primary-700 dark:text-primary-300`}},H=({title:e,description:t,icon:n,className:r,action:i,children:a})=>(0,j.jsxs)(`section`,{className:s(`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,r),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,j.jsx)(`div`,{className:`mt-0.5 rounded-xl bg-primary-500/10 p-1.5 text-primary-600 dark:text-primary-300`,children:(0,j.jsx)(n,{className:`h-4 w-4`})}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e}),t&&(0,j.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t})]})]}),i]}),a]}),U=({label:e,value:t,mono:n})=>(0,j.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-5 border-b border-gray-100 py-2 last:border-0 dark:border-white/[0.05]`,children:[(0,j.jsx)(`dt`,{className:`shrink-0 text-xs text-gray-500 dark:text-dark-500`,children:e}),(0,j.jsx)(`dd`,{className:s(`min-w-0 break-words text-end text-xs font-medium text-gray-800 dark:text-dark-800`,n&&`font-mono text-[11px]`),children:t})]}),W=({value:e,tone:t=`primary`})=>(0,j.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(B(e)),children:(0,j.jsx)(`div`,{className:s(`h-full rounded-full transition-[width] duration-300`,t===`warning`?`bg-amber-500 dark:bg-amber-400`:`bg-primary-500 dark:bg-primary-400`),style:{width:`${B(e)}%`}})}),G=()=>{let{t:e,i18n:t}=a(),n=r(),[s,c]=k.useState(!1),{data:l,error:d}=i({queryKey:[`work-admin-recovery`],queryFn:async()=>{let t=await C.adminRecovery();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.work.recovery.loadFailed`));return t.data},refetchInterval:15e3,refetchIntervalInBackground:!1}),f=t=>{switch(t){case`stop-failed`:return e(`systemPage.work.recovery.reasonStopFailed`);case`runtime-unreachable`:return e(`systemPage.work.recovery.reasonRuntimeUnreachable`);case`orphan`:return e(`systemPage.work.recovery.reasonOrphan`);default:return e(`systemPage.work.recovery.reasonStartup`)}},p=async()=>{c(!0);try{let t=await C.retryAdminRecovery();if(!t.success||!t.data){u.error(t.error||e(`systemPage.work.recovery.retryFailed`));return}let{attempted:n,cleared:r}=t.data;r>0?u.success(e(`systemPage.work.recovery.retrySucceeded`,{attempted:n,cleared:r})):u.error(e(`systemPage.work.recovery.retryPending`,{attempted:n}))}catch(t){u.error(t instanceof Error&&t.message?t.message:e(`systemPage.work.recovery.retryFailed`))}finally{c(!1),await n.invalidateQueries({queryKey:[`work-admin-recovery`]}),await n.invalidateQueries({queryKey:[`work-admin-overview`]})}};return(0,j.jsxs)(`div`,{"data-testid":`work-recovery-panel`,className:`mx-4 mt-4 rounded-xl border border-amber-500/30 bg-amber-500/5 sm:mx-5`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 px-4 py-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,j.jsx)(h,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e(`systemPage.work.recovery.title`)}),(0,j.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-600 dark:text-dark-600`,children:e(`systemPage.work.recovery.description`)})]})]}),(0,j.jsx)(E,{variant:`outline`,size:`sm`,"data-testid":`work-recovery-retry`,onClick:()=>void p(),disabled:s,children:e(s?`systemPage.work.recovery.retrying`:`systemPage.work.recovery.retry`)})]}),d&&!l?(0,j.jsx)(`p`,{className:`px-4 pb-3 text-xs text-red-700 dark:text-red-300`,children:d instanceof Error&&d.message?d.message:e(`systemPage.work.recovery.loadFailed`)}):(0,j.jsx)(`div`,{className:`overflow-x-auto`,children:(0,j.jsxs)(`table`,{className:`w-full min-w-[720px] text-sm`,children:[(0,j.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.container`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.task`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.reason`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.attempts`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.recovery.lastError`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`systemPage.work.recovery.nextAttempt`)})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-amber-500/20`,children:(l??[]).map(n=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{className:`px-4 py-2.5 font-mono text-[11px] text-gray-800 dark:text-dark-800`,children:n.containerName}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-700 dark:text-dark-700`,children:n.title?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:n.title}),n.ownerUsername&&(0,j.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:n.ownerUsername})]}):e(`systemPage.work.recovery.reasonOrphan`)}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-700 dark:text-dark-700`,children:f(n.reason)}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-700 dark:text-dark-700`,children:n.attempts}),(0,j.jsx)(`td`,{className:`max-w-xs px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:(0,j.jsx)(`span`,{className:`line-clamp-2`,children:n.lastError||`—`})}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-end text-xs text-gray-600 dark:text-dark-600`,children:n.nextAttemptAt?o(n.nextAttemptAt,t.language):e(`systemPage.work.recovery.notScheduled`)})]},`${n.kind}:${n.containerName}`))})]})})]})},K=()=>{let{t:e}=a(),{data:t,error:n,isFetching:r,refetch:o}=i({queryKey:[`work-admin-overview`],queryFn:async()=>{let t=await C.adminOverview();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1});if(!t)return n?(0,j.jsx)(H,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:m,children:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-4 sm:px-5`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3 text-sm text-red-700 dark:text-red-300`,children:[(0,j.jsx)(h,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,j.jsx)(`p`,{children:n instanceof Error&&n.message?n.message:e(`systemPage.loadFailed`)})]}),(0,j.jsx)(E,{variant:`outline`,size:`sm`,onClick:()=>void o(),disabled:r,children:e(`common.retry`)})]})}):null;let c=t=>e(t===null?`systemPage.work.stateUnknown`:t?`systemPage.work.stateRunning`:`systemPage.work.stateStopped`),l=t=>{if(!t||t.length===0)return e(`systemPage.work.inUseNone`);let n=new Map;for(let e of t)n.set(e.kind,(n.get(e.kind)??0)+1);return[...n.entries()].map(([t,n])=>`${n} ${e(`systemPage.work.usageKinds.${t}`)}`).join(`, `)},u=t=>{switch((t||``).split(`:`)[0]){case`completed`:return e(`work.runs.exitStates.completed`);case`needs_input`:return e(`work.runs.exitStates.needsInput`);case`failed`:return e(`work.runs.exitStates.failed`);case`cancelled`:return e(`work.runs.exitStates.cancelled`);default:return`—`}},d=t=>t===`running`?e(`systemPage.work.stateRunning`):t===`starting`?e(`systemPage.work.stateStarting`):`—`;return(0,j.jsxs)(H,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:m,action:(0,j.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,t.runtimeAvailable?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,j.jsx)(`span`,{className:s(`h-1.5 w-1.5 rounded-full`,t.runtimeAvailable?`bg-emerald-500`:`bg-gray-400`)}),t.runtimeAvailable?e(`systemPage.work.runtimeAvailable`):e(`systemPage.work.runtimeUnavailable`)]}),children:[(0,j.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[e(`systemPage.work.access`),t.accessMode===`all-users`?e(`systemPage.work.accessAllUsers`):e(`systemPage.work.accessAdmins`)],[e(`systemPage.work.activeRuntimes`),`${t.admission.activeGlobal} / ${t.admission.maxGlobal}`],[e(`systemPage.work.pendingCleanups`),t.recoveryPending],[e(`systemPage.work.orphans`),t.orphanContainers.length]].map(([e,t])=>(0,j.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,j.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),t.recoveryPending>0&&(0,j.jsx)(G,{}),!t.runtimeAvailable&&t.runtimeReason&&(0,j.jsxs)(`div`,{className:`mx-4 mt-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-3 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:mx-5`,children:[(0,j.jsx)(h,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,j.jsx)(`p`,{children:t.runtimeReason})]}),t.tasks.length===0?(0,j.jsx)(`p`,{className:`px-4 py-4 text-sm text-gray-500 dark:text-dark-500 sm:px-5`,children:e(`systemPage.work.noTasks`)}):(0,j.jsx)(`div`,{className:`overflow-x-auto`,children:(0,j.jsxs)(`table`,{"data-testid":`system-work-table`,className:`w-full min-w-[900px] text-sm`,children:[(0,j.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`systemPage.work.owner`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.task`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.state`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.preview`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.terminals`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.inUse`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.lastRun`)}),(0,j.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`systemPage.work.updated`)})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:t.tasks.map(t=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{className:`px-5 py-2.5 text-gray-800 dark:text-dark-800`,children:t.ownerUsername}),(0,j.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,j.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:t.model})]}),(0,j.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,j.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 text-xs`,t.running?`text-emerald-700 dark:text-emerald-300`:`text-gray-600 dark:text-dark-600`),children:[(0,j.jsx)(`span`,{className:s(`h-1.5 w-1.5 rounded-full`,t.running===null?`bg-amber-400`:t.running?`bg-emerald-500`:`bg-gray-400`)}),c(t.running)]})}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:d(t.previewStatus)}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:t.terminalSessions}),(0,j.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,"data-testid":`work-admin-usage`,children:l(t.usage)}),(0,j.jsx)(`td`,{className:`max-w-[240px] px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,"data-testid":`work-admin-last-run`,children:t.lastRun?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{title:t.lastRun.exitState,children:u(t.lastRun.exitState)}),t.lastRun.summary&&(0,j.jsx)(`div`,{dir:`auto`,className:`mt-0.5 truncate text-[10px] text-gray-500 dark:text-dark-500`,title:t.lastRun.summary,children:t.lastRun.summary})]}):e(`systemPage.work.noRun`)}),(0,j.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-600 dark:text-dark-600`,children:L.format(t.updatedAt)})]},t.id))})]})})]})},q=()=>{let{t:e}=a(),{data:t,error:n,isLoading:r,isFetching:o,refetch:l}=i({queryKey:[`system-diagnostics`],queryFn:async()=>{let t=await w.getDiagnostics();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1}),u=n?n instanceof Error?n.message:e(`systemPage.loadFailed`):null;return r&&!t?(0,j.jsx)(O,{width:`wide`,children:(0,j.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,j.jsx)(c,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,j.jsxs)(O,{width:`wide`,children:[(0,j.jsx)(D,{eyebrow:e(`systemPage.eyebrow`),title:e(`systemPage.title`),description:e(`systemPage.description`),actions:(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,j.jsx)(`span`,{className:`hidden text-xs text-gray-500 dark:text-dark-500 sm:inline`,children:e(`systemPage.updated`,{date:L.format(t.generatedAt)})}),(0,j.jsxs)(E,{variant:`outline`,size:`sm`,onClick:()=>void l(),disabled:o,children:[(0,j.jsx)(p,{className:s(`h-4 w-4`,o&&`animate-spin`)}),(0,j.jsx)(`span`,{className:`sr-only`,children:e(`systemPage.refresh`)})]})]})}),u&&(0,j.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,j.jsx)(h,{className:`h-4 w-4 shrink-0`}),(0,j.jsx)(`span`,{children:u})]}),t&&(0,j.jsxs)(`div`,{"data-testid":`system-dashboard`,className:`space-y-4`,children:[(0,j.jsx)(J,{diagnostics:t}),(0,j.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,j.jsx)(Y,{diagnostics:t}),(0,j.jsx)(X,{diagnostics:t})]}),(0,j.jsx)(Z,{diagnostics:t}),(0,j.jsx)(Q,{diagnostics:t}),(0,j.jsx)(K,{}),(0,j.jsx)(P,{}),(0,j.jsx)(ee,{diagnostics:t}),(0,j.jsxs)(`div`,{className:`flex items-start gap-2 px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:[(0,j.jsx)(x,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary-500`}),(0,j.jsx)(`p`,{children:e(`systemPage.securityNote`)})]})]})]})},J=({diagnostics:e})=>{let{t}=a(),n=e.filesystems.find(e=>e.label===`Data directory`)??e.filesystems[0],r=[{label:t(`systemPage.cards.uptime`),value:z(e.host.uptimeSeconds),detail:t(`systemPage.cards.uptimeDetail`,{date:L.format(e.host.bootedAt)}),icon:l},{label:t(`systemPage.cards.memory`),value:`${I.format(e.memory.usedPercent)}%`,detail:t(`systemPage.cards.memoryDetail`,{used:R(e.memory.usedBytes),total:R(e.memory.totalBytes)}),icon:v},{label:t(`systemPage.cards.freeSpace`),value:n?R(n.freeBytes):`—`,detail:n?t(`systemPage.cards.freeSpaceDetail`,{label:n.label,total:R(n.totalBytes)}):t(`systemPage.cards.unavailable`),icon:f},{label:t(`systemPage.cards.containers`),value:e.docker.available?String(e.docker.runningContainers):`—`,detail:e.docker.available?t(`systemPage.cards.containersDetail`,{total:e.docker.totalContainers}):t(`systemPage.cards.dockerUnavailable`),icon:_}];return(0,j.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:r.map(e=>{let t=e.icon;return(0,j.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,j.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,j.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,j.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})})},Y=({diagnostics:e})=>{let{t}=a(),{host:n,runtime:r}=e;return(0,j.jsx)(H,{title:t(`systemPage.host.title`),description:t(`systemPage.host.description`),icon:d,action:(0,j.jsx)(`span`,{className:`rounded-full bg-primary-500/10 px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em] text-primary-700 dark:text-primary-300`,children:n.containerized?t(`systemPage.host.container`):t(`systemPage.host.native`)}),children:(0,j.jsxs)(`dl`,{className:`px-4 py-2 sm:px-5`,children:[(0,j.jsx)(U,{label:t(`systemPage.host.hostname`),value:n.hostname}),(0,j.jsx)(U,{label:t(`systemPage.host.operatingSystem`),value:`${n.platform} ${n.release} · ${n.architecture}`}),(0,j.jsx)(U,{label:t(`systemPage.host.processor`),value:`${n.cpuModel} · ${n.logicalCpus} ${t(`systemPage.host.logicalCpus`)}`}),(0,j.jsx)(U,{label:t(`systemPage.host.loadAverage`),value:n.loadAverage.map(e=>I.format(e)).join(` · `)}),(0,j.jsx)(U,{label:t(`systemPage.host.libreVersion`),value:r.appVersion}),(0,j.jsx)(U,{label:t(`systemPage.host.nodeVersion`),value:r.nodeVersion}),(0,j.jsx)(U,{label:t(`systemPage.host.process`),value:`PID ${r.processId} · ${z(r.processUptimeSeconds)}`}),(0,j.jsx)(U,{label:t(`systemPage.host.workingDirectory`),value:r.workingDirectory,mono:!0})]})})},X=({diagnostics:e})=>{let{t}=a(),{memory:n}=e;return(0,j.jsx)(H,{title:t(`systemPage.memory.title`),description:t(`systemPage.memory.description`),icon:v,children:(0,j.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`mb-2 flex items-end justify-between gap-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`text-2xl tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:[I.format(n.usedPercent),`%`]}),(0,j.jsx)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.usedOf`,{used:R(n.usedBytes),total:R(n.totalBytes)})})]}),(0,j.jsx)(`span`,{className:`text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.free`,{value:R(n.freeBytes)})})]}),(0,j.jsx)(W,{value:n.usedPercent,tone:n.usedPercent>=85?`warning`:`primary`})]}),(0,j.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[t(`systemPage.memory.processRss`),n.processRssBytes],[t(`systemPage.memory.heapUsed`),n.heapUsedBytes],[t(`systemPage.memory.heapTotal`),n.heapTotalBytes],[t(`systemPage.memory.external`),n.externalBytes]].map(([e,t])=>(0,j.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,j.jsx)(`div`,{className:`mt-1 text-lg text-gray-950 dark:text-dark-950`,children:R(Number(t))})]},String(e)))})]})})},Z=({diagnostics:e})=>{let{t}=a();return(0,j.jsx)(H,{title:t(`systemPage.storage.title`),description:t(`systemPage.storage.description`),icon:f,children:e.filesystems.length===0?(0,j.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.storage.empty`)}):(0,j.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5`,children:e.filesystems.map(e=>(0,j.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e.label}),(0,j.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.path})]}),(0,j.jsxs)(`span`,{className:`shrink-0 text-sm tabular-nums text-gray-700 dark:text-dark-700`,children:[I.format(e.usedPercent),`%`]})]}),(0,j.jsx)(`div`,{className:`mt-4`,children:(0,j.jsx)(W,{value:e.usedPercent,tone:e.usedPercent>=85?`warning`:`primary`})}),(0,j.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,j.jsx)(`span`,{children:t(`systemPage.storage.used`,{value:R(e.usedBytes)})}),(0,j.jsx)(`span`,{children:t(`systemPage.storage.free`,{value:R(e.freeBytes)})})]})]},`${e.label}:${e.path}`))})})},Q=({diagnostics:e})=>{let{t}=a(),{docker:n}=e;return(0,j.jsx)(H,{title:t(`systemPage.docker.title`),description:t(`systemPage.docker.description`),icon:_,action:(0,j.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,n.available?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-gray-500/10 text-gray-600 dark:text-dark-600`),children:[(0,j.jsx)(`span`,{className:s(`h-1.5 w-1.5 rounded-full`,n.available?`bg-emerald-500`:`bg-gray-400`)}),n.available?t(`systemPage.docker.connected`):t(`systemPage.docker.unavailable`)]}),children:n.available?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`grid gap-3 border-b border-gray-200/70 p-4 dark:border-white/[0.07] sm:grid-cols-2 sm:p-5 lg:grid-cols-4`,children:[[t(`systemPage.docker.running`),n.runningContainers],[t(`systemPage.docker.stopped`),n.stoppedContainers],[t(`systemPage.docker.paused`),n.pausedContainers],[t(`systemPage.docker.total`),n.totalContainers]].map(([e,t])=>(0,j.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,j.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,j.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-4 sm:px-5`,children:[n.serverVersion&&(0,j.jsx)($,{label:t(`systemPage.docker.version`),value:n.serverVersion}),n.operatingSystem&&(0,j.jsx)($,{label:t(`systemPage.docker.host`),value:n.operatingSystem}),n.architecture&&(0,j.jsx)($,{label:t(`systemPage.docker.architecture`),value:n.architecture}),n.logicalCpus!==void 0&&(0,j.jsx)($,{label:t(`systemPage.docker.cpus`),value:String(n.logicalCpus)}),n.memoryBytes!==void 0&&(0,j.jsx)($,{label:t(`systemPage.docker.memory`),value:R(n.memoryBytes)})]}),n.containers.length===0?(0,j.jsx)(`p`,{className:`px-5 pb-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.empty`)}):(0,j.jsx)(`div`,{className:`overflow-x-auto border-t border-gray-200/70 dark:border-white/[0.07]`,children:(0,j.jsxs)(`table`,{"data-testid":`system-docker-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,j.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:t(`systemPage.docker.container`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.image`)}),(0,j.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.state`)}),(0,j.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:t(`systemPage.docker.created`)})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:n.containers.map(e=>(0,j.jsxs)(`tr`,{children:[(0,j.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,j.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.id})]}),(0,j.jsx)(`td`,{className:`max-w-[280px] px-4 py-2.5`,children:(0,j.jsx)(`div`,{className:`truncate font-mono text-[11px] text-gray-600 dark:text-dark-600`,title:e.image,children:e.image})}),(0,j.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,j.jsx)(`span`,{className:s(`inline-flex rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.08em]`,V(e.state)),children:e.state}),(0,j.jsx)(`div`,{className:`mt-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:e.status})]}),(0,j.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-500 dark:text-dark-500`,children:e.createdAt?L.format(e.createdAt):`—`})]},e.id))})]})})]}):(0,j.jsxs)(`div`,{className:`m-4 flex items-start gap-3 rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 text-sm text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/60 dark:text-dark-600 sm:m-5`,children:[(0,j.jsx)(h,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{children:n.reason||t(`systemPage.docker.unavailableDetail`)}),(0,j.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.socketStatus`,{status:n.socketMounted?t(`systemPage.docker.mounted`):t(`systemPage.docker.notMounted`)})})]})]})})},$=({label:e,value:t})=>(0,j.jsxs)(`span`,{className:`rounded-full border border-gray-200 bg-white px-3 py-1.5 text-[11px] text-gray-600 dark:border-white/[0.07] dark:bg-dark-200/70 dark:text-dark-600`,children:[(0,j.jsx)(`span`,{className:`text-gray-400 dark:text-dark-500`,children:e}),` `,t]}),ee=({diagnostics:e})=>{let{t}=a();return(0,j.jsx)(H,{title:t(`systemPage.network.title`),description:t(`systemPage.network.description`),icon:g,children:e.network.interfaces.length===0?(0,j.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.network.empty`)}):(0,j.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5 xl:grid-cols-3`,children:e.network.interfaces.map(e=>(0,j.jsxs)(`div`,{className:`rounded-xl border border-gray-200/80 bg-gray-50/70 p-4 dark:border-white/[0.06] dark:bg-dark-200/55`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(y,{className:`h-4 w-4 text-primary-500`}),(0,j.jsx)(`h3`,{className:`font-mono text-xs font-medium text-gray-900 dark:text-dark-900`,children:e.name})]}),(0,j.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.addresses.map(e=>(0,j.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-white px-3 py-2 dark:bg-dark-100/80`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,j.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-gray-400 dark:text-dark-500`,children:e.family}),e.internal&&(0,j.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`systemPage.network.internal`)})]}),(0,j.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-gray-700 dark:text-dark-700`,children:e.cidr||e.address})]},`${e.family}:${e.address}`))}),(e.receivedBytes!==void 0||e.transmittedBytes!==void 0)&&(0,j.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[10px] text-gray-500 dark:text-dark-500`,children:[(0,j.jsxs)(`span`,{children:[`↓ `,R(e.receivedBytes??0)]}),(0,j.jsxs)(`span`,{children:[`↑ `,R(e.transmittedBytes??0)]})]})]},e.name))})})};export{q as default};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-D0Ec-185.js";import{C as r,t as i}from"./useQuery-C3O4CZ54.js";import{a}from"./logger-BR4forr_.js";import{t as o}from"./useTranslation-Kn7_iLGj.js";import{t as s}from"./utils-Dq1w7K0c.js";import{E as c,G as l,I as u,Jn as d,K as f,R as p,Rn as m,Sr as h,T as g,Xn as _,Z as v,_t as y,c as b,d as x,et as S,f as C,j as w,jt as T,ot as E,s as D,v as O,vt as k,xt as A}from"./ui-vendor-LatG6rFF.js";import{n as j,r as M,t as N}from"./workApi-OieM8qEL.js";import{F as P,L as F,T as I,d as L,s as R,w as z,x as B,y as V,z as H}from"./api-29NO19CP.js";import{t as U}from"./authStore-Cm8P6rYs.js";import{c as W,t as ee}from"./appStore-Din-tTD9.js";import{t as G}from"./Button-ZQ6BePid.js";import{c as K,f as q,m as J,n as te}from"./ui-CNcEDQ95.js";import{t as ne}from"./PasswordStrengthMeter-BJr4eBbo.js";import{t as Y}from"./SettingsToggle-CKLHOUt-.js";var X=e(t(),1),Z=n(),re=`h-11 w-full rounded-xl border border-line bg-surface-raised px-3 text-sm text-ink focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-60`;function ie(e,t){return e?.response?.data?.message||(e instanceof Error?e.message:t)||t}function ae({user:e,currentUserId:t,onClose:n,onSaved:r}){let{t:i}=o(),[a,s]=(0,X.useState)({username:e?.username??``,email:e?.email??``,password:``,role:e?.role??`user`}),[c,l]=(0,X.useState)(!1),u=(0,X.useRef)(!1),[d,f]=(0,X.useState)(``),p=e?.id===t,m=()=>{u.current||n()};return(0,Z.jsx)(te,{titleId:`user-form-title`,title:i(e?`userManager.form.title.edit`:`userManager.form.title.create`),subtitle:e?(0,Z.jsx)(`span`,{className:`break-all`,children:e.username}):i(`userManager.subtitle`),onClose:m,testId:`user-form-dialog`,children:(0,Z.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),u.current)return;u.current=!0,l(!0),f(``);let n=i(e?`userManager.form.updateFailed`:`userManager.form.createFailed`);try{let t={username:a.username.trim(),email:a.email.trim()||null,role:p?e.role:a.role};a.password&&(t.password=a.password);let o=e?await H.updateUser(e.id,t):await H.createUser({...a,username:a.username.trim(),email:a.email.trim()});if(!o.success||!o.data)throw Error(o.message||n);r(o.data),h.success(i(e?`userManager.form.updateSuccess`:`userManager.form.createSuccess`))}catch(e){f(ie(e,n))}finally{u.current=!1,l(!1)}},className:`space-y-5`,"aria-busy":c,children:[(0,Z.jsxs)(`fieldset`,{disabled:c,className:`min-w-0 space-y-4`,children:[(0,Z.jsx)(J,{id:`user-form-username`,label:i(`userManager.form.username`),autoFocus:!0,autoComplete:`off`,value:a.username,onChange:e=>s({...a,username:e.target.value}),required:!0}),(0,Z.jsx)(J,{id:`user-form-email`,label:`${i(`userManager.form.email`)}${e?` (${i(`common.optional`)})`:``}`,type:`email`,dir:`ltr`,autoComplete:`off`,value:a.email,onChange:e=>s({...a,email:e.target.value}),required:!e}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(J,{id:`user-form-password`,label:`${i(`userManager.form.password`)}${e?` (${i(`common.optional`)})`:``}`,type:`password`,autoComplete:`new-password`,value:a.password,onChange:e=>s({...a,password:e.target.value}),required:!e,helper:e?i(`userManager.form.passwordHint`):void 0}),(0,Z.jsx)(ne,{password:a.password})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(K,{htmlFor:`user-form-role`,children:i(`userManager.form.role`)}),(0,Z.jsxs)(`select`,{id:`user-form-role`,value:a.role,onChange:e=>s({...a,role:e.target.value}),disabled:p,"aria-describedby":p?`user-form-role-hint`:void 0,className:re,children:[(0,Z.jsx)(`option`,{value:`user`,children:i(`userManager.roles.user`)}),(0,Z.jsx)(`option`,{value:`admin`,children:i(`userManager.roles.admin`)})]}),p&&(0,Z.jsx)(`p`,{id:`user-form-role-hint`,className:`text-xs text-ink-muted`,children:i(`userManager.directory.editSelfRole`)})]})]}),d&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:d}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-line pt-4`,children:[(0,Z.jsx)(G,{type:`button`,variant:`outline`,onClick:m,disabled:c,className:`min-h-11`,children:i(`common.cancel`)}),(0,Z.jsx)(G,{type:`submit`,loading:c,disabled:!a.username.trim(),className:`min-h-11`,children:i(c?e?`userManager.form.updating`:`userManager.form.creating`:e?`userManager.form.updateButton`:`userManager.form.createButton`)})]})]})})}var oe=()=>{let{t:e,i18n:t}=o(),n=r(),a=U(e=>e.user),s=U(e=>e.setUser),[c,d]=(0,X.useState)(null),[f,g]=(0,X.useState)(``),[_,y]=(0,X.useState)(`all`),[x,T]=(0,X.useState)(null),[E,k]=(0,X.useState)(``),[A,j]=(0,X.useState)(null),M=(0,X.useRef)(!1),{data:N=[],isLoading:P,isError:F,isFetching:I,refetch:L}=i({queryKey:[`users`],queryFn:async()=>{let t=await H.getUsers();if(!t.success||!t.data)throw Error(e(`userManager.directory.loadFailed`));return t.data}}),R=()=>{n.invalidateQueries({queryKey:[`users`]})},z=e=>{n.setQueryData([`users`],(t=[])=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),e.id===a?.id&&s(e),d(null),R()},B=f.trim().toLocaleLowerCase(t.language),V=N.filter(e=>(_===`all`||e.role===_)&&`${e.username} ${e.email??``}`.toLocaleLowerCase(t.language).includes(B)),W=V.filter(e=>e.status===`pending`),ee=V.filter(e=>e.status!==`pending`),q=N.filter(e=>e.status===`pending`).length,ne=N.length-q,Y=!!(f||_!==`all`),oe=()=>{g(``),y(`all`)},se=async t=>{if(!M.current){M.current=!0,j(t.id);try{let n=await H.approveUser(t.id);if(!n.success||!n.data)throw Error(n.message||e(`userManager.approval.failed`));z(n.data),h.success(e(`userManager.approval.approved`,{name:t.username}))}catch(t){h.error(ie(t,e(`userManager.approval.failed`)))}finally{M.current=!1,j(null)}}},ce=async()=>{if(!x||M.current||x.kind===`delete`&&x.user.id===a?.id)return;M.current=!0,j(x.user.id),k(``);let t=e(x.kind===`delete`?`userManager.deleteFailed`:`userManager.mfaResetFailed`);try{if(x.kind===`delete`){let r=await H.deleteUser(x.user.id);if(!r.success)throw Error(r.message||t);n.setQueryData([`users`],(e=[])=>e.filter(e=>e.id!==x.user.id)),R(),h.success(e(`userManager.deleteSuccess`))}else{let n=await H.resetUserMfa(x.user.id);if(!n.success)throw Error(n.message||t);h.success(e(n.data?.removed?`userManager.mfaResetSuccess`:`userManager.mfaResetNothing`,{name:x.user.username}))}T(null)}catch(e){k(ie(e,t))}finally{M.current=!1,j(null)}},le=(e,t)=>{k(``),T({kind:e,user:t})},ue=n=>(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-surface-subtle text-ink-muted`,"aria-hidden":`true`,children:n.status===`pending`?(0,Z.jsx)(m,{size:18}):n.role===`admin`?(0,Z.jsx)(u,{size:18}):(0,Z.jsx)(b,{size:18})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`h3`,{className:`min-w-0 break-all text-sm font-medium text-ink`,children:(0,Z.jsx)(`bdi`,{children:n.username})}),n.id===a?.id&&(0,Z.jsxs)(`span`,{className:`text-xs text-ink-muted`,children:[`(`,e(`chatMessage.you`),`)`]}),(0,Z.jsx)(`span`,{className:`rounded-md border border-line px-1.5 py-0.5 text-xs text-ink-muted`,children:e(n.role===`admin`?`userManager.roles.admin`:`userManager.roles.user`)})]}),(0,Z.jsx)(`p`,{className:`mt-1 break-all text-sm text-ink-muted`,children:(0,Z.jsx)(`bdi`,{children:n.email||e(`userManager.noEmail`)})}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(n.status===`pending`?`userManager.approval.registered`:`userManager.columns.created`),`: `,new Date(n.createdAt).toLocaleDateString(t.language)]})]})]}),de=e=>(0,Z.jsxs)(`div`,{className:`px-4 py-8 text-center`,children:[(0,Z.jsx)(D,{size:24,className:`mx-auto mb-3 text-ink-subtle`,"aria-hidden":`true`}),(0,Z.jsx)(`p`,{className:`text-sm text-ink-muted`,children:e})]});return(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-5`,"data-testid":`user-directory`,children:[(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-line bg-surface p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`relative min-w-0 basis-full sm:flex-1 sm:basis-48`,children:[(0,Z.jsx)(l,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute start-3.5 top-3.5 text-ink-subtle`}),(0,Z.jsx)(J,{type:`search`,"aria-label":e(`userManager.search`),placeholder:e(`userManager.search`),value:f,onChange:e=>g(e.target.value),className:`ps-10`})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 sm:max-w-36`,children:[(0,Z.jsx)(K,{htmlFor:`user-role-filter`,className:`sr-only`,children:e(`userManager.columns.role`)}),(0,Z.jsxs)(`select`,{id:`user-role-filter`,value:_,onChange:e=>y(e.target.value),className:re,children:[(0,Z.jsx)(`option`,{value:`all`,children:e(`userManager.directory.allRoles`)}),(0,Z.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)}),(0,Z.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)})]})]}),(0,Z.jsx)(G,{type:`button`,variant:`outline`,onClick:()=>void L(),disabled:I,className:`min-h-11 min-w-11 px-3`,"aria-label":e(`common.refresh`),title:e(`common.refresh`),children:(0,Z.jsx)(v,{size:16,"aria-hidden":`true`,className:I?`animate-spin motion-reduce:animate-none`:void 0})}),(0,Z.jsxs)(G,{type:`button`,onClick:()=>d(`create`),disabled:!!A,className:`min-h-11`,children:[(0,Z.jsx)(S,{size:16,"aria-hidden":`true`}),e(`userManager.createUser`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex min-h-5 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{role:`status`,className:`text-xs text-ink-muted`,children:P?e(`userManager.loading`):e(`userManager.directory.results`,{visible:V.length,total:N.length})}),Y&&(0,Z.jsx)(G,{type:`button`,size:`sm`,variant:`ghost`,onClick:oe,className:`min-h-11 sm:min-h-8`,children:e(`userManager.directory.clearFilters`)})]})]}),F&&(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-error-500/30 p-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-ink`,children:e(`userManager.directory.loadFailed`)}),(0,Z.jsx)(G,{type:`button`,variant:`outline`,onClick:()=>void L(),disabled:I,children:e(`common.retry`)})]}),!P&&(!F||N.length>0)&&(0,Z.jsxs)(Z.Fragment,{children:[q>0&&(0,Z.jsxs)(`section`,{"data-testid":`pending-user-approvals`,"aria-labelledby":`pending-users-title`,className:`overflow-hidden rounded-2xl border border-warning-500/30 bg-surface`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-line bg-warning-500/[0.06] p-4`,children:[(0,Z.jsxs)(`h3`,{id:`pending-users-title`,className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,Z.jsx)(m,{size:16,"aria-hidden":`true`,className:`text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`),` `,(0,Z.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,q,`)`]})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-ink-muted`,children:e(`userManager.approval.description`)})]}),(0,Z.jsxs)(`div`,{className:`divide-y divide-line`,children:[W.map(t=>(0,Z.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-3 p-4 xl:flex-row xl:items-center xl:justify-between`,children:[ue(t),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,Z.jsxs)(G,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void se(t),disabled:!!A,loading:A===t.id,className:`min-h-11 sm:min-h-9`,children:[(0,Z.jsx)(C,{size:16,"aria-hidden":`true`}),e(`userManager.approval.activate`)]}),(0,Z.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>le(`delete`,t),disabled:!!A,className:`min-h-11 sm:min-h-9`,children:e(`userManager.approval.reject`)})]})]},t.id)),W.length===0&&de(e(`userManager.noUsersMatching`))]})]}),(0,Z.jsxs)(`section`,{"aria-labelledby":`active-users-title`,className:`overflow-hidden rounded-2xl border border-line bg-surface`,children:[(0,Z.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,Z.jsxs)(`h3`,{id:`active-users-title`,className:`text-sm font-semibold text-ink`,children:[e(`userManager.directory.title`),` `,(0,Z.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,ne,`)`]})]})}),(0,Z.jsxs)(`div`,{className:`divide-y divide-line`,children:[ee.map(t=>(0,Z.jsxs)(`div`,{"data-testid":`user-row`,className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[ue(t),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsxs)(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>d(t),disabled:!!A,"aria-label":`${e(`common.edit`)}: ${t.username}`,className:`min-h-11 sm:min-h-9`,children:[(0,Z.jsx)(w,{size:15,"aria-hidden":`true`}),e(`common.edit`)]}),(0,Z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-mfa-button`,"aria-label":`${e(`userManager.mfaReset`)}: ${t.username}`,title:e(`userManager.mfaReset`),onClick:()=>le(`reset`,t),disabled:!!A,className:`min-h-11 min-w-11 sm:min-h-9 sm:min-w-9 px-2`,children:(0,Z.jsx)(p,{size:16,"aria-hidden":`true`})}),(0,Z.jsx)(G,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":`${e(`common.delete`)}: ${t.username}`,title:t.id===a?.id?e(`userManager.cannotDeleteSelf`):e(`common.delete`),onClick:()=>le(`delete`,t),disabled:t.id===a?.id||!!A,className:`min-h-11 min-w-11 sm:min-h-9 sm:min-w-9 px-2 text-error-600 dark:text-error-400`,children:(0,Z.jsx)(O,{size:16,"aria-hidden":`true`})})]})]},t.id)),ee.length===0&&de(e(Y?`userManager.noUsersMatching`:`userManager.directory.empty`))]})]})]}),c&&(0,Z.jsx)(ae,{user:c===`create`?null:c,currentUserId:a?.id,onClose:()=>d(null),onSaved:z},c===`create`?`create`:c.id),x&&(0,Z.jsxs)(te,{titleId:`user-action-title`,title:e(x.kind===`reset`?`userManager.mfaReset`:x.user.status===`pending`?`userManager.approval.reject`:`userManager.directory.deleteTitle`),onClose:()=>{M.current||T(null)},testId:`user-action-dialog`,children:[(0,Z.jsx)(`p`,{className:`break-words text-sm leading-relaxed text-ink-muted`,children:e(x.kind===`delete`?`userManager.deleteConfirm`:`userManager.mfaResetConfirm`,{name:x.user.username})}),E&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error-600 dark:text-error-400`,children:E}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-line pt-4`,children:[(0,Z.jsx)(G,{type:`button`,variant:`outline`,onClick:()=>T(null),disabled:!!A,className:`min-h-11`,children:e(`common.cancel`)}),(0,Z.jsx)(G,{type:`button`,variant:`danger`,loading:!!A,onClick:()=>void ce(),className:`min-h-11`,children:e(x.kind===`delete`?`common.delete`:`userManager.mfaReset`)})]})]})]})},se=()=>{let{t:e}=o(),t=U(e=>e.systemInfo),n=U(e=>e.setSystemInfo),[r,i]=(0,X.useState)(null),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return B.access().then(t=>{e||(t.success&&t.data?(i(t.data.enabled),s(t.data.lockedByEnv)):d(!0))}).catch(()=>{e||d(!0)}),()=>{e=!0}},[f]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.agentAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.agentAccess.description`)}),a&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.agentAccess.lockedByEnv`)})]}),r===null&&u?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{d(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:r===!0,onChange:async r=>{l(!0);try{let a=await B.setAccess(r);if(!a.success||!a.data)throw Error(a.error||`Agent access update failed.`);i(a.data.enabled),t&&n({...t,agentsEnabled:a.data.enabled}),h.success(e(`userManager.agentAccess.saved`))}catch{h.error(e(`userManager.agentAccess.saveFailed`))}finally{l(!1)}},disabled:c||r===null||a})]})})},ce=[{mode:`light`,icon:c,key:`settings.appearance.theme.light`},{mode:`dark`,icon:y,key:`settings.appearance.theme.dark`},{mode:`amoled`,icon:k,key:`settings.appearance.theme.amoled`},{mode:`celestial`,icon:g,key:`settings.appearance.theme.celestial`}],le=()=>{let{t:e}=o(),t=U(e=>e.systemInfo),n=U(e=>e.setSystemInfo),r=ee(e=>e.applyInstanceTheme),[i,a]=(0,X.useState)(null),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return R.getDefaultTheme().then(t=>{e||(t.success&&t.data?a(W(t.data.theme)):d(!0))}).catch(()=>{e||d(!0)}),()=>{e=!0}},[f]);let m=async o=>{if(i&&i.mode!==o){l(!0);try{let s=await R.setDefaultTheme({...i,mode:o});if(!s.success||!s.data)throw Error(s.error||`Default theme update failed.`);let c=W(s.data.theme);a(c),t&&n({...t,defaultTheme:c}),r(c),h.success(e(`userManager.defaultTheme.saved`))}catch{h.error(e(`userManager.defaultTheme.saveFailed`))}finally{l(!1)}}};return(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-[1_1_18rem]`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.defaultTheme.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.defaultTheme.description`)})]}),i===null&&u?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{d(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`userManager.defaultTheme.title`),className:`flex max-w-full flex-wrap gap-2`,children:ce.map(({mode:t,icon:n,key:r})=>{let a=i?.mode===t;return(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":a,disabled:c||i===null,onClick:()=>void m(t),className:s(`flex min-h-11 max-w-full items-center gap-2 rounded-lg border px-3 py-2 text-sm text-ink transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40 disabled:cursor-not-allowed disabled:opacity-60`,a?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Z.jsx)(n,{className:`h-4 w-4`,"aria-hidden":`true`}),e(r)]},t)})})]})})},ue=()=>{let{t:e}=o(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return L.getAccessMode().then(t=>{e||(t.success&&t.data?(n(t.data.mode),i(t.data.lockedByEnv)):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.tools.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.tools.description`)}),r&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.tools.lockedByEnv`)})]}),t===null&&c?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),d(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;s(!0);try{let t=await L.setAccessMode(r);if(!t.success)throw Error(t.error||`Tool access update failed.`);n(r),h.success(e(`userManager.tools.saved`))}catch{h.error(e(`userManager.tools.saveFailed`))}finally{s(!1)}},disabled:a||t===null||r})]})})},de={stt:{mode:`all-users`,lockedByEnv:!1},tts:{mode:`all-users`,lockedByEnv:!1},"voice-mode":{mode:`all-users`,lockedByEnv:!1},"voice-cloning":{mode:`all-users`,lockedByEnv:!1}},fe={getModes:async()=>a()?M(de):(await j.get(`/voice-access`)).data,setMode:async(e,t)=>a()?M({feature:e,mode:t}):(await j.put(`/voice-access/${encodeURIComponent(e)}`,{mode:t})).data},pe=[{key:`stt`,labelKey:`userManager.voice.features.stt`},{key:`tts`,labelKey:`userManager.voice.features.tts`},{key:`voice-mode`,labelKey:`userManager.voice.features.voiceMode`},{key:`voice-cloning`,labelKey:`userManager.voice.features.voiceCloning`}],me=()=>{let{t:e}=o(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return fe.getModes().then(t=>{e||(t.success&&t.data?n(t.data):s(!0))}).catch(()=>{e||s(!0)}),()=>{e=!0}},[c]);let u=async(t,r)=>{let a=r?`all-users`:`admins`;i(t);try{let r=await fe.setMode(t,a);if(!r.success)throw Error(r.error||`Voice access update failed.`);n(e=>e&&{...e,[t]:{...e[t],mode:a}}),h.success(e(`userManager.voice.saved`))}catch{h.error(e(`userManager.voice.saveFailed`))}finally{i(null)}};return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.voice.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.voice.description`)})]}),t===null&&a&&(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{s(!1),l(e=>e+1)},children:e(`common.retry`)})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:pe.map(n=>{let i=t?.[n.key];return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:e(n.labelKey)}),i?.lockedByEnv&&(0,Z.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:e(`userManager.voice.lockedByEnv`)})]}),(0,Z.jsx)(Y,{checked:i?.mode===`all-users`,onChange:e=>u(n.key,e),disabled:i===void 0||r===n.key||i.lockedByEnv})]},n.key)})})]})},he=[`starttls`,`tls`,`none`],ge=e=>({host:e.host??``,port:e.port?String(e.port):``,security:e.security??`starttls`,username:e.username??``,password:``,from:e.from??``,appUrl:e.appUrl??``,rejectUnauthorized:e.rejectUnauthorized!==!1}),_e=()=>{let{t:e}=o(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),[a,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return z.getSettings().then(t=>{e||(t.success&&t.data?(n(t.data),i(ge(t.data)),s(t.data.recipient??``)):g(!0))}).catch(()=>{e||g(!0)}),()=>{e=!0}},[_]);let y=e=>{n(e),i(ge(e)),p(!1)},b=(e,t)=>{let n=e.response?.data;return n?.error?n.error:n?.message?n.message:e instanceof Error&&e.message?e.message:t},x=async()=>{if(r){l(!0);try{let t=await z.updateSettings({host:r.host.trim(),port:r.port.trim(),security:r.security,username:r.username.trim(),from:r.from.trim(),appUrl:r.appUrl.trim(),rejectUnauthorized:r.rejectUnauthorized,...r.password?{password:r.password}:f?{password:``}:{}});if(!t.success||!t.data)throw Error(t.error||e(`userManager.emailNotifications.saveFailed`));y(t.data),h.success(e(`userManager.emailNotifications.saved`))}catch(t){h.error(b(t,e(`userManager.emailNotifications.saveFailed`)))}finally{l(!1)}}},S=async t=>{l(!0);try{let n=await z.updateSettings({enabled:t});if(!n.success||!n.data)throw Error(n.error||e(`userManager.emailNotifications.saveFailed`));y(n.data),h.success(e(t?`userManager.emailNotifications.enabledToast`:`userManager.emailNotifications.disabledToast`))}catch(t){h.error(b(t,e(`userManager.emailNotifications.saveFailed`)))}finally{l(!1)}},C=async()=>{d(!0);try{let t=await z.test(a.trim()||void 0);if(!t.success||!t.data?.ok)throw Error(t.error||e(`userManager.emailNotifications.testFailed`));h.success(t.data.sentTo?e(`userManager.emailNotifications.testSent`,{address:t.data.sentTo}):e(`userManager.emailNotifications.testConnected`))}catch(t){h.error(b(t,e(`userManager.emailNotifications.testFailed`)))}finally{d(!1)}},w=(e,t)=>i(n=>n&&{...n,[e]:t}),E=n=>t?.sources?.[n]===`env`?e(`userManager.emailNotifications.fromEnvironment`):null,D=t!==null&&r!==null&&(JSON.stringify(ge(t))!==JSON.stringify({...r,password:``})||r.password.length>0||f),O=`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,k=`mb-2 block text-xs text-gray-500 dark:text-gray-400`;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-4`,"data-testid":`email-notification-settings`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(T,{className:`h-4 w-4 text-primary-500`}),e(`userManager.emailNotifications.title`)]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.emailNotifications.description`)})]}),(0,Z.jsx)(`div`,{"data-testid":`email-notifications-enabled`,children:(0,Z.jsx)(Y,{checked:t?.enabled===!0,onChange:e=>void S(e),disabled:c||t===null||!t.enabled&&!t.configured})})]}),m&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,Z.jsx)(`span`,{children:e(`userManager.emailNotifications.loadFailed`)}),(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{g(!1),v(e=>e+1)},children:e(`common.retry`)})]}),r&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[2fr_1fr]`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.hostLabel`)}),(0,Z.jsx)(`span`,{className:k,children:E(`host`)??e(`userManager.emailNotifications.hostHint`)}),(0,Z.jsx)(J,{value:r.host,onChange:e=>w(`host`,e.target.value),placeholder:`smtp.example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-host`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.portLabel`)}),(0,Z.jsx)(`span`,{className:k,children:E(`port`)??e(`userManager.emailNotifications.portHint`)}),(0,Z.jsx)(J,{type:`number`,min:1,max:65535,value:r.port,onChange:e=>w(`port`,e.target.value),placeholder:r.security===`tls`?`465`:`587`,dir:`ltr`,"data-testid":`email-smtp-port`})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.securityLabel`)}),(0,Z.jsx)(`span`,{className:k,children:E(`security`)??e(`userManager.emailNotifications.securityHint`)}),(0,Z.jsx)(q,{value:r.security,onChange:e=>w(`security`,e.target.value),options:he.map(t=>({value:t,label:e(`userManager.emailNotifications.security.${t}`)})),"data-testid":`email-smtp-security`})]}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4 sm:pt-1`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.verifyLabel`)}),(0,Z.jsx)(`span`,{className:`block text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.emailNotifications.verifyHint`)})]}),(0,Z.jsx)(Y,{checked:r.rejectUnauthorized,onChange:e=>w(`rejectUnauthorized`,e),disabled:c||r.security===`none`})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.usernameLabel`)}),(0,Z.jsx)(`span`,{className:k,children:E(`username`)??e(`userManager.emailNotifications.usernameHint`)}),(0,Z.jsx)(J,{value:r.username,onChange:e=>w(`username`,e.target.value),autoComplete:`off`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-username`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.passwordLabel`)}),(0,Z.jsx)(`span`,{className:k,children:E(`password`)??(t?.passwordConfigured?e(`userManager.emailNotifications.passwordStored`):e(`userManager.emailNotifications.passwordHint`))}),(0,Z.jsx)(J,{type:`password`,value:r.password,onChange:e=>{w(`password`,e.target.value),e.target.value&&p(!1)},autoComplete:`new-password`,placeholder:t?.passwordConfigured?`••••••••`:``,dir:`ltr`,"data-testid":`email-smtp-password`}),t?.passwordConfigured&&t.sources?.password===`stored`&&!r.password&&(0,Z.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),e(`userManager.emailNotifications.clearPassword`)]})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.fromLabel`)}),(0,Z.jsx)(`span`,{className:k,children:E(`from`)??e(`userManager.emailNotifications.fromHint`)}),(0,Z.jsx)(J,{value:r.from,onChange:e=>w(`from`,e.target.value),placeholder:`Libre WebUI <notifications@example.com>`,spellCheck:!1,dir:`ltr`,"data-testid":`email-smtp-from`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.appUrlLabel`)}),(0,Z.jsx)(`span`,{className:k,children:E(`appUrl`)??e(`userManager.emailNotifications.appUrlHint`)}),(0,Z.jsx)(J,{value:r.appUrl,onChange:e=>w(`appUrl`,e.target.value),placeholder:`https://chat.example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-app-url`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-gray-200 dark:border-dark-300 pt-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsxs)(`label`,{className:`block sm:max-w-xs sm:flex-1`,children:[(0,Z.jsx)(`span`,{className:O,children:e(`userManager.emailNotifications.testRecipientLabel`)}),(0,Z.jsx)(`span`,{className:k,children:e(`userManager.emailNotifications.testRecipientHint`)}),(0,Z.jsx)(J,{type:`email`,value:a,onChange:e=>s(e.target.value),placeholder:`you@example.com`,spellCheck:!1,dir:`ltr`,"data-testid":`email-test-recipient`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void C(),disabled:u||c||!t?.configured||D,title:D?e(`userManager.emailNotifications.saveBeforeTest`):void 0,"data-testid":`email-test-button`,children:e(u?`userManager.emailNotifications.testing`:`userManager.emailNotifications.test`)}),(0,Z.jsx)(G,{size:`sm`,onClick:()=>void x(),disabled:c||!D,"data-testid":`email-save-button`,children:e(c?`userManager.emailNotifications.saving`:`userManager.emailNotifications.save`)})]})]})]})]})},ve=()=>{let{t:e}=o(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return F.getMfaPolicy().then(t=>{e||(t.success&&t.data?n(t.data):s(!0))}).catch(()=>{e||s(!0)}),()=>{e=!0}},[c]),(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.mfaPolicy.description`)})]}),t===null&&a&&(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{s(!1),l(e=>e+1)},children:e(`common.retry`)})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:e(`userManager.mfaPolicy.requireAll`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t?.locked?e(`userManager.mfaPolicy.lockedByEnv`):e(`userManager.mfaPolicy.requireAllHint`)})]}),(0,Z.jsx)(Y,{checked:t?.mode===`required`,disabled:t===null||t.locked||r,onChange:async t=>{let r=t?`required`:`optional`;i(!0);try{let t=await F.setMfaPolicy(r);if(!t.success||!t.data)throw Error(t.error||`MFA policy update failed.`);n(t.data),h.success(e(`userManager.mfaPolicy.saved`))}catch{h.error(e(`userManager.mfaPolicy.saveFailed`))}finally{i(!1)}}})]})]})},ye=()=>{let{t:e}=o(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)([]),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!0),[u,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(``),[g,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(!1),[C,w]=(0,X.useState)(null),[T,E]=(0,X.useState)(``),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(``),[N,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(!1),R=(0,X.useMemo)(()=>{let e=new Map;return r.forEach(t=>e.set(t.id,t.username)),e},[r]),z=(0,X.useCallback)(async()=>{l(!0),s(!1);try{let[e,t]=await Promise.all([P.getGroups(),H.getUsers()]);if(!e.success||!e.data)throw Error(e.error||`Failed to load groups.`);n(e.data),t.success&&t.data&&i(t.data)}catch{s(!0)}finally{l(!1)}},[]);(0,X.useEffect)(()=>{let e=setTimeout(()=>void z(),0);return()=>clearTimeout(e)},[z]);let B=async t=>{if(t.preventDefault(),!p.trim()){h.error(e(`userManager.groups.nameRequired`,`Give the group a name.`));return}b(!0);try{let t=await P.createGroup({name:p.trim(),description:g.trim()||void 0});if(!t.success)throw Error(t.error||`Group creation failed.`);m(``),v(``),f(!1),h.success(e(`userManager.groups.created`,`Group created.`)),await z()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.createFailed`,`The group could not be created.`))}finally{b(!1)}},V=async t=>{A(t.id);try{let n=await P.deleteGroup(t.id);if(!n.success)throw Error(n.error||`Group delete failed.`);h.success(e(`userManager.groups.deleted`,`Group deleted.`)),C===t.id&&w(null),await z()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.deleteFailed`,`The group could not be deleted.`))}finally{A(null)}},U=async t=>{if(T){A(t.id);try{let n=await P.addGroupMember(t.id,T);if(!n.success)throw Error(n.error||`Member add failed.`);E(``),h.success(e(`userManager.groups.memberAdded`,`Member added.`)),await z()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberAddFailed`,`The member could not be added.`))}finally{A(null)}}},W=async(t,n)=>{A(t.id);try{let r=await P.removeGroupMember(t.id,n);if(!r.success)throw Error(r.error||`Member remove failed.`);h.success(e(`userManager.groups.memberRemoved`,`Member removed.`)),await z()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberRemoveFailed`,`The member could not be removed.`))}finally{A(null)}},ee=async t=>{if(M(t),F(null),t){L(!0);try{let e=await P.getEffectiveAccess(t);if(!e.success||!e.data)throw Error(e.error||`Access lookup failed.`);F(e.data)}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.accessLookupFailed`,`The effective access could not be loaded.`))}finally{L(!1)}}},K=e=>e.map(e=>({value:e.id,label:e.username}));return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(D,{className:`h-4 w-4 text-primary-500`}),e(`userManager.groups.title`,`Groups`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.groups.description`,`Group accounts to manage shared access, and inspect what any account can effectively do.`)})]}),a?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void z(),children:e(`common.retry`)}):(0,Z.jsxs)(G,{size:`sm`,variant:`outline`,onClick:()=>f(e=>!e),className:`gap-1.5`,children:[(0,Z.jsx)(S,{size:14}),e(`userManager.groups.newGroup`,`New group`)]})]}),u&&(0,Z.jsxs)(`form`,{onSubmit:B,className:`mt-4 rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50 p-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.nameLabel`,`Name`)}),(0,Z.jsx)(J,{value:p,onChange:e=>m(e.target.value)})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.descriptionLabel`,`Description (optional)`)}),(0,Z.jsx)(J,{value:g,onChange:e=>v(e.target.value)})]})]}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(G,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>f(!1),children:e(`common.cancel`)}),(0,Z.jsx)(G,{type:`submit`,size:`sm`,disabled:y,children:y?e(`userManager.groups.creating`,`Creating…`):e(`userManager.groups.create`,`Create group`)})]})]}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-3`,children:c?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):a?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.loadFailed`,`The groups could not be loaded.`)}):t.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.empty`,`No groups yet.`)}):t.map(t=>{let n=C===t.id,i=new Set(t.members.map(e=>e.user_id)),a=r.filter(e=>!i.has(e.id));return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-100`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-4`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-start`,onClick:()=>{w(n?null:t.id),E(``)},"aria-expanded":n,children:[n?(0,Z.jsx)(_,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(d,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:[t.name,(0,Z.jsx)(`span`,{className:`ms-2 text-xs font-normal text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberCount`,{count:t.members.length,defaultValue:`Members: {{count}}`})})]}),t.description&&(0,Z.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:t.description})]})]}),(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void V(t),disabled:k===t.id,"aria-label":e(`userManager.groups.deleteGroup`,`Delete group`),className:`text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,Z.jsx)(O,{size:16})})]}),n&&(0,Z.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 p-4 space-y-3`,children:[t.members.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.noMembers`,`No members yet.`)}):(0,Z.jsx)(`div`,{className:`space-y-2`,children:t.members.map(n=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-50 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:R.get(n.user_id)||n.user_id}),(0,Z.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`userManager.groups.addedAt`,`Added`),`:`,` `,new Date(n.added_at).toLocaleDateString()]})]}),(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void W(t,n.user_id),disabled:k===t.id,"aria-label":e(`userManager.groups.removeMember`,`Remove member`),children:(0,Z.jsx)(x,{size:16})})]},n.user_id))}),a.length>0&&(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex-1`,children:(0,Z.jsx)(q,{label:e(`userManager.groups.addMember`,`Add member`),value:T,onChange:e=>E(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...K(a)]})}),(0,Z.jsx)(G,{size:`sm`,onClick:()=>void U(t),disabled:!T||k===t.id,className:`mb-0.5`,children:e(`userManager.groups.add`,`Add`)})]})]})]},t.id)})}),(0,Z.jsxs)(`div`,{className:`mt-6 border-t border-gray-200 dark:border-dark-300 pt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.effectiveTitle`,`Effective access`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.groups.effectiveDescription`,`Pick an account to see the access it ends up with across role, groups, and grants.`)})]}),(0,Z.jsx)(q,{value:j,onChange:e=>void ee(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...K(r)]}),I&&(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}),N&&!I&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50 p-4 space-y-3`,children:[(0,Z.jsxs)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:N.username}),(0,Z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[` · `,e(`userManager.groups.roleLabel`,`Role`),`: `,N.role,` · `,e(`userManager.groups.statusLabel`,`Status`),`: `,N.status]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberOf`,`Groups`)}),N.groups.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:N.groups.map(e=>(0,Z.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs text-primary-700 dark:text-primary-300`,children:e.name},e.id))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.featuresLabel`,`Feature access`)}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(N.features).map(([t,n])=>(0,Z.jsxs)(`span`,{className:n?`rounded-full bg-green-100 dark:bg-green-900/30 px-2 py-0.5 text-xs text-green-700 dark:text-green-300`:`rounded-full bg-gray-100 dark:bg-dark-200 px-2 py-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[t,`: `,e(n?`common.yes`:`common.no`)]},t))})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.grantsLabel`,`Grants`)}),N.grants.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,Z.jsx)(`div`,{className:`space-y-1`,children:N.grants.map(t=>(0,Z.jsxs)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[t.resourceType,`/`,t.resourceId,` ·`,` `,t.permission,` `,(0,Z.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[`(`,e(`userManager.groups.grantVia`,`via`),` `,t.via,`)`]})]},t.id))})]})]})]})]})},be={success:`bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300`,denied:`bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300`,failure:`bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300`},xe=()=>{let{t:e}=o(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(!0),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(null),[u,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(``),[g,y]=(0,X.useState)(`50`),b=(0,X.useCallback)(async()=>{i(!0),s(!1);try{let e=Number(g),t=await P.getAuditEvents({action:u.trim()||void 0,result:m||void 0,limit:Number.isInteger(e)&&e>0?e:void 0});if(!t.success||!t.data)throw Error(t.error||`Failed to load audit events.`);n(t.data)}catch{s(!0)}finally{i(!1)}},[u,m,g]);(0,X.useEffect)(()=>{let e=setTimeout(()=>void b(),0);return()=>clearTimeout(e)},[]);let x=t=>{switch(t){case`success`:return e(`userManager.audit.resultSuccess`,`Success`);case`denied`:return e(`userManager.audit.resultDenied`,`Denied`);case`failure`:return e(`userManager.audit.resultFailure`,`Failure`);default:return t}};return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Z.jsx)(f,{className:`h-4 w-4 text-primary-500`}),e(`userManager.audit.title`,`Security audit log`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.audit.description`,`Recent sign-ins, permission checks, and administrative changes on this instance.`)})]}),(0,Z.jsxs)(G,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:r,className:`gap-1.5`,children:[(0,Z.jsx)(v,{size:14,className:r?`animate-spin`:void 0}),e(`common.refresh`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.actionFilter`,`Action`)}),(0,Z.jsx)(J,{value:u,onChange:e=>p(e.target.value),placeholder:e(`userManager.audit.actionPlaceholder`,`e.g. auth.login`),spellCheck:!1,dir:`ltr`})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.resultFilter`,`Result`)}),(0,Z.jsx)(q,{value:m,onChange:e=>h(e.target.value),options:[{value:``,label:e(`common.all`)},{value:`success`,label:e(`userManager.audit.resultSuccess`,`Success`)},{value:`denied`,label:e(`userManager.audit.resultDenied`,`Denied`)},{value:`failure`,label:e(`userManager.audit.resultFailure`,`Failure`)}]})]}),(0,Z.jsxs)(`label`,{className:`block`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.limitFilter`,`Limit`)}),(0,Z.jsx)(J,{type:`number`,min:1,max:500,value:g,onChange:e=>y(e.target.value),dir:`ltr`})]})]}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-2`,children:r?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):a?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.loadFailed`,`The audit log could not be loaded.`)}),(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void b(),children:e(`common.retry`)})]}):t.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.empty`,`No audit events recorded yet.`)}):t.map(t=>{let n=c===t.id,r=t.details&&Object.keys(t.details).length>0;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 px-3 py-2 text-start`,onClick:()=>l(n?null:t.id),"aria-expanded":n,children:[r?n?(0,Z.jsx)(_,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(d,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,Z.jsx)(`span`,{className:`h-4 w-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.action}),(0,Z.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${be[t.result]||`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-300`}`,children:x(t.result)})]}),(0,Z.jsxs)(`span`,{className:`mt-0.5 block truncate text-xs text-gray-500 dark:text-gray-400`,children:[new Date(t.occurredAt).toLocaleString(),` · `,e(`userManager.audit.actor`,`Actor`),`:`,` `,t.actorUserId||t.actorKind,t.targetType&&(0,Z.jsxs)(Z.Fragment,{children:[` · `,e(`userManager.audit.target`,`Target`),`:`,` `,t.targetType,t.targetId?`/${t.targetId}`:``]})]})]})]}),n&&r&&(0,Z.jsx)(`pre`,{dir:`ltr`,className:`mx-3 mb-3 overflow-x-auto rounded-md bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 p-3 text-xs text-gray-700 dark:text-gray-300`,children:JSON.stringify(t.details,null,2)})]},t.id)})})]})},Se=()=>{let{t:e}=o(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return V.getModelAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):s(!0))}).catch(()=>{e||s(!0)}),()=>{e=!0}},[c]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.modelAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.modelAccess.description`)})]}),t===null&&a?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{s(!1),l(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;i(!0);try{if(!(await V.setModelAccess(r)).success)throw Error(`Model download access update failed.`);n(r),h.success(e(`userManager.modelAccess.saved`))}catch{h.error(e(`userManager.modelAccess.saveFailed`))}finally{i(!1)}},disabled:r||t===null})]})})},Ce=()=>{let{t:e}=o(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(``),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1;return V.getSettings().then(t=>{e||(t.success&&t.data?(n(t.data),i(t.data.baseUrl)):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]);let f=async t=>{s(!0);try{let r=await V.updateSettings(t);if(!r.success||!r.data)throw Error(r.message||`update failed`);n(r.data),i(r.data.baseUrl),h.success(e(`userManager.ollamaProvider.saved`))}catch{h.error(e(`userManager.ollamaProvider.saveFailed`))}finally{s(!1)}},p=t!==null&&r.trim()!==t.baseUrl;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.ollamaProvider.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.ollamaProvider.description`)})]}),t===null&&c?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),d(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:t?.enabled===!0,onChange:e=>void f({enabled:e}),disabled:a||t===null})]}),t!==null&&(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 font-mono text-xs text-gray-900 focus:border-primary-400 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,value:r,onChange:e=>i(e.target.value),placeholder:`http://localhost:11434`,spellCheck:!1,"aria-label":e(`userManager.ollamaProvider.baseUrlLabel`)}),(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>void f({baseUrl:r.trim()}),disabled:a||!p||!r.trim(),children:e(`common.save`)})]})]})},we=()=>{let{t:e}=o(),[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return I.getAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):s(!0))}).catch(()=>{e||s(!0)}),()=>{e=!0}},[c]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.webSearchAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.webSearchAccess.description`)})]}),t===null&&a?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{s(!1),l(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;i(!0);try{if(!(await I.setAccess(r)).success)throw Error(`Web search access update failed.`);n(r),h.success(e(`userManager.webSearchAccess.saved`))}catch{h.error(e(`userManager.webSearchAccess.saveFailed`))}finally{i(!1)}},disabled:r||t===null})]})})},Te=()=>{let{t:e}=o(),t=U(e=>e.refreshWorkAccess),[n,r]=(0,X.useState)(null),[i,a]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let e=!1;return N.access().then(t=>{e||(t.success&&t.data?r(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,Z.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAccess.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAccess.description`)})]}),n===null&&s?(0,Z.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,Z.jsx)(Y,{checked:n===`all-users`,onChange:async n=>{let i=n?`all-users`:`admins`;a(!0);try{if(!(await N.setAccess(i)).success)throw Error(`Work access update failed.`);r(i),await t(),h.success(e(`userManager.workAccess.saved`))}catch{h.error(e(`userManager.workAccess.saveFailed`))}finally{a(!1)}},disabled:i||n===null})]})})},Q={name:``,image:``,memoryLimit:``,cpuLimit:``,pidsLimit:``,workspaceSize:``,idleMinutes:``,networkDefault:`inherit`,guiEnabled:!1,takeoverEnabled:!0,approvalsRequired:!1},Ee={...Q,name:`Work Computer`,image:`libre-work-computer:latest`,memoryLimit:`4g`,networkDefault:`on`,guiEnabled:!0},De=e=>({name:e.name,guiEnabled:e.guiEnabled===!0,takeoverEnabled:e.takeoverEnabled!==!1,approvalsRequired:e.approvalsRequired===!0,image:e.image??``,memoryLimit:e.memoryLimit??``,cpuLimit:e.cpuLimit??``,pidsLimit:e.pidsLimit===void 0?``:String(e.pidsLimit),workspaceSize:e.workspaceSize??``,idleMinutes:e.idleTimeoutMs===void 0?``:String(e.idleTimeoutMs/6e4),networkDefault:e.networkDefault===void 0?`inherit`:e.networkDefault?`on`:`off`}),Oe=e=>[e.pidsLimit,e.idleMinutes].some(e=>e.trim()!==``&&!Number.isFinite(Number(e))),ke=e=>({name:e.name.trim(),image:e.image.trim()||null,memoryLimit:e.memoryLimit.trim()||null,cpuLimit:e.cpuLimit.trim()||null,pidsLimit:e.pidsLimit.trim()?Number(e.pidsLimit):null,workspaceSize:e.workspaceSize.trim()||null,idleTimeoutMs:e.idleMinutes.trim()?Math.round(Number(e.idleMinutes)*6e4):null,networkDefault:e.networkDefault===`inherit`?null:e.networkDefault===`on`,guiEnabled:e.guiEnabled?!0:null,takeoverEnabled:e.takeoverEnabled?null:!1,approvalsRequired:e.approvalsRequired?!0:null}),Ae=()=>{let{t:e}=o(),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(null),[a,s]=(0,X.useState)(Q),[c,l]=(0,X.useState)(!1),u=async()=>{try{let e=await N.listPolicies();e.success&&e.data&&n(e.data)}catch{}};(0,X.useEffect)(()=>{let e=!1;return N.listPolicies().then(t=>{!e&&t.success&&t.data&&n(t.data)}).catch(()=>{}),()=>{e=!0}},[]);let d=e=>({value:a[e],onChange:t=>s(n=>({...n,[e]:t.target.value}))}),f=async()=>{if(Oe(a)){h.error(e(`userManager.workPolicies.invalidNumber`));return}l(!0);try{let t=ke(a),n=r===`new`?await N.createPolicy(t):await N.updatePolicy(r,t);if(!n.success)throw Error(n.error||`Policy save failed.`);h.success(e(`userManager.workPolicies.saved`)),i(null),s(Q),await u()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}finally{l(!1)}},p=async t=>{if(window.confirm(e(`userManager.workPolicies.deleteConfirm`)))try{let n=await N.deletePolicy(t.id);if(!n.success)throw Error(n.error||`Policy delete failed.`);h.success(e(`userManager.workPolicies.deleted`)),await u()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}},m=(e,t,n)=>(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:t}),(0,Z.jsx)(`input`,{...d(e),placeholder:n,spellCheck:!1,className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-none focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]});return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workPolicies.title`)}),(0,Z.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workPolicies.description`)})]}),r===null&&(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsxs)(G,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,"data-testid":`work-policy-computer-preset`,onClick:()=>{s(Ee),i(`new`)},children:[(0,Z.jsx)(A,{size:14,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.computerPreset`)})]}),(0,Z.jsxs)(G,{size:`sm`,variant:`outline`,className:`whitespace-nowrap`,onClick:()=>{s(Q),i(`new`)},children:[(0,Z.jsx)(S,{size:14,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.add`)})]})]})]}),t.length===0&&r===null&&(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.empty`)}),t.length>0&&(0,Z.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-100 dark:divide-dark-300`,children:t.map(t=>(0,Z.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,Z.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-gray-500 dark:text-gray-400`,children:[t.memoryLimit,t.cpuLimit&&`cpu ${t.cpuLimit}`,t.pidsLimit&&`pids ${t.pidsLimit}`,t.workspaceSize,t.idleTimeoutMs!==void 0&&`idle ${Math.round(t.idleTimeoutMs/6e4)}m`,t.networkDefault!==void 0&&`net ${t.networkDefault?`on`:`off`}`,t.image].filter(Boolean).join(` · `)||`—`})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.edit`),onClick:()=>{s(De(t)),i(t.id)},children:(0,Z.jsx)(E,{size:14})}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.delete`),onClick:()=>void p(t),children:(0,Z.jsx)(O,{size:14})})]})]},t.id))}),r!==null&&(0,Z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 p-3 dark:border-dark-300`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[m(`name`,e(`userManager.workPolicies.name`),`heavy`),m(`memoryLimit`,e(`userManager.workPolicies.memory`),`4g`),m(`cpuLimit`,e(`userManager.workPolicies.cpu`),`4`),m(`pidsLimit`,e(`userManager.workPolicies.pids`),`512`),m(`workspaceSize`,e(`userManager.workPolicies.workspaceSize`),`20Gi`),m(`idleMinutes`,e(`userManager.workPolicies.idleMinutes`),`30`),(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[(0,Z.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.networkDefault`)}),(0,Z.jsxs)(`select`,{...d(`networkDefault`),className:`w-full rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-sm text-gray-900 outline-none focus:border-primary-500 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`,children:[(0,Z.jsx)(`option`,{value:`inherit`,children:e(`userManager.workPolicies.networkInherit`)}),(0,Z.jsx)(`option`,{value:`on`,children:e(`userManager.workPolicies.networkOn`)}),(0,Z.jsx)(`option`,{value:`off`,children:e(`userManager.workPolicies.networkOff`)})]})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-gui`,checked:a.guiEnabled,onChange:e=>s(t=>({...t,guiEnabled:e.target.checked})),className:`h-3.5 w-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.guiEnabled`)})]}),a.guiEnabled&&(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-takeover`,checked:a.takeoverEnabled,onChange:e=>s(t=>({...t,takeoverEnabled:e.target.checked})),className:`h-3.5 w-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.takeoverEnabled`)})]}),(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`work-policy-approvals`,checked:a.approvalsRequired,onChange:e=>s(t=>({...t,approvalsRequired:e.target.checked})),className:`h-3.5 w-3.5 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),(0,Z.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.approvalsRequired`)})]}),m(`image`,e(`userManager.workPolicies.image`),`node:22-bookworm@sha256:…`)]}),a.guiEnabled&&(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.computerPresetHint`)}),(0,Z.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>{i(null),s(Q)},children:e(`userManager.workPolicies.cancel`)}),(0,Z.jsx)(G,{size:`sm`,disabled:c||!a.name.trim(),onClick:()=>void f(),children:e(`userManager.workPolicies.save`)})]})]})]})},$=[{id:`users`,label:`userManager.sections.users`},{id:`groups`,label:`userManager.groups.title`},{id:`access`,label:`userManager.sections.access`},{id:`security`,label:`userManager.sections.security`},{id:`defaults`,label:`userManager.sections.defaults`}],je=e=>{switch(e){case`users`:return(0,Z.jsx)(oe,{});case`groups`:return(0,Z.jsx)(ye,{});case`access`:return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(Te,{}),(0,Z.jsx)(Ae,{}),(0,Z.jsx)(Ce,{}),(0,Z.jsx)(Se,{}),(0,Z.jsx)(we,{}),(0,Z.jsx)(se,{}),(0,Z.jsx)(ue,{}),(0,Z.jsx)(me,{}),(0,Z.jsx)(_e,{})]});case`security`:return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(ve,{}),(0,Z.jsx)(xe,{})]});case`defaults`:return(0,Z.jsx)(le,{})}},Me=()=>{let{t:e}=o(),t=(0,X.useId)(),n=(0,X.useRef)({}),[r,i]=(0,X.useState)(`users`),[a,c]=(0,X.useState)([`users`]),l=e=>{i(e),c(t=>t.includes(e)?t:[...t,e])},u=(e,t)=>{let r=getComputedStyle(e.currentTarget).direction===`rtl`,i=$.findIndex(e=>e.id===t),a;switch(e.key){case`Home`:a=0;break;case`End`:a=$.length-1;break;case`ArrowRight`:a=i+(r?-1:1);break;case`ArrowLeft`:a=i+(r?1:-1);break;default:return}e.preventDefault();let o=$[(a+$.length)%$.length].id;l(o),n.current[o]?.focus()};return(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Z.jsx)(`div`,{role:`tablist`,"aria-label":e(`userManager.title`),"aria-orientation":`horizontal`,className:`-mx-1 flex gap-1 overflow-x-auto border-b border-line px-1 pb-3 pt-1 scrollbar-thin`,children:$.map(i=>(0,Z.jsx)(`button`,{ref:e=>{n.current[i.id]=e},type:`button`,role:`tab`,id:`${t}-tab-${i.id}`,"aria-controls":`${t}-panel-${i.id}`,"aria-selected":r===i.id,tabIndex:r===i.id?0:-1,onClick:()=>l(i.id),onKeyDown:e=>u(e,i.id),className:s(`min-h-11 shrink-0 rounded-xl border px-3 py-2 text-sm font-medium outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-surface motion-reduce:transition-none`,r===i.id?`border-line bg-nav-active text-ink`:`border-transparent text-ink-muted hover:bg-hover-solid hover:text-ink`),children:e(i.label)},i.id))}),$.map(e=>(0,Z.jsx)(`div`,{id:`${t}-panel-${e.id}`,role:`tabpanel`,"aria-labelledby":`${t}-tab-${e.id}`,hidden:r!==e.id,children:a.includes(e.id)&&je(e.id)},e.id))]})};export{Me as UserManagementPanel,Me as default};