libre-webui 0.24.1 → 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 (543) hide show
  1. package/README.md +36 -15
  2. package/backend/dist/index.d.ts.map +1 -1
  3. package/backend/dist/index.js +35 -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 +12 -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/postgresPersonalAutomationsMigration.d.ts +8 -0
  51. package/backend/dist/persistence/postgresPersonalAutomationsMigration.d.ts.map +1 -0
  52. package/backend/dist/persistence/postgresPersonalAutomationsMigration.js +98 -0
  53. package/backend/dist/persistence/postgresPersonalAutomationsMigration.js.map +1 -0
  54. package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
  55. package/backend/dist/persistence/postgresResourceRepositories.js +1972 -63
  56. package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
  57. package/backend/dist/persistence/postgresSkillFilesMigration.d.ts +9 -0
  58. package/backend/dist/persistence/postgresSkillFilesMigration.d.ts.map +1 -0
  59. package/backend/dist/persistence/postgresSkillFilesMigration.js +50 -0
  60. package/backend/dist/persistence/postgresSkillFilesMigration.js.map +1 -0
  61. package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts +10 -0
  62. package/backend/dist/persistence/postgresTeamCollaborationMigration.d.ts.map +1 -0
  63. package/backend/dist/persistence/postgresTeamCollaborationMigration.js +161 -0
  64. package/backend/dist/persistence/postgresTeamCollaborationMigration.js.map +1 -0
  65. package/backend/dist/persistence/resourceTypes.d.ts +622 -3
  66. package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
  67. package/backend/dist/persistence/resourceTypes.js.map +1 -1
  68. package/backend/dist/persistence/sqliteExtensionRepositories.d.ts.map +1 -1
  69. package/backend/dist/persistence/sqliteExtensionRepositories.js +26 -4
  70. package/backend/dist/persistence/sqliteExtensionRepositories.js.map +1 -1
  71. package/backend/dist/persistence/sqliteMigrations.d.ts +10 -0
  72. package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
  73. package/backend/dist/persistence/sqliteMigrations.js +1396 -48
  74. package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
  75. package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
  76. package/backend/dist/persistence/sqliteResourceRepositories.js +1680 -58
  77. package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
  78. package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
  79. package/backend/dist/persistence/sqliteToPostgresMigration.js +297 -2
  80. package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
  81. package/backend/dist/platform/jobs/domainJobContracts.d.ts +11 -0
  82. package/backend/dist/platform/jobs/domainJobContracts.d.ts.map +1 -1
  83. package/backend/dist/platform/jobs/domainJobContracts.js +11 -0
  84. package/backend/dist/platform/jobs/domainJobContracts.js.map +1 -1
  85. package/backend/dist/platform/jobs/domainJobHandlers.d.ts.map +1 -1
  86. package/backend/dist/platform/jobs/domainJobHandlers.js +409 -2
  87. package/backend/dist/platform/jobs/domainJobHandlers.js.map +1 -1
  88. package/backend/dist/platform/jobs/embeddedDurableJobWorker.d.ts.map +1 -1
  89. package/backend/dist/platform/jobs/embeddedDurableJobWorker.js +4 -2
  90. package/backend/dist/platform/jobs/embeddedDurableJobWorker.js.map +1 -1
  91. package/backend/dist/platform/jobs/postgresDurableJobWorker.d.ts.map +1 -1
  92. package/backend/dist/platform/jobs/postgresDurableJobWorker.js +4 -2
  93. package/backend/dist/platform/jobs/postgresDurableJobWorker.js.map +1 -1
  94. package/backend/dist/platform/storage/pgVectorStore.d.ts +2 -1
  95. package/backend/dist/platform/storage/pgVectorStore.d.ts.map +1 -1
  96. package/backend/dist/platform/storage/pgVectorStore.js +51 -0
  97. package/backend/dist/platform/storage/pgVectorStore.js.map +1 -1
  98. package/backend/dist/platform/storage/platformDomainRepositories.d.ts +8 -2
  99. package/backend/dist/platform/storage/platformDomainRepositories.d.ts.map +1 -1
  100. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.d.ts.map +1 -1
  101. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js +25 -4
  102. package/backend/dist/platform/storage/postgresPlatformDomainRepositories.js.map +1 -1
  103. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts +2 -1
  104. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.d.ts.map +1 -1
  105. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js +35 -0
  106. package/backend/dist/platform/storage/sqliteEncryptedVectorStore.js.map +1 -1
  107. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.d.ts.map +1 -1
  108. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js +26 -3
  109. package/backend/dist/platform/storage/sqlitePlatformDomainRepositories.js.map +1 -1
  110. package/backend/dist/platform/storage/vectorStore.d.ts +14 -0
  111. package/backend/dist/platform/storage/vectorStore.d.ts.map +1 -1
  112. package/backend/dist/platform/storage/vectorStore.js.map +1 -1
  113. package/backend/dist/routes/access.d.ts.map +1 -1
  114. package/backend/dist/routes/access.js +84 -3
  115. package/backend/dist/routes/access.js.map +1 -1
  116. package/backend/dist/routes/automations.d.ts +3 -0
  117. package/backend/dist/routes/automations.d.ts.map +1 -0
  118. package/backend/dist/routes/automations.js +232 -0
  119. package/backend/dist/routes/automations.js.map +1 -0
  120. package/backend/dist/routes/calendar.d.ts +3 -0
  121. package/backend/dist/routes/calendar.d.ts.map +1 -0
  122. package/backend/dist/routes/calendar.js +309 -0
  123. package/backend/dist/routes/calendar.js.map +1 -0
  124. package/backend/dist/routes/channels.d.ts +3 -0
  125. package/backend/dist/routes/channels.d.ts.map +1 -0
  126. package/backend/dist/routes/channels.js +447 -0
  127. package/backend/dist/routes/channels.js.map +1 -0
  128. package/backend/dist/routes/chat.d.ts.map +1 -1
  129. package/backend/dist/routes/chat.js +237 -10
  130. package/backend/dist/routes/chat.js.map +1 -1
  131. package/backend/dist/routes/costs.d.ts +3 -0
  132. package/backend/dist/routes/costs.d.ts.map +1 -0
  133. package/backend/dist/routes/costs.js +191 -0
  134. package/backend/dist/routes/costs.js.map +1 -0
  135. package/backend/dist/routes/documents.d.ts.map +1 -1
  136. package/backend/dist/routes/documents.js +64 -21
  137. package/backend/dist/routes/documents.js.map +1 -1
  138. package/backend/dist/routes/evaluations.d.ts +3 -0
  139. package/backend/dist/routes/evaluations.d.ts.map +1 -0
  140. package/backend/dist/routes/evaluations.js +352 -0
  141. package/backend/dist/routes/evaluations.js.map +1 -0
  142. package/backend/dist/routes/imageGen.d.ts.map +1 -1
  143. package/backend/dist/routes/imageGen.js +2 -1
  144. package/backend/dist/routes/imageGen.js.map +1 -1
  145. package/backend/dist/routes/media.d.ts.map +1 -1
  146. package/backend/dist/routes/media.js +228 -7
  147. package/backend/dist/routes/media.js.map +1 -1
  148. package/backend/dist/routes/notes.d.ts.map +1 -1
  149. package/backend/dist/routes/notes.js +149 -36
  150. package/backend/dist/routes/notes.js.map +1 -1
  151. package/backend/dist/routes/notifications.d.ts +3 -0
  152. package/backend/dist/routes/notifications.d.ts.map +1 -0
  153. package/backend/dist/routes/notifications.js +213 -0
  154. package/backend/dist/routes/notifications.js.map +1 -0
  155. package/backend/dist/routes/ollama.d.ts.map +1 -1
  156. package/backend/dist/routes/ollama.js +4 -1
  157. package/backend/dist/routes/ollama.js.map +1 -1
  158. package/backend/dist/routes/openaiCompat.d.ts +3 -0
  159. package/backend/dist/routes/openaiCompat.d.ts.map +1 -0
  160. package/backend/dist/routes/openaiCompat.js +314 -0
  161. package/backend/dist/routes/openaiCompat.js.map +1 -0
  162. package/backend/dist/routes/personas.js +1 -1
  163. package/backend/dist/routes/personas.js.map +1 -1
  164. package/backend/dist/routes/prompts.d.ts +3 -0
  165. package/backend/dist/routes/prompts.d.ts.map +1 -0
  166. package/backend/dist/routes/prompts.js +173 -0
  167. package/backend/dist/routes/prompts.js.map +1 -0
  168. package/backend/dist/routes/search.d.ts.map +1 -1
  169. package/backend/dist/routes/search.js +34 -4
  170. package/backend/dist/routes/search.js.map +1 -1
  171. package/backend/dist/routes/skills.d.ts +3 -0
  172. package/backend/dist/routes/skills.d.ts.map +1 -0
  173. package/backend/dist/routes/skills.js +246 -0
  174. package/backend/dist/routes/skills.js.map +1 -0
  175. package/backend/dist/routes/stt.d.ts.map +1 -1
  176. package/backend/dist/routes/stt.js +2 -1
  177. package/backend/dist/routes/stt.js.map +1 -1
  178. package/backend/dist/routes/tools.d.ts +3 -0
  179. package/backend/dist/routes/tools.d.ts.map +1 -0
  180. package/backend/dist/routes/tools.js +359 -0
  181. package/backend/dist/routes/tools.js.map +1 -0
  182. package/backend/dist/routes/tts.d.ts.map +1 -1
  183. package/backend/dist/routes/tts.js +63 -8
  184. package/backend/dist/routes/tts.js.map +1 -1
  185. package/backend/dist/routes/voiceAccess.d.ts +3 -0
  186. package/backend/dist/routes/voiceAccess.d.ts.map +1 -0
  187. package/backend/dist/routes/voiceAccess.js +102 -0
  188. package/backend/dist/routes/voiceAccess.js.map +1 -0
  189. package/backend/dist/services/apiTokenService.d.ts +2 -2
  190. package/backend/dist/services/apiTokenService.d.ts.map +1 -1
  191. package/backend/dist/services/apiTokenService.js +7 -0
  192. package/backend/dist/services/apiTokenService.js.map +1 -1
  193. package/backend/dist/services/authorizationService.d.ts +8 -4
  194. package/backend/dist/services/authorizationService.d.ts.map +1 -1
  195. package/backend/dist/services/authorizationService.js +31 -1
  196. package/backend/dist/services/authorizationService.js.map +1 -1
  197. package/backend/dist/services/automationSchedulerService.d.ts +28 -0
  198. package/backend/dist/services/automationSchedulerService.d.ts.map +1 -0
  199. package/backend/dist/services/automationSchedulerService.js +221 -0
  200. package/backend/dist/services/automationSchedulerService.js.map +1 -0
  201. package/backend/dist/services/automationService.d.ts +56 -0
  202. package/backend/dist/services/automationService.d.ts.map +1 -0
  203. package/backend/dist/services/automationService.js +247 -0
  204. package/backend/dist/services/automationService.js.map +1 -0
  205. package/backend/dist/services/builtinToolsService.d.ts +20 -0
  206. package/backend/dist/services/builtinToolsService.d.ts.map +1 -0
  207. package/backend/dist/services/builtinToolsService.js +661 -0
  208. package/backend/dist/services/builtinToolsService.js.map +1 -0
  209. package/backend/dist/services/calendarService.d.ts +74 -0
  210. package/backend/dist/services/calendarService.d.ts.map +1 -0
  211. package/backend/dist/services/calendarService.js +339 -0
  212. package/backend/dist/services/calendarService.js.map +1 -0
  213. package/backend/dist/services/channelService.d.ts +195 -0
  214. package/backend/dist/services/channelService.d.ts.map +1 -0
  215. package/backend/dist/services/channelService.js +1057 -0
  216. package/backend/dist/services/channelService.js.map +1 -0
  217. package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
  218. package/backend/dist/services/chatGenerationService.js +7 -1
  219. package/backend/dist/services/chatGenerationService.js.map +1 -1
  220. package/backend/dist/services/chatRequestService.d.ts.map +1 -1
  221. package/backend/dist/services/chatRequestService.js +29 -1
  222. package/backend/dist/services/chatRequestService.js.map +1 -1
  223. package/backend/dist/services/chatService.d.ts +62 -1
  224. package/backend/dist/services/chatService.d.ts.map +1 -1
  225. package/backend/dist/services/chatService.js +242 -1
  226. package/backend/dist/services/chatService.js.map +1 -1
  227. package/backend/dist/services/chatToolRuntimeService.d.ts +55 -0
  228. package/backend/dist/services/chatToolRuntimeService.d.ts.map +1 -0
  229. package/backend/dist/services/chatToolRuntimeService.js +389 -0
  230. package/backend/dist/services/chatToolRuntimeService.js.map +1 -0
  231. package/backend/dist/services/costGovernanceService.d.ts +102 -0
  232. package/backend/dist/services/costGovernanceService.d.ts.map +1 -0
  233. package/backend/dist/services/costGovernanceService.js +463 -0
  234. package/backend/dist/services/costGovernanceService.js.map +1 -0
  235. package/backend/dist/services/dataArchiveService.d.ts +6 -0
  236. package/backend/dist/services/dataArchiveService.d.ts.map +1 -1
  237. package/backend/dist/services/dataArchiveService.js +23 -4
  238. package/backend/dist/services/dataArchiveService.js.map +1 -1
  239. package/backend/dist/services/documentService.d.ts +58 -1
  240. package/backend/dist/services/documentService.d.ts.map +1 -1
  241. package/backend/dist/services/documentService.js +289 -84
  242. package/backend/dist/services/documentService.js.map +1 -1
  243. package/backend/dist/services/durableChatGenerationService.d.ts +9 -0
  244. package/backend/dist/services/durableChatGenerationService.d.ts.map +1 -1
  245. package/backend/dist/services/durableChatGenerationService.js +160 -13
  246. package/backend/dist/services/durableChatGenerationService.js.map +1 -1
  247. package/backend/dist/services/evaluationService.d.ts +111 -0
  248. package/backend/dist/services/evaluationService.d.ts.map +1 -0
  249. package/backend/dist/services/evaluationService.js +403 -0
  250. package/backend/dist/services/evaluationService.js.map +1 -0
  251. package/backend/dist/services/galleryService.d.ts +6 -0
  252. package/backend/dist/services/galleryService.d.ts.map +1 -1
  253. package/backend/dist/services/galleryService.js +26 -0
  254. package/backend/dist/services/galleryService.js.map +1 -1
  255. package/backend/dist/services/mcpClientService.d.ts +29 -0
  256. package/backend/dist/services/mcpClientService.d.ts.map +1 -0
  257. package/backend/dist/services/mcpClientService.js +189 -0
  258. package/backend/dist/services/mcpClientService.js.map +1 -0
  259. package/backend/dist/services/noteService.d.ts +71 -0
  260. package/backend/dist/services/noteService.d.ts.map +1 -0
  261. package/backend/dist/services/noteService.js +397 -0
  262. package/backend/dist/services/noteService.js.map +1 -0
  263. package/backend/dist/services/notificationService.d.ts +55 -0
  264. package/backend/dist/services/notificationService.d.ts.map +1 -0
  265. package/backend/dist/services/notificationService.js +308 -0
  266. package/backend/dist/services/notificationService.js.map +1 -0
  267. package/backend/dist/services/ollamaService.d.ts.map +1 -1
  268. package/backend/dist/services/ollamaService.js +3 -1
  269. package/backend/dist/services/ollamaService.js.map +1 -1
  270. package/backend/dist/services/openApiToolService.d.ts +38 -0
  271. package/backend/dist/services/openApiToolService.d.ts.map +1 -0
  272. package/backend/dist/services/openApiToolService.js +254 -0
  273. package/backend/dist/services/openApiToolService.js.map +1 -0
  274. package/backend/dist/services/personaService.d.ts +18 -2
  275. package/backend/dist/services/personaService.d.ts.map +1 -1
  276. package/backend/dist/services/personaService.js +113 -4
  277. package/backend/dist/services/personaService.js.map +1 -1
  278. package/backend/dist/services/pluginImageGenerationService.d.ts +19 -0
  279. package/backend/dist/services/pluginImageGenerationService.d.ts.map +1 -1
  280. package/backend/dist/services/pluginImageGenerationService.js +121 -0
  281. package/backend/dist/services/pluginImageGenerationService.js.map +1 -1
  282. package/backend/dist/services/pluginService.d.ts +7 -0
  283. package/backend/dist/services/pluginService.d.ts.map +1 -1
  284. package/backend/dist/services/pluginService.js +8 -2
  285. package/backend/dist/services/pluginService.js.map +1 -1
  286. package/backend/dist/services/promptService.d.ts +74 -0
  287. package/backend/dist/services/promptService.d.ts.map +1 -0
  288. package/backend/dist/services/promptService.js +513 -0
  289. package/backend/dist/services/promptService.js.map +1 -0
  290. package/backend/dist/services/resourceGrantService.d.ts.map +1 -1
  291. package/backend/dist/services/resourceGrantService.js +62 -17
  292. package/backend/dist/services/resourceGrantService.js.map +1 -1
  293. package/backend/dist/services/searchService.d.ts +29 -0
  294. package/backend/dist/services/searchService.d.ts.map +1 -0
  295. package/backend/dist/services/searchService.js +0 -0
  296. package/backend/dist/services/searchService.js.map +1 -0
  297. package/backend/dist/services/securityAuditService.d.ts.map +1 -1
  298. package/backend/dist/services/securityAuditService.js +2 -1
  299. package/backend/dist/services/securityAuditService.js.map +1 -1
  300. package/backend/dist/services/sharedResourceAccess.d.ts +25 -0
  301. package/backend/dist/services/sharedResourceAccess.d.ts.map +1 -0
  302. package/backend/dist/services/sharedResourceAccess.js +59 -0
  303. package/backend/dist/services/sharedResourceAccess.js.map +1 -0
  304. package/backend/dist/services/skillService.d.ts +137 -0
  305. package/backend/dist/services/skillService.d.ts.map +1 -0
  306. package/backend/dist/services/skillService.js +852 -0
  307. package/backend/dist/services/skillService.js.map +1 -0
  308. package/backend/dist/services/titleGenerationService.d.ts.map +1 -1
  309. package/backend/dist/services/titleGenerationService.js +5 -1
  310. package/backend/dist/services/titleGenerationService.js.map +1 -1
  311. package/backend/dist/services/toolAccessService.d.ts +9 -0
  312. package/backend/dist/services/toolAccessService.d.ts.map +1 -0
  313. package/backend/dist/services/toolAccessService.js +60 -0
  314. package/backend/dist/services/toolAccessService.js.map +1 -0
  315. package/backend/dist/services/toolApprovalService.d.ts +34 -0
  316. package/backend/dist/services/toolApprovalService.d.ts.map +1 -0
  317. package/backend/dist/services/toolApprovalService.js +188 -0
  318. package/backend/dist/services/toolApprovalService.js.map +1 -0
  319. package/backend/dist/services/toolGatewayService.d.ts +53 -0
  320. package/backend/dist/services/toolGatewayService.d.ts.map +1 -0
  321. package/backend/dist/services/toolGatewayService.js +249 -0
  322. package/backend/dist/services/toolGatewayService.js.map +1 -0
  323. package/backend/dist/services/toolServerService.d.ts +57 -0
  324. package/backend/dist/services/toolServerService.d.ts.map +1 -0
  325. package/backend/dist/services/toolServerService.js +521 -0
  326. package/backend/dist/services/toolServerService.js.map +1 -0
  327. package/backend/dist/services/voiceAccessService.d.ts +10 -0
  328. package/backend/dist/services/voiceAccessService.d.ts.map +1 -0
  329. package/backend/dist/services/voiceAccessService.js +74 -0
  330. package/backend/dist/services/voiceAccessService.js.map +1 -0
  331. package/backend/dist/services/voiceProfileService.d.ts +20 -0
  332. package/backend/dist/services/voiceProfileService.d.ts.map +1 -1
  333. package/backend/dist/services/voiceProfileService.js +60 -0
  334. package/backend/dist/services/voiceProfileService.js.map +1 -1
  335. package/backend/dist/services/webSearchPlanService.d.ts +18 -0
  336. package/backend/dist/services/webSearchPlanService.d.ts.map +1 -0
  337. package/backend/dist/services/webSearchPlanService.js +160 -0
  338. package/backend/dist/services/webSearchPlanService.js.map +1 -0
  339. package/backend/dist/services/webSearchService.d.ts +9 -3
  340. package/backend/dist/services/webSearchService.d.ts.map +1 -1
  341. package/backend/dist/services/webSearchService.js +8 -2
  342. package/backend/dist/services/webSearchService.js.map +1 -1
  343. package/backend/dist/storage.d.ts +34 -1
  344. package/backend/dist/storage.d.ts.map +1 -1
  345. package/backend/dist/storage.js +164 -1
  346. package/backend/dist/storage.js.map +1 -1
  347. package/backend/dist/storageMappers.d.ts +2 -2
  348. package/backend/dist/storageMappers.d.ts.map +1 -1
  349. package/backend/dist/storageMappers.js.map +1 -1
  350. package/backend/dist/types/index.d.ts +269 -2
  351. package/backend/dist/types/index.d.ts.map +1 -1
  352. package/backend/dist/types/index.js.map +1 -1
  353. package/backend/dist/types/tools.d.ts +137 -0
  354. package/backend/dist/types/tools.d.ts.map +1 -0
  355. package/backend/dist/types/tools.js +25 -0
  356. package/backend/dist/types/tools.js.map +1 -0
  357. package/backend/dist/utils/automationSchedule.d.ts +26 -0
  358. package/backend/dist/utils/automationSchedule.d.ts.map +1 -0
  359. package/backend/dist/utils/automationSchedule.js +231 -0
  360. package/backend/dist/utils/automationSchedule.js.map +1 -0
  361. package/backend/dist/utils/chatDocumentContext.d.ts +26 -1
  362. package/backend/dist/utils/chatDocumentContext.d.ts.map +1 -1
  363. package/backend/dist/utils/chatDocumentContext.js +87 -18
  364. package/backend/dist/utils/chatDocumentContext.js.map +1 -1
  365. package/backend/dist/utils/documentExtraction.d.ts +69 -0
  366. package/backend/dist/utils/documentExtraction.d.ts.map +1 -0
  367. package/backend/dist/utils/documentExtraction.js +545 -0
  368. package/backend/dist/utils/documentExtraction.js.map +1 -0
  369. package/backend/dist/utils/hybridRetrieval.d.ts +34 -0
  370. package/backend/dist/utils/hybridRetrieval.d.ts.map +1 -0
  371. package/backend/dist/utils/hybridRetrieval.js +119 -0
  372. package/backend/dist/utils/hybridRetrieval.js.map +1 -0
  373. package/backend/dist/utils/icsCalendar.d.ts +27 -0
  374. package/backend/dist/utils/icsCalendar.d.ts.map +1 -0
  375. package/backend/dist/utils/icsCalendar.js +313 -0
  376. package/backend/dist/utils/icsCalendar.js.map +1 -0
  377. package/backend/dist/utils/imageEditUpload.d.ts +29 -0
  378. package/backend/dist/utils/imageEditUpload.d.ts.map +1 -0
  379. package/backend/dist/utils/imageEditUpload.js +82 -0
  380. package/backend/dist/utils/imageEditUpload.js.map +1 -0
  381. package/backend/dist/utils/logRedaction.d.ts +2 -0
  382. package/backend/dist/utils/logRedaction.d.ts.map +1 -0
  383. package/backend/dist/utils/logRedaction.js +66 -0
  384. package/backend/dist/utils/logRedaction.js.map +1 -0
  385. package/backend/dist/utils/logger.d.ts +3 -0
  386. package/backend/dist/utils/logger.d.ts.map +1 -1
  387. package/backend/dist/utils/logger.js +63 -20
  388. package/backend/dist/utils/logger.js.map +1 -1
  389. package/backend/dist/utils/pluginChatAdapter.d.ts +5 -1
  390. package/backend/dist/utils/pluginChatAdapter.d.ts.map +1 -1
  391. package/backend/dist/utils/pluginChatAdapter.js +83 -0
  392. package/backend/dist/utils/pluginChatAdapter.js.map +1 -1
  393. package/backend/dist/utils/pluginDefinitionTrust.js +1 -1
  394. package/backend/dist/utils/resourceLimits.d.ts +68 -2
  395. package/backend/dist/utils/resourceLimits.d.ts.map +1 -1
  396. package/backend/dist/utils/resourceLimits.js +66 -0
  397. package/backend/dist/utils/resourceLimits.js.map +1 -1
  398. package/backend/dist/utils/toolEgress.d.ts +22 -0
  399. package/backend/dist/utils/toolEgress.d.ts.map +1 -0
  400. package/backend/dist/utils/toolEgress.js +157 -0
  401. package/backend/dist/utils/toolEgress.js.map +1 -0
  402. package/backend/dist/utils/websocketMessages.d.ts +6 -0
  403. package/backend/dist/utils/websocketMessages.d.ts.map +1 -1
  404. package/backend/dist/utils/websocketMessages.js +8 -0
  405. package/backend/dist/utils/websocketMessages.js.map +1 -1
  406. package/backend/dist/utils/zipArchive.d.ts +32 -0
  407. package/backend/dist/utils/zipArchive.d.ts.map +1 -0
  408. package/backend/dist/utils/zipArchive.js +171 -0
  409. package/backend/dist/utils/zipArchive.js.map +1 -0
  410. package/backend/dist/websocketServer.d.ts.map +1 -1
  411. package/backend/dist/websocketServer.js +150 -37
  412. package/backend/dist/websocketServer.js.map +1 -1
  413. package/backend/package.json +1 -1
  414. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  415. package/frontend/dist/assets/index-BPsH9FII.js +80 -0
  416. package/frontend/dist/assets/index-BtXF0Oxa.css +1 -0
  417. package/frontend/dist/index.html +18 -18
  418. package/frontend/dist/js/{ArtifactContainer-B-hs0F5K.js → ArtifactContainer-CIoFoMv8.js} +1 -1
  419. package/frontend/dist/js/{ArtifactDemoPage-QFtJw-u4.js → ArtifactDemoPage-D0JEIAbZ.js} +1 -1
  420. package/frontend/dist/js/{ArtifactSandboxFrame-S9g_q47-.js → ArtifactSandboxFrame-REazyIrx.js} +2 -2
  421. package/frontend/dist/js/ArtifactSlideOutPanel-A-i94ghF.js +1 -0
  422. package/frontend/dist/js/AutomationsPage-Dow_lbIf.js +1 -0
  423. package/frontend/dist/js/{Button-BPf_pOxH.js → Button-C0r3J9G_.js} +1 -1
  424. package/frontend/dist/js/CalendarPage-DLjasZOd.js +1 -0
  425. package/frontend/dist/js/ChannelsPage-C8hvTD7J.js +1 -0
  426. package/frontend/dist/js/ChatPage-BAgBHUES.js +16 -0
  427. package/frontend/dist/js/EvaluationsPage-Bm8FRoeX.js +2 -0
  428. package/frontend/dist/js/FirstTimeSetup-BxJapNul.js +1 -0
  429. package/frontend/dist/js/GalleryPage-DHz9DkK7.js +1 -0
  430. package/frontend/dist/js/HomePage-BqNy-FWX.js +1 -0
  431. package/frontend/dist/js/LibreClawPage-BDzDILjY.js +1 -0
  432. package/frontend/dist/js/{ModelManagerModals-DBmm_slu.js → ModelManagerModals-DX9eT5r2.js} +1 -1
  433. package/frontend/dist/js/ModelSelector-ol8mK2ja.js +1 -0
  434. package/frontend/dist/js/NotesPage-DzHEx2O4.js +3 -0
  435. package/frontend/dist/js/{OptimizedSyntaxHighlighter-Dz7D1LPB.js → OptimizedSyntaxHighlighter-CZNPwN0i.js} +1 -1
  436. package/frontend/dist/js/PersonasPage-M_WKH2a9.js +13 -0
  437. package/frontend/dist/js/PluginUsagePage-Ctoka6JZ.js +1 -0
  438. package/frontend/dist/js/RichMessageContent-BqgafH4p.js +3 -0
  439. package/frontend/dist/js/SettingsModal-R9EDadAV.js +19 -0
  440. package/frontend/dist/js/{SettingsToggle-woG_WebF.js → SettingsToggle-BIVyfGjl.js} +1 -1
  441. package/frontend/dist/js/{SystemPage-Xr7XJv8c.js → SystemPage-aOkrSuY7.js} +1 -1
  442. package/frontend/dist/js/UserManagementPage-BOuaX3ay.js +1 -0
  443. package/frontend/dist/js/WorkPage-DxZISerQ.js +6 -0
  444. package/frontend/dist/js/api-6bSMtSNh.js +14 -0
  445. package/frontend/dist/js/{appStore-DXlmTjIC.js → appStore-CdObhQBb.js} +2 -2
  446. package/frontend/dist/js/ar-DT_VLBO3.js +2 -0
  447. package/frontend/dist/js/{authStore-B97lJ5Ee.js → authStore-DbqqrfZv.js} +3 -3
  448. package/frontend/dist/js/{babel-D24oDI9y.js → babel-DSqqk5kt.js} +1 -1
  449. package/frontend/dist/js/bn-BrvEqhGA.js +2 -0
  450. package/frontend/dist/js/calendarDates-Co3o_05Y.js +1 -0
  451. package/frontend/dist/js/chatStore-DbZPJNsu.js +3 -0
  452. package/frontend/dist/js/{config-CmEh9o8U.js → config-8KdgjtEx.js} +1 -1
  453. package/frontend/dist/js/cs-BthnM_YI.js +2 -0
  454. package/frontend/dist/js/da-DCth-6_j.js +2 -0
  455. package/frontend/dist/js/de-BBWt0gJ_.js +2 -0
  456. package/frontend/dist/js/es-DuslOPqM.js +2 -0
  457. package/frontend/dist/js/{estree-CZO8RS52.js → estree-BU5-LV_1.js} +7 -7
  458. package/frontend/dist/js/evaluationsApi-CwZJsgeG.js +1 -0
  459. package/frontend/dist/js/fr-DZAeg46S.js +2 -0
  460. package/frontend/dist/js/hi-ijDSiY77.js +2 -0
  461. package/frontend/dist/js/{html-C31pxhBG.js → html-DeoAy2bo.js} +10 -10
  462. package/frontend/dist/js/id-BS6qS0oq.js +2 -0
  463. package/frontend/dist/js/is-CO2PMDte.js +2 -0
  464. package/frontend/dist/js/it-ChhxT4hs.js +2 -0
  465. package/frontend/dist/js/ja-cyeqUeJN.js +2 -0
  466. package/frontend/dist/js/ko-CfqHTLXj.js +2 -0
  467. package/frontend/dist/js/{markdown-C1CEqXpL.js → markdown-DOLsYkBY.js} +6 -6
  468. package/frontend/dist/js/markdown-core-BK7WVOb7.js +32 -0
  469. package/frontend/dist/js/{markdown-math-DK846gXU.js → markdown-math-e1ByS3KY.js} +5 -5
  470. package/frontend/dist/js/{messageCodeStyles-BqQ6kOSU.js → messageCodeStyles-DhVgizF-.js} +2 -2
  471. package/frontend/dist/js/ms-DZ5pACe1.js +2 -0
  472. package/frontend/dist/js/nl-BsRsnOVp.js +2 -0
  473. package/frontend/dist/js/pl-DXSTAW4M.js +2 -0
  474. package/frontend/dist/js/{postcss-Bx9CTcIc.js → postcss-Bg15EcFE.js} +1 -1
  475. package/frontend/dist/js/pt-DmDx0JxB.js +2 -0
  476. package/frontend/dist/js/{react-vendor-C5yShNlM.js → react-vendor-BG_HPV6X.js} +1 -1
  477. package/frontend/dist/js/router-vendor-CbexJIsv.js +1 -0
  478. package/frontend/dist/js/ru-d2g8EWfY.js +2 -0
  479. package/frontend/dist/js/{standalone-Dz0pkxn0.js → standalone-BO5pzI8_.js} +5 -5
  480. package/frontend/dist/js/sv-CIhYUTVQ.js +2 -0
  481. package/frontend/dist/js/{syntax-highlight-3EEX6CGL.js → syntax-highlight-DcR9Vhb7.js} +3 -3
  482. package/frontend/dist/js/th-B3wSxanB.js +2 -0
  483. package/frontend/dist/js/tr-R4UGgPOY.js +2 -0
  484. package/frontend/dist/js/{typescript-DeXPhp90.js → typescript-6GJ8APmn.js} +2 -2
  485. package/frontend/dist/js/ui-CV0LYmkM.js +2 -0
  486. package/frontend/dist/js/ui-vendor-CWjIBW-z.js +177 -0
  487. package/frontend/dist/js/uk-BzUF4Vkt.js +2 -0
  488. package/frontend/dist/js/{useTranslation-Bho4HCyg.js → useTranslation-5b5UhAc9.js} +1 -1
  489. package/frontend/dist/js/{utils-D9W1Lnkn.js → utils-BGrdX9ie.js} +1 -1
  490. package/frontend/dist/js/{utils-vendor-DWh39_3x.js → utils-vendor-9bQ62WeD.js} +1 -1
  491. package/frontend/dist/js/vi-CKc6Fg4h.js +2 -0
  492. package/frontend/dist/js/{workApi-C4QtuhcE.js → workApi-BruWTlHM.js} +2 -2
  493. package/frontend/dist/js/{yaml-DioTxVLA.js → yaml-DUeWcOOH.js} +5 -5
  494. package/frontend/dist/js/zh-CXL-kDe8.js +2 -0
  495. package/package.json +2 -2
  496. package/plugins/openai.json +52 -9
  497. package/frontend/dist/assets/index-CDQ12KBq.js +0 -34
  498. package/frontend/dist/assets/index-DkFWzmFD.css +0 -1
  499. package/frontend/dist/js/ArtifactSlideOutPanel-D0UOo8RW.js +0 -1
  500. package/frontend/dist/js/ChatPage-fdd8500b.js +0 -23
  501. package/frontend/dist/js/FirstTimeSetup-BTjafGOq.js +0 -1
  502. package/frontend/dist/js/GalleryPage-hR9AJ6b-.js +0 -1
  503. package/frontend/dist/js/HomePage-JvTzq-Pp.js +0 -1
  504. package/frontend/dist/js/LibreClawPage-CLJvtXft.js +0 -1
  505. package/frontend/dist/js/ModelSelector-A-viVFEc.js +0 -1
  506. package/frontend/dist/js/ModelsPage-C4Rm-TZF.js +0 -2
  507. package/frontend/dist/js/NotesPage-C7bPU_KF.js +0 -1
  508. package/frontend/dist/js/PersonasPage-DpvxbFzv.js +0 -13
  509. package/frontend/dist/js/PluginUsagePage-laF-M2X9.js +0 -1
  510. package/frontend/dist/js/RichMessageContent-D0mK9vRA.js +0 -3
  511. package/frontend/dist/js/SettingsModal-DNEQ5sTt.js +0 -1
  512. package/frontend/dist/js/UserManagementPage-DGmbGTC2.js +0 -1
  513. package/frontend/dist/js/WorkPage-DNKFD9gS.js +0 -6
  514. package/frontend/dist/js/api-DGVZHSkS.js +0 -14
  515. package/frontend/dist/js/ar-DW79oSyN.js +0 -2
  516. package/frontend/dist/js/bn-BEAmE7VH.js +0 -2
  517. package/frontend/dist/js/chatStore-zilBUd1p.js +0 -3
  518. package/frontend/dist/js/cs-irpRMzRo.js +0 -2
  519. package/frontend/dist/js/da-cgilTVxc.js +0 -2
  520. package/frontend/dist/js/de-BU-eH3gU.js +0 -2
  521. package/frontend/dist/js/es-B2LRpZ0p.js +0 -2
  522. package/frontend/dist/js/fr-Cd5JM-oQ.js +0 -2
  523. package/frontend/dist/js/hi-CvOhdtiK.js +0 -2
  524. package/frontend/dist/js/id-BtRK5nR_.js +0 -2
  525. package/frontend/dist/js/is-CnEqwgRF.js +0 -2
  526. package/frontend/dist/js/it-CI6WjId6.js +0 -2
  527. package/frontend/dist/js/ja-B6gFOHi6.js +0 -2
  528. package/frontend/dist/js/ko-DuAhnmMf.js +0 -2
  529. package/frontend/dist/js/markdown-core-BmPPZiuD.js +0 -31
  530. package/frontend/dist/js/ms-C8BIP7MZ.js +0 -2
  531. package/frontend/dist/js/nl-DnEdspER.js +0 -2
  532. package/frontend/dist/js/pl-Ddyyvbse.js +0 -2
  533. package/frontend/dist/js/pt-BYuzm70F.js +0 -2
  534. package/frontend/dist/js/router-vendor-CbPDks39.js +0 -1
  535. package/frontend/dist/js/ru-CmSPFxPX.js +0 -2
  536. package/frontend/dist/js/sv-Dd6SQ9f1.js +0 -2
  537. package/frontend/dist/js/th-CpH8745B.js +0 -2
  538. package/frontend/dist/js/tr-DuVD75iJ.js +0 -2
  539. package/frontend/dist/js/ui-CO0DPqrI.js +0 -2
  540. package/frontend/dist/js/ui-vendor-mqjSfAaS.js +0 -177
  541. package/frontend/dist/js/uk-B0MU-M8k.js +0 -2
  542. package/frontend/dist/js/vi-BLmFNp_z.js +0 -2
  543. package/frontend/dist/js/zh-BQu0TLhw.js +0 -2
