libre-webui 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (510) hide show
  1. package/README.md +32 -22
  2. package/backend/dist/index.d.ts.map +1 -1
  3. package/backend/dist/index.js +26 -4
  4. package/backend/dist/index.js.map +1 -1
  5. package/backend/dist/middleware/auth.d.ts +7 -0
  6. package/backend/dist/middleware/auth.d.ts.map +1 -1
  7. package/backend/dist/middleware/auth.js +26 -0
  8. package/backend/dist/middleware/auth.js.map +1 -1
  9. package/backend/dist/middleware/index.d.ts +20 -0
  10. package/backend/dist/middleware/index.d.ts.map +1 -1
  11. package/backend/dist/middleware/index.js +105 -2
  12. package/backend/dist/middleware/index.js.map +1 -1
  13. package/backend/dist/models/personaModel.d.ts.map +1 -1
  14. package/backend/dist/models/personaModel.js +2 -0
  15. package/backend/dist/models/personaModel.js.map +1 -1
  16. package/backend/dist/observability/otel.d.ts +40 -0
  17. package/backend/dist/observability/otel.d.ts.map +1 -0
  18. package/backend/dist/observability/otel.js +337 -0
  19. package/backend/dist/observability/otel.js.map +1 -0
  20. package/backend/dist/observability/requestContext.d.ts +14 -0
  21. package/backend/dist/observability/requestContext.d.ts.map +1 -0
  22. package/backend/dist/observability/requestContext.js +21 -0
  23. package/backend/dist/observability/requestContext.js.map +1 -0
  24. package/backend/dist/persistence/chatGenerationTypes.d.ts +9 -0
  25. package/backend/dist/persistence/chatGenerationTypes.d.ts.map +1 -1
  26. package/backend/dist/persistence/extensionTypes.d.ts +13 -0
  27. package/backend/dist/persistence/extensionTypes.d.ts.map +1 -1
  28. package/backend/dist/persistence/extensionTypes.js.map +1 -1
  29. package/backend/dist/persistence/index.d.ts +1 -1
  30. package/backend/dist/persistence/index.d.ts.map +1 -1
  31. package/backend/dist/persistence/index.js.map +1 -1
  32. package/backend/dist/persistence/postgresAgentFoundationMigration.d.ts +9 -0
  33. package/backend/dist/persistence/postgresAgentFoundationMigration.d.ts.map +1 -0
  34. package/backend/dist/persistence/postgresAgentFoundationMigration.js +164 -0
  35. package/backend/dist/persistence/postgresAgentFoundationMigration.js.map +1 -0
  36. package/backend/dist/persistence/postgresExtensionRepositories.d.ts.map +1 -1
  37. package/backend/dist/persistence/postgresExtensionRepositories.js +46 -2
  38. package/backend/dist/persistence/postgresExtensionRepositories.js.map +1 -1
  39. package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.d.ts +10 -0
  40. package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.d.ts.map +1 -0
  41. package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.js +148 -0
  42. package/backend/dist/persistence/postgresMediaEnterpriseOpsMigration.js.map +1 -0
  43. package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
  44. package/backend/dist/persistence/postgresMigrationRegistry.js +10 -0
  45. package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
  46. package/backend/dist/persistence/postgresNotesV2Migration.d.ts +4 -0
  47. package/backend/dist/persistence/postgresNotesV2Migration.d.ts.map +1 -0
  48. package/backend/dist/persistence/postgresNotesV2Migration.js +57 -0
  49. package/backend/dist/persistence/postgresNotesV2Migration.js.map +1 -0
  50. package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
  51. package/backend/dist/persistence/postgresResourceRepositories.js +1646 -11
  52. package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
  53. package/backend/dist/persistence/postgresSkillFilesMigration.d.ts +9 -0
  54. package/backend/dist/persistence/postgresSkillFilesMigration.d.ts.map +1 -0
  55. package/backend/dist/persistence/postgresSkillFilesMigration.js +50 -0
  56. package/backend/dist/persistence/postgresSkillFilesMigration.js.map +1 -0
  57. package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts +10 -0
  58. package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts.map +1 -0
  59. package/backend/dist/persistence/postgresTeamCollaborationMigration.js +161 -0
  60. package/backend/dist/persistence/postgresTeamCollaborationMigration.js.map +1 -0
  61. package/backend/dist/persistence/resourceTypes.d.ts +541 -3
  62. package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
  63. package/backend/dist/persistence/resourceTypes.js.map +1 -1
  64. package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
  65. package/backend/dist/persistence/sqliteExtensionRepositories.js +26 -4
  66. package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
  67. package/backend/dist/persistence/sqliteMigrations.d.ts +9 -0
  68. package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
  69. package/backend/dist/persistence/sqliteMigrations.js +1196 -29
  70. package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
  71. package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
  72. package/backend/dist/persistence/sqliteResourceRepositories.js +1523 -134
  73. package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
  74. package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
  75. package/backend/dist/persistence/sqliteToPostgresMigration.js +257 -3
  76. package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
  77. package/backend/dist/platform/jobs/domainJobContracts.d.ts +8 -0
  78. package/backend/dist/platform/jobs/domainJobContracts.d.ts.map +1 -1
  79. package/backend/dist/platform/jobs/domainJobContracts.js +8 -0
  80. package/backend/dist/platform/jobs/domainJobContracts.js.map +1 -1
  81. package/backend/dist/platform/jobs/domainJobHandlers.d.ts.map +1 -1
  82. package/backend/dist/platform/jobs/domainJobHandlers.js +310 -3
  83. package/backend/dist/platform/jobs/domainJobHandlers.js.map +1 -1
  84. package/backend/dist/platform/jobs/embeddedDurableJobWorker.d.ts.map +1 -1
  85. package/backend/dist/platform/jobs/embeddedDurableJobWorker.js +4 -2
  86. package/backend/dist/platform/jobs/embeddedDurableJobWorker.js.map +1 -1
  87. package/backend/dist/platform/jobs/postgresDurableJobWorker.d.ts.map +1 -1
  88. package/backend/dist/platform/jobs/postgresDurableJobWorker.js +4 -2
  89. package/backend/dist/platform/jobs/postgresDurableJobWorker.js.map +1 -1
  90. package/backend/dist/platform/storage/pgVectorStore.d.ts +2 -1
  91. package/backend/dist/platform/storage/pgVectorStore.d.ts.map +1 -1
  92. package/backend/dist/platform/storage/pgVectorStore.js +51 -0
  93. package/backend/dist/platform/storage/pgVectorStore.js.map +1 -1
  94. package/backend/dist/platform/storage/platformDomainRepositories.d.ts +8 -2
  95. package/backend/dist/platform/storage/platformDomainRepositories.d.ts.map +1 -1
  96. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.d.ts.map +1 -1
  97. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js +25 -4
  98. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js.map +1 -1
  99. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts +2 -1
  100. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts.map +1 -1
  101. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js +35 -0
  102. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js.map +1 -1
  103. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.d.ts.map +1 -1
  104. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js +26 -3
  105. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js.map +1 -1
  106. package/backend/dist/platform/storage/vectorStore.d.ts +14 -0
  107. package/backend/dist/platform/storage/vectorStore.d.ts.map +1 -1
  108. package/backend/dist/platform/storage/vectorStore.js.map +1 -1
  109. package/backend/dist/routes/access.d.ts.map +1 -1
  110. package/backend/dist/routes/access.js +84 -3
  111. package/backend/dist/routes/access.js.map +1 -1
  112. package/backend/dist/routes/calendar.d.ts.map +1 -1
  113. package/backend/dist/routes/calendar.js +125 -22
  114. package/backend/dist/routes/calendar.js.map +1 -1
  115. package/backend/dist/routes/channels.d.ts +3 -0
  116. package/backend/dist/routes/channels.d.ts.map +1 -0
  117. package/backend/dist/routes/channels.js +447 -0
  118. package/backend/dist/routes/channels.js.map +1 -0
  119. package/backend/dist/routes/chat.d.ts.map +1 -1
  120. package/backend/dist/routes/chat.js +195 -7
  121. package/backend/dist/routes/chat.js.map +1 -1
  122. package/backend/dist/routes/costs.d.ts +3 -0
  123. package/backend/dist/routes/costs.d.ts.map +1 -0
  124. package/backend/dist/routes/costs.js +191 -0
  125. package/backend/dist/routes/costs.js.map +1 -0
  126. package/backend/dist/routes/documents.d.ts.map +1 -1
  127. package/backend/dist/routes/documents.js +64 -21
  128. package/backend/dist/routes/documents.js.map +1 -1
  129. package/backend/dist/routes/evaluations.d.ts +3 -0
  130. package/backend/dist/routes/evaluations.d.ts.map +1 -0
  131. package/backend/dist/routes/evaluations.js +352 -0
  132. package/backend/dist/routes/evaluations.js.map +1 -0
  133. package/backend/dist/routes/imageGen.d.ts.map +1 -1
  134. package/backend/dist/routes/imageGen.js +2 -1
  135. package/backend/dist/routes/imageGen.js.map +1 -1
  136. package/backend/dist/routes/media.d.ts.map +1 -1
  137. package/backend/dist/routes/media.js +228 -7
  138. package/backend/dist/routes/media.js.map +1 -1
  139. package/backend/dist/routes/notes.d.ts.map +1 -1
  140. package/backend/dist/routes/notes.js +149 -36
  141. package/backend/dist/routes/notes.js.map +1 -1
  142. package/backend/dist/routes/notifications.d.ts +3 -0
  143. package/backend/dist/routes/notifications.d.ts.map +1 -0
  144. package/backend/dist/routes/notifications.js +213 -0
  145. package/backend/dist/routes/notifications.js.map +1 -0
  146. package/backend/dist/routes/openaiCompat.d.ts +3 -0
  147. package/backend/dist/routes/openaiCompat.d.ts.map +1 -0
  148. package/backend/dist/routes/openaiCompat.js +314 -0
  149. package/backend/dist/routes/openaiCompat.js.map +1 -0
  150. package/backend/dist/routes/personas.js +1 -1
  151. package/backend/dist/routes/personas.js.map +1 -1
  152. package/backend/dist/routes/prompts.d.ts +3 -0
  153. package/backend/dist/routes/prompts.d.ts.map +1 -0
  154. package/backend/dist/routes/prompts.js +173 -0
  155. package/backend/dist/routes/prompts.js.map +1 -0
  156. package/backend/dist/routes/search.d.ts.map +1 -1
  157. package/backend/dist/routes/search.js +29 -1
  158. package/backend/dist/routes/search.js.map +1 -1
  159. package/backend/dist/routes/skills.d.ts +3 -0
  160. package/backend/dist/routes/skills.d.ts.map +1 -0
  161. package/backend/dist/routes/skills.js +246 -0
  162. package/backend/dist/routes/skills.js.map +1 -0
  163. package/backend/dist/routes/stt.d.ts.map +1 -1
  164. package/backend/dist/routes/stt.js +2 -1
  165. package/backend/dist/routes/stt.js.map +1 -1
  166. package/backend/dist/routes/tools.d.ts +3 -0
  167. package/backend/dist/routes/tools.d.ts.map +1 -0
  168. package/backend/dist/routes/tools.js +359 -0
  169. package/backend/dist/routes/tools.js.map +1 -0
  170. package/backend/dist/routes/tts.d.ts.map +1 -1
  171. package/backend/dist/routes/tts.js +63 -8
  172. package/backend/dist/routes/tts.js.map +1 -1
  173. package/backend/dist/routes/voiceAccess.d.ts +3 -0
  174. package/backend/dist/routes/voiceAccess.d.ts.map +1 -0
  175. package/backend/dist/routes/voiceAccess.js +102 -0
  176. package/backend/dist/routes/voiceAccess.js.map +1 -0
  177. package/backend/dist/services/apiTokenService.d.ts +2 -2
  178. package/backend/dist/services/apiTokenService.d.ts.map +1 -1
  179. package/backend/dist/services/apiTokenService.js +7 -0
  180. package/backend/dist/services/apiTokenService.js.map +1 -1
  181. package/backend/dist/services/authorizationService.d.ts +8 -4
  182. package/backend/dist/services/authorizationService.d.ts.map +1 -1
  183. package/backend/dist/services/authorizationService.js +31 -1
  184. package/backend/dist/services/authorizationService.js.map +1 -1
  185. package/backend/dist/services/automationSchedulerService.d.ts.map +1 -1
  186. package/backend/dist/services/automationSchedulerService.js +33 -3
  187. package/backend/dist/services/automationSchedulerService.js.map +1 -1
  188. package/backend/dist/services/automationService.d.ts +4 -1
  189. package/backend/dist/services/automationService.d.ts.map +1 -1
  190. package/backend/dist/services/automationService.js +25 -2
  191. package/backend/dist/services/automationService.js.map +1 -1
  192. package/backend/dist/services/builtinToolsService.d.ts +20 -0
  193. package/backend/dist/services/builtinToolsService.d.ts.map +1 -0
  194. package/backend/dist/services/builtinToolsService.js +661 -0
  195. package/backend/dist/services/builtinToolsService.js.map +1 -0
  196. package/backend/dist/services/calendarService.d.ts +74 -0
  197. package/backend/dist/services/calendarService.d.ts.map +1 -0
  198. package/backend/dist/services/calendarService.js +339 -0
  199. package/backend/dist/services/calendarService.js.map +1 -0
  200. package/backend/dist/services/channelService.d.ts +195 -0
  201. package/backend/dist/services/channelService.d.ts.map +1 -0
  202. package/backend/dist/services/channelService.js +1057 -0
  203. package/backend/dist/services/channelService.js.map +1 -0
  204. package/backend/dist/services/chatRequestService.d.ts.map +1 -1
  205. package/backend/dist/services/chatRequestService.js +29 -1
  206. package/backend/dist/services/chatRequestService.js.map +1 -1
  207. package/backend/dist/services/chatService.d.ts +61 -1
  208. package/backend/dist/services/chatService.d.ts.map +1 -1
  209. package/backend/dist/services/chatService.js +218 -1
  210. package/backend/dist/services/chatService.js.map +1 -1
  211. package/backend/dist/services/chatToolRuntimeService.d.ts +55 -0
  212. package/backend/dist/services/chatToolRuntimeService.d.ts.map +1 -0
  213. package/backend/dist/services/chatToolRuntimeService.js +389 -0
  214. package/backend/dist/services/chatToolRuntimeService.js.map +1 -0
  215. package/backend/dist/services/costGovernanceService.d.ts +102 -0
  216. package/backend/dist/services/costGovernanceService.d.ts.map +1 -0
  217. package/backend/dist/services/costGovernanceService.js +463 -0
  218. package/backend/dist/services/costGovernanceService.js.map +1 -0
  219. package/backend/dist/services/dataArchiveService.d.ts +6 -0
  220. package/backend/dist/services/dataArchiveService.d.ts.map +1 -1
  221. package/backend/dist/services/dataArchiveService.js +23 -4
  222. package/backend/dist/services/dataArchiveService.js.map +1 -1
  223. package/backend/dist/services/documentService.d.ts +58 -1
  224. package/backend/dist/services/documentService.d.ts.map +1 -1
  225. package/backend/dist/services/documentService.js +289 -84
  226. package/backend/dist/services/documentService.js.map +1 -1
  227. package/backend/dist/services/durableChatGenerationService.d.ts +9 -0
  228. package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
  229. package/backend/dist/services/durableChatGenerationService.js +152 -11
  230. package/backend/dist/services/durableChatGenerationService.js.map +1 -1
  231. package/backend/dist/services/evaluationService.d.ts +111 -0
  232. package/backend/dist/services/evaluationService.d.ts.map +1 -0
  233. package/backend/dist/services/evaluationService.js +403 -0
  234. package/backend/dist/services/evaluationService.js.map +1 -0
  235. package/backend/dist/services/galleryService.d.ts +6 -0
  236. package/backend/dist/services/galleryService.d.ts.map +1 -1
  237. package/backend/dist/services/galleryService.js +26 -0
  238. package/backend/dist/services/galleryService.js.map +1 -1
  239. package/backend/dist/services/mcpClientService.d.ts +29 -0
  240. package/backend/dist/services/mcpClientService.d.ts.map +1 -0
  241. package/backend/dist/services/mcpClientService.js +189 -0
  242. package/backend/dist/services/mcpClientService.js.map +1 -0
  243. package/backend/dist/services/noteService.d.ts +71 -0
  244. package/backend/dist/services/noteService.d.ts.map +1 -0
  245. package/backend/dist/services/noteService.js +397 -0
  246. package/backend/dist/services/noteService.js.map +1 -0
  247. package/backend/dist/services/notificationService.d.ts +55 -0
  248. package/backend/dist/services/notificationService.d.ts.map +1 -0
  249. package/backend/dist/services/notificationService.js +308 -0
  250. package/backend/dist/services/notificationService.js.map +1 -0
  251. package/backend/dist/services/openApiToolService.d.ts +38 -0
  252. package/backend/dist/services/openApiToolService.d.ts.map +1 -0
  253. package/backend/dist/services/openApiToolService.js +254 -0
  254. package/backend/dist/services/openApiToolService.js.map +1 -0
  255. package/backend/dist/services/personaService.d.ts +18 -2
  256. package/backend/dist/services/personaService.d.ts.map +1 -1
  257. package/backend/dist/services/personaService.js +113 -4
  258. package/backend/dist/services/personaService.js.map +1 -1
  259. package/backend/dist/services/pluginImageGenerationService.d.ts +19 -0
  260. package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -1
  261. package/backend/dist/services/pluginImageGenerationService.js +121 -0
  262. package/backend/dist/services/pluginImageGenerationService.js.map +1 -1
  263. package/backend/dist/services/pluginService.d.ts +7 -0
  264. package/backend/dist/services/pluginService.d.ts.map +1 -1
  265. package/backend/dist/services/pluginService.js +8 -2
  266. package/backend/dist/services/pluginService.js.map +1 -1
  267. package/backend/dist/services/promptService.d.ts +74 -0
  268. package/backend/dist/services/promptService.d.ts.map +1 -0
  269. package/backend/dist/services/promptService.js +513 -0
  270. package/backend/dist/services/promptService.js.map +1 -0
  271. package/backend/dist/services/resourceGrantService.d.ts.map +1 -1
  272. package/backend/dist/services/resourceGrantService.js +62 -17
  273. package/backend/dist/services/resourceGrantService.js.map +1 -1
  274. package/backend/dist/services/searchService.d.ts +29 -0
  275. package/backend/dist/services/searchService.d.ts.map +1 -0
  276. package/backend/dist/services/searchService.js +0 -0
  277. package/backend/dist/services/searchService.js.map +1 -0
  278. package/backend/dist/services/securityAuditService.d.ts.map +1 -1
  279. package/backend/dist/services/securityAuditService.js +2 -1
  280. package/backend/dist/services/securityAuditService.js.map +1 -1
  281. package/backend/dist/services/sharedResourceAccess.d.ts +25 -0
  282. package/backend/dist/services/sharedResourceAccess.d.ts.map +1 -0
  283. package/backend/dist/services/sharedResourceAccess.js +59 -0
  284. package/backend/dist/services/sharedResourceAccess.js.map +1 -0
  285. package/backend/dist/services/skillService.d.ts +137 -0
  286. package/backend/dist/services/skillService.d.ts.map +1 -0
  287. package/backend/dist/services/skillService.js +852 -0
  288. package/backend/dist/services/skillService.js.map +1 -0
  289. package/backend/dist/services/toolAccessService.d.ts +9 -0
  290. package/backend/dist/services/toolAccessService.d.ts.map +1 -0
  291. package/backend/dist/services/toolAccessService.js +60 -0
  292. package/backend/dist/services/toolAccessService.js.map +1 -0
  293. package/backend/dist/services/toolApprovalService.d.ts +34 -0
  294. package/backend/dist/services/toolApprovalService.d.ts.map +1 -0
  295. package/backend/dist/services/toolApprovalService.js +188 -0
  296. package/backend/dist/services/toolApprovalService.js.map +1 -0
  297. package/backend/dist/services/toolGatewayService.d.ts +53 -0
  298. package/backend/dist/services/toolGatewayService.d.ts.map +1 -0
  299. package/backend/dist/services/toolGatewayService.js +249 -0
  300. package/backend/dist/services/toolGatewayService.js.map +1 -0
  301. package/backend/dist/services/toolServerService.d.ts +57 -0
  302. package/backend/dist/services/toolServerService.d.ts.map +1 -0
  303. package/backend/dist/services/toolServerService.js +521 -0
  304. package/backend/dist/services/toolServerService.js.map +1 -0
  305. package/backend/dist/services/voiceAccessService.d.ts +10 -0
  306. package/backend/dist/services/voiceAccessService.d.ts.map +1 -0
  307. package/backend/dist/services/voiceAccessService.js +74 -0
  308. package/backend/dist/services/voiceAccessService.js.map +1 -0
  309. package/backend/dist/services/voiceProfileService.d.ts +20 -0
  310. package/backend/dist/services/voiceProfileService.d.ts.map +1 -1
  311. package/backend/dist/services/voiceProfileService.js +60 -0
  312. package/backend/dist/services/voiceProfileService.js.map +1 -1
  313. package/backend/dist/storage.d.ts +28 -1
  314. package/backend/dist/storage.d.ts.map +1 -1
  315. package/backend/dist/storage.js +100 -1
  316. package/backend/dist/storage.js.map +1 -1
  317. package/backend/dist/storageMappers.d.ts +2 -2
  318. package/backend/dist/storageMappers.d.ts.map +1 -1
  319. package/backend/dist/storageMappers.js.map +1 -1
  320. package/backend/dist/types/index.d.ts +197 -2
  321. package/backend/dist/types/index.d.ts.map +1 -1
  322. package/backend/dist/types/index.js.map +1 -1
  323. package/backend/dist/types/tools.d.ts +137 -0
  324. package/backend/dist/types/tools.d.ts.map +1 -0
  325. package/backend/dist/types/tools.js +25 -0
  326. package/backend/dist/types/tools.js.map +1 -0
  327. package/backend/dist/utils/chatDocumentContext.d.ts +26 -1
  328. package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -1
  329. package/backend/dist/utils/chatDocumentContext.js +87 -18
  330. package/backend/dist/utils/chatDocumentContext.js.map +1 -1
  331. package/backend/dist/utils/documentExtraction.d.ts +69 -0
  332. package/backend/dist/utils/documentExtraction.d.ts.map +1 -0
  333. package/backend/dist/utils/documentExtraction.js +545 -0
  334. package/backend/dist/utils/documentExtraction.js.map +1 -0
  335. package/backend/dist/utils/hybridRetrieval.d.ts +34 -0
  336. package/backend/dist/utils/hybridRetrieval.d.ts.map +1 -0
  337. package/backend/dist/utils/hybridRetrieval.js +119 -0
  338. package/backend/dist/utils/hybridRetrieval.js.map +1 -0
  339. package/backend/dist/utils/icsCalendar.d.ts +27 -0
  340. package/backend/dist/utils/icsCalendar.d.ts.map +1 -0
  341. package/backend/dist/utils/icsCalendar.js +313 -0
  342. package/backend/dist/utils/icsCalendar.js.map +1 -0
  343. package/backend/dist/utils/imageEditUpload.d.ts +29 -0
  344. package/backend/dist/utils/imageEditUpload.d.ts.map +1 -0
  345. package/backend/dist/utils/imageEditUpload.js +82 -0
  346. package/backend/dist/utils/imageEditUpload.js.map +1 -0
  347. package/backend/dist/utils/logRedaction.d.ts +2 -0
  348. package/backend/dist/utils/logRedaction.d.ts.map +1 -0
  349. package/backend/dist/utils/logRedaction.js +66 -0
  350. package/backend/dist/utils/logRedaction.js.map +1 -0
  351. package/backend/dist/utils/logger.d.ts +3 -0
  352. package/backend/dist/utils/logger.d.ts.map +1 -1
  353. package/backend/dist/utils/logger.js +63 -20
  354. package/backend/dist/utils/logger.js.map +1 -1
  355. package/backend/dist/utils/pluginChatAdapter.d.ts +5 -1
  356. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
  357. package/backend/dist/utils/pluginChatAdapter.js +83 -0
  358. package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
  359. package/backend/dist/utils/pluginDefinitionTrust.js +1 -1
  360. package/backend/dist/utils/resourceLimits.d.ts +61 -2
  361. package/backend/dist/utils/resourceLimits.d.ts.map +1 -1
  362. package/backend/dist/utils/resourceLimits.js +59 -0
  363. package/backend/dist/utils/resourceLimits.js.map +1 -1
  364. package/backend/dist/utils/toolEgress.d.ts +22 -0
  365. package/backend/dist/utils/toolEgress.d.ts.map +1 -0
  366. package/backend/dist/utils/toolEgress.js +157 -0
  367. package/backend/dist/utils/toolEgress.js.map +1 -0
  368. package/backend/dist/utils/websocketMessages.d.ts +6 -0
  369. package/backend/dist/utils/websocketMessages.d.ts.map +1 -1
  370. package/backend/dist/utils/websocketMessages.js +8 -0
  371. package/backend/dist/utils/websocketMessages.js.map +1 -1
  372. package/backend/dist/utils/zipArchive.d.ts +32 -0
  373. package/backend/dist/utils/zipArchive.d.ts.map +1 -0
  374. package/backend/dist/utils/zipArchive.js +171 -0
  375. package/backend/dist/utils/zipArchive.js.map +1 -0
  376. package/backend/dist/websocketServer.d.ts.map +1 -1
  377. package/backend/dist/websocketServer.js +142 -35
  378. package/backend/dist/websocketServer.js.map +1 -1
  379. package/backend/package.json +1 -1
  380. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  381. package/frontend/dist/assets/index-BPsH9FII.js +80 -0
  382. package/frontend/dist/assets/index-BtXF0Oxa.css +1 -0
  383. package/frontend/dist/index.html +18 -18
  384. package/frontend/dist/js/{ArtifactContainer-CpUi6ekF.js → ArtifactContainer-CIoFoMv8.js} +1 -1
  385. package/frontend/dist/js/{ArtifactDemoPage-BeNs3gHp.js → ArtifactDemoPage-D0JEIAbZ.js} +1 -1
  386. package/frontend/dist/js/{ArtifactSandboxFrame-qsj_Y3LV.js → ArtifactSandboxFrame-REazyIrx.js} +2 -2
  387. package/frontend/dist/js/ArtifactSlideOutPanel-A-i94ghF.js +1 -0
  388. package/frontend/dist/js/AutomationsPage-Dow_lbIf.js +1 -0
  389. package/frontend/dist/js/{Button-BPf_pOxH.js → Button-C0r3J9G_.js} +1 -1
  390. package/frontend/dist/js/CalendarPage-DLjasZOd.js +1 -0
  391. package/frontend/dist/js/ChannelsPage-C8hvTD7J.js +1 -0
  392. package/frontend/dist/js/ChatPage-BAgBHUES.js +16 -0
  393. package/frontend/dist/js/EvaluationsPage-Bm8FRoeX.js +2 -0
  394. package/frontend/dist/js/{FirstTimeSetup-Df0YJni3.js → FirstTimeSetup-BxJapNul.js} +1 -1
  395. package/frontend/dist/js/GalleryPage-DHz9DkK7.js +1 -0
  396. package/frontend/dist/js/HomePage-BqNy-FWX.js +1 -0
  397. package/frontend/dist/js/LibreClawPage-BDzDILjY.js +1 -0
  398. package/frontend/dist/js/{ModelManagerModals-DcLGYN3l.js → ModelManagerModals-DX9eT5r2.js} +1 -1
  399. package/frontend/dist/js/ModelSelector-ol8mK2ja.js +1 -0
  400. package/frontend/dist/js/NotesPage-DzHEx2O4.js +3 -0
  401. package/frontend/dist/js/{OptimizedSyntaxHighlighter-Dz7D1LPB.js → OptimizedSyntaxHighlighter-CZNPwN0i.js} +1 -1
  402. package/frontend/dist/js/PersonasPage-M_WKH2a9.js +13 -0
  403. package/frontend/dist/js/PluginUsagePage-Ctoka6JZ.js +1 -0
  404. package/frontend/dist/js/RichMessageContent-BqgafH4p.js +3 -0
  405. package/frontend/dist/js/SettingsModal-R9EDadAV.js +19 -0
  406. package/frontend/dist/js/{SettingsToggle-woG_WebF.js → SettingsToggle-BIVyfGjl.js} +1 -1
  407. package/frontend/dist/js/SystemPage-aOkrSuY7.js +1 -0
  408. package/frontend/dist/js/UserManagementPage-BOuaX3ay.js +1 -0
  409. package/frontend/dist/js/WorkPage-DxZISerQ.js +6 -0
  410. package/frontend/dist/js/api-6bSMtSNh.js +14 -0
  411. package/frontend/dist/js/{appStore-0JnCUlEq.js → appStore-CdObhQBb.js} +2 -2
  412. package/frontend/dist/js/ar-DT_VLBO3.js +2 -0
  413. package/frontend/dist/js/{authStore-DbMdvNgJ.js → authStore-DbqqrfZv.js} +3 -3
  414. package/frontend/dist/js/{babel-BsYoxD-7.js → babel-DSqqk5kt.js} +1 -1
  415. package/frontend/dist/js/bn-BrvEqhGA.js +2 -0
  416. package/frontend/dist/js/chatStore-DbZPJNsu.js +3 -0
  417. package/frontend/dist/js/{config-DSOYQ9a3.js → config-8KdgjtEx.js} +1 -1
  418. package/frontend/dist/js/cs-BthnM_YI.js +2 -0
  419. package/frontend/dist/js/da-DCth-6_j.js +2 -0
  420. package/frontend/dist/js/de-BBWt0gJ_.js +2 -0
  421. package/frontend/dist/js/es-DuslOPqM.js +2 -0
  422. package/frontend/dist/js/{estree-BcnBcOAx.js → estree-BU5-LV_1.js} +3 -3
  423. package/frontend/dist/js/evaluationsApi-CwZJsgeG.js +1 -0
  424. package/frontend/dist/js/fr-DZAeg46S.js +2 -0
  425. package/frontend/dist/js/hi-ijDSiY77.js +2 -0
  426. package/frontend/dist/js/{html-DkY55Jys.js → html-DeoAy2bo.js} +2 -2
  427. package/frontend/dist/js/id-BS6qS0oq.js +2 -0
  428. package/frontend/dist/js/is-CO2PMDte.js +2 -0
  429. package/frontend/dist/js/it-ChhxT4hs.js +2 -0
  430. package/frontend/dist/js/ja-cyeqUeJN.js +2 -0
  431. package/frontend/dist/js/ko-CfqHTLXj.js +2 -0
  432. package/frontend/dist/js/{markdown-IZSI9DXw.js → markdown-DOLsYkBY.js} +3 -3
  433. package/frontend/dist/js/markdown-core-BK7WVOb7.js +32 -0
  434. package/frontend/dist/js/{markdown-math-DK846gXU.js → markdown-math-e1ByS3KY.js} +5 -5
  435. package/frontend/dist/js/{messageCodeStyles-BFNR9Wv6.js → messageCodeStyles-DhVgizF-.js} +2 -2
  436. package/frontend/dist/js/ms-DZ5pACe1.js +2 -0
  437. package/frontend/dist/js/nl-BsRsnOVp.js +2 -0
  438. package/frontend/dist/js/pl-DXSTAW4M.js +2 -0
  439. package/frontend/dist/js/{postcss-BJ0okz7n.js → postcss-Bg15EcFE.js} +1 -1
  440. package/frontend/dist/js/pt-DmDx0JxB.js +2 -0
  441. package/frontend/dist/js/{react-vendor-C5yShNlM.js → react-vendor-BG_HPV6X.js} +1 -1
  442. package/frontend/dist/js/router-vendor-CbexJIsv.js +1 -0
  443. package/frontend/dist/js/ru-d2g8EWfY.js +2 -0
  444. package/frontend/dist/js/{standalone-Csw3jfJ_.js → standalone-BO5pzI8_.js} +3 -3
  445. package/frontend/dist/js/sv-CIhYUTVQ.js +2 -0
  446. package/frontend/dist/js/{syntax-highlight-3EEX6CGL.js → syntax-highlight-DcR9Vhb7.js} +3 -3
  447. package/frontend/dist/js/th-B3wSxanB.js +2 -0
  448. package/frontend/dist/js/tr-R4UGgPOY.js +2 -0
  449. package/frontend/dist/js/{typescript-CnF4UVx7.js → typescript-6GJ8APmn.js} +1 -1
  450. package/frontend/dist/js/ui-CV0LYmkM.js +2 -0
  451. package/frontend/dist/js/ui-vendor-CWjIBW-z.js +177 -0
  452. package/frontend/dist/js/uk-BzUF4Vkt.js +2 -0
  453. package/frontend/dist/js/{useTranslation-Bho4HCyg.js → useTranslation-5b5UhAc9.js} +1 -1
  454. package/frontend/dist/js/{utils-D9W1Lnkn.js → utils-BGrdX9ie.js} +1 -1
  455. package/frontend/dist/js/{utils-vendor-DWh39_3x.js → utils-vendor-9bQ62WeD.js} +1 -1
  456. package/frontend/dist/js/vi-CKc6Fg4h.js +2 -0
  457. package/frontend/dist/js/{workApi-C3uy9EDT.js → workApi-BruWTlHM.js} +3 -3
  458. package/frontend/dist/js/{yaml-DzT5hBSH.js → yaml-DUeWcOOH.js} +2 -2
  459. package/frontend/dist/js/zh-CXL-kDe8.js +2 -0
  460. package/package.json +2 -2
  461. package/plugins/openai.json +52 -9
  462. package/frontend/dist/assets/index-6o-Hc2wS.js +0 -41
  463. package/frontend/dist/assets/index-D-pM957b.css +0 -1
  464. package/frontend/dist/js/ArtifactSlideOutPanel-CSFRluWA.js +0 -1
  465. package/frontend/dist/js/AutomationsPage-KUeWoZNv.js +0 -1
  466. package/frontend/dist/js/CalendarPage-D9I972w8.js +0 -1
  467. package/frontend/dist/js/ChatPage-CmBx4oAL.js +0 -16
  468. package/frontend/dist/js/GalleryPage-bLCrdJN_.js +0 -1
  469. package/frontend/dist/js/HomePage-Uc6PEg-U.js +0 -1
  470. package/frontend/dist/js/LibreClawPage-CG63DHg1.js +0 -1
  471. package/frontend/dist/js/ModelSelector-yxJC64rM.js +0 -1
  472. package/frontend/dist/js/ModelsPage-1R_TxgmJ.js +0 -2
  473. package/frontend/dist/js/NotesPage-L65j5HoW.js +0 -1
  474. package/frontend/dist/js/PersonasPage-CKeBpHIH.js +0 -13
  475. package/frontend/dist/js/PluginUsagePage-BX1SKMbW.js +0 -1
  476. package/frontend/dist/js/RichMessageContent-DiySVYGB.js +0 -3
  477. package/frontend/dist/js/SettingsModal-68SG1uZ2.js +0 -1
  478. package/frontend/dist/js/SystemPage-CytpZiQV.js +0 -1
  479. package/frontend/dist/js/UserManagementPage-BzJBvZiS.js +0 -1
  480. package/frontend/dist/js/WorkPage-C8gr0QJe.js +0 -6
  481. package/frontend/dist/js/api-BDtqBtqw.js +0 -14
  482. package/frontend/dist/js/ar-CSpi37Gr.js +0 -2
  483. package/frontend/dist/js/bn-CyH1BeDD.js +0 -2
  484. package/frontend/dist/js/chatStore-CHQ2uINS.js +0 -3
  485. package/frontend/dist/js/cs-Cv2NfRK5.js +0 -2
  486. package/frontend/dist/js/da-D6D6IvPK.js +0 -2
  487. package/frontend/dist/js/de-BNoJJTrT.js +0 -2
  488. package/frontend/dist/js/es-kzo9C7q_.js +0 -2
  489. package/frontend/dist/js/fr-CjHYvJRp.js +0 -2
  490. package/frontend/dist/js/hi-BU98AdCQ.js +0 -2
  491. package/frontend/dist/js/id-CpdedejX.js +0 -2
  492. package/frontend/dist/js/is-Cp5dDWBH.js +0 -2
  493. package/frontend/dist/js/it-CuH_cK4U.js +0 -2
  494. package/frontend/dist/js/ja-BWXXXiHn.js +0 -2
  495. package/frontend/dist/js/ko-DQgv2M1t.js +0 -2
  496. package/frontend/dist/js/markdown-core-BmPPZiuD.js +0 -31
  497. package/frontend/dist/js/ms-DCcRoIcX.js +0 -2
  498. package/frontend/dist/js/nl-CbKR1_EU.js +0 -2
  499. package/frontend/dist/js/pl-CRyJZccn.js +0 -2
  500. package/frontend/dist/js/pt-BXYmHFGH.js +0 -2
  501. package/frontend/dist/js/router-vendor-DGFGM3EP.js +0 -1
  502. package/frontend/dist/js/ru-M9SyZG4b.js +0 -2
  503. package/frontend/dist/js/sv-DJ486LTU.js +0 -2
  504. package/frontend/dist/js/th-Ch7gKtZv.js +0 -2
  505. package/frontend/dist/js/tr-ClehWhSC.js +0 -2
  506. package/frontend/dist/js/ui-CC-K19wO.js +0 -2
  507. package/frontend/dist/js/ui-vendor-B1UgO3vd.js +0 -177
  508. package/frontend/dist/js/uk-BqAd5zHF.js +0 -2
  509. package/frontend/dist/js/vi-D9gjlDVB.js +0 -2
  510. package/frontend/dist/js/zh-DKTyHkiR.js +0 -2