@@ -1,6 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/babel-D24oDI9y.js","js/router-vendor-CbPDks39.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-BmPPZiuD.js","js/estree-CZO8RS52.js","assets/index-CDQ12KBq.js","js/react-vendor-C5yShNlM.js","js/useTranslation-Bho4HCyg.js","js/utils-D9W1Lnkn.js","js/utils-vendor-DWh39_3x.js","js/chatStore-zilBUd1p.js","js/i18next-DgmgtwsV.js","js/ui-vendor-mqjSfAaS.js","js/logger-DSXjF4ye.js","js/api-DGVZHSkS.js","js/config-CmEh9o8U.js","js/workApi-C4QtuhcE.js","js/authStore-B97lJ5Ee.js","js/appStore-DXlmTjIC.js","js/welcomePrompts-to5mv_gx.js","js/messageCodeStyles-BqQ6kOSU.js","js/Button-BPf_pOxH.js","js/ui-CO0DPqrI.js","assets/index-DkFWzmFD.css","js/typescript-DeXPhp90.js","js/postcss-Bx9CTcIc.js","js/html-C31pxhBG.js","js/markdown-C1CEqXpL.js","js/yaml-DioTxVLA.js","js/standalone-Dz0pkxn0.js","js/OptimizedSyntaxHighlighter-Dz7D1LPB.js","js/syntax-highlight-3EEX6CGL.js","assets/xterm-DHcfr8qj.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{m as t,p as n}from"./markdown-core-BmPPZiuD.js";import{d as r,f as i,i as a,l as o,u as s}from"./router-vendor-CbPDks39.js";import{t as c}from"./useTranslation-Bho4HCyg.js";import{t as l}from"./utils-D9W1Lnkn.js";import{C as u,t as d}from"./chatStore-zilBUd1p.js";import{At as f,B as p,C as m,Cn as h,D as g,En as _,F as v,H as y,Ht as b,It as ee,Kt as x,L as S,Mn as C,Pt as w,Rt as T,T as E,Tn as te,Tt as D,U as O,_n as k,an as A,c as j,dn as M,fn as N,g as ne,i as re,kn as ie,kt as P,n as F,on as I,pt as L,qt as ae,rt as oe,st as se,un as R,yn as ce,z as le,zt as ue}from"./ui-vendor-mqjSfAaS.js";import{t as de}from"./config-CmEh9o8U.js";import{r as fe,t as z}from"./workApi-C4QtuhcE.js";import{c as pe}from"./api-DGVZHSkS.js";import{a as me,c as he,i as ge,n as _e,o as ve,s as ye,u as be}from"./authStore-B97lJ5Ee.js";import{t as xe}from"./appStore-DXlmTjIC.js";import{t as B}from"./Button-BPf_pOxH.js";import{u as Se}from"./ui-CO0DPqrI.js";import{h as Ce,m as V}from"../assets/index-CDQ12KBq.js";import{t as H}from"./RichMessageContent-D0mK9vRA.js";import{t as U}from"./ModelSelector-A-viVFEc.js";import{n as W,t as we}from"./work-DVgm81bJ.js";var G=e(t(),1),K=n(),Te=e=>W({model:e.name,providerType:e.isPlugin?`plugin`:`ollama`,providerId:e.isPlugin?e.pluginId:void 0}),Ee=e=>{let t=e.name.split(`/`).filter(Boolean),n=t[t.length-1]||e.name;return t.length>1?n.replace(/[-_]+/g,` `):n},De=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 Oe({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:g,onCancel:_}){let{t:v}=c(),[y,b]=(0,G.useState)(``),ee=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=e.find(e=>e.key===n),w=C?.remote===!0,T=a===`landing`,E=(0,G.useMemo)(()=>{let n=new Set(t.map(Te)),r=e.filter(e=>!n.has(e.key)).map(De);return[...t,...r]},[e,t]);(0,G.useEffect)(()=>{let e=ee.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[y]);let te=async()=>{await f()&&([x.current,S.current].find(e=>e&&e.offsetParent!==null)||x.current)?.focus()},D=t=>{let n=e.find(e=>e.key===t)||e.find(e=>e.providerType===`ollama`&&e.model===t);n&&d(n.key)},O=async()=>{let e=y.trim();!e||i||r||o||!C||await g(e)&&b(``)};return(0,K.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,K.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,K.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,K.jsx)(`button`,{type:`button`,onClick:()=>void te(),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":v(`work.composer.remoteDismissLabel`,{defaultValue:`Dismiss remote provider notice`}),children:(0,K.jsx)(F,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.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,K.jsx)(A,{"data-testid":`work-provider-disclosure-accent`,className:`h-4 w-4 text-warning-500`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{id:`work-provider-disclosure-title`,className:`text-sm font-semibold text-ink`,children:v(`work.composer.remoteTitle`,{defaultValue:`Remote provider`})}),(0,K.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-ink-muted`,children:v(`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,K.jsx)(`div`,{className:`mt-2.5 flex justify-end`,children:(0,K.jsx)(B,{"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 te(),children:v(`work.composer.remoteDismiss`,{defaultValue:`Dismiss`})})})]})]})]})}),(0,K.jsx)(`form`,{className:`mx-auto w-full max-w-3xl`,onSubmit:e=>{e.preventDefault(),O()},children:(0,K.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,K.jsx)(`textarea`,{ref:ee,"data-testid":`work-composer-input`,dir:`auto`,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),O())},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:v(`work.composer.placeholder`,{defaultValue:`Describe what you want to build or change…`})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,K.jsx)(`div`,{className:`hidden shrink-0 sm:block`,children:(0,K.jsx)(U,{models:E,selectedModel:n,onModelChange:e=>D(e.target.value),onModelsRefresh:()=>void p(),getModelValue:Te,getModelLabel:Ee,getModelTitle:e=>e.name,triggerRef:x,triggerTestId:`work-model-selector-trigger`,selectTestId:`work-model-select`,ariaLabel:v(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`min-w-[150px] max-w-[230px]`,compact:!0})}),r?(0,K.jsx)(B,{"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:v(`work.composer.cancel`,{defaultValue:`Stop`}),"aria-label":v(`work.composer.cancel`,{defaultValue:`Stop`}),onClick:()=>void _(),children:i?(0,K.jsx)(L,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(m,{className:`h-4 w-4 fill-current`})}):(0,K.jsx)(B,{"data-testid":`work-submit-button`,type:`submit`,variant:`ghost`,size:`sm`,disabled:i||o||!y.trim()||!C,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:v(`work.composer.send`,{defaultValue:`Run`}),"aria-label":v(`work.composer.send`,{defaultValue:`Run`}),children:i?(0,K.jsx)(L,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(h,{className:`h-4 w-4`})})]})]})}),(0,K.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-3xl sm:hidden`,children:(0,K.jsx)(U,{models:E,selectedModel:n,onModelChange:e=>D(e.target.value),onModelsRefresh:()=>void p(),getModelValue:Te,getModelLabel:Ee,getModelTitle:e=>e.name,triggerRef:S,triggerTestId:`work-model-selector-trigger-mobile`,selectTestId:`work-model-select-mobile`,ariaLabel:v(`work.composer.model`,{defaultValue:`Work model`}),disabled:r||e.length===0,className:`w-full`,compact:!0})})]})}var ke=e=>{if(e==null||e===``)return null;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},q=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`},Ae=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 J({run:e}){let[t,n]=(0,G.useState)();if((0,G.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,K.jsx)(`span`,{dir:`ltr`,className:`tabular-nums text-ink-subtle`,"aria-hidden":`true`,children:q(r-e.startedAt)}):null}function je({tool:e,expandedByDefault:t}){let{t:n}=c(),[r]=(0,G.useState)(e.status),[i,a]=(0,G.useState)(null),o=(0,G.useMemo)(()=>ke(e.arguments),[e.arguments]),s=e.output||null,u=!!(o||s),d=e.status===`error`,f=e.status===`running`,p=(0,G.useId)(),m=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`}),h=i??(e.status===r?t:e.status===`error`);return(0,K.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,K.jsxs)(`button`,{type:`button`,disabled:!u,onClick:()=>{a(!h)},"aria-expanded":u?h:void 0,"aria-controls":u?p:void 0,"aria-label":`${m}: ${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,K.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:d?(0,K.jsx)(A,{className:`h-3.5 w-3.5 text-error-500`}):f?(0,K.jsx)(L,{className:`h-3.5 w-3.5 animate-spin text-[rgb(48,121,255)] motion-reduce:animate-none`}):(0,K.jsx)(N,{className:`h-3.5 w-3.5 text-[rgb(76,212,117)]`})}),(0,K.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,K.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-ink-subtle`,children:q(e.durationMs)}),u&&(0,K.jsx)(M,{"aria-hidden":`true`,className:l(`h-3.5 w-3.5 shrink-0 text-ink-subtle transition-transform`,h&&`rotate-180`)})]}),u&&h&&(0,K.jsxs)(`div`,{id:p,className:`border-t border-line bg-surface-subtle/50`,children:[o&&(0,K.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,K.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 Me=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 Ne({content:e,streaming:t}){let{t:n}=c(),[r,i]=(0,G.useState)(!1),a=t&&!r?Me(e):``;return(0,K.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,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-1 px-3 py-2 marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-3 text-xs font-medium text-ink-muted`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(k,{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,K.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,K.jsx)(`span`,{className:`truncate`,children:n(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,K.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),a&&(0,K.jsx)(`span`,{dir:`auto`,"data-testid":`work-live-reasoning-preview`,className:`block truncate text-[11px] leading-relaxed text-ink-subtle`,children:a})]}),(0,K.jsx)(`div`,{className:`border-t border-line px-3 py-2.5`,children:(0,K.jsx)(Se,{content:e,isStreaming:t,className:`text-xs text-ink-muted`})})]})}var Pe=(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`}),Fe=(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 Ie({run:e,variant:t=`conversation`}){let{t:n}=c(),r=[...e.tools].reverse().find(e=>e.status===`running`),i=Fe(e.connection,n)||Pe(e.phase,n,r),a=!e.terminal,o=e.usage?.outputTokens,s=e.reasoning+e.response,u=o!==void 0&&o>0?o:s?Ae(s):o,d=(o===void 0||o===0)&&!!s&&u!==void 0,f=e.usage?.tokensPerSecond;return(0,K.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,K.jsxs)(`div`,{className:`mb-3 flex min-h-6 items-center gap-2 text-xs`,children:[(0,K.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,K.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,K.jsx)(`span`,{dir:`ltr`,className:`shrink-0 tabular-nums text-ink-subtle`,children:e.roundLimit===void 0?`#${e.round}`:`${e.round}/${e.roundLimit}`}),(0,K.jsx)(J,{run:e})]}),t===`conversation`&&(0,K.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i}),e.skills.length>0&&(0,K.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1.5`,children:(0,K.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,K.jsx)(g,{className:`h-3 w-3 text-[#ff7b52]`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{dir:`auto`,children:n(`work.live.skillsLoaded`,{count:e.skills.length,defaultValue:`Workspace skills · {{count}}`})})]})}),t===`conversation`?e.timeline.length>0&&(0,K.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,K.jsx)(Ne,{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,K.jsx)(je,{tool:n,expandedByDefault:n.status===`error`},n.id):null}return(0,K.jsx)(Se,{content:t.text,isStreaming:a&&r,className:`text-ink`},`segment-${n}`)})}):e.tools.length>0&&(0,K.jsx)(`div`,{"data-testid":`work-live-tools`,className:`space-y-1.5`,children:e.tools.map(e=>(0,K.jsx)(je,{tool:e,expandedByDefault:e.status===`running`||e.status===`error`},e.id))}),e.error&&(0,K.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,K.jsx)(A,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:e.error})]}),(u!==void 0||f!==void 0)&&(0,K.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,K.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.generatedTokens`,{defaultValue:`Generated tokens:`}),` `,(0,K.jsxs)(`bdi`,{dir:`ltr`,children:[d&&`≈`,u.toLocaleString()]})]}),f!==void 0&&(0,K.jsxs)(`span`,{dir:`auto`,children:[n(`generationStats.speed`,{defaultValue:`Speed:`}),` `,(0,K.jsxs)(`bdi`,{dir:`ltr`,children:[f.toFixed(1),` t/s`]})]})]}),a&&!e.reasoning&&!e.response&&e.tools.length===0&&(0,K.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-5 items-center gap-1 text-[rgb(48,121,255)]`,children:[(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current motion-reduce:animate-none`}),(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current [animation-delay:160ms] motion-reduce:animate-none`}),(0,K.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,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-ink-muted`,children:[(0,K.jsx)(E,{className:`h-3.5 w-3.5`}),n(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]})]})}function Y({role:e,user:t,size:n=`message`}){let[r,i]=(0,G.useState)(null);if(e===`assistant`)return(0,K.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,K.jsx)(Ce,{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,K.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,K.jsx)(`img`,{src:o,alt:a,className:`h-full w-full object-cover`,onError:()=>i(o)}):t?(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium uppercase leading-none`,children:t.username.charAt(0)}):(0,K.jsx)(j,{"aria-hidden":`true`,className:`h-4 w-4`})})}var Le=(e,t)=>{let n=e.metadata,r=n?.name??n?.toolName??n?.tool??n?.command;return typeof r==`string`&&r?r:t},Re=e=>{let t=e.metadata?.toolCallId;return typeof t==`string`&&t?t:null},ze=(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?Le(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}},Be=(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=Re(a);if(a.kind===`tool_call`&&e){let o=i(ze(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]=ze(i.call,a,t),r.delete(e);continue}}}i(ze(a.kind===`tool_call`?a:void 0,a.kind===`tool_call`?void 0:a,t),a.id)}return n};function Ve({message:e}){let{t}=c();return(0,K.jsxs)(`details`,{"data-testid":`work-provider-reasoning`,className:`group ms-14 overflow-hidden rounded-xl border border-line bg-surface-subtle/70`,children:[(0,K.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,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(k,{className:`h-3.5 w-3.5 shrink-0 text-[rgb(48,121,255)]`}),(0,K.jsx)(`span`,{className:`truncate`,children:t(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`})})]}),(0,K.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180`})]}),(0,K.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 He({task:e,user:t,loading:n,loadingOlder:r,liveRun:i,onLoadOlder:a}){let{t:o}=c(),s=(0,G.useRef)(null),u=(0,G.useRef)(!0),[d,f]=(0,G.useState)(!1),p=(0,G.useMemo)(()=>[...e.messages||[]].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id)),[e.messages]),m=i?.runId,h=(0,G.useMemo)(()=>Be(p.filter(e=>!(m&&e.runId===m&&e.role!==`user`)),o(`work.activity.toolActivity`,{defaultValue:`Tool activity`})),[m,p,o]),g=[...p].reverse().find(e=>e.role===`assistant`&&e.kind===`message`)?.id;(0,G.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,G.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,K.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-ink-muted`,children:(0,K.jsx)(L,{className:`h-6 w-6 animate-spin`})}):(0,K.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,K.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,K.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,K.jsxs)(`div`,{className:`m-auto max-w-md text-center`,children:[(0,K.jsx)(Y,{role:`assistant`,size:`empty`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-ink`,children:o(`work.conversation.ready`,{defaultValue:`Workspace ready`})}),(0,K.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,K.jsxs)(`div`,{className:`space-y-6`,children:[e.hasMoreMessages&&(0,K.jsx)(`div`,{className:`flex justify-center`,children:(0,K.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,K.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}),o(`work.conversation.loadOlder`,{defaultValue:`Load older messages`})]})}),h.map(({key:n,item:r})=>{if(r.type===`reasoning`)return(0,K.jsx)(Ve,{message:r.message},n);if(r.type===`tools`)return(0,K.jsx)(`div`,{className:`ms-14 space-y-1.5`,children:r.tools.map(e=>(0,K.jsx)(je,{tool:e,expandedByDefault:!1},e.id))},n);let i=r.message,a=i.role===`user`,o=!a&&e.status===`running`&&i.id===g&&i.runId===e.activeRun?.id;return(0,K.jsxs)(`article`,{className:l(`flex gap-3`,a&&`flex-row-reverse`),children:[(0,K.jsx)(Y,{role:a?`user`:`assistant`,user:a?t:void 0}),(0,K.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,K.jsx)(`p`,{dir:`auto`,className:`whitespace-pre-wrap break-words text-sm leading-relaxed`,children:i.content}):o?(0,K.jsx)(Se,{content:i.content,className:`text-ink`}):(0,K.jsx)(H,{content:i.content,className:`text-sm text-ink`})})]},i.id)}),i&&(0,K.jsxs)(`article`,{className:`flex gap-3`,"data-testid":`work-live-run-message`,children:[(0,K.jsx)(Y,{role:`assistant`}),(0,K.jsx)(`div`,{className:`min-w-0 max-w-[92%] flex-1`,children:(0,K.jsx)(Ie,{run:i})})]}),!i&&(e.status===`preparing`||e.status===`running`)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 ps-14 text-xs text-ink-muted`,children:[(0,K.jsx)(L,{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,K.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,K.jsx)(_,{className:`h-3.5 w-3.5`}),o(`work.live.newActivity`,{defaultValue:`New activity`})]})]})}var Ue=45,X=30,We=70,Ge=360,Ke=480,qe=9,Je=2,Ye=10,Xe=`libre-webui-work-split:`,Ze=(e,t,n)=>Math.min(n,Math.max(t,e)),Qe=e=>`${Xe}${encodeURIComponent(e||`local`)}`,$e=e=>{if(typeof window>`u`)return Ue;try{let t=window.localStorage.getItem(e);if(t===null||t.trim()===``)return Ue;let n=Number(t);return Number.isFinite(n)?Ze(n,X,We):Ue}catch{return Ue}},et=(e,t)=>{if(!(typeof window>`u`))try{window.localStorage.setItem(e,t.toFixed(2))}catch{}},tt=e=>{let t=Math.max(0,e-qe);if(t===0)return{min:X,max:We};let n=Math.max(X,Ge/t*100),r=Math.min(We,(t-Ke)/t*100);if(n<=r)return{min:n,max:r};let i=Ze(Ge/840*100,X,We);return{min:i,max:i}},nt=(e,t)=>Ze(e,t.min,t.max);function rt({conversation:e,workspace:t,userId:n,mobileSurface:r=`conversation`,className:i}){let{t:a,i18n:o}=c(),s=u(o.language),d=Qe(n),[f,p]=(0,G.useState)(()=>({storageKey:d,percent:$e(d)})),[m,h]=(0,G.useState)(0),[g,_]=(0,G.useState)(!1),v=(0,G.useRef)(null),y=(0,G.useRef)(null),b=(0,G.useRef)(null),ee=(0,G.useRef)(d),x=(0,G.useRef)(f.percent),S=(0,G.useRef)(null),C=f.storageKey===d?f.percent:$e(d),w=(0,G.useMemo)(()=>tt(m),[m]),T=nt(C,w),E=Math.round(T),te=100-E,D=(0,G.useCallback)(e=>{p({storageKey:d,percent:e})},[d]),O=(0,G.useCallback)(e=>{let t=nt(e,tt(v.current?.getBoundingClientRect().width??0));x.current=t,S.current===null&&(S.current=window.requestAnimationFrame(()=>{S.current=null,D(x.current)}))},[D]),k=(0,G.useCallback)(()=>{if(b.current===null&&!g)return;S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null);let e=v.current?.getBoundingClientRect().width??0,t=nt(x.current,tt(e));x.current=t,D(t),et(ee.current,t);let n=b.current;b.current=null,n!==null&&y.current?.hasPointerCapture(n)&&y.current.releasePointerCapture(n),_(!1)},[g,D]),A=(0,G.useCallback)(e=>{let t=v.current?.getBoundingClientRect();if(!t)return x.current;let n=Math.max(1,t.width-qe);return((s?t.right-e:e-t.left)-qe/2)/n*100},[s]),j=e=>{e.button!==0||!e.isPrimary||(e.preventDefault(),e.stopPropagation(),b.current=e.pointerId,ee.current=d,x.current=T,e.currentTarget.setPointerCapture(e.pointerId),_(!0))},M=(0,G.useCallback)(e=>{let t=nt(e,w);x.current=t,D(t),et(d,t)},[w,D,d]),N=(0,G.useCallback)(()=>{M(Ue)},[M]),ne=e=>{let t=e.shiftKey?Ye:Je,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=Ue),n!==null&&(e.preventDefault(),M(n))};(0,G.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,G.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(),O(A(e.clientX)))},r=e=>{e.pointerId===b.current&&k()};return window.addEventListener(`pointermove`,n,{passive:!1}),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),window.addEventListener(`blur`,k),()=>{window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r),window.removeEventListener(`blur`,k),document.body.style.cursor=e,document.body.style.userSelect=t}},[k,g,A,O]),(0,G.useEffect)(()=>()=>{S.current!==null&&window.cancelAnimationFrame(S.current),b.current!==null&&et(ee.current,x.current)},[]);let re={gridTemplateColumns:`minmax(0, ${T}fr) ${qe}px minmax(0, ${100-T}fr)`};return(0,K.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:re,children:[(0,K.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,K.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:te,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:j,onDoubleClick:N,onKeyDown:ne,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,K.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,K.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,K.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,K.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 it=1e5,at=4e3,ot={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`},st={".bashrc":`bash`,".zshrc":`bash`},Z={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`}},ct=e=>e.split(/[\\/]/).pop()?.toLowerCase()??``,lt=e=>{let t=ct(e),n=t.lastIndexOf(`.`);return n>-1?t.slice(n+1):``},ut=e=>st[ct(e)]??ot[lt(e)]??`text`,dt=e=>Z[lt(e)],ft=e=>dt(e)!==void 0,pt=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},Q=async e=>(await e).default,mt=async(e,t)=>{switch(e.family){case`babel`:return Promise.all([Q(a(()=>import(`./babel-D24oDI9y.js`),__vite__mapDeps([0,1,2,3]))),Q(a(()=>import(`./estree-CZO8RS52.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([Q(a(()=>import(`./typescript-DeXPhp90.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]))),Q(a(()=>import(`./estree-CZO8RS52.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 Q(a(()=>import(`./postcss-Bx9CTcIc.js`),__vite__mapDeps([25,1,2,3])))];case`html`:{let e=[await Q(a(()=>import(`./html-C31pxhBG.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 Q(a(()=>import(`./babel-D24oDI9y.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-CZO8RS52.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 Q(a(()=>import(`./typescript-DeXPhp90.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 Q(a(()=>import(`./postcss-Bx9CTcIc.js`),__vite__mapDeps([25,1,2,3])))),[...new Set(e)]}case`markdown`:{let n=[await Q(a(()=>import(`./markdown-C1CEqXpL.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])))],r=e=>RegExp(`^(?: {0,3})(?:\`{3,}|~{3,})\\s*(?:${e})(?:\\s|$)`,`im`).test(t);return e.parser===`mdx`&&n.push(await Q(a(()=>import(`./babel-D24oDI9y.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-CZO8RS52.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])))),r(`js|jsx|javascript|json|json5|jsonc`)&&n.push(await Q(a(()=>import(`./babel-D24oDI9y.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-CZO8RS52.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])))),r(`ts|tsx|typescript`)&&n.push(await Q(a(()=>import(`./typescript-DeXPhp90.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 Q(a(()=>import(`./estree-CZO8RS52.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])))),r(`css|scss|less`)&&n.push(await Q(a(()=>import(`./postcss-Bx9CTcIc.js`),__vite__mapDeps([25,1,2,3])))),r(`html`)&&n.push(await Q(a(()=>import(`./html-C31pxhBG.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 Q(a(()=>import(`./babel-D24oDI9y.js`),__vite__mapDeps([0,1,2,3]))),await Q(a(()=>import(`./estree-CZO8RS52.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 Q(a(()=>import(`./typescript-DeXPhp90.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 Q(a(()=>import(`./postcss-Bx9CTcIc.js`),__vite__mapDeps([25,1,2,3])))),r(`yaml|yml`)&&n.push(await Q(a(()=>import(`./yaml-DioTxVLA.js`),__vite__mapDeps([28,1,2,3])))),[...new Set(n)]}case`yaml`:return[await Q(a(()=>import(`./yaml-DioTxVLA.js`),__vite__mapDeps([28,1,2,3])))]}},ht=async(e,t)=>{let n=dt(e);if(!n)throw Error(`Formatting is not supported for “${ct(e)||e}”.`);if(!pt(t))throw Error(`Could not format “${ct(e)||e}”: files are limited to ${it.toLocaleString()} characters and ${at.toLocaleString()} lines.`);try{let[{format:e},r]=await Promise.all([a(()=>import(`./standalone-Dz0pkxn0.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])),mt(n,t)]);return await e(t,{parser:n.parser,plugins:r,tabWidth:2,useTabs:!1})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Could not format “${ct(e)||e}”: ${n}`)}},gt=(0,G.lazy)(async()=>({default:(await a(()=>import(`./OptimizedSyntaxHighlighter-Dz7D1LPB.js`).then(e=>e.n),__vite__mapDeps([30,2,3,31]))).OptimizedSyntaxHighlighter})),_t=8e3,vt=400,yt=500;function bt({path:e,value:t,ariaLabel:n,disabled:r=!1,onChange:i,onSaveShortcut:a,onFormatShortcut:o}){let{t:s}=c(),u=xe(e=>e.theme.mode===`dark`),d=(0,G.useRef)(null),f=(0,G.useRef)(null),[p,m]=(0,G.useState)(``),h=(0,G.useMemo)(()=>ut(e),[e]),g=(0,G.useMemo)(()=>{if(t.length>_t)return 401;let e=1;for(let n=0;n<t.length&&!(t.charCodeAt(n)===10&&(e+=1,e>vt));n+=1);return e},[t]),_=t.length>_t||g>vt,v=h!==`text`&&!_,y=v&&p===t;return(0,G.useEffect)(()=>{if(!v)return;let e=window.setTimeout(()=>m(t),yt);return()=>window.clearTimeout(e)},[v,e,t]),(0,G.useLayoutEffect)(()=>{!y||!d.current||!f.current||(d.current.style.transform=`translate3d(${-f.current.scrollLeft}px, ${-f.current.scrollTop}px, 0)`)},[y,e]),(0,K.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,K.jsx)(`div`,{"aria-hidden":`true`,"data-testid":`work-file-highlight`,className:`pointer-events-none absolute inset-0 z-0 overflow-hidden`,children:(0,K.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,K.jsx)(G.Suspense,{fallback:(0,K.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,K.jsx)(gt,{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,K.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,K.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 xt=4e6,St=e=>{if(e===``)return[];let t=e.split(`
4
- `);return t[t.length-1]===``&&t.pop(),t},$=(e,t)=>{let n=St(e),r=St(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=Ct(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},Ct=(e,t)=>{if(e.length===0&&t.length===0)return[];if(e.length>0&&t.length>0&&e.length*t.length>xt)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},wt=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}},Tt=3,Et=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-Tt),i=Math.min(e.length-1,n+Tt);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,K.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,K.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.beforeLine??``}),(0,K.jsx)(`td`,{className:`w-10 select-none px-2 text-right align-top text-[10px] tabular-nums text-ink-subtle`,children:e.afterLine??``}),(0,K.jsxs)(`td`,{className:`w-full whitespace-pre-wrap break-all px-3 align-top`,children:[(0,K.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,G.useMemo)(()=>Et(e),[e]),r=(0,G.useMemo)(()=>kt(n),[n]),[i,a]=(0,G.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,K.jsx)(`table`,{className:`w-full border-collapse`,children:(0,K.jsx)(`tbody`,{children:n.map((e,n)=>{let i=r[n];return(0,K.jsxs)(G.Fragment,{children:[i>0&&(0,K.jsx)(`tr`,{"data-testid":`work-diff-gap`,children:(0,K.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,K.jsx)(G.Fragment,{children:e.lines.map((e,t)=>(0,K.jsx)(Dt,{line:e},t))},`fold-${n}`):(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:3,className:`p-0`,children:(0,K.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,K.jsx)(I,{className:`h-3 w-3 shrink-0`}),t(`work.files.diffFolded`,{count:e.count,defaultValue:`{{count}} unchanged lines`})]})})},`fold-${n}`):(0,K.jsx)(Dt,{line:e.line},`line-${n}`)}}function jt({lines:e,ariaLabel:t}){return(0,K.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,K.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:wt(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,K.jsxs)(`span`,{dir:`ltr`,className:`shrink-0 font-mono text-[10px] tabular-nums`,children:[(0,K.jsxs)(`span`,{className:n?`text-ink-subtle`:`text-[rgb(46,164,79)]`,children:[`+`,e]}),` `,(0,K.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,K.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,K.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-4 shrink-0 text-center font-mono text-[11px] font-semibold`,Wt(e)),children:e}),(0,K.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,K.jsx)(Kt,{added:r,removed:i})]})}function Jt({taskId:e,mutationsDisabled:t=!1,disabledReason:n}){let{t:r}=c(),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!0),[u,d]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)([]),[ee,x]=(0,G.useState)(``),[S,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(``),[D,O]=(0,G.useState)(null),[k,A]=(0,G.useState)(!1),[j,M]=(0,G.useState)(null),[ne,re]=(0,G.useState)(!1),ie=(0,G.useRef)(0),P=(0,G.useRef)(0),F=(0,G.useCallback)(async()=>{let t=++ie.current;s(!0),h(null);try{let n=zt(await z.getGitStatus(e),r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`}));if(t!==ie.current)return;a(n),_([])}catch(e){if(t!==ie.current)return;h(Bt(e,r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})))}finally{t===ie.current&&s(!1)}},[r,e]);(0,G.useEffect)(()=>{let e=window.setTimeout(()=>void F(),0);return()=>{window.clearTimeout(e),ie.current+=1}},[F]),(0,G.useEffect)(()=>{let t=!1,n=window.setTimeout(async()=>{if(!i?.initialized){M(null);return}if(!i.changes.some(e=>!Vt(e))){M(i.changes.length>0?{files:[],truncated:!1}:null);return}re(!0);try{let n=await z.getGitDiff(e);if(t||!n.success||!n.data)return;M({files:Lt(n.data.patch),truncated:n.data.truncated})}catch{}finally{t||re(!1)}},0);return()=>{t=!0,window.clearTimeout(n)}},[i,e]);let I=async(e,n)=>{if(t||u)return!1;d(!0),h(null);try{let t=zt(await e(),r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return P.current+=1,a(t),_([]),O(null),C.success(n),!0}catch(e){let t=Bt(e,r(`work.git.actionFailed`,{defaultValue:`Git action failed.`}));return h(t),C.error(t),!1}finally{d(!1)}},ae=async t=>{let n=++P.current;A(!0),h(null);try{if(Vt(t)){let i=zt(await z.getFile(e,t.path),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`}));if(n!==P.current)return;O({path:t.path,status:`added`,lines:$(``,i.content),binary:!1,truncated:!1})}else{let i=zt(await z.getGitDiff(e,t.path),r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`}));if(n!==P.current)return;let a=Lt(i.patch)[0];O({path:t.path,status:a?.status??`modified`,lines:a?.lines??[],binary:a?.binary??!1,truncated:i.truncated})}}catch(e){if(n!==P.current)return;h(Bt(e,r(`work.git.diffFailed`,{defaultValue:`Could not load this diff.`})))}finally{n===P.current&&A(!1)}},oe=(0,G.useMemo)(()=>{let e=new Map;for(let t of j?.files??[])e.set(t.path,t);return e},[j]),se=(0,G.useMemo)(()=>Rt(j?.files??[]),[j]),R=T.trim().toLowerCase(),ce=(0,G.useMemo)(()=>{let e=i?.changes??[];return R?e.filter(e=>e.path.toLowerCase().includes(R)):e},[R,i]);if(o&&!i)return(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center text-ink-muted`,children:(0,K.jsx)(L,{className:`h-5 w-5 animate-spin`})});if(!i)return(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,K.jsx)(f,{className:`mb-3 h-8 w-8 text-error-500`}),(0,K.jsx)(`p`,{className:`max-w-sm text-xs leading-relaxed text-error-600`,children:m||r(`work.git.loadFailed`,{defaultValue:`Could not load Git status.`})}),(0,K.jsxs)(B,{size:`sm`,variant:`secondary`,className:`mt-4`,onClick:()=>void F(),children:[(0,K.jsx)(p,{className:`h-3.5 w-3.5`}),r(`common.retry`,{defaultValue:`Retry`})]})]});if(!i.initialized)return(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center`,children:[(0,K.jsx)(f,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-ink`,children:r(`work.git.notInitialized`,{defaultValue:`Git is not initialized`})}),(0,K.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.`})}),m&&(0,K.jsx)(`p`,{className:`mt-3 text-xs text-error-600`,children:m}),(0,K.jsxs)(B,{"data-testid":`work-git-init-button`,size:`sm`,className:`mt-4 bg-[#ff7b52] text-[#3d120c] hover:bg-[#ff7b52]/90`,disabled:t||u,onClick:()=>void I(()=>z.initializeGit(e),r(`work.git.initialized`,{defaultValue:`Git repository initialized.`})),children:[u?(0,K.jsx)(L,{className:`me-2 h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(y,{className:`me-2 h-3.5 w-3.5`}),r(`work.git.initialize`,{defaultValue:`Initialize Git`})]}),t&&n&&(0,K.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-subtle`,children:n})]});let ue=i.changes.filter(e=>e.staged).length,de=i.changes.length>0,fe=ce.filter(Vt),pe=R?(j?.files??[]).filter(e=>e.path.toLowerCase().includes(R)):j?.files??[];return(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-testid":`work-git-panel`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-3 py-2`,children:[(0,K.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,K.jsx)(f,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:i.detached?r(`work.git.detached`,{defaultValue:`detached HEAD`}):i.branch||`main`})]}),j&&(se.added>0||se.removed>0)&&(0,K.jsxs)(`span`,{"data-testid":`work-git-total-stats`,dir:`ltr`,className:`font-mono text-[11px] font-medium tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-[rgb(46,164,79)]`,children:[`+`,se.added]}),` `,(0,K.jsxs)(`span`,{className:`text-[rgb(255,61,129)]`,children:[`−`,se.removed]})]}),(i.ahead>0||i.behind>0)&&(0,K.jsxs)(`span`,{className:`text-[10px] text-ink-muted`,children:[`↑`,i.ahead,` ↓`,i.behind]}),(0,K.jsxs)(`select`,{"data-testid":`work-git-branch-select`,"aria-label":r(`work.git.switchBranch`,{defaultValue:`Switch local branch`}),value:i.branch||``,disabled:t||u||de,onChange:t=>{let n=t.target.value;!n||n===i.branch||I(()=>z.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,K.jsx)(`option`,{value:``,disabled:!0,children:r(`work.git.detached`,{defaultValue:`detached HEAD`})}),i.branches.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsxs)(`div`,{className:`flex min-w-44 flex-1 items-center gap-1`,children:[(0,K.jsx)(`input`,{"data-testid":`work-git-branch-input`,value:S,maxLength:200,onChange:e=>w(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,K.jsxs)(B,{"data-testid":`work-git-create-branch-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2`,disabled:t||u||!i.head||!S.trim(),onClick:()=>{let t=S.trim();I(()=>z.createGitBranch(e,t),r(`work.git.branchCreated`,{name:t,defaultValue:`Created {{name}}.`})).then(e=>{e&&w(``)})},children:[(0,K.jsx)(y,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:r(`work.git.createBranch`,{defaultValue:`Create`})})]})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void F(),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,K.jsx)(p,{className:l(`h-3.5 w-3.5`,o&&`animate-spin`)})})]}),m&&(0,K.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:m}),t&&n&&(0,K.jsx)(`div`,{className:`border-b border-line px-3 py-1.5 text-[11px] text-ink-subtle`,children:n}),(0,K.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,K.jsxs)(`section`,{className:`flex min-h-0 flex-col border-b border-line lg:border-b-0 lg:border-e`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-medium text-ink`,children:[r(`work.git.changes`,{defaultValue:`Changes`}),` `,(0,K.jsx)(`span`,{className:`text-ink-subtle`,children:i.changes.length})]}),(0,K.jsxs)(B,{"data-testid":`work-git-stage-button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-[11px]`,disabled:t||u||g.length===0&&i.changes.length===0,onClick:()=>{let t=g.length>0?g:i.changes.map(e=>e.path);I(()=>z.stageGitPaths(e,t),r(`work.git.staged`,{defaultValue:`Changes staged.`}))},children:[(0,K.jsx)(N,{className:`h-3.5 w-3.5`}),g.length>0?r(`work.git.stageSelected`,{count:g.length,defaultValue:`Stage {{count}}`}):r(`work.git.stageAll`,{defaultValue:`Stage all`})]})]}),i.changes.length>0&&(0,K.jsxs)(`div`,{className:`relative px-2 pb-1.5`,children:[(0,K.jsx)(v,{className:`pointer-events-none absolute start-4 top-1/2 h-3 w-3 -translate-y-[calc(50%+3px)] text-ink-subtle`}),(0,K.jsx)(`input`,{"data-testid":`work-git-filter`,value:T,maxLength:500,onChange:e=>E(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,K.jsx)(`div`,{className:`min-h-32 flex-1 overflow-y-auto px-2 pb-2`,children:i.changes.length===0?(0,K.jsx)(`p`,{className:`px-2 py-8 text-center text-xs text-ink-muted`,children:r(`work.git.clean`,{defaultValue:`Working tree is clean.`})}):ce.length===0?(0,K.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.`})}):ce.map(e=>{let t=Ht(e),{name:n,directory:i}=Gt(e.path),a=oe.get(e.path);return(0,K.jsxs)(`div`,{className:l(`flex items-center gap-1 rounded-lg hover:bg-surface-subtle`,D?.path===e.path&&`bg-surface-subtle`),children:[(0,K.jsx)(`input`,{type:`checkbox`,"aria-label":r(`work.git.selectPath`,{path:e.path,defaultValue:`Select {{path}}`}),checked:g.includes(e.path),onChange:t=>_(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,K.jsxs)(`button`,{type:`button`,"data-testid":`work-git-change`,onClick:()=>void ae(e),className:`flex min-w-0 flex-1 items-center gap-2 px-1.5 py-2 text-start`,title:e.path,children:[(0,K.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,K.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate text-start font-mono text-[11px]`,children:[(0,K.jsx)(`span`,{className:`text-ink`,children:n}),i&&(0,K.jsxs)(`span`,{className:`text-ink-subtle`,children:[` `,i]})]}),a&&(a.stats.added>0||a.stats.removed>0)&&(0,K.jsx)(Kt,{added:a.stats.added,removed:a.stats.removed})]})]},`${e.path}:${e.originalPath||``}`)})}),(0,K.jsxs)(`div`,{className:`border-t border-line p-2`,children:[(0,K.jsx)(`textarea`,{"data-testid":`work-git-commit-input`,value:ee,maxLength:4e3,rows:2,onChange:e=>x(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,K.jsxs)(B,{"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||!ee.trim(),onClick:()=>{let t=ee.trim();I(()=>z.commitGit(e,t),r(`work.git.committed`,{defaultValue:`Commit created.`})).then(e=>{e&&x(``)})},children:[u&&(0,K.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}),r(`work.git.commit`,{defaultValue:`Commit staged changes`})]})]}),(0,K.jsxs)(`div`,{className:`max-h-56 shrink-0 overflow-y-auto border-t border-line p-3`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-ink`,children:[(0,K.jsx)(le,{className:`h-3.5 w-3.5`}),r(`work.git.history`,{defaultValue:`Local history`})]}),i.commits.length===0?(0,K.jsx)(`p`,{className:`py-3 text-center text-xs text-ink-muted`,children:r(`work.git.noCommits`,{defaultValue:`No commits yet.`})}):(0,K.jsx)(`ol`,{className:`space-y-2`,children:i.commits.map(e=>(0,K.jsxs)(`li`,{className:`rounded-lg border border-line bg-surface px-2.5 py-2`,children:[(0,K.jsx)(`p`,{dir:`auto`,className:`text-xs text-ink`,children:e.subject}),(0,K.jsxs)(`p`,{className:`mt-1 flex flex-wrap gap-x-2 text-[10px] text-ink-subtle`,children:[(0,K.jsx)(`span`,{dir:`ltr`,className:`font-mono`,children:e.shortHash}),(0,K.jsx)(`span`,{dir:`auto`,children:e.author}),(0,K.jsx)(`time`,{dateTime:e.authoredAt,children:new Date(e.authoredAt).toLocaleDateString()})]})]},e.hash))}),(0,K.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,K.jsx)(`section`,{className:`flex min-h-48 min-w-0 flex-col`,children:D||k?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-line px-2 py-1.5`,children:[(0,K.jsxs)(`button`,{type:`button`,"data-testid":`work-git-all-changes-button`,onClick:()=>{P.current+=1,O(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,K.jsx)(te,{className:`h-3 w-3 rtl:rotate-180`}),r(`work.git.allChanges`,{defaultValue:`All changes`})]}),D&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:l(`w-4 shrink-0 text-center font-mono text-[11px] font-semibold`,Wt(Ut(D.status))),children:Ut(D.status)}),(0,K.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,title:D.path,children:D.path}),!D.binary&&(0,K.jsx)(Kt,{added:D.lines.filter(e=>e.type===`added`).length,removed:D.lines.filter(e=>e.type===`removed`).length})]})]}),k?(0,K.jsx)(L,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):D?(0,K.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:[D.truncated&&(0,K.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.`})}),D.binary?(0,K.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.`})}):D.lines.length===0?(0,K.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,K.jsx)(At,{lines:D.lines})]}):null]}):i.changes.length===0?(0,K.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,K.jsx)(L,{className:`m-auto h-5 w-5 animate-spin text-ink-muted`}):(0,K.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,K.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.`})}),pe.map(e=>(0,K.jsxs)(`div`,{"data-testid":`work-git-review-file`,children:[(0,K.jsx)(qt,{letter:Ut(e.status),path:e.path,oldPath:e.oldPath,added:e.stats.added,removed:e.stats.removed}),e.binary?(0,K.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,K.jsx)(At,{lines:e.lines})]},e.path)),fe.map(e=>(0,K.jsx)(`div`,{"data-testid":`work-git-review-file`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void ae(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,K.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,K.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink`,children:e.path}),(0,K.jsx)(b,{className:`h-3 w-3 shrink-0 text-ink-subtle`})]})},e.path)),pe.length===0&&fe.length===0&&(0,K.jsx)(`p`,{className:`px-5 py-10 text-center font-sans text-xs text-ink-muted`,children:R?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 ge(e,t.ticket,t)}async function Xt(e){let t=(await fe.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:r}=c(),i=xe(e=>e.theme.mode===`dark`),o=(0,G.useRef)(null),s=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),[f,p]=(0,G.useState)(`idle`),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(0),v=(0,G.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,G.useEffect)(()=>{if(!t||n)return;let r=!1,c,l;return(async()=>{p(`connecting`),h(null);let[{Terminal:t},{FitAddon:n}]=await Promise.all([a(()=>import(`./xterm-Da5ppSVt.js`),[]),a(()=>import(`./addon-fit-DIOBYJe3.js`),[])]);if(await a(()=>Promise.resolve({}),__vite__mapDeps([32])),r||!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:i?Qt:Zt});let f=new n;c.loadAddon(f),c.open(o.current),u.current=c,d.current=f;try{f.fit()}catch{}let m;try{m=await Xt(e)}catch(e){r||(p(`error`),h(e instanceof Error?e.message:null));return}if(r)return;l=new WebSocket(m),l.binaryType=`arraybuffer`,s.current=l;let g=new TextDecoder;l.onmessage=e=>{if(typeof e.data!=`string`){c?.write(g.decode(new Uint8Array(e.data)));return}try{let t=JSON.parse(e.data);if(t.type===`ready`){p(`connected`),v(),c?.focus();return}if(t.type===`error`){p(`error`),h(t.message||null);return}t.type===`exit`&&p(`closed`)}catch{}},l.onclose=()=>{r||p(e=>e===`error`||e===`closed`?e:`closed`)},l.onerror=()=>{r||p(`error`)},c.onData(e=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:`input`,data:e}))})})(),()=>{r=!0,l?.close(),s.current=null,c?.dispose(),u.current=null,d.current=null}},[t,n,g,i,v,e]),(0,G.useEffect)(()=>{let e=o.current;if(!e||!t)return;let n=new ResizeObserver(()=>v());return n.observe(e),()=>n.disconnect()},[t,v]);let y=()=>{s.current?.close(),_(e=>e+1)},b=n??(f===`error`?m??r(`work.terminal.failed`,{defaultValue:`The terminal session could not start.`}):f===`closed`?r(`work.terminal.closed`,{defaultValue:`Terminal session ended.`}):null);return(0,K.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,K.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,K.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center gap-2 text-xs text-ink-muted`,children:[(0,K.jsx)(L,{className:`h-4 w-4 animate-spin`}),r(`work.terminal.connecting`,{defaultValue:`Opening a shell in the sandbox…`})]}),b&&(0,K.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,K.jsx)(E,{className:`h-6 w-6 text-ink-subtle`}),(0,K.jsx)(`p`,{dir:`auto`,"data-testid":`work-terminal-status`,className:`max-w-md text-xs leading-relaxed text-ink-muted`,children:b}),!n&&(0,K.jsx)(B,{size:`sm`,"data-testid":`work-terminal-reconnect-button`,className:`h-8 rounded-lg bg-[#ff7b52] px-3 text-[#3d120c] hover:bg-[#ff7b52]/90`,onClick:y,children:r(`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(de,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:d,onSaveFile:h,onStartPreview:g,onStopPreview:_,onDirtyChange:v,terminal:y}){let{t:b,i18n:ee}=c(),D=u(ee.language),[k,A]=(0,G.useState)(`files`),[j,M]=(0,G.useState)(``),[N,ne]=(0,G.useState)(``),[F,I]=(0,G.useState)(),[ae,se]=(0,G.useState)(``),[R,ce]=(0,G.useState)(!1),[le,de]=(0,G.useState)(!1),fe=(0,G.useRef)(new Map),[z,pe]=(0,G.useState)(()=>new Map),ge=en(e.previewUrl),_e=t?.runId,ve=t?.error,be=t?.tools,xe=(0,G.useMemo)(()=>{let t=new Set(be?.map(e=>e.id)||[]);return(e.messages||[]).filter(e=>{if(e.kind===`reasoning`||e.role!==`tool`&&e.kind===`message`)return!1;if(!_e||e.runId!==_e)return!0;if(e.kind===`error`&&ve)return!1;let n=e.metadata?.toolCallId;return typeof n!=`string`||!t.has(n)})},[ve,_e,be,e.messages]),Se=xe.length+(be?.length||0),Ce=!!r&&N!==(r?.content??``),V=e.status===`preparing`||e.status===`running`,H=(0,G.useRef)(V),U=(0,G.useRef)(0),W=(0,G.useRef)(N),we=(0,G.useRef)(F),Te=(0,G.useRef)(r),Ee=(0,G.useRef)(e.id),De=(0,G.useRef)(o),Oe=(0,G.useRef)(s),ke=(0,G.useRef)(v),q=(0,G.useRef)(!0),Ae=r?z.get(r.path):void 0,J=(0,G.useMemo)(()=>r&&Ae!==void 0&&Ae!==r.content?$(Ae,r.content):null,[Ae,r]),je=(0,G.useMemo)(()=>J?wt(J):null,[J]),Me=!!(je&&(je.added>0||je.removed>0)),Ne=r?ft(r.path):!1,Pe=!r||pt(N),Fe=Ne&&Pe;(0,G.useEffect)(()=>{W.current=N,we.current=F,Te.current=r,Ee.current=e.id,ke.current=v},[F,N,v,r,e.id]),(0,G.useEffect)(()=>{De.current=o,Oe.current=s},[s,o]),(0,G.useEffect)(()=>(q.current=!0,()=>{q.current=!1,U.current+=1,ke.current(!1)}),[]),(0,G.useEffect)(()=>{if(!H.current&&V&&pe(new Map(fe.current)),H.current&&!V&&(De.current(j),r&&!Ce)){let e=++U.current,t=r.path,n=W.current,i=we.current;Oe.current(t).then(r=>{if(!q.current||e!==U.current||r.path!==t||W.current!==n||we.current!==i)return;fe.current.set(r.path,r.content);let a=z.get(r.path);a!==void 0&&a!==r.content&&de(!0),W.current=r.content,we.current=r.updatedAt??r.modifiedAt,ne(r.content),I(r.updatedAt??r.modifiedAt)}).catch(()=>void 0)}H.current=V},[j,Ce,r,V,z]);let Y=()=>!Ce||window.confirm(b(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),Le=()=>{r&&me(e.id,r.path)},Re=async e=>{Y()&&(U.current+=1,Le(),d(),v(!1),de(!1),M(e),await o(e).catch(()=>void 0))},ze=async t=>{if(!Y())return;let n=++U.current;Le();let r=await s(t).catch(()=>void 0);if(!q.current||!r||n!==U.current)return;fe.current.set(r.path,r.content);let i=z.get(r.path);de(i!==void 0&&i!==r.content);let a=ye(e.id,r.path),o=a?.content??r.content,c=a?.baseUpdatedAt??r.updatedAt??r.modifiedAt;W.current=o,we.current=c,ne(o),I(c),v(a!==null&&a.content!==r.content)},Be=()=>{Y()&&(U.current+=1,Le(),d(),v(!1),de(!1))},Ve=t=>{r&&(W.current=t,ne(t),t===r.content?me(e.id,r.path):he(e.id,r.path,{content:t,baseUpdatedAt:F??r.updatedAt??r.modifiedAt}),v(t!==r.content))},He=async()=>{if(!r)return;let t=e.id,n=r.path,i=N,a=U.current,o=await h(n,i,F).catch(()=>!1);if(!q.current||o===!1||a!==U.current||Ee.current!==t||Te.current?.path!==n)return;let s=o.updatedAt??o.modifiedAt;fe.current.set(n,typeof o.content==`string`?o.content:i),we.current=s,I(s);let c=W.current;if(c===i){me(t,n),v(!1);return}he(t,n,{content:c,baseUpdatedAt:s}),v(!0)},Ue=async()=>{if(!r||V||R||!Fe)return;ce(!0);let e=U.current,t=r.path,n=W.current;try{let r=await ht(t,n);if(!q.current||e!==U.current||Te.current?.path!==t||W.current!==n)return;Ve(r),C.success(b(`work.files.formatted`,{defaultValue:`Code formatted.`}))}catch(r){if(!q.current||e!==U.current||Te.current?.path!==t||W.current!==n)return;C.error(r instanceof Error?r.message:b(`work.files.formatFailed`,{defaultValue:`Could not format this file.`}))}finally{q.current&&ce(!1)}},X=[{id:`files`,label:b(`work.workspace.files`,{defaultValue:`Files`}),icon:T,testId:`work-files-tab`},{id:`activity`,label:b(`work.workspace.activity`,{defaultValue:`Activity`}),icon:ie,testId:`work-activity-tab`},{id:`git`,label:b(`work.workspace.git`,{defaultValue:`Git`}),icon:f,testId:`work-git-tab`},{id:`terminal`,label:b(`work.workspace.terminal`,{defaultValue:`Terminal`}),icon:E,testId:`work-terminal-tab`},{id:`preview`,label:b(`work.workspace.preview`,{defaultValue:`Preview`}),icon:oe,testId:`work-preview-tab`}],We=(e,t)=>{let n=null;if(e.key===`ArrowRight`&&(n=(t+(D?-1:1)+X.length)%X.length),e.key===`ArrowLeft`&&(n=(t+(D?1:-1)+X.length)%X.length),e.key===`Home`&&(n=0),e.key===`End`&&(n=X.length-1),n===null)return;e.preventDefault();let r=X[n];A(r.id),e.currentTarget.parentElement?.querySelector(`#work-workspace-tab-${r.id}`)?.focus()};return(0,K.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-transparent`,children:[(0,K.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,K.jsx)(`div`,{role:`tablist`,"aria-orientation":`horizontal`,"aria-label":b(`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:X.map((e,t)=>{let n=e.icon;return(0,K.jsxs)(`button`,{type:`button`,role:`tab`,id:`work-workspace-tab-${e.id}`,"aria-selected":k===e.id,"aria-controls":k===e.id?`work-workspace-panel-${e.id}`:void 0,"aria-label":e.label,tabIndex:k===e.id?0:-1,title:e.label,"data-testid":e.testId,onClick:()=>A(e.id),onKeyDown:e=>We(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]`,k===e.id?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:text-ink`),children:[(0,K.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`hidden xs:inline`,children:e.label}),e.id===`activity`&&Se>0&&(0,K.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-[10px] text-ink-muted`,children:Se})]},e.id)})}),k===`files`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[r&&(0,K.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:Be,"aria-label":b(`work.files.back`,{defaultValue:`Back to files`}),children:(0,K.jsx)(te,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,K.jsxs)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,title:r?.path??`/workspace${j?`/${j}`:``}`,children:[r?.path??`/workspace${j?`/${j}`:``}`,Ce&&` •`]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:!j,onClick:()=>void Re(tn(j)),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":b(`work.files.up`,{defaultValue:`Parent folder`}),title:b(`work.files.up`,{defaultValue:`Parent folder`}),children:(0,K.jsx)(te,{className:`h-3.5 w-3.5 rtl:rotate-180`})}),(0,K.jsx)(`button`,{type:`button`,"data-testid":`work-refresh-files-button`,onClick:()=>void o(j).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":b(`common.refresh`,{defaultValue:`Refresh`}),title:b(`common.refresh`,{defaultValue:`Refresh`}),children:(0,K.jsx)(p,{className:l(`h-3.5 w-3.5`,i&&`animate-spin`)})}),r&&Me&&je&&(0,K.jsxs)(`button`,{type:`button`,"data-testid":`work-diff-toggle-button`,"aria-pressed":le,onClick:()=>de(e=>!e),title:b(`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`,le?`border-transparent bg-ink text-ink-inverse`:`border-line text-ink-muted hover:bg-surface-subtle hover:text-ink`),children:[(0,K.jsx)(P,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:b(`work.files.changes`,{defaultValue:`Changes`})}),(0,K.jsxs)(`span`,{dir:`ltr`,className:`tabular-nums`,children:[(0,K.jsxs)(`span`,{className:le?void 0:`text-[rgb(46,164,79)]`,children:[`+`,je.added]}),` `,(0,K.jsxs)(`span`,{className:le?void 0:`text-[rgb(255,61,129)]`,children:[`−`,je.removed]})]})]}),r&&!le&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(B,{"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:V||R||!Fe,onClick:()=>void Ue(),"aria-busy":R||void 0,title:Fe?b(`work.files.formatShortcut`,{defaultValue:`Format (Shift+Alt+F)`}):Ne?b(`work.files.formatTooLarge`,{defaultValue:`Formatting is limited to files under 100,000 characters and 4,000 lines.`}):b(`work.files.formatUnsupported`,{defaultValue:`Formatting is not available for this file type.`}),"aria-label":b(`work.files.format`,{defaultValue:`Format file`}),children:[R?(0,K.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(re,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`hidden 2xl:inline`,children:b(`work.files.format`,{defaultValue:`Format`})})]}),(0,K.jsxs)(B,{"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:!Ce||V||R||a,onClick:()=>void He(),"aria-busy":a||void 0,title:b(`work.files.saveShortcut`,{defaultValue:`Save (⌘/Ctrl+S)`}),"aria-label":b(`common.save`),children:[a?(0,K.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(S,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`hidden 2xl:inline`,children:b(`common.save`)})]})]})]})]}),(k===`activity`||k===`git`)&&(0,K.jsx)(`div`,{className:`min-w-0 flex-1`}),k===`terminal`&&(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,K.jsx)(`span`,{dir:`ltr`,className:`min-w-0 flex-1 truncate font-mono text-[11px] text-ink-muted`,children:`/workspace`}),V&&(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-ink-subtle`,children:b(`work.terminal.taskRunning`,{defaultValue:`Model turn in progress`})})]}),k===`preview`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{dir:`auto`,value:ae,onChange:e=>se(e.target.value),placeholder:b(`work.preview.command`,{defaultValue:`Optional start command`}),"aria-label":b(`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,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.previewStatus===`running`||e.previewStatus===`starting`?(0,K.jsxs)(B,{"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":b(`work.preview.stop`,{defaultValue:`Stop preview`}),children:[a?(0,K.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(m,{className:`h-3.5 w-3.5 fill-current`}),(0,K.jsx)(`span`,{className:`hidden 2xl:inline`,children:b(`work.preview.stop`,{defaultValue:`Stop preview`})})]}):(0,K.jsxs)(B,{"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 g(ae.trim()||void 0),"aria-busy":a||void 0,"aria-label":b(`work.preview.start`,{defaultValue:`Start preview`}),children:[a?(0,K.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(O,{className:`h-3.5 w-3.5 fill-current`}),(0,K.jsx)(`span`,{className:`hidden 2xl:inline`,children:b(`work.preview.start`,{defaultValue:`Start preview`})})]}),ge&&(0,K.jsx)(`a`,{href:ge,target:`_blank`,rel:`noopener noreferrer`,"aria-label":b(`work.preview.open`,{defaultValue:`Open`}),title:b(`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,K.jsx)(x,{className:`h-3.5 w-3.5`})})]})]})]}),k===`files`&&(0,K.jsxs)(`div`,{id:`work-workspace-panel-files`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-files`,className:`flex min-h-0 flex-1`,children:[(0,K.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,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:i&&n.length===0?(0,K.jsx)(`div`,{className:`flex justify-center py-8 text-ink-muted`,children:(0,K.jsx)(L,{className:`h-5 w-5 animate-spin`})}):n.length===0?(0,K.jsx)(`p`,{className:`px-3 py-8 text-center text-xs text-ink-muted`,children:b(`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,K.jsxs)(`button`,{type:`button`,"data-testid":`work-file-item`,"data-path":e.path,onClick:()=>{e.type===`directory`?Re(e.path):ze(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,K.jsx)(w,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}):(0,K.jsx)(ue,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{dir:`auto`,className:`truncate`,children:e.name})]},e.path))})}),(0,K.jsx)(`div`,{className:l(`min-h-0 min-w-0 flex-1 flex-col`,r?`flex`:`hidden sm:flex`),children:r&&le&&J?(0,K.jsx)(jt,{lines:J,ariaLabel:b(`work.files.diffLabel`,{path:r.path,defaultValue:`Changes since the last turn: {{path}}`})}):r?(0,K.jsx)(bt,{path:r.path,value:N,ariaLabel:b(`work.files.editorLabel`,{path:r.path,defaultValue:`File editor: {{path}}`}),onChange:Ve,onSaveShortcut:()=>{Ce&&!V&&!a&&!R&&He()},onFormatShortcut:()=>void Ue(),disabled:V||R}):(0,K.jsxs)(`div`,{className:`m-auto px-6 text-center text-xs text-ink-muted`,children:[(0,K.jsx)(ue,{className:`mx-auto mb-3 h-7 w-7 text-ink-subtle`}),b(`work.files.select`,{defaultValue:`Select a file to inspect and edit it.`})]})})]}),k===`activity`&&(0,K.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,K.jsx)(`div`,{className:`mb-3`,children:(0,K.jsx)(Ie,{run:t,variant:`activity`})}),xe.length===0&&!t?(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-6 text-center text-xs text-ink-muted`,children:[(0,K.jsx)(E,{className:`mb-3 h-7 w-7 text-ink-subtle`}),b(`work.activity.empty`,{defaultValue:`Commands, file operations, and tool results will appear here.`})]}):(0,K.jsx)(`div`,{className:`space-y-2`,children:xe.map(e=>(0,K.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{dir:`auto`,className:`truncate font-mono text-xs font-medium text-ink`,children:nn(e,b(`work.activity.toolActivity`,{defaultValue:`Tool activity`}))}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-ink-subtle rtl:tracking-normal`,children:{message:b(`work.activity.kinds.message`,{defaultValue:`Message`}),reasoning:b(`libreClaw.metrics.reasoning`,{defaultValue:`Reasoning`}),tool_call:b(`work.activity.kinds.toolCall`,{defaultValue:`Tool call`}),tool_result:b(`work.activity.kinds.toolResult`,{defaultValue:`Tool result`}),error:b(`work.activity.kinds.error`,{defaultValue:`Error`})}[e.kind]})]}),e.content&&(0,K.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))})]}),k===`git`&&(0,K.jsx)(`div`,{id:`work-workspace-panel-git`,role:`tabpanel`,"aria-labelledby":`work-workspace-tab-git`,className:`min-h-0 flex-1`,children:(0,K.jsx)(Jt,{taskId:e.id,mutationsDisabled:V||e.previewStatus===`starting`||e.previewStatus===`running`,disabledReason:V?b(`work.git.blockedByRun`,{defaultValue:`Git write actions unlock when the model turn finishes.`}):e.previewStatus===`starting`||e.previewStatus===`running`?b(`work.git.blockedByPreview`,{defaultValue:`Stop the preview before changing Git state.`}):void 0})}),k===`terminal`&&(0,K.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,K.jsx)($t,{taskId:e.id,active:k===`terminal`,disabledReason:y&&!y.available?y.reason??b(`work.terminal.unavailable`,{defaultValue:`The interactive terminal is not available in this deployment.`}):V?b(`work.terminal.blockedByRun`,{defaultValue:`The model is using this container. The terminal opens when the turn finishes.`}):void 0})}),k===`preview`&&(0,K.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,K.jsxs)(`div`,{className:`m-auto flex items-center gap-2 text-xs text-ink-muted`,children:[(0,K.jsx)(L,{className:`h-4 w-4 animate-spin`}),b(`work.preview.starting`,{defaultValue:`Starting preview…`})]}):ge&&e.previewStatus===`running`?(0,K.jsx)(`iframe`,{"data-testid":`work-preview-frame`,title:b(`work.preview.frameTitle`,{defaultValue:`Workspace preview`}),src:ge,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,K.jsxs)(`div`,{className:`m-auto max-w-sm px-6 text-center text-xs leading-relaxed text-ink-muted`,children:[(0,K.jsx)(oe,{className:`mx-auto mb-3 h-8 w-8 text-ink-subtle`}),e.previewStatus===`failed`?b(`work.preview.failed`,{defaultValue:`The preview could not start. Check Activity, then try another command.`}):b(`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=s(),n=r(),{taskId:a}=i(),u=xe(e=>e.preferences),f=xe(e=>e.setPreferences),p=_e(e=>e.user),m=p?.id??null,[h,g]=(0,G.useState)(!1),_=d(e=>e.models),v=d(e=>e.selectedModel),y=d(e=>e.selectedProviderType),b=d(e=>e.selectedProviderId),x=d(e=>e.loadModels),{capabilities:S,tasks:w,selectedTask:T,files:E,selectedFile:te,liveRuns:O,loadingTask:k,loadingOlderMessages:j,loadingFiles:M,actionLoading:N,error:re,loadCapabilities:ie,loadTasks:P,selectTask:F,loadTask:I,loadOlderMessages:L,createTask:le,updateTask:ue,deleteTask:de,startRun:fe,cancelRun:he,beginLiveRun:ge,applyRunEvents:ye,setLiveRunConnection:B,clearLiveRun:Se,loadFiles:H,loadFile:U,clearSelectedFile:Te,saveFile:Ee,startPreview:De,stopPreview:ke,clearError:q}=be(),Ae=(0,G.useMemo)(()=>_.filter(e=>!e.isPersona&&!e.isAgent&&an(e.name)&&(!e.isPlugin||!!e.pluginId)),[_]),J=(0,G.useMemo)(()=>Ae.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:W(i),label:e.isPlugin&&e.pluginName?`${e.name} · ${e.pluginName}`:e.name,remote:e.isPlugin||r.endsWith(`:cloud`)||r.endsWith(`-cloud`)}]}),[Ae]),[je,Me]=(0,G.useState)(``),[Ne,Pe]=(0,G.useState)({locationKey:t.key,value:`conversation`}),Fe=Ne.locationKey===t.key?Ne.value:`conversation`,Ie=e=>Pe({locationKey:t.key,value:e}),[Y,Le]=(0,G.useState)(!1),[Re,ze]=(0,G.useState)(``),Be=S?.hostWorkspaces?.enabled===!0,Ve=S?.hostWorkspaces?.roots??[],[Ue,X]=(0,G.useState)([]),[We,Ge]=(0,G.useState)(``),Ke=!T;(0,G.useEffect)(()=>{if(!Ke)return;let e=!1;return z.listPolicies().then(t=>{if(e||!t.success||!t.data)return;let n=t.data;X(n),Ge(e=>e&&!n.some(t=>t.id===e)?``:e)}).catch(()=>{}),()=>{e=!0}},[Ke]);let qe=T?.id,Je=T?.previewStatus===`running`||T?.previewStatus===`starting`;(0,G.useEffect)(()=>{if(!qe||!Je)return;let e=window.setInterval(()=>{document.visibilityState===`visible`&&I(qe,!0).catch(()=>{})},3e4);return()=>window.clearInterval(e)},[qe,Je,I]);let[Ye,Xe]=(0,G.useState)({taskId:null,open:!1}),Ze=Ye.open&&Ye.taskId===T?.id,Qe=(0,G.useRef)(null),$e=(0,G.useRef)(null),et=(0,G.useRef)(null),tt=(0,G.useCallback)((e=!1)=>{Xe(e=>({...e,open:!1})),e&&window.requestAnimationFrame(()=>$e.current?.focus())},[]);(0,G.useEffect)(()=>{if(!Ze)return;let e=window.requestAnimationFrame(()=>{et.current?.querySelector(`[role="menuitem"]`)?.focus()}),t=e=>{e.target instanceof Node&&!Qe.current?.contains(e.target)&&tt()},n=e=>{e.key===`Escape`&&(e.preventDefault(),tt(!0))};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,n),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,n)}},[tt,Ze]);let nt=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),tt(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=[...et.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,G.useEffect)(()=>{ie(),P()},[ie,P]),(0,G.useEffect)(()=>{if(!a){F(null);return}F(a),I(a).catch(()=>void 0),H(a,``).catch(()=>void 0)},[a,H,I,F]);let it=J.find(e=>e.key===je)||J.find(e=>e.model===v&&(y===`plugin`?e.providerType===`plugin`&&e.providerId===b:e.providerType===`ollama`))||J[0],at=a?w.find(e=>e.id===a):void 0,ot=at?.status??T?.status,st=T?.activeRun??at?.activeRun??null,Z=st?.id,ct=st?.status===`queued`||st?.status===`preparing`||st?.status===`running`,lt=a&&O[a]?.runId===Z?O[a]:void 0,ut=ot===`preparing`||ot===`running`?1e3:4e3;(0,G.useEffect)(()=>{let e,t=!1,n=async()=>{await P(!0),t||(e=setTimeout(n,ut))};return e=setTimeout(n,ut),()=>{t=!0,e&&clearTimeout(e)}},[P,ut]);let dt=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!a||!ot){dt.current=null;return}let e=dt.current;dt.current={taskId:a,status:ot},e?.taskId===a&&(e.status===`preparing`||e.status===`running`)&&ot!==`preparing`&&ot!==`running`&&(I(a,!0).catch(()=>void 0),H(a,``).catch(()=>void 0))},[H,I,ot,a]),(0,G.useEffect)(()=>{if(!a||!Z||!ct)return;let e=new AbortController,t=!1,n=0,r=be.getState().liveRuns[a]?.runId===Z&&be.getState().liveRuns[a]?.lastEventId||0,i=!1,o=[],s=null,c=()=>{if(s!==null&&(window.cancelAnimationFrame(s),s=null),o.length===0)return;let e=o;o=[],ye(e)},l=e=>{if(e.type!==`snapshot`&&(n=0),r=Math.max(r,e.id),o.push(e),e.type===`done`||e.type===`error`&&e.data.terminal!==!1){i=!0,c();return}s===null&&(s=window.requestAnimationFrame(c))};return ge(a,Z,st?.startedAt||void 0),(async()=>{for(;!t&&!e.signal.aborted&&!i;){B(a,Z,n>=3?`error`:n===0?`connecting`:`reconnecting`);let o=Date.now();try{if(await z.streamRunEvents({taskId:a,runId:Z,after:r,signal:e.signal,onEvent:l}),c(),i||t||e.signal.aborted)break;throw Error(`The live Work connection closed.`)}catch(r){if(c(),t||e.signal.aborted)return;Date.now()-o>=5e3&&(n=0),n+=1,B(a,Z,n>=3?`error`:`reconnecting`,n>=3?on(r,`Live updates are reconnecting in the background.`):void 0),await sn(Math.min(4e3,250*2**Math.min(n,4)),e.signal)}}if(c(),!(!i||e.signal.aborted)){B(a,Z,`closed`);try{await Promise.all([I(a,!0),H(a,``),P(!0)])}catch{}finally{Se(a,Z)}}})(),()=>{t=!0,e.abort(),c()}},[ye,ge,Se,H,I,P,st?.startedAt,ct,Z,B,a]),(0,G.useEffect)(()=>{if(!Y)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Y]);let ft=(0,G.useCallback)(()=>!Y||window.confirm(e(`work.files.discard`,{defaultValue:`Discard unsaved file changes?`})),[e,Y]),pt=(0,G.useCallback)(()=>!Y||window.confirm(e(`work.files.leaveWithDraft`,{defaultValue:`Leave this file? Your unsaved edit will remain as a browser draft.`})),[e,Y]),Q=()=>{T&&te&&me(T.id,te.path)},mt=o(({currentLocation:e,nextLocation:t})=>{let n=t.state;return Y&&n?.deletedWorkTaskId!==a&&`${e.pathname}${e.search}${e.hash}`!=`${t.pathname}${t.search}${t.hash}`});(0,G.useEffect)(()=>{if(mt.state!==`blocked`)return;if(!pt()){mt.reset();return}let e=mt.proceed,t=window.setTimeout(()=>{Le(!1),window.setTimeout(e,0)},0);return()=>window.clearTimeout(t)},[pt,mt]);let ht=()=>{q(),Ie(`conversation`),n(`/work`)},gt=async t=>{if(T&&!ft())return!1;T&&Y&&(Q(),Te(),Le(!1));try{if(T)await fe(T.id,{message:t,model:T.model,providerType:T.providerType,providerId:T.providerId||void 0});else{if(!it)throw Error(e(`work.composer.noModelSelected`,{defaultValue:`No Work-compatible model is selected.`}));let r=await le({message:t,model:it.model,providerType:it.providerType,providerId:it.providerId,networkEnabled:!0,...Be&&Re.trim()?{hostPath:Re.trim()}:{},...We?{policyId:We}:{}});n(`/work/${r.id}`)}return!0}catch(t){return C.error(on(t,e(`work.toasts.runFailed`,{defaultValue:`Could not start the Work task.`}))),!1}},_t=async t=>{let n=kt.find(e=>e.key===t);if(n){if(!T){Me(t);return}try{await ue(T.id,{model:n.model,providerType:n.providerType,providerId:n.providerId})}catch(t){C.error(on(t,e(`work.toasts.updateFailed`,{defaultValue:`Could not update this task.`})))}}},vt=async()=>{if(T)try{await he(T.id),C.success(e(`work.toasts.cancelled`,{defaultValue:`Work run stopped.`}))}catch(t){C.error(on(t,e(`work.toasts.cancelFailed`,{defaultValue:`Could not stop the Work run.`})))}},yt=async t=>{let r=w.find(e=>e.id===t);if(!window.confirm(e(`work.tasks.deleteConfirm`,{defaultValue:`Delete “{{title}}” and its workspace permanently?`,title:r?.title||e(`work.tasks.untitled`,{defaultValue:`Untitled task`})})))return;let i=a===t&&Y;i&&Le(!1);try{await de(t),ve(t),a===t&&n(`/work`)}catch(t){i&&Le(!0),C.error(on(t,e(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`})))}},bt=async t=>{if(!T)return!1;let n=t.trim();if(!n||n===T.title)return!!n;try{return await ue(T.id,{title:n}),!0}catch(t){return C.error(on(t,e(`work.toasts.renameFailed`,{defaultValue:`Could not rename this task.`}))),!1}},xt=async(e,t,n)=>{try{return await e(),n&&C.success(n),!0}catch(e){return C.error(on(e,t)),!1}},St=async(t,n,r)=>{if(!T)return!1;let i=T.id;try{let a=await Ee(i,t,n,r);return be.getState().selectedTaskId===i&&C.success(e(`work.toasts.saved`,{defaultValue:`File saved.`})),a}catch(t){return be.getState().selectedTaskId===i&&C.error(on(t,e(`work.toasts.saveFailed`,{defaultValue:`Could not save this file.`}))),!1}},$=S?.available===!1,Ct=e(`work.runtime.ready`,{defaultValue:`Runtime ready`}),wt=S?.runtime===`kubernetes`?`Kubernetes · ${Ct}`:S?.pluginAvailable?S.ollamaAvailable?e(`work.runtime.readyHybrid`,{defaultValue:`Docker + models ready`}):e(`work.runtime.readyPlugin`,{defaultValue:`Docker + plugin ready`}):e(`work.runtime.readyOllama`,{defaultValue:`Docker ready`}),Tt=T?we(T):!1,Et=T?{model:T.model,providerType:T.providerType,providerId:T.providerId||void 0}:void 0,Dt=Et?W(Et):it?.key||``,Ot=Et&&!J.some(e=>e.key===Dt)?{...Et,key:Dt,label:`${Et.model} · ${Et.providerType===`plugin`?Et.providerId||`plugin`:`Ollama`}`,remote:Et.providerType===`plugin`||Et.model.toLowerCase().endsWith(`:cloud`)||Et.model.toLowerCase().endsWith(`-cloud`)}:void 0,kt=Ot?[Ot,...J]:J,At=V[T?.status??`idle`],jt=e(At.labelKey,{defaultValue:At.label}),Mt=async()=>{if(u.workRemoteProviderDisclosureDismissed||h)return!1;let t=m;g(!0);try{let n=await pe.updatePreferences({workRemoteProviderDisclosureDismissed:!0});if(!n.success)throw Error(n.error||e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`}));return(_e.getState().user?.id??null)===t&&(f({workRemoteProviderDisclosureDismissed:!0}),!0)}catch{return C.error(e(`work.composer.remoteDismissFailed`,{defaultValue:`Could not save the remote provider preference.`})),!1}finally{g(!1)}};return(0,K.jsx)(`div`,{"data-testid":`work-page`,className:`relative flex h-full min-h-0 overflow-hidden bg-transparent`,children:(0,K.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,K.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:[T?(0,K.jsx)(`input`,{"data-testid":`work-task-title`,dir:`auto`,defaultValue:T.title,onBlur:e=>{let t=e.currentTarget;if(!t.value.trim()){t.value=T.title;return}bt(t.value).then(e=>{e||(t.value=T.title)})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=T.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`})},`${T.id}:${T.title}`):(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(`h1`,{className:`truncate text-sm font-semibold text-ink`,children:e(`work.title`,{defaultValue:`Work`})})}),T?.hostPath&&(0,K.jsxs)(`span`,{"data-testid":`work-host-path-chip`,title:T.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,K.jsx)(ee,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`max-w-[16rem] truncate`,children:T.hostPath})]}),T&&(0,K.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,K.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`,T.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:At.color}}),(0,K.jsx)(`span`,{className:`hidden md:inline`,children:jt})]}),T&&(0,K.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,K.jsxs)(`button`,{type:`button`,onClick:()=>Ie(`conversation`),"aria-label":e(`work.mobile.conversation`,{defaultValue:`Conversation`}),"aria-pressed":Fe===`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`,Fe===`conversation`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,K.jsx)(se,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.conversation`,{defaultValue:`Conversation`})})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>Ie(`workspace`),"aria-label":e(`work.mobile.workspace`,{defaultValue:`Workspace`}),"aria-pressed":Fe===`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`,Fe===`workspace`?`bg-surface-raised text-ink shadow-subtle`:`text-ink-muted hover:bg-surface-raised/70 hover:text-ink`),children:[(0,K.jsx)(oe,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`work.mobile.workspace`,{defaultValue:`Workspace`})})]})]}),(0,K.jsxs)(`div`,{className:l(`ms-auto hidden min-w-0 items-center gap-2`,T?`xl:flex`:`sm:flex`),children:[T&&(0,K.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,K.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`work-status-indicator`,className:l(`h-1.5 w-1.5 rounded-full`,At.animated&&`animate-pulse`,T.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:At.color}}),jt]}),(0,K.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`,$?`border-transparent bg-error-500 text-[#0D0D0C]`:`border-transparent bg-success-500 text-[#0D0D0C]`),title:$?S?.reason||e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):S?.image?`${wt} · ${S.image}`:wt,children:[(0,K.jsx)(ce,{className:`h-3.5 w-3.5`}),$?e(`work.runtime.unavailable`,{defaultValue:`Runtime unavailable`}):Ct]}),T&&(0,K.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,K.jsx)(D,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{dir:`ltr`,className:`truncate`,children:T.model})]})]}),T&&(0,K.jsxs)(`div`,{ref:Qe,className:`relative shrink-0`,children:[(0,K.jsx)(`button`,{ref:$e,id:`work-task-actions-trigger`,type:`button`,"data-testid":`work-task-actions-button`,onClick:()=>Xe(e=>({taskId:T.id,open:e.taskId!==T.id||!e.open})),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),Xe({taskId:T.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":Ze,"aria-controls":Ze?`work-task-actions-menu`:void 0,children:(0,K.jsx)(ae,{className:`h-4 w-4`})}),Ze&&(0,K.jsx)(`div`,{ref:et,id:`work-task-actions-menu`,role:`menu`,"aria-labelledby":`work-task-actions-trigger`,onKeyDown:nt,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,K.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`work-delete-task-button`,onClick:()=>{tt(!0),yt(T.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,K.jsx)(ne,{className:`h-3.5 w-3.5`}),e(`work.tasks.delete`,{defaultValue:`Delete task`})]})})]})]}),($||re)&&(0,K.jsxs)(`div`,{className:l(`flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs`,$?`border-error-500/20 bg-error-500/10 text-error-700`:`border-amber-500/20 bg-amber-500/10 text-ink`),children:[(0,K.jsx)(A,{className:`h-4 w-4 shrink-0`}),(0,K.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1`,children:$?S?.reason||e(`work.runtime.reason`,{defaultValue:`A Work runtime and an available Ollama or plugin model provider are required.`}):re}),re&&!$&&(0,K.jsx)(`button`,{type:`button`,className:`rounded-md p-1 hover:bg-black/5`,onClick:q,"aria-label":e(`common.close`),children:`×`})]}),a?T?(0,K.jsx)(rt,{userId:m,mobileSurface:Fe,conversation:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(He,{task:T,user:p,liveRun:lt,loading:k,loadingOlder:j,onLoadOlder:()=>L(T.id)}),(0,K.jsx)(Oe,{models:kt,selectorModels:Ae,modelKey:Dt,running:Tt,loading:N,disabled:$,remoteDisclosureDismissed:u.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:h,onModelChange:_t,onDismissRemoteDisclosure:Mt,onModelsRefresh:x,onSubmit:gt,onCancel:vt},T.id)]}),workspace:(0,K.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:(0,K.jsx)(rn,{task:T,liveRun:lt,files:E,selectedFile:te,loadingFiles:M,actionLoading:N,onLoadFiles:e=>H(T.id,e),onLoadFile:e=>U(T.id,e),onClearSelectedFile:Te,onSaveFile:St,onStartPreview:t=>xt(()=>De(T.id,t),e(`work.toasts.previewFailed`,{defaultValue:`Could not start the preview.`})),onStopPreview:()=>xt(()=>ke(T.id),e(`work.toasts.previewStopFailed`,{defaultValue:`Could not stop the preview.`})),onDirtyChange:Le,terminal:S?.terminal},T.id)})}):(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center`,children:k?(0,K.jsx)(`div`,{className:`text-sm text-ink-muted`,children:e(`work.tasks.loading`,{defaultValue:`Loading task…`})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(A,{className:`mb-3 h-8 w-8 text-ink-subtle`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-ink`,children:e(`work.tasks.notFound`,{defaultValue:`This Work task is unavailable`})}),(0,K.jsxs)(`button`,{type:`button`,onClick:ht,className:`mt-4 inline-flex items-center gap-1.5 text-sm font-medium text-primary-600 hover:text-primary-700`,children:[(0,K.jsx)(R,{className:`h-4 w-4 rtl:rotate-180`}),e(`work.tasks.back`,{defaultValue:`Start a new task`})]})]})}):(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-y-auto`,children:[(0,K.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0`,children:[(0,K.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,K.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,K.jsx)(`div`,{className:`absolute left-1/2 top-0 h-16 w-px bg-gray-300/60 dark:bg-white/10`})]}),(0,K.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,K.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center justify-center gap-3`,children:[(0,K.jsx)(Ce,{size:`sm`,label:null,className:`h-9 w-9 shrink-0 p-0 text-ink`}),(0,K.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,K.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.`})})]}),Ue.length>0&&(0,K.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,K.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,K.jsxs)(`select`,{id:`work-policy`,"data-testid":`work-policy`,value:We,onChange:e=>Ge(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,K.jsx)(`option`,{value:``,children:e(`work.policy.default`,{defaultValue:`Default (global limits)`})}),Ue.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),Be&&(0,K.jsxs)(`div`,{className:`mt-8 w-full max-w-2xl`,children:[(0,K.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,K.jsx)(`input`,{id:`work-host-path`,"data-testid":`work-host-path`,value:Re,onChange:e=>ze(e.target.value),spellCheck:!1,placeholder:Ve[0]?`${Ve[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,K.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-subtle`,children:Re.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,K.jsx)(Oe,{variant:`landing`,models:J,selectorModels:Ae,modelKey:it?.key||``,running:!1,loading:N,disabled:$,remoteDisclosureDismissed:u.workRemoteProviderDisclosureDismissed,remoteDisclosureSaving:h,onModelChange:_t,onDismissRemoteDisclosure:Mt,onModelsRefresh:x,onSubmit:gt,onCancel:vt}),(0,K.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,K.jsx)(ce,{"aria-hidden":`true`,className:`h-3.5 w-3.5`}),(0,K.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};
@@ -1,14 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./logger-DSXjF4ye.js";import{t as n}from"./config-CmEh9o8U.js";import{a as r,i,r as a}from"./workApi-C4QtuhcE.js";var o={getModels:()=>t()?i([]):a.get(`/agent-clis/models`).then(e=>e.data)},s=`0.24.1`,c=[`chat`,`models`,`documents`,`notes`,`personas`,`media`,`work`,`admin`],l={login:e=>t()?i({user:{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:s}}):a.post(`/auth/login`,e).then(e=>e.data),signup:e=>t()?i({user:{id:`demo-user-new`,username:e.username,email:e.email||``,role:`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},token:`demo-token-new`,systemInfo:{requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:s,turnstile:{enabled:!1}}}):a.post(`/auth/signup`,e).then(e=>e.data),logout:()=>t()?i(void 0):a.post(`/auth/logout`).then(e=>e.data),getSystemInfo:()=>(r.debug(`getSystemInfo called, demo mode:`,t()),t()?i({requiresAuth:!0,hasUsers:!0,userCount:1,signupEnabled:!0,version:s,turnstile:{enabled:!1}}):(r.debug(`Making API call to:`,n+`/auth/system-info`),r.debug(`Full URL from:`,window.location.origin,`-> API:`,n+`/auth/system-info`),a.get(`/auth/system-info`).then(e=>(r.debug(`getSystemInfo response:`,e.data),e.data)).catch(e=>{throw r.debug(`getSystemInfo error:`,e),e.response&&(r.debug(`Error response data:`,e.response.data),r.debug(`Error status:`,e.response.status),r.debug(`Error headers:`,e.response.headers)),e.request&&r.debug(`Network error - no response received:`,e.request),r.debug(`Error config:`,e.config),e}))),verifyToken:()=>t()?i({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):a.get(`/auth/verify`).then(e=>e.data),getEncryptionKey:()=>t()?i({encryptionKey:`demo-encryption-key-not-real`}):a.get(`/auth/encryption-key`).then(e=>e.data),getSessions:()=>t()?i([{id:`demo-session`,kind:`password`,userAgent:navigator.userAgent,createdAt:new Date().toISOString(),lastSeenAt:new Date().toISOString(),expiresAt:null,revokedAt:null,current:!0}]):a.get(`/auth/sessions`).then(e=>e.data),revokeSession:e=>t()?i(void 0):a.delete(`/auth/sessions/${e}`).then(e=>e.data),revokeOtherSessions:()=>t()?i({revokedCount:0}):a.post(`/auth/sessions/revoke-others`).then(e=>e.data),listApiTokens:()=>t()?i([]):a.get(`/auth/tokens`).then(e=>e.data),createApiToken:e=>t()?i({token:`lwui_demo_not_a_real_token`,record:{id:`demo-token-`+Date.now(),name:e.name,tokenPrefix:`lwui_demo`,scopes:e.scopes,createdAt:new Date().toISOString(),expiresAt:null,lastUsedAt:null,revokedAt:null}}):a.post(`/auth/tokens`,e).then(e=>e.data),revokeApiToken:e=>t()?i(void 0):a.delete(`/auth/tokens/${e}`).then(e=>e.data)},u={getUsers:()=>t()?i([{id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]):a.get(`/users`).then(e=>e.data),createUser:e=>t()?i({id:`new-user-`+Date.now(),username:e.username,email:e.email,role:e.role,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):a.post(`/users`,e).then(e=>e.data),updateUser:(e,n)=>t()?i({id:e,username:n.username||`demo`,email:n.email||`demo@example.com`,role:n.role||`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):a.patch(`/users/${e}`,n).then(e=>e.data),deleteUser:e=>t()?i(void 0):a.delete(`/users/${e}`).then(e=>e.data),getPendingApprovals:()=>t()?i({count:0,latestCreatedAt:null}):a.get(`/users/pending-approvals`).then(e=>e.data),approveUser:e=>t()?i({id:e,username:`demo-user`,email:`demo@example.com`,role:`user`,status:`active`,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):a.patch(`/users/${e}/approve`).then(e=>e.data),updateMyAvatar:e=>t()?i({id:`demo-user`,username:`demo`,email:`demo@example.com`,role:`admin`,status:`active`,avatar:e,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}):a.patch(`/users/me/avatar`,{avatar:e}).then(e=>e.data)},d={getGroups:()=>t()?i([]):a.get(`/groups`).then(e=>e.data),createGroup:e=>t()?i({id:`demo-group-`+Date.now(),name:e.name,description:e.description??null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),members:[]}):a.post(`/groups`,e).then(e=>e.data),updateGroup:(e,n)=>t()?i({id:e,name:n.name??`demo-group`,description:n.description??null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),members:[]}):a.patch(`/groups/${e}`,n).then(e=>e.data),deleteGroup:e=>t()?i(void 0):a.delete(`/groups/${e}`).then(e=>e.data),addGroupMember:(e,n)=>t()?i({id:e,name:`demo-group`,description:null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),members:[]}):a.post(`/groups/${e}/members`,{userId:n}).then(e=>e.data),removeGroupMember:(e,n)=>t()?i(void 0):a.delete(`/groups/${e}/members/${n}`).then(e=>e.data),getEffectiveAccess:e=>t()?i({userId:e,username:`demo`,role:`admin`,status:`active`,groups:[],features:{work:!0,"model-download":!0,"web-search":!0,agents:!0},grants:[]}):a.get(`/groups/effective/${e}`).then(e=>e.data),getAuditEvents:(e={})=>{if(t())return i([]);let n=new URLSearchParams;e.action&&n.set(`action`,e.action),e.actor&&n.set(`actor`,e.actor),e.result&&n.set(`result`,e.result),e.limit&&n.set(`limit`,String(e.limit));let r=n.toString()?`?${n.toString()}`:``;return a.get(`/audit${r}`).then(e=>e.data)}},f=[{name:`llama3.2:3b`,size:2048e6,digest:`demo-digest-1`,modified_at:new Date().toISOString(),details:{format:`gguf`,family:`llama`,families:[`llama`],parameter_size:`3B`,quantization_level:`Q4_0`}},{name:`qwen2.5:7b`,size:4096e6,digest:`demo-digest-2`,modified_at:new Date().toISOString(),details:{format:`gguf`,family:`qwen`,families:[`qwen`],parameter_size:`7B`,quantization_level:`Q4_0`}}],p=()=>[{id:`demo-session-1`,title:`Demo Chat Session`,model:f[0].name,providerType:`ollama`,providerId:null,messages:[{id:`demo-msg-1`,role:`user`,content:`Hello! Can you tell me about this demo?`,timestamp:Date.now()},{id:`demo-msg-2`,role:`assistant`,content:`This is a demo of Libre WebUI! In a real deployment, I would be powered by Ollama running locally on your machine. This demo shows the beautiful interface and features without the backend connection.`,timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()}],m=p(),h={theme:{mode:`dark`,adaptToAccent:!1,accent:`blue`,customAccent:`#2563eb`},defaultModel:`llama3.2:3b`,defaultProviderType:`ollama`,defaultProviderId:null,visionModel:``,visionProviderType:null,visionProviderId:null,systemMessage:`You are a helpful assistant.`,generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.7},titleSettings:{autoTitle:!1,taskModel:``,taskProviderType:null,taskProviderId:null},showUsername:!1,hapticFeedbackEnabled:!1,workRemoteProviderDisclosureDismissed:!1,backgroundSettings:{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6}},g={...h,theme:{...h.theme},generationOptions:{...h.generationOptions},embeddingSettings:{...h.embeddingSettings},titleSettings:{...h.titleSettings},backgroundSettings:{...h.backgroundSettings}},_=()=>g,v=e=>{let t=g.backgroundSettings||h.backgroundSettings;return g={...g,...e,theme:{...g.theme,...e.theme},generationOptions:{...g.generationOptions,...e.generationOptions},embeddingSettings:{...g.embeddingSettings,...e.embeddingSettings},titleSettings:e.titleSettings?{...g.titleSettings||h.titleSettings,...e.titleSettings}:g.titleSettings,backgroundSettings:e.backgroundSettings?{...t,...e.backgroundSettings}:g.backgroundSettings},g},y={getSessions:()=>a.get(`/chat/sessions`).then(e=>e.data),createSession:(e,t,n,r,i)=>a.post(`/chat/sessions`,{model:e,title:t,personaId:n,providerType:r,providerId:i}).then(e=>e.data),getSession:e=>{if(t()){let t=p().find(t=>t.id===e);return t?i(t):Promise.resolve({success:!1,error:`Session not found in demo mode`})}return a.get(`/chat/sessions/${e}`).then(e=>e.data)},updateSession:(e,n)=>{if(t()){let t=m.findIndex(t=>t.id===e),r=m[t];if(r){let e={...r,...n,updatedAt:Date.now()};return m[t]=e,i(e)}return Promise.resolve({success:!1,error:`Session not found in demo mode`})}return a.put(`/chat/sessions/${e}`,n).then(e=>e.data)},deleteSession:e=>t()?i(null):a.delete(`/chat/sessions/${e}`).then(e=>e.data),clearAllSessions:()=>a.delete(`/chat/sessions`).then(e=>e.data),generateTitle:(e,n,r,o,s)=>{if(t()){let e=r.substring(0,30)+(r.length>30?`...`:``);return i({title:e,source:`fallback`,updatedAt:Date.now()})}return a.post(`/chat/sessions/${e}/generate-title`,{model:n,message:r,providerType:o,providerId:s}).then(e=>e.data)},getFolders:()=>t()?i([]):a.get(`/chat/folders`).then(e=>e.data),createFolder:e=>a.post(`/chat/folders`,{name:e}).then(e=>e.data),renameFolder:(e,t)=>a.put(`/chat/folders/${e}`,{name:t}).then(e=>e.data),deleteFolder:e=>a.delete(`/chat/folders/${e}`).then(e=>e.data),generateFollowUps:e=>t()?i({suggestions:[]}):a.post(`/chat/sessions/${e}/followups`).then(e=>e.data),sendMessage:(e,t,n)=>a.post(`/chat/sessions/${e}/messages`,{content:t,options:n}).then(e=>e.data),saveMessage:(e,t)=>a.post(`/chat/sessions/${e}/messages`,t).then(e=>e.data),updateMessage:(e,n,r)=>t()?i({}):a.put(`/chat/sessions/${e}/messages/${n}`,r).then(e=>e.data),generateChatResponse:(e,t,n)=>a.post(`/chat/sessions/${e}/generate`,{message:t,options:n}).then(e=>e.data),generateChatStreamResponse:(e,t,i)=>({subscribe:async(a,o,s)=>{try{let c=await fetch(`${n}/chat/sessions/${e}/generate/stream`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:t,options:i})});if(!c.ok)throw Error(`HTTP error! status: ${c.status}`);let l=c.body?.getReader();if(!l)throw Error(`No response body reader available`);let u=new TextDecoder,d=``,f=()=>{l.read().then(({done:e,value:t})=>{if(e){s?.();return}d+=u.decode(t,{stream:!0});let n=d.split(`
2
- `);d=n.pop()||``;for(let e of n){let t=e.trim();if(t.startsWith(`data: `)){let e=t.slice(6);if(e===`[DONE]`){s?.();return}try{let t=JSON.parse(e);if(a(t),t.type===`done`||t.type===`error`){t.type===`error`?o?.(t.error):s?.();return}}catch(e){r.error(`Failed to parse SSE data:`,e)}}}f()}).catch(e=>{o?.(e instanceof Error?e:Error(String(e)))})};return f(),()=>l.cancel()}catch(e){return o?.(e instanceof Error?e:Error(String(e))),()=>{}}}}),getMessageBranches:(e,n)=>t()?i([]):a.get(`/chat/sessions/${e}/messages/${n}/branches`).then(e=>e.data),switchMessageBranch:(e,n,r)=>t()?i({}):a.post(`/chat/sessions/${e}/messages/${n}/branch`,{branchIndex:r}).then(e=>e.data),createMessageBranch:(e,n,r)=>t()?i({}):a.post(`/chat/sessions/${e}/messages/${n}/branches`,{...r}).then(e=>e.data),restoreCompaction:(e,t)=>a.post(`/chat/sessions/${e}/compaction/${t}/restore`).then(e=>e.data),getContextPolicy:()=>t()?i({windowMessages:10}):a.get(`/chat/context-policy`).then(e=>e.data),getCompactionConfig:()=>t()?i({enabled:!1,thresholdTokens:8e3,keepRecentMessages:8,model:``,prompt:``}):a.get(`/chat/compaction-config`).then(e=>e.data),setCompactionConfig:e=>t()?i({enabled:!1,thresholdTokens:8e3,keepRecentMessages:8,model:``,prompt:``},!1):a.put(`/chat/compaction-config`,e).then(e=>e.data)},b={uploadDocument:(e,n)=>{if(t())return i({id:`demo-doc-`+Date.now(),filename:e.name,fileType:e.name.endsWith(`.pdf`)?`pdf`:`txt`,size:e.size,sessionId:n,uploadedAt:Date.now()});let r=new FormData;return r.append(`document`,e),n&&r.append(`sessionId`,n),a.post(`/documents/upload`,r).then(e=>e.data)},getCollections:()=>t()?i([]):a.get(`/documents/collections`).then(e=>e.data),createCollection:e=>a.post(`/documents/collections`,{name:e}).then(e=>e.data),deleteCollection:e=>a.delete(`/documents/collections/${e}`).then(e=>e.data),setDocumentCollection:(e,t)=>a.put(`/documents/${e}/collection`,{collectionId:t}).then(e=>e.data),fetchWebpage:(e,n)=>t()?i({id:`demo-doc-`+Date.now(),filename:`demo-webpage.txt`,fileType:`txt`,size:0,sessionId:n,uploadedAt:Date.now()}):a.post(`/documents/fetch-url`,{url:e,sessionId:n}).then(e=>e.data),getDocuments:e=>{if(t())return i([]);let n=e?`/documents/session/${e}`:`/documents`;return a.get(n).then(e=>e.data)},getDocument:e=>t()?i({id:e,filename:`demo-document.pdf`,fileType:`pdf`,size:1024,content:`Demo document content...`,uploadedAt:Date.now()}):a.get(`/documents/${e}`).then(e=>e.data),searchDocuments:(e,n,r)=>t()?i([]):a.post(`/documents/search`,{query:e,sessionId:n,limit:r}).then(e=>e.data),deleteDocument:e=>t()?i(void 0):a.delete(`/documents/${e}`).then(e=>e.data),getEmbeddingStatus:()=>t()?i({available:!1,model:`nomic-embed-text`,chunksWithEmbeddings:0,totalChunks:0}):a.get(`/documents/embeddings/status`).then(e=>e.data),regenerateEmbeddings:()=>t()?i({documentsTotal:0,documentsRegenerated:0,documentsSkipped:0,chunksTotal:0,chunksEmbedded:0,model:`nomic-embed-text`,version:`v1`}):a.post(`/documents/embeddings/regenerate`).then(e=>e.data)},ee={getModels:()=>t()?i([{id:`nomic-embed-text`,name:`nomic-embed-text`,description:`Ollama - Default embedding model`,provider:`ollama`,dimensions:0,isDetectedEmbedding:!0}]):a.get(`/embeddings/models`).then(e=>e.data)},te={getNotes:()=>t()?i([]):a.get(`/notes`).then(e=>e.data),createNote:(e,t)=>a.post(`/notes`,{title:e,content:t}).then(e=>e.data),updateNote:(e,t)=>a.put(`/notes/${e}`,t).then(e=>e.data),deleteNote:e=>a.delete(`/notes/${e}`).then(e=>e.data)},x={getConfig:()=>t()?i({enabled:!1,available:!1,allowed:!1}):a.get(`/search/config`).then(e=>e.data),getAccess:()=>t()?i({mode:`admins`,allowed:!1}):a.get(`/search/access`).then(e=>e.data),setAccess:e=>t()?i({mode:e}):a.put(`/search/access`,{mode:e}).then(e=>e.data),setConfig:(e,n,r)=>t()?i({enabled:e,available:e,allowed:!1,url:n}):a.put(`/search/config`,{enabled:e,url:n,...r??{}}).then(e=>e.data),test:()=>t()?i({ok:!1,results:0},!1):a.post(`/search/test`).then(e=>e.data)},S={getModels:e=>t()?i([{id:`meta-llama/Llama-3.3-70B-Instruct`,modelId:`meta-llama/Llama-3.3-70B-Instruct`,author:`meta-llama`,downloads:1e6,likes:5e3,tags:[`text-generation`,`llama`],pipeline_tag:`text-generation`,gated:!1}]):a.get(`/huggingface-hub/models`,{params:e}).then(e=>e.data),getTrending:e=>t()?i([]):a.get(`/huggingface-hub/trending`,{params:e}).then(e=>e.data),getModel:(e,n)=>t()?i({id:`${e}/${n}`,modelId:`${e}/${n}`,author:e,downloads:0,likes:0,tags:[],gated:!1}):a.get(`/huggingface-hub/models/${e}/${n}`).then(e=>e.data),getTasks:()=>t()?i([`text-generation`,`text-to-speech`,`text-to-image`]):a.get(`/huggingface-hub/tasks`).then(e=>e.data),clearCache:()=>t()?i(!0):a.post(`/huggingface-hub/cache/clear`).then(e=>e.data),getGgufFiles:(e,n)=>t()?i([{filename:`model-Q4_K_M.gguf`,size:45e8,sizeFormatted:`4.19 GB`,quantization:`Q4_K_M`,url:`https://huggingface.co/${e}/${n}/resolve/main/model-Q4_K_M.gguf`,ollamaCommand:`hf.co/${e}/${n}:Q4_K_M`}]):a.get(`/huggingface-hub/models/${e}/${n}/gguf`).then(e=>e.data),hasGgufFiles:(e,n)=>t()?i({hasGguf:!1,count:0}):a.get(`/huggingface-hub/models/${e}/${n}/has-gguf`).then(e=>e.data)};function C(e,t){return t?t.aborted?Promise.reject(t.reason??new DOMException(`The operation was aborted`,`AbortError`)):new Promise((n,r)=>{let i=()=>{r(t.reason??new DOMException(`The operation was aborted`,`AbortError`))};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})}):e}var w={getModels:()=>t()?i([{model:`gpt-image-2`,plugin:`openai`,config:{sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}}]):a.get(`/image-gen/models`).then(e=>e.data),getPlugins:()=>t()?i([{id:`openai`,name:`OpenAI GPT Image`,models:[`gpt-image-2`,`gpt-image-1.5`,`gpt-image-1`,`gpt-image-1-mini`],config:{sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}}]):a.get(`/image-gen/plugins`).then(e=>e.data),getConfig:e=>t()?i({sizes:[`1024x1024`,`1536x1024`,`1024x1536`],default_size:`1024x1024`,qualities:[`auto`,`low`,`medium`,`high`],default_quality:`auto`}):a.get(`/image-gen/config/${e}`).then(e=>e.data),generate:(e,n)=>t()?C(i({images:[{url:`https://placehold.co/1024x1024/purple/white?text=Demo+Image`,revised_prompt:e.prompt}],model:e.model,pluginId:e.pluginId}),n):a.post(`/image-gen/generate`,e,{signal:n}).then(e=>e.data),getGallery:e=>t()?i({images:[],total:0}):a.get(`/image-gen/gallery`,{params:e}).then(e=>e.data),getGalleryImage:e=>t()?i({id:e,userId:`demo`,prompt:`Demo image prompt`,model:`dall-e-3`,imageData:`https://placehold.co/1024x1024/purple/white?text=Demo`,createdAt:Date.now()}):a.get(`/image-gen/gallery/${e}`).then(e=>e.data),deleteGalleryImage:e=>t()?i(void 0):a.delete(`/image-gen/gallery/${e}`).then(e=>e.data)},T={connected:!1,baseUrl:`http://127.0.0.1:8766`,dashboardUrl:`http://127.0.0.1:8766/dashboard`,error:`Libre Claw daemon is not connected in demo mode.`},E={access:()=>t()?i({enabled:!1,lockedByEnv:!1}):a.get(`/libre-claw/access`).then(e=>e.data),setAccess:e=>t()?i({enabled:e,lockedByEnv:!1}):a.put(`/libre-claw/access`,{enabled:e}).then(e=>e.data),status:()=>t()?i(T):a.get(`/libre-claw/status`).then(e=>e.data),dashboard:()=>t()?i({url:T.dashboardUrl}):a.get(`/libre-claw/dashboard`).then(e=>e.data),currentModel:()=>t()?i({provider:`openrouter`,model:`openrouter/auto`}):a.get(`/libre-claw/config/model`).then(e=>e.data),updateModel:(e,n,r=!1)=>t()?i({provider:e,model:n,persist_global:r}):a.patch(`/libre-claw/config/model`,{provider:e,model:n,persist_global:r}).then(e=>e.data),currentFallback:()=>t()?i({enabled:!1,routes:[]}):a.get(`/libre-claw/config/fallback`).then(e=>e.data),updateFallback:e=>t()?i(e):a.patch(`/libre-claw/config/fallback`,e).then(e=>e.data),updateTheme:(e,n=!0)=>t()?i({theme:e,label:e,persist_global:n}):a.patch(`/libre-claw/config/theme`,{theme:e,persist_global:n}).then(e=>e.data),usage:(e=``,n=250)=>{let r=new URLSearchParams({limit:String(n)});return e&&r.set(`provider`,e),t()?i({summary:{},records:[],text:``}):a.get(`/libre-claw/usage?${r.toString()}`).then(e=>e.data)},listRuns:(e=20)=>t()?i({runs:[]}):a.get(`/libre-claw/runs?limit=${e}`).then(e=>e.data),startRun:e=>{if(t()){let t=new Date().toISOString();return i({run:{run_id:`demo-${Date.now()}`,state:`queued`,title:e.message.slice(0,80)||`Libre Claw demo run`,kind:e.kind||`chat`,provider:e.provider||`openrouter`,model:e.model||`openrouter/auto`,working_directory:``,created_at:t,updated_at:t}})}return a.post(`/libre-claw/runs`,e).then(e=>e.data)},getRun:e=>t()?i({run_id:e}):a.get(`/libre-claw/runs/${encodeURIComponent(e)}`).then(e=>e.data),getEvents:(e,n=0)=>t()?i({events:[]}):a.get(`/libre-claw/runs/${encodeURIComponent(e)}/events?after=${n}`).then(e=>e.data),cancelRun:e=>t()?i({run_id:e,cancelled:!0}):a.post(`/libre-claw/runs/${encodeURIComponent(e)}/cancel`).then(e=>e.data),resolvePermission:(e,n,r)=>t()?i({run_id:e,tool_call_id:n,resolution:r}):a.post(`/libre-claw/runs/${encodeURIComponent(e)}/permissions/${encodeURIComponent(n)}`,{resolution:r}).then(e=>e.data),listAutomations:(e=50)=>t()?i({automations:[]}):a.get(`/libre-claw/automations?limit=${e}`).then(e=>e.data),createAutomation:e=>t()?i({...e,automation_id:`demo-${Date.now()}`}):a.post(`/libre-claw/automations`,e).then(e=>e.data),updateAutomation:(e,n)=>t()?i({...n,automation_id:e}):a.patch(`/libre-claw/automations/${encodeURIComponent(e)}`,n).then(e=>e.data),pauseAutomation:e=>t()?i({automation_id:e,status:`paused`}):a.post(`/libre-claw/automations/${encodeURIComponent(e)}/pause`).then(e=>e.data),resumeAutomation:e=>t()?i({automation_id:e,status:`active`}):a.post(`/libre-claw/automations/${encodeURIComponent(e)}/resume`).then(e=>e.data),runAutomationNow:e=>t()?i({automation_id:e,run:!0}):a.post(`/libre-claw/automations/${encodeURIComponent(e)}/run`).then(e=>e.data),deleteAutomation:e=>t()?i({automation_id:e,deleted:!0}):a.delete(`/libre-claw/automations/${encodeURIComponent(e)}`).then(e=>e.data)},D={getModels:()=>a.get(`/media/models`).then(e=>e.data),generateAudio:(e,t)=>a.post(`/media/audio/generate`,e,{signal:t}).then(e=>e.data),cloneVoice:(e,t)=>{let n=new FormData;return n.set(`model`,e.model),n.set(`pluginId`,e.pluginId),n.set(`input`,e.input),n.set(`reference_audio`,e.referenceAudio),e.referenceText&&n.set(`reference_text`,e.referenceText),e.responseFormat&&n.set(`response_format`,e.responseFormat),e.saveVoiceName&&n.set(`saveVoiceName`,e.saveVoiceName),e.consentToStore&&n.set(`consentToStore`,`true`),a.post(`/media/audio/voice-clone`,n,{signal:t}).then(e=>e.data)},generateSound:(e,t)=>a.post(`/media/sound/generate`,e,{signal:t}).then(e=>e.data),generateVideo:(e,t)=>a.post(`/media/video/generate`,e,{signal:t}).then(e=>e.data),getVideoJob:(e,t)=>a.get(`/media/video/jobs/${e}`,{signal:t}).then(e=>e.data),listVideoJobs:e=>a.get(`/media/video/jobs`,{params:e}).then(e=>e.data),resumeVideoJob:(e,t)=>a.post(`/media/video/jobs/${encodeURIComponent(e)}/resume`,void 0,{signal:t}).then(e=>e.data),cancelVideoJob:e=>a.delete(`/media/video/jobs/${encodeURIComponent(e)}`).then(e=>e.data),getGallery:e=>a.get(`/media/gallery`,{params:e}).then(e=>e.data),deleteGalleryItem:e=>a.delete(`/media/gallery/${e}`).then(e=>e.data),getGalleryContent:e=>a.get(`/media/gallery/${e}/content`,{responseType:`blob`}).then(e=>e.data)},O=(e,t,n)=>{let r=new AbortController,i=localStorage.getItem(`auth-token`);return(async()=>{try{let n=await fetch(e,{headers:{Accept:`text/event-stream`,...i?{Authorization:`Bearer ${i}`}:{}},cache:`no-store`,credentials:`same-origin`,signal:r.signal});if(!n.ok){let e=`Request failed with status ${n.status}`;try{let t=await n.json();typeof t.error==`string`?e=t.error:typeof t.message==`string`&&(e=t.message)}catch{}throw Error(e)}if(!n.body)throw Error(`Response stream is unavailable`);let a=n.body.getReader(),o=new TextDecoder,s=``;try{for(;!r.signal.aborted;){let{done:e,value:n}=await a.read();s+=o.decode(n,{stream:!e});let r=s.split(/\r?\n\r?\n/);s=r.pop()||``;for(let e of r){let n=e.split(/\r?\n/).find(e=>e.startsWith(`data:`));n&&t(JSON.parse(n.slice(5).trim()))}if(e)break}}finally{a.releaseLock()}}catch(e){r.signal.aborted||n(e instanceof Error?e.message:`Connection lost`)}})(),()=>r.abort()},k=`libre:models-changed`,A=()=>{window.dispatchEvent(new Event(k))},j={checkHealth:()=>t()?i({status:`offline`},!1):a.get(`/ollama/health`).then(e=>e.data),getModels:()=>t()?i(f):a.get(`/ollama/models`).then(e=>e.data),getModelAccess:()=>t()?i({mode:`admins`,allowed:!1}):a.get(`/ollama/models/access`).then(e=>e.data),setModelAccess:e=>t()?i({mode:e}):a.put(`/ollama/models/access`,{mode:e}).then(e=>e.data),getModelVisibility:()=>t()?i({hidden:[],order:[],metadata:{}}):a.get(`/ollama/models/visibility`).then(e=>e.data),setModelVisibility:e=>t()?i({hidden:e.hidden??[],order:e.order??[],metadata:e.metadata??{}}):a.put(`/ollama/models/visibility`,e).then(e=>e.data),pullModel:e=>t()?i(null,!1):a.post(`/ollama/models/pull`,{name:e}).then(e=>(A(),e.data)),pullModelStream:(e,r,i,a)=>{if(t()){let e=0,t=setInterval(()=>{e+=Math.random()*20,e>=100?(e=100,r({status:`success`,total:100,completed:100,percent:100}),clearInterval(t),setTimeout(()=>{A(),i()},500)):r({status:`pulling`,total:100,completed:e,percent:Math.round(e)})},1e3);return()=>clearInterval(t)}let o=new URLSearchParams({model:e});return O(`${n}/ollama/pull/stream?${o.toString()}`,e=>{switch(e.type){case`progress`:r({status:typeof e.status==`string`?e.status:`pulling`,digest:typeof e.digest==`string`?e.digest:void 0,total:typeof e.total==`number`?e.total:void 0,completed:typeof e.completed==`number`?e.completed:void 0,percent:typeof e.percent==`number`?e.percent:void 0});break;case`complete`:A(),i();break;case`error`:a(String(e.error||`Model pull failed`))}},a)},deleteModel:e=>t()?i(null,!1):a.delete(`/ollama/models`,{params:{name:e}}).then(e=>(A(),e.data)),getModelDefaults:e=>a.get(`/ollama/models/${encodeURIComponent(e)}/defaults`).then(e=>e.data),showModel:(e,n=!1)=>{if(t()){let t=f.find(t=>t.name===e);return i(t||null,!!t)}return a.get(`/ollama/models/show`,{params:{name:e,verbose:n}}).then(e=>e.data)},createModel:e=>t()?i(null,!1):a.post(`/ollama/models`,e).then(e=>(A(),e.data)),copyModel:(e,n)=>t()?i(null,!1):a.post(`/ollama/models/copy`,{source:e,destination:n}).then(e=>(A(),e.data)),pushModel:e=>t()?i(null,!1):a.post(`/ollama/models/push`,{name:e}).then(e=>e.data),pullAllModels:()=>t()?i(null,!1):a.post(`/ollama/models/pull-all`).then(e=>e.data),pullAllModelsStream:(e,r,i)=>{if(t()){let t=f,n=0,i=setInterval(()=>{n++,n<=t.length&&e({current:n,total:t.length,modelName:t[n-1]?.name||`demo-model`,status:Math.random()>.1?`success`:`error`,error:Math.random()>.1?void 0:`Demo error`}),n>=t.length&&(clearInterval(i),setTimeout(()=>{A(),r()},500))},1e3);return}O(`${n}/ollama/models/pull-all/stream`,t=>{switch(t.type){case`progress`:{let n=t.status===`success`||t.status===`error`?t.status:`starting`;e({current:typeof t.current==`number`?t.current:0,total:typeof t.total==`number`?t.total:0,modelName:typeof t.modelName==`string`?t.modelName:`unknown`,status:n,error:typeof t.error==`string`?t.error:void 0});break}case`complete`:A(),r();break;case`error`:i(String(t.error||`Model update failed`))}},i)},generateEmbeddings:e=>t()?i({embeddings:[[]]},!1):a.post(`/ollama/embed`,e).then(e=>e.data),listRunningModels:()=>t()?i([]):a.get(`/ollama/running`).then(e=>e.data),unloadModel:e=>t()?i(null):a.post(`/ollama/models/unload`,{name:e}).then(e=>e.data),unloadAllModels:()=>t()?i(null):a.post(`/ollama/models/unload-all`).then(e=>e.data),getVersion:()=>t()?i({version:`demo-mode`},!1):a.get(`/ollama/version`).then(e=>e.data),chatCompletion:e=>t()?i({message:{content:`Demo response`,role:`assistant`}},!1):a.post(`/ollama/chat`,e).then(e=>e.data),checkBlobExists:e=>t()?Promise.resolve(!1):a.head(`/ollama/blobs/${e}`).then(()=>!0).catch(()=>!1),pushBlob:(e,n)=>t()?i(null,!1):a.post(`/ollama/blobs/${e}`,n,{headers:{"Content-Type":`application/octet-stream`}}).then(e=>e.data),generateLegacyEmbeddings:e=>t()?i({embedding:[]},!1):a.post(`/ollama/embeddings`,e).then(e=>e.data),getLibraryModels:e=>{if(t())return e?.category===`cloud`?i([{name:`gpt-oss:cloud`,description:`Demo cloud model using Ollama cloud naming`,category:`cloud`,sizes:[`cloud`],pulls:`Cloud`,tags:[`cloud`]}]):i([{name:`llama3.2`,description:`Meta's latest Llama model`,category:`general`,sizes:[`1b`,`3b`],pulls:`50M+`,tags:[`general`]},{name:`deepseek-r1`,description:`Open reasoning model`,category:`reasoning`,sizes:[`7b`,`14b`,`32b`],pulls:`200M+`,tags:[`reasoning`]}]);let n=new URLSearchParams;e?.search&&n.set(`search`,e.search),e?.sort&&n.set(`sort`,e.sort),e?.category&&n.set(`category`,e.category);let r=n.toString();return a.get(`/ollama/library${r?`?${r}`:``}`).then(e=>e.data)}},M=[[`#2563eb`,`#7c3aed`],[`#0891b2`,`#2563eb`],[`#0f766e`,`#2563eb`],[`#be123c`,`#7c3aed`],[`#ff7b52`,`#dc2626`]],N=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)},P=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`),F=e=>{let t=e.trim().split(/[\s._-]+/).filter(Boolean);return t.length===0?`AI`:t.slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`AI`},I=(e,t=128)=>{let n=e.trim()||`AI Persona`,r=N(n),[i,a]=M[r%M.length],o=P(F(n)),s=`persona-avatar-${r}-${t}`,c=t>=96?44:24,l=`
3
- <svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}" role="img" aria-label="${P(n)} avatar">
4
- <defs>
5
- <linearGradient id="${s}" x1="0" y1="0" x2="1" y2="1">
6
- <stop offset="0%" stop-color="${i}" />
7
- <stop offset="100%" stop-color="${a}" />
8
- </linearGradient>
9
- </defs>
10
- <rect width="${t}" height="${t}" rx="${Math.round(t*.22)}" fill="url(#${s})" />
11
- <circle cx="${t*.22}" cy="${t*.22}" r="${t*.26}" fill="rgba(255,255,255,0.16)" />
12
- <text x="50%" y="52%" dominant-baseline="middle" text-anchor="middle" fill="white" font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="${c}" font-weight="700">${o}</text>
13
- </svg>
14
- `;return`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(l)}`},L=(e,t=128)=>e.avatar?.trim()||I(e.name,t),R=(e,t,n=128)=>{e.onerror=null,e.src=I(t,n)},z={getPersonas:()=>{if(t()){let e=[{id:`demo-1`,user_id:`default`,name:`Creative Assistant`,description:`Helpful assistant for creative tasks`,model:`llama3.3:latest`,parameters:{temperature:.8,top_p:.9,context_window:4096,system_prompt:`You are a creative and helpful assistant. Provide thoughtful and engaging responses.`},avatar:I(`Creative Assistant`,128),created_at:Date.now()-864e5,updated_at:Date.now()-864e5},{id:`demo-2`,user_id:`default`,name:`Research Assistant`,description:`Academic assistant for research and learning`,model:`qwen3:7b`,parameters:{temperature:.3,top_p:.8,context_window:8192,system_prompt:`You are a knowledgeable research assistant. Provide detailed, informative explanations.`},avatar:I(`Research Assistant`,128),created_at:Date.now()-1728e5,updated_at:Date.now()-1728e5}];return i(e)}return a.get(`/personas`).then(e=>e.data)},getPersona:e=>t()?i({id:e,user_id:`default`,name:`Sample Assistant`,description:`A sample assistant for demonstration`,model:`llama3.2:latest`,parameters:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},created_at:Date.now(),updated_at:Date.now()}):a.get(`/personas/${e}`).then(e=>e.data),createPersona:e=>{if(t()){let t={id:`demo-`+Date.now(),user_id:`default`,...e,created_at:Date.now(),updated_at:Date.now()};return i(t)}return a.post(`/personas`,e).then(e=>e.data)},updatePersona:(e,n)=>{if(t()){let t={id:e,user_id:`default`,name:n.name||`Updated Sample Assistant`,description:n.description,model:n.model||`llama3.2:latest`,parameters:n.parameters||{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},avatar:n.avatar,background:n.background,created_at:Date.now()-864e5,updated_at:Date.now()};return i(t)}return a.put(`/personas/${e}`,n).then(e=>e.data)},deletePersona:e=>t()?i(void 0):a.delete(`/personas/${e}`).then(e=>e.data),exportPersona:e=>{if(t()){let e={name:`Sample Assistant`,description:`A sample assistant for demonstration`,model:`llama3.2:latest`,params:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},exportedAt:Date.now(),version:`1.0.0`};return Promise.resolve(e)}return a.get(`/personas/${e}/export`).then(e=>e.data)},importPersona:e=>{if(t()){let t={id:`demo-imported-`+Date.now(),user_id:`default`,name:e.name,description:e.description,model:e.model,parameters:e.params,avatar:e.avatar,background:e.background,created_at:Date.now(),updated_at:Date.now(),embedding_model:e.embedding_model,memory_settings:e.memory_settings,mutation_settings:e.mutation_settings};return i(t)}return a.post(`/personas/import`,e).then(e=>e.data)},getPersonasCount:()=>t()?i({count:2}):a.get(`/personas/stats/count`).then(e=>e.data),getDefaultParameters:()=>t()?i({temperature:.7,top_p:.9,top_k:40,context_window:4096,max_tokens:1024,system_prompt:``,repeat_penalty:1.1,presence_penalty:0,frequency_penalty:0}):a.get(`/personas/defaults/parameters`).then(e=>e.data),getMemoryStatus:e=>t()?i({status:`active`,memory_count:42,last_backup:Date.now()-864e5,size_mb:2.3}):a.get(`/personas/${e}/memory/status`).then(e=>e.data),wipeMemories:e=>t()?i({deleted_count:42}):a.delete(`/personas/${e}/memory`).then(e=>e.data),backupPersona:e=>{if(t()){let t=JSON.stringify({persona_id:e,backup_date:new Date().toISOString(),data:`demo backup data`});return Promise.resolve(new Blob([t],{type:`application/json`}))}return a.get(`/personas/${e}/backup`,{responseType:`blob`}).then(e=>e.data)},exportPersonaDNA:e=>{if(t()){let t=JSON.stringify({persona_id:e,export_date:new Date().toISOString(),dna:`demo DNA data`,memories:[],learned_behaviors:{}});return Promise.resolve(new Blob([t],{type:`application/json`}))}return a.get(`/personas/${e}/export/dna`,{responseType:`blob`}).then(e=>e.data)},importPersonaDNA:e=>{if(t()){let e={id:`demo-dna-`+Date.now(),user_id:`default`,name:`Imported Persona`,description:`Persona imported from DNA`,model:`llama3.2:latest`,parameters:{temperature:.7,top_p:.9,context_window:4096,system_prompt:`You are a helpful assistant.`},created_at:Date.now(),updated_at:Date.now()};return i(e)}let n=new FormData;return n.append(`dnaFile`,e),a.post(`/personas/import/dna`,n).then(e=>e.data)},downloadPersona:async(e,t)=>{try{let n=await z.exportPersona(e),r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${t}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}catch(e){throw r.error(`Error while downloading persona:`,e),Error(`Failed to download persona: ${e instanceof Error?e.message:String(e)}`)}}},B=e=>{let t=Date.now();return{range:{from:t-Math.max(0,e-1)*864e5,to:t,days:e},totals:{calls:0,successfulCalls:0,failedCalls:0,cancelledCalls:0,meteredCalls:0,promptTokens:0,completionTokens:0,reportedTokens:0,averageLatencyMs:0,uniqueUsers:0},series:[],plugins:[],models:[],capabilities:[]}},V={getUsage:(e=30)=>t()?i(B(e)):a.get(`/plugins/usage`,{params:{days:e}}).then(e=>e.data),getAllPlugins:()=>t()?i([]):a.get(`/plugins`).then(e=>e.data),discoverModels:e=>t()?i({models:[],outcome:`unavailable`}):a.post(`/plugins/discover/${encodeURIComponent(e)}`).then(e=>e.data),uploadPlugin:e=>{if(t())return i({},!1);let n=new FormData;return n.append(`plugin`,e),a.post(`/plugins/upload`,n).then(e=>e.data)},installPlugin:e=>t()?i({},!1):a.post(`/plugins/install`,e).then(e=>e.data),updatePlugin:(e,n)=>t()?i({},!1):a.put(`/plugins/${e}`,n).then(e=>e.data),deletePlugin:e=>t()?i(void 0):a.delete(`/plugins/${e}`).then(e=>e.data),activatePlugin:e=>t()?i(!1,!1):a.post(`/plugins/activate/${e}`).then(e=>e.data),deactivatePlugin:e=>{if(t())return i(void 0);let n=e?`/plugins/deactivate/${e}`:`/plugins/deactivate`;return a.post(n).then(e=>e.data)},getActivePlugin:()=>t()?i(null):a.get(`/plugins/active`).then(e=>e.data),getPluginStatus:()=>t()?i([]):a.get(`/plugins/status`).then(e=>e.data),exportPlugin:e=>t()?Promise.resolve(new Blob([`{}`],{type:`application/json`})):a.get(`/plugins/${e}/export`,{responseType:`blob`}).then(e=>e.data),getCredentials:()=>t()?i([]):a.get(`/plugins/credentials/all`).then(e=>e.data),setApiKey:(e,n)=>t()?i(!1,!1):a.post(`/plugins/${e}/credentials`,{api_key:n}).then(e=>e.data),deleteApiKey:e=>t()?i(!1,!1):a.delete(`/plugins/${e}/credentials`).then(e=>e.data),checkApiKey:e=>t()?i(!1):a.get(`/plugins/${e}/credentials/check`).then(e=>e.data),getVariables:e=>t()?i({}):a.get(`/plugins/${e}/variables`).then(e=>e.data),setVariables:(e,n,r=[])=>t()?i(!0):a.put(`/plugins/${e}/variables`,{variables:n,unset:r}).then(e=>e.data),resetVariables:e=>t()?i(!0):a.delete(`/plugins/${e}/variables`).then(e=>e.data)},H=`libre-webui-user-data`,U=`libre-webui-export`,W=new Set([2,3]);function G(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(e=>G(e)).join(`,`)}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${G(e[t])}`).join(`,`)}}`}async function K(e){let{integrity:t,...n}=e,r=JSON.parse(JSON.stringify(n)),i=await globalThis.crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(G(r)));return Array.from(new Uint8Array(i),e=>e.toString(16).padStart(2,`0`)).join(``)}function q(e){let t;try{t=JSON.parse(e)}catch{throw Error(`Portable archive is not valid JSON.`)}if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Portable archive must contain a JSON object.`);let n=t;if(n.format===H){if(!W.has(n.version))throw Error(`Unsupported portable archive version ${String(n.version)}.`);return n}if(n.format===U)return n;throw Error(`This file is not a Libre WebUI portable archive.`)}var J=[{key:`accountAndAuthentication`,reason:`Account and authentication records are not portable.`},{key:`providerSecrets`,reason:`Provider credentials must be configured again.`},{key:`voiceProfiles`,reason:`Voice reference audio is biometric data and is not portable.`},{key:`personasAndMemory`,reason:`Personas and persona memory are not part of archive version 3.`},{key:`generatedMedia`,reason:`Generated media library files are not portable.`},{key:`work`,reason:`Work data and volumes require a system backup.`},{key:`derivedEmbeddings`,reason:`Document embeddings can be regenerated after import.`}];function Y(e,t){if(typeof File<`u`&&e instanceof File){let n=new FormData;return n.append(`archive`,e),n.append(`strategy`,t),n}return{data:e,strategy:t}}var X={getPreferences:()=>t()?i(_()):a.get(`/preferences`).then(e=>e.data),updatePreferences:e=>t()?i(v(e)):a.put(`/preferences`,e).then(e=>e.data),setDefaultModel:(e,n,r)=>t()?i(v({defaultModel:e,defaultProviderType:n,defaultProviderId:n===`plugin`||n===`agent`?r:null})):a.put(`/preferences/default-model`,{model:e,providerType:n,providerId:r}).then(e=>e.data),setSystemMessage:e=>t()?i(v({systemMessage:e})):a.put(`/preferences/system-message`,{message:e}).then(e=>e.data),setGenerationOptions:e=>t()?i(v({generationOptions:e})):a.put(`/preferences/generation-options`,e).then(e=>e.data),setModelGenerationOptions:(e,t)=>a.put(`/preferences/model-generation-options`,{model:e,options:t}).then(e=>e.data),resetGenerationOptions:()=>t()?i(v({generationOptions:h.generationOptions})):a.post(`/preferences/generation-options/reset`).then(e=>e.data),setEmbeddingSettings:e=>t()?i(v({embeddingSettings:e})):a.put(`/preferences/embedding-settings`,e).then(e=>e.data),resetEmbeddingSettings:()=>t()?i(v({embeddingSettings:h.embeddingSettings})):a.post(`/preferences/embedding-settings/reset`).then(e=>e.data),exportData:async()=>{if(t()){let e={format:`libre-webui-user-data`,version:3,exportedAt:new Date().toISOString(),preferences:_(),sessionFolders:[],sessions:[],notes:[],knowledgeCollections:[],documents:[],exclusions:J};return i({...e,integrity:{algorithm:`sha256`,canonicalization:`libre-json-sort-v1`,digest:await K(e)}})}return a.get(`/preferences/export`).then(e=>e.data)},preflightImport:(e,n)=>t()?i({valid:!0,format:`libre-webui-user-data`,version:3,strategy:n,incoming:{sessionFolders:0,sessions:0,messages:0,notes:0,knowledgeCollections:0,documents:0,documentChunks:0},result:{format:`libre-webui-user-data`,version:3,strategy:n,sessionFolders:{imported:0,overwritten:0,skipped:0},sessions:{imported:0,overwritten:0,skipped:0},notes:{imported:0,overwritten:0,skipped:0},knowledgeCollections:{imported:0,overwritten:0,skipped:0},documents:{imported:0,overwritten:0,skipped:0},remappedIds:0,warnings:[],exclusions:[]},warnings:[],exclusions:[]}):a.post(`/preferences/import/preflight`,Y(e,n)).then(e=>e.data),importData:(e,n=`skip`)=>t()?i({format:`libre-webui-user-data`,version:3,strategy:n,preferences:{imported:!0,mode:n===`overwrite`?`replace`:`merge`},sessionFolders:{imported:0,overwritten:0,skipped:0},sessions:{imported:0,overwritten:0,skipped:0},notes:{imported:0,overwritten:0,skipped:0},knowledgeCollections:{imported:0,overwritten:0,skipped:0},documents:{imported:0,overwritten:0,skipped:0},remappedIds:0,warnings:[],exclusions:[]}):a.post(`/preferences/import`,Y(e,n)).then(e=>e.data)},Z={getDiagnostics:()=>a.get(`/system`).then(e=>e.data)};function Q(e,t,n){if(t)return e.find(e=>e.model===t&&(!n||e.plugin===n))}function ne(e,t,n){return Q(e,t,n)||e[0]}function re(e){return`${encodeURIComponent(e.plugin)}::${encodeURIComponent(e.model)}`}var $={getModels:()=>t()?i([{model:`tts-1`,plugin:`openai`,config:{voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`,formats:[`mp3`,`opus`,`aac`,`flac`,`wav`],default_format:`mp3`,max_characters:4096}}]):a.get(`/tts/models`).then(e=>e.data),getPlugins:()=>t()?i([{id:`openai`,name:`OpenAI GPT`,models:[`tts-1`,`tts-1-hd`],config:{voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`}}]):a.get(`/tts/plugins`).then(e=>e.data),getVoiceProfiles:(e={})=>t()?i([]):a.get(`/tts/voice-profiles`,{params:{pluginId:e.pluginId||void 0,model:e.model||void 0}}).then(e=>e.data),deleteVoiceProfile:async e=>{t()||await a.delete(`/tts/voice-profiles/${encodeURIComponent(e)}`)},getVoices:e=>t()?i({voices:[`alloy`,`echo`,`fable`,`onyx`,`nova`,`shimmer`],default_voice:`alloy`,formats:[`mp3`,`opus`,`aac`,`flac`,`wav`],default_format:`mp3`,max_characters:4096,supports_streaming:!1,supports_voice_cloning:!1,clone_requires_transcript:!1}):a.get(`/tts/voices/${e}`).then(e=>e.data),generateBase64:e=>{if(t())return i({audio:``,format:e.response_format||`mp3`,mimeType:`audio/mpeg`,size:0});let n={...e,pluginId:e.pluginId||void 0};return a.post(`/tts/generate-base64`,n).then(e=>e.data)},generate:async(e,n={})=>{if(t())return new Blob([],{type:`audio/mpeg`});let r={...e,pluginId:e.pluginId||void 0};return(await a.post(`/tts/generate`,r,{responseType:`blob`,signal:n.signal})).data},speak:async(e,t={})=>{try{t.onStart?.();let n=await $.generateBase64({model:t.model||`tts-1`,pluginId:t.pluginId,input:e,voice:t.voice,voiceProfileId:t.voiceProfileId,speed:t.speed,response_format:t.responseFormat});if(!n.success||!n.data?.audio)throw Error(n.message||`Failed to generate speech`);let r=`data:${n.data.mimeType};base64,${n.data.audio}`,i=new Audio(r);return i.onended=()=>t.onEnd?.(),i.onerror=()=>t.onError?.(Error(`Audio playback failed`)),await i.play(),i}catch(e){let n=e instanceof Error?e:Error(`Unknown error`);return t.onError?.(n),null}}},ie={getModels:()=>t()?i([]):a.get(`/stt/models`).then(e=>e.data),transcribe:async(e,t,n={})=>{let r=new FormData,i=ae(e.type);r.append(`audio`,e,`recording.${i}`),r.append(`model`,t.model),r.append(`pluginId`,t.plugin),n.language&&r.append(`language`,n.language);let o=await a.post(`/stt/transcribe`,r,{signal:n.signal});if(!o.data.success||!o.data.data)throw Error(o.data.message||o.data.error||`Transcription failed`);return o.data.data}};function ae(e){let t=e.split(`;`,1)[0].toLowerCase();return t.includes(`webm`)?`webm`:t.includes(`ogg`)?`ogg`:t.includes(`wav`)?`wav`:t.includes(`flac`)?`flac`:t.includes(`mp4`)||t.includes(`m4a`)?`m4a`:`mp3`}var oe=e({MODELS_CHANGED_EVENT:()=>k,agentCliApi:()=>o,personaApi:()=>z,preferencesApi:()=>X});export{ee as C,l as D,c as E,u as O,b as S,d as T,E as _,ne as a,x as b,X as c,z as d,L as f,D as g,j as h,re as i,q as l,k as m,ie as n,$ as o,R as p,Q as r,Z as s,oe as t,V as u,w as v,y as w,te as x,S as y};