@@ -1 +1 @@
1
- import{p as e}from"./markdown-core-BmPPZiuD.js";import{t}from"./utils-D9W1Lnkn.js";var n=e();function r({checked:e,onChange:r,disabled:i=!1}){return(0,n.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>r(e.target.checked),disabled:i,className:`sr-only`}),(0,n.jsx)(`div`,{className:t(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2`,i?`bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed`:e?`bg-primary-600 dark:bg-primary-500`:`bg-gray-200 dark:bg-dark-300`),children:(0,n.jsx)(`span`,{className:t(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})]})}export{r as t};
1
+ import{g as e}from"./markdown-core-BK7WVOb7.js";import{t}from"./utils-BGrdX9ie.js";var n=e();function r({checked:e,onChange:r,disabled:i=!1}){return(0,n.jsxs)(`label`,{className:`flex items-center cursor-pointer`,children:[(0,n.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>r(e.target.checked),disabled:i,className:`sr-only`}),(0,n.jsx)(`div`,{className:t(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2`,i?`bg-gray-100 dark:bg-dark-200 opacity-50 cursor-not-allowed`:e?`bg-primary-600 dark:bg-primary-500`:`bg-gray-200 dark:bg-dark-300`),children:(0,n.jsx)(`span`,{className:t(`inline-block h-4 w-4 transform rounded-full bg-white transition-transform`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})]})}export{r as t};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-hePW80VL.js";import{_ as e,g as t}from"./markdown-core-BK7WVOb7.js";import{t as n}from"./useTranslation-5b5UhAc9.js";import{t as r}from"./utils-BGrdX9ie.js";import{Bt as i,Dn as a,Dt as o,I as s,J as c,Jn as l,Yn as u,bn as d,h as f,ut as p,xt as m,z as h}from"./ui-vendor-CWjIBW-z.js";import{t as g}from"./workApi-BruWTlHM.js";import{s as _}from"./api-6bSMtSNh.js";import{t as v}from"./Button-C0r3J9G_.js";import{a as y,o as b}from"./ui-CV0LYmkM.js";import{w as x}from"../assets/index-BPsH9FII.js";e();var S=t(),C=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),w=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),T=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),E=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`${C.format(e/1024**n)} ${t[n]}`},D=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`},O=e=>Math.min(100,Math.max(0,Number.isFinite(e)?e:0)),k=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`}},A=({title:e,description:t,icon:n,className:i,action:a,children:o})=>(0,S.jsxs)(`section`,{className:r(`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`,i),children:[(0,S.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,S.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,S.jsx)(`div`,{className:`mt-0.5 rounded-xl bg-primary-500/10 p-1.5 text-primary-600 dark:text-primary-300`,children:(0,S.jsx)(n,{className:`h-4 w-4`})}),(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e}),t&&(0,S.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:t})]})]}),a]}),o]}),j=({label:e,value:t,mono:n})=>(0,S.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,S.jsx)(`dt`,{className:`shrink-0 text-xs text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`dd`,{className:r(`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})]}),M=({value:e,tone:t=`primary`})=>(0,S.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(O(e)),children:(0,S.jsx)(`div`,{className:r(`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:`${O(e)}%`}})}),N=()=>{let{t:e}=n(),{data:t,error:i,isFetching:a,refetch:o}=x({queryKey:[`work-admin-overview`],queryFn:async()=>{let t=await g.adminOverview();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1});if(!t)return i?(0,S.jsx)(A,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:l,children:(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 px-4 py-4 sm:px-5`,children:[(0,S.jsxs)(`div`,{className:`flex items-start gap-3 text-sm text-red-700 dark:text-red-300`,children:[(0,S.jsx)(f,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsx)(`p`,{children:i instanceof Error&&i.message?i.message:e(`systemPage.loadFailed`)})]}),(0,S.jsx)(v,{variant:`outline`,size:`sm`,onClick:()=>void o(),disabled:a,children:e(`common.retry`)})]})}):null;let s=t=>e(t===null?`systemPage.work.stateUnknown`:t?`systemPage.work.stateRunning`:`systemPage.work.stateStopped`),c=t=>t===`running`?e(`systemPage.work.stateRunning`):t===`starting`?e(`systemPage.work.stateStarting`):`—`;return(0,S.jsxs)(A,{title:e(`systemPage.work.title`),description:e(`systemPage.work.description`),icon:l,action:(0,S.jsxs)(`span`,{className:r(`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,S.jsx)(`span`,{className:r(`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,S.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,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),!t.runtimeAvailable&&t.runtimeReason&&(0,S.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,S.jsx)(f,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsx)(`p`,{children:t.runtimeReason})]}),t.tasks.length===0?(0,S.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,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{"data-testid":`system-work-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,S.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`systemPage.work.owner`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.task`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.state`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.preview`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:e(`systemPage.work.terminals`)}),(0,S.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`systemPage.work.updated`)})]})}),(0,S.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:t.tasks.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-gray-800 dark:text-dark-800`,children:e.ownerUsername}),(0,S.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,S.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.title}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.model})]}),(0,S.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,S.jsxs)(`span`,{className:r(`inline-flex items-center gap-1.5 text-xs`,e.running?`text-emerald-700 dark:text-emerald-300`:`text-gray-600 dark:text-dark-600`),children:[(0,S.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,e.running===null?`bg-amber-400`:e.running?`bg-emerald-500`:`bg-gray-400`)}),s(e.running)]})}),(0,S.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:c(e.previewStatus)}),(0,S.jsx)(`td`,{className:`px-4 py-2.5 text-xs text-gray-600 dark:text-dark-600`,children:e.terminalSessions}),(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-600 dark:text-dark-600`,children:T.format(e.updatedAt)})]},e.id))})]})})]})},P=()=>{let{t:e}=n(),{data:t,error:i,isLoading:a,isFetching:l,refetch:u}=x({queryKey:[`system-diagnostics`],queryFn:async()=>{let t=await _.getDiagnostics();if(!t.success||!t.data)throw Error(t.error||e(`systemPage.loadFailed`));return t.data},refetchInterval:3e4,refetchIntervalInBackground:!1}),d=i?i instanceof Error?i.message:e(`systemPage.loadFailed`):null;return a&&!t?(0,S.jsx)(b,{width:`wide`,children:(0,S.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,S.jsx)(o,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,S.jsxs)(b,{width:`wide`,children:[(0,S.jsx)(y,{eyebrow:e(`systemPage.eyebrow`),title:e(`systemPage.title`),description:e(`systemPage.description`),actions:(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,S.jsx)(`span`,{className:`hidden text-xs text-gray-500 dark:text-dark-500 sm:inline`,children:e(`systemPage.updated`,{date:T.format(t.generatedAt)})}),(0,S.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>void u(),disabled:l,children:[(0,S.jsx)(c,{className:r(`h-4 w-4`,l&&`animate-spin`)}),(0,S.jsx)(`span`,{className:`sr-only`,children:e(`systemPage.refresh`)})]})]})}),d&&(0,S.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,S.jsx)(f,{className:`h-4 w-4 shrink-0`}),(0,S.jsx)(`span`,{children:d})]}),t&&(0,S.jsxs)(`div`,{"data-testid":`system-dashboard`,className:`space-y-4`,children:[(0,S.jsx)(F,{diagnostics:t}),(0,S.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,S.jsx)(I,{diagnostics:t}),(0,S.jsx)(L,{diagnostics:t})]}),(0,S.jsx)(R,{diagnostics:t}),(0,S.jsx)(z,{diagnostics:t}),(0,S.jsx)(N,{}),(0,S.jsx)(V,{diagnostics:t}),(0,S.jsxs)(`div`,{className:`flex items-start gap-2 px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:[(0,S.jsx)(s,{className:`mt-0.5 h-4 w-4 shrink-0 text-primary-500`}),(0,S.jsx)(`p`,{children:e(`systemPage.securityNote`)})]})]})]})},F=({diagnostics:e})=>{let{t}=n(),r=e.filesystems.find(e=>e.label===`Data directory`)??e.filesystems[0],o=[{label:t(`systemPage.cards.uptime`),value:D(e.host.uptimeSeconds),detail:t(`systemPage.cards.uptimeDetail`,{date:T.format(e.host.bootedAt)}),icon:a},{label:t(`systemPage.cards.memory`),value:`${w.format(e.memory.usedPercent)}%`,detail:t(`systemPage.cards.memoryDetail`,{used:E(e.memory.usedBytes),total:E(e.memory.totalBytes)}),icon:m},{label:t(`systemPage.cards.freeSpace`),value:r?E(r.freeBytes):`—`,detail:r?t(`systemPage.cards.freeSpaceDetail`,{label:r.label,total:E(r.totalBytes)}):t(`systemPage.cards.unavailable`),icon:i},{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:d}];return(0,S.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:o.map(e=>{let t=e.icon;return(0,S.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,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,S.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,S.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,S.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})})},I=({diagnostics:e})=>{let{t}=n(),{host:r,runtime:i}=e;return(0,S.jsx)(A,{title:t(`systemPage.host.title`),description:t(`systemPage.host.description`),icon:h,action:(0,S.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:r.containerized?t(`systemPage.host.container`):t(`systemPage.host.native`)}),children:(0,S.jsxs)(`dl`,{className:`px-4 py-2 sm:px-5`,children:[(0,S.jsx)(j,{label:t(`systemPage.host.hostname`),value:r.hostname}),(0,S.jsx)(j,{label:t(`systemPage.host.operatingSystem`),value:`${r.platform} ${r.release} · ${r.architecture}`}),(0,S.jsx)(j,{label:t(`systemPage.host.processor`),value:`${r.cpuModel} · ${r.logicalCpus} ${t(`systemPage.host.logicalCpus`)}`}),(0,S.jsx)(j,{label:t(`systemPage.host.loadAverage`),value:r.loadAverage.map(e=>w.format(e)).join(` · `)}),(0,S.jsx)(j,{label:t(`systemPage.host.libreVersion`),value:i.appVersion}),(0,S.jsx)(j,{label:t(`systemPage.host.nodeVersion`),value:i.nodeVersion}),(0,S.jsx)(j,{label:t(`systemPage.host.process`),value:`PID ${i.processId} · ${D(i.processUptimeSeconds)}`}),(0,S.jsx)(j,{label:t(`systemPage.host.workingDirectory`),value:i.workingDirectory,mono:!0})]})})},L=({diagnostics:e})=>{let{t}=n(),{memory:r}=e;return(0,S.jsx)(A,{title:t(`systemPage.memory.title`),description:t(`systemPage.memory.description`),icon:m,children:(0,S.jsxs)(`div`,{className:`space-y-4 p-4 sm:p-5`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-2 flex items-end justify-between gap-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`text-2xl tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:[w.format(r.usedPercent),`%`]}),(0,S.jsx)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.usedOf`,{used:E(r.usedBytes),total:E(r.totalBytes)})})]}),(0,S.jsx)(`span`,{className:`text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`systemPage.memory.free`,{value:E(r.freeBytes)})})]}),(0,S.jsx)(M,{value:r.usedPercent,tone:r.usedPercent>=85?`warning`:`primary`})]}),(0,S.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[[t(`systemPage.memory.processRss`),r.processRssBytes],[t(`systemPage.memory.heapUsed`),r.heapUsedBytes],[t(`systemPage.memory.heapTotal`),r.heapTotalBytes],[t(`systemPage.memory.external`),r.externalBytes]].map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-lg text-gray-950 dark:text-dark-950`,children:E(Number(t))})]},String(e)))})]})})},R=({diagnostics:e})=>{let{t}=n();return(0,S.jsx)(A,{title:t(`systemPage.storage.title`),description:t(`systemPage.storage.description`),icon:i,children:e.filesystems.length===0?(0,S.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.storage.empty`)}):(0,S.jsx)(`div`,{className:`grid gap-3 p-4 sm:grid-cols-2 sm:p-5`,children:e.filesystems.map(e=>(0,S.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,S.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:e.label}),(0,S.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.path})]}),(0,S.jsxs)(`span`,{className:`shrink-0 text-sm tabular-nums text-gray-700 dark:text-dark-700`,children:[w.format(e.usedPercent),`%`]})]}),(0,S.jsx)(`div`,{className:`mt-4`,children:(0,S.jsx)(M,{value:e.usedPercent,tone:e.usedPercent>=85?`warning`:`primary`})}),(0,S.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[11px] text-gray-500 dark:text-dark-500`,children:[(0,S.jsx)(`span`,{children:t(`systemPage.storage.used`,{value:E(e.usedBytes)})}),(0,S.jsx)(`span`,{children:t(`systemPage.storage.free`,{value:E(e.freeBytes)})})]})]},`${e.label}:${e.path}`))})})},z=({diagnostics:e})=>{let{t}=n(),{docker:i}=e;return(0,S.jsx)(A,{title:t(`systemPage.docker.title`),description:t(`systemPage.docker.description`),icon:d,action:(0,S.jsxs)(`span`,{className:r(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.1em]`,i.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,S.jsx)(`span`,{className:r(`h-1.5 w-1.5 rounded-full`,i.available?`bg-emerald-500`:`bg-gray-400`)}),i.available?t(`systemPage.docker.connected`):t(`systemPage.docker.unavailable`)]}),children:i.available?(0,S.jsxs)(S.Fragment,{children:[(0,S.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`),i.runningContainers],[t(`systemPage.docker.stopped`),i.stoppedContainers],[t(`systemPage.docker.paused`),i.pausedContainers],[t(`systemPage.docker.total`),i.totalContainers]].map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,S.jsx)(`div`,{className:`text-[11px] text-gray-500 dark:text-dark-500`,children:e}),(0,S.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:t})]},String(e)))}),(0,S.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-4 sm:px-5`,children:[i.serverVersion&&(0,S.jsx)(B,{label:t(`systemPage.docker.version`),value:i.serverVersion}),i.operatingSystem&&(0,S.jsx)(B,{label:t(`systemPage.docker.host`),value:i.operatingSystem}),i.architecture&&(0,S.jsx)(B,{label:t(`systemPage.docker.architecture`),value:i.architecture}),i.logicalCpus!==void 0&&(0,S.jsx)(B,{label:t(`systemPage.docker.cpus`),value:String(i.logicalCpus)}),i.memoryBytes!==void 0&&(0,S.jsx)(B,{label:t(`systemPage.docker.memory`),value:E(i.memoryBytes)})]}),i.containers.length===0?(0,S.jsx)(`p`,{className:`px-5 pb-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.empty`)}):(0,S.jsx)(`div`,{className:`overflow-x-auto border-t border-gray-200/70 dark:border-white/[0.07]`,children:(0,S.jsxs)(`table`,{"data-testid":`system-docker-table`,className:`w-full min-w-[760px] text-sm`,children:[(0,S.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:t(`systemPage.docker.container`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.image`)}),(0,S.jsx)(`th`,{className:`px-4 py-2 text-start font-medium`,children:t(`systemPage.docker.state`)}),(0,S.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:t(`systemPage.docker.created`)})]})}),(0,S.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:i.containers.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,S.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,S.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-gray-500 dark:text-dark-500`,children:e.id})]}),(0,S.jsx)(`td`,{className:`max-w-[280px] px-4 py-2.5`,children:(0,S.jsx)(`div`,{className:`truncate font-mono text-[11px] text-gray-600 dark:text-dark-600`,title:e.image,children:e.image})}),(0,S.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,S.jsx)(`span`,{className:r(`inline-flex rounded-full px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.08em]`,k(e.state)),children:e.state}),(0,S.jsx)(`div`,{className:`mt-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:e.status})]}),(0,S.jsx)(`td`,{className:`px-5 py-2.5 text-end text-xs text-gray-500 dark:text-dark-500`,children:e.createdAt?T.format(e.createdAt):`—`})]},e.id))})]})})]}):(0,S.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,S.jsx)(f,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{children:i.reason||t(`systemPage.docker.unavailableDetail`)}),(0,S.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-dark-500`,children:t(`systemPage.docker.socketStatus`,{status:i.socketMounted?t(`systemPage.docker.mounted`):t(`systemPage.docker.notMounted`)})})]})]})})},B=({label:e,value:t})=>(0,S.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,S.jsx)(`span`,{className:`text-gray-400 dark:text-dark-500`,children:e}),` `,t]}),V=({diagnostics:e})=>{let{t}=n();return(0,S.jsx)(A,{title:t(`systemPage.network.title`),description:t(`systemPage.network.description`),icon:p,children:e.network.interfaces.length===0?(0,S.jsx)(`p`,{className:`p-5 text-sm text-gray-500 dark:text-dark-500`,children:t(`systemPage.network.empty`)}):(0,S.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,S.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,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(u,{className:`h-4 w-4 text-primary-500`}),(0,S.jsx)(`h3`,{className:`font-mono text-xs font-medium text-gray-900 dark:text-dark-900`,children:e.name})]}),(0,S.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.addresses.map(e=>(0,S.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-white px-3 py-2 dark:bg-dark-100/80`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-gray-400 dark:text-dark-500`,children:e.family}),e.internal&&(0,S.jsx)(`span`,{className:`text-[10px] text-gray-400 dark:text-dark-500`,children:t(`systemPage.network.internal`)})]}),(0,S.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,S.jsxs)(`div`,{className:`mt-3 flex justify-between gap-4 text-[10px] text-gray-500 dark:text-dark-500`,children:[(0,S.jsxs)(`span`,{children:[`↓ `,E(e.receivedBytes??0)]}),(0,S.jsxs)(`span`,{children:[`↑ `,E(e.transmittedBytes??0)]})]})]},e.name))})})};export{P as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{t as r}from"./useTranslation-5b5UhAc9.js";import{Dn as i,In as a,J as o,N as s,O as c,Rn as l,U as u,X as d,_ as f,c as p,d as m,lr as h,s as g,tt as _,u as v}from"./ui-vendor-CWjIBW-z.js";import{i as y,t as b}from"./logger-DSXjF4ye.js";import{i as x,r as S,t as C}from"./workApi-BruWTlHM.js";import{C as w,I as T,N as E,b as D,d as O,v as k}from"./api-6bSMtSNh.js";import{n as A}from"./authStore-DbqqrfZv.js";import{t as j}from"./Button-C0r3J9G_.js";import{a as M,c as N,d as P,f as F,g as I,l as L,o as R,p as z,u as B,v as V}from"./ui-CV0LYmkM.js";import{E as H,w as U}from"../assets/index-BPsH9FII.js";import{t as W}from"./SettingsToggle-BIVyfGjl.js";var G=e(t(),1),K=n(),q=b(`components:user-manager`),J=()=>{let{t:e}=r(),t=H(),[n,a]=(0,G.useState)(!1),[o,l]=(0,G.useState)(null),[u,g]=(0,G.useState)({username:``,email:``,password:``,role:`user`}),{user:_}=A(),{data:v=[],isLoading:y}=U({queryKey:[`users`],queryFn:async()=>{let t=await T.getUsers();if(!t.success||!t.data)throw Error(e(`errors.generic`));return t.data}}),b=()=>t.invalidateQueries({queryKey:[`users`]}),x=v.filter(e=>e.status===`pending`),S=v.filter(e=>e.status!==`pending`),C=async t=>{t.preventDefault();try{let t=await T.createUser(u);t.success&&t.data&&(await b(),g({username:``,email:``,password:``,role:`user`}),a(!1),h.success(e(`userManager.form.createSuccess`)))}catch(t){q.error(`Error creating user:`,t);let n=e(`userManager.form.createFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.createFailed`)),h.error(n)}},w=async t=>{if(t.preventDefault(),o)try{let t={username:u.username,email:u.email,role:u.role};u.password&&u.password.trim()!==``&&(t.password=u.password);let n=await T.updateUser(o.id,t);n.success&&n.data&&(await b(),l(null),g({username:``,email:``,password:``,role:`user`}),h.success(e(`userManager.form.updateSuccess`)))}catch(t){q.error(`Error updating user:`,t);let n=e(`userManager.form.updateFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.form.updateFailed`)),h.error(n)}},E=async(t,n)=>{if(confirm(e(`userManager.deleteConfirm`,{name:n})))try{(await T.deleteUser(t)).success&&(await b(),h.success(e(`userManager.deleteSuccess`)))}catch(t){q.error(`Error deleting user:`,t);let n=e(`userManager.deleteFailed`);t instanceof Error&&`response`in t&&(n=t.response?.data?.message||e(`userManager.deleteFailed`)),h.error(n)}},D=async t=>{try{let n=await T.approveUser(t.id);n.success&&n.data&&(await b(),h.success(e(`userManager.approval.approved`,{name:t.username,defaultValue:`{{name}} can now sign in.`})))}catch(t){q.error(`Error approving user:`,t);let n=t;h.error(n.response?.data?.message||e(`userManager.approval.failed`,`The account could not be approved.`))}},O=e=>{l(e),g({username:e.username,email:e.email||``,password:``,role:e.role})};return y?(0,K.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,K.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-200 dark:border-gray-600 border-t-primary-500 rounded-full animate-spin`})}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`div`,{}),(0,K.jsxs)(j,{onClick:()=>a(!n),className:`flex items-center space-x-2 bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600`,children:[(0,K.jsx)(d,{size:16}),(0,K.jsx)(`span`,{children:e(`userManager.createUser`)})]})]}),n&&(0,K.jsxs)(N,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,K.jsxs)(P,{children:[(0,K.jsx)(F,{className:`text-gray-900 dark:text-gray-100`,children:e(`userManager.form.title.create`)}),(0,K.jsx)(B,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,K.jsx)(L,{children:(0,K.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(z,{htmlFor:`username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,K.jsx)(V,{id:`username`,value:u.username,onChange:e=>g({...u,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(z,{htmlFor:`email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,K.jsx)(V,{id:`email`,type:`email`,value:u.email,onChange:e=>g({...u,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(z,{htmlFor:`password`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.password`)}),(0,K.jsx)(V,{id:`password`,type:`password`,value:u.password,onChange:e=>g({...u,password:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(z,{htmlFor:`role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,K.jsxs)(`select`,{id:`role`,value:u.role,onChange:e=>g({...u,role:e.target.value}),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200`,children:[(0,K.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,K.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,K.jsx)(j,{type:`submit`,children:e(`userManager.form.createButton`)}),(0,K.jsx)(j,{type:`button`,variant:`outline`,onClick:()=>{g({username:``,email:``,password:``,role:`user`}),a(!1)},children:e(`common.cancel`)})]})]})})]}),o&&(0,K.jsxs)(N,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,K.jsxs)(P,{children:[(0,K.jsxs)(F,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.form.title.edit`),`: `,o.username]}),(0,K.jsx)(B,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,K.jsx)(L,{children:(0,K.jsxs)(`form`,{onSubmit:w,className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(z,{htmlFor:`edit-username`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.username`)}),(0,K.jsx)(V,{id:`edit-username`,value:u.username,onChange:e=>g({...u,username:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(z,{htmlFor:`edit-email`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.email`)}),(0,K.jsx)(V,{id:`edit-email`,type:`email`,value:u.email,onChange:e=>g({...u,email:e.target.value}),required:!0,className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(z,{htmlFor:`edit-password`,className:`text-gray-700 dark:text-gray-300`,children:[e(`userManager.form.password`),` (`,e(`common.optional`),`)`]}),(0,K.jsx)(V,{id:`edit-password`,type:`password`,value:u.password,onChange:e=>g({...u,password:e.target.value}),placeholder:e(`userManager.form.passwordHint`),className:`bg-white dark:bg-dark-100 border-gray-300 dark:border-dark-300 text-gray-900 dark:text-gray-100`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:`Use at least 12 characters, no more than 72 UTF-8 bytes, with uppercase, lowercase, and a number.`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(z,{htmlFor:`edit-role`,className:`text-gray-700 dark:text-gray-300`,children:e(`userManager.form.role`)}),(0,K.jsxs)(`select`,{id:`edit-role`,value:u.role,onChange:e=>g({...u,role:e.target.value}),disabled:o?.id===_?.id&&_?.role===`admin`,className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 bg-white dark:bg-dark-100 text-gray-900 dark:text-gray-100 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,K.jsx)(`option`,{value:`user`,children:e(`userManager.roles.user`)}),(0,K.jsx)(`option`,{value:`admin`,children:e(`userManager.roles.admin`)})]}),o?.id===_?.id&&_?.role===`admin`&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-ink-muted`,children:e(`userManager.cannotDeleteSelf`)})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,K.jsx)(j,{type:`submit`,children:e(`userManager.form.updateButton`)}),(0,K.jsx)(j,{type:`button`,variant:`outline`,onClick:()=>{l(null),g({username:``,email:``,password:``,role:`user`})},children:e(`common.cancel`)})]})]})})]}),x.length>0&&(0,K.jsxs)(N,{"data-testid":`pending-user-approvals`,className:`border border-warning-500/30 bg-warning-500/[0.06] shadow-lg`,children:[(0,K.jsxs)(P,{children:[(0,K.jsxs)(F,{className:`flex items-center gap-2 text-gray-900 dark:text-gray-100`,children:[(0,K.jsx)(i,{className:`h-5 w-5 text-warning-700 dark:text-warning-400`}),e(`userManager.approval.title`,`Pending approvals`),` (`,x.length,`)`]}),(0,K.jsx)(B,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.approval.description`,`Review new registrations before allowing them into this instance.`)})]}),(0,K.jsx)(L,{children:(0,K.jsx)(`div`,{className:`space-y-3`,children:x.map(t=>(0,K.jsxs)(`div`,{"data-testid":`pending-user-row`,className:`flex flex-col gap-4 rounded-xl border border-warning-500/25 bg-surface p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h3`,{className:`truncate font-medium text-ink`,children:t.username}),(0,K.jsx)(`p`,{className:`truncate text-sm text-ink-muted`,children:t.email||e(`userManager.noEmail`)}),(0,K.jsxs)(`p`,{className:`mt-1 text-xs text-ink-subtle`,children:[e(`userManager.approval.registered`,`Registered`),`:`,` `,new Date(t.createdAt).toLocaleString()]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,K.jsxs)(j,{type:`button`,size:`sm`,"data-testid":`approve-user-button`,onClick:()=>void D(t),className:`gap-2`,children:[(0,K.jsx)(m,{size:16}),e(`userManager.approval.activate`,`Activate account`)]}),(0,K.jsx)(j,{type:`button`,variant:`outline`,size:`sm`,"aria-label":e(`userManager.approval.reject`,`Reject registration`),onClick:()=>void E(t.id,t.username),className:`text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-900/20 dark:hover:text-red-300`,children:(0,K.jsx)(f,{size:16})})]})]},t.id))})})]}),(0,K.jsxs)(N,{className:`bg-white dark:bg-dark-25 border border-gray-200 dark:border-dark-200 shadow-lg`,children:[(0,K.jsxs)(P,{children:[(0,K.jsxs)(F,{className:`text-gray-900 dark:text-gray-100`,children:[e(`userManager.title`),` (`,S.length,`)`]}),(0,K.jsx)(B,{className:`text-gray-600 dark:text-gray-400`,children:e(`userManager.subtitle`)})]}),(0,K.jsx)(L,{children:(0,K.jsx)(`div`,{className:`space-y-3`,children:S.map(t=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-dark-100 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,K.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,K.jsx)(`div`,{className:`p-2 bg-primary-100 dark:bg-primary-900/20 rounded-lg`,children:t.role===`admin`?(0,K.jsx)(s,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`}):(0,K.jsx)(p,{className:`h-5 w-5 text-primary-600 dark:text-primary-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[t.username,t.id===_?.id&&(0,K.jsxs)(`span`,{className:`ml-2 text-xs text-primary-600 dark:text-primary-400 font-normal`,children:[`(`,e(`chatMessage.you`),`)`]})]}),(0,K.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[t.email||e(`userManager.noEmail`),` •`,` `,t.role===`admin`?e(`userManager.roles.admin`):e(`userManager.roles.user`)]}),(0,K.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-500`,children:[e(`userManager.columns.created`),`:`,` `,new Date(t.createdAt).toLocaleDateString()]})]})]}),(0,K.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,K.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>O(t),className:`text-gray-600 dark:text-gray-400 hover:text-primary-600 dark:hover:text-primary-400`,children:(0,K.jsx)(c,{size:16})}),(0,K.jsx)(j,{variant:`outline`,size:`sm`,onClick:()=>E(t.id,t.username),disabled:t.id===_?.id,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,K.jsx)(f,{size:16})})]})]},t.id))})})]})]})},Y=()=>{let{t:e}=r(),t=A(e=>e.systemInfo),n=A(e=>e.setSystemInfo),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let e=!1;return D.access().then(t=>{e||(t.success&&t.data?(a(t.data.enabled),s(t.data.lockedByEnv)):d(!0))}).catch(()=>{e||d(!0)}),()=>{e=!0}},[f]),(0,K.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.agentAccess.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.agentAccess.description`)}),o&&(0,K.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.agentAccess.lockedByEnv`)})]}),i===null&&u?(0,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>{d(!1),p(e=>e+1)},children:e(`common.retry`)}):(0,K.jsx)(W,{checked:i===!0,onChange:async r=>{l(!0);try{let i=await D.setAccess(r);if(!i.success||!i.data)throw Error(i.error||`Agent access update failed.`);a(i.data.enabled),t&&n({...t,agentsEnabled:i.data.enabled}),h.success(e(`userManager.agentAccess.saved`))}catch{h.error(e(`userManager.agentAccess.saveFailed`))}finally{l(!1)}},disabled:c||i===null||o})]})})},X=()=>{let{t:e}=r(),[t,n]=(0,G.useState)(null),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let e=!1;return O.getAccessMode().then(t=>{e||(t.success&&t.data?(n(t.data.mode),a(t.data.lockedByEnv)):l(!0))}).catch(()=>{e||l(!0)}),()=>{e=!0}},[u]),(0,K.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.tools.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.tools.description`)}),i&&(0,K.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400 mt-1`,children:e(`userManager.tools.lockedByEnv`)})]}),t===null&&c?(0,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>{l(!1),d(e=>e+1)},children:e(`common.retry`)}):(0,K.jsx)(W,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;s(!0);try{let t=await O.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:o||t===null||i})]})})},Z={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}},Q={getModes:async()=>y()?x(Z):(await S.get(`/voice-access`)).data,setMode:async(e,t)=>y()?x({feature:e,mode:t}):(await S.put(`/voice-access/${encodeURIComponent(e)}`,{mode:t})).data},ee=[{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`}],te=()=>{let{t:e}=r(),[t,n]=(0,G.useState)(null),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(0);(0,G.useEffect)(()=>{let e=!1;return Q.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 i=r?`all-users`:`admins`;a(t);try{let r=await Q.setMode(t,i);if(!r.success)throw Error(r.error||`Voice access update failed.`);n(e=>e&&{...e,[t]:{...e[t],mode:i}}),h.success(e(`userManager.voice.saved`))}catch{h.error(e(`userManager.voice.saveFailed`))}finally{a(null)}};return(0,K.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.voice.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.voice.description`)})]}),t===null&&o&&(0,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>{s(!1),l(e=>e+1)},children:e(`common.retry`)})]}),(0,K.jsx)(`div`,{className:`mt-3 space-y-2`,children:ee.map(n=>{let r=t?.[n.key];return(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:e(n.labelKey)}),r?.lockedByEnv&&(0,K.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:e(`userManager.voice.lockedByEnv`)})]}),(0,K.jsx)(W,{checked:r?.mode===`all-users`,onChange:e=>u(n.key,e),disabled:r===void 0||i===n.key||r.lockedByEnv})]},n.key)})})]})},ne=()=>{let{t:e}=r(),[t,n]=(0,G.useState)([]),[i,o]=(0,G.useState)([]),[s,c]=(0,G.useState)(!1),[u,p]=(0,G.useState)(!0),[m,_]=(0,G.useState)(!1),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(!1),[D,O]=(0,G.useState)(null),[k,A]=(0,G.useState)(``),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(``),[L,R]=(0,G.useState)(null),[z,B]=(0,G.useState)(!1),H=(0,G.useMemo)(()=>{let e=new Map;return i.forEach(t=>e.set(t.id,t.username)),e},[i]),U=(0,G.useCallback)(async()=>{p(!0),c(!1);try{let[e,t]=await Promise.all([E.getGroups(),T.getUsers()]);if(!e.success||!e.data)throw Error(e.error||`Failed to load groups.`);n(e.data),t.success&&t.data&&o(t.data)}catch{c(!0)}finally{p(!1)}},[]);(0,G.useEffect)(()=>{let e=setTimeout(()=>void U(),0);return()=>clearTimeout(e)},[U]);let W=async t=>{if(t.preventDefault(),!y.trim()){h.error(e(`userManager.groups.nameRequired`,`Give the group a name.`));return}w(!0);try{let t=await E.createGroup({name:y.trim(),description:x.trim()||void 0});if(!t.success)throw Error(t.error||`Group creation failed.`);b(``),S(``),_(!1),h.success(e(`userManager.groups.created`,`Group created.`)),await U()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.createFailed`,`The group could not be created.`))}finally{w(!1)}},q=async t=>{N(t.id);try{let n=await E.deleteGroup(t.id);if(!n.success)throw Error(n.error||`Group delete failed.`);h.success(e(`userManager.groups.deleted`,`Group deleted.`)),D===t.id&&O(null),await U()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.deleteFailed`,`The group could not be deleted.`))}finally{N(null)}},J=async t=>{if(k){N(t.id);try{let n=await E.addGroupMember(t.id,k);if(!n.success)throw Error(n.error||`Member add failed.`);A(``),h.success(e(`userManager.groups.memberAdded`,`Member added.`)),await U()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberAddFailed`,`The member could not be added.`))}finally{N(null)}}},Y=async(t,n)=>{N(t.id);try{let r=await E.removeGroupMember(t.id,n);if(!r.success)throw Error(r.error||`Member remove failed.`);h.success(e(`userManager.groups.memberRemoved`,`Member removed.`)),await U()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.groups.memberRemoveFailed`,`The member could not be removed.`))}finally{N(null)}},X=async t=>{if(F(t),R(null),t){B(!0);try{let e=await E.getEffectiveAccess(t);if(!e.success||!e.data)throw Error(e.error||`Access lookup failed.`);R(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{B(!1)}}},Z=e=>e.map(e=>({value:e.id,label:e.username}));return(0,K.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,K.jsx)(g,{className:`h-4 w-4 text-primary-500`}),e(`userManager.groups.title`,`Groups`)]}),(0,K.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.`)})]}),s?(0,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>void U(),children:e(`common.retry`)}):(0,K.jsxs)(j,{size:`sm`,variant:`outline`,onClick:()=>_(e=>!e),className:`gap-1.5`,children:[(0,K.jsx)(d,{size:14}),e(`userManager.groups.newGroup`,`New group`)]})]}),m&&(0,K.jsxs)(`form`,{onSubmit:W,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,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.nameLabel`,`Name`)}),(0,K.jsx)(V,{value:y,onChange:e=>b(e.target.value)})]}),(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.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,K.jsx)(V,{value:x,onChange:e=>S(e.target.value)})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(j,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>_(!1),children:e(`common.cancel`)}),(0,K.jsx)(j,{type:`submit`,size:`sm`,disabled:C,children:C?e(`userManager.groups.creating`,`Creating…`):e(`userManager.groups.create`,`Create group`)})]})]}),(0,K.jsx)(`div`,{className:`mt-4 space-y-3`,children:u?(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):s?(0,K.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,K.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=D===t.id,r=new Set(t.members.map(e=>e.user_id)),o=i.filter(e=>!r.has(e.id));return(0,K.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-100`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-4`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-start`,onClick:()=>{O(n?null:t.id),A(``)},"aria-expanded":n,children:[n?(0,K.jsx)(l,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,K.jsx)(a,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:[t.name,(0,K.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,K.jsx)(`span`,{className:`block truncate text-xs text-gray-500 dark:text-gray-400`,children:t.description})]})]}),(0,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>void q(t),disabled:M===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,K.jsx)(f,{size:16})})]}),n&&(0,K.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300 p-4 space-y-3`,children:[t.members.length===0?(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.noMembers`,`No members yet.`)}):(0,K.jsx)(`div`,{className:`space-y-2`,children:t.members.map(n=>(0,K.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,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:H.get(n.user_id)||n.user_id}),(0,K.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,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>void Y(t,n.user_id),disabled:M===t.id,"aria-label":e(`userManager.groups.removeMember`,`Remove member`),children:(0,K.jsx)(v,{size:16})})]},n.user_id))}),o.length>0&&(0,K.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(I,{label:e(`userManager.groups.addMember`,`Add member`),value:k,onChange:e=>A(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...Z(o)]})}),(0,K.jsx)(j,{size:`sm`,onClick:()=>void J(t),disabled:!k||M===t.id,className:`mb-0.5`,children:e(`userManager.groups.add`,`Add`)})]})]})]},t.id)})}),(0,K.jsxs)(`div`,{className:`mt-6 border-t border-gray-200 dark:border-dark-300 pt-4 space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.groups.effectiveTitle`,`Effective access`)}),(0,K.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,K.jsx)(I,{value:P,onChange:e=>void X(e.target.value),options:[{value:``,label:e(`userManager.groups.selectUser`,`Select a user…`)},...Z(i)]}),z&&(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}),L&&!z&&(0,K.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,K.jsxs)(`p`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:L.username}),(0,K.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[` · `,e(`userManager.groups.roleLabel`,`Role`),`: `,L.role,` · `,e(`userManager.groups.statusLabel`,`Status`),`: `,L.status]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.memberOf`,`Groups`)}),L.groups.length===0?(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:L.groups.map(e=>(0,K.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,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.featuresLabel`,`Feature access`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(L.features).map(([t,n])=>(0,K.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,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.groups.grantsLabel`,`Grants`)}),L.grants.length===0?(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.none`)}):(0,K.jsx)(`div`,{className:`space-y-1`,children:L.grants.map(t=>(0,K.jsxs)(`p`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[t.resourceType,`/`,t.resourceId,` ·`,` `,t.permission,` `,(0,K.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[`(`,e(`userManager.groups.grantVia`,`via`),` `,t.via,`)`]})]},t.id))})]})]})]})]})},re={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`},ie=()=>{let{t:e}=r(),[t,n]=(0,G.useState)([]),[i,s]=(0,G.useState)(!0),[c,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(``),[g,_]=(0,G.useState)(``),[v,y]=(0,G.useState)(`50`),b=(0,G.useCallback)(async()=>{s(!0),d(!1);try{let e=Number(v),t=await E.getAuditEvents({action:m.trim()||void 0,result:g||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{d(!0)}finally{s(!1)}},[m,g,v]);(0,G.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,K.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,K.jsx)(u,{className:`h-4 w-4 text-primary-500`}),e(`userManager.audit.title`,`Security audit log`)]}),(0,K.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,K.jsxs)(j,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:i,className:`gap-1.5`,children:[(0,K.jsx)(o,{size:14,className:i?`animate-spin`:void 0}),e(`common.refresh`)]})]}),(0,K.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-3`,children:[(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.actionFilter`,`Action`)}),(0,K.jsx)(V,{value:m,onChange:e=>h(e.target.value),placeholder:e(`userManager.audit.actionPlaceholder`,`e.g. auth.login`),spellCheck:!1,dir:`ltr`})]}),(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.resultFilter`,`Result`)}),(0,K.jsx)(I,{value:g,onChange:e=>_(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,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`userManager.audit.limitFilter`,`Limit`)}),(0,K.jsx)(V,{type:`number`,min:1,max:500,value:v,onChange:e=>y(e.target.value),dir:`ltr`})]})]}),(0,K.jsx)(`div`,{className:`mt-4 space-y-2`,children:i?(0,K.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):c?(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.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,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>void b(),children:e(`common.retry`)})]}):t.length===0?(0,K.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=f===t.id,r=t.details&&Object.keys(t.details).length>0;return(0,K.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-gray-50 dark:bg-dark-50`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 px-3 py-2 text-start`,onClick:()=>p(n?null:t.id),"aria-expanded":n,children:[r?n?(0,K.jsx)(l,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,K.jsx)(a,{className:`h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`}):(0,K.jsx)(`span`,{className:`h-4 w-4 shrink-0`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.action}),(0,K.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${re[t.result]||`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-300`}`,children:x(t.result)})]}),(0,K.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,K.jsxs)(K.Fragment,{children:[` · `,e(`userManager.audit.target`,`Target`),`:`,` `,t.targetType,t.targetId?`/${t.targetId}`:``]})]})]})]}),n&&r&&(0,K.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)})})]})},ae=()=>{let{t:e}=r(),[t,n]=(0,G.useState)(null),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let e=!1;return k.getModelAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):s(!0))}).catch(()=>{e||s(!0)}),()=>{e=!0}},[c]),(0,K.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.modelAccess.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.modelAccess.description`)})]}),t===null&&o?(0,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>{s(!1),l(e=>e+1)},children:e(`common.retry`)}):(0,K.jsx)(W,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;a(!0);try{if(!(await k.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{a(!1)}},disabled:i||t===null})]})})},oe=()=>{let{t:e}=r(),[t,n]=(0,G.useState)(null),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let e=!1;return w.getAccess().then(t=>{e||(t.success&&t.data?n(t.data.mode):s(!0))}).catch(()=>{e||s(!0)}),()=>{e=!0}},[c]),(0,K.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.webSearchAccess.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.webSearchAccess.description`)})]}),t===null&&o?(0,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>{s(!1),l(e=>e+1)},children:e(`common.retry`)}):(0,K.jsx)(W,{checked:t===`all-users`,onChange:async t=>{let r=t?`all-users`:`admins`;a(!0);try{if(!(await w.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{a(!1)}},disabled:i||t===null})]})})},se=()=>{let{t:e}=r(),t=A(e=>e.refreshWorkAccess),[n,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let e=!1;return C.access().then(t=>{e||(t.success&&t.data?i(t.data.mode):c(!0))}).catch(()=>{e||c(!0)}),()=>{e=!0}},[l]),(0,K.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workAccess.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workAccess.description`)})]}),n===null&&s?(0,K.jsx)(j,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),u(e=>e+1)},children:e(`common.retry`)}):(0,K.jsx)(W,{checked:n===`all-users`,onChange:async n=>{let r=n?`all-users`:`admins`;o(!0);try{if(!(await C.setAccess(r)).success)throw Error(`Work access update failed.`);i(r),await t(),h.success(e(`userManager.workAccess.saved`))}catch{h.error(e(`userManager.workAccess.saveFailed`))}finally{o(!1)}},disabled:a||n===null})]})})},$={name:``,image:``,memoryLimit:``,cpuLimit:``,pidsLimit:``,workspaceSize:``,idleMinutes:``,networkDefault:`inherit`},ce=e=>({name:e.name,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`}),le=e=>[e.pidsLimit,e.idleMinutes].some(e=>e.trim()!==``&&!Number.isFinite(Number(e))),ue=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`}),de=()=>{let{t:e}=r(),[t,n]=(0,G.useState)([]),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)($),[c,l]=(0,G.useState)(!1),u=async()=>{try{let e=await C.listPolicies();e.success&&e.data&&n(e.data)}catch{}};(0,G.useEffect)(()=>{let e=!1;return C.listPolicies().then(t=>{!e&&t.success&&t.data&&n(t.data)}).catch(()=>{}),()=>{e=!0}},[]);let p=e=>({value:o[e],onChange:t=>s(n=>({...n,[e]:t.target.value}))}),m=async()=>{if(le(o)){h.error(e(`userManager.workPolicies.invalidNumber`));return}l(!0);try{let t=ue(o),n=i===`new`?await C.createPolicy(t):await C.updatePolicy(i,t);if(!n.success)throw Error(n.error||`Policy save failed.`);h.success(e(`userManager.workPolicies.saved`)),a(null),s($),await u()}catch(t){h.error(t instanceof Error&&t.message?t.message:e(`userManager.workPolicies.failed`))}finally{l(!1)}},g=async t=>{if(window.confirm(e(`userManager.workPolicies.deleteConfirm`)))try{let n=await C.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`))}},v=(e,t,n)=>(0,K.jsxs)(`label`,{className:`block text-xs`,children:[(0,K.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:t}),(0,K.jsx)(`input`,{...p(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,K.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`userManager.workPolicies.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`userManager.workPolicies.description`)})]}),i===null&&(0,K.jsxs)(j,{size:`sm`,variant:`outline`,className:`shrink-0 whitespace-nowrap`,onClick:()=>{s($),a(`new`)},children:[(0,K.jsx)(d,{size:14,className:`shrink-0`}),(0,K.jsx)(`span`,{className:`ms-1.5`,children:e(`userManager.workPolicies.add`)})]})]}),t.length===0&&i===null&&(0,K.jsx)(`p`,{className:`mt-3 text-xs text-gray-500 dark:text-gray-400`,children:e(`userManager.workPolicies.empty`)}),t.length>0&&(0,K.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-100 dark:divide-dark-300`,children:t.map(t=>(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,K.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,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,K.jsx)(j,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.edit`),onClick:()=>{s(ce(t)),a(t.id)},children:(0,K.jsx)(_,{size:14})}),(0,K.jsx)(j,{size:`sm`,variant:`ghost`,"aria-label":e(`userManager.workPolicies.delete`),onClick:()=>void g(t),children:(0,K.jsx)(f,{size:14})})]})]},t.id))}),i!==null&&(0,K.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 p-3 dark:border-dark-300`,children:[(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[v(`name`,e(`userManager.workPolicies.name`),`heavy`),v(`memoryLimit`,e(`userManager.workPolicies.memory`),`4g`),v(`cpuLimit`,e(`userManager.workPolicies.cpu`),`4`),v(`pidsLimit`,e(`userManager.workPolicies.pids`),`512`),v(`workspaceSize`,e(`userManager.workPolicies.workspaceSize`),`20Gi`),v(`idleMinutes`,e(`userManager.workPolicies.idleMinutes`),`30`),(0,K.jsxs)(`label`,{className:`block text-xs`,children:[(0,K.jsx)(`span`,{className:`mb-1 block font-medium text-gray-700 dark:text-gray-300`,children:e(`userManager.workPolicies.networkDefault`)}),(0,K.jsxs)(`select`,{...p(`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,K.jsx)(`option`,{value:`inherit`,children:e(`userManager.workPolicies.networkInherit`)}),(0,K.jsx)(`option`,{value:`on`,children:e(`userManager.workPolicies.networkOn`)}),(0,K.jsx)(`option`,{value:`off`,children:e(`userManager.workPolicies.networkOff`)})]})]}),v(`image`,e(`userManager.workPolicies.image`),`node:22-bookworm@sha256:…`)]}),(0,K.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,K.jsx)(j,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>{a(null),s($)},children:e(`userManager.workPolicies.cancel`)}),(0,K.jsx)(j,{size:`sm`,disabled:c||!o.name.trim(),onClick:()=>void m(),children:e(`userManager.workPolicies.save`)})]})]})]})},fe=()=>{let{t:e}=r();return(0,K.jsxs)(R,{children:[(0,K.jsx)(M,{title:e(`userManager.title`),description:e(`userManager.pageDescription`)}),(0,K.jsxs)(`div`,{className:`mb-4 space-y-4`,children:[(0,K.jsx)(se,{}),(0,K.jsx)(de,{}),(0,K.jsx)(ae,{}),(0,K.jsx)(oe,{}),(0,K.jsx)(Y,{}),(0,K.jsx)(X,{}),(0,K.jsx)(te,{}),(0,K.jsx)(ne,{}),(0,K.jsx)(ie,{})]}),(0,K.jsx)(J,{})]})};export{fe as UserManagementPage,fe as default};
@@ -0,0 +1,6 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-DSqqk5kt.js","js/router-vendor-CbexJIsv.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-BK7WVOb7.js","js/estree-BU5-LV_1.js","assets/index-BPsH9FII.js","js/react-vendor-BG_HPV6X.js","js/useTranslation-5b5UhAc9.js","js/utils-BGrdX9ie.js","js/utils-vendor-9bQ62WeD.js","js/chatStore-DbZPJNsu.js","js/i18next-DgmgtwsV.js","js/ui-vendor-CWjIBW-z.js","js/logger-DSXjF4ye.js","js/api-6bSMtSNh.js","js/config-8KdgjtEx.js","js/workApi-BruWTlHM.js","js/authStore-DbqqrfZv.js","js/appStore-CdObhQBb.js","js/welcomePrompts-to5mv_gx.js","js/messageCodeStyles-DhVgizF-.js","js/Button-C0r3J9G_.js","js/ui-CV0LYmkM.js","assets/index-BtXF0Oxa.css","js/typescript-6GJ8APmn.js","js/postcss-Bg15EcFE.js","js/html-DeoAy2bo.js","js/markdown-DOLsYkBY.js","js/yaml-DUeWcOOH.js","js/standalone-BO5pzI8_.js","js/OptimizedSyntaxHighlighter-CZNPwN0i.js","js/syntax-highlight-DcR9Vhb7.js","assets/xterm-DHcfr8qj.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-BK7WVOb7.js";import{a as r,d as i,f as a,p as o,u as s}from"./router-vendor-CbexJIsv.js";import{t as c}from"./useTranslation-5b5UhAc9.js";import{t as l}from"./utils-BGrdX9ie.js";import{t as u,w as d}from"./chatStore-DbZPJNsu.js";import{Bt as f,D as p,Dt as m,H as h,J as g,Jn as _,Jt as v,K as y,Kn as b,Kt as x,Ln as S,Mn as C,Nn as ee,Q as w,Qt as T,Rn as E,T as D,W as O,X as k,_ as A,c as j,cn as M,ft as te,hn as ne,i as re,in as ie,ir as N,k as P,n as ae,pn as oe,rn as se,rr as F,sr as ce,tn as le,tr as I,ur as L,vt as ue,zn as de}from"./ui-vendor-CWjIBW-z.js";import{t as fe}from"./config-8KdgjtEx.js";import{r as pe,t as R}from"./workApi-BruWTlHM.js";import{c as me}from"./api-6bSMtSNh.js";import{a as he,c as ge,i as _e,n as ve,o as ye,s as be,u as xe}from"./authStore-DbqqrfZv.js";import{t as Se}from"./appStore-CdObhQBb.js";import{t as z}from"./Button-C0r3J9G_.js";import{h as Ce}from"./ui-CV0LYmkM.js";import{v as we,x as B}from"../assets/index-BPsH9FII.js";import{t as V}from"./RichMessageContent-BqgafH4p.js";import{t as H}from"./ModelSelector-ol8mK2ja.js";import{n as U,t as Te}from"./work-DVgm81bJ.js";var W=e(t(),1),G=n(),Ee=e=>U({model:e.name,providerType:e.isPlugin?`plugin`:`ollama`,providerId:e.isPlugin?e.pluginId:void 0}),De=e=>{let t=e.name.split(`/`).filter(Boolean),n=t[t.length-1]||e.name;return t.length>1?n.replace(/[-_]+/g,` `):n},Oe=e=>{let t=`${e.model} · `;return{name:e.model,model:e.model,size:0,digest:``,modified_at:``,details:{},isPlugin:e.providerType===`plugin`,pluginId:e.providerId,pluginName:e.providerType===`plugin`?e.label.startsWith(t)?e.label.slice(t.length):e.providerId:void 0}};function ke({models:e,selectorModels:t,modelKey:n,running:r,loading:i,variant:a=`task`,disabled:o=!1,remoteDisclosureDismissed:s,remoteDisclosureSaving:u,onModelChange:d,onDismissRemoteDisclosure:f,onModelsRefresh:p,onSubmit:h,onCancel:g}){let{t:_}=c(),[v,y]=(0,W.useState)(``),b=(0,W.useRef)(null),x=(0,W.useRef)(null),S=(0,W.useRef)(null),ee=e.find(e=>e.key===n),w=ee?.remote===!0,T=a===`landing`,E=(0,W.useMemo)(()=>{let n=new Set(t.map(Ee)),r=e.filter(e=>!n.has(e.key)).map(Oe);return[...t,...r]},[e,t]);(0,W.useEffect)(()=>{let e=b.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[v]);let O=async()=>{await f()&&([x.current,S.current].find(e=>e&&e.offsetParent!==null)||x.current)?.focus()},k=t=>{let n=e.find(e=>e.key===t)||e.find(e=>e.providerType===`ollama`&&e.model===t);n&&d(n.key)},A=async()=>{let e=v.trim();!e||i||r||o||!ee||await h(e)&&y(``)};return(0,G.jsxs)(`div`,{"data-testid":T?`work-landing-composer`:`work-task-composer`,"data-variant":a,className:l(`relative shrink-0`,T?`mt-10 w-full`:`border-t border-line bg-surface/95 px-3 py-3 backdrop-blur md:px-5`),children:[w&&!s&&(0,G.jsx)(`div`,{className:l(`absolute inset-x-3 z-30 mx-auto max-w-3xl md:inset-x-5`,`bottom-full mb-3`),children:(0,G.jsxs)(`aside`,{"data-testid":`work-provider-disclosure-popover`,"aria-labelledby":`work-provider-disclosure-title`,"aria-live":`polite`,className:`relative rounded-2xl border border-warning-500/40 bg-surface-overlay p-3 pe-10 shadow-overlay backdrop-blur dark:border-warning-500/45`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>void O(),disabled:u,className:`absolute end-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-warning-500/20 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-warning-500 disabled:cursor-wait disabled:opacity-50`,"aria-label":_(`work.composer.remoteDismissLabel`,{defaultValue:`Dismiss remote provider notice`}),children:(0,G.jsx)(ae,{className:`h-4 w-4`})}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-warning-500/20`,children:(0,G.jsx)(C,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:_(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-ink-muted`,children:_(`work.composer.remoteHint`,{defaultValue:`Conversation and tool output are sent to the configured service. One autonomous run can make multiple provider calls and may incur charges. Workspace files stay local unless a tool returns their contents.`})}),(0,G.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,G.jsx)(z,{"data-testid":`work-provider-disclosure-dismiss`,type:`button`,variant:`ghost`,size:`sm`,loading:u,className:`h-7 border-warning-500 bg-warning-500 px-2.5 text-xs text-[#3d120c] hover:bg-warning-500/90 hover:text-[#3d120c]`,onClick:()=>void O(),children:_(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,G.jsx)(`form`,{className:`mx-auto w-full max-w-3xl`,onSubmit:e=>{e.preventDefault(),A()},children:(0,G.jsxs)(`div`,{"data-testid":`work-composer-surface`,className:l(`rounded-[24px] border p-2.5 transition-[border-color,box-shadow,background-color] duration-200`,`border-black/[0.08] bg-surface dark:border-white/[0.09] dark:bg-surface-subtle`,`shadow-lv2 focus-within:shadow-lv3`),children:[(0,G.jsx)(`textarea`,{ref:b,"data-testid":`work-composer-input`,dir:`auto`,value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),A())},disabled:o||r,rows:1,className:`m-0 block max-h-[160px] min-h-9 w-full resize-none overflow-y-auto rounded-none border-0 bg-transparent px-2 pt-1.5 pb-2 text-[0.9375rem] leading-relaxed text-ink shadow-none outline-none placeholder:text-ink-subtle focus:border-0 focus:bg-transparent focus:ring-0 disabled:cursor-not-allowed disabled:opacity-60`,placeholder:_(`work.composer.placeholder`,{defaultValue:`Describe what you want to build or change…`})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,G.jsx)(`div`,{className:`hidden shrink-0 sm:block`,children:(0,G.jsx)(H,{models:E,selectedModel:n,onModelChange:e=>k(e.target.value),onModelsRefresh:()=>void p(),getModelValue:Ee,getModelLabel:De,getModelTitle:e=>e.name,triggerRef:x,triggerTestId:`work-model-selector-trigger`,selectTestId:`work-model-select`,ariaLabel:_(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`min-w-[150px] max-w-[230px]`,compact:!0})}),r?(0,G.jsx)(z,{"data-testid":`work-cancel-button`,type:`button`,variant:`ghost`,size:`sm`,disabled:i,className:`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full bg-error-500/15 p-0 text-error-600 transition-colors duration-150 hover:bg-error-500/25 dark:text-error-400 sm:h-10 sm:w-10`,title:_(`work.composer.cancel`,{defaultValue:`Stop`}),"aria-label":_(`work.composer.cancel`,{defaultValue:`Stop`}),onClick:()=>void g(),children:i?(0,G.jsx)(m,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(D,{className:`h-4 w-4 fill-current`})}):(0,G.jsx)(z,{"data-testid":`work-submit-button`,type:`submit`,variant:`ghost`,size:`sm`,disabled:i||o||!v.trim()||!ee,className:l(`flex h-9 w-9 shrink-0 touch-manipulation items-center justify-center rounded-full p-0 transition-colors duration-150`,`bg-primary-500 text-white hover:bg-primary-400`,`disabled:bg-primary-300/50 disabled:text-white/80 dark:disabled:bg-primary-800/60 dark:disabled:text-white/40 disabled:hover:bg-primary-300/50 dark:disabled:hover:bg-primary-800/60`),title:_(`work.composer.send`,{defaultValue:`Run`}),"aria-label":_(`work.composer.send`,{defaultValue:`Run`}),children:i?(0,G.jsx)(m,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(I,{className:`h-4 w-4`})})]})]})}),(0,G.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-3xl sm:hidden`,children:(0,G.jsx)(H,{models:E,selectedModel:n,onModelChange:e=>k(e.target.value),onModelsRefresh:()=>void p(),getModelValue:Ee,getModelLabel:De,getModelTitle:e=>e.name,triggerRef:S,triggerTestId:`work-model-selector-trigger-mobile`,selectTestId:`work-model-select-mobile`,ariaLabel:_(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`w-full`,compact:!0})})]})}var Ae=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},K=e=>{if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,`0`)}`:`${r}s`},je=e=>{if(!e)return 0;let t=Array.from(e).length,n=e.trim()?e.trim().split(/\s+/u).length:0;return Math.max(n,Math.ceil(t/4))};function q({run:e}){let[t,n]=(0,W.useState)();if((0,W.useEffect)(()=>{if(e.terminal||!e.startedAt)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e.startedAt,e.terminal]),!e.startedAt)return null;let r=e.finishedAt||t;return r?(0,G.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:K(r-e.startedAt)}):null}function Me({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,W.useState)(e.status),[i,a]=(0,W.useState)(null),o=(0,W.useMemo)(()=>Ae(e.arguments),[e.arguments]),s=e.output||null,u=!!(o||s),d=e.status===`error`,f=e.status===`running`,p=(0,W.useId)(),h=d?n(`work.activity.kinds.error`,{defaultValue:`Error`}):f?n(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}):n(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),g=i??(e.status===r?t:e.status===`error`);return(0,G.jsxs)(`div`,{"data-testid":`work-live-tool`,"data-tool-id":e.id,className:l(`overflow-hidden rounded-xl border bg-surface-raised transition-colors`,d?`border-error-500/30`:`border-line`),children:[(0,G.jsxs)(`button`,{type:`button`,disabled:!u,onClick:()=>{a(!g)},"aria-expanded":u?g:void 0,"aria-controls":u?p:void 0,"aria-label":`${h}: ${e.name}`,className:`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-start outline-none hover:bg-surface-subtle focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52] disabled:cursor-default disabled:hover:bg-transparent`,children:[(0,G.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:d?(0,G.jsx)(C,{className:`h-3.5 w-3.5 text-error-500`}):f?(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,G.jsx)(de,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,G.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-xs text-ink`,children:e.name}),e.durationMs!==void 0&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:K(e.durationMs)}),u&&(0,G.jsx)(E,{"aria-hidden":`true`,className:l(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,g&&`rotate-180`)})]}),u&&g&&(0,G.jsxs)(`div`,{id:p,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,G.jsx)(`pre`,{dir:`ltr`,className:`max-h-48 overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:o}),s&&(0,G.jsx)(`pre`,{dir:`ltr`,className:l(`max-h-64 overflow-auto whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-left font-mono text-[11px] leading-relaxed`,d?`text-error-600`:`text-ink-muted`),children:s})]})]})}var Ne=e=>{let t=e.split(`
3
+ `);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n)return n}return``};function Pe({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,W.useState)(!1),a=t&&!r?Ne(e):``;return(0,G.jsxs)(`details`,{"data-testid":`work-live-reasoning`,open:r,onToggle:e=>i(e.currentTarget.open),className:`group overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-1 px-3 py-2 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,G.jsxs)(`span`,{className:`flex items-center justify-between gap-3 text-xs font-medium text-ink-muted`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(b,{className:l(`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`,t&&`animate-pulse-subtle motion-reduce:animate-none`)}),t?(0,G.jsxs)(`span`,{className:`animate-shimmer truncate bg-gradient-to-r from-ink-subtle via-ink to-ink-subtle bg-[length:200%_100%] bg-clip-text text-transparent motion-reduce:animate-none motion-reduce:bg-none motion-reduce:text-ink-muted`,children:[n(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),`…`]}):(0,G.jsx)(`span`,{className:`truncate`,children:n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,G.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),a&&(0,G.jsx)(`span`,{dir:`auto`,"data-testid":`work-live-reasoning-preview`,className:`block truncate text-[11px] leading-relaxed text-ink-subtle`,children:a})]}),(0,G.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,G.jsx)(Ce,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var Fe=(e,t,n)=>e===`queued`||e===`preparing`?t(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):e===`using_tool`?n?.name?`${t(`work.activity.toolActivity`,{defaultValue:`Tool activity`})} · ${n.name}`:t(`work.activity.toolActivity`,{defaultValue:`Tool activity`}):e===`completed`?t(`work.statusLabels.complete`,{defaultValue:`Complete`}):e===`needs_input`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`failed`?t(`work.statusLabels.error`,{defaultValue:`Error`}):e===`cancelled`?t(`work.statusLabels.needsInput`,{defaultValue:`Needs input`}):e===`responding`?t(`work.status.running`,{defaultValue:`Working in the local workspace…`}):t(`work.statusLabels.thinking`,{defaultValue:`Thinking`}),Ie=(e,t)=>{if(e===`connecting`)return t(`work.live.connecting`,{defaultValue:`Connecting to live updates…`});if(e===`reconnecting`)return t(`work.live.reconnecting`,{defaultValue:`Reconnecting to live updates…`});if(e===`error`)return t(`work.live.unavailable`,{defaultValue:`Live updates unavailable`})};function Le({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=Ie(e.connection,n)||Fe(e.phase,n,r),a=!e.terminal,o=e.usage?.outputTokens,s=e.reasoning+e.response,u=o!==void 0&&o>0?o:s?je(s):o,d=(o===void 0||o===0)&&!!s&&u!==void 0,f=e.usage?.tokensPerSecond;return(0,G.jsxs)(`section`,{"data-testid":`work-live-run`,"data-run-id":e.runId,"data-phase":e.phase,"aria-busy":a||void 0,className:l(`min-w-0`,t===`activity`&&`rounded-2xl border border-line bg-surface p-3 shadow-subtle`),children:[(0,G.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:l(`h-2 w-2 shrink-0 rounded-full`,e.phase===`failed`?`bg-[rgb(255,61,129)]`:e.phase===`completed`?`bg-[rgb(76,212,117)]`:e.phase===`needs_input`||e.phase===`cancelled`?`bg-[rgb(255,204,0)]`:e.connection===`error`?`bg-[rgb(255,61,129)]`:`bg-[rgb(48,121,255)]`,a&&`animate-pulse motion-reduce:animate-none`)}),(0,G.jsx)(`span`,{dir:`auto`,title:e.connectionError,className:`min-w-0 flex-1 truncate font-medium text-ink-muted`,children:i}),e.round!==void 0&&(0,G.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,G.jsx)(q,{run:e})]}),t===`conversation`&&(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,G.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-line bg-surface-raised px-2 py-1 text-[10px] text-ink-muted`,children:[(0,G.jsx)(P,{className:`h-3 w-3 text-[#ff7b52]`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{dir:`auto`,children:n(`work.live.skillsLoaded`,{count:e.skills.length,defaultValue:`Workspace skills · {{count}}`})})]})}),t===`conversation`?e.timeline.length>0&&(0,G.jsx)(`div`,{"data-testid":`work-live-timeline`,className:`space-y-2`,children:e.timeline.map((t,n)=>{let r=n===e.timeline.length-1;if(t.kind===`reasoning`)return(0,G.jsx)(Pe,{content:t.text,streaming:a&&r},`segment-${n}`);if(t.kind===`tool`){let n=e.tools.find(e=>e.id===t.toolId);return n?(0,G.jsx)(Me,{tool:n,expandedByDefault:n.status===`error`},n.id):null}return(0,G.jsx)(Ce,{content:t.text,isStreaming:a&&r,className:`text-ink`},`segment-${n}`)})}):e.tools.length>0&&(0,G.jsx)(`div`,{"data-testid":`work-live-tools`,className:`space-y-1.5`,children:e.tools.map(e=>(0,G.jsx)(Me,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),e.error&&(0,G.jsxs)(`div`,{role:`alert`,dir:`auto`,className:`mt-3 flex items-start gap-2 rounded-xl border border-error-500/30 bg-error-500/10 px-3 py-2.5 text-xs leading-relaxed text-error-600`,children:[(0,G.jsx)(C,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,G.jsx)(`span`,{children:e.error})]}),(u!==void 0||f!==void 0)&&(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-line pt-2 text-[10px] tabular-nums text-ink-subtle`,children:[u!==void 0&&(0,G.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,G.jsxs)(`bdi`,{dir:`ltr`,children:[d&&`≈`,u.toLocaleString()]})]}),f!==void 0&&(0,G.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,G.jsxs)(`bdi`,{dir:`ltr`,children:[f.toFixed(1),` t/s`]})]})]}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,G.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,G.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:320ms] motion-reduce:animate-none`})]}),t===`activity`&&e.tools.length===0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,G.jsx)(p,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}function J({role:e,user:t,size:n=`message`}){let[r,i]=(0,W.useState)(null);if(e===`assistant`)return(0,G.jsx)(`div`,{role:`img`,"aria-label":`Libre WebUI`,"data-testid":`work-assistant-avatar`,className:l(`flex shrink-0 items-center justify-center rounded-full border border-line bg-surface-raised text-ink shadow-subtle`,n===`empty`?`mx-auto mb-4 h-12 w-12`:`mt-0.5 h-8 w-8`),children:(0,G.jsx)(B,{label:null,className:l(n===`empty`?`h-6 w-6`:`h-4 w-4`)})});let a=t?.username||`User`,o=t?.avatar?.trim()||``,s=!!o&&o!==r;return(0,G.jsx)(`div`,{role:s?void 0:`img`,"aria-label":s?void 0:a,"data-testid":`work-user-avatar`,className:l(`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-full`,s?`border border-line bg-surface-raised`:`bg-ink text-ink-inverse`),title:a,children:s?(0,G.jsx)(`img`,{src:o,alt:a,className:`h-full w-full object-cover`,onError:()=>i(o)}):t?(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,G.jsx)(j,{"aria-hidden":`true`,className:`h-4 w-4`})})}var Re=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t},ze=e=>{let t=e.metadata?.toolCallId;return typeof t==`string`&&t?t:null},Be=(e,t,n)=>{let r=e??t,i=t?.kind===`error`||t?.metadata?.isError===!0||!t&&r?.kind===`error`,a=t?.metadata?.durationMs;return{id:(e??t)?.id??`tool`,name:r?Re(r,n):n,status:i?`error`:`completed`,arguments:e?.metadata,output:t?.content||(!t&&e?e.content:void 0),durationMs:typeof a==`number`?a:void 0}},Ve=(e,t)=>{let n=[],r=new Map,i=(e,t)=>{let r=n[n.length-1];return r?.item.type===`tools`?(r.item.tools.push(e),r.item.tools.length-1):(n.push({key:t,item:{type:`tools`,tools:[e]}}),0)};for(let a of e){if(a.kind===`reasoning`){n.push({key:a.id,item:{type:`reasoning`,message:a}});continue}if(a.role!==`tool`&&a.kind===`message`){n.push({key:a.id,item:{type:`message`,message:a}});continue}let e=ze(a);if(a.kind===`tool_call`&&e){let o=i(Be(a,void 0,t),a.id);r.set(e,{itemIndex:n.length-1,toolIndex:o,call:a});continue}if(a.kind===`tool_result`&&e){let i=r.get(e);if(i){let o=n[i.itemIndex];if(o.item.type===`tools`){o.item.tools[i.toolIndex]=Be(i.call,a,t),r.delete(e);continue}}}i(Be(a.kind===`tool_call`?a:void 0,a.kind===`tool_call`?void 0:a,t),a.id)}return n};function He({message:e}){let{t}=c();return(0,G.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-14 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-ink-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(b,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,G.jsx)(`span`,{className:`truncate`,children:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,G.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,G.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words border-t border-line px-3 py-2.5 text-xs leading-relaxed text-ink-muted`,children:e.content})]})}function Ue({task:e,user:t,loading:n,loadingOlder:r,liveRun:i,onLoadOlder:a}){let{t:o}=c(),s=(0,W.useRef)(null),u=(0,W.useRef)(!0),[d,f]=(0,W.useState)(!1),p=(0,W.useMemo)(()=>[...e.messages||[]].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id)),[e.messages]),h=i?.runId,g=(0,W.useMemo)(()=>Ve(p.filter(e=>!(h&&e.runId===h&&e.role!==`user`)),o(`work.activity.toolActivity`,{defaultValue:`Tool activity`})),[h,p,o]),_=[...p].reverse().find(e=>e.role===`assistant`&&e.kind===`message`)?.id;(0,W.useEffect)(()=>{u.current=!0;let e=s.current;e&&(e.scrollTop=e.scrollHeight);let t=window.requestAnimationFrame(()=>f(!1));return()=>window.cancelAnimationFrame(t)},[e.id]),(0,W.useEffect)(()=>{let e=s.current,t;return e&&u.current?(e.scrollTop=e.scrollHeight,t=window.requestAnimationFrame(()=>f(!1))):e&&i&&(t=window.requestAnimationFrame(()=>f(!0))),()=>{t!==void 0&&window.cancelAnimationFrame(t)}},[i,p,e.status]);let v=async()=>{let e=s.current,t=e?.scrollHeight??0,n=e?.scrollTop??0;u.current=!1;try{await a(),requestAnimationFrame(()=>{let e=s.current;e&&(e.scrollTop=n+e.scrollHeight-t)})}catch{}};return n&&p.length===0?(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,G.jsx)(m,{className:`h-6 w-6 animate-spin`})}):(0,G.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,G.jsx)(`div`,{ref:s,onScroll:e=>{let t=e.currentTarget;u.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,u.current&&f(!1)},className:`min-h-0 flex-1 overflow-y-auto`,children:(0,G.jsx)(`div`,{className:`mx-auto flex min-h-full max-w-3xl flex-col px-4 py-6 md:px-6`,children:p.length===0&&!i?(0,G.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,G.jsx)(J,{role:`assistant`,size:`empty`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:o(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-ink-muted`,children:o(`work.conversation.empty`,{defaultValue:`Continue the task below. This conversation and its files stay attached to this workspace.`})})]}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,G.jsx)(`div`,{className:`flex justify-center`,children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`work-load-older-messages`,disabled:r,onClick:()=>void v(),className:`inline-flex items-center gap-2 rounded-lg border border-line bg-surface-raised px-3 py-1.5 text-xs font-medium text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink disabled:cursor-not-allowed disabled:opacity-60`,children:[r&&(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),o(`work.conversation.loadOlder`,{defaultValue:`Load older messages`})]})}),g.map(({key:n,item:r})=>{if(r.type===`reasoning`)return(0,G.jsx)(He,{message:r.message},n);if(r.type===`tools`)return(0,G.jsx)(`div`,{className:`ms-14 space-y-1.5`,children:r.tools.map(e=>(0,G.jsx)(Me,{tool:e,expandedByDefault:!1},e.id))},n);let i=r.message,a=i.role===`user`,o=!a&&e.status===`running`&&i.id===_&&i.runId===e.activeRun?.id;return(0,G.jsxs)(`article`,{className:l(`flex gap-3`,a&&`flex-row-reverse`),children:[(0,G.jsx)(J,{role:a?`user`:`assistant`,user:a?t:void 0}),(0,G.jsx)(`div`,{className:l(`min-w-0 max-w-[88%]`,a&&`rounded-2xl rounded-se-md bg-ink px-4 py-2.5 text-ink-inverse`),children:a?(0,G.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:i.content}):o?(0,G.jsx)(Ce,{content:i.content,className:`text-ink`}):(0,G.jsx)(V,{content:i.content,className:`text-sm text-ink`})})]},i.id)}),i&&(0,G.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,G.jsx)(J,{role:`assistant`}),(0,G.jsx)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:(0,G.jsx)(Le,{run:i})})]}),!i&&(e.status===`preparing`||e.status===`running`)&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 ps-14 text-xs text-ink-muted`,children:[(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),e.status===`preparing`?o(`work.status.preparing`,{defaultValue:`Preparing isolated workspace…`}):o(`work.status.running`,{defaultValue:`Working in the local workspace…`})]})]})})}),d&&(0,G.jsxs)(`button`,{type:`button`,"data-testid":`work-new-activity-button`,onClick:()=>{let e=s.current;e&&(e.scrollTop=e.scrollHeight),u.current=!0,f(!1)},className:`absolute bottom-4 left-1/2 z-10 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-line bg-surface-overlay/95 px-3 py-2 text-xs font-medium text-ink shadow-overlay backdrop-blur transition-colors hover:bg-surface-raised`,children:[(0,G.jsx)(N,{className:`h-3.5 w-3.5`}),o(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var We=45,Y=30,Ge=70,Ke=360,qe=480,Je=9,Ye=2,Xe=10,Ze=`libre-webui-work-split:`,Qe=(e,t,n)=>Math.min(n,Math.max(t,e)),$e=e=>`${Ze}${encodeURIComponent(e||`local`)}`,et=e=>{if(typeof window>`u`)return We;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return We;let n=Number(t);return Number.isFinite(n)?Qe(n,Y,Ge):We}catch{return We}},tt=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},nt=e=>{let t=Math.max(0,e-Je);if(t===0)return{min:Y,max:Ge};let n=Math.max(Y,Ke/t*100),r=Math.min(Ge,(t-qe)/t*100);if(n<=r)return{min:n,max:r};let i=Qe(Ke/840*100,Y,Ge);return{min:i,max:i}},rt=(e,t)=>Qe(e,t.min,t.max);function it({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=d(o.language),u=$e(n),[f,p]=(0,W.useState)(()=>({storageKey:u,percent:et(u)})),[m,h]=(0,W.useState)(0),[g,_]=(0,W.useState)(!1),v=(0,W.useRef)(null),y=(0,W.useRef)(null),b=(0,W.useRef)(null),x=(0,W.useRef)(u),S=(0,W.useRef)(f.percent),C=(0,W.useRef)(null),ee=f.storageKey===u?f.percent:et(u),w=(0,W.useMemo)(()=>nt(m),[m]),T=rt(ee,w),E=Math.round(T),D=100-E,O=(0,W.useCallback)(e=>{p({storageKey:u,percent:e})},[u]),k=(0,W.useCallback)(e=>{let t=rt(e,nt(v.current?.getBoundingClientRect().width??0));S.current=t,C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,O(S.current)}))},[O]),A=(0,W.useCallback)(()=>{if(b.current===null&&!g)return;C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null);let e=v.current?.getBoundingClientRect().width??0,t=rt(S.current,nt(e));S.current=t,O(t),tt(x.current,t);let n=b.current;b.current=null,n!==null&&y.current?.hasPointerCapture(n)&&y.current.releasePointerCapture(n),_(!1)},[g,O]),j=(0,W.useCallback)(e=>{let t=v.current?.getBoundingClientRect();if(!t)return S.current;let n=Math.max(1,t.width-Je);return((s?t.right-e:e-t.left)-Je/2)/n*100},[s]),M=e=>{e.button!==0||!e.isPrimary||(e.preventDefault(),e.stopPropagation(),b.current=e.pointerId,x.current=u,S.current=T,e.currentTarget.setPointerCapture(e.pointerId),_(!0))},te=(0,W.useCallback)(e=>{let t=rt(e,w);S.current=t,O(t),tt(u,t)},[w,O,u]),ne=(0,W.useCallback)(()=>{te(We)},[te]),re=e=>{let t=e.shiftKey?Xe:Ye,n=null;e.key===`ArrowLeft`?n=T+(s?t:-t):e.key===`ArrowRight`?n=T+(s?-t:t):e.key===`Home`?n=w.min:e.key===`End`?n=w.max:e.key===`Enter`&&(n=We),n!==null&&(e.preventDefault(),te(n))};(0,W.useEffect)(()=>{let e=v.current;if(!e)return;if(typeof ResizeObserver>`u`){let t=()=>h(e.getBoundingClientRect().width);return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)}let t=new ResizeObserver(e=>{let t=e[0];t&&h(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]),(0,W.useEffect)(()=>{if(!g)return;let e=document.body.style.cursor,t=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let n=e=>{e.pointerId===b.current&&(e.preventDefault(),k(j(e.clientX)))},r=e=>{e.pointerId===b.current&&A()};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),window.addEventListener(`blur`,A),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`blur`,A),document.body.style.cursor=e,document.body.style.userSelect=t}},[A,g,j,k]),(0,W.useEffect)(()=>()=>{C.current!==null&&window.cancelAnimationFrame(C.current),b.current!==null&&tt(x.current,S.current)},[]);let ie={gridTemplateColumns:`minmax(0, ${T}fr) ${Je}px minmax(0, ${100-T}fr)`};return(0,G.jsxs)(`div`,{ref:v,"data-testid":`work-split-pane`,"data-split-percent":T.toFixed(2),"data-resizing":g?`true`:`false`,className:l(`relative flex min-h-0 min-w-0 flex-1 overflow-hidden xl:grid`,i),style:ie,children:[(0,G.jsx)(`section`,{id:`work-conversation-panel`,"data-testid":`work-conversation-panel`,className:l(`min-h-0 min-w-0 flex-1 flex-col bg-transparent xl:flex`,r===`conversation`?`flex`:`hidden`),children:e}),(0,G.jsxs)(`div`,{ref:y,role:`separator`,"aria-orientation":`vertical`,"aria-controls":`work-conversation-panel work-workspace-panel`,"aria-label":a(`work.workspace.resize`,{defaultValue:`Resize conversation and workspace`}),"aria-valuemin":Math.round(w.min),"aria-valuemax":Math.round(w.max),"aria-valuenow":E,"aria-valuetext":a(`work.workspace.splitSize`,{conversation:E,workspace:D,defaultValue:`Conversation {{conversation}}%, workspace {{workspace}}%`}),title:a(`work.workspace.resizeHint`,{defaultValue:`Drag to resize. Use arrow keys for precise control. Double-click or press Enter to reset.`}),tabIndex:0,"data-testid":`work-split-resizer`,onPointerDown:M,onDoubleClick:ne,onKeyDown:re,className:l(`group relative z-40 hidden h-full cursor-col-resize touch-none select-none items-center justify-center outline-none xl:flex`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#ff7b52]`),children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:l(`pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-line transition-colors`,`group-hover:bg-[#ff7b52] group-focus-visible:bg-[#ff7b52]`,g&&`bg-[#ff7b52]`)}),(0,G.jsx)(`span`,{"aria-hidden":`true`,className:l(`pointer-events-none relative h-14 w-1 rounded-full bg-ink-subtle/50 opacity-60 transition-[height,background-color,opacity]`,`group-hover:h-20 group-hover:bg-[#ff7b52] group-hover:opacity-100`,`group-focus-visible:h-20 group-focus-visible:bg-[#ff7b52] group-focus-visible:opacity-100`,g&&`h-20 bg-[#ff7b52] opacity-100`)})]}),(0,G.jsx)(`section`,{id:`work-workspace-panel`,"data-testid":`work-workspace-panel`,className:l(`min-h-0 min-w-0 flex-1 flex-col bg-surface-raised/85 backdrop-blur-xl xl:flex`,r===`workspace`?`flex`:`hidden`),children:t}),g&&(0,G.jsx)(`div`,{"data-testid":`work-split-drag-shield`,"aria-hidden":`true`,className:`absolute inset-0 z-30 hidden cursor-col-resize select-none xl:block`})]})}var at=1e5,ot=4e3,st={bash:`bash`,c:`c`,cc:`cpp`,cjs:`javascript`,cpp:`cpp`,cs:`csharp`,csh:`bash`,css:`css`,cts:`typescript`,cxx:`cpp`,diff:`diff`,go:`go`,h:`c`,hpp:`cpp`,htm:`markup`,html:`markup`,java:`java`,js:`javascript`,json:`json`,json5:`json`,jsonc:`json`,jsx:`jsx`,kt:`kotlin`,kts:`kotlin`,less:`css`,md:`markdown`,mdx:`markdown`,mjs:`javascript`,mts:`typescript`,patch:`diff`,php:`php`,py:`python`,rb:`ruby`,rs:`rust`,scss:`css`,sh:`bash`,sql:`sql`,svg:`markup`,swift:`swift`,ts:`typescript`,tsx:`tsx`,xml:`markup`,yaml:`yaml`,yml:`yaml`,zsh:`bash`},ct={".bashrc":`bash`,".zshrc":`bash`},X={cjs:{family:`babel`,parser:`babel`},css:{family:`postcss`,parser:`css`},cts:{family:`typescript`,parser:`typescript`},htm:{family:`html`,parser:`html`},html:{family:`html`,parser:`html`},js:{family:`babel`,parser:`babel`},json:{family:`babel`,parser:`json`},json5:{family:`babel`,parser:`json5`},jsonc:{family:`babel`,parser:`json`},jsx:{family:`babel`,parser:`babel`},less:{family:`postcss`,parser:`less`},md:{family:`markdown`,parser:`markdown`},mdx:{family:`markdown`,parser:`mdx`},mjs:{family:`babel`,parser:`babel`},mts:{family:`typescript`,parser:`typescript`},scss:{family:`postcss`,parser:`scss`},ts:{family:`typescript`,parser:`typescript`},tsx:{family:`typescript`,parser:`typescript`},yaml:{family:`yaml`,parser:`yaml`},yml:{family:`yaml`,parser:`yaml`}},lt=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,ut=e=>{let t=lt(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},dt=e=>ct[lt(e)]??st[ut(e)]??`text`,ft=e=>X[ut(e)],pt=e=>ft(e)!==void 0,mt=e=>{if(e.length>1e5)return!1;let t=1;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10&&(t+=1,t>4e3))return!1;return!0},Z=async e=>(await e).default,ht=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([Z(r(()=>import(`./babel-DSqqk5kt.js`),__vite__mapDeps([0,1,2,3]))),Z(r(()=>import(`./estree-BU5-LV_1.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))]);case`typescript`:return Promise.all([Z(r(()=>import(`./typescript-6GJ8APmn.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),Z(r(()=>import(`./estree-BU5-LV_1.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))]);case`postcss`:return[await Z(r(()=>import(`./postcss-Bg15EcFE.js`),__vite__mapDeps([25,1,2,3])))];case`html`:{let e=[await Z(r(()=>import(`./html-DeoAy2bo.js`),__vite__mapDeps([26,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))];return/<script\b/i.test(t)&&e.push(await Z(r(()=>import(`./babel-DSqqk5kt.js`),__vite__mapDeps([0,1,2,3]))),await Z(r(()=>import(`./estree-BU5-LV_1.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),/<script\b[^>]*\blang\s*=\s*["']?(?:ts|typescript)/i.test(t)&&e.push(await Z(r(()=>import(`./typescript-6GJ8APmn.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),/<style\b/i.test(t)&&e.push(await Z(r(()=>import(`./postcss-Bg15EcFE.js`),__vite__mapDeps([25,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await Z(r(()=>import(`./markdown-DOLsYkBY.js`),__vite__mapDeps([27,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))],i=e=>RegExp(`^(?: {0,3})(?:\`{3,}|~{3,})\\s*(?:${e})(?:\\s|$)`,`im`).test(t);return e.parser===`mdx`&&n.push(await Z(r(()=>import(`./babel-DSqqk5kt.js`),__vite__mapDeps([0,1,2,3]))),await Z(r(()=>import(`./estree-BU5-LV_1.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),i(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await Z(r(()=>import(`./babel-DSqqk5kt.js`),__vite__mapDeps([0,1,2,3]))),await Z(r(()=>import(`./estree-BU5-LV_1.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),i(`ts|tsx|typescript`)&&n.push(await Z(r(()=>import(`./typescript-6GJ8APmn.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Z(r(()=>import(`./estree-BU5-LV_1.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])))),i(`css|scss|less`)&&n.push(await Z(r(()=>import(`./postcss-Bg15EcFE.js`),__vite__mapDeps([25,1,2,3])))),i(`html`)&&n.push(await Z(r(()=>import(`./html-DeoAy2bo.js`),__vite__mapDeps([26,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Z(r(()=>import(`./babel-DSqqk5kt.js`),__vite__mapDeps([0,1,2,3]))),await Z(r(()=>import(`./estree-BU5-LV_1.js`),__vite__mapDeps([4,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Z(r(()=>import(`./typescript-6GJ8APmn.js`),__vite__mapDeps([24,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),await Z(r(()=>import(`./postcss-Bg15EcFE.js`),__vite__mapDeps([25,1,2,3])))),i(`yaml|yml`)&&n.push(await Z(r(()=>import(`./yaml-DUeWcOOH.js`),__vite__mapDeps([28,1,2,3])))),[...new Set(n)]}case`yaml`:return[await Z(r(()=>import(`./yaml-DUeWcOOH.js`),__vite__mapDeps([28,1,2,3])))]}},gt=async(e,t)=>{let n=ft(e);if(!n)throw Error(`Formatting is not supported for “${lt(e)||e}”.`);if(!mt(t))throw Error(`Could not format “${lt(e)||e}”: files are limited to ${at.toLocaleString()} characters and ${ot.toLocaleString()} lines.`);try{let[{format:e},i]=await Promise.all([r(()=>import(`./standalone-BO5pzI8_.js`),__vite__mapDeps([29,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23])),ht(n,t)]);return await e(t,{parser:n.parser,plugins:i,tabWidth:2,useTabs:!1})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not format “${lt(e)||e}”: ${n}`)}},_t=(0,W.lazy)(async()=>({default:(await r(()=>import(`./OptimizedSyntaxHighlighter-CZNPwN0i.js`).then(e=>e.n),__vite__mapDeps([30,2,3,31]))).OptimizedSyntaxHighlighter})),vt=8e3,yt=400,bt=500;function xt({path:e,value:t,ariaLabel:n,disabled:r=!1,onChange:i,onSaveShortcut:a,onFormatShortcut:o}){let{t:s}=c(),u=Se(e=>e.theme.mode===`dark`),d=(0,W.useRef)(null),f=(0,W.useRef)(null),[p,m]=(0,W.useState)(``),h=(0,W.useMemo)(()=>dt(e),[e]),g=(0,W.useMemo)(()=>{if(t.length>vt)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>yt));n+=1);return e},[t]),_=t.length>vt||g>yt,v=h!==`text`&&!_,y=v&&p===t;return(0,W.useEffect)(()=>{if(!v)return;let e=window.setTimeout(()=>m(t),bt);return()=>window.clearTimeout(e)},[v,e,t]),(0,W.useLayoutEffect)(()=>{!y||!d.current||!f.current||(d.current.style.transform=`translate3d(${-f.current.scrollLeft}px, ${-f.current.scrollTop}px, 0)`)},[y,e]),(0,G.jsxs)(`div`,{dir:`ltr`,className:l(`relative min-h-0 flex-1 overflow-hidden bg-surface focus-within:ring-1 focus-within:ring-inset focus-within:ring-primary-500/60`,r&&`opacity-60`),"data-language":h,"data-highlighted":y?`true`:`false`,children:[y&&(0,G.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,G.jsx)(`div`,{ref:d,"data-testid":`work-file-highlight-content`,className:`min-h-full min-w-full origin-top-left will-change-transform`,children:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`pre`,{className:`m-0 min-h-full min-w-full whitespace-pre p-4 text-left font-mono text-[12px] leading-5 text-ink`,children:t||`​`}),children:(0,G.jsx)(_t,{language:h,isDark:u,backgroundColor:`transparent`,borderRadius:0,customStyle:{margin:0,minHeight:`100%`,minWidth:`100%`,width:`max-content`,overflow:`visible`,padding:`1rem`,fontSize:`12px`,lineHeight:`20px`,tabSize:2,whiteSpace:`pre`},children:p||`​`})})})}),(0,G.jsx)(`textarea`,{ref:f,"data-testid":`work-file-editor`,"data-language":h,"aria-label":n,value:t,onChange:e=>i(e.target.value),onScroll:e=>{d.current&&(d.current.style.transform=`translate3d(${-e.currentTarget.scrollLeft}px, ${-e.currentTarget.scrollTop}px, 0)`)},onKeyDown:e=>{let t=e.key.toLowerCase();if((e.metaKey||e.ctrlKey)&&t===`s`){e.preventDefault(),a();return}e.altKey&&e.shiftKey&&t===`f`&&(e.preventDefault(),o())},disabled:r,spellCheck:!1,wrap:`off`,className:l(`absolute inset-0 z-10 h-full w-full resize-none overflow-auto whitespace-pre border-0 bg-transparent p-4 text-left font-mono text-[12px] leading-5 outline-none selection:bg-primary-500/25 disabled:cursor-not-allowed`,y?`text-transparent caret-ink`:`text-ink`),style:y?{WebkitTextFillColor:`transparent`,caretColor:`rgb(var(--color-ink))`,tabSize:2}:{tabSize:2}}),_&&(0,G.jsx)(`span`,{dir:`auto`,className:`pointer-events-none absolute bottom-2 end-3 z-20 rounded-md border border-line bg-surface-overlay/90 px-2 py-1 text-[10px] text-ink-muted shadow-subtle`,title:s(`work.files.highlightPaused`,{defaultValue:`Live highlighting is paused for large files to keep editing responsive.`}),children:s(`work.files.plainTextLarge`,{defaultValue:`Plain text · large file`})})]})}var St=4e6,Ct=e=>{if(e===``)return[];let t=e.split(`
4
+ `);return t[t.length-1]===``&&t.pop(),t},Q=(e,t)=>{let n=Ct(e),r=Ct(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=n.slice(i,n.length-a),s=r.slice(i,r.length-a),c=[];for(let e=0;e<i;e+=1)c.push({type:`context`,text:n[e],beforeLine:e+1,afterLine:e+1});let l=wt(o,s);for(let e of l){let t={type:e.type,text:e.text};e.beforeLine!==void 0&&(t.beforeLine=e.beforeLine+i),e.afterLine!==void 0&&(t.afterLine=e.afterLine+i),c.push(t)}for(let e=0;e<a;e+=1){let t=n.length-a+e,i=r.length-a+e;c.push({type:`context`,text:n[t],beforeLine:t+1,afterLine:i+1})}return c},wt=(e,t)=>{if(e.length===0&&t.length===0)return[];if(e.length>0&&t.length>0&&e.length*t.length>St)return[...e.map((e,t)=>({type:`removed`,text:e,beforeLine:t+1})),...t.map((e,t)=>({type:`added`,text:e,afterLine:t+1}))];let n=e.length+1,r=t.length+1,i=new Uint32Array(n*r);for(let n=e.length-1;n>=0;--n)for(let a=t.length-1;a>=0;--a)i[n*r+a]=e[n]===t[a]?i[(n+1)*r+a+1]+1:Math.max(i[(n+1)*r+a],i[n*r+a+1]);let a=[],o=0,s=0;for(;o<e.length&&s<t.length;)e[o]===t[s]?(a.push({type:`context`,text:e[o],beforeLine:o+1,afterLine:s+1}),o+=1,s+=1):i[(o+1)*r+s]>=i[o*r+s+1]?(a.push({type:`removed`,text:e[o],beforeLine:o+1}),o+=1):(a.push({type:`added`,text:t[s],afterLine:s+1}),s+=1);for(;o<e.length;)a.push({type:`removed`,text:e[o],beforeLine:o+1}),o+=1;for(;s<t.length;)a.push({type:`added`,text:t[s],afterLine:s+1}),s+=1;return a},Tt=e=>{let t=0,n=0;for(let r of e)r.type===`added`&&(t+=1),r.type===`removed`&&(n+=1);return{added:t,removed:n}},Et=3,$=e=>{let t=Array(e.length).fill(!1);for(let n=0;n<e.length;n+=1){if(e[n].type===`context`)continue;let r=Math.max(0,n-Et),i=Math.min(e.length-1,n+Et);for(let e=r;e<=i;e+=1)t[e]=!0}let n=[],r=[];for(let i=0;i<e.length;i+=1){if(!t[i]){r.push(e[i]);continue}r.length>0&&(n.push({type:`fold`,count:r.length,lines:r}),r=[]),n.push({type:`line`,line:e[i]})}return r.length>0&&n.push({type:`fold`,count:r.length,lines:r}),n};function Dt({line:e}){return(0,G.jsxs)(`tr`,{className:l(e.type===`added`&&`bg-[rgb(76,212,117)]/[0.12] text-ink`,e.type===`removed`&&`bg-[rgb(255,61,129)]/[0.10] text-ink-muted`,e.type===`context`&&`text-ink-muted`),children:[(0,G.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.beforeLine??``}),(0,G.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.afterLine??``}),(0,G.jsxs)(`td`,{className:`w-full whitespace-pre-wrap break-all px-3 align-top`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:l(`me-2 inline-block w-3 select-none text-center`,e.type===`added`&&`text-[rgb(46,164,79)]`,e.type===`removed`&&`text-[rgb(255,61,129)]`),children:e.type===`added`?`+`:e.type===`removed`?`−`:``}),e.text||`​`]})]})}var Ot=new Set,kt=e=>{let t=null;return e.map(e=>{let n=e.type===`line`?e.line:e.lines[0],r=t;return t=e.type===`line`?e.line:e.lines[e.lines.length-1],!r||!n?0:n.beforeLine!==void 0&&r.beforeLine!==void 0?n.beforeLine-r.beforeLine-1:n.afterLine!==void 0&&r.afterLine!==void 0?n.afterLine-r.afterLine-1:0})};function At({lines:e}){let{t}=c(),n=(0,W.useMemo)(()=>$(e),[e]),r=(0,W.useMemo)(()=>kt(n),[n]),[i,a]=(0,W.useState)({rows:null,set:Ot}),o=i.rows===n?i.set:Ot,s=e=>a({rows:n,set:new Set(o).add(e)});return(0,G.jsx)(`table`,{className:`w-full border-collapse`,children:(0,G.jsx)(`tbody`,{children:n.map((e,n)=>{let i=r[n];return(0,G.jsxs)(W.Fragment,{children:[i>0&&(0,G.jsx)(`tr`,{"data-testid":`work-diff-gap`,children:(0,G.jsx)(`td`,{colSpan:3,className:`select-none border-y border-line bg-surface-subtle/70 px-4 py-1 text-center text-[11px] text-ink-subtle`,children:t(`work.files.diffFolded`,{count:i,defaultValue:`{{count}} unchanged lines`})})}),l(e,n)]},`row-${n}`)})})});function l(e,n){return e.type===`fold`?o.has(n)?(0,G.jsx)(W.Fragment,{children:e.lines.map((e,t)=>(0,G.jsx)(Dt,{line:e},t))},`fold-${n}`):(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:3,className:`p-0`,children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`work-diff-fold`,onClick:()=>s(n),className:`flex w-full select-none items-center justify-center gap-1.5 border-y border-line bg-surface-subtle/70 px-4 py-1 text-[11px] text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink`,children:[(0,G.jsx)(ee,{className:`h-3 w-3 shrink-0`}),t(`work.files.diffFolded`,{count:e.count,defaultValue:`{{count}} unchanged lines`})]})})},`fold-${n}`):(0,G.jsx)(Dt,{line:e.line},`line-${n}`)}}function jt({lines:e,ariaLabel:t}){return(0,G.jsx)(`div`,{dir:`ltr`,role:`region`,"aria-label":t,"data-testid":`work-file-diff`,className:`min-h-0 flex-1 overflow-auto bg-surface font-mono text-[12px] leading-5`,children:(0,G.jsx)(At,{lines:e})})}var Mt=e=>{if(!e.startsWith(`"`)||!e.endsWith(`"`)||e.length<2)return e;let t=e.slice(1,-1),n=``;for(let e=0;e<t.length;e+=1){let r=t[e];if(r!==`\\`||e===t.length-1){n+=r;continue}e+=1;let i=t[e];if(i===`n`)n+=`
5
+ `;else if(i===`t`)n+=` `;else if(i===`\\`||i===`"`)n+=i;else if(i>=`0`&&i<=`7`){let r=i;for(;r.length<3&&e+1<t.length&&t[e+1]>=`0`&&t[e+1]<=`7`;)e+=1,r+=t[e];n+=String.fromCharCode(parseInt(r,8))}else n+=`\\${i}`}return n},Nt=e=>{let t=Mt(e);return t.startsWith(`a/`)||t.startsWith(`b/`)?t.slice(2):t},Pt=e=>{let t=e.slice(11).trim();if(t.startsWith(`"`)){let e=t.indexOf(`" `,1);return e===-1?null:{oldPath:Nt(t.slice(0,e+1)),newPath:Nt(t.slice(e+2).trim())}}let n=t.lastIndexOf(` b/`);if(n===-1){let e=t.indexOf(` `);return e===-1?null:{oldPath:Nt(t.slice(0,e)),newPath:Nt(t.slice(e+1))}}return{oldPath:Nt(t.slice(0,n)),newPath:Nt(t.slice(n+1))}},Ft=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,It=e=>({path:e.status===`deleted`?e.oldPath:e.newPath,...e.status===`renamed`&&e.oldPath!==e.newPath?{oldPath:e.oldPath}:{},status:e.status,binary:e.binary,lines:e.lines,stats:Tt(e.lines)}),Lt=e=>{let t=[],n=null;for(let r of e.split(`
6
+ `)){if(r.startsWith(`diff --git `)){n&&t.push(It(n));let e=Pt(r);n={oldPath:e?.oldPath??``,newPath:e?.newPath??e?.oldPath??``,status:`modified`,binary:!1,lines:[]};continue}if(!n)continue;if(r.startsWith(`new file mode`)){n.status=`added`;continue}if(r.startsWith(`deleted file mode`)){n.status=`deleted`;continue}if(r.startsWith(`rename from `)){n.status=`renamed`,n.oldPath=Mt(r.slice(12));continue}if(r.startsWith(`rename to `)){n.status=`renamed`,n.newPath=Mt(r.slice(10));continue}if(r.startsWith(`Binary files `)||r===`GIT binary patch`){n.binary=!0;continue}if(r.startsWith(`--- `)){let e=r.slice(4).trim();e!==`/dev/null`&&n.status!==`renamed`&&(n.oldPath=Nt(e));continue}if(r.startsWith(`+++ `)){let e=r.slice(4).trim();e!==`/dev/null`&&n.status!==`renamed`&&(n.newPath=Nt(e));continue}let e=r.match(Ft);if(e){n.beforeLine=parseInt(e[1],10),n.afterLine=parseInt(e[2],10);continue}if(!(r.startsWith(`index `)||r.startsWith(`similarity index`)||r.startsWith(`dissimilarity index`)||r.startsWith(`old mode`)||r.startsWith(`new mode`)||r.startsWith(`copy from`)||r.startsWith(`copy to`)||r.startsWith(`\\`))){if(r.startsWith(`+`)){n.lines.push({type:`added`,text:r.slice(1),...n.afterLine===void 0?{}:{afterLine:n.afterLine++}});continue}if(r.startsWith(`-`)){n.lines.push({type:`removed`,text:r.slice(1),...n.beforeLine===void 0?{}:{beforeLine:n.beforeLine++}});continue}if(r.startsWith(` `)){n.lines.push({type:`context`,text:r.slice(1),...n.beforeLine===void 0?{}:{beforeLine:n.beforeLine++},...n.afterLine===void 0?{}:{afterLine:n.afterLine++}});continue}}}return n&&t.push(It(n)),t},Rt=e=>{let t=0,n=0;for(let r of e)t+=r.stats.added,n+=r.stats.removed;return{added:t,removed:n}},zt=(e,t)=>{if(e.success&&e.data)return e.data;throw Error(e.error||t)},Bt=(e,t)=>{let n=e?.response?.data?.error;return typeof n==`string`&&n?n:e instanceof Error&&e.message?e.message:t},Vt=e=>e.indexStatus===`?`,Ht=e=>Vt(e)?`U`:e.workingTreeStatus===`.`?e.indexStatus:e.workingTreeStatus,Ut=e=>({modified:`M`,added:`A`,deleted:`D`,renamed:`R`})[e],Wt=e=>e===`A`||e===`U`?`text-[rgb(46,164,79)]`:e===`D`?`text-[rgb(255,61,129)]`:e===`R`||e===`C`?`text-sky-600 dark:text-sky-400`:`text-amber-600 dark:text-amber-500`,Gt=e=>{let t=e.lastIndexOf(`/`);return t===-1?{name:e,directory:``}:{name:e.slice(t+1),directory:e.slice(0,t)}};function Kt({added:e,removed:t,muted:n=!1}){return(0,G.jsxs)(`span`,{dir:`ltr`,className:`shrink-0 font-mono text-[10px] tabular-nums`,children:[(0,G.jsxs)(`span`,{className:n?`text-ink-subtle`:`text-[rgb(46,164,79)]`,children:[`+`,e]}),` `,(0,G.jsxs)(`span`,{className:n?`text-ink-subtle`:`text-[rgb(255,61,129)]`,children:[`−`,t]})]})}function qt({letter:e,path:t,oldPath:n,added:r,removed:i}){return(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-line bg-surface-raised/95 px-3 py-1.5 backdrop-blur`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-4 shrink-0 text-center font-mono text-[11px] font-semibold`,Wt(e)),children:e}),(0,G.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate text-start font-mono text-[11px] text-ink`,title:n?`${n} → ${t}`:t,children:n?`${n} → ${t}`:t}),(0,G.jsx)(Kt,{added:r,removed:i})]})}function Jt({taskId:e,mutationsDisabled:t=!1,disabledReason:n}){let{t:r}=c(),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!0),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[_,b]=(0,W.useState)([]),[x,S]=(0,W.useState)(``),[C,ee]=(0,W.useState)(``),[w,T]=(0,W.useState)(``),[E,D]=(0,W.useState)(null),[O,A]=(0,W.useState)(!1),[j,te]=(0,W.useState)(null),[ne,re]=(0,W.useState)(!1),ie=(0,W.useRef)(0),N=(0,W.useRef)(0),P=(0,W.useCallback)(async()=>{let t=++ie.current;s(!0),p(null);try{let n=zt(await R.getGitStatus(e),r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`}));if(t!==ie.current)return;a(n),b([])}catch(e){if(t!==ie.current)return;p(Bt(e,r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})))}finally{t===ie.current&&s(!1)}},[r,e]);(0,W.useEffect)(()=>{let e=window.setTimeout(()=>void P(),0);return()=>{window.clearTimeout(e),ie.current+=1}},[P]),(0,W.useEffect)(()=>{let t=!1,n=window.setTimeout(async()=>{if(!i?.initialized){te(null);return}if(!i.changes.some(e=>!Vt(e))){te(i.changes.length>0?{files:[],truncated:!1}:null);return}re(!0);try{let n=await R.getGitDiff(e);if(t||!n.success||!n.data)return;te({files:Lt(n.data.patch),truncated:n.data.truncated})}catch{}finally{t||re(!1)}},0);return()=>{t=!0,window.clearTimeout(n)}},[i,e]);let ae=async(e,n)=>{if(t||u)return!1;d(!0),p(null);try{let t=zt(await e(),r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return N.current+=1,a(t),b([]),D(null),L.success(n),!0}catch(e){let t=Bt(e,r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return p(t),L.error(t),!1}finally{d(!1)}},oe=async t=>{let n=++N.current;A(!0),p(null);try{if(Vt(t)){let i=zt(await R.getFile(e,t.path),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`}));if(n!==N.current)return;D({path:t.path,status:`added`,lines:Q(``,i.content),binary:!1,truncated:!1})}else{let i=zt(await R.getGitDiff(e,t.path),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`}));if(n!==N.current)return;let a=Lt(i.patch)[0];D({path:t.path,status:a?.status??`modified`,lines:a?.lines??[],binary:a?.binary??!1,truncated:i.truncated})}}catch(e){if(n!==N.current)return;p(Bt(e,r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}finally{n===N.current&&A(!1)}},se=(0,W.useMemo)(()=>{let e=new Map;for(let t of j?.files??[])e.set(t.path,t);return e},[j]),ce=(0,W.useMemo)(()=>Rt(j?.files??[]),[j]),le=w.trim().toLowerCase(),I=(0,W.useMemo)(()=>{let e=i?.changes??[];return le?e.filter(e=>e.path.toLowerCase().includes(le)):e},[le,i]);if(o&&!i)return(0,G.jsx)(`div`,{className:`flex h-full items-center justify-center text-ink-muted`,children:(0,G.jsx)(m,{className:`h-5 w-5 animate-spin`})});if(!i)return(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(v,{className:`mb-3 h-8 w-8 text-error-500`}),(0,G.jsx)(`p`,{className:`max-w-sm text-xs leading-relaxed text-error-600`,children:f||r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})}),(0,G.jsxs)(z,{size:`sm`,variant:`secondary`,className:`mt-4`,onClick:()=>void P(),children:[(0,G.jsx)(g,{className:`h-3.5 w-3.5`}),r(`common.retry`,{defaultValue:`Retry`})]})]});if(!i.initialized)return(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,G.jsx)(v,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,G.jsx)(`h3`,{className:`text-sm font-medium text-ink`,children:r(`work.git.notInitialized`,{defaultValue:`Git is not initialized`})}),(0,G.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-relaxed text-ink-muted`,children:r(`work.git.initializeDescription`,{defaultValue:`Create a local repository for status, diffs, branches, and commits. No remote credentials are connected.`})}),f&&(0,G.jsx)(`p`,{className:`mt-3 text-xs text-error-600`,children:f}),(0,G.jsxs)(z,{"data-testid":`work-git-init-button`,size:`sm`,className:`mt-4 bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||u,onClick:()=>void ae(()=>R.initializeGit(e),r(`work.git.initialized`,{defaultValue:`Git repository initialized.`})),children:[u?(0,G.jsx)(m,{className:`me-2 h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(k,{className:`me-2 h-3.5 w-3.5`}),r(`work.git.initialize`,{defaultValue:`Initialize Git`})]}),t&&n&&(0,G.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-subtle`,children:n})]});let ue=i.changes.filter(e=>e.staged).length,fe=i.changes.length>0,pe=I.filter(Vt),me=le?(j?.files??[]).filter(e=>e.path.toLowerCase().includes(le)):j?.files??[];return(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`work-git-panel`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-2`,children:[(0,G.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-lg bg-surface-subtle px-2 py-1 font-mono text-[11px] text-ink`,children:[(0,G.jsx)(v,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:i.detached?r(`work.git.detached`,{defaultValue:`detached HEAD`}):i.branch||`main`})]}),j&&(ce.added>0||ce.removed>0)&&(0,G.jsxs)(`span`,{"data-testid":`work-git-total-stats`,dir:`ltr`,className:`font-mono text-[11px] font-medium tabular-nums`,children:[(0,G.jsxs)(`span`,{className:`text-[rgb(46,164,79)]`,children:[`+`,ce.added]}),` `,(0,G.jsxs)(`span`,{className:`text-[rgb(255,61,129)]`,children:[`−`,ce.removed]})]}),(i.ahead>0||i.behind>0)&&(0,G.jsxs)(`span`,{className:`text-[10px] text-ink-muted`,children:[`↑`,i.ahead,` ↓`,i.behind]}),(0,G.jsxs)(`select`,{"data-testid":`work-git-branch-select`,"aria-label":r(`work.git.switchBranch`,{defaultValue:`Switch local branch`}),value:i.branch||``,disabled:t||u||fe,onChange:t=>{let n=t.target.value;!n||n===i.branch||ae(()=>R.switchGitBranch(e,n),r(`work.git.branchSwitched`,{name:n,defaultValue:`Switched to {{name}}.`}))},className:`h-7 max-w-44 rounded-lg border border-line bg-surface px-2 text-[11px] text-ink outline-none disabled:opacity-50`,children:[i.detached&&(0,G.jsx)(`option`,{value:``,disabled:!0,children:r(`work.git.detached`,{defaultValue:`detached HEAD`})}),i.branches.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}),(0,G.jsxs)(`div`,{className:`flex min-w-44 flex-1 items-center gap-1`,children:[(0,G.jsx)(`input`,{"data-testid":`work-git-branch-input`,value:C,maxLength:200,onChange:e=>ee(e.target.value),placeholder:r(`work.git.newBranch`,{defaultValue:`New local branch`}),className:`h-7 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,G.jsxs)(z,{"data-testid":`work-git-create-branch-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2`,disabled:t||u||!i.head||!C.trim(),onClick:()=>{let t=C.trim();ae(()=>R.createGitBranch(e,t),r(`work.git.branchCreated`,{name:t,defaultValue:`Created {{name}}.`})).then(e=>{e&&ee(``)})},children:[(0,G.jsx)(k,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:r(`work.git.createBranch`,{defaultValue:`Create`})})]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void P(),disabled:o||u,"aria-label":r(`common.refresh`,{defaultValue:`Refresh`}),className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink disabled:opacity-50`,children:(0,G.jsx)(g,{className:l(`h-3.5 w-3.5`,o&&`animate-spin`)})})]}),f&&(0,G.jsx)(`div`,{className:`border-b border-error-200 bg-error-50 px-3 py-2 text-xs text-error-700 dark:border-error-900/60 dark:bg-error-900/30 dark:text-error-300`,children:f}),t&&n&&(0,G.jsx)(`div`,{className:`border-b border-line px-3 py-1.5 text-[11px] text-ink-subtle`,children:n}),(0,G.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[minmax(15rem,0.75fr)_minmax(0,2.25fr)]`,children:[(0,G.jsxs)(`section`,{className:`flex min-h-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,G.jsxs)(`h3`,{className:`text-xs font-medium text-ink`,children:[r(`work.git.changes`,{defaultValue:`Changes`}),` `,(0,G.jsx)(`span`,{className:`text-ink-subtle`,children:i.changes.length})]}),(0,G.jsxs)(z,{"data-testid":`work-git-stage-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-[11px]`,disabled:t||u||_.length===0&&i.changes.length===0,onClick:()=>{let t=_.length>0?_:i.changes.map(e=>e.path);ae(()=>R.stageGitPaths(e,t),r(`work.git.staged`,{defaultValue:`Changes staged.`}))},children:[(0,G.jsx)(de,{className:`h-3.5 w-3.5`}),_.length>0?r(`work.git.stageSelected`,{count:_.length,defaultValue:`Stage {{count}}`}):r(`work.git.stageAll`,{defaultValue:`Stage all`})]})]}),i.changes.length>0&&(0,G.jsxs)(`div`,{className:`relative px-2 pb-1.5`,children:[(0,G.jsx)(h,{className:`pointer-events-none absolute start-4 top-1/2 h-3 w-3 -translate-y-[calc(50%+3px)] text-ink-subtle`}),(0,G.jsx)(`input`,{"data-testid":`work-git-filter`,value:w,maxLength:500,onChange:e=>T(e.target.value),placeholder:r(`work.git.filterFiles`,{defaultValue:`Filter changed files`}),"aria-label":r(`work.git.filterFiles`,{defaultValue:`Filter changed files`}),className:`h-7 w-full rounded-lg border border-line bg-surface pe-2 ps-7 text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`})]}),(0,G.jsx)(`div`,{className:`min-h-32 flex-1 overflow-y-auto px-2 pb-2`,children:i.changes.length===0?(0,G.jsx)(`p`,{className:`px-2 py-8 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):I.length===0?(0,G.jsx)(`p`,{className:`px-2 py-8 text-center text-xs text-ink-muted`,children:r(`work.git.noFilterMatches`,{defaultValue:`No changed files match this filter.`})}):I.map(e=>{let t=Ht(e),{name:n,directory:i}=Gt(e.path),a=se.get(e.path);return(0,G.jsxs)(`div`,{className:l(`flex items-center gap-1 rounded-lg hover:bg-surface-subtle`,E?.path===e.path&&`bg-surface-subtle`),children:[(0,G.jsx)(`input`,{type:`checkbox`,"aria-label":r(`work.git.selectPath`,{path:e.path,defaultValue:`Select {{path}}`}),checked:_.includes(e.path),onChange:t=>b(n=>t.target.checked?[...n,e.path]:n.filter(t=>t!==e.path)),className:`ms-2 h-3.5 w-3.5 accent-[#ff7b52]`}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`work-git-change`,onClick:()=>void oe(e),className:`flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-start`,title:e.path,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-3.5 shrink-0 text-center font-mono text-[10px] font-semibold`,Wt(t),e.staged&&`underline underline-offset-2`),children:t}),(0,G.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate text-start font-mono text-[11px]`,children:[(0,G.jsx)(`span`,{className:`text-ink`,children:n}),i&&(0,G.jsxs)(`span`,{className:`text-ink-subtle`,children:[` `,i]})]}),a&&(a.stats.added>0||a.stats.removed>0)&&(0,G.jsx)(Kt,{added:a.stats.added,removed:a.stats.removed})]})]},`${e.path}:${e.originalPath||``}`)})}),(0,G.jsxs)(`div`,{className:`border-t border-line p-2`,children:[(0,G.jsx)(`textarea`,{"data-testid":`work-git-commit-input`,value:x,maxLength:4e3,rows:2,onChange:e=>S(e.target.value),placeholder:r(`work.git.commitMessage`,{defaultValue:`Commit message`}),className:`w-full resize-none rounded-lg border border-line bg-surface px-2.5 py-2 text-xs text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,G.jsxs)(z,{"data-testid":`work-git-commit-button`,size:`sm`,className:`mt-1.5 w-full bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||u||ue===0||!x.trim(),onClick:()=>{let t=x.trim();ae(()=>R.commitGit(e,t),r(`work.git.committed`,{defaultValue:`Commit created.`})).then(e=>{e&&S(``)})},children:[u&&(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),r(`work.git.commit`,{defaultValue:`Commit staged changes`})]})]}),(0,G.jsxs)(`div`,{className:`max-h-56 shrink-0 overflow-y-auto border-t border-line p-3`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-ink`,children:[(0,G.jsx)(y,{className:`h-3.5 w-3.5`}),r(`work.git.history`,{defaultValue:`Local history`})]}),i.commits.length===0?(0,G.jsx)(`p`,{className:`py-3 text-center text-xs text-ink-muted`,children:r(`work.git.noCommits`,{defaultValue:`No commits yet.`})}):(0,G.jsx)(`ol`,{className:`space-y-2`,children:i.commits.map(e=>(0,G.jsxs)(`li`,{className:`rounded-lg border border-line bg-surface px-2.5 py-2`,children:[(0,G.jsx)(`p`,{dir:`auto`,className:`text-xs text-ink`,children:e.subject}),(0,G.jsxs)(`p`,{className:`mt-1 flex flex-wrap gap-x-2 text-[10px] text-ink-subtle`,children:[(0,G.jsx)(`span`,{dir:`ltr`,className:`font-mono`,children:e.shortHash}),(0,G.jsx)(`span`,{dir:`auto`,children:e.author}),(0,G.jsx)(`time`,{dateTime:e.authoredAt,children:new Date(e.authoredAt).toLocaleDateString()})]})]},e.hash))}),(0,G.jsx)(`p`,{className:`mt-3 border-t border-line pt-2 text-[10px] leading-relaxed text-ink-subtle`,children:r(`work.git.localOnly`,{defaultValue:`Local Git only. Push, pull, and pull requests require a separate trusted credential broker.`})})]})]}),(0,G.jsx)(`section`,{className:`flex min-h-48 min-w-0 flex-col`,children:E||O?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-2 py-1.5`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`work-git-all-changes-button`,onClick:()=>{N.current+=1,D(null),A(!1)},className:`inline-flex h-6 shrink-0 items-center gap-1 rounded-lg px-1.5 text-[11px] text-ink-muted hover:bg-surface-subtle hover:text-ink`,children:[(0,G.jsx)(F,{className:`h-3 w-3 rtl:rotate-180`}),r(`work.git.allChanges`,{defaultValue:`All changes`})]}),E&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-4 shrink-0 text-center font-mono text-[11px] font-semibold`,Wt(Ut(E.status))),children:Ut(E.status)}),(0,G.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,title:E.path,children:E.path}),!E.binary&&(0,G.jsx)(Kt,{added:E.lines.filter(e=>e.type===`added`).length,removed:E.lines.filter(e=>e.type===`removed`).length})]})]}),O?(0,G.jsx)(m,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):E?(0,G.jsxs)(`div`,{"data-testid":`work-git-diff`,dir:`ltr`,className:`min-h-0 flex-1 overflow-auto bg-surface font-mono text-[12px] leading-5`,children:[E.truncated&&(0,G.jsx)(`p`,{className:`border-b border-line bg-surface-subtle/70 px-3 py-1.5 text-center font-sans text-[11px] text-ink-subtle`,children:r(`work.git.diffTruncated`,{defaultValue:`This diff is truncated.`})}),E.binary?(0,G.jsx)(`p`,{className:`px-5 py-10 text-center font-sans text-xs text-ink-muted`,children:r(`work.git.binaryFile`,{defaultValue:`Binary file, no text diff.`})}):E.lines.length===0?(0,G.jsx)(`p`,{className:`px-5 py-10 text-center font-sans text-xs text-ink-muted`,children:r(`work.git.noDiff`,{defaultValue:`No textual diff is available yet. Untracked files appear after staging.`})}):(0,G.jsx)(At,{lines:E.lines})]}):null]}):i.changes.length===0?(0,G.jsx)(`p`,{className:`m-auto px-5 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):ne&&!j?(0,G.jsx)(m,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):(0,G.jsxs)(`div`,{"data-testid":`work-git-review`,dir:`ltr`,className:`min-h-0 flex-1 overflow-auto bg-surface font-mono text-[12px] leading-5`,children:[j?.truncated&&(0,G.jsx)(`p`,{className:`border-b border-line bg-surface-subtle/70 px-3 py-1.5 text-center font-sans text-[11px] text-ink-subtle`,children:r(`work.git.diffTruncated`,{defaultValue:`This diff is truncated.`})}),me.map(e=>(0,G.jsxs)(`div`,{"data-testid":`work-git-review-file`,children:[(0,G.jsx)(qt,{letter:Ut(e.status),path:e.path,oldPath:e.oldPath,added:e.stats.added,removed:e.stats.removed}),e.binary?(0,G.jsx)(`p`,{className:`px-5 py-6 text-center font-sans text-xs text-ink-muted`,children:r(`work.git.binaryFile`,{defaultValue:`Binary file, no text diff.`})}):(0,G.jsx)(At,{lines:e.lines})]},e.path)),pe.map(e=>(0,G.jsx)(`div`,{"data-testid":`work-git-review-file`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void oe(e),title:e.path,className:`flex w-full items-center gap-2 border-b border-line px-3 py-1.5 text-start hover:bg-surface-subtle`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`w-4 shrink-0 text-center font-mono text-[11px] font-semibold text-[rgb(46,164,79)]`,children:`U`}),(0,G.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,children:e.path}),(0,G.jsx)(M,{className:`h-3 w-3 shrink-0 text-ink-subtle`})]})},e.path)),me.length===0&&pe.length===0&&(0,G.jsx)(`p`,{className:`px-5 py-10 text-center font-sans text-xs text-ink-muted`,children:le?r(`work.git.noFilterMatches`,{defaultValue:`No changed files match this filter.`}):r(`work.git.selectChange`,{defaultValue:`Select a changed file to inspect its diff.`})})]})})]})]})}function Yt(e,t){return _e(e,t.ticket,t)}async function Xt(e){let t=(await pe.post(`/auth/websocket-ticket`,{audience:`work-terminal`,taskId:e})).data.data?.ticket;if(!t)throw Error(`The server did not issue a terminal ticket.`);return Yt(e,{protocol:window.location.protocol,host:window.location.host,hostname:window.location.hostname,apiBaseUrl:void 0,websocketBaseUrl:void 0,production:!0,ticket:t})}var Zt={background:`#ffffff`,foreground:`#1f2328`,cursor:`#1f2328`,selectionBackground:`rgba(255, 123, 82, 0.28)`},Qt={background:`#0f1115`,foreground:`#e6e6e6`,cursor:`#ff7b52`,selectionBackground:`rgba(255, 123, 82, 0.32)`};function $t({taskId:e,active:t,disabledReason:n}){let{t:i}=c(),a=Se(e=>e.theme.mode===`dark`),o=(0,W.useRef)(null),s=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useRef)(null),[f,h]=(0,W.useState)(`idle`),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(0),b=(0,W.useCallback)(()=>{let e=d.current,t=u.current,n=s.current;if(!(!e||!t||!n||n.readyState!==WebSocket.OPEN)){try{e.fit()}catch{return}n.send(JSON.stringify({type:`resize`,cols:t.cols,rows:t.rows}))}},[]);(0,W.useEffect)(()=>{if(!t||n)return;let i=!1,c,l;return(async()=>{h(`connecting`),_(null);let[{Terminal:t},{FitAddon:n}]=await Promise.all([r(()=>import(`./xterm-Da5ppSVt.js`),[]),r(()=>import(`./addon-fit-DIOBYJe3.js`),[])]);if(await r(()=>Promise.resolve({}),__vite__mapDeps([32])),i||!o.current)return;c=new t({allowProposedApi:!0,convertEol:!1,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`,fontSize:12,scrollback:5e3,theme:a?Qt:Zt});let f=new n;c.loadAddon(f),c.open(o.current),u.current=c,d.current=f;try{f.fit()}catch{}let p;try{p=await Xt(e)}catch(e){i||(h(`error`),_(e instanceof Error?e.message:null));return}if(i)return;l=new WebSocket(p),l.binaryType=`arraybuffer`,s.current=l;let m=new TextDecoder;l.onmessage=e=>{if(typeof e.data!=`string`){c?.write(m.decode(new Uint8Array(e.data)));return}try{let t=JSON.parse(e.data);if(t.type===`ready`){h(`connected`),b(),c?.focus();return}if(t.type===`error`){h(`error`),_(t.message||null);return}t.type===`exit`&&h(`closed`)}catch{}},l.onclose=()=>{i||h(e=>e===`error`||e===`closed`?e:`closed`)},l.onerror=()=>{i||h(`error`)},c.onData(e=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:`input`,data:e}))})})(),()=>{i=!0,l?.close(),s.current=null,c?.dispose(),u.current=null,d.current=null}},[t,n,v,a,b,e]),(0,W.useEffect)(()=>{let e=o.current;if(!e||!t)return;let n=new ResizeObserver(()=>b());return n.observe(e),()=>n.disconnect()},[t,b]);let x=()=>{s.current?.close(),y(e=>e+1)},S=n??(f===`error`?g??i(`work.terminal.failed`,{defaultValue:`The terminal session could not start.`}):f===`closed`?i(`work.terminal.closed`,{defaultValue:`Terminal session ended.`}):null);return(0,G.jsxs)(`div`,{"data-testid":`work-terminal-panel`,"data-status":n?`unavailable`:f,className:`relative flex min-h-0 flex-1 flex-col bg-surface`,children:[!n&&(0,G.jsx)(`div`,{ref:o,"data-testid":`work-terminal-surface`,dir:`ltr`,className:l(`min-h-0 flex-1 overflow-hidden p-2 text-left`,f!==`connected`&&`opacity-60`)}),f===`connecting`&&!n&&(0,G.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-xs text-ink-muted`,children:[(0,G.jsx)(m,{className:`h-4 w-4 animate-spin`}),i(`work.terminal.connecting`,{defaultValue:`Opening a shell in the sandbox…`})]}),S&&(0,G.jsxs)(`div`,{role:f===`error`?`alert`:void 0,className:`flex flex-col items-center gap-3 border-t border-line bg-surface-raised px-6 py-4 text-center`,children:[(0,G.jsx)(p,{className:`h-6 w-6 text-ink-subtle`}),(0,G.jsx)(`p`,{dir:`auto`,"data-testid":`work-terminal-status`,className:`max-w-md text-xs leading-relaxed text-ink-muted`,children:S}),!n&&(0,G.jsx)(z,{size:`sm`,"data-testid":`work-terminal-reconnect-button`,className:`h-8 rounded-lg bg-[#ff7b52] px-3 text-[#3d120c] hover:bg-[#ff7b52]/90`,onClick:x,children:i(`work.terminal.reconnect`,{defaultValue:`Reconnect`})})]})]})}var en=e=>{if(!e)return null;if(/^\/api\/work\/previews\/[A-Za-z0-9-]{1,100}\/\d{1,5}\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}\//.test(e))try{let t=new URL(fe,window.location.origin).origin;return new URL(e,`${t}/`).toString()}catch{return null}return null},tn=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),t.join(`/`)},nn=(e,t)=>{let n=e.metadata?.name??e.metadata?.toolName??e.metadata?.tool??e.metadata?.command;return typeof n==`string`&&n?n:t};function rn({task:e,liveRun:t,files:n,selectedFile:r,loadingFiles:i,actionLoading:a,onLoadFiles:o,onLoadFile:s,onClearSelectedFile:u,onSaveFile:f,onStartPreview:h,onStopPreview:_,onDirtyChange:y,terminal:b}){let{t:S,i18n:C}=c(),ee=d(C.language),[E,k]=(0,W.useState)(`files`),[A,j]=(0,W.useState)(``),[M,ne]=(0,W.useState)(``),[N,P]=(0,W.useState)(),[ae,le]=(0,W.useState)(``),[I,ue]=(0,W.useState)(!1),[de,fe]=(0,W.useState)(!1),pe=(0,W.useRef)(new Map),[R,me]=(0,W.useState)(()=>new Map),_e=en(e.previewUrl),ve=t?.runId,ye=t?.error,xe=t?.tools,Se=(0,W.useMemo)(()=>{let t=new Set(xe?.map(e=>e.id)||[]);return(e.messages||[]).filter(e=>{if(e.kind===`reasoning`||e.role!==`tool`&&e.kind===`message`)return!1;if(!ve||e.runId!==ve)return!0;if(e.kind===`error`&&ye)return!1;let n=e.metadata?.toolCallId;return typeof n!=`string`||!t.has(n)})},[ye,ve,xe,e.messages]),Ce=Se.length+(xe?.length||0),we=!!r&&M!==(r?.content??``),B=e.status===`preparing`||e.status===`running`,V=(0,W.useRef)(B),H=(0,W.useRef)(0),U=(0,W.useRef)(M),Te=(0,W.useRef)(N),Ee=(0,W.useRef)(r),De=(0,W.useRef)(e.id),Oe=(0,W.useRef)(o),ke=(0,W.useRef)(s),Ae=(0,W.useRef)(y),K=(0,W.useRef)(!0),je=r?R.get(r.path):void 0,q=(0,W.useMemo)(()=>r&&je!==void 0&&je!==r.content?Q(je,r.content):null,[je,r]),Me=(0,W.useMemo)(()=>q?Tt(q):null,[q]),Ne=!!(Me&&(Me.added>0||Me.removed>0)),Pe=r?pt(r.path):!1,Fe=!r||mt(M),Ie=Pe&&Fe;(0,W.useEffect)(()=>{U.current=M,Te.current=N,Ee.current=r,De.current=e.id,Ae.current=y},[N,M,y,r,e.id]),(0,W.useEffect)(()=>{Oe.current=o,ke.current=s},[s,o]),(0,W.useEffect)(()=>(K.current=!0,()=>{K.current=!1,H.current+=1,Ae.current(!1)}),[]),(0,W.useEffect)(()=>{if(!V.current&&B&&me(new Map(pe.current)),V.current&&!B&&(Oe.current(A),r&&!we)){let e=++H.current,t=r.path,n=U.current,i=Te.current;ke.current(t).then(r=>{if(!K.current||e!==H.current||r.path!==t||U.current!==n||Te.current!==i)return;pe.current.set(r.path,r.content);let a=R.get(r.path);a!==void 0&&a!==r.content&&fe(!0),U.current=r.content,Te.current=r.updatedAt??r.modifiedAt,ne(r.content),P(r.updatedAt??r.modifiedAt)}).catch(()=>void 0)}V.current=B},[A,we,r,B,R]);let J=()=>!we||window.confirm(S(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),Re=()=>{r&&he(e.id,r.path)},ze=async e=>{J()&&(H.current+=1,Re(),u(),y(!1),fe(!1),j(e),await o(e).catch(()=>void 0))},Be=async t=>{if(!J())return;let n=++H.current;Re();let r=await s(t).catch(()=>void 0);if(!K.current||!r||n!==H.current)return;pe.current.set(r.path,r.content);let i=R.get(r.path);fe(i!==void 0&&i!==r.content);let a=be(e.id,r.path),o=a?.content??r.content,c=a?.baseUpdatedAt??r.updatedAt??r.modifiedAt;U.current=o,Te.current=c,ne(o),P(c),y(a!==null&&a.content!==r.content)},Ve=()=>{J()&&(H.current+=1,Re(),u(),y(!1),fe(!1))},He=t=>{r&&(U.current=t,ne(t),t===r.content?he(e.id,r.path):ge(e.id,r.path,{content:t,baseUpdatedAt:N??r.updatedAt??r.modifiedAt}),y(t!==r.content))},Ue=async()=>{if(!r)return;let t=e.id,n=r.path,i=M,a=H.current,o=await f(n,i,N).catch(()=>!1);if(!K.current||o===!1||a!==H.current||De.current!==t||Ee.current?.path!==n)return;let s=o.updatedAt??o.modifiedAt;pe.current.set(n,typeof o.content==`string`?o.content:i),Te.current=s,P(s);let c=U.current;if(c===i){he(t,n),y(!1);return}ge(t,n,{content:c,baseUpdatedAt:s}),y(!0)},We=async()=>{if(!r||B||I||!Ie)return;ue(!0);let e=H.current,t=r.path,n=U.current;try{let r=await gt(t,n);if(!K.current||e!==H.current||Ee.current?.path!==t||U.current!==n)return;He(r),L.success(S(`work.files.formatted`,{defaultValue:`Code formatted.`}))}catch(r){if(!K.current||e!==H.current||Ee.current?.path!==t||U.current!==n)return;L.error(r instanceof Error?r.message:S(`work.files.formatFailed`,{defaultValue:`Could not format this file.`}))}finally{K.current&&ue(!1)}},Y=[{id:`files`,label:S(`work.workspace.files`,{defaultValue:`Files`}),icon:se,testId:`work-files-tab`},{id:`activity`,label:S(`work.workspace.activity`,{defaultValue:`Activity`}),icon:ce,testId:`work-activity-tab`},{id:`git`,label:S(`work.workspace.git`,{defaultValue:`Git`}),icon:v,testId:`work-git-tab`},{id:`terminal`,label:S(`work.workspace.terminal`,{defaultValue:`Terminal`}),icon:p,testId:`work-terminal-tab`},{id:`preview`,label:S(`work.workspace.preview`,{defaultValue:`Preview`}),icon:te,testId:`work-preview-tab`}],Ge=(e,t)=>{let n=null;if(e.key===`ArrowRight`&&(n=(t+(ee?-1:1)+Y.length)%Y.length),e.key===`ArrowLeft`&&(n=(t+(ee?1:-1)+Y.length)%Y.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=Y.length-1),n===null)return;e.preventDefault();let r=Y[n];k(r.id),e.currentTarget.parentElement?.querySelector(`#work-workspace-tab-${r.id}`)?.focus()};return(0,G.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-transparent`,children:[(0,G.jsxs)(`div`,{"data-testid":`work-workspace-toolbar`,className:`flex h-12 shrink-0 items-center gap-2 border-b border-line bg-surface-raised/75 px-2 backdrop-blur-xl`,children:[(0,G.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,"aria-label":S(`work.workspace.label`,{defaultValue:`Workspace views`}),className:`flex min-w-0 items-center overflow-x-auto rounded-xl border border-line bg-surface-subtle p-0.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:Y.map((e,t)=>{let n=e.icon;return(0,G.jsxs)(`button`,{type:`button`,role:`tab`,id:`work-workspace-tab-${e.id}`,"aria-selected":E===e.id,"aria-controls":E===e.id?`work-workspace-panel-${e.id}`:void 0,"aria-label":e.label,tabIndex:E===e.id?0:-1,title:e.label,"data-testid":e.testId,onClick:()=>k(e.id),onKeyDown:e=>Ge(e,t),className:l(`flex h-7 items-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow]`,E===e.id?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:text-ink`),children:[(0,G.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`hidden xs:inline`,children:e.label}),e.id===`activity`&&Ce>0&&(0,G.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-[10px] text-ink-muted`,children:Ce})]},e.id)})}),E===`files`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[r&&(0,G.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-ink-muted hover:bg-surface-subtle hover:text-ink sm:hidden`,onClick:Ve,"aria-label":S(`work.files.back`,{defaultValue:`Back to files`}),children:(0,G.jsx)(F,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,G.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,title:r?.path??`/workspace${A?`/${A}`:``}`,children:[r?.path??`/workspace${A?`/${A}`:``}`,we&&` •`]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,disabled:!A,onClick:()=>void ze(tn(A)),className:l(`hidden h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink disabled:opacity-30 sm:inline-flex`,!r&&`inline-flex`),"aria-label":S(`work.files.up`,{defaultValue:`Parent folder`}),title:S(`work.files.up`,{defaultValue:`Parent folder`}),children:(0,G.jsx)(F,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`work-refresh-files-button`,onClick:()=>void o(A).catch(()=>void 0),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-transparent text-ink-muted hover:border-line hover:bg-surface-subtle hover:text-ink`,"aria-label":S(`common.refresh`,{defaultValue:`Refresh`}),title:S(`common.refresh`,{defaultValue:`Refresh`}),children:(0,G.jsx)(g,{className:l(`h-3.5 w-3.5`,i&&`animate-spin`)})}),r&&Ne&&Me&&(0,G.jsxs)(`button`,{type:`button`,"data-testid":`work-diff-toggle-button`,"aria-pressed":de,onClick:()=>fe(e=>!e),title:S(`work.files.changesSince`,{defaultValue:`What changed since the last turn`}),className:l(`inline-flex h-8 items-center gap-1.5 rounded-lg border px-2 text-[11px] font-medium transition-colors`,de?`border-transparent bg-ink text-ink-inverse`:`border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`),children:[(0,G.jsx)(x,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:S(`work.files.changes`,{defaultValue:`Changes`})}),(0,G.jsxs)(`span`,{dir:`ltr`,className:`tabular-nums`,children:[(0,G.jsxs)(`span`,{className:de?void 0:`text-[rgb(46,164,79)]`,children:[`+`,Me.added]}),` `,(0,G.jsxs)(`span`,{className:de?void 0:`text-[rgb(255,61,129)]`,children:[`−`,Me.removed]})]})]}),r&&!de&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(z,{"data-testid":`work-format-file-button`,size:`sm`,variant:`ghost`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:B||I||!Ie,onClick:()=>void We(),"aria-busy":I||void 0,title:Ie?S(`work.files.formatShortcut`,{defaultValue:`Format (Shift+Alt+F)`}):Pe?S(`work.files.formatTooLarge`,{defaultValue:`Formatting is limited to files under 100,000 characters and 4,000 lines.`}):S(`work.files.formatUnsupported`,{defaultValue:`Formatting is not available for this file type.`}),"aria-label":S(`work.files.format`,{defaultValue:`Format file`}),children:[I?(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(re,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{className:`hidden 2xl:inline`,children:S(`work.files.format`,{defaultValue:`Format`})})]}),(0,G.jsxs)(z,{"data-testid":`work-save-file-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:!we||B||I||a,onClick:()=>void Ue(),"aria-busy":a||void 0,title:S(`work.files.saveShortcut`,{defaultValue:`Save (⌘/Ctrl+S)`}),"aria-label":S(`common.save`),children:[a?(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(O,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{className:`hidden 2xl:inline`,children:S(`common.save`)})]})]})]})]}),(E===`activity`||E===`git`)&&(0,G.jsx)(`div`,{className:`min-w-0 flex-1`}),E===`terminal`&&(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,G.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,children:`/workspace`}),B&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-ink-subtle`,children:S(`work.terminal.taskRunning`,{defaultValue:`Model turn in progress`})})]}),E===`preview`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{dir:`auto`,value:ae,onChange:e=>le(e.target.value),placeholder:S(`work.preview.command`,{defaultValue:`Optional start command`}),"aria-label":S(`work.preview.command`,{defaultValue:`Optional start command`}),className:`h-8 min-w-0 flex-1 rounded-lg border border-line bg-surface px-2.5 font-mono text-[11px] text-ink outline-none placeholder:text-ink-subtle focus:border-primary-500`}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.previewStatus===`running`||e.previewStatus===`starting`?(0,G.jsxs)(z,{"data-testid":`work-stop-preview-button`,variant:`danger`,size:`sm`,className:`h-8 w-8 rounded-lg px-0 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void _(),"aria-busy":a||void 0,"aria-label":S(`work.preview.stop`,{defaultValue:`Stop preview`}),children:[a?(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(D,{className:`h-3.5 w-3.5 fill-current`}),(0,G.jsx)(`span`,{className:`hidden 2xl:inline`,children:S(`work.preview.stop`,{defaultValue:`Stop preview`})})]}):(0,G.jsxs)(z,{"data-testid":`work-start-preview-button`,size:`sm`,className:`h-8 w-8 rounded-lg bg-[#ff7b52] px-0 text-[#3d120c] hover:bg-[#ff7b52]/90 sm:w-auto sm:px-2.5`,disabled:a,onClick:()=>void h(ae.trim()||void 0),"aria-busy":a||void 0,"aria-label":S(`work.preview.start`,{defaultValue:`Start preview`}),children:[a?(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(w,{className:`h-3.5 w-3.5 fill-current`}),(0,G.jsx)(`span`,{className:`hidden 2xl:inline`,children:S(`work.preview.start`,{defaultValue:`Start preview`})})]}),_e&&(0,G.jsx)(`a`,{href:_e,target:`_blank`,rel:`noopener noreferrer`,"aria-label":S(`work.preview.open`,{defaultValue:`Open`}),title:S(`work.preview.open`,{defaultValue:`Open`}),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`,children:(0,G.jsx)(oe,{className:`h-3.5 w-3.5`})})]})]})]}),E===`files`&&(0,G.jsxs)(`div`,{id:`work-workspace-panel-files`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-files`,className:`flex min-h-0 flex-1`,children:[(0,G.jsx)(`div`,{className:l(`flex min-h-0 w-full flex-col border-e border-line bg-surface-raised`,r?`hidden sm:flex sm:w-52 xl:w-60`:`flex`),children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:i&&n.length===0?(0,G.jsx)(`div`,{className:`flex justify-center py-8 text-ink-muted`,children:(0,G.jsx)(m,{className:`h-5 w-5 animate-spin`})}):n.length===0?(0,G.jsx)(`p`,{className:`px-3 py-8 text-center text-xs text-ink-muted`,children:S(`work.files.empty`,{defaultValue:`No files in this folder yet.`})}):[...n].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1).map(e=>(0,G.jsxs)(`button`,{type:`button`,"data-testid":`work-file-item`,"data-path":e.path,onClick:()=>{e.type===`directory`?ze(e.path):Be(e.path)},className:l(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-xs hover:bg-surface-subtle`,r?.path===e.path?`bg-surface-subtle text-ink`:`text-ink-muted`),children:[e.type===`directory`?(0,G.jsx)(T,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}):(0,G.jsx)(ie,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsx)(`span`,{dir:`auto`,className:`truncate`,children:e.name})]},e.path))})}),(0,G.jsx)(`div`,{className:l(`min-h-0 min-w-0 flex-1 flex-col`,r?`flex`:`hidden sm:flex`),children:r&&de&&q?(0,G.jsx)(jt,{lines:q,ariaLabel:S(`work.files.diffLabel`,{path:r.path,defaultValue:`Changes since the last turn: {{path}}`})}):r?(0,G.jsx)(xt,{path:r.path,value:M,ariaLabel:S(`work.files.editorLabel`,{path:r.path,defaultValue:`File editor: {{path}}`}),onChange:He,onSaveShortcut:()=>{we&&!B&&!a&&!I&&Ue()},onFormatShortcut:()=>void We(),disabled:B||I}):(0,G.jsxs)(`div`,{className:`m-auto px-6 text-center text-xs text-ink-muted`,children:[(0,G.jsx)(ie,{className:`mx-auto mb-3 h-7 w-7 text-ink-subtle`}),S(`work.files.select`,{defaultValue:`Select a file to inspect and edit it.`})]})})]}),E===`activity`&&(0,G.jsxs)(`div`,{id:`work-workspace-panel-activity`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-activity`,className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[t&&(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(Le,{run:t,variant:`activity`})}),Se.length===0&&!t?(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center text-xs text-ink-muted`,children:[(0,G.jsx)(p,{className:`mb-3 h-7 w-7 text-ink-subtle`}),S(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]}):(0,G.jsx)(`div`,{className:`space-y-2`,children:Se.map(e=>(0,G.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{dir:`auto`,className:`truncate font-mono text-xs font-medium text-ink`,children:nn(e,S(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-ink-subtle rtl:tracking-normal`,children:{message:S(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:S(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:S(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:S(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:S(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind]})]}),e.content&&(0,G.jsx)(`pre`,{dir:`ltr`,className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap break-words text-left font-mono text-[11px] leading-relaxed text-ink-muted`,children:e.content})]},e.id))})]}),E===`git`&&(0,G.jsx)(`div`,{id:`work-workspace-panel-git`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-git`,className:`min-h-0 flex-1`,children:(0,G.jsx)(Jt,{taskId:e.id,mutationsDisabled:B||e.previewStatus===`starting`||e.previewStatus===`running`,disabledReason:B?S(`work.git.blockedByRun`,{defaultValue:`Git write actions unlock when the model turn finishes.`}):e.previewStatus===`starting`||e.previewStatus===`running`?S(`work.git.blockedByPreview`,{defaultValue:`Stop the preview before changing Git state.`}):void 0})}),E===`terminal`&&(0,G.jsx)(`div`,{id:`work-workspace-panel-terminal`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-terminal`,className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)($t,{taskId:e.id,active:E===`terminal`,disabledReason:b&&!b.available?b.reason??S(`work.terminal.unavailable`,{defaultValue:`The interactive terminal is not available in this deployment.`}):B?S(`work.terminal.blockedByRun`,{defaultValue:`The model is using this container. The terminal opens when the turn finishes.`}):void 0})}),E===`preview`&&(0,G.jsx)(`div`,{id:`work-workspace-panel-preview`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-preview`,className:`flex min-h-0 flex-1 flex-col`,children:e.previewStatus===`starting`?(0,G.jsxs)(`div`,{className:`m-auto flex items-center gap-2 text-xs text-ink-muted`,children:[(0,G.jsx)(m,{className:`h-4 w-4 animate-spin`}),S(`work.preview.starting`,{defaultValue:`Starting preview…`})]}):_e&&e.previewStatus===`running`?(0,G.jsx)(`iframe`,{"data-testid":`work-preview-frame`,title:S(`work.preview.frameTitle`,{defaultValue:`Workspace preview`}),src:_e,sandbox:`allow-scripts allow-forms allow-modals allow-downloads allow-pointer-lock`,referrerPolicy:`no-referrer`,className:`min-h-0 flex-1 border-0 bg-white`}):(0,G.jsxs)(`div`,{className:`m-auto max-w-sm px-6 text-center text-xs leading-relaxed text-ink-muted`,children:[(0,G.jsx)(te,{className:`mx-auto mb-3 h-8 w-8 text-ink-subtle`}),e.previewStatus===`failed`?S(`work.preview.failed`,{defaultValue:`The preview could not start. Check Activity, then try another command.`}):S(`work.preview.empty`,{defaultValue:`Start the app inside this workspace to inspect it here.`})]})})]})}var an=e=>{let t=e.trim().toLowerCase();return!!t&&!t.includes(`embed`)},on=(e,t)=>e instanceof Error&&e.message?e.message:t,sn=(e,t)=>new Promise(n=>{if(t.aborted){n();return}let r,i=()=>{r!==void 0&&window.clearTimeout(r),t.removeEventListener(`abort`,i),n()};r=window.setTimeout(i,e),t.addEventListener(`abort`,i,{once:!0})});function cn(){let{t:e}=c(),t=i(),n=a(),{taskId:r}=o(),d=Se(e=>e.preferences),p=Se(e=>e.setPreferences),m=ve(e=>e.user),h=m?.id??null,[g,v]=(0,W.useState)(!1),y=u(e=>e.models),b=u(e=>e.selectedModel),x=u(e=>e.selectedProviderType),ee=u(e=>e.selectedProviderId),w=u(e=>e.loadModels),{capabilities:T,tasks:E,selectedTask:D,files:O,selectedFile:k,liveRuns:j,loadingTask:M,loadingOlderMessages:re,loadingFiles:ie,actionLoading:N,error:P,loadCapabilities:ae,loadTasks:oe,selectTask:se,loadTask:F,loadOlderMessages:ce,createTask:I,updateTask:de,deleteTask:fe,startRun:pe,cancelRun:ge,beginLiveRun:_e,applyRunEvents:be,setLiveRunConnection:z,clearLiveRun:Ce,loadFiles:V,loadFile:H,clearSelectedFile:Ee,saveFile:De,startPreview:Oe,stopPreview:Ae,clearError:K}=xe(),je=(0,W.useMemo)(()=>y.filter(e=>!e.isPersona&&!e.isAgent&&an(e.name)&&(!e.isPlugin||!!e.pluginId)),[y]),q=(0,W.useMemo)(()=>je.flatMap(e=>{if(e.isPlugin&&!e.pluginId)return[];let t=e.isPlugin?`plugin`:`ollama`,n=e.isPlugin?e.pluginId:void 0,r=e.name.trim().toLowerCase(),i={model:e.name,providerType:t,providerId:n};return[{...i,key:U(i),label:e.isPlugin&&e.pluginName?`${e.name} · ${e.pluginName}`:e.name,remote:e.isPlugin||r.endsWith(`:cloud`)||r.endsWith(`-cloud`)}]}),[je]),[Me,Ne]=(0,W.useState)(``),[Pe,Fe]=(0,W.useState)({locationKey:t.key,value:`conversation`}),Ie=Pe.locationKey===t.key?Pe.value:`conversation`,Le=e=>Fe({locationKey:t.key,value:e}),[J,Re]=(0,W.useState)(!1),[ze,Be]=(0,W.useState)(``),Ve=T?.hostWorkspaces?.enabled===!0,He=T?.hostWorkspaces?.roots??[],[We,Y]=(0,W.useState)([]),[Ge,Ke]=(0,W.useState)(``),qe=!D;(0,W.useEffect)(()=>{if(!qe)return;let e=!1;return R.listPolicies().then(t=>{if(e||!t.success||!t.data)return;let n=t.data;Y(n),Ke(e=>e&&!n.some(t=>t.id===e)?``:e)}).catch(()=>{}),()=>{e=!0}},[qe]);let Je=D?.id,Ye=D?.previewStatus===`running`||D?.previewStatus===`starting`;(0,W.useEffect)(()=>{if(!Je||!Ye)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&F(Je,!0).catch(()=>{})},3e4);return()=>window.clearInterval(e)},[Je,Ye,F]);let[Xe,Ze]=(0,W.useState)({taskId:null,open:!1}),Qe=Xe.open&&Xe.taskId===D?.id,$e=(0,W.useRef)(null),et=(0,W.useRef)(null),tt=(0,W.useRef)(null),nt=(0,W.useCallback)((e=!1)=>{Ze(e=>({...e,open:!1})),e&&window.requestAnimationFrame(()=>et.current?.focus())},[]);(0,W.useEffect)(()=>{if(!Qe)return;let e=window.requestAnimationFrame(()=>{tt.current?.querySelector(`[role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!$e.current?.contains(e.target)&&nt()},n=e=>{e.key===`Escape`&&(e.preventDefault(),nt(!0))};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[nt,Qe]);let rt=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),nt(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=[...tt.current?.querySelectorAll(`[role="menuitem"]:not(:disabled)`)??[]];if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowUp`?(n-1+t.length)%t.length:(n+1)%t.length]?.focus()};(0,W.useEffect)(()=>{ae(),oe()},[ae,oe]),(0,W.useEffect)(()=>{if(!r){se(null);return}se(r),F(r).catch(()=>void 0),V(r,``).catch(()=>void 0)},[r,V,F,se]);let at=q.find(e=>e.key===Me)||q.find(e=>e.model===b&&(x===`plugin`?e.providerType===`plugin`&&e.providerId===ee:e.providerType===`ollama`))||q[0],ot=r?E.find(e=>e.id===r):void 0,st=ot?.status??D?.status,ct=D?.activeRun??ot?.activeRun??null,X=ct?.id,lt=ct?.status===`queued`||ct?.status===`preparing`||ct?.status===`running`,ut=r&&j[r]?.runId===X?j[r]:void 0,dt=st===`preparing`||st===`running`?1e3:4e3;(0,W.useEffect)(()=>{let e,t=!1,n=async()=>{await oe(!0),t||(e=setTimeout(n,dt))};return e=setTimeout(n,dt),()=>{t=!0,e&&clearTimeout(e)}},[oe,dt]);let ft=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!r||!st){ft.current=null;return}let e=ft.current;ft.current={taskId:r,status:st},e?.taskId===r&&(e.status===`preparing`||e.status===`running`)&&st!==`preparing`&&st!==`running`&&(F(r,!0).catch(()=>void 0),V(r,``).catch(()=>void 0))},[V,F,st,r]),(0,W.useEffect)(()=>{if(!r||!X||!lt)return;let e=new AbortController,t=!1,n=0,i=xe.getState().liveRuns[r]?.runId===X&&xe.getState().liveRuns[r]?.lastEventId||0,a=!1,o=[],s=null,c=()=>{if(s!==null&&(window.cancelAnimationFrame(s),s=null),o.length===0)return;let e=o;o=[],be(e)},l=e=>{if(e.type!==`snapshot`&&(n=0),i=Math.max(i,e.id),o.push(e),e.type===`done`||e.type===`error`&&e.data.terminal!==!1){a=!0,c();return}s===null&&(s=window.requestAnimationFrame(c))};return _e(r,X,ct?.startedAt||void 0),(async()=>{for(;!t&&!e.signal.aborted&&!a;){z(r,X,n>=3?`error`:n===0?`connecting`:`reconnecting`);let o=Date.now();try{if(await R.streamRunEvents({taskId:r,runId:X,after:i,signal:e.signal,onEvent:l}),c(),a||t||e.signal.aborted)break;throw Error(`The live Work connection closed.`)}catch(i){if(c(),t||e.signal.aborted)return;Date.now()-o>=5e3&&(n=0),n+=1,z(r,X,n>=3?`error`:`reconnecting`,n>=3?on(i,`Live updates are reconnecting in the background.`):void 0),await sn(Math.min(4e3,250*2**Math.min(n,4)),e.signal)}}if(c(),!(!a||e.signal.aborted)){z(r,X,`closed`);try{await Promise.all([F(r,!0),V(r,``),oe(!0)])}catch{}finally{Ce(r,X)}}})(),()=>{t=!0,e.abort(),c()}},[be,_e,Ce,V,F,oe,ct?.startedAt,lt,X,z,r]),(0,W.useEffect)(()=>{if(!J)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[J]);let pt=(0,W.useCallback)(()=>!J||window.confirm(e(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),[e,J]),mt=(0,W.useCallback)(()=>!J||window.confirm(e(`work.files.leaveWithDraft`,{defaultValue:`Leave this file? Your unsaved edit will remain as a browser draft.`})),[e,J]),Z=()=>{D&&k&&he(D.id,k.path)},ht=s(({currentLocation:e,nextLocation:t})=>{let n=t.state;return J&&n?.deletedWorkTaskId!==r&&`${e.pathname}${e.search}${e.hash}`!=`${t.pathname}${t.search}${t.hash}`});(0,W.useEffect)(()=>{if(ht.state!==`blocked`)return;if(!mt()){ht.reset();return}let e=ht.proceed,t=window.setTimeout(()=>{Re(!1),window.setTimeout(e,0)},0);return()=>window.clearTimeout(t)},[mt,ht]);let gt=()=>{K(),Le(`conversation`),n(`/work`)},_t=async t=>{if(D&&!pt())return!1;D&&J&&(Z(),Ee(),Re(!1));try{if(D)await pe(D.id,{message:t,model:D.model,providerType:D.providerType,providerId:D.providerId||void 0});else{if(!at)throw Error(e(`work.composer.noModelSelected`,{defaultValue:`No Work-compatible model is selected.`}));let r=await I({message:t,model:at.model,providerType:at.providerType,providerId:at.providerId,networkEnabled:!0,...Ve&&ze.trim()?{hostPath:ze.trim()}:{},...Ge?{policyId:Ge}:{}});n(`/work/${r.id}`)}return!0}catch(t){return L.error(on(t,e(`work.toasts.runFailed`,{defaultValue:`Could not start the Work task.`}))),!1}},vt=async t=>{let n=kt.find(e=>e.key===t);if(n){if(!D){Ne(t);return}try{await de(D.id,{model:n.model,providerType:n.providerType,providerId:n.providerId})}catch(t){L.error(on(t,e(`work.toasts.updateFailed`,{defaultValue:`Could not update this task.`})))}}},yt=async()=>{if(D)try{await ge(D.id),L.success(e(`work.toasts.cancelled`,{defaultValue:`Work run stopped.`}))}catch(t){L.error(on(t,e(`work.toasts.cancelFailed`,{defaultValue:`Could not stop the Work run.`})))}},bt=async t=>{let i=E.find(e=>e.id===t);if(!window.confirm(e(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:i?.title||e(`work.tasks.untitled`,{defaultValue:`Untitled task`})})))return;let a=r===t&&J;a&&Re(!1);try{await fe(t),ye(t),r===t&&n(`/work`)}catch(t){a&&Re(!0),L.error(on(t,e(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`})))}},xt=async t=>{if(!D)return!1;let n=t.trim();if(!n||n===D.title)return!!n;try{return await de(D.id,{title:n}),!0}catch(t){return L.error(on(t,e(`work.toasts.renameFailed`,{defaultValue:`Could not rename this task.`}))),!1}},St=async(e,t,n)=>{try{return await e(),n&&L.success(n),!0}catch(e){return L.error(on(e,t)),!1}},Ct=async(t,n,r)=>{if(!D)return!1;let i=D.id;try{let a=await De(i,t,n,r);return xe.getState().selectedTaskId===i&&L.success(e(`work.toasts.saved`,{defaultValue:`File saved.`})),a}catch(t){return xe.getState().selectedTaskId===i&&L.error(on(t,e(`work.toasts.saveFailed`,{defaultValue:`Could not save this file.`}))),!1}},Q=T?.available===!1,wt=e(`work.runtime.ready`,{defaultValue:`Runtime ready`}),Tt=T?.runtime===`kubernetes`?`Kubernetes · ${wt}`:T?.pluginAvailable?T.ollamaAvailable?e(`work.runtime.readyHybrid`,{defaultValue:`Docker + models ready`}):e(`work.runtime.readyPlugin`,{defaultValue:`Docker + plugin ready`}):e(`work.runtime.readyOllama`,{defaultValue:`Docker ready`}),Et=D?Te(D):!1,$=D?{model:D.model,providerType:D.providerType,providerId:D.providerId||void 0}:void 0,Dt=$?U($):at?.key||``,Ot=$&&!q.some(e=>e.key===Dt)?{...$,key:Dt,label:`${$.model} · ${$.providerType===`plugin`?$.providerId||`plugin`:`Ollama`}`,remote:$.providerType===`plugin`||$.model.toLowerCase().endsWith(`:cloud`)||$.model.toLowerCase().endsWith(`-cloud`)}:void 0,kt=Ot?[Ot,...q]:q,At=we[D?.status??`idle`],jt=e(At.labelKey,{defaultValue:At.label}),Mt=async()=>{if(d.workRemoteProviderDisclosureDismissed||g)return!1;let t=h;v(!0);try{let n=await me.updatePreferences({workRemoteProviderDisclosureDismissed:!0});if(!n.success)throw Error(n.error||e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`}));return(ve.getState().user?.id??null)===t&&(p({workRemoteProviderDisclosureDismissed:!0}),!0)}catch{return L.error(e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`})),!1}finally{v(!1)}};return(0,G.jsx)(`div`,{"data-testid":`work-page`,className:`relative flex h-full min-h-0 overflow-hidden bg-transparent`,children:(0,G.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,G.jsxs)(`header`,{className:`relative z-50 flex h-16 shrink-0 items-center gap-3 border-b border-line bg-surface/55 px-3 backdrop-blur-xl md:px-4`,children:[D?(0,G.jsx)(`input`,{"data-testid":`work-task-title`,dir:`auto`,defaultValue:D.title,onBlur:e=>{let t=e.currentTarget;if(!t.value.trim()){t.value=D.title;return}xt(t.value).then(e=>{e||(t.value=D.title)})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=D.title,e.currentTarget.blur())},className:`min-w-0 max-w-sm flex-1 truncate rounded-lg border border-transparent bg-transparent px-2 py-1 text-sm font-semibold text-ink outline-none hover:border-line focus:border-primary-500 focus:bg-surface`,"aria-label":e(`work.tasks.rename`,{defaultValue:`Task title`})},`${D.id}:${D.title}`):(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsx)(`h1`,{className:`truncate text-sm font-semibold text-ink`,children:e(`work.title`,{defaultValue:`Work`})})}),D?.hostPath&&(0,G.jsxs)(`span`,{"data-testid":`work-host-path-chip`,title:D.hostPath,className:`hidden h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 font-mono text-[11px] text-ink-muted sm:inline-flex`,children:[(0,G.jsx)(le,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:D.hostPath})]}),D&&(0,G.jsxs)(`span`,{"data-testid":`work-compact-status`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface px-2 text-[11px] font-medium text-ink-muted xl:hidden`,"aria-label":e(`work.tasks.status`,{status:jt,defaultValue:`Status: {{status}}`}),title:e(`work.tasks.status`,{status:jt,defaultValue:`Status: {{status}}`}),children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-compact-status-indicator`,className:l(`h-1.5 w-1.5 rounded-full`,At.animated&&`animate-pulse`,D.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:At.color}}),(0,G.jsx)(`span`,{className:`hidden md:inline`,children:jt})]}),D&&(0,G.jsxs)(`div`,{className:`ms-auto inline-flex h-9 shrink-0 items-center rounded-xl border border-line bg-surface-subtle p-1 shadow-subtle xl:hidden`,role:`group`,"aria-label":e(`work.mobile.surface`,{defaultValue:`Task surface`}),children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>Le(`conversation`),"aria-label":e(`work.mobile.conversation`,{defaultValue:`Conversation`}),"aria-pressed":Ie===`conversation`,className:l(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,Ie===`conversation`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,G.jsx)(ue,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.conversation`,{defaultValue:`Conversation`})})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>Le(`workspace`),"aria-label":e(`work.mobile.workspace`,{defaultValue:`Workspace`}),"aria-pressed":Ie===`workspace`,className:l(`inline-flex h-7 items-center justify-center gap-1.5 rounded-lg px-2 text-[11px] font-medium transition-[background-color,color,box-shadow] sm:px-2.5`,Ie===`workspace`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,G.jsx)(te,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.workspace`,{defaultValue:`Workspace`})})]})]}),(0,G.jsxs)(`div`,{className:l(`ms-auto hidden min-w-0 items-center gap-2`,D?`xl:flex`:`sm:flex`),children:[D&&(0,G.jsxs)(`span`,{"data-testid":`work-status`,className:`inline-flex h-7 items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-status-indicator`,className:l(`h-1.5 w-1.5 rounded-full`,At.animated&&`animate-pulse`,D.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:At.color}}),jt]}),(0,G.jsxs)(`span`,{"data-testid":`work-runtime-status`,className:l(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-[11px] font-medium`,Q?`border-transparent bg-error-500 text-[#0D0D0C]`:`border-transparent bg-success-500 text-[#0D0D0C]`),title:Q?T?.reason||e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):T?.image?`${Tt} · ${T.image}`:Tt,children:[(0,G.jsx)(_,{className:`h-3.5 w-3.5`}),Q?e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):wt]}),D&&(0,G.jsxs)(`span`,{className:`hidden h-7 max-w-44 items-center gap-1.5 truncate rounded-full border border-line bg-surface px-2.5 text-[11px] font-medium text-ink-muted md:inline-flex`,children:[(0,G.jsx)(f,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsx)(`span`,{dir:`ltr`,className:`truncate`,children:D.model})]})]}),D&&(0,G.jsxs)(`div`,{ref:$e,className:`relative shrink-0`,children:[(0,G.jsx)(`button`,{ref:et,id:`work-task-actions-trigger`,type:`button`,"data-testid":`work-task-actions-button`,onClick:()=>Ze(e=>({taskId:D.id,open:e.taskId!==D.id||!e.open})),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),Ze({taskId:D.id,open:!0}))},className:`inline-flex h-9 w-9 items-center justify-center rounded-lg text-ink-muted transition-colors hover:bg-surface-subtle hover:text-ink`,"aria-label":e(`work.tasks.actions`,{defaultValue:`Task actions`}),"aria-haspopup":`menu`,"aria-expanded":Qe,"aria-controls":Qe?`work-task-actions-menu`:void 0,children:(0,G.jsx)(ne,{className:`h-4 w-4`})}),Qe&&(0,G.jsx)(`div`,{ref:tt,id:`work-task-actions-menu`,role:`menu`,"aria-labelledby":`work-task-actions-trigger`,onKeyDown:rt,className:`absolute end-0 top-10 z-40 min-w-44 rounded-xl border border-line bg-surface-overlay p-1.5 shadow-overlay`,children:(0,G.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`work-delete-task-button`,onClick:()=>{nt(!0),bt(D.id)},className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-start text-xs font-medium text-error-600 transition-colors hover:bg-error-500/10`,children:[(0,G.jsx)(A,{className:`h-3.5 w-3.5`}),e(`work.tasks.delete`,{defaultValue:`Delete task`})]})})]})]}),(Q||P)&&(0,G.jsxs)(`div`,{className:l(`flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs`,Q?`border-error-500/20 bg-error-500/10 text-error-700`:`border-amber-500/20 bg-amber-500/10 text-ink`),children:[(0,G.jsx)(C,{className:`h-4 w-4 shrink-0`}),(0,G.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1`,children:Q?T?.reason||e(`work.runtime.reason`,{defaultValue:`A Work runtime and an available Ollama or plugin model provider are required.`}):P}),P&&!Q&&(0,G.jsx)(`button`,{type:`button`,className:`rounded-md p-1 hover:bg-black/5`,onClick:K,"aria-label":e(`common.close`),children:`×`})]}),r?D?(0,G.jsx)(it,{userId:h,mobileSurface:Ie,conversation:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ue,{task:D,user:m,liveRun:ut,loading:M,loadingOlder:re,onLoadOlder:()=>ce(D.id)}),(0,G.jsx)(ke,{models:kt,selectorModels:je,modelKey:Dt,running:Et,loading:N,disabled:Q,remoteDisclosureDismissed:d.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:g,onModelChange:vt,onDismissRemoteDisclosure:Mt,onModelsRefresh:w,onSubmit:_t,onCancel:yt},D.id)]}),workspace:(0,G.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,G.jsx)(rn,{task:D,liveRun:ut,files:O,selectedFile:k,loadingFiles:ie,actionLoading:N,onLoadFiles:e=>V(D.id,e),onLoadFile:e=>H(D.id,e),onClearSelectedFile:Ee,onSaveFile:Ct,onStartPreview:t=>St(()=>Oe(D.id,t),e(`work.toasts.previewFailed`,{defaultValue:`Could not start the preview.`})),onStopPreview:()=>St(()=>Ae(D.id),e(`work.toasts.previewStopFailed`,{defaultValue:`Could not stop the preview.`})),onDirtyChange:Re,terminal:T?.terminal},D.id)})}):(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:M?(0,G.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`work.tasks.loading`,{defaultValue:`Loading task…`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(C,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-ink`,children:e(`work.tasks.notFound`,{defaultValue:`This Work task is unavailable`})}),(0,G.jsxs)(`button`,{type:`button`,onClick:gt,className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-primary-600 hover:text-primary-700`,children:[(0,G.jsx)(S,{className:`h-4 w-4 rtl:rotate-180`}),e(`work.tasks.back`,{defaultValue:`Start a new task`})]})]})}):(0,G.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-y-auto`,children:[(0,G.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:[(0,G.jsx)(`div`,{className:`absolute left-[12%] top-[18%] h-56 w-56 rounded-full bg-primary-500/[0.035] blur-3xl dark:bg-primary-400/[0.04]`}),(0,G.jsx)(`div`,{className:`absolute bottom-[16%] right-[10%] h-72 w-72 rounded-full bg-gray-900/[0.025] blur-3xl dark:bg-white/[0.025]`}),(0,G.jsx)(`div`,{className:`absolute left-1/2 top-0 h-16 w-px bg-gray-300/60 dark:bg-white/10`})]}),(0,G.jsxs)(`section`,{"data-testid":`work-landing`,className:`relative z-[1] mx-auto flex min-h-full w-full max-w-3xl flex-col items-center justify-center px-4 py-20 sm:px-8 sm:py-24`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-center gap-3`,children:[(0,G.jsx)(B,{size:`sm`,label:null,className:`h-9 w-9 shrink-0 p-0 text-ink`}),(0,G.jsx)(`h2`,{className:`max-w-3xl text-balance text-[clamp(1.75rem,3.5vw,2.35rem)] font-medium leading-tight tracking-[-0.02em] text-ink rtl:tracking-normal`,children:e(`work.landing.title`,{defaultValue:`Start a new Work task`})})]}),(0,G.jsx)(`p`,{className:`max-w-xl text-balance text-[15px] leading-relaxed text-ink-subtle`,children:e(`work.landing.description`,{defaultValue:`Give a local model a durable, isolated workspace. It can inspect files, run tools, and continue where it left off when you return.`})})]}),We.length>0&&(0,G.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,G.jsx)(`label`,{htmlFor:`work-policy`,className:`mb-1.5 block text-xs font-medium text-ink-muted`,children:e(`work.policy.label`,{defaultValue:`Runtime policy`})}),(0,G.jsxs)(`select`,{id:`work-policy`,"data-testid":`work-policy`,value:Ge,onChange:e=>Ke(e.target.value),className:`w-full rounded-xl border border-line bg-surface px-3 py-2 text-[13px] text-ink outline-none transition-colors focus:border-line-strong focus-visible:ring-2 focus-visible:ring-primary-500/30`,children:[(0,G.jsx)(`option`,{value:``,children:e(`work.policy.default`,{defaultValue:`Default (global limits)`})}),We.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),Ve&&(0,G.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,G.jsx)(`label`,{htmlFor:`work-host-path`,className:`mb-1.5 block text-xs font-medium text-ink-muted`,children:e(`work.hostWorkspace.label`,{defaultValue:`Workspace folder (optional)`})}),(0,G.jsx)(`input`,{id:`work-host-path`,"data-testid":`work-host-path`,value:ze,onChange:e=>Be(e.target.value),spellCheck:!1,placeholder:He[0]?`${He[0]}/my-project`:`/path/to/folder`,className:`w-full rounded-xl border border-line bg-surface px-3 py-2 font-mono text-[13px] text-ink outline-none transition-colors placeholder:text-ink-subtle focus:border-line-strong focus-visible:ring-2 focus-visible:ring-primary-500/30`}),(0,G.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:ze.trim()?e(`work.hostWorkspace.warning`,{defaultValue:`The task can read and write this folder directly. Leave blank to use an isolated workspace instead.`}):e(`work.hostWorkspace.hint`,{defaultValue:`Leave blank for an isolated workspace, or point the task at a folder on this machine.`})})]}),(0,G.jsx)(ke,{variant:`landing`,models:q,selectorModels:je,modelKey:at?.key||``,running:!1,loading:N,disabled:Q,remoteDisclosureDismissed:d.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:g,onModelChange:vt,onDismissRemoteDisclosure:Mt,onModelsRefresh:w,onSubmit:_t,onCancel:yt}),(0,G.jsxs)(`div`,{"data-testid":`work-workspace-note`,role:`note`,className:`mt-4 flex max-w-2xl flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center text-[10px] leading-relaxed text-ink-subtle`,children:[(0,G.jsx)(_,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:e(`work.composer.hint`,{defaultValue:`Each task keeps its own files and history. Review model output before using it.`})})]})]})]})]})})}export{cn as default